author | Claus Gittinger <cg@exept.de> |
Thu, 22 Aug 1996 09:12:24 +0200 | |
changeset 1036 | e4b2a5b5b0df |
parent 1012 | e408830caf2d |
child 1037 | 8bb234162a7d |
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 |
|
621c17076f00
static menus override dynamic ones (is this good ?)
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
157 |
(actionSelector notNil |
621c17076f00
static menus override dynamic ones (is this good ?)
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
158 |
and:[actionSelector isSymbol]) ifTrue:[ |
621c17076f00
static menus override dynamic ones (is this good ?)
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
159 |
menuPerformer perform:actionSelector |
621c17076f00
static menus override dynamic ones (is this good ?)
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
160 |
]. |
621c17076f00
static menus override dynamic ones (is this good ?)
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
161 |
^ self |
621c17076f00
static menus override dynamic ones (is this good ?)
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
162 |
]. |
621c17076f00
static menus override dynamic ones (is this good ?)
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
163 |
|
621c17076f00
static menus override dynamic ones (is this good ?)
Claus Gittinger <cg@exept.de>
parents:
469
diff
changeset
|
164 |
"Modified: 28.2.1996 / 17:32:42 / cg" |
413
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
165 |
! ! |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
166 |
|
0 | 167 |
!Controller methodsFor:'accessing'! |
168 |
||
245 | 169 |
menuHolder |
170 |
"by default, the model has to provide the menu" |
|
171 |
||
1036 | 172 |
model isNil ifTrue:[ |
173 |
^ view menuHolder |
|
174 |
]. |
|
245 | 175 |
^ model |
1036 | 176 |
|
177 |
"Modified: 22.8.1996 / 09:11:43 / cg" |
|
245 | 178 |
! |
179 |
||
180 |
menuPerformer |
|
181 |
"by default, the model is performing menu actions" |
|
182 |
||
183 |
model isNil ifTrue:[^ view]. |
|
184 |
^ model |
|
185 |
! |
|
186 |
||
187 |
model |
|
188 |
"return my model" |
|
189 |
||
190 |
^ model |
|
191 |
! |
|
192 |
||
193 |
model:aModel |
|
194 |
"set my model" |
|
195 |
||
196 |
model notNil ifTrue:[ |
|
197 |
model removeDependent:view |
|
198 |
]. |
|
199 |
model := aModel. |
|
200 |
"/ model notNil ifTrue:[model addDependent:view] |
|
201 |
! |
|
202 |
||
203 |
sensor |
|
204 |
"return my views sensor" |
|
205 |
||
206 |
^ view sensor |
|
207 |
! |
|
208 |
||
209 |
view |
|
210 |
"return my view" |
|
211 |
||
212 |
^ view |
|
213 |
! |
|
214 |
||
0 | 215 |
view:aView |
216 |
"set my view" |
|
217 |
||
218 |
view notNil ifTrue:[ |
|
80 | 219 |
model notNil ifTrue:[ |
220 |
model removeDependent:view |
|
221 |
] |
|
0 | 222 |
]. |
223 |
view := aView. |
|
224 |
model notNil ifTrue:[ |
|
127 | 225 |
"/ model addDependent:view |
226 |
view notNil ifTrue:[ |
|
227 |
view model:model |
|
228 |
] |
|
0 | 229 |
]. |
80 | 230 |
! ! |
231 |
||
86 | 232 |
!Controller methodsFor:'event handling'! |
0 | 233 |
|
245 | 234 |
buttonMotion:buttonMask x:x y:y |
235 |
"mouse was moved with button pressed in my view; nothing done here" |
|
236 |
||
237 |
^ self |
|
238 |
! |
|
239 |
||
240 |
buttonMultiPress:button x:x y:y |
|
241 |
"a mouse button was pressed again shortly after in my view" |
|
242 |
||
243 |
^ self buttonPress:button x:x y:y |
|
244 |
! |
|
245 |
||
80 | 246 |
buttonPress:button x:x y:y |
92 | 247 |
"a mouse button was pressed in my view. |
248 |
Translate buttonPress events into similar ST-80 type |
|
249 |
event messages. This method and/or these ST-80 methods |
|
250 |
can be redefined in subclasses" |
|
0 | 251 |
|
80 | 252 |
((button == 1) or:[button == #select]) ifTrue:[ |
253 |
self redButtonActivity |
|
254 |
]. |
|
255 |
((button == 2) or:[button == #menu]) ifTrue:[ |
|
256 |
self yellowButtonActivity |
|
257 |
]. |
|
258 |
(button == 3) ifTrue:[ |
|
259 |
self blueButtonActivity |
|
260 |
] |
|
261 |
! |
|
0 | 262 |
|
245 | 263 |
buttonRelease:button x:x y:y |
264 |
"a mouse button was released in my view; nothing done here" |
|
118 | 265 |
|
245 | 266 |
^ self |
118 | 267 |
! |
268 |
||
245 | 269 |
deviceButtonMotion:state x:x y:y |
153 | 270 |
"this is the low-level (untransformed) event as received |
271 |
from the device (i.e. coordinates are in device coordinates). |
|
272 |
If there is a transformation, apply the inverse |
|
681 | 273 |
and send a buttonMotion with the logical coordinates. |
274 |
||
275 |
Controllers which are interrested in deviceCoordinates should |
|
276 |
redefine this method - |
|
277 |
those which are interrested in logical coordinates |
|
278 |
should redefine #buttonMotion:x:y:" |
|
153 | 279 |
|
280 |
|lx ly trans| |
|
281 |
||
282 |
lx := x. |
|
283 |
ly := y. |
|
284 |
(trans := view transformation) notNil ifTrue:[ |
|
681 | 285 |
lx := trans applyInverseToX:lx. |
286 |
ly := trans applyInverseToY:ly. |
|
153 | 287 |
]. |
245 | 288 |
self buttonMotion:state x:lx y:ly |
681 | 289 |
|
290 |
"Modified: 13.5.1996 / 11:24:11 / cg" |
|
291 |
! |
|
292 |
||
293 |
deviceButtonMultiPress:button x:x y:y |
|
294 |
"this is the low-level (untransformed) event as received |
|
295 |
from the device (i.e. coordinates are in device coordinates). |
|
296 |
If there is a transformation, apply the inverse |
|
297 |
and send a buttonMultiPress with the logical coordinates. |
|
298 |
||
299 |
Controllers which are interrested in deviceCoordinates should |
|
300 |
redefine this method - |
|
301 |
those which are interrested in logical coordinates |
|
302 |
should redefine #buttonMultiPress:x:y:" |
|
303 |
||
304 |
|lx ly trans| |
|
305 |
||
306 |
lx := x. |
|
307 |
ly := y. |
|
308 |
(trans := view transformation) notNil ifTrue:[ |
|
309 |
lx := trans applyInverseToX:lx. |
|
310 |
ly := trans applyInverseToY:ly. |
|
311 |
]. |
|
312 |
self buttonMultiPress:button x:lx y:ly |
|
313 |
||
314 |
"Modified: 13.5.1996 / 11:23:54 / cg" |
|
245 | 315 |
! |
316 |
||
317 |
deviceButtonPress:button x:x y:y |
|
318 |
"this is the low-level (untransformed) event as received |
|
319 |
from the device (i.e. coordinates are in device coordinates). |
|
320 |
If there is a transformation, apply the inverse |
|
681 | 321 |
and send a buttonPress with the logical coordinates. |
245 | 322 |
|
681 | 323 |
Controllers which are interrested in deviceCoordinates should |
324 |
redefine this method - |
|
325 |
those which are interrested in logical coordinates |
|
326 |
should redefine #buttonPress:x:y:" |
|
245 | 327 |
|
328 |
|lx ly trans| |
|
329 |
||
330 |
lx := x. |
|
331 |
ly := y. |
|
332 |
(trans := view transformation) notNil ifTrue:[ |
|
681 | 333 |
lx := trans applyInverseToX:lx. |
334 |
ly := trans applyInverseToY:ly. |
|
335 |
]. |
|
336 |
self buttonPress:button x:lx y:ly |
|
337 |
||
338 |
"Modified: 13.5.1996 / 11:24:23 / cg" |
|
339 |
! |
|
340 |
||
341 |
deviceButtonRelease:button x:x y:y |
|
342 |
"this is the low-level (untransformed) event as received |
|
343 |
from the device (i.e. coordinates are in device coordinates). |
|
344 |
If there is a transformation, apply the inverse |
|
345 |
and send a buttonRelease with the logical coordinates. |
|
346 |
||
347 |
Controllers which are interrested in deviceCoordinates should |
|
348 |
redefine this method - |
|
349 |
those which are interrested in logical coordinates |
|
350 |
should redefine #buttonRelease:x:y:" |
|
351 |
||
352 |
|lx ly trans| |
|
353 |
||
354 |
lx := x. |
|
355 |
ly := y. |
|
356 |
(trans := view transformation) notNil ifTrue:[ |
|
357 |
lx := trans applyInverseToX:lx. |
|
358 |
ly := trans applyInverseToY:ly. |
|
245 | 359 |
]. |
360 |
self buttonRelease:button x:lx y:ly |
|
681 | 361 |
|
362 |
"Modified: 13.5.1996 / 11:24:33 / cg" |
|
153 | 363 |
! |
364 |
||
365 |
deviceKeyPress:key x:x y:y |
|
366 |
"this is the low-level (untransformed) event as received |
|
367 |
from the device (i.e. coordinates are in device coordinates). |
|
368 |
If there is a transformation, apply the inverse |
|
681 | 369 |
and send a keyPress with the logical coordinates. |
370 |
||
371 |
Controllers which are interrested in deviceCoordinates should |
|
372 |
redefine this method - |
|
373 |
those which are interrested in logical coordinates |
|
374 |
should redefine #keyPress:x:y:" |
|
153 | 375 |
|
376 |
|lx ly trans| |
|
377 |
||
378 |
lx := x. |
|
379 |
ly := y. |
|
380 |
(trans := view transformation) notNil ifTrue:[ |
|
681 | 381 |
lx := trans applyInverseToX:lx. |
382 |
ly := trans applyInverseToY:ly. |
|
153 | 383 |
]. |
384 |
self keyPress:key x:lx y:ly |
|
681 | 385 |
|
386 |
"Modified: 13.5.1996 / 11:24:43 / cg" |
|
153 | 387 |
! |
388 |
||
389 |
deviceKeyRelease:key x:x y:y |
|
390 |
"this is the low-level (untransformed) event as received |
|
391 |
from the device (i.e. coordinates are in device coordinates). |
|
392 |
If there is a transformation, apply the inverse |
|
681 | 393 |
and send a keyRelease with the logical coordinates. |
394 |
||
395 |
Controllers which are interrested in deviceCoordinates should |
|
396 |
redefine this method - |
|
397 |
those which are interrested in logical coordinates |
|
398 |
should redefine #keyRelease:x:y:" |
|
153 | 399 |
|
400 |
|lx ly trans| |
|
401 |
||
402 |
lx := x. |
|
403 |
ly := y. |
|
404 |
(trans := view transformation) notNil ifTrue:[ |
|
681 | 405 |
lx := trans applyInverseToX:lx. |
406 |
ly := trans applyInverseToY:ly. |
|
153 | 407 |
]. |
408 |
self keyRelease:key x:lx y:ly |
|
681 | 409 |
|
410 |
"Modified: 13.5.1996 / 11:24:51 / cg" |
|
153 | 411 |
! |
412 |
||
245 | 413 |
devicePointerEnter:state x:x y:y |
153 | 414 |
"this is the low-level (untransformed) event as received |
415 |
from the device (i.e. coordinates are in device coordinates). |
|
416 |
If there is a transformation, apply the inverse |
|
681 | 417 |
and send a pointerEnter with the logical coordinates. |
418 |
||
419 |
Controllers which are interrested in deviceCoordinates should |
|
420 |
redefine this method - |
|
421 |
those which are interrested in logical coordinates |
|
422 |
should redefine #pointerEnter:x:y:" |
|
153 | 423 |
|
424 |
|lx ly trans| |
|
425 |
||
426 |
lx := x. |
|
427 |
ly := y. |
|
428 |
(trans := view transformation) notNil ifTrue:[ |
|
681 | 429 |
lx := trans applyInverseToX:lx. |
430 |
ly := trans applyInverseToY:ly. |
|
153 | 431 |
]. |
245 | 432 |
self pointerEnter:state x:lx y:ly |
681 | 433 |
|
434 |
"Modified: 13.5.1996 / 11:24:59 / cg" |
|
245 | 435 |
! |
436 |
||
437 |
focusIn |
|
438 |
"my view got the keyboard focus; nothing done here" |
|
439 |
||
440 |
^ self |
|
441 |
! |
|
442 |
||
443 |
focusOut |
|
444 |
"my view lost keyboard focus; nothing done here" |
|
445 |
||
446 |
^ self |
|
447 |
! |
|
448 |
||
449 |
keyPress:key x:x y:y |
|
416
0f08407c955e
use sensor shiftDown (instead of device shiftDown)
Claus Gittinger <cg@exept.de>
parents:
413
diff
changeset
|
450 |
"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
|
451 |
except for Tab keys." |
245 | 452 |
|
509 | 453 |
<resource: #keyboard (#Tab #FocusNext #FocusPrevious)> |
454 |
||
502
0df8d2b173e4
focusKey handling now done here & in TopView
Claus Gittinger <cg@exept.de>
parents:
472
diff
changeset
|
455 |
|windowGroup| |
413
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
456 |
|
502
0df8d2b173e4
focusKey handling now done here & in TopView
Claus Gittinger <cg@exept.de>
parents:
472
diff
changeset
|
457 |
windowGroup := view windowGroup. |
416
0f08407c955e
use sensor shiftDown (instead of device shiftDown)
Claus Gittinger <cg@exept.de>
parents:
413
diff
changeset
|
458 |
key == #Tab ifTrue:[ |
502
0df8d2b173e4
focusKey handling now done here & in TopView
Claus Gittinger <cg@exept.de>
parents:
472
diff
changeset
|
459 |
windowGroup notNil ifTrue:[ |
744 | 460 |
view graphicsDevice shiftDown ifTrue:[ |
502
0df8d2b173e4
focusKey handling now done here & in TopView
Claus Gittinger <cg@exept.de>
parents:
472
diff
changeset
|
461 |
windowGroup focusPrevious |
416
0f08407c955e
use sensor shiftDown (instead of device shiftDown)
Claus Gittinger <cg@exept.de>
parents:
413
diff
changeset
|
462 |
] ifFalse:[ |
502
0df8d2b173e4
focusKey handling now done here & in TopView
Claus Gittinger <cg@exept.de>
parents:
472
diff
changeset
|
463 |
windowGroup focusNext |
416
0f08407c955e
use sensor shiftDown (instead of device shiftDown)
Claus Gittinger <cg@exept.de>
parents:
413
diff
changeset
|
464 |
]. |
0f08407c955e
use sensor shiftDown (instead of device shiftDown)
Claus Gittinger <cg@exept.de>
parents:
413
diff
changeset
|
465 |
] |
413
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
466 |
]. |
502
0df8d2b173e4
focusKey handling now done here & in TopView
Claus Gittinger <cg@exept.de>
parents:
472
diff
changeset
|
467 |
key == #FocusNext ifTrue:[ |
0df8d2b173e4
focusKey handling now done here & in TopView
Claus Gittinger <cg@exept.de>
parents:
472
diff
changeset
|
468 |
windowGroup notNil ifTrue:[ |
0df8d2b173e4
focusKey handling now done here & in TopView
Claus Gittinger <cg@exept.de>
parents:
472
diff
changeset
|
469 |
windowGroup focusNext. |
0df8d2b173e4
focusKey handling now done here & in TopView
Claus Gittinger <cg@exept.de>
parents:
472
diff
changeset
|
470 |
] |
0df8d2b173e4
focusKey handling now done here & in TopView
Claus Gittinger <cg@exept.de>
parents:
472
diff
changeset
|
471 |
]. |
0df8d2b173e4
focusKey handling now done here & in TopView
Claus Gittinger <cg@exept.de>
parents:
472
diff
changeset
|
472 |
key == #FocusPrevious ifTrue:[ |
0df8d2b173e4
focusKey handling now done here & in TopView
Claus Gittinger <cg@exept.de>
parents:
472
diff
changeset
|
473 |
windowGroup notNil ifTrue:[ |
0df8d2b173e4
focusKey handling now done here & in TopView
Claus Gittinger <cg@exept.de>
parents:
472
diff
changeset
|
474 |
windowGroup focusPrevious. |
0df8d2b173e4
focusKey handling now done here & in TopView
Claus Gittinger <cg@exept.de>
parents:
472
diff
changeset
|
475 |
] |
0df8d2b173e4
focusKey handling now done here & in TopView
Claus Gittinger <cg@exept.de>
parents:
472
diff
changeset
|
476 |
]. |
0df8d2b173e4
focusKey handling now done here & in TopView
Claus Gittinger <cg@exept.de>
parents:
472
diff
changeset
|
477 |
|
245 | 478 |
^ self |
413
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
479 |
|
744 | 480 |
"Modified: 28.5.1996 / 20:21:41 / cg" |
245 | 481 |
! |
482 |
||
483 |
keyRelease:key x:x y:y |
|
484 |
"key was released in my view; nothing done here" |
|
485 |
||
486 |
^ self |
|
487 |
! |
|
488 |
||
489 |
pointerEnter:state x:x y:y |
|
490 |
"mouse pointer entered my view; nothing done here" |
|
491 |
||
492 |
^ self |
|
153 | 493 |
! |
494 |
||
245 | 495 |
pointerLeave:state |
496 |
"mouse pointer left my view; nothing done here" |
|
153 | 497 |
|
245 | 498 |
^ self |
499 |
! ! |
|
153 | 500 |
|
413
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
501 |
!Controller methodsFor:'initialize / release'! |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
502 |
|
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
503 |
initialize |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
504 |
"initialize the controller; subclasses should redefine |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
505 |
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
|
506 |
|
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
507 |
^ self |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
508 |
! |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
509 |
|
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
510 |
release |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
511 |
"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
|
512 |
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
|
513 |
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
|
514 |
|
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
515 |
view notNil ifTrue:[view controller:nil]. |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
516 |
view := nil. |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
517 |
model := nil |
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 |
|
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
520 |
startUp |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
521 |
"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
|
522 |
right before it becomes visible. |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
523 |
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
|
524 |
|
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
525 |
self controlInitialize. |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
526 |
! ! |
2bd84440febd
forward Tab to the views windowGroup (if any)
Claus Gittinger <cg@exept.de>
parents:
252
diff
changeset
|
527 |
|
245 | 528 |
!Controller methodsFor:'menus'! |
529 |
||
530 |
yellowButtonMenu |
|
531 |
"actually, this should be called 'middleButtonMenu'. |
|
532 |
But for ST-80 compatibility ...." |
|
533 |
||
534 |
|sym menuHolder m| |
|
153 | 535 |
|
245 | 536 |
"/ (m := view middleButtonMenu) notNil ifTrue:[ |
537 |
"/ "/ |
|
538 |
"/ "/ has been assigned a static middleButtonMenu |
|
539 |
"/ "/ (or a cached menu) |
|
540 |
"/ "/ |
|
541 |
"/ ^ m |
|
542 |
"/ ]. |
|
153 | 543 |
|
245 | 544 |
menuHolder := self menuHolder. |
153 | 545 |
|
245 | 546 |
" |
547 |
try ST-80 style menus first: |
|
548 |
if there is a model, and a menuMessage is defined, |
|
549 |
ask model for the menu and launch that if non-nil. |
|
550 |
" |
|
551 |
(menuHolder notNil |
|
552 |
and:[(sym := view menuMessage) notNil |
|
553 |
and:[sym isSymbol]]) ifTrue:[ |
|
554 |
" |
|
555 |
ask model for the menu |
|
556 |
" |
|
557 |
^ menuHolder perform:sym. |
|
153 | 558 |
]. |
245 | 559 |
^ nil |
0 | 560 |
! ! |
245 | 561 |
|
1012
e408830caf2d
no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents:
744
diff
changeset
|
562 |
!Controller class methodsFor:'documentation'! |
252 | 563 |
|
564 |
version |
|
1036 | 565 |
^ '$Header: /cvs/stx/stx/libview/Controller.st,v 1.38 1996-08-22 07:12:24 cg Exp $' |
252 | 566 |
! ! |