source: cprs/branches/tmg-cprs/m_files/TMGWIN01.m@ 1522

Last change on this file since 1522 was 796, checked in by Kevin Toppenberg, 14 years ago

Initial upload

File size: 5.9 KB
Line 
1TMGWIN01 ;TMG/kst/OO Window Object ;04/18/07
2 ;;1.0;TMG-LIB;**1**;04/18/07
3
4 ;"Kevin Toppenberg MD
5 ;"GNU General Public License (GPL) applies
6 ;"------------------------------------------
7 ;"Object oriented window object setup code below
8 ;"------------------------------------------
9
10Constructor(instanceName) ;"Module MUST have 'Constructor' procedure
11 ;"Purpose -- A constructor for object Window
12 ;"Input: instanceName -- the NAME of the type of the object to be defined.
13 ;" This should be a variable (global or otherwise) of the object.
14 ;"Note: This function should NOT be called directly, but instead is called
15 ;" via new^TMGOOL
16 ;"Result: none <--- REQUIRED TO NOT RETURN A RESULT
17
18 ;"Here we define the default values for vars and functions.
19
20 ;"----------------All constructors should copy this format --------------------
21 new TMGthis set TMGthis=instanceName
22
23 do inheritFrom^TMGOOL(instanceName,"TMGWGOJ")
24
25 ;"---------------------------------------------------------
26 ;"Declare PROCEDURES/FUNCTIONS
27
28 ;"Note: to use a procedure/function, use this format:
29 ;" do proc^TMGOOL(instanceName,"SET TOP",MyTopVar),!
30 ;" set MyTop=$$fn^TMGOOL(instanceName,"GET TOP")
31
32 do regFn^TMGOOL(TMGthis,"PAINT","Paint^TMGWIN01()")
33
34 ;"---------------------------------------------------------------------
35 ;"Register Event Handlers
36 do regEvent^TMGOOL(TMGthis,"SHIFT-CLICK","HandleSClick^TMGWIN01(LOC)")
37 do regEvent^TMGOOL(TMGthis,"CLICK","HandleClick^TMGWIN01(LOC)")
38
39 ;"--------------------------------------------------------------------------------
40 ;"Optional initialization of some instance-specific variables.
41
42 do setProp^TMGOOL(TMGthis,"FRAME","SIZABLE") ;"change default to BE resizable
43
44 ;"--------------------------------------------------------------------------------
45 ;"Startup code here...
46
47 quit
48
49
50Destructor(instanceName) ;"Module MUST have 'Destructor' procedure
51 ;"Purpose: A destructor for object Widget
52 ;" any needed clean up code would go here first.
53 ;"Input: instanceName -- the name of the object instance to be deleted.
54 ;" This should be the value returned from defWidget
55 ;"Note: Don't actually delete the object here. Just perform code needed to
56 ;" save the object variables etc. Anything neeed before the object
57 ;" is deleted by delete^TMGOOL
58
59 ;"-----------------
60
61 ;" Here I would put code that needs to be called before destruction of the object.
62
63 ;"-----------------
64
65 quit
66
67
68 ;"------------------------------------------
69 ;"Object member functions below
70 ;"------------------------------------------
71
72 ;"Note: A variable (with global scope) TMGthis is available as a 'this' pointer (this instance)
73 ;"Note: ALL members must have QUIT xx (even if xx is meaningless, as in a procedure)
74
75Paint()
76 ;"Purpose: To paint the current window (and all children windows)
77 ;"Input: instanceName -- the name/ref of this instance
78
79 ;"call inherited (this effects paint of children too)
80 do procInh^TMGOOL(TMGthis,"TMGWIN01","PAINT")
81
82 ;"do Specializations to paint here...
83
84 new T,L,B,R,LOC
85 new scrap set scrap=$$getProp^TMGOOL(TMGthis,"LOC",.LOC)
86 do proc^TMGOOL(TMGthis,"CONVERT TO FRAME",.LOC,"SCREEN")
87 set T=+$get(LOC("TOP")),L=+$get(LOC("LEFT"))
88 set B=+$get(LOC("BOTTOM")),R=+$get(LOC("RIGHT"))
89
90 do proc^TMGOOL(TMGthis,"CLIP TO PARENT",TMGthis)
91
92 new selected set selected=($$getProp^TMGOOL(TMGthis,"STATE")="SELECTED")
93 new focused set focused=$$fn^TMGOOL(TMGthis,"IS FOCUSED")
94 if $$getProp^TMGOOL(TMGthis,"RESIZING FLAGS")'="" goto P2
95
96 if (selected)!(focused) do CHGA^TMGXGF("I1")
97 new title set title="="_$$getProp^TMGOOL(TMGthis,"TITLE")
98 if title="" goto P2
99 new w set w=$$getProp^TMGOOL(TMGthis,"WIDTH")
100 for quit:($length(title)>(w-2)) set title=title_"="
101 if title'="" do SAY^TMGXGF(T,L+1,title,"")
102 do SAY^TMGXGF(T,R-4,"v^X","")
103 if (selected)!(focused) do CHGA^TMGXGF("I0")
104
105P2
106 quit 0
107
108
109HandleClick(LOC)
110 ;"Purpose: do something here with a mouse click. Note: descendents can
111 ;" overwrite this function to customize their control.
112 ;"Input: LOC -- PASS BY REFERNCE. Expected input format:
113 ;" coordinates in LOCAL frame of refeernces.
114 ;" LOC("TOP")=
115 ;" LOC("LEFT")=
116 ;" LOC("HEIGHT")= ;"optional
117 ;" LOC("WIDTH")= ;"optional
118 ;" LOC("BOTTOM")= ;"optional
119 ;" LOC("RIGHT")= ;"optional
120
121 ;"Click belongs to this window, so handle it.
122 ;"Put click handler code here
123
124 do fireInhEvent^TMGOOL(TMGthis,"TMGWIN01","CLICK",.LOC)
125
126 ;"...
127ACDone
128 quit ;"<-- required: NO return value for event handler
129
130
131HandleSClick(LOC)
132 ;"Purpose: do something here with a mouse shift click. Note: descendents can
133 ;" overwrite this function to customize their control.
134 ;"Input: LOC -- PASS BY REFERNCE. Expected input format:
135 ;" coordinates in LOCAL frame of refeernces.
136 ;" LOC("TOP")=
137 ;" LOC("LEFT")=
138 ;" LOC("HEIGHT")= ;"optional
139 ;" LOC("WIDTH")= ;"optional
140 ;" LOC("BOTTOM")= ;"optional
141 ;" LOC("RIGHT")= ;"optional
142
143 ;"Click belongs to this window, so handle it.
144
145 do fireInhEvent^TMGOOL(TMGthis,"TMGWIN01","SHIFT-CLICK",.LOC)
146
147 ;"...
148ADCDone
149 quit ;"<-- required: NO return value for event handler
150
151
152 ;"------------------------------------------
153 ;"Private functions below
154 ;"------------------------------------------
155
Note: See TracBrowser for help on using the repository browser.