author | Claus Gittinger <cg@exept.de> |
Wed, 23 Jul 2008 13:58:24 +0200 | |
changeset 5007 | bfac35f480d6 |
parent 4857 | bbfc8b071b46 |
child 5345 | b64a7f6ed325 |
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 |
" |
|
3753 | 12 |
"{ Package: 'stx:libview' }" |
13 |
||
0 | 14 |
Object subclass:#Controller |
4208
0a16e323fe6b
Remove unused instance variable 'sensor'
Stefan Vogel <sv@exept.de>
parents:
3902
diff
changeset
|
15 |
instanceVariableNames:'model view' |
413
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
16 |
classVariableNames:'' |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
17 |
poolDictionaries:'' |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
18 |
category:'Interface-Support-Controllers' |
0 | 19 |
! |
20 |
||
1112 | 21 |
!Controller class methodsFor:'documentation'! |
46 | 22 |
|
23 |
copyright |
|
24 |
" |
|
25 |
COPYRIGHT (c) 1992 by Claus Gittinger |
|
80 | 26 |
All Rights Reserved |
0 | 27 |
|
46 | 28 |
This software is furnished under a license and may be used |
29 |
only in accordance with the terms of that license and with the |
|
30 |
inclusion of the above copyright notice. This software may not |
|
31 |
be provided or otherwise made available to, or used by, any |
|
32 |
other person. No title to or ownership of the software is |
|
33 |
hereby transferred. |
|
34 |
" |
|
35 |
! |
|
0 | 36 |
|
46 | 37 |
documentation |
38 |
" |
|
39 |
Controllers can be used to controll the user-interactions |
|
5007 | 40 |
to a model which is shown in a view. |
413
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
41 |
|
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
42 |
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
|
43 |
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
|
44 |
|
80 | 45 |
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
|
46 |
sent directly to the view, if the view has no controller |
5007 | 47 |
(i.e. if its controller instance variable is nil). |
413
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
48 |
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
|
49 |
|
89 | 50 |
For now (vsn 2.10.4) there are only a few view classes using controllers; |
51 |
however, over time, more will be converted, since separating the controller |
|
5007 | 52 |
offers much more flexibility |
127 | 53 |
(although view initialization becomes a bit more complex). |
46 | 54 |
|
413
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
55 |
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
|
56 |
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
|
57 |
be appearing. |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
58 |
This migration should be backward compatible. |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
59 |
|
681 | 60 |
Device coordinates vs. Logical coordinates: |
5007 | 61 |
if the view has a non-identity transformation (for example: drawing |
62 |
in millimeters or inches), the application/controller may or may not |
|
63 |
be interested in device coordinates in button/key events. |
|
64 |
Most are not, these will receive logical coordinates transparently |
|
65 |
in theyr button/key-Press/Release/Motion methods. |
|
66 |
Those which are interested should redefine the corresponding |
|
67 |
device-Key/Button-Press/Release/Motion methods. |
|
68 |
Of course, it is always possible to map between device and logical |
|
69 |
coordinates, using `view transformation applyTo/applyInverseTo:', |
|
70 |
if both coordinates are required (which is unlikely). |
|
681 | 71 |
|
612 | 72 |
[Instance variables:] |
5007 | 73 |
view <View> the view I control |
413
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
74 |
|
5007 | 75 |
model <Model> the model which is to be worked on |
612 | 76 |
|
681 | 77 |
|
612 | 78 |
[author:] |
5007 | 79 |
Claus Gittinger |
612 | 80 |
|
81 |
[see also:] |
|
5007 | 82 |
View Model WindowGroup |
83 |
WindowEvent DeviceWorkstation |
|
46 | 84 |
" |
85 |
! ! |
|
0 | 86 |
|
1112 | 87 |
!Controller class methodsFor:'instance creation'! |
89 | 88 |
|
89 |
new |
|
90 |
^ self basicNew initialize |
|
91 |
! ! |
|
92 |
||
3880 | 93 |
!Controller methodsFor:'Compatibility-ST80'! |
2934 | 94 |
|
95 |
blueButtonActivity |
|
96 |
"actually, this should be called 'rightButtonActivity'. |
|
97 |
But for ST-80 compatibility ...." |
|
98 |
||
99 |
^ self |
|
100 |
! |
|
99 | 101 |
|
413
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
102 |
controlInitialize |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
103 |
^ self |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
104 |
! |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
105 |
|
99 | 106 |
open |
107 |
"open my view" |
|
108 |
||
109 |
view open |
|
1434
136173f28066
set the sensor; dont change models deps in view:
Claus Gittinger <cg@exept.de>
parents:
1394
diff
changeset
|
110 |
! |
136173f28066
set the sensor; dont change models deps in view:
Claus Gittinger <cg@exept.de>
parents:
1394
diff
changeset
|
111 |
|
136173f28066
set the sensor; dont change models deps in view:
Claus Gittinger <cg@exept.de>
parents:
1394
diff
changeset
|
112 |
poll |
136173f28066
set the sensor; dont change models deps in view:
Claus Gittinger <cg@exept.de>
parents:
1394
diff
changeset
|
113 |
"ST-80 compatibility - ignored here" |
136173f28066
set the sensor; dont change models deps in view:
Claus Gittinger <cg@exept.de>
parents:
1394
diff
changeset
|
114 |
|
136173f28066
set the sensor; dont change models deps in view:
Claus Gittinger <cg@exept.de>
parents:
1394
diff
changeset
|
115 |
"Created: 6.3.1997 / 15:29:45 / cg" |
413
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
116 |
! |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
117 |
|
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
118 |
redButtonActivity |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
119 |
"actually, this should be called 'leftButtonActivity'. |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
120 |
But for ST-80 compatibility ...." |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
121 |
|
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
122 |
^ self |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
123 |
! |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
124 |
|
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
125 |
yellowButtonActivity |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
126 |
"actually, this should be called 'middleButtonActivity'. |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
127 |
But for ST-80 compatibility ...." |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
128 |
|
1112 | 129 |
|menu actionSelector menuPerformer prevReceiver| |
413
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
130 |
|
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
131 |
" |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
132 |
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
|
133 |
" |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
134 |
(menu := view middleButtonMenu) notNil ifTrue:[ |
5007 | 135 |
menu showAtPointer. |
136 |
^ self |
|
472
621c17076f00
static menus override dynamic ones (is this good ?)
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
137 |
]. |
621c17076f00
static menus override dynamic ones (is this good ?)
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
138 |
|
621c17076f00
static menus override dynamic ones (is this good ?)
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
139 |
menu := self yellowButtonMenu. |
621c17076f00
static menus override dynamic ones (is this good ?)
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
140 |
menu notNil ifTrue:[ |
5007 | 141 |
menuPerformer := self menuPerformer. |
472
621c17076f00
static menus override dynamic ones (is this good ?)
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
142 |
|
5007 | 143 |
" |
144 |
a temporary kludge: |
|
145 |
pass myself as receiver, the menuPerformer as performer; |
|
146 |
the menu will send its messages to either the |
|
147 |
menuPerformer or me (its receiver). |
|
148 |
This allows for the ST-80 behavior, where some messages |
|
149 |
go to the model, others to the view |
|
150 |
(copy/cut/paste). |
|
151 |
" |
|
152 |
(prevReceiver := menu receiver) isNil ifTrue:[ |
|
1259
60af09384d13
pass myself AND the menuPerformer to the popupMenu.
Claus Gittinger <cg@exept.de>
parents:
1112
diff
changeset
|
153 |
"/ menu receiver:menuPerformer. |
5007 | 154 |
menu menuPerformer:menuPerformer. |
155 |
menu receiver:self. |
|
156 |
]. |
|
1259
60af09384d13
pass myself AND the menuPerformer to the popupMenu.
Claus Gittinger <cg@exept.de>
parents:
1112
diff
changeset
|
157 |
|
5007 | 158 |
" |
159 |
Launch the menu. It is supposed |
|
160 |
to return an actionSelector. |
|
161 |
" |
|
162 |
actionSelector := view startUpMenu:menu. |
|
472
621c17076f00
static menus override dynamic ones (is this good ?)
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
163 |
|
5007 | 164 |
actionSelector notNil notNil ifTrue:[ |
165 |
actionSelector isSymbol ifTrue:[ |
|
166 |
menuPerformer perform:actionSelector |
|
167 |
] ifFalse:[ |
|
168 |
(actionSelector isArray |
|
169 |
and:[actionSelector size == 2 |
|
170 |
and:[(actionSelector at:1) isSymbol]]) ifTrue:[ |
|
171 |
menuPerformer |
|
172 |
perform:(actionSelector at:1) |
|
173 |
with:(actionSelector at:2) |
|
174 |
] |
|
175 |
] |
|
176 |
]. |
|
1112 | 177 |
|
5007 | 178 |
menu receiver:prevReceiver. |
1112 | 179 |
|
5007 | 180 |
^ self |
472
621c17076f00
static menus override dynamic ones (is this good ?)
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
181 |
]. |
621c17076f00
static menus override dynamic ones (is this good ?)
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
182 |
|
1259
60af09384d13
pass myself AND the menuPerformer to the popupMenu.
Claus Gittinger <cg@exept.de>
parents:
1112
diff
changeset
|
183 |
"Modified: 21.1.1997 / 15:45:48 / cg" |
413
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
184 |
! ! |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
185 |
|
0 | 186 |
!Controller methodsFor:'accessing'! |
187 |
||
5007 | 188 |
menuHolder |
245 | 189 |
"by default, the model has to provide the menu" |
190 |
||
1036 | 191 |
model isNil ifTrue:[ |
5007 | 192 |
^ view menuHolder |
1036 | 193 |
]. |
245 | 194 |
^ model |
1036 | 195 |
|
196 |
"Modified: 22.8.1996 / 09:11:43 / cg" |
|
245 | 197 |
! |
198 |
||
5007 | 199 |
menuPerformer |
245 | 200 |
"by default, the model is performing menu actions" |
201 |
||
202 |
model isNil ifTrue:[^ view]. |
|
203 |
^ model |
|
204 |
! |
|
205 |
||
206 |
model |
|
207 |
"return my model" |
|
208 |
||
209 |
^ model |
|
210 |
! |
|
211 |
||
212 |
model:aModel |
|
213 |
"set my model" |
|
214 |
||
215 |
model := aModel. |
|
1394 | 216 |
|
217 |
"Modified: 28.2.1997 / 19:52:50 / cg" |
|
245 | 218 |
! |
219 |
||
5007 | 220 |
sensor |
245 | 221 |
"return my views sensor" |
222 |
||
223 |
^ view sensor |
|
224 |
! |
|
225 |
||
226 |
view |
|
227 |
"return my view" |
|
228 |
||
229 |
^ view |
|
230 |
! |
|
231 |
||
0 | 232 |
view:aView |
233 |
"set my view" |
|
234 |
||
235 |
view := aView. |
|
1434
136173f28066
set the sensor; dont change models deps in view:
Claus Gittinger <cg@exept.de>
parents:
1394
diff
changeset
|
236 |
|
136173f28066
set the sensor; dont change models deps in view:
Claus Gittinger <cg@exept.de>
parents:
1394
diff
changeset
|
237 |
"Modified: 6.3.1997 / 15:31:48 / cg" |
80 | 238 |
! ! |
239 |
||
86 | 240 |
!Controller methodsFor:'event handling'! |
0 | 241 |
|
245 | 242 |
buttonMotion:buttonMask x:x y:y |
243 |
"mouse was moved with button pressed in my view; nothing done here" |
|
244 |
||
245 |
^ self |
|
246 |
! |
|
247 |
||
248 |
buttonMultiPress:button x:x y:y |
|
249 |
"a mouse button was pressed again shortly after in my view" |
|
250 |
||
251 |
^ self buttonPress:button x:x y:y |
|
252 |
! |
|
253 |
||
80 | 254 |
buttonPress:button x:x y:y |
92 | 255 |
"a mouse button was pressed in my view. |
256 |
Translate buttonPress events into similar ST-80 type |
|
257 |
event messages. This method and/or these ST-80 methods |
|
258 |
can be redefined in subclasses" |
|
0 | 259 |
|
80 | 260 |
((button == 1) or:[button == #select]) ifTrue:[ |
261 |
self redButtonActivity |
|
262 |
]. |
|
263 |
((button == 2) or:[button == #menu]) ifTrue:[ |
|
264 |
self yellowButtonActivity |
|
265 |
]. |
|
266 |
(button == 3) ifTrue:[ |
|
267 |
self blueButtonActivity |
|
268 |
] |
|
269 |
! |
|
0 | 270 |
|
245 | 271 |
buttonRelease:button x:x y:y |
272 |
"a mouse button was released in my view; nothing done here" |
|
118 | 273 |
|
245 | 274 |
^ self |
118 | 275 |
! |
276 |
||
245 | 277 |
deviceButtonMotion:state x:x y:y |
153 | 278 |
"this is the low-level (untransformed) event as received |
5007 | 279 |
from the device (i.e. coordinates are in device coordinates). |
153 | 280 |
If there is a transformation, apply the inverse |
681 | 281 |
and send a buttonMotion with the logical coordinates. |
282 |
||
1073
75fafd486819
Rename misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
1054
diff
changeset
|
283 |
Controllers which are interested in deviceCoordinates should |
5007 | 284 |
redefine this method - |
1073
75fafd486819
Rename misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
1054
diff
changeset
|
285 |
those which are interested in logical coordinates |
681 | 286 |
should redefine #buttonMotion:x:y:" |
153 | 287 |
|
288 |
|lx ly trans| |
|
289 |
||
290 |
lx := x. |
|
291 |
ly := y. |
|
292 |
(trans := view transformation) notNil ifTrue:[ |
|
5007 | 293 |
lx := trans applyInverseToX:lx. |
294 |
ly := trans applyInverseToY:ly. |
|
153 | 295 |
]. |
245 | 296 |
self buttonMotion:state x:lx y:ly |
681 | 297 |
|
298 |
"Modified: 13.5.1996 / 11:24:11 / cg" |
|
1073
75fafd486819
Rename misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
1054
diff
changeset
|
299 |
"Modified: 14.10.1996 / 22:23:56 / stefan" |
681 | 300 |
! |
301 |
||
302 |
deviceButtonMultiPress:button x:x y:y |
|
303 |
"this is the low-level (untransformed) event as received |
|
5007 | 304 |
from the device (i.e. coordinates are in device coordinates). |
681 | 305 |
If there is a transformation, apply the inverse |
306 |
and send a buttonMultiPress with the logical coordinates. |
|
307 |
||
1073
75fafd486819
Rename misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
1054
diff
changeset
|
308 |
Controllers which are interested in deviceCoordinates should |
5007 | 309 |
redefine this method - |
1073
75fafd486819
Rename misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
1054
diff
changeset
|
310 |
those which are interested in logical coordinates |
681 | 311 |
should redefine #buttonMultiPress:x:y:" |
312 |
||
313 |
|lx ly trans| |
|
314 |
||
315 |
lx := x. |
|
316 |
ly := y. |
|
317 |
(trans := view transformation) notNil ifTrue:[ |
|
5007 | 318 |
lx := trans applyInverseToX:lx. |
319 |
ly := trans applyInverseToY:ly. |
|
681 | 320 |
]. |
321 |
self buttonMultiPress:button x:lx y:ly |
|
322 |
||
323 |
"Modified: 13.5.1996 / 11:23:54 / cg" |
|
1073
75fafd486819
Rename misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
1054
diff
changeset
|
324 |
"Modified: 14.10.1996 / 22:24:06 / stefan" |
245 | 325 |
! |
326 |
||
327 |
deviceButtonPress:button x:x y:y |
|
328 |
"this is the low-level (untransformed) event as received |
|
5007 | 329 |
from the device (i.e. coordinates are in device coordinates). |
245 | 330 |
If there is a transformation, apply the inverse |
681 | 331 |
and send a buttonPress with the logical coordinates. |
245 | 332 |
|
1073
75fafd486819
Rename misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
1054
diff
changeset
|
333 |
Controllers which are interested in deviceCoordinates should |
5007 | 334 |
redefine this method - |
1073
75fafd486819
Rename misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
1054
diff
changeset
|
335 |
those which are interested in logical coordinates |
681 | 336 |
should redefine #buttonPress:x:y:" |
245 | 337 |
|
338 |
|lx ly trans| |
|
339 |
||
340 |
lx := x. |
|
341 |
ly := y. |
|
342 |
(trans := view transformation) notNil ifTrue:[ |
|
5007 | 343 |
lx := trans applyInverseToX:lx. |
344 |
ly := trans applyInverseToY:ly. |
|
681 | 345 |
]. |
346 |
self buttonPress:button x:lx y:ly |
|
347 |
||
348 |
"Modified: 13.5.1996 / 11:24:23 / cg" |
|
1073
75fafd486819
Rename misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
1054
diff
changeset
|
349 |
"Modified: 14.10.1996 / 22:24:17 / stefan" |
681 | 350 |
! |
351 |
||
352 |
deviceButtonRelease:button x:x y:y |
|
353 |
"this is the low-level (untransformed) event as received |
|
5007 | 354 |
from the device (i.e. coordinates are in device coordinates). |
681 | 355 |
If there is a transformation, apply the inverse |
356 |
and send a buttonRelease with the logical coordinates. |
|
357 |
||
1073
75fafd486819
Rename misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
1054
diff
changeset
|
358 |
Controllers which are interested in deviceCoordinates should |
5007 | 359 |
redefine this method - |
1073
75fafd486819
Rename misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
1054
diff
changeset
|
360 |
those which are interested in logical coordinates |
681 | 361 |
should redefine #buttonRelease:x:y:" |
362 |
||
363 |
|lx ly trans| |
|
364 |
||
365 |
lx := x. |
|
366 |
ly := y. |
|
367 |
(trans := view transformation) notNil ifTrue:[ |
|
5007 | 368 |
lx := trans applyInverseToX:lx. |
369 |
ly := trans applyInverseToY:ly. |
|
245 | 370 |
]. |
371 |
self buttonRelease:button x:lx y:ly |
|
681 | 372 |
|
373 |
"Modified: 13.5.1996 / 11:24:33 / cg" |
|
1073
75fafd486819
Rename misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
1054
diff
changeset
|
374 |
"Modified: 14.10.1996 / 22:24:28 / stefan" |
153 | 375 |
! |
376 |
||
377 |
deviceKeyPress:key x:x y:y |
|
378 |
"this is the low-level (untransformed) event as received |
|
5007 | 379 |
from the device (i.e. coordinates are in device coordinates). |
153 | 380 |
If there is a transformation, apply the inverse |
681 | 381 |
and send a keyPress with the logical coordinates. |
382 |
||
1073
75fafd486819
Rename misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
1054
diff
changeset
|
383 |
Controllers which are interested in deviceCoordinates should |
5007 | 384 |
redefine this method - |
1073
75fafd486819
Rename misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
1054
diff
changeset
|
385 |
those which are interested in logical coordinates |
681 | 386 |
should redefine #keyPress:x:y:" |
153 | 387 |
|
388 |
|lx ly trans| |
|
389 |
||
390 |
lx := x. |
|
391 |
ly := y. |
|
392 |
(trans := view transformation) notNil ifTrue:[ |
|
5007 | 393 |
lx := trans applyInverseToX:lx. |
394 |
ly := trans applyInverseToY:ly. |
|
153 | 395 |
]. |
396 |
self keyPress:key x:lx y:ly |
|
681 | 397 |
|
398 |
"Modified: 13.5.1996 / 11:24:43 / cg" |
|
1073
75fafd486819
Rename misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
1054
diff
changeset
|
399 |
"Modified: 14.10.1996 / 22:24:36 / stefan" |
153 | 400 |
! |
401 |
||
402 |
deviceKeyRelease:key x:x y:y |
|
403 |
"this is the low-level (untransformed) event as received |
|
5007 | 404 |
from the device (i.e. coordinates are in device coordinates). |
153 | 405 |
If there is a transformation, apply the inverse |
681 | 406 |
and send a keyRelease with the logical coordinates. |
407 |
||
1073
75fafd486819
Rename misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
1054
diff
changeset
|
408 |
Controllers which are interested in deviceCoordinates should |
5007 | 409 |
redefine this method - |
1073
75fafd486819
Rename misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
1054
diff
changeset
|
410 |
those which are interested in logical coordinates |
681 | 411 |
should redefine #keyRelease:x:y:" |
153 | 412 |
|
413 |
|lx ly trans| |
|
414 |
||
415 |
lx := x. |
|
416 |
ly := y. |
|
417 |
(trans := view transformation) notNil ifTrue:[ |
|
5007 | 418 |
lx := trans applyInverseToX:lx. |
419 |
ly := trans applyInverseToY:ly. |
|
153 | 420 |
]. |
421 |
self keyRelease:key x:lx y:ly |
|
681 | 422 |
|
423 |
"Modified: 13.5.1996 / 11:24:51 / cg" |
|
1073
75fafd486819
Rename misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
1054
diff
changeset
|
424 |
"Modified: 14.10.1996 / 22:24:46 / stefan" |
153 | 425 |
! |
426 |
||
245 | 427 |
devicePointerEnter:state x:x y:y |
153 | 428 |
"this is the low-level (untransformed) event as received |
5007 | 429 |
from the device (i.e. coordinates are in device coordinates). |
153 | 430 |
If there is a transformation, apply the inverse |
681 | 431 |
and send a pointerEnter with the logical coordinates. |
432 |
||
1073
75fafd486819
Rename misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
1054
diff
changeset
|
433 |
Controllers which are interested in deviceCoordinates should |
5007 | 434 |
redefine this method - |
1073
75fafd486819
Rename misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
1054
diff
changeset
|
435 |
those which are interested in logical coordinates |
681 | 436 |
should redefine #pointerEnter:x:y:" |
153 | 437 |
|
438 |
|lx ly trans| |
|
439 |
||
440 |
lx := x. |
|
441 |
ly := y. |
|
442 |
(trans := view transformation) notNil ifTrue:[ |
|
5007 | 443 |
lx := trans applyInverseToX:lx. |
444 |
ly := trans applyInverseToY:ly. |
|
153 | 445 |
]. |
245 | 446 |
self pointerEnter:state x:lx y:ly |
681 | 447 |
|
448 |
"Modified: 13.5.1996 / 11:24:59 / cg" |
|
1073
75fafd486819
Rename misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents:
1054
diff
changeset
|
449 |
"Modified: 14.10.1996 / 22:24:54 / stefan" |
245 | 450 |
! |
451 |
||
452 |
focusIn |
|
453 |
"my view got the keyboard focus; nothing done here" |
|
454 |
||
455 |
^ self |
|
456 |
! |
|
457 |
||
458 |
focusOut |
|
459 |
"my view lost keyboard focus; nothing done here" |
|
460 |
||
461 |
^ self |
|
462 |
! |
|
463 |
||
464 |
keyPress:key x:x y:y |
|
416
0f08407c955e
use sensor shiftDown (instead of device shiftDown)
Claus Gittinger <cg@exept.de>
parents:
413
diff
changeset
|
465 |
"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
|
466 |
except for Tab keys." |
245 | 467 |
|
509 | 468 |
<resource: #keyboard (#Tab #FocusNext #FocusPrevious)> |
469 |
||
2481 | 470 |
|windowGroup action| |
413
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
471 |
|
502
0df8d2b173e4
focusKey handling now done here & in TopView
Claus Gittinger <cg@exept.de>
parents:
472
diff
changeset
|
472 |
windowGroup := view windowGroup. |
2481 | 473 |
windowGroup notNil ifTrue:[ |
5007 | 474 |
action := key. |
475 |
key == #Tab ifTrue:[ |
|
476 |
(view tabRequiresControl not |
|
477 |
or:[ view sensor ctrlDown ]) ifTrue:[ |
|
478 |
view graphicsDevice shiftDown ifTrue:[ |
|
479 |
action := #FocusPrevious. |
|
480 |
] ifFalse:[ |
|
481 |
action := #FocusNext. |
|
482 |
] |
|
483 |
] |
|
484 |
]. |
|
485 |
action == #FocusNext ifTrue:[ |
|
486 |
windowGroup focusNext. |
|
487 |
]. |
|
488 |
action == #FocusPrevious ifTrue:[ |
|
489 |
windowGroup focusPrevious. |
|
490 |
]. |
|
413
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
491 |
]. |
245 | 492 |
^ self |
413
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
493 |
|
744 | 494 |
"Modified: 28.5.1996 / 20:21:41 / cg" |
245 | 495 |
! |
496 |
||
497 |
keyRelease:key x:x y:y |
|
498 |
"key was released in my view; nothing done here" |
|
499 |
||
500 |
^ self |
|
501 |
! |
|
502 |
||
4857 | 503 |
mouseWheelMotion:event x:x y:y amount:amount deltaTime:deltaTime |
504 |
"a mouse wheel was turned - nothing done here" |
|
505 |
||
506 |
^ self. |
|
507 |
! |
|
508 |
||
245 | 509 |
pointerEnter:state x:x y:y |
510 |
"mouse pointer entered my view; nothing done here" |
|
511 |
||
512 |
^ self |
|
153 | 513 |
! |
514 |
||
245 | 515 |
pointerLeave:state |
516 |
"mouse pointer left my view; nothing done here" |
|
153 | 517 |
|
245 | 518 |
^ self |
519 |
! ! |
|
153 | 520 |
|
3884 | 521 |
!Controller methodsFor:'initialization & release'! |
413
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
522 |
|
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
523 |
initialize |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
524 |
"initialize the controller; subclasses should redefine |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
525 |
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
|
526 |
|
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
527 |
^ self |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
528 |
! |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
529 |
|
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
530 |
release |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
531 |
"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
|
532 |
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
|
533 |
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
|
534 |
|
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
535 |
view notNil ifTrue:[view controller:nil]. |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
536 |
view := nil. |
1744
0c992e0ea53b
oops - release must send a super release also
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
537 |
model := nil. |
0c992e0ea53b
oops - release must send a super release also
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
538 |
super release. |
0c992e0ea53b
oops - release must send a super release also
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
539 |
|
0c992e0ea53b
oops - release must send a super release also
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
540 |
"Modified: 11.6.1997 / 13:18:09 / cg" |
413
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
541 |
! |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
542 |
|
5007 | 543 |
startUp |
413
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
544 |
"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
|
545 |
right before it becomes visible. |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
546 |
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
|
547 |
|
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
548 |
self controlInitialize. |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
549 |
! ! |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
550 |
|
245 | 551 |
!Controller methodsFor:'menus'! |
552 |
||
553 |
yellowButtonMenu |
|
554 |
"actually, this should be called 'middleButtonMenu'. |
|
555 |
But for ST-80 compatibility ...." |
|
556 |
||
557 |
|sym menuHolder m| |
|
153 | 558 |
|
245 | 559 |
menuHolder := self menuHolder. |
153 | 560 |
|
245 | 561 |
" |
562 |
try ST-80 style menus first: |
|
563 |
if there is a model, and a menuMessage is defined, |
|
564 |
ask model for the menu and launch that if non-nil. |
|
565 |
" |
|
5007 | 566 |
(menuHolder notNil |
245 | 567 |
and:[(sym := view menuMessage) notNil |
568 |
and:[sym isSymbol]]) ifTrue:[ |
|
5007 | 569 |
" |
570 |
ask menuHolder (model) for the menu |
|
571 |
" |
|
572 |
(menuHolder respondsTo:sym) ifTrue:[ |
|
573 |
^ menuHolder perform:sym. |
|
574 |
] |
|
153 | 575 |
]. |
245 | 576 |
^ nil |
1054
b7e7ed0c35f6
dont ask valueHolders for a menu ...
Claus Gittinger <cg@exept.de>
parents:
1037
diff
changeset
|
577 |
|
b7e7ed0c35f6
dont ask valueHolders for a menu ...
Claus Gittinger <cg@exept.de>
parents:
1037
diff
changeset
|
578 |
"Modified: 14.9.1996 / 13:19:34 / cg" |
0 | 579 |
! ! |
245 | 580 |
|
1112 | 581 |
!Controller class methodsFor:'documentation'! |
252 | 582 |
|
583 |
version |
|
5007 | 584 |
^ '$Header: /cvs/stx/stx/libview/Controller.st,v 1.56 2008-07-23 11:58:24 cg Exp $' |
252 | 585 |
! ! |