author | Claus Gittinger <cg@exept.de> |
Thu, 07 Mar 1996 13:25:36 +0100 | |
changeset 509 | 3e4d2800717a |
parent 502 | 0df8d2b173e4 |
child 612 | 8758d0c9933e |
permissions | -rw-r--r-- |
0 | 1 |
" |
2 |
COPYRIGHT (c) 1992 by Claus Gittinger |
|
80 | 3 |
All Rights Reserved |
0 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
13 |
Object subclass:#Controller |
|
413
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
14 |
instanceVariableNames:'model view sensor' |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
15 |
classVariableNames:'' |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
16 |
poolDictionaries:'' |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
17 |
category:'Interface-Support-Controllers' |
0 | 18 |
! |
19 |
||
46 | 20 |
!Controller class methodsFor:'documentation'! |
21 |
||
22 |
copyright |
|
23 |
" |
|
24 |
COPYRIGHT (c) 1992 by Claus Gittinger |
|
80 | 25 |
All Rights Reserved |
0 | 26 |
|
46 | 27 |
This software is furnished under a license and may be used |
28 |
only in accordance with the terms of that license and with the |
|
29 |
inclusion of the above copyright notice. This software may not |
|
30 |
be provided or otherwise made available to, or used by, any |
|
31 |
other person. No title to or ownership of the software is |
|
32 |
hereby transferred. |
|
33 |
" |
|
34 |
! |
|
0 | 35 |
|
46 | 36 |
documentation |
37 |
" |
|
38 |
Controllers can be used to controll the user-interactions |
|
413
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
39 |
to a model which is shown in a view. |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
40 |
|
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
41 |
For very simple views (and due to the evolution of Smalltalk/X), |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
42 |
many view-classes have the controller function integrated. |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
43 |
|
80 | 44 |
To allow both controller and non-controller operation, events are |
413
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
45 |
sent directly to the view, if the view has no controller |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
46 |
(i.e. if its controller instance variable is nil). |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
47 |
Otherwise, the controller gets the event message. |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
48 |
|
89 | 49 |
For now (vsn 2.10.4) there are only a few view classes using controllers; |
50 |
however, over time, more will be converted, since separating the controller |
|
127 | 51 |
offers much more flexibility |
52 |
(although view initialization becomes a bit more complex). |
|
46 | 53 |
|
413
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
54 |
Over time, expect the buttonPress/Release/Motion and keyPress/Release |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
55 |
methods to vanish from the view classes and corresponding controllers to |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
56 |
be appearing. |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
57 |
This migration should be backward compatible. |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
58 |
|
46 | 59 |
Instance variables: |
413
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
60 |
view <View> the view I control |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
61 |
|
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
62 |
model <Model> the model which is to be worked on |
46 | 63 |
" |
64 |
! ! |
|
0 | 65 |
|
89 | 66 |
!Controller class methodsFor:'instance creation'! |
67 |
||
68 |
new |
|
69 |
^ self basicNew initialize |
|
70 |
! ! |
|
71 |
||
99 | 72 |
!Controller methodsFor:'ST-80 compatibility'! |
73 |
||
413
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
74 |
controlInitialize |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
75 |
^ self |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
76 |
! |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
77 |
|
99 | 78 |
open |
79 |
"open my view" |
|
80 |
||
81 |
view open |
|
82 |
! ! |
|
83 |
||
413
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
84 |
!Controller methodsFor:'ST-80 compatibility events'! |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
85 |
|
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
86 |
blueButtonActivity |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
87 |
"actually, this should be called 'rightButtonActivity'. |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
88 |
But for ST-80 compatibility ...." |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
89 |
|
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
90 |
^ self |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
91 |
! |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
92 |
|
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
93 |
redButtonActivity |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
94 |
"actually, this should be called 'leftButtonActivity'. |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
95 |
But for ST-80 compatibility ...." |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
96 |
|
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
97 |
^ self |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
98 |
! |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
99 |
|
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
100 |
yellowButtonActivity |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
101 |
"actually, this should be called 'middleButtonActivity'. |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
102 |
But for ST-80 compatibility ...." |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
103 |
|
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
104 |
|menu actionSelector menuPerformer| |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
105 |
|
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
106 |
" |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
107 |
ST/X style static menus - going to be obsoleted ... |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
108 |
" |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
109 |
(menu := view middleButtonMenu) notNil ifTrue:[ |
472
621c17076f00
static menus override dynamic ones (is this good ?)
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
110 |
menu showAtPointer. |
621c17076f00
static menus override dynamic ones (is this good ?)
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
111 |
^ self |
621c17076f00
static menus override dynamic ones (is this good ?)
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
112 |
]. |
621c17076f00
static menus override dynamic ones (is this good ?)
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
113 |
|
621c17076f00
static menus override dynamic ones (is this good ?)
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
114 |
menu := self yellowButtonMenu. |
621c17076f00
static menus override dynamic ones (is this good ?)
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
115 |
menu notNil ifTrue:[ |
621c17076f00
static menus override dynamic ones (is this good ?)
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
116 |
menuPerformer := self menuPerformer. |
621c17076f00
static menus override dynamic ones (is this good ?)
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
117 |
|
621c17076f00
static menus override dynamic ones (is this good ?)
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
118 |
" |
621c17076f00
static menus override dynamic ones (is this good ?)
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
119 |
got one, launch the menu. It is supposed |
621c17076f00
static menus override dynamic ones (is this good ?)
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
120 |
to return an actionSelector. |
621c17076f00
static menus override dynamic ones (is this good ?)
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
121 |
" |
621c17076f00
static menus override dynamic ones (is this good ?)
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
122 |
" |
621c17076f00
static menus override dynamic ones (is this good ?)
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
123 |
a temporary kludge: subMenus dont know about |
621c17076f00
static menus override dynamic ones (is this good ?)
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
124 |
actionSelectors yet ... |
621c17076f00
static menus override dynamic ones (is this good ?)
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
125 |
" |
621c17076f00
static menus override dynamic ones (is this good ?)
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
126 |
menu receiver isNil ifTrue:[ |
621c17076f00
static menus override dynamic ones (is this good ?)
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
127 |
menu receiver:menuPerformer |
621c17076f00
static menus override dynamic ones (is this good ?)
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
128 |
] ifFalse:[ |
621c17076f00
static menus override dynamic ones (is this good ?)
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
129 |
" |
621c17076f00
static menus override dynamic ones (is this good ?)
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
130 |
if the menu has an explicit receiver, |
621c17076f00
static menus override dynamic ones (is this good ?)
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
131 |
thats the one to do the work. |
621c17076f00
static menus override dynamic ones (is this good ?)
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
132 |
" |
621c17076f00
static menus override dynamic ones (is this good ?)
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
133 |
menuPerformer := menu receiver |
621c17076f00
static menus override dynamic ones (is this good ?)
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
134 |
]. |
621c17076f00
static menus override dynamic ones (is this good ?)
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
135 |
actionSelector := menu startUp. |
621c17076f00
static menus override dynamic ones (is this good ?)
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
136 |
|
621c17076f00
static menus override dynamic ones (is this good ?)
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
137 |
(actionSelector notNil |
621c17076f00
static menus override dynamic ones (is this good ?)
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
138 |
and:[actionSelector isSymbol]) ifTrue:[ |
621c17076f00
static menus override dynamic ones (is this good ?)
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
139 |
menuPerformer perform:actionSelector |
621c17076f00
static menus override dynamic ones (is this good ?)
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
140 |
]. |
621c17076f00
static menus override dynamic ones (is this good ?)
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
141 |
^ self |
621c17076f00
static menus override dynamic ones (is this good ?)
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
142 |
]. |
621c17076f00
static menus override dynamic ones (is this good ?)
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
143 |
|
621c17076f00
static menus override dynamic ones (is this good ?)
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
144 |
"Modified: 28.2.1996 / 17:32:42 / cg" |
413
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
145 |
! ! |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
146 |
|
0 | 147 |
!Controller methodsFor:'accessing'! |
148 |
||
245 | 149 |
menuHolder |
150 |
"by default, the model has to provide the menu" |
|
151 |
||
152 |
model isNil ifTrue:[^ view]. |
|
153 |
^ model |
|
154 |
! |
|
155 |
||
156 |
menuPerformer |
|
157 |
"by default, the model is performing menu actions" |
|
158 |
||
159 |
model isNil ifTrue:[^ view]. |
|
160 |
^ model |
|
161 |
! |
|
162 |
||
163 |
model |
|
164 |
"return my model" |
|
165 |
||
166 |
^ model |
|
167 |
! |
|
168 |
||
169 |
model:aModel |
|
170 |
"set my model" |
|
171 |
||
172 |
model notNil ifTrue:[ |
|
173 |
model removeDependent:view |
|
174 |
]. |
|
175 |
model := aModel. |
|
176 |
"/ model notNil ifTrue:[model addDependent:view] |
|
177 |
! |
|
178 |
||
179 |
sensor |
|
180 |
"return my views sensor" |
|
181 |
||
182 |
^ view sensor |
|
183 |
! |
|
184 |
||
185 |
view |
|
186 |
"return my view" |
|
187 |
||
188 |
^ view |
|
189 |
! |
|
190 |
||
0 | 191 |
view:aView |
192 |
"set my view" |
|
193 |
||
194 |
view notNil ifTrue:[ |
|
80 | 195 |
model notNil ifTrue:[ |
196 |
model removeDependent:view |
|
197 |
] |
|
0 | 198 |
]. |
199 |
view := aView. |
|
200 |
model notNil ifTrue:[ |
|
127 | 201 |
"/ model addDependent:view |
202 |
view notNil ifTrue:[ |
|
203 |
view model:model |
|
204 |
] |
|
0 | 205 |
]. |
80 | 206 |
! ! |
207 |
||
86 | 208 |
!Controller methodsFor:'event handling'! |
0 | 209 |
|
245 | 210 |
buttonMotion:buttonMask x:x y:y |
211 |
"mouse was moved with button pressed in my view; nothing done here" |
|
212 |
||
213 |
^ self |
|
214 |
! |
|
215 |
||
216 |
buttonMultiPress:button x:x y:y |
|
217 |
"a mouse button was pressed again shortly after in my view" |
|
218 |
||
219 |
^ self buttonPress:button x:x y:y |
|
220 |
! |
|
221 |
||
80 | 222 |
buttonPress:button x:x y:y |
92 | 223 |
"a mouse button was pressed in my view. |
224 |
Translate buttonPress events into similar ST-80 type |
|
225 |
event messages. This method and/or these ST-80 methods |
|
226 |
can be redefined in subclasses" |
|
0 | 227 |
|
80 | 228 |
((button == 1) or:[button == #select]) ifTrue:[ |
229 |
self redButtonActivity |
|
230 |
]. |
|
231 |
((button == 2) or:[button == #menu]) ifTrue:[ |
|
232 |
self yellowButtonActivity |
|
233 |
]. |
|
234 |
(button == 3) ifTrue:[ |
|
235 |
self blueButtonActivity |
|
236 |
] |
|
237 |
! |
|
0 | 238 |
|
245 | 239 |
buttonRelease:button x:x y:y |
240 |
"a mouse button was released in my view; nothing done here" |
|
118 | 241 |
|
245 | 242 |
^ self |
118 | 243 |
! |
244 |
||
245 |
buttonShiftPress:button x:x y:y |
|
246 |
"a mouse button was pressed again shortly after in my view" |
|
247 |
||
248 |
^ self buttonPress:button x:x y:y |
|
249 |
! |
|
250 |
||
245 | 251 |
deviceButtonMotion:state x:x y:y |
153 | 252 |
"this is the low-level (untransformed) event as received |
253 |
from the device (i.e. coordinates are in device coordinates). |
|
254 |
If there is a transformation, apply the inverse |
|
245 | 255 |
and send a buttonMotion with the logical coordinates." |
153 | 256 |
|
257 |
|lx ly trans| |
|
258 |
||
259 |
lx := x. |
|
260 |
ly := y. |
|
261 |
(trans := view transformation) notNil ifTrue:[ |
|
262 |
lx := trans applyInverseToX:lx. |
|
263 |
ly := trans applyInverseToY:ly. |
|
264 |
]. |
|
245 | 265 |
self buttonMotion:state x:lx y:ly |
266 |
! |
|
267 |
||
268 |
deviceButtonPress:button x:x y:y |
|
269 |
"this is the low-level (untransformed) event as received |
|
270 |
from the device (i.e. coordinates are in device coordinates). |
|
271 |
If there is a transformation, apply the inverse |
|
272 |
and send a buttonPress with the logical coordinates." |
|
273 |
||
274 |
|lx ly trans| |
|
275 |
||
276 |
lx := x. |
|
277 |
ly := y. |
|
278 |
(trans := view transformation) notNil ifTrue:[ |
|
279 |
lx := trans applyInverseToX:lx. |
|
280 |
ly := trans applyInverseToY:ly. |
|
281 |
]. |
|
282 |
self buttonPress:button x:lx y:ly |
|
283 |
! |
|
284 |
||
285 |
deviceButtonRelease:button x:x y:y |
|
286 |
"this is the low-level (untransformed) event as received |
|
287 |
from the device (i.e. coordinates are in device coordinates). |
|
288 |
If there is a transformation, apply the inverse |
|
289 |
and send a buttonRelease with the logical coordinates." |
|
290 |
||
291 |
|lx ly trans| |
|
292 |
||
293 |
lx := x. |
|
294 |
ly := y. |
|
295 |
(trans := view transformation) notNil ifTrue:[ |
|
296 |
lx := trans applyInverseToX:lx. |
|
297 |
ly := trans applyInverseToY:ly. |
|
298 |
]. |
|
299 |
self buttonRelease:button x:lx y:ly |
|
153 | 300 |
! |
301 |
||
302 |
deviceKeyPress:key x:x y:y |
|
303 |
"this is the low-level (untransformed) event as received |
|
304 |
from the device (i.e. coordinates are in device coordinates). |
|
305 |
If there is a transformation, apply the inverse |
|
306 |
and send a keyPress with the logical coordinates." |
|
307 |
||
308 |
|lx ly trans| |
|
309 |
||
310 |
lx := x. |
|
311 |
ly := y. |
|
312 |
(trans := view transformation) notNil ifTrue:[ |
|
313 |
lx := trans applyInverseToX:lx. |
|
314 |
ly := trans applyInverseToY:ly. |
|
315 |
]. |
|
316 |
self keyPress:key x:lx y:ly |
|
317 |
! |
|
318 |
||
319 |
deviceKeyRelease:key x:x y:y |
|
320 |
"this is the low-level (untransformed) event as received |
|
321 |
from the device (i.e. coordinates are in device coordinates). |
|
322 |
If there is a transformation, apply the inverse |
|
323 |
and send a keyRelease with the logical coordinates." |
|
324 |
||
325 |
|lx ly trans| |
|
326 |
||
327 |
lx := x. |
|
328 |
ly := y. |
|
329 |
(trans := view transformation) notNil ifTrue:[ |
|
330 |
lx := trans applyInverseToX:lx. |
|
331 |
ly := trans applyInverseToY:ly. |
|
332 |
]. |
|
333 |
self keyRelease:key x:lx y:ly |
|
334 |
! |
|
335 |
||
245 | 336 |
devicePointerEnter:state x:x y:y |
153 | 337 |
"this is the low-level (untransformed) event as received |
338 |
from the device (i.e. coordinates are in device coordinates). |
|
339 |
If there is a transformation, apply the inverse |
|
245 | 340 |
and send a pointerEnter with the logical coordinates." |
153 | 341 |
|
342 |
|lx ly trans| |
|
343 |
||
344 |
lx := x. |
|
345 |
ly := y. |
|
346 |
(trans := view transformation) notNil ifTrue:[ |
|
347 |
lx := trans applyInverseToX:lx. |
|
348 |
ly := trans applyInverseToY:ly. |
|
349 |
]. |
|
245 | 350 |
self pointerEnter:state x:lx y:ly |
351 |
! |
|
352 |
||
353 |
focusIn |
|
354 |
"my view got the keyboard focus; nothing done here" |
|
355 |
||
356 |
^ self |
|
357 |
! |
|
358 |
||
359 |
focusOut |
|
360 |
"my view lost keyboard focus; nothing done here" |
|
361 |
||
362 |
^ self |
|
363 |
! |
|
364 |
||
365 |
keyPress:key x:x y:y |
|
416
0f08407c955e
use sensor shiftDown (instead of device shiftDown)
Claus Gittinger <cg@exept.de>
parents:
413
diff
changeset
|
366 |
"key was pressed in my view; nothing done here, |
0f08407c955e
use sensor shiftDown (instead of device shiftDown)
Claus Gittinger <cg@exept.de>
parents:
413
diff
changeset
|
367 |
except for Tab keys." |
245 | 368 |
|
509 | 369 |
<resource: #keyboard (#Tab #FocusNext #FocusPrevious)> |
370 |
||
502
0df8d2b173e4
focusKey handling now done here & in TopView
Claus Gittinger <cg@exept.de>
parents:
472
diff
changeset
|
371 |
|windowGroup| |
413
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
372 |
|
502
0df8d2b173e4
focusKey handling now done here & in TopView
Claus Gittinger <cg@exept.de>
parents:
472
diff
changeset
|
373 |
windowGroup := view windowGroup. |
416
0f08407c955e
use sensor shiftDown (instead of device shiftDown)
Claus Gittinger <cg@exept.de>
parents:
413
diff
changeset
|
374 |
key == #Tab ifTrue:[ |
502
0df8d2b173e4
focusKey handling now done here & in TopView
Claus Gittinger <cg@exept.de>
parents:
472
diff
changeset
|
375 |
windowGroup notNil ifTrue:[ |
469
6a263638989c
use device shiftDown - NOT sensor shiftDown
Claus Gittinger <cg@exept.de>
parents:
416
diff
changeset
|
376 |
view device shiftDown ifTrue:[ |
502
0df8d2b173e4
focusKey handling now done here & in TopView
Claus Gittinger <cg@exept.de>
parents:
472
diff
changeset
|
377 |
windowGroup focusPrevious |
416
0f08407c955e
use sensor shiftDown (instead of device shiftDown)
Claus Gittinger <cg@exept.de>
parents:
413
diff
changeset
|
378 |
] ifFalse:[ |
502
0df8d2b173e4
focusKey handling now done here & in TopView
Claus Gittinger <cg@exept.de>
parents:
472
diff
changeset
|
379 |
windowGroup focusNext |
416
0f08407c955e
use sensor shiftDown (instead of device shiftDown)
Claus Gittinger <cg@exept.de>
parents:
413
diff
changeset
|
380 |
]. |
0f08407c955e
use sensor shiftDown (instead of device shiftDown)
Claus Gittinger <cg@exept.de>
parents:
413
diff
changeset
|
381 |
] |
413
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
382 |
]. |
502
0df8d2b173e4
focusKey handling now done here & in TopView
Claus Gittinger <cg@exept.de>
parents:
472
diff
changeset
|
383 |
key == #FocusNext ifTrue:[ |
0df8d2b173e4
focusKey handling now done here & in TopView
Claus Gittinger <cg@exept.de>
parents:
472
diff
changeset
|
384 |
windowGroup notNil ifTrue:[ |
0df8d2b173e4
focusKey handling now done here & in TopView
Claus Gittinger <cg@exept.de>
parents:
472
diff
changeset
|
385 |
windowGroup focusNext. |
0df8d2b173e4
focusKey handling now done here & in TopView
Claus Gittinger <cg@exept.de>
parents:
472
diff
changeset
|
386 |
] |
0df8d2b173e4
focusKey handling now done here & in TopView
Claus Gittinger <cg@exept.de>
parents:
472
diff
changeset
|
387 |
]. |
0df8d2b173e4
focusKey handling now done here & in TopView
Claus Gittinger <cg@exept.de>
parents:
472
diff
changeset
|
388 |
key == #FocusPrevious ifTrue:[ |
0df8d2b173e4
focusKey handling now done here & in TopView
Claus Gittinger <cg@exept.de>
parents:
472
diff
changeset
|
389 |
windowGroup notNil ifTrue:[ |
0df8d2b173e4
focusKey handling now done here & in TopView
Claus Gittinger <cg@exept.de>
parents:
472
diff
changeset
|
390 |
windowGroup focusPrevious. |
0df8d2b173e4
focusKey handling now done here & in TopView
Claus Gittinger <cg@exept.de>
parents:
472
diff
changeset
|
391 |
] |
0df8d2b173e4
focusKey handling now done here & in TopView
Claus Gittinger <cg@exept.de>
parents:
472
diff
changeset
|
392 |
]. |
0df8d2b173e4
focusKey handling now done here & in TopView
Claus Gittinger <cg@exept.de>
parents:
472
diff
changeset
|
393 |
|
245 | 394 |
^ self |
413
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
395 |
|
509 | 396 |
"Modified: 7.3.1996 / 13:14:49 / cg" |
245 | 397 |
! |
398 |
||
399 |
keyRelease:key x:x y:y |
|
400 |
"key was released in my view; nothing done here" |
|
401 |
||
402 |
^ self |
|
403 |
! |
|
404 |
||
405 |
pointerEnter:state x:x y:y |
|
406 |
"mouse pointer entered my view; nothing done here" |
|
407 |
||
408 |
^ self |
|
153 | 409 |
! |
410 |
||
245 | 411 |
pointerLeave:state |
412 |
"mouse pointer left my view; nothing done here" |
|
153 | 413 |
|
245 | 414 |
^ self |
415 |
! ! |
|
153 | 416 |
|
413
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
417 |
!Controller methodsFor:'initialize / release'! |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
418 |
|
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
419 |
initialize |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
420 |
"initialize the controller; subclasses should redefine |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
421 |
this and include a super initialize for proper initialization." |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
422 |
|
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
423 |
^ self |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
424 |
! |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
425 |
|
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
426 |
release |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
427 |
"close down the controller; this is sent when the view is destroyed. |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
428 |
Can be redefined in subclasses to do some cleanup action. However, |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
429 |
these redefined methods should do a super release." |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
430 |
|
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
431 |
view notNil ifTrue:[view controller:nil]. |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
432 |
view := nil. |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
433 |
model := nil |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
434 |
! |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
435 |
|
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
436 |
startUp |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
437 |
"startup the controller; this is sent when the view realizes, |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
438 |
right before it becomes visible. |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
439 |
Can be redefined in subclasses to do some startup action." |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
440 |
|
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
441 |
self controlInitialize. |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
442 |
! ! |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
443 |
|
245 | 444 |
!Controller methodsFor:'menus'! |
445 |
||
446 |
yellowButtonMenu |
|
447 |
"actually, this should be called 'middleButtonMenu'. |
|
448 |
But for ST-80 compatibility ...." |
|
449 |
||
450 |
|sym menuHolder m| |
|
153 | 451 |
|
245 | 452 |
"/ (m := view middleButtonMenu) notNil ifTrue:[ |
453 |
"/ "/ |
|
454 |
"/ "/ has been assigned a static middleButtonMenu |
|
455 |
"/ "/ (or a cached menu) |
|
456 |
"/ "/ |
|
457 |
"/ ^ m |
|
458 |
"/ ]. |
|
153 | 459 |
|
245 | 460 |
menuHolder := self menuHolder. |
153 | 461 |
|
245 | 462 |
" |
463 |
try ST-80 style menus first: |
|
464 |
if there is a model, and a menuMessage is defined, |
|
465 |
ask model for the menu and launch that if non-nil. |
|
466 |
" |
|
467 |
(menuHolder notNil |
|
468 |
and:[(sym := view menuMessage) notNil |
|
469 |
and:[sym isSymbol]]) ifTrue:[ |
|
470 |
" |
|
471 |
ask model for the menu |
|
472 |
" |
|
473 |
^ menuHolder perform:sym. |
|
153 | 474 |
]. |
245 | 475 |
^ nil |
0 | 476 |
! ! |
245 | 477 |
|
252 | 478 |
!Controller class methodsFor:'documentation'! |
479 |
||
480 |
version |
|
509 | 481 |
^ '$Header: /cvs/stx/stx/libview/Controller.st,v 1.33 1996-03-07 12:25:03 cg Exp $' |
252 | 482 |
! ! |