PageRenderTime 51ms CodeModel.GetById 47ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 1ms

/lib/CProgressControl.ahk

http://github.com/Skiouros/Macro
AutoHotKey | 79 lines | 59 code | 1 blank | 19 comment | 20 complexity | 319078378a6c756667dc0c33d14ef878 MD5 | raw file
 1/*
 2Class: CProgressControl
 3A Progress control.
 4
 5This control extends <CControl>. All basic properties and functions are implemented and documented in this class.
 6*/
 7Class CProgressControl Extends CControl
 8{
 9	__New(Name, Options, Text, GUINum)
10	{
11		Base.__New(Name, Options, Text, GUINum)
12		this.Type := "Progress"
13		this._.Insert("ControlStyles", {Vertical : 0x4, Smooth : 0x1, Marquee : 0x8})
14		;TODO: Range in options is not parsed but could potentially be set by the user
15		this._.Insert("Min", 0)
16		this._.Insert("Max", 100)
17	}	
18	
19	/*
20	Variable: Value
21	The Value of the progress indicator. Relative offsets are possible by adding a sign when assigning it, i.e. Progress.Value := "+10". Progress.Value += 10 is also possible but less efficient.
22	
23	Variable: Min
24	The minimum value of the progress indicator.
25	
26	Variable: Max
27	The maximum value of the progress indicator.
28	*/
29	__Get(Name, Params*)
30	{
31		;~ global CGUI
32		if(Name != "GUINum" && !CGUI.GUIList[this.GUINum].IsDestroyed)
33		{
34			DetectHidden := A_DetectHiddenWindows
35			DetectHiddenWindows, On
36			if(Name = "Value")
37				GuiControlGet, Value, % this.GUINum ":", % this.ClassNN
38			else if(Name = "Min")
39				Value := this._.Min
40			else if(Name = "Max")
41				Value := this._.Max
42			Loop % Params.MaxIndex()
43				if(IsObject(Value)) ;Fix unlucky multi parameter __GET
44					Value := Value[Params[A_Index]]
45			if(!DetectHidden)
46				DetectHiddenWindows, Off
47			if(Value != "")
48				return Value
49		}
50	}
51	__Set(Name, Value, Params*)
52	{
53		;~ global CGUI
54		if(!CGUI.GUIList[this.GUINum].IsDestroyed)
55		{
56			DetectHidden := A_DetectHiddenWindows
57			DetectHiddenWindows, On
58			Handled := true
59			if(Name = "Value")
60				GuiControl, % this.GUINum ":", % this.ClassNN, %Value%
61			else if(Name = "Min")
62			{
63				GuiControl, % this.GUINum ":+Range" Value "-" this._.Max, % this.ClassNN
64				this._.Min := Value
65			}
66			else if(Name = "Max")
67			{
68				GuiControl, % this.GUINum ":+Range" this._.Min "-" Value, % this.ClassNN
69				this._.Max := Value
70			}
71			else
72				Handled := false
73			if(!DetectHidden)
74				DetectHiddenWindows, Off
75			if(Handled)
76				return Value
77		}
78	}
79}