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