author | Claus Gittinger <cg@exept.de> |
Wed, 26 Jun 2013 01:06:26 +0200 | |
changeset 6088 | 43475a5a6ac6 |
parent 6034 | a4e78ef00042 |
child 6276 | 08a809f9180a |
permissions | -rw-r--r-- |
0 | 1 |
" |
6 | 2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
72 | 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 |
" |
|
3204
ed184af034d3
Remove dependents on various channels when destroying.
Stefan Vogel <sv@exept.de>
parents:
3170
diff
changeset
|
12 |
"{ Package: 'stx:libview' }" |
ed184af034d3
Remove dependents on various channels when destroying.
Stefan Vogel <sv@exept.de>
parents:
3170
diff
changeset
|
13 |
|
135 | 14 |
SimpleView subclass:#View |
2548 | 15 |
instanceVariableNames:'model aspectMsg changeMsg menuMsg menuHolder menuPerformer |
3365
a76614b953c7
lifted visibilityChannel stuff to superclass
Claus Gittinger <cg@exept.de>
parents:
3355
diff
changeset
|
16 |
enableChannel foregroundChannel backgroundChannel' |
616 | 17 |
classVariableNames:'' |
18 |
poolDictionaries:'' |
|
19 |
category:'Views-Basic' |
|
0 | 20 |
! |
21 |
||
2 | 22 |
!View class methodsFor:'documentation'! |
41 | 23 |
|
46 | 24 |
copyright |
25 |
" |
|
26 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
72 | 27 |
All Rights Reserved |
46 | 28 |
|
29 |
This software is furnished under a license and may be used |
|
30 |
only in accordance with the terms of that license and with the |
|
31 |
inclusion of the above copyright notice. This software may not |
|
32 |
be provided or otherwise made available to, or used by, any |
|
33 |
other person. No title to or ownership of the software is |
|
34 |
hereby transferred. |
|
35 |
" |
|
36 |
! |
|
37 |
||
41 | 38 |
documentation |
2 | 39 |
" |
135 | 40 |
this class adds provisions for views which show or work on a model. |
41 |
This functionality used to be in View, but has been extracted into SimpleView and |
|
42 |
this new View class, to take some of the stuff out of views which do not need |
|
43 |
this functionality (i.e. all views which do only geometry management). |
|
82 | 44 |
Instances of View are seldom used, most views in the system inherit |
45 |
from this class. |
|
41 | 46 |
|
616 | 47 |
[Instance variables:] |
48 |
model <nil | any> the model (if any) |
|
41 | 49 |
|
616 | 50 |
aspectMsg <nil | Symbol> the aspect; typically |
51 |
dependentViews react on changes |
|
52 |
of this aspect and update their contents. |
|
53 |
||
54 |
changeMsg <nil | Symbol> the changeMessage; typically |
|
55 |
dependentViews send this message to |
|
56 |
the model to tell it about changes. |
|
140 | 57 |
|
616 | 58 |
menuMsg <nil | Symbol> the menuMessage; typically |
59 |
dependentViews send this message to |
|
60 |
the model to ask for a popup menu. |
|
1151
1a3682212ea9
Move rest of menuHolder/menuPerformer stuff to view.
Stefan Vogel <sv@exept.de>
parents:
1149
diff
changeset
|
61 |
|
1a3682212ea9
Move rest of menuHolder/menuPerformer stuff to view.
Stefan Vogel <sv@exept.de>
parents:
1149
diff
changeset
|
62 |
|
1152
21c666e130dd
menuHolder/menuPerformer stuff.
Stefan Vogel <sv@exept.de>
parents:
1151
diff
changeset
|
63 |
menuHolder <any> who has a menu |
21c666e130dd
menuHolder/menuPerformer stuff.
Stefan Vogel <sv@exept.de>
parents:
1151
diff
changeset
|
64 |
(default: nil i.e. model has menu) |
21c666e130dd
menuHolder/menuPerformer stuff.
Stefan Vogel <sv@exept.de>
parents:
1151
diff
changeset
|
65 |
|
21c666e130dd
menuHolder/menuPerformer stuff.
Stefan Vogel <sv@exept.de>
parents:
1151
diff
changeset
|
66 |
menuPerformer <any> who performs menu actions |
21c666e130dd
menuHolder/menuPerformer stuff.
Stefan Vogel <sv@exept.de>
parents:
1151
diff
changeset
|
67 |
(default: nil i.e. model has menu) |
616 | 68 |
|
69 |
[see also:] |
|
621 | 70 |
StandardSystemView TopView DialogBox |
616 | 71 |
WindowGroup |
621 | 72 |
Model ValueHolder |
616 | 73 |
( introduction to view programming :html: programming/viewintro.html ) |
74 |
||
140 | 75 |
|
616 | 76 |
[author:] |
77 |
Claus Gittinger |
|
78 |
" |
|
79 |
! |
|
80 |
||
81 |
examples |
|
82 |
" |
|
83 |
a subView in a topView: |
|
621 | 84 |
[exBegin] |
616 | 85 |
|top v| |
140 | 86 |
|
2134 | 87 |
top := StandardSystemView new. |
616 | 88 |
v := View new. |
89 |
v origin:0.25 @ 0.25 corner:0.75 @ 0.75. |
|
90 |
top addSubView:v. |
|
91 |
top open |
|
621 | 92 |
[exEnd] |
616 | 93 |
|
94 |
||
95 |
the same, a bit more compact: |
|
621 | 96 |
[exBegin] |
616 | 97 |
|top v| |
98 |
||
2134 | 99 |
top := StandardSystemView new. |
100 |
v := View origin:0.25 @ 0.25 corner:0.75 @ 0.75 in:top. |
|
101 |
top open |
|
102 |
[exEnd] |
|
103 |
||
104 |
menuHolder |
|
105 |
[exBegin] |
|
106 |
|top mh| |
|
107 |
||
108 |
mh := (PopUpMenu itemList:#( ('foo' foo) (#'bar' bar)) resources:nil) asValue. |
|
109 |
||
110 |
top := StandardSystemView extent:200@200. |
|
111 |
top menuHolder:mh. |
|
112 |
top open |
|
113 |
[exEnd] |
|
114 |
||
115 |
||
116 |
menuHolder |
|
117 |
[exBegin] |
|
118 |
|top mh| |
|
119 |
||
120 |
mh := (PopUpMenu itemList:#( ('foo' foo) (#'bar' bar)) resources:nil) asValue. |
|
121 |
[ |
|
122 |
Delay waitForSeconds:5. |
|
123 |
mh value: (PopUpMenu itemList:#( ('waboo' foo) (#'baz' bar)) resources:nil) |
|
124 |
] fork. |
|
125 |
||
126 |
top := StandardSystemView extent:200@200. |
|
127 |
top menuHolder:mh. |
|
616 | 128 |
top open |
621 | 129 |
[exEnd] |
130 |
||
2 | 131 |
" |
132 |
! ! |
|
0 | 133 |
|
118 | 134 |
!View class methodsFor:'instance creation'! |
135 |
||
140 | 136 |
on:aModel aspect:aspectMsg |
137 |
"st-80 style view creation: create a new view, set its model |
|
138 |
and selectors for aspect" |
|
139 |
||
140 |
^ self new |
|
141 |
on:aModel |
|
142 |
aspect:aspectMsg |
|
143 |
! |
|
144 |
||
145 |
on:aModel aspect:aspectMsg change:changeMsg |
|
146 |
"st-80 style view creation: create a new view, set its model |
|
147 |
and selectors for aspect and change" |
|
148 |
||
149 |
^ self new |
|
150 |
on:aModel |
|
151 |
aspect:aspectMsg |
|
152 |
change:changeMsg |
|
153 |
! |
|
154 |
||
135 | 155 |
on:aModel aspect:aspectMsg change:changeMsg menu:menuMsg |
118 | 156 |
"st-80 style view creation: create a new view, set its model |
140 | 157 |
and selectors for aspect, change and menu" |
118 | 158 |
|
135 | 159 |
^ self new |
160 |
on:aModel |
|
161 |
aspect:aspectMsg |
|
162 |
change:changeMsg |
|
163 |
menu:menuMsg |
|
118 | 164 |
! |
165 |
||
269 | 166 |
on:aModel aspect:aspectMsg menu:menuMsg |
167 |
"st-80 style view creation: create a new view, set its model |
|
168 |
and selectors for aspect and menu" |
|
118 | 169 |
|
269 | 170 |
^ self new |
171 |
on:aModel |
|
172 |
aspect:aspectMsg |
|
173 |
menu:menuMsg |
|
118 | 174 |
! ! |
175 |
||
123 | 176 |
!View class methodsFor:'defaults'! |
177 |
||
140 | 178 |
defaultAspectMessage |
135 | 179 |
"subclasses which by default do NOT want to be informed about changed |
180 |
models should redefine this to return nil" |
|
118 | 181 |
|
135 | 182 |
^ #value |
0 | 183 |
! |
184 |
||
140 | 185 |
defaultChangeMessage |
135 | 186 |
"subclasses which by default do NOT want to inform the model |
187 |
should redefine this to return nil" |
|
0 | 188 |
|
135 | 189 |
^ #value: |
1151
1a3682212ea9
Move rest of menuHolder/menuPerformer stuff to view.
Stefan Vogel <sv@exept.de>
parents:
1149
diff
changeset
|
190 |
! |
1a3682212ea9
Move rest of menuHolder/menuPerformer stuff to view.
Stefan Vogel <sv@exept.de>
parents:
1149
diff
changeset
|
191 |
|
1a3682212ea9
Move rest of menuHolder/menuPerformer stuff to view.
Stefan Vogel <sv@exept.de>
parents:
1149
diff
changeset
|
192 |
defaultMenuMessage |
1a3682212ea9
Move rest of menuHolder/menuPerformer stuff to view.
Stefan Vogel <sv@exept.de>
parents:
1149
diff
changeset
|
193 |
"subclasses which by default do NOT want to send menu messages |
1a3682212ea9
Move rest of menuHolder/menuPerformer stuff to view.
Stefan Vogel <sv@exept.de>
parents:
1149
diff
changeset
|
194 |
should return nil" |
1a3682212ea9
Move rest of menuHolder/menuPerformer stuff to view.
Stefan Vogel <sv@exept.de>
parents:
1149
diff
changeset
|
195 |
|
1a3682212ea9
Move rest of menuHolder/menuPerformer stuff to view.
Stefan Vogel <sv@exept.de>
parents:
1149
diff
changeset
|
196 |
^ nil |
1a3682212ea9
Move rest of menuHolder/menuPerformer stuff to view.
Stefan Vogel <sv@exept.de>
parents:
1149
diff
changeset
|
197 |
|
1a3682212ea9
Move rest of menuHolder/menuPerformer stuff to view.
Stefan Vogel <sv@exept.de>
parents:
1149
diff
changeset
|
198 |
"Created: 3.1.1997 / 01:50:36 / stefan" |
0 | 199 |
! ! |
200 |
||
6034
a4e78ef00042
moved assignKeyboardFocus stuff from topView
Claus Gittinger <cg@exept.de>
parents:
4985
diff
changeset
|
201 |
!View methodsFor:'accessing-behavior'! |
a4e78ef00042
moved assignKeyboardFocus stuff from topView
Claus Gittinger <cg@exept.de>
parents:
4985
diff
changeset
|
202 |
|
a4e78ef00042
moved assignKeyboardFocus stuff from topView
Claus Gittinger <cg@exept.de>
parents:
4985
diff
changeset
|
203 |
preferFirstInputFieldWhenAssigningInitialFocus |
a4e78ef00042
moved assignKeyboardFocus stuff from topView
Claus Gittinger <cg@exept.de>
parents:
4985
diff
changeset
|
204 |
"define the focus behavior for dialogs. |
a4e78ef00042
moved assignKeyboardFocus stuff from topView
Claus Gittinger <cg@exept.de>
parents:
4985
diff
changeset
|
205 |
If true is returned, input fields take precedence over other keyboard consumers. |
a4e78ef00042
moved assignKeyboardFocus stuff from topView
Claus Gittinger <cg@exept.de>
parents:
4985
diff
changeset
|
206 |
This used to return true, but the behavior is somewhat ugly." |
a4e78ef00042
moved assignKeyboardFocus stuff from topView
Claus Gittinger <cg@exept.de>
parents:
4985
diff
changeset
|
207 |
|
a4e78ef00042
moved assignKeyboardFocus stuff from topView
Claus Gittinger <cg@exept.de>
parents:
4985
diff
changeset
|
208 |
^ false |
a4e78ef00042
moved assignKeyboardFocus stuff from topView
Claus Gittinger <cg@exept.de>
parents:
4985
diff
changeset
|
209 |
|
a4e78ef00042
moved assignKeyboardFocus stuff from topView
Claus Gittinger <cg@exept.de>
parents:
4985
diff
changeset
|
210 |
"Created: / 29-08-2006 / 14:28:54 / cg" |
a4e78ef00042
moved assignKeyboardFocus stuff from topView
Claus Gittinger <cg@exept.de>
parents:
4985
diff
changeset
|
211 |
! ! |
a4e78ef00042
moved assignKeyboardFocus stuff from topView
Claus Gittinger <cg@exept.de>
parents:
4985
diff
changeset
|
212 |
|
3355
2ec13d9b93ca
in allViewBackground: do not change the bg, if I have a bg-channel
Claus Gittinger <cg@exept.de>
parents:
3204
diff
changeset
|
213 |
!View methodsFor:'accessing-bg & border'! |
2ec13d9b93ca
in allViewBackground: do not change the bg, if I have a bg-channel
Claus Gittinger <cg@exept.de>
parents:
3204
diff
changeset
|
214 |
|
4957 | 215 |
allViewBackground:something if:condition |
3355
2ec13d9b93ca
in allViewBackground: do not change the bg, if I have a bg-channel
Claus Gittinger <cg@exept.de>
parents:
3204
diff
changeset
|
216 |
"set the viewBackground to something, a color, image or form, |
2ec13d9b93ca
in allViewBackground: do not change the bg, if I have a bg-channel
Claus Gittinger <cg@exept.de>
parents:
3204
diff
changeset
|
217 |
in myself and recursively in all of my subviews. |
2ec13d9b93ca
in allViewBackground: do not change the bg, if I have a bg-channel
Claus Gittinger <cg@exept.de>
parents:
3204
diff
changeset
|
218 |
However, if I have a backgroundChannel, dont change my own bg." |
2ec13d9b93ca
in allViewBackground: do not change the bg, if I have a bg-channel
Claus Gittinger <cg@exept.de>
parents:
3204
diff
changeset
|
219 |
|
2ec13d9b93ca
in allViewBackground: do not change the bg, if I have a bg-channel
Claus Gittinger <cg@exept.de>
parents:
3204
diff
changeset
|
220 |
backgroundChannel isNil ifTrue:[ |
4957 | 221 |
^ super allViewBackground:something if:condition |
3355
2ec13d9b93ca
in allViewBackground: do not change the bg, if I have a bg-channel
Claus Gittinger <cg@exept.de>
parents:
3204
diff
changeset
|
222 |
]. |
2ec13d9b93ca
in allViewBackground: do not change the bg, if I have a bg-channel
Claus Gittinger <cg@exept.de>
parents:
3204
diff
changeset
|
223 |
|
4957 | 224 |
self allSubViewsBackground:something if:condition |
3355
2ec13d9b93ca
in allViewBackground: do not change the bg, if I have a bg-channel
Claus Gittinger <cg@exept.de>
parents:
3204
diff
changeset
|
225 |
! ! |
2ec13d9b93ca
in allViewBackground: do not change the bg, if I have a bg-channel
Claus Gittinger <cg@exept.de>
parents:
3204
diff
changeset
|
226 |
|
170 | 227 |
!View methodsFor:'accessing-channels'! |
228 |
||
2548 | 229 |
backgroundChannel |
230 |
"return a valueHolder for background color" |
|
231 |
||
232 |
^ backgroundChannel |
|
233 |
||
234 |
"Modified: / 30.3.1999 / 13:49:28 / stefan" |
|
235 |
"Created: / 30.3.1999 / 13:50:55 / stefan" |
|
236 |
! |
|
237 |
||
238 |
backgroundChannel:aValueHolder |
|
4985 | 239 |
"set the backgroundChannel - a valueHolder holding a color" |
2548 | 240 |
|
241 |
|prev| |
|
242 |
||
243 |
prev := backgroundChannel. |
|
244 |
backgroundChannel := aValueHolder. |
|
4926 | 245 |
self setupChannel:aValueHolder for:#backgroundColorChanged withOld:prev |
2548 | 246 |
|
247 |
"Modified: / 31.10.1997 / 14:38:38 / cg" |
|
248 |
"Created: / 30.3.1999 / 13:48:42 / stefan" |
|
249 |
! |
|
250 |
||
251 |
enableChannel |
|
252 |
"return a valueHolder for enable/disable" |
|
253 |
||
254 |
^ enableChannel |
|
255 |
||
256 |
"Created: / 30.3.1999 / 13:46:43 / stefan" |
|
257 |
! |
|
258 |
||
259 |
enableChannel:aValueHolder |
|
260 |
"set the valueHolder, which holds the enable boolean value" |
|
261 |
||
262 |
|prev| |
|
263 |
||
264 |
prev := enableChannel. |
|
265 |
enableChannel := aValueHolder. |
|
2950
705ddb097eec
Fix visibilityChannel and enableChannel stuff
Claus Gittinger <cg@exept.de>
parents:
2573
diff
changeset
|
266 |
self setupChannel:aValueHolder for:#enableStateChanged withOld:prev |
2548 | 267 |
|
268 |
"Modified: / 14.11.1997 / 13:52:44 / cg" |
|
269 |
"Modified: / 30.3.1999 / 13:50:15 / stefan" |
|
270 |
! |
|
271 |
||
272 |
foregroundChannel |
|
273 |
"return a valueHolder for foreground color" |
|
274 |
||
275 |
^ foregroundChannel |
|
276 |
||
277 |
"Modified: / 30.3.1999 / 13:49:28 / stefan" |
|
278 |
! |
|
279 |
||
280 |
foregroundChannel:aValueHolder |
|
281 |
"set the foregroundChannel - a valueHolder holding a color" |
|
282 |
||
283 |
|prev| |
|
284 |
||
285 |
prev := foregroundChannel. |
|
286 |
foregroundChannel := aValueHolder. |
|
4926 | 287 |
self setupChannel:aValueHolder for:#foregroundColorChanged withOld:prev |
2548 | 288 |
|
289 |
"Modified: / 31.10.1997 / 14:38:38 / cg" |
|
290 |
"Modified: / 30.3.1999 / 13:50:08 / stefan" |
|
170 | 291 |
! ! |
292 |
||
269 | 293 |
!View methodsFor:'accessing-menus'! |
294 |
||
295 |
menuHolder |
|
296 |
"who has the menu ? |
|
1147
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
297 |
If no explicit menuHolder was defined, its the model if I have one. |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
298 |
Otherwise, its the menuHolder (if nonNil) or mySelf. |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
299 |
The menuHolder is supposed to return a popUpMenu when asked via the |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
300 |
menuMessage." |
269 | 301 |
|
1147
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
302 |
menuHolder notNil ifTrue:[^ menuHolder]. |
269 | 303 |
model notNil ifTrue:[^ model]. |
304 |
^ self |
|
1147
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
305 |
|
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
306 |
"Modified: 23.12.1996 / 13:56:55 / cg" |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
307 |
! |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
308 |
|
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
309 |
menuHolder:anObject |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
310 |
"change the one that provides the menu (via menuMsg)." |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
311 |
|
2134 | 312 |
menuHolder := anObject. |
313 |
menuMsg isNil ifTrue:[menuMsg := #value]. |
|
1147
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
314 |
|
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
315 |
"Created: 23.12.1996 / 13:54:33 / cg" |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
316 |
! |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
317 |
|
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
318 |
menuMessage |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
319 |
"Return the symbol sent to the model to aquire the menu" |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
320 |
|
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
321 |
^ menuMsg |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
322 |
! |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
323 |
|
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
324 |
menuMessage:aSymbol |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
325 |
"ST-80 style menus: If a views menuSymbol is nonNil, it |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
326 |
will send it to its model when the middleButton is pressed. |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
327 |
That method should return nil or the menu to be shown. |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
328 |
This is useful for very dynamic menus, where it does not |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
329 |
make sense to define an initial menu. |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
330 |
This is the same as #menu: which was added for ST-80 compatibility." |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
331 |
|
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
332 |
menuMsg := aSymbol |
269 | 333 |
! |
334 |
||
335 |
menuPerformer |
|
336 |
"who should perform the menu actions ? |
|
1147
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
337 |
If no menuPerformer was defined, its the model if I have one. |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
338 |
Otherwise its the menuPerformer (if nonNil), or myself. |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
339 |
The menuPerformer get messages from the menu" |
269 | 340 |
|
1147
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
341 |
menuPerformer notNil ifTrue:[^ menuPerformer]. |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
342 |
|
3405
0c6b6fcd819f
if never set, the default menuPerformer is
Claus Gittinger <cg@exept.de>
parents:
3365
diff
changeset
|
343 |
"/ the stuff below tries to make for a reasonable |
0c6b6fcd819f
if never set, the default menuPerformer is
Claus Gittinger <cg@exept.de>
parents:
3365
diff
changeset
|
344 |
"/ default, in case the menuPerformer was NOT set explicitely |
0c6b6fcd819f
if never set, the default menuPerformer is
Claus Gittinger <cg@exept.de>
parents:
3365
diff
changeset
|
345 |
"/ (you should not depend on this in your application) |
0c6b6fcd819f
if never set, the default menuPerformer is
Claus Gittinger <cg@exept.de>
parents:
3365
diff
changeset
|
346 |
(model isNil |
0c6b6fcd819f
if never set, the default menuPerformer is
Claus Gittinger <cg@exept.de>
parents:
3365
diff
changeset
|
347 |
or:[model isValueModel |
0c6b6fcd819f
if never set, the default menuPerformer is
Claus Gittinger <cg@exept.de>
parents:
3365
diff
changeset
|
348 |
or:[model isBlock]]) ifTrue:[ |
0c6b6fcd819f
if never set, the default menuPerformer is
Claus Gittinger <cg@exept.de>
parents:
3365
diff
changeset
|
349 |
"/ a simple holder-model. dont send menuMessages to it |
0c6b6fcd819f
if never set, the default menuPerformer is
Claus Gittinger <cg@exept.de>
parents:
3365
diff
changeset
|
350 |
^ self application ? self |
0c6b6fcd819f
if never set, the default menuPerformer is
Claus Gittinger <cg@exept.de>
parents:
3365
diff
changeset
|
351 |
]. |
0c6b6fcd819f
if never set, the default menuPerformer is
Claus Gittinger <cg@exept.de>
parents:
3365
diff
changeset
|
352 |
^ model |
1147
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
353 |
! |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
354 |
|
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
355 |
menuPerformer:anObject |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
356 |
"change the one that does the menu actions. |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
357 |
See the comment in SimpleView>>activateMenu on who gets the menus |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
358 |
message." |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
359 |
|
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
360 |
menuPerformer := anObject |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
361 |
|
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
362 |
" |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
363 |
|top textV plug| |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
364 |
|
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
365 |
plug := Plug new. |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
366 |
plug respondTo:#textMenu |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
367 |
with:[ |m| |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
368 |
m := PopUpMenu |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
369 |
labels:#('copy' 'foo' '-' 'others') |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
370 |
selectors:#(copySelection foo nil others). |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
371 |
m subMenuAt:#others |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
372 |
put:(PopUpMenu |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
373 |
labels:#('bar' 'goto') |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
374 |
selectors:#(bar gotoLine)) |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
375 |
]. |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
376 |
|
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
377 |
top := StandardSystemView new. |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
378 |
top extent:300@300. |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
379 |
|
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
380 |
textV := TextView origin:0.0@0.0 corner:1.0@1.0 in:top. |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
381 |
textV menuHolder:plug; menuMessage:#textMenu; menuPerformer:plug. |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
382 |
textV contents:'hello world'. |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
383 |
top open. |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
384 |
" |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
385 |
|
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
386 |
"Created: 23.12.1996 / 13:57:28 / cg" |
2166
d6e05def4f83
added #performer: (dummy - ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
2134
diff
changeset
|
387 |
! |
d6e05def4f83
added #performer: (dummy - ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
2134
diff
changeset
|
388 |
|
d6e05def4f83
added #performer: (dummy - ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
2134
diff
changeset
|
389 |
performer:anObject |
d6e05def4f83
added #performer: (dummy - ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
2134
diff
changeset
|
390 |
"same as #menuPerformer - ST80 compatibility" |
d6e05def4f83
added #performer: (dummy - ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
2134
diff
changeset
|
391 |
|
d6e05def4f83
added #performer: (dummy - ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
2134
diff
changeset
|
392 |
self menuPerformer:anObject |
d6e05def4f83
added #performer: (dummy - ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
2134
diff
changeset
|
393 |
|
d6e05def4f83
added #performer: (dummy - ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
2134
diff
changeset
|
394 |
"Created: / 6.7.1998 / 13:38:32 / cg" |
269 | 395 |
! ! |
396 |
||
118 | 397 |
!View methodsFor:'accessing-mvc'! |
398 |
||
269 | 399 |
addModelInterfaceTo:aDictionary |
400 |
"this adds entries for all messages sent to my model |
|
401 |
to aDictionary" |
|
402 |
||
403 |
aDictionary at:#aspectMessage put:aspectMsg. |
|
404 |
aDictionary at:#changeMessage put:changeMsg. |
|
405 |
aDictionary at:#menuMessage put:menuMsg. |
|
406 |
||
407 |
" |
|
408 |
Button new modelInterface |
|
409 |
" |
|
410 |
! |
|
135 | 411 |
|
269 | 412 |
aspect |
413 |
"Return the aspect used with changes from/to the model" |
|
414 |
||
415 |
^ aspectMsg |
|
416 |
! |
|
417 |
||
418 |
aspectMessage |
|
419 |
"Return the aspect used with changes from/to the model" |
|
420 |
||
421 |
^ aspectMsg |
|
422 |
! |
|
423 |
||
424 |
aspectMessage:aspectSymbol |
|
425 |
"ST-80 style updating: If a views aspectSymbol is nonNil, |
|
426 |
it will respond to changes of this aspect from the model." |
|
427 |
||
428 |
aspectMsg := aspectSymbol |
|
135 | 429 |
! |
430 |
||
269 | 431 |
change:changeSymbol |
432 |
"ST-80 style change notification: If a views changeSymbol is nonNil, |
|
433 |
it will send it to its model when something changes. |
|
434 |
Alias for changeMessage: for ST-80 compatibility." |
|
435 |
||
436 |
self changeMessage:changeSymbol |
|
437 |
! |
|
438 |
||
439 |
changeMessage |
|
440 |
"Return the symbol sent to the model if nonNil when something changes." |
|
135 | 441 |
|
269 | 442 |
^ changeMsg |
443 |
! |
|
444 |
||
445 |
changeMessage:aSymbol |
|
446 |
"ST-80 style change notification: If a views changeSymbol is nonNil, |
|
447 |
it will send it to its model when something changes. |
|
448 |
This is the same as change: which was added for ST-80 compatibility." |
|
449 |
||
450 |
changeMsg := aSymbol |
|
451 |
! |
|
452 |
||
453 |
controller:aController |
|
454 |
"set the controller" |
|
118 | 455 |
|
269 | 456 |
super controller:aController. |
457 |
controller notNil ifTrue:[ |
|
458 |
controller model:model |
|
0 | 459 |
] |
460 |
! |
|
461 |
||
269 | 462 |
menu:menuSymbol |
463 |
"ST-80 style menus: If a views menuSymbol is nonNil, it |
|
464 |
will send it to its model when the middleButton is pressed. |
|
465 |
That method should return nil or the menu to be shown. |
|
466 |
This is useful for very dynamic menus, where it does not |
|
467 |
make sense to define an initial menu. |
|
468 |
Alias for #menuMessage:, for ST-80 compatibility." |
|
469 |
||
470 |
menuMsg := menuSymbol |
|
471 |
! |
|
472 |
||
118 | 473 |
model |
474 |
"return the model, for non-MVC views, |
|
475 |
this is nil or the receiver" |
|
476 |
||
477 |
^ model |
|
478 |
! |
|
479 |
||
480 |
model:aModel |
|
1151
1a3682212ea9
Move rest of menuHolder/menuPerformer stuff to view.
Stefan Vogel <sv@exept.de>
parents:
1149
diff
changeset
|
481 |
"Set the model. |
1149
a3a75ffb29ce
Set meuPerformer also, when model is set.
Stefan Vogel <sv@exept.de>
parents:
1147
diff
changeset
|
482 |
Here, if I am my own menuPerformer/menuHolder, |
1151
1a3682212ea9
Move rest of menuHolder/menuPerformer stuff to view.
Stefan Vogel <sv@exept.de>
parents:
1149
diff
changeset
|
483 |
set the menuHolder and menuPerformer to the model. |
1a3682212ea9
Move rest of menuHolder/menuPerformer stuff to view.
Stefan Vogel <sv@exept.de>
parents:
1149
diff
changeset
|
484 |
This is a compatibility kludge, |
1149
a3a75ffb29ce
Set meuPerformer also, when model is set.
Stefan Vogel <sv@exept.de>
parents:
1147
diff
changeset
|
485 |
since typically, ST-80 code expects the model to provide a menu |
1151
1a3682212ea9
Move rest of menuHolder/menuPerformer stuff to view.
Stefan Vogel <sv@exept.de>
parents:
1149
diff
changeset
|
486 |
and perform it. If the model does not support a menu message, |
1a3682212ea9
Move rest of menuHolder/menuPerformer stuff to view.
Stefan Vogel <sv@exept.de>
parents:
1149
diff
changeset
|
487 |
it will be forwarded to the view. |
1149
a3a75ffb29ce
Set meuPerformer also, when model is set.
Stefan Vogel <sv@exept.de>
parents:
1147
diff
changeset
|
488 |
Those apps which want the view to provide the (default) menu have to reset |
a3a75ffb29ce
Set meuPerformer also, when model is set.
Stefan Vogel <sv@exept.de>
parents:
1147
diff
changeset
|
489 |
this by sending #menuHolder: message (again)" |
118 | 490 |
|
491 |
model notNil ifTrue:[ |
|
1149
a3a75ffb29ce
Set meuPerformer also, when model is set.
Stefan Vogel <sv@exept.de>
parents:
1147
diff
changeset
|
492 |
model removeDependent:self |
89 | 493 |
]. |
118 | 494 |
model := aModel. |
2524
6a32a348aaa4
relaxed setting of menuPerformer to model,
Claus Gittinger <cg@exept.de>
parents:
2166
diff
changeset
|
495 |
|
6a32a348aaa4
relaxed setting of menuPerformer to model,
Claus Gittinger <cg@exept.de>
parents:
2166
diff
changeset
|
496 |
"/ ST80 kludge start |
6a32a348aaa4
relaxed setting of menuPerformer to model,
Claus Gittinger <cg@exept.de>
parents:
2166
diff
changeset
|
497 |
(menuPerformer == self |
6a32a348aaa4
relaxed setting of menuPerformer to model,
Claus Gittinger <cg@exept.de>
parents:
2166
diff
changeset
|
498 |
and:[menuHolder == self |
6a32a348aaa4
relaxed setting of menuPerformer to model,
Claus Gittinger <cg@exept.de>
parents:
2166
diff
changeset
|
499 |
and:[model isValueModel not]]) ifTrue:[ |
1149
a3a75ffb29ce
Set meuPerformer also, when model is set.
Stefan Vogel <sv@exept.de>
parents:
1147
diff
changeset
|
500 |
menuPerformer := menuHolder := model |
a3a75ffb29ce
Set meuPerformer also, when model is set.
Stefan Vogel <sv@exept.de>
parents:
1147
diff
changeset
|
501 |
]. |
2524
6a32a348aaa4
relaxed setting of menuPerformer to model,
Claus Gittinger <cg@exept.de>
parents:
2166
diff
changeset
|
502 |
"/ ST80 kludge end. |
6a32a348aaa4
relaxed setting of menuPerformer to model,
Claus Gittinger <cg@exept.de>
parents:
2166
diff
changeset
|
503 |
|
118 | 504 |
model notNil ifTrue:[ |
1149
a3a75ffb29ce
Set meuPerformer also, when model is set.
Stefan Vogel <sv@exept.de>
parents:
1147
diff
changeset
|
505 |
aModel addDependent:self |
118 | 506 |
]. |
507 |
controller notNil ifTrue:[ |
|
1149
a3a75ffb29ce
Set meuPerformer also, when model is set.
Stefan Vogel <sv@exept.de>
parents:
1147
diff
changeset
|
508 |
controller model:aModel |
1395
7218ca27d752
moved class>.model to superClass.
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
509 |
]. |
1149
a3a75ffb29ce
Set meuPerformer also, when model is set.
Stefan Vogel <sv@exept.de>
parents:
1147
diff
changeset
|
510 |
|
1395
7218ca27d752
moved class>.model to superClass.
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
511 |
"Modified: 28.2.1997 / 19:23:06 / cg" |
118 | 512 |
! |
513 |
||
140 | 514 |
modelInterface |
515 |
"this returns a dictionary of messages sent to my model. |
|
516 |
It can be used for builders and wrappers to get information |
|
517 |
about the messages sent to my model. |
|
518 |
The returned dictionary contains one entry for each get-Msg, |
|
519 |
and the recevier will implement corresponding messages (with a colon) |
|
520 |
to set the message symbol." |
|
521 |
||
522 |
|d| |
|
523 |
||
524 |
d := IdentityDictionary new. |
|
525 |
self addModelInterfaceTo:d. |
|
526 |
^ d |
|
527 |
||
528 |
" |
|
529 |
Button new modelInterface |
|
530 |
Label new modelInterface |
|
531 |
" |
|
532 |
||
533 |
" |
|
534 |
does the view support setting the menuMessage ? |
|
535 |
||
536 |
SelectionInListView new modelInterface includesKey:#menuMessage |
|
537 |
" |
|
538 |
||
539 |
" |
|
540 |
turn off all interaction to the model: |
|
541 |
||
542 |
|m v if| |
|
543 |
||
544 |
m := SelectionInList new. |
|
545 |
m list:#('one' 'two' 'tree' 'four') asValue. |
|
546 |
m selection:1 asValue. |
|
547 |
v := SelectionInListView on:m. |
|
548 |
v open. |
|
549 |
v inspect. |
|
550 |
||
551 |
if := v modelInterface. |
|
552 |
if inspect. |
|
553 |
||
554 |
if keysAndValuesDo:[:what :msg | |
|
555 |
v perform:(what , ':') asSymbol with:nil. |
|
556 |
]. |
|
557 |
" |
|
269 | 558 |
! |
559 |
||
560 |
on:aModel aspect:aspectSymbol |
|
561 |
"ST-80 compatibility: set model and aspect |
|
562 |
messages - needs a view which uses these" |
|
563 |
||
564 |
aspectMsg := aspectSymbol. |
|
565 |
self model:aModel. |
|
566 |
! |
|
567 |
||
568 |
on:aModel aspect:aspectSymbol change:changeSymbol |
|
569 |
"ST-80 compatibility: set model, aspect and change |
|
570 |
messages - needs a view which uses these" |
|
571 |
||
572 |
aspectMsg := aspectSymbol. |
|
573 |
changeMsg := changeSymbol. |
|
574 |
self model:aModel. |
|
575 |
! |
|
576 |
||
577 |
on:aModel aspect:aspectSymbol change:changeSymbol menu:menuSymbol |
|
578 |
"ST-80 compatibility: set model, aspect, change and menu |
|
579 |
messages - needs a view which uses these" |
|
580 |
||
581 |
aspectMsg := aspectSymbol. |
|
582 |
changeMsg := changeSymbol. |
|
583 |
menuMsg := menuSymbol. |
|
584 |
self model:aModel. |
|
585 |
! |
|
586 |
||
587 |
on:aModel aspect:aspectSymbol menu:menuSymbol |
|
588 |
"ST-80 compatibility: set model, aspect and menu |
|
589 |
messages - needs a view which uses these" |
|
590 |
||
591 |
aspectMsg := aspectSymbol. |
|
592 |
menuMsg := menuSymbol. |
|
593 |
self model:aModel. |
|
594 |
! |
|
595 |
||
596 |
sendChangeMessage:aSelector with:arg |
|
597 |
"tell the model about a change" |
|
598 |
||
599 |
|n selector| |
|
600 |
||
601 |
"/ |
|
602 |
"/ MVC way of doing it: |
|
603 |
"/ if the model is a block, evaluate it, optionally |
|
604 |
"/ passing the arg and the receiver as arguments. |
|
605 |
"/ |
|
606 |
"/ otherwise (the common case) send it a changeMsg message |
|
607 |
"/ also with arg and the receiver (depending on the number of arguments |
|
608 |
"/ as defined by the selector). |
|
609 |
"/ |
|
610 |
(model notNil and:[aSelector notNil]) ifTrue:[ |
|
3170 | 611 |
n := aSelector numArgs. |
612 |
model isBlock ifTrue:[ |
|
613 |
n := model numArgs. |
|
614 |
n == 0 ifTrue:[ |
|
615 |
selector := #value |
|
616 |
] ifFalse:[ |
|
617 |
n == 1 ifTrue:[ |
|
618 |
selector := #value: |
|
619 |
] ifFalse:[ |
|
620 |
selector := #value:value: |
|
621 |
] |
|
622 |
] |
|
623 |
] ifFalse:[ |
|
624 |
selector := aSelector |
|
625 |
]. |
|
626 |
n == 0 ifTrue:[ |
|
627 |
model perform:selector |
|
628 |
] ifFalse:[ |
|
629 |
selector == #value: ifTrue:[ |
|
630 |
"/ must take care, if model is == to the selection-collection |
|
631 |
"/ in this case, we must force a change on the model |
|
632 |
"/ (valueHolder would not send a change in the == case) |
|
633 |
"/ Q: is this a good idea, or should it be done |
|
634 |
"/ at the invoking side |
|
635 |
"/ model isValueModel ifTrue:[ |
|
636 |
"/ model value == arg ifTrue:[ |
|
637 |
"/ model setValue:nil. |
|
638 |
"/ ] |
|
639 |
"/ ]. |
|
640 |
model value:arg |
|
641 |
] ifFalse:[ |
|
642 |
n == 1 ifTrue:[ |
|
643 |
model perform:selector with:arg |
|
644 |
] ifFalse:[ |
|
645 |
model perform:selector with:arg with:self |
|
646 |
] |
|
647 |
] |
|
648 |
] |
|
269 | 649 |
] |
650 |
! |
|
651 |
||
652 |
sendChangeMessageWith:arg |
|
653 |
"tell the model about a change" |
|
654 |
||
655 |
self sendChangeMessage:changeMsg with:arg |
|
72 | 656 |
! ! |
657 |
||
2548 | 658 |
!View methodsFor:'change & update'! |
659 |
||
660 |
update:something with:aParameter from:changedObject |
|
661 |
||
662 |
changedObject == backgroundChannel ifTrue:[ |
|
663 |
self backgroundColor:(backgroundChannel value). |
|
664 |
^ self |
|
665 |
]. |
|
666 |
changedObject == foregroundChannel ifTrue:[ |
|
667 |
self foregroundColor:(foregroundChannel value). |
|
668 |
^ self |
|
669 |
]. |
|
3731 | 670 |
changedObject == model ifTrue:[ |
671 |
self updateFromModel. |
|
672 |
^ self |
|
673 |
]. |
|
2548 | 674 |
super update:something with:aParameter from:changedObject |
675 |
||
676 |
"Created: / 14.1.1998 / 17:10:11 / stefan" |
|
677 |
"Modified: / 30.3.1999 / 13:52:31 / stefan" |
|
3731 | 678 |
! |
679 |
||
680 |
updateFromModel |
|
681 |
"to be redefined in subclasses" |
|
2548 | 682 |
! ! |
683 |
||
269 | 684 |
!View methodsFor:'drawing'! |
118 | 685 |
|
269 | 686 |
redraw |
687 |
"redraw myself |
|
688 |
if there is a model, this one shall redraw itself, |
|
689 |
otherwise we cannot do much here - has to be redefined in subclasses" |
|
118 | 690 |
|
269 | 691 |
model notNil ifTrue:[ |
692 |
model update:self |
|
693 |
] |
|
118 | 694 |
! ! |
695 |
||
2548 | 696 |
!View methodsFor:'event handling'! |
697 |
||
4926 | 698 |
backgroundColorChanged |
699 |
"called to update the background color" |
|
700 |
||
701 |
|color| |
|
702 |
||
703 |
color := backgroundChannel value. |
|
704 |
self backgroundColor:color. |
|
705 |
! |
|
706 |
||
2556
27e9e1cc8cb3
renambe #enableStateChange and #visibilityStateChange
Claus Gittinger <cg@exept.de>
parents:
2548
diff
changeset
|
707 |
enableStateChanged |
2548 | 708 |
"called to update enable/disable state" |
709 |
||
710 |
self enabled:(enableChannel value) |
|
711 |
||
712 |
"Modified: / 30.3.1999 / 16:07:08 / stefan" |
|
4926 | 713 |
! |
714 |
||
715 |
foregroundColorChanged |
|
4977 | 716 |
"called to update the foreground color" |
4926 | 717 |
|
4977 | 718 |
self foregroundColor:(foregroundChannel value) |
2548 | 719 |
! ! |
720 |
||
3095 | 721 |
!View methodsFor:'focus handling'! |
722 |
||
723 |
wantsFocusWithButtonPress |
|
724 |
"views which do not like to take the keyboard focus |
|
725 |
with buttonPress can do so by redefining this |
|
726 |
to return false" |
|
727 |
||
728 |
(self class == View) ifTrue:[ |
|
729 |
"/ a pure filler/geometric layout view |
|
730 |
^ false |
|
731 |
]. |
|
732 |
^ super wantsFocusWithButtonPress |
|
733 |
||
734 |
||
735 |
! ! |
|
736 |
||
3170 | 737 |
!View methodsFor:'initialization & release'! |
2573 | 738 |
|
6034
a4e78ef00042
moved assignKeyboardFocus stuff from topView
Claus Gittinger <cg@exept.de>
parents:
4985
diff
changeset
|
739 |
assignKeyboardFocusToFirstInputField |
a4e78ef00042
moved assignKeyboardFocus stuff from topView
Claus Gittinger <cg@exept.de>
parents:
4985
diff
changeset
|
740 |
"assign the keyboard focus to the first first keyboardConsumer. |
a4e78ef00042
moved assignKeyboardFocus stuff from topView
Claus Gittinger <cg@exept.de>
parents:
4985
diff
changeset
|
741 |
(in older versions, this used to favour inputfields over editFields; |
a4e78ef00042
moved assignKeyboardFocus stuff from topView
Claus Gittinger <cg@exept.de>
parents:
4985
diff
changeset
|
742 |
see (or redefine) preferFirstInputFieldWhenAssigningInitialFocus)" |
a4e78ef00042
moved assignKeyboardFocus stuff from topView
Claus Gittinger <cg@exept.de>
parents:
4985
diff
changeset
|
743 |
|
a4e78ef00042
moved assignKeyboardFocus stuff from topView
Claus Gittinger <cg@exept.de>
parents:
4985
diff
changeset
|
744 |
|firstInputField firstConsumer firstCursorConsumer consumer| |
a4e78ef00042
moved assignKeyboardFocus stuff from topView
Claus Gittinger <cg@exept.de>
parents:
4985
diff
changeset
|
745 |
|
a4e78ef00042
moved assignKeyboardFocus stuff from topView
Claus Gittinger <cg@exept.de>
parents:
4985
diff
changeset
|
746 |
self allSubViewsDo:[:v | |
a4e78ef00042
moved assignKeyboardFocus stuff from topView
Claus Gittinger <cg@exept.de>
parents:
4985
diff
changeset
|
747 |
(firstInputField isNil and:[v isInputField]) ifTrue:[ |
a4e78ef00042
moved assignKeyboardFocus stuff from topView
Claus Gittinger <cg@exept.de>
parents:
4985
diff
changeset
|
748 |
firstInputField := v |
a4e78ef00042
moved assignKeyboardFocus stuff from topView
Claus Gittinger <cg@exept.de>
parents:
4985
diff
changeset
|
749 |
]. |
a4e78ef00042
moved assignKeyboardFocus stuff from topView
Claus Gittinger <cg@exept.de>
parents:
4985
diff
changeset
|
750 |
(firstConsumer isNil and:[v isKeyboardConsumer]) ifTrue:[ |
a4e78ef00042
moved assignKeyboardFocus stuff from topView
Claus Gittinger <cg@exept.de>
parents:
4985
diff
changeset
|
751 |
firstConsumer := v |
a4e78ef00042
moved assignKeyboardFocus stuff from topView
Claus Gittinger <cg@exept.de>
parents:
4985
diff
changeset
|
752 |
]. |
a4e78ef00042
moved assignKeyboardFocus stuff from topView
Claus Gittinger <cg@exept.de>
parents:
4985
diff
changeset
|
753 |
(firstCursorConsumer isNil and:[v isCursorKeyConsumer]) ifTrue:[ |
a4e78ef00042
moved assignKeyboardFocus stuff from topView
Claus Gittinger <cg@exept.de>
parents:
4985
diff
changeset
|
754 |
firstCursorConsumer := v |
a4e78ef00042
moved assignKeyboardFocus stuff from topView
Claus Gittinger <cg@exept.de>
parents:
4985
diff
changeset
|
755 |
]. |
a4e78ef00042
moved assignKeyboardFocus stuff from topView
Claus Gittinger <cg@exept.de>
parents:
4985
diff
changeset
|
756 |
]. |
a4e78ef00042
moved assignKeyboardFocus stuff from topView
Claus Gittinger <cg@exept.de>
parents:
4985
diff
changeset
|
757 |
self preferFirstInputFieldWhenAssigningInitialFocus ifTrue:[ |
a4e78ef00042
moved assignKeyboardFocus stuff from topView
Claus Gittinger <cg@exept.de>
parents:
4985
diff
changeset
|
758 |
consumer := firstInputField. |
a4e78ef00042
moved assignKeyboardFocus stuff from topView
Claus Gittinger <cg@exept.de>
parents:
4985
diff
changeset
|
759 |
]. |
a4e78ef00042
moved assignKeyboardFocus stuff from topView
Claus Gittinger <cg@exept.de>
parents:
4985
diff
changeset
|
760 |
consumer := (consumer ? firstConsumer ? firstCursorConsumer). |
a4e78ef00042
moved assignKeyboardFocus stuff from topView
Claus Gittinger <cg@exept.de>
parents:
4985
diff
changeset
|
761 |
consumer notNil ifTrue:[ |
a4e78ef00042
moved assignKeyboardFocus stuff from topView
Claus Gittinger <cg@exept.de>
parents:
4985
diff
changeset
|
762 |
device platformName = 'WIN32' ifTrue:[ |
a4e78ef00042
moved assignKeyboardFocus stuff from topView
Claus Gittinger <cg@exept.de>
parents:
4985
diff
changeset
|
763 |
self windowGroup focusView:consumer byTab:true. |
a4e78ef00042
moved assignKeyboardFocus stuff from topView
Claus Gittinger <cg@exept.de>
parents:
4985
diff
changeset
|
764 |
] ifFalse:[ |
a4e78ef00042
moved assignKeyboardFocus stuff from topView
Claus Gittinger <cg@exept.de>
parents:
4985
diff
changeset
|
765 |
consumer requestFocus. |
a4e78ef00042
moved assignKeyboardFocus stuff from topView
Claus Gittinger <cg@exept.de>
parents:
4985
diff
changeset
|
766 |
"/ consumer requestFocus. - could be denied; but we force it here |
a4e78ef00042
moved assignKeyboardFocus stuff from topView
Claus Gittinger <cg@exept.de>
parents:
4985
diff
changeset
|
767 |
windowGroup focusView:consumer byTab:false. |
a4e78ef00042
moved assignKeyboardFocus stuff from topView
Claus Gittinger <cg@exept.de>
parents:
4985
diff
changeset
|
768 |
]. |
a4e78ef00042
moved assignKeyboardFocus stuff from topView
Claus Gittinger <cg@exept.de>
parents:
4985
diff
changeset
|
769 |
]. |
a4e78ef00042
moved assignKeyboardFocus stuff from topView
Claus Gittinger <cg@exept.de>
parents:
4985
diff
changeset
|
770 |
|
a4e78ef00042
moved assignKeyboardFocus stuff from topView
Claus Gittinger <cg@exept.de>
parents:
4985
diff
changeset
|
771 |
"Modified: / 29-08-2006 / 14:32:30 / cg" |
a4e78ef00042
moved assignKeyboardFocus stuff from topView
Claus Gittinger <cg@exept.de>
parents:
4985
diff
changeset
|
772 |
! |
a4e78ef00042
moved assignKeyboardFocus stuff from topView
Claus Gittinger <cg@exept.de>
parents:
4985
diff
changeset
|
773 |
|
118 | 774 |
initialize |
775 |
super initialize. |
|
140 | 776 |
|
777 |
aspectMsg := self class defaultAspectMessage. |
|
778 |
changeMsg := self class defaultChangeMessage. |
|
1151
1a3682212ea9
Move rest of menuHolder/menuPerformer stuff to view.
Stefan Vogel <sv@exept.de>
parents:
1149
diff
changeset
|
779 |
menuMsg := self class defaultMenuMessage. |
1a3682212ea9
Move rest of menuHolder/menuPerformer stuff to view.
Stefan Vogel <sv@exept.de>
parents:
1149
diff
changeset
|
780 |
|
135 | 781 |
model notNil ifTrue:[ |
1151
1a3682212ea9
Move rest of menuHolder/menuPerformer stuff to view.
Stefan Vogel <sv@exept.de>
parents:
1149
diff
changeset
|
782 |
controller notNil ifTrue:[ |
1a3682212ea9
Move rest of menuHolder/menuPerformer stuff to view.
Stefan Vogel <sv@exept.de>
parents:
1149
diff
changeset
|
783 |
controller model:model |
1a3682212ea9
Move rest of menuHolder/menuPerformer stuff to view.
Stefan Vogel <sv@exept.de>
parents:
1149
diff
changeset
|
784 |
] |
81 | 785 |
]. |
1151
1a3682212ea9
Move rest of menuHolder/menuPerformer stuff to view.
Stefan Vogel <sv@exept.de>
parents:
1149
diff
changeset
|
786 |
|
1152
21c666e130dd
menuHolder/menuPerformer stuff.
Stefan Vogel <sv@exept.de>
parents:
1151
diff
changeset
|
787 |
"Modified: 3.1.1997 / 02:11:15 / stefan" |
3707 | 788 |
! |
789 |
||
790 |
release |
|
791 |
model notNil ifTrue:[ |
|
792 |
model removeDependent:self. |
|
793 |
model := nil. |
|
794 |
]. |
|
4979
649eaf7aecd3
must retract interests - not remove dependent
Claus Gittinger <cg@exept.de>
parents:
4977
diff
changeset
|
795 |
visibilityChannel notNil ifTrue:[ |
649eaf7aecd3
must retract interests - not remove dependent
Claus Gittinger <cg@exept.de>
parents:
4977
diff
changeset
|
796 |
visibilityChannel retractInterestsFor:self. |
649eaf7aecd3
must retract interests - not remove dependent
Claus Gittinger <cg@exept.de>
parents:
4977
diff
changeset
|
797 |
visibilityChannel removeDependent:self. visibilityChannel := nil |
649eaf7aecd3
must retract interests - not remove dependent
Claus Gittinger <cg@exept.de>
parents:
4977
diff
changeset
|
798 |
]. |
649eaf7aecd3
must retract interests - not remove dependent
Claus Gittinger <cg@exept.de>
parents:
4977
diff
changeset
|
799 |
enableChannel notNil ifTrue:[ |
649eaf7aecd3
must retract interests - not remove dependent
Claus Gittinger <cg@exept.de>
parents:
4977
diff
changeset
|
800 |
enableChannel retractInterestsFor:self. |
649eaf7aecd3
must retract interests - not remove dependent
Claus Gittinger <cg@exept.de>
parents:
4977
diff
changeset
|
801 |
enableChannel removeDependent:self. enableChannel := nil |
649eaf7aecd3
must retract interests - not remove dependent
Claus Gittinger <cg@exept.de>
parents:
4977
diff
changeset
|
802 |
]. |
649eaf7aecd3
must retract interests - not remove dependent
Claus Gittinger <cg@exept.de>
parents:
4977
diff
changeset
|
803 |
foregroundChannel notNil ifTrue:[ |
649eaf7aecd3
must retract interests - not remove dependent
Claus Gittinger <cg@exept.de>
parents:
4977
diff
changeset
|
804 |
foregroundChannel retractInterestsFor:self. |
649eaf7aecd3
must retract interests - not remove dependent
Claus Gittinger <cg@exept.de>
parents:
4977
diff
changeset
|
805 |
foregroundChannel removeDependent:self. foregroundChannel := nil |
649eaf7aecd3
must retract interests - not remove dependent
Claus Gittinger <cg@exept.de>
parents:
4977
diff
changeset
|
806 |
]. |
649eaf7aecd3
must retract interests - not remove dependent
Claus Gittinger <cg@exept.de>
parents:
4977
diff
changeset
|
807 |
backgroundChannel notNil ifTrue:[ |
649eaf7aecd3
must retract interests - not remove dependent
Claus Gittinger <cg@exept.de>
parents:
4977
diff
changeset
|
808 |
backgroundChannel retractInterestsFor:self. |
649eaf7aecd3
must retract interests - not remove dependent
Claus Gittinger <cg@exept.de>
parents:
4977
diff
changeset
|
809 |
backgroundChannel removeDependent:self. backgroundChannel := nil |
649eaf7aecd3
must retract interests - not remove dependent
Claus Gittinger <cg@exept.de>
parents:
4977
diff
changeset
|
810 |
]. |
3707 | 811 |
super release. |
118 | 812 |
! ! |
813 |
||
269 | 814 |
!View class methodsFor:'documentation'! |
815 |
||
816 |
version |
|
6088 | 817 |
^ '$Header: /cvs/stx/stx/libview/View.st,v 1.82 2013-06-25 23:06:26 cg Exp $' |
269 | 818 |
! ! |
6034
a4e78ef00042
moved assignKeyboardFocus stuff from topView
Claus Gittinger <cg@exept.de>
parents:
4985
diff
changeset
|
819 |