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