author | Claus Gittinger <cg@exept.de> |
Thu, 28 Apr 2016 14:18:50 +0200 | |
changeset 7319 | a7aeb15d709f |
parent 7234 | 335f9a3179bd |
child 7408 | d1cebfa53c19 |
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 |
||
3355
2ec13d9b93ca
in allViewBackground: do not change the bg, if I have a bg-channel
Claus Gittinger <cg@exept.de>
parents:
3204
diff
changeset
|
203 |
!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
|
204 |
|
4957 | 205 |
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
|
206 |
"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
|
207 |
in myself and recursively in all of my subviews. |
6605 | 208 |
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
|
209 |
|
2ec13d9b93ca
in allViewBackground: do not change the bg, if I have a bg-channel
Claus Gittinger <cg@exept.de>
parents:
3204
diff
changeset
|
210 |
backgroundChannel isNil ifTrue:[ |
4957 | 211 |
^ 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
|
212 |
]. |
2ec13d9b93ca
in allViewBackground: do not change the bg, if I have a bg-channel
Claus Gittinger <cg@exept.de>
parents:
3204
diff
changeset
|
213 |
|
4957 | 214 |
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
|
215 |
! ! |
2ec13d9b93ca
in allViewBackground: do not change the bg, if I have a bg-channel
Claus Gittinger <cg@exept.de>
parents:
3204
diff
changeset
|
216 |
|
170 | 217 |
!View methodsFor:'accessing-channels'! |
218 |
||
2548 | 219 |
backgroundChannel |
220 |
"return a valueHolder for background color" |
|
221 |
||
222 |
^ backgroundChannel |
|
223 |
||
224 |
"Modified: / 30.3.1999 / 13:49:28 / stefan" |
|
225 |
"Created: / 30.3.1999 / 13:50:55 / stefan" |
|
226 |
! |
|
227 |
||
228 |
backgroundChannel:aValueHolder |
|
4985 | 229 |
"set the backgroundChannel - a valueHolder holding a color" |
2548 | 230 |
|
231 |
|prev| |
|
232 |
||
233 |
prev := backgroundChannel. |
|
234 |
backgroundChannel := aValueHolder. |
|
4926 | 235 |
self setupChannel:aValueHolder for:#backgroundColorChanged withOld:prev |
2548 | 236 |
|
237 |
"Modified: / 31.10.1997 / 14:38:38 / cg" |
|
238 |
"Created: / 30.3.1999 / 13:48:42 / stefan" |
|
239 |
! |
|
240 |
||
241 |
enableChannel |
|
242 |
"return a valueHolder for enable/disable" |
|
243 |
||
244 |
^ enableChannel |
|
245 |
||
246 |
"Created: / 30.3.1999 / 13:46:43 / stefan" |
|
247 |
! |
|
248 |
||
249 |
enableChannel:aValueHolder |
|
250 |
"set the valueHolder, which holds the enable boolean value" |
|
251 |
||
252 |
|prev| |
|
253 |
||
254 |
prev := enableChannel. |
|
255 |
enableChannel := aValueHolder. |
|
2950
705ddb097eec
Fix visibilityChannel and enableChannel stuff
Claus Gittinger <cg@exept.de>
parents:
2573
diff
changeset
|
256 |
self setupChannel:aValueHolder for:#enableStateChanged withOld:prev |
2548 | 257 |
|
258 |
"Modified: / 14.11.1997 / 13:52:44 / cg" |
|
259 |
"Modified: / 30.3.1999 / 13:50:15 / stefan" |
|
260 |
! |
|
261 |
||
262 |
foregroundChannel |
|
263 |
"return a valueHolder for foreground color" |
|
264 |
||
265 |
^ foregroundChannel |
|
266 |
||
267 |
"Modified: / 30.3.1999 / 13:49:28 / stefan" |
|
268 |
! |
|
269 |
||
270 |
foregroundChannel:aValueHolder |
|
271 |
"set the foregroundChannel - a valueHolder holding a color" |
|
272 |
||
273 |
|prev| |
|
274 |
||
275 |
prev := foregroundChannel. |
|
276 |
foregroundChannel := aValueHolder. |
|
4926 | 277 |
self setupChannel:aValueHolder for:#foregroundColorChanged withOld:prev |
2548 | 278 |
|
279 |
"Modified: / 31.10.1997 / 14:38:38 / cg" |
|
280 |
"Modified: / 30.3.1999 / 13:50:08 / stefan" |
|
170 | 281 |
! ! |
282 |
||
269 | 283 |
!View methodsFor:'accessing-menus'! |
284 |
||
285 |
menuHolder |
|
286 |
"who has the menu ? |
|
1147
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
287 |
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
|
288 |
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
|
289 |
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
|
290 |
menuMessage." |
269 | 291 |
|
1147
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
292 |
menuHolder notNil ifTrue:[^ menuHolder]. |
269 | 293 |
model notNil ifTrue:[^ model]. |
294 |
^ self |
|
1147
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
295 |
|
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
296 |
"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
|
297 |
! |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
298 |
|
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
299 |
menuHolder:anObject |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
300 |
"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
|
301 |
|
2134 | 302 |
menuHolder := anObject. |
303 |
menuMsg isNil ifTrue:[menuMsg := #value]. |
|
1147
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
304 |
|
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
305 |
"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
|
306 |
! |
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 |
menuMessage |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
309 |
"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
|
310 |
|
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
311 |
^ menuMsg |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
312 |
! |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
313 |
|
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
314 |
menuMessage:aSymbol |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
315 |
"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
|
316 |
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
|
317 |
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
|
318 |
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
|
319 |
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
|
320 |
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
|
321 |
|
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
322 |
menuMsg := aSymbol |
269 | 323 |
! |
324 |
||
325 |
menuPerformer |
|
326 |
"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
|
327 |
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
|
328 |
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
|
329 |
The menuPerformer get messages from the menu" |
269 | 330 |
|
1147
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
331 |
menuPerformer notNil ifTrue:[^ menuPerformer]. |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
332 |
|
3405
0c6b6fcd819f
if never set, the default menuPerformer is
Claus Gittinger <cg@exept.de>
parents:
3365
diff
changeset
|
333 |
"/ 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
|
334 |
"/ 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
|
335 |
"/ (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
|
336 |
(model isNil |
0c6b6fcd819f
if never set, the default menuPerformer is
Claus Gittinger <cg@exept.de>
parents:
3365
diff
changeset
|
337 |
or:[model isValueModel |
0c6b6fcd819f
if never set, the default menuPerformer is
Claus Gittinger <cg@exept.de>
parents:
3365
diff
changeset
|
338 |
or:[model isBlock]]) ifTrue:[ |
0c6b6fcd819f
if never set, the default menuPerformer is
Claus Gittinger <cg@exept.de>
parents:
3365
diff
changeset
|
339 |
"/ 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
|
340 |
^ self application ? self |
0c6b6fcd819f
if never set, the default menuPerformer is
Claus Gittinger <cg@exept.de>
parents:
3365
diff
changeset
|
341 |
]. |
0c6b6fcd819f
if never set, the default menuPerformer is
Claus Gittinger <cg@exept.de>
parents:
3365
diff
changeset
|
342 |
^ model |
1147
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
343 |
! |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
344 |
|
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
345 |
menuPerformer:anObject |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
346 |
"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
|
347 |
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
|
348 |
message." |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
349 |
|
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
350 |
menuPerformer := anObject |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
351 |
|
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
352 |
" |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
353 |
|top textV plug| |
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 |
plug := Plug new. |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
356 |
plug respondTo:#textMenu |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
357 |
with:[ |m| |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
358 |
m := PopUpMenu |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
359 |
labels:#('copy' 'foo' '-' 'others') |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
360 |
selectors:#(copySelection foo nil others). |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
361 |
m subMenuAt:#others |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
362 |
put:(PopUpMenu |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
363 |
labels:#('bar' 'goto') |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
364 |
selectors:#(bar gotoLine)) |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
365 |
]. |
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 |
top := StandardSystemView new. |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
368 |
top extent:300@300. |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
369 |
|
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
370 |
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
|
371 |
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
|
372 |
textV contents:'hello world'. |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
373 |
top open. |
83ed804938e7
moved menuHolder/menuPerformer stuff up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
1146
diff
changeset
|
374 |
" |
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 |
"Created: 23.12.1996 / 13:57:28 / cg" |
2166
d6e05def4f83
added #performer: (dummy - ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
2134
diff
changeset
|
377 |
! |
d6e05def4f83
added #performer: (dummy - ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
2134
diff
changeset
|
378 |
|
d6e05def4f83
added #performer: (dummy - ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
2134
diff
changeset
|
379 |
performer:anObject |
d6e05def4f83
added #performer: (dummy - ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
2134
diff
changeset
|
380 |
"same as #menuPerformer - ST80 compatibility" |
d6e05def4f83
added #performer: (dummy - ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
2134
diff
changeset
|
381 |
|
d6e05def4f83
added #performer: (dummy - ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
2134
diff
changeset
|
382 |
self menuPerformer:anObject |
d6e05def4f83
added #performer: (dummy - ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
2134
diff
changeset
|
383 |
|
d6e05def4f83
added #performer: (dummy - ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
2134
diff
changeset
|
384 |
"Created: / 6.7.1998 / 13:38:32 / cg" |
269 | 385 |
! ! |
386 |
||
118 | 387 |
!View methodsFor:'accessing-mvc'! |
388 |
||
269 | 389 |
addModelInterfaceTo:aDictionary |
390 |
"this adds entries for all messages sent to my model |
|
391 |
to aDictionary" |
|
392 |
||
393 |
aDictionary at:#aspectMessage put:aspectMsg. |
|
394 |
aDictionary at:#changeMessage put:changeMsg. |
|
395 |
aDictionary at:#menuMessage put:menuMsg. |
|
396 |
||
397 |
" |
|
398 |
Button new modelInterface |
|
399 |
" |
|
400 |
! |
|
135 | 401 |
|
269 | 402 |
aspect |
403 |
"Return the aspect used with changes from/to the model" |
|
404 |
||
405 |
^ aspectMsg |
|
406 |
! |
|
407 |
||
408 |
aspectMessage |
|
409 |
"Return the aspect used with changes from/to the model" |
|
410 |
||
411 |
^ aspectMsg |
|
412 |
! |
|
413 |
||
414 |
aspectMessage:aspectSymbol |
|
415 |
"ST-80 style updating: If a views aspectSymbol is nonNil, |
|
416 |
it will respond to changes of this aspect from the model." |
|
417 |
||
418 |
aspectMsg := aspectSymbol |
|
135 | 419 |
! |
420 |
||
269 | 421 |
change:changeSymbol |
422 |
"ST-80 style change notification: If a views changeSymbol is nonNil, |
|
423 |
it will send it to its model when something changes. |
|
424 |
Alias for changeMessage: for ST-80 compatibility." |
|
425 |
||
426 |
self changeMessage:changeSymbol |
|
427 |
! |
|
428 |
||
429 |
changeMessage |
|
430 |
"Return the symbol sent to the model if nonNil when something changes." |
|
135 | 431 |
|
269 | 432 |
^ changeMsg |
433 |
! |
|
434 |
||
435 |
changeMessage:aSymbol |
|
436 |
"ST-80 style change notification: If a views changeSymbol is nonNil, |
|
437 |
it will send it to its model when something changes. |
|
438 |
This is the same as change: which was added for ST-80 compatibility." |
|
439 |
||
440 |
changeMsg := aSymbol |
|
441 |
! |
|
442 |
||
443 |
controller:aController |
|
444 |
"set the controller" |
|
118 | 445 |
|
269 | 446 |
super controller:aController. |
447 |
controller notNil ifTrue:[ |
|
448 |
controller model:model |
|
0 | 449 |
] |
450 |
! |
|
451 |
||
269 | 452 |
menu:menuSymbol |
453 |
"ST-80 style menus: If a views menuSymbol is nonNil, it |
|
454 |
will send it to its model when the middleButton is pressed. |
|
455 |
That method should return nil or the menu to be shown. |
|
456 |
This is useful for very dynamic menus, where it does not |
|
457 |
make sense to define an initial menu. |
|
458 |
Alias for #menuMessage:, for ST-80 compatibility." |
|
459 |
||
460 |
menuMsg := menuSymbol |
|
461 |
! |
|
462 |
||
118 | 463 |
model |
464 |
"return the model, for non-MVC views, |
|
465 |
this is nil or the receiver" |
|
466 |
||
467 |
^ model |
|
468 |
! |
|
469 |
||
470 |
model:aModel |
|
1151
1a3682212ea9
Move rest of menuHolder/menuPerformer stuff to view.
Stefan Vogel <sv@exept.de>
parents:
1149
diff
changeset
|
471 |
"Set the model. |
1149
a3a75ffb29ce
Set meuPerformer also, when model is set.
Stefan Vogel <sv@exept.de>
parents:
1147
diff
changeset
|
472 |
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
|
473 |
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
|
474 |
This is a compatibility kludge, |
1149
a3a75ffb29ce
Set meuPerformer also, when model is set.
Stefan Vogel <sv@exept.de>
parents:
1147
diff
changeset
|
475 |
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
|
476 |
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
|
477 |
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
|
478 |
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
|
479 |
this by sending #menuHolder: message (again)" |
118 | 480 |
|
481 |
model notNil ifTrue:[ |
|
1149
a3a75ffb29ce
Set meuPerformer also, when model is set.
Stefan Vogel <sv@exept.de>
parents:
1147
diff
changeset
|
482 |
model removeDependent:self |
89 | 483 |
]. |
118 | 484 |
model := aModel. |
2524
6a32a348aaa4
relaxed setting of menuPerformer to model,
Claus Gittinger <cg@exept.de>
parents:
2166
diff
changeset
|
485 |
|
6a32a348aaa4
relaxed setting of menuPerformer to model,
Claus Gittinger <cg@exept.de>
parents:
2166
diff
changeset
|
486 |
"/ ST80 kludge start |
6a32a348aaa4
relaxed setting of menuPerformer to model,
Claus Gittinger <cg@exept.de>
parents:
2166
diff
changeset
|
487 |
(menuPerformer == self |
6a32a348aaa4
relaxed setting of menuPerformer to model,
Claus Gittinger <cg@exept.de>
parents:
2166
diff
changeset
|
488 |
and:[menuHolder == self |
6a32a348aaa4
relaxed setting of menuPerformer to model,
Claus Gittinger <cg@exept.de>
parents:
2166
diff
changeset
|
489 |
and:[model isValueModel not]]) ifTrue:[ |
1149
a3a75ffb29ce
Set meuPerformer also, when model is set.
Stefan Vogel <sv@exept.de>
parents:
1147
diff
changeset
|
490 |
menuPerformer := menuHolder := model |
a3a75ffb29ce
Set meuPerformer also, when model is set.
Stefan Vogel <sv@exept.de>
parents:
1147
diff
changeset
|
491 |
]. |
2524
6a32a348aaa4
relaxed setting of menuPerformer to model,
Claus Gittinger <cg@exept.de>
parents:
2166
diff
changeset
|
492 |
"/ ST80 kludge end. |
6a32a348aaa4
relaxed setting of menuPerformer to model,
Claus Gittinger <cg@exept.de>
parents:
2166
diff
changeset
|
493 |
|
118 | 494 |
model notNil ifTrue:[ |
1149
a3a75ffb29ce
Set meuPerformer also, when model is set.
Stefan Vogel <sv@exept.de>
parents:
1147
diff
changeset
|
495 |
aModel addDependent:self |
118 | 496 |
]. |
497 |
controller notNil ifTrue:[ |
|
1149
a3a75ffb29ce
Set meuPerformer also, when model is set.
Stefan Vogel <sv@exept.de>
parents:
1147
diff
changeset
|
498 |
controller model:aModel |
1395
7218ca27d752
moved class>.model to superClass.
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
499 |
]. |
1149
a3a75ffb29ce
Set meuPerformer also, when model is set.
Stefan Vogel <sv@exept.de>
parents:
1147
diff
changeset
|
500 |
|
1395
7218ca27d752
moved class>.model to superClass.
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
501 |
"Modified: 28.2.1997 / 19:23:06 / cg" |
118 | 502 |
! |
503 |
||
140 | 504 |
modelInterface |
505 |
"this returns a dictionary of messages sent to my model. |
|
506 |
It can be used for builders and wrappers to get information |
|
507 |
about the messages sent to my model. |
|
508 |
The returned dictionary contains one entry for each get-Msg, |
|
7234 | 509 |
and the receiver will implement corresponding messages (with a colon) |
140 | 510 |
to set the message symbol." |
511 |
||
512 |
|d| |
|
513 |
||
514 |
d := IdentityDictionary new. |
|
515 |
self addModelInterfaceTo:d. |
|
516 |
^ d |
|
517 |
||
518 |
" |
|
519 |
Button new modelInterface |
|
520 |
Label new modelInterface |
|
521 |
" |
|
522 |
||
523 |
" |
|
524 |
does the view support setting the menuMessage ? |
|
525 |
||
526 |
SelectionInListView new modelInterface includesKey:#menuMessage |
|
527 |
" |
|
528 |
||
529 |
" |
|
530 |
turn off all interaction to the model: |
|
531 |
||
532 |
|m v if| |
|
533 |
||
534 |
m := SelectionInList new. |
|
535 |
m list:#('one' 'two' 'tree' 'four') asValue. |
|
536 |
m selection:1 asValue. |
|
537 |
v := SelectionInListView on:m. |
|
538 |
v open. |
|
539 |
v inspect. |
|
540 |
||
541 |
if := v modelInterface. |
|
542 |
if inspect. |
|
543 |
||
544 |
if keysAndValuesDo:[:what :msg | |
|
7234 | 545 |
v perform:(what , ':') asSymbol with:nil. |
140 | 546 |
]. |
547 |
" |
|
269 | 548 |
! |
549 |
||
550 |
on:aModel aspect:aspectSymbol |
|
551 |
"ST-80 compatibility: set model and aspect |
|
552 |
messages - needs a view which uses these" |
|
553 |
||
554 |
aspectMsg := aspectSymbol. |
|
555 |
self model:aModel. |
|
556 |
! |
|
557 |
||
558 |
on:aModel aspect:aspectSymbol change:changeSymbol |
|
559 |
"ST-80 compatibility: set model, aspect and change |
|
560 |
messages - needs a view which uses these" |
|
561 |
||
562 |
aspectMsg := aspectSymbol. |
|
563 |
changeMsg := changeSymbol. |
|
564 |
self model:aModel. |
|
565 |
! |
|
566 |
||
567 |
on:aModel aspect:aspectSymbol change:changeSymbol menu:menuSymbol |
|
568 |
"ST-80 compatibility: set model, aspect, change and menu |
|
569 |
messages - needs a view which uses these" |
|
570 |
||
571 |
aspectMsg := aspectSymbol. |
|
572 |
changeMsg := changeSymbol. |
|
573 |
menuMsg := menuSymbol. |
|
574 |
self model:aModel. |
|
575 |
! |
|
576 |
||
577 |
on:aModel aspect:aspectSymbol menu:menuSymbol |
|
578 |
"ST-80 compatibility: set model, aspect and menu |
|
579 |
messages - needs a view which uses these" |
|
580 |
||
581 |
aspectMsg := aspectSymbol. |
|
582 |
menuMsg := menuSymbol. |
|
583 |
self model:aModel. |
|
584 |
! |
|
585 |
||
586 |
sendChangeMessage:aSelector with:arg |
|
587 |
"tell the model about a change" |
|
588 |
||
589 |
|n selector| |
|
590 |
||
591 |
"/ |
|
592 |
"/ MVC way of doing it: |
|
593 |
"/ if the model is a block, evaluate it, optionally |
|
594 |
"/ passing the arg and the receiver as arguments. |
|
595 |
"/ |
|
596 |
"/ otherwise (the common case) send it a changeMsg message |
|
597 |
"/ also with arg and the receiver (depending on the number of arguments |
|
598 |
"/ as defined by the selector). |
|
599 |
"/ |
|
600 |
(model notNil and:[aSelector notNil]) ifTrue:[ |
|
3170 | 601 |
n := aSelector numArgs. |
602 |
model isBlock ifTrue:[ |
|
603 |
n := model numArgs. |
|
604 |
n == 0 ifTrue:[ |
|
605 |
selector := #value |
|
606 |
] ifFalse:[ |
|
607 |
n == 1 ifTrue:[ |
|
608 |
selector := #value: |
|
609 |
] ifFalse:[ |
|
610 |
selector := #value:value: |
|
611 |
] |
|
612 |
] |
|
613 |
] ifFalse:[ |
|
614 |
selector := aSelector |
|
615 |
]. |
|
616 |
n == 0 ifTrue:[ |
|
617 |
model perform:selector |
|
618 |
] ifFalse:[ |
|
619 |
selector == #value: ifTrue:[ |
|
620 |
"/ must take care, if model is == to the selection-collection |
|
621 |
"/ in this case, we must force a change on the model |
|
622 |
"/ (valueHolder would not send a change in the == case) |
|
623 |
"/ Q: is this a good idea, or should it be done |
|
624 |
"/ at the invoking side |
|
625 |
"/ model isValueModel ifTrue:[ |
|
626 |
"/ model value == arg ifTrue:[ |
|
627 |
"/ model setValue:nil. |
|
628 |
"/ ] |
|
629 |
"/ ]. |
|
630 |
model value:arg |
|
631 |
] ifFalse:[ |
|
632 |
n == 1 ifTrue:[ |
|
633 |
model perform:selector with:arg |
|
634 |
] ifFalse:[ |
|
635 |
model perform:selector with:arg with:self |
|
636 |
] |
|
637 |
] |
|
638 |
] |
|
269 | 639 |
] |
640 |
! |
|
641 |
||
642 |
sendChangeMessageWith:arg |
|
643 |
"tell the model about a change" |
|
644 |
||
645 |
self sendChangeMessage:changeMsg with:arg |
|
72 | 646 |
! ! |
647 |
||
2548 | 648 |
!View methodsFor:'change & update'! |
649 |
||
650 |
update:something with:aParameter from:changedObject |
|
651 |
||
652 |
changedObject == backgroundChannel ifTrue:[ |
|
653 |
self backgroundColor:(backgroundChannel value). |
|
654 |
^ self |
|
655 |
]. |
|
656 |
changedObject == foregroundChannel ifTrue:[ |
|
657 |
self foregroundColor:(foregroundChannel value). |
|
658 |
^ self |
|
659 |
]. |
|
3731 | 660 |
changedObject == model ifTrue:[ |
661 |
self updateFromModel. |
|
662 |
^ self |
|
663 |
]. |
|
2548 | 664 |
super update:something with:aParameter from:changedObject |
665 |
||
666 |
"Created: / 14.1.1998 / 17:10:11 / stefan" |
|
667 |
"Modified: / 30.3.1999 / 13:52:31 / stefan" |
|
3731 | 668 |
! |
669 |
||
670 |
updateFromModel |
|
671 |
"to be redefined in subclasses" |
|
2548 | 672 |
! ! |
673 |
||
269 | 674 |
!View methodsFor:'drawing'! |
118 | 675 |
|
269 | 676 |
redraw |
677 |
"redraw myself |
|
678 |
if there is a model, this one shall redraw itself, |
|
679 |
otherwise we cannot do much here - has to be redefined in subclasses" |
|
118 | 680 |
|
269 | 681 |
model notNil ifTrue:[ |
682 |
model update:self |
|
683 |
] |
|
118 | 684 |
! ! |
685 |
||
2548 | 686 |
!View methodsFor:'event handling'! |
687 |
||
4926 | 688 |
backgroundColorChanged |
689 |
"called to update the background color" |
|
690 |
||
691 |
|color| |
|
692 |
||
693 |
color := backgroundChannel value. |
|
694 |
self backgroundColor:color. |
|
695 |
! |
|
696 |
||
2556
27e9e1cc8cb3
renambe #enableStateChange and #visibilityStateChange
Claus Gittinger <cg@exept.de>
parents:
2548
diff
changeset
|
697 |
enableStateChanged |
2548 | 698 |
"called to update enable/disable state" |
699 |
||
700 |
self enabled:(enableChannel value) |
|
701 |
||
702 |
"Modified: / 30.3.1999 / 16:07:08 / stefan" |
|
4926 | 703 |
! |
704 |
||
705 |
foregroundColorChanged |
|
4977 | 706 |
"called to update the foreground color" |
4926 | 707 |
|
4977 | 708 |
self foregroundColor:(foregroundChannel value) |
2548 | 709 |
! ! |
710 |
||
3095 | 711 |
!View methodsFor:'focus handling'! |
712 |
||
713 |
wantsFocusWithButtonPress |
|
714 |
"views which do not like to take the keyboard focus |
|
715 |
with buttonPress can do so by redefining this |
|
716 |
to return false" |
|
717 |
||
718 |
(self class == View) ifTrue:[ |
|
719 |
"/ a pure filler/geometric layout view |
|
720 |
^ false |
|
721 |
]. |
|
722 |
^ super wantsFocusWithButtonPress |
|
723 |
||
724 |
||
725 |
! ! |
|
726 |
||
3170 | 727 |
!View methodsFor:'initialization & release'! |
2573 | 728 |
|
118 | 729 |
initialize |
730 |
super initialize. |
|
140 | 731 |
|
732 |
aspectMsg := self class defaultAspectMessage. |
|
733 |
changeMsg := self class defaultChangeMessage. |
|
1151
1a3682212ea9
Move rest of menuHolder/menuPerformer stuff to view.
Stefan Vogel <sv@exept.de>
parents:
1149
diff
changeset
|
734 |
menuMsg := self class defaultMenuMessage. |
1a3682212ea9
Move rest of menuHolder/menuPerformer stuff to view.
Stefan Vogel <sv@exept.de>
parents:
1149
diff
changeset
|
735 |
|
135 | 736 |
model notNil ifTrue:[ |
1151
1a3682212ea9
Move rest of menuHolder/menuPerformer stuff to view.
Stefan Vogel <sv@exept.de>
parents:
1149
diff
changeset
|
737 |
controller notNil ifTrue:[ |
1a3682212ea9
Move rest of menuHolder/menuPerformer stuff to view.
Stefan Vogel <sv@exept.de>
parents:
1149
diff
changeset
|
738 |
controller model:model |
1a3682212ea9
Move rest of menuHolder/menuPerformer stuff to view.
Stefan Vogel <sv@exept.de>
parents:
1149
diff
changeset
|
739 |
] |
81 | 740 |
]. |
1151
1a3682212ea9
Move rest of menuHolder/menuPerformer stuff to view.
Stefan Vogel <sv@exept.de>
parents:
1149
diff
changeset
|
741 |
|
1152
21c666e130dd
menuHolder/menuPerformer stuff.
Stefan Vogel <sv@exept.de>
parents:
1151
diff
changeset
|
742 |
"Modified: 3.1.1997 / 02:11:15 / stefan" |
3707 | 743 |
! |
744 |
||
745 |
release |
|
746 |
model notNil ifTrue:[ |
|
747 |
model removeDependent:self. |
|
748 |
model := nil. |
|
749 |
]. |
|
4979
649eaf7aecd3
must retract interests - not remove dependent
Claus Gittinger <cg@exept.de>
parents:
4977
diff
changeset
|
750 |
visibilityChannel notNil ifTrue:[ |
649eaf7aecd3
must retract interests - not remove dependent
Claus Gittinger <cg@exept.de>
parents:
4977
diff
changeset
|
751 |
visibilityChannel retractInterestsFor:self. |
649eaf7aecd3
must retract interests - not remove dependent
Claus Gittinger <cg@exept.de>
parents:
4977
diff
changeset
|
752 |
visibilityChannel removeDependent:self. visibilityChannel := nil |
649eaf7aecd3
must retract interests - not remove dependent
Claus Gittinger <cg@exept.de>
parents:
4977
diff
changeset
|
753 |
]. |
649eaf7aecd3
must retract interests - not remove dependent
Claus Gittinger <cg@exept.de>
parents:
4977
diff
changeset
|
754 |
enableChannel notNil ifTrue:[ |
649eaf7aecd3
must retract interests - not remove dependent
Claus Gittinger <cg@exept.de>
parents:
4977
diff
changeset
|
755 |
enableChannel retractInterestsFor:self. |
649eaf7aecd3
must retract interests - not remove dependent
Claus Gittinger <cg@exept.de>
parents:
4977
diff
changeset
|
756 |
enableChannel removeDependent:self. enableChannel := nil |
649eaf7aecd3
must retract interests - not remove dependent
Claus Gittinger <cg@exept.de>
parents:
4977
diff
changeset
|
757 |
]. |
649eaf7aecd3
must retract interests - not remove dependent
Claus Gittinger <cg@exept.de>
parents:
4977
diff
changeset
|
758 |
foregroundChannel notNil ifTrue:[ |
649eaf7aecd3
must retract interests - not remove dependent
Claus Gittinger <cg@exept.de>
parents:
4977
diff
changeset
|
759 |
foregroundChannel retractInterestsFor:self. |
649eaf7aecd3
must retract interests - not remove dependent
Claus Gittinger <cg@exept.de>
parents:
4977
diff
changeset
|
760 |
foregroundChannel removeDependent:self. foregroundChannel := nil |
649eaf7aecd3
must retract interests - not remove dependent
Claus Gittinger <cg@exept.de>
parents:
4977
diff
changeset
|
761 |
]. |
649eaf7aecd3
must retract interests - not remove dependent
Claus Gittinger <cg@exept.de>
parents:
4977
diff
changeset
|
762 |
backgroundChannel notNil ifTrue:[ |
649eaf7aecd3
must retract interests - not remove dependent
Claus Gittinger <cg@exept.de>
parents:
4977
diff
changeset
|
763 |
backgroundChannel retractInterestsFor:self. |
649eaf7aecd3
must retract interests - not remove dependent
Claus Gittinger <cg@exept.de>
parents:
4977
diff
changeset
|
764 |
backgroundChannel removeDependent:self. backgroundChannel := nil |
649eaf7aecd3
must retract interests - not remove dependent
Claus Gittinger <cg@exept.de>
parents:
4977
diff
changeset
|
765 |
]. |
3707 | 766 |
super release. |
118 | 767 |
! ! |
768 |
||
269 | 769 |
!View class methodsFor:'documentation'! |
770 |
||
771 |
version |
|
7234 | 772 |
^ '$Header$' |
6743 | 773 |
! |
774 |
||
775 |
version_CVS |
|
7234 | 776 |
^ '$Header$' |
269 | 777 |
! ! |
6034
a4e78ef00042
moved assignKeyboardFocus stuff from topView
Claus Gittinger <cg@exept.de>
parents:
4985
diff
changeset
|
778 |