forked from ChrisS85/CGUI
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathCCompoundControl.ahk
79 lines (77 loc) · 1.74 KB
/
CCompoundControl.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
;This is the base class for compound controls which consist of multiple controls. Examples include a path control with an edit field and a browse button or a synchronized list
Class CCompoundControl
{
Container := {}
Name := "Compound Control"
Boundaries := ""
AddContainerControl(GUI, Type, Name, Options, Text)
{
this.Container.Insert(Name, GUI.AddControl(Type, Name, Options, Text))
}
__Get(Key)
{
if Key in x,y,Width,Height
{
if(!IsObject(this.Boundaries))
this.CalculateBoundaries()
return this.Boundaries[Key]
}
}
__Set(Key, Value)
{
if Key in x,y
{
this.CalculateBoundaries()
if(Key = "X")
{
DeltaX := Value - this.Boundaries.X
for index, Control in this.Container
Control.X := Control.X + DeltaX
return this.Boundaries.X += DeltaX
}
if(Key = "Y")
{
DeltaY := Value - this.Boundaries.Y
for index, Control in this.Container
Control.Y := Control.Y + DeltaY
return this.Boundaries.Y += DeltaY
}
}
;Don't allow storing Width/Height keys. The implementing Compound object needs to handle these keys.
if Key in Width,Height
return this.Boundaries[Key]
}
CalculateBoundaries()
{
x := 0x7fFFffFF
y := 0x7fFFffFF
w := 0
h := 0
for index, control in this.Container
{
Position := control.Position
Size := control.Size
if(Position.x < x)
x := Position.x
if(Position.y < y)
y := Position.y
if(Position.x + Size.Width < w)
w := Position.w
if(Position.y + Size.Height < h)
h := Position.h
}
this.Boundaries := {x : x, y : y, width : w, height : h}
}
Hide()
{
this.Visible := false
for name, ctrl in this.Container
ctrl.Hide()
}
Show()
{
this.Visible := true
for name, ctrl in this.Container
ctrl.Show()
}
}