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