ChrisS85/CGUI — Issue #42: GUI-geometry?
Author: hoppfrosch
Created: 2012-01-19 13:17:28+00:00
State: open

The geometry of the GUI (x,y,width,height) does not seem to be handled correctly. I tested with width and height (not with x and y yet) and do have following observations/remarks/bugs ...

Base Code from your CSharpGuiConverter.ahk:
----
001: Class CSharpGuiConverter Extends CGUI
002: {
003:	label1	:= this.AddControl("Text", "label1", "x12 y15 w53 h13", "Input File:")
004:	txtInput	:= this.AddControl("Edit", "txtInput", "x71 y14 w274 h20", "")
005:	btnInput	:= this.AddControl("Button", "btnInput", "x351 y12 w36 h23", "...")
006:	label2	:= this.AddControl("Text", "label2", "x12 y41 w61 h13", "Output File:")
007:	txtOutput	:= this.AddControl("Edit", "txtOutput", "x71 y40 w274 h20", "")
008:	btnOutput	:= this.AddControl("Button", "btnOutput", "x351 y38 w36 h23", "...")
009:	btnConvert	:= this.AddControl("Button", "btnConvert", "x15 y66 w120 h23", "Convert")
010:	btnRun	:= this.AddControl("Button", "btnRun", "x141 y66 w120 h23", "Run Converted File")
011:	btnEdit	:= this.AddControl("Button", "btnEdit", "x267 y66 w120 h23", "Edit Converted File")
012:	__New()
013:	{
014:	IniRead, in, %A_ScriptName%.ini,Settings, In, %A_Space%
015:	IniRead, out, %A_ScriptName%.ini,Settings, Out, %A_Space%
016:
017:	this.txtInput.Text := in
018:	this.txtOutput.Text := out
019:
020:	this.btnConvert.Enabled := FileExist(in) && strlen(out) > 1
021:	this.btnRun.Enabled := 0
022:	this.btnEdit.Enabled := 0
023:
024:	MsgBox % this.x " - " this.y " - " this.Width " - " this.Height ; TEST A
025:	this.height := 116
026:	this.Title := "C# GUI Converter"
027:	this.Width := 401
028:	MsgBox % this.x " - " this.y " - " this.Width " - " this.Height
029:	this.DestroyOnClose := true
030:	this.Show()
031:	}
--------

1.) Initialization (Line 024)
TestResult: MsgBox shows " 0 - 0 - 0 - "
* this.Height is unititialized - whereas this.x, this.y, this.Width are initialized to zero

2.) What are/should be the impacts of setting this.width (or height or x or y)
2.a.) If width is not set by user (Omitting line 025): As the GUI contains already some controls (Line 002 ... Line 011) the GUI does have some default width (which seems to be correct - as the GUI is drawn to show all added controls). In this case this.width should be set to the "default value" (= "calculated width") ...
2.b.) What should be the behaviour if this.width is set explictly? Should the size of the drawn GUI be "this.width" - or "calculated width"? I think it has to be "this.width" - which isn't the case yet. (Change line 027 to "this.Width := 801" and run the example - the drawn GUI has the same size as before, "this.Width" is unconsidered .... -> ERROR!)

Coming back to 1.) this.Width should not show up as "0" in line 024 - better it should show up as "calculated width"

3.) this.width should always have a valid value. I would like to do something like this:
(Nonsense example in context of example above - but demonstrates what I mean (for example: Placing a button in the lower left corner of GUI, width over the whole GUI)
024a: margin := 20
024b: this.btnEdit.x := margin
024c: this.btnEdit.y := this.height - margin
024d: this.btnEdit.width := this.width - 2*margin

BTW: as the GUI uses some default margin, it would be nice to have a Getter() for this value ... ;-)

=> Summary:
Geometric properties of GUI should be considered correctly (2.b) - and they always should contain the current width of the GUI (1/2.a)