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