PageRenderTime 38ms CodeModel.GetById 36ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/lib/CTextControl.ahk

http://github.com/Skiouros/Macro
AutoHotKey | 62 lines | 36 code | 0 blank | 26 comment | 3 complexity | 1e31d912346e09acca521175eae883e4 MD5 | raw file
 1/*
 2Class: CTextControl
 3A static text control that can also be used as hyperlink.
 4
 5This control extends <CControl>. All basic properties and functions are implemented and documented in this class.
 6*/
 7Class CTextControl Extends CControl
 8{
 9	__New(Name, Options, Text, GUINum)
10	{
11		Base.__New(Name, Options, Text, GUINum)
12		this.Type := "Text"
13		this._.Insert("ControlStyles", {Center : 0x1, Left : 0, Right : 0x2, Wrap : -0xC})
14		this._.Insert("Events", ["Click", "DoubleClick"])
15	}
16	/*
17	Variable: Link
18	If true, the control will appear like a hyperlink. To react to a click, implement the Click() event.
19	*/
20	__Set(Name, Value)
21	{
22		;~ global CGUI
23		if(Name = "Link")
24		{
25			WM_SETCURSOR := 0x20
26			WM_MOUSEMOVE := 0x200
27			WM_NCMOUSELEAVE := 0x2A2
28			WM_MOUSELEAVE := 0x2A3
29			if(Value)
30			{
31				CGUI.GUIList[this.GUINum].OnMessage(WM_SETCURSOR, "HandleInternalMessage")
32				CGUI.GUIList[this.GUINum].OnMessage(WM_MOUSEMOVE, "HandleInternalMessage")
33			}
34			this._.Link := Value > 0
35			this.Font.Options := "cBlue"
36		}
37	}
38	__Get(Name)
39	{
40		if(Name = "Link")
41			return this._.Link
42	}
43	/*
44	Event: Introduction
45	To handle control events you need to create a function with this naming scheme in your window class: ControlName_EventName(params)
46	The parameters depend on the event and there may not be params at all in some cases.
47	Additionally it is required to create a label with this naming scheme: GUIName_ControlName
48	GUIName is the name of the window class that extends CGUI. The label simply needs to call CGUI.HandleEvent(). 
49	For better readability labels may be chained since they all execute the same code.
50	Instead of using ControlName_EventName() you may also call <CControl.RegisterEvent> on a control instance to register a different event function name.
51	
52	Event: Click()
53	Invoked when the user clicked on the control.
54	
55	Event: DoubleClick()
56	Invoked when the user double-clicked on the control.
57	*/
58	HandleEvent(Event)
59	{
60		this.CallEvent(Event.GUIEvent = "DoubleClick" ? "DoubleClick" : "Click")
61	}
62}