author | Claus Gittinger <cg@exept.de> |
Sat, 08 Dec 2001 14:29:15 +0100 | |
changeset 2497 | e3e1a719e31d |
parent 2495 | 2a9d8cd995f4 |
child 2578 | d5cdeaff2431 |
permissions | -rw-r--r-- |
20 | 1 |
" |
2 |
COPYRIGHT (c) 1994 by Claus Gittinger |
|
59 | 3 |
All Rights Reserved |
20 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
2172
411ac4dcf8b4
action invocation for VW compatibility.
Claus Gittinger <cg@exept.de>
parents:
1988
diff
changeset
|
13 |
"{ Package: 'stx:libwidg' }" |
411ac4dcf8b4
action invocation for VW compatibility.
Claus Gittinger <cg@exept.de>
parents:
1988
diff
changeset
|
14 |
|
20 | 15 |
Button subclass:#PopUpList |
1758 | 16 |
instanceVariableNames:'menu menuAction values useIndex listMsg defaultLabel listHolder |
17 |
showHandle' |
|
327
5cd2a6f4f28e
fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
18 |
classVariableNames:'' |
5cd2a6f4f28e
fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
19 |
poolDictionaries:'' |
5cd2a6f4f28e
fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
20 |
category:'Views-Interactors' |
20 | 21 |
! |
22 |
||
998 | 23 |
!PopUpList class methodsFor:'documentation'! |
38 | 24 |
|
25 |
copyright |
|
26 |
" |
|
27 |
COPYRIGHT (c) 1994 by Claus Gittinger |
|
59 | 28 |
All Rights Reserved |
38 | 29 |
|
30 |
This software is furnished under a license and may be used |
|
31 |
only in accordance with the terms of that license and with the |
|
32 |
inclusion of the above copyright notice. This software may not |
|
33 |
be provided or otherwise made available to, or used by, any |
|
34 |
other person. No title to or ownership of the software is |
|
35 |
hereby transferred. |
|
36 |
" |
|
37 |
! |
|
38 |
||
39 |
documentation |
|
40 |
" |
|
41 |
a PopUpList is basically a button with a popup menu. |
|
42 |
The PopUpLists label is showing the current selection from the |
|
43 |
list. |
|
121 | 44 |
When an entry is selected, an actionBlock (if nonNil) is evaluated |
45 |
and (if nonNil), the model is notified via the changeMessage. |
|
125 | 46 |
|
1052
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
47 |
If no model is set, the list is assumed to be a static list, which |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
48 |
is defined via #list:, and the popUpList evaluates the action block, |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
49 |
as defined via #action:. |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
50 |
|
1065 | 51 |
If a model is provided, it should return the current selected items index via the |
52 |
aspectMessage (default is #selection or: #selectionIndex, depending on the setting |
|
53 |
of useIndex) and the list via the listMessage (default is #list). |
|
54 |
If the listMessage was set to nil, the list is not aquired from the model |
|
55 |
and can be set explicitely via #list:. |
|
1052
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
56 |
|
1065 | 57 |
The defaults are set to allow a PopUpList to be used with a SelectionInList |
1063 | 58 |
as model without further setup. |
1077 | 59 |
A simple valueHolder may also be used without further setup. |
121 | 60 |
(if used with some other model, either use an adaptor, or set the |
1063 | 61 |
change/aspect and/or listMessage to something else ..) |
125 | 62 |
|
1065 | 63 |
If a listHolder is set, this one is always asked for the list instead of the |
64 |
model, via the #value message. |
|
65 |
This allows the popUpListView to aquire the list and value from different places. |
|
66 |
||
67 |
||
1070 | 68 |
Notice: PopUpList and ComboListView provide a similar protocol and functionality. |
69 |
||
1065 | 70 |
|
585 | 71 |
[Instance variables:] |
125 | 72 |
|
1063 | 73 |
menu helpers for the popup menu |
74 |
menuAction |
|
75 |
values |
|
1052
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
76 |
|
1063 | 77 |
useIndex <Boolean> if true, the index of the selected entry |
78 |
is passed to the action block and the |
|
79 |
model in a change-message. |
|
80 |
If false (the default), the value is passed. |
|
81 |
Notice that the default changeMessage is |
|
82 |
#selection:, which is not ok to be used |
|
83 |
with useIndex:true and a selectionInList model. |
|
84 |
(set the changeMessage to #selectionIndex: then) |
|
125 | 85 |
|
1063 | 86 |
listMsg <Symbol> message to aquire a new list from the |
87 |
model. Default is #list. |
|
1052
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
88 |
|
125 | 89 |
|
1063 | 90 |
listHolder <Object> if non-nil, this object is assumed to return the |
91 |
list via the listMsg (instead of the model). |
|
92 |
Default is nil. |
|
585 | 93 |
|
94 |
[see also:] |
|
1070 | 95 |
SelectionInList ValueHolder |
1063 | 96 |
SelectionInListView |
1070 | 97 |
ComboListView |
585 | 98 |
|
99 |
[author:] |
|
1063 | 100 |
Claus Gittinger |
63 | 101 |
" |
102 |
! |
|
38 | 103 |
|
63 | 104 |
examples |
105 |
" |
|
1063 | 106 |
non-MVC use: |
107 |
[exBegin] |
|
38 | 108 |
|p| |
109 |
p := PopUpList label:'healthy fruit'. |
|
119 | 110 |
p list:#('apples' 'bananas' 'grape' 'lemon' 'margaritas'). |
38 | 111 |
p open |
1063 | 112 |
[exEnd] |
38 | 113 |
|
114 |
||
115 |
with an initial selection: |
|
1063 | 116 |
[exBegin] |
38 | 117 |
|p| |
118 |
p := PopUpList label:'dummy'. |
|
119 | 119 |
p list:#('apples' 'bananas' 'grape' 'lemon' 'margaritas'). |
38 | 120 |
p selection:'apples'. |
121 |
p open |
|
1063 | 122 |
[exEnd] |
38 | 123 |
|
124 |
||
125 |
with separating lines: |
|
1063 | 126 |
[exBegin] |
38 | 127 |
|p| |
119 | 128 |
p := PopUpList label:'fruit'. |
129 |
p list:#('apples' 'bananas' 'grape' 'lemon' '-' 'margaritas'). |
|
38 | 130 |
p selection:'apples'. |
131 |
p open |
|
1063 | 132 |
[exEnd] |
77 | 133 |
|
134 |
||
1772 | 135 |
draw without menu-handle: |
136 |
[exBegin] |
|
137 |
|p| |
|
138 |
p := PopUpList label:'fruit'. |
|
139 |
p list:#('apples' 'bananas' 'grape' 'lemon' '-' 'margaritas'). |
|
140 |
p showHandle:false. |
|
141 |
p open |
|
142 |
[exEnd] |
|
143 |
||
144 |
||
77 | 145 |
with an action: |
1063 | 146 |
[exBegin] |
77 | 147 |
|p| |
148 |
p := PopUpList label:'dummy'. |
|
119 | 149 |
p list:#('apples' 'bananas' 'grape' 'lemon' '-' 'margaritas'). |
77 | 150 |
p selection:'apples'. |
655 | 151 |
p action:[:what | Transcript showCR:'you selected: ' , what]. |
77 | 152 |
p open |
1063 | 153 |
[exEnd] |
77 | 154 |
|
155 |
||
119 | 156 |
sometimes, you may like the index instead of the value: |
327
5cd2a6f4f28e
fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
157 |
(notice, that the separating line counts, so you have to take care ...) |
1063 | 158 |
[exBegin] |
119 | 159 |
|p| |
160 |
p := PopUpList label:'dummy'. |
|
161 |
p list:#('apples' 'bananas' 'grape' 'lemon' '-' 'margaritas'). |
|
162 |
p selection:'apples'. |
|
655 | 163 |
p action:[:what | Transcript show:'you selected: '; showCR:what]. |
119 | 164 |
p useIndex:true. |
165 |
p open |
|
1063 | 166 |
[exEnd] |
119 | 167 |
|
168 |
||
169 |
since the list is actually a popupMenu, you can add double-separators: |
|
1071 | 170 |
also, here values are different from the labels |
1063 | 171 |
[exBegin] |
119 | 172 |
|p| |
173 |
p := PopUpList label:'dummy'. |
|
174 |
p list:#('apples' 'bananas' 'grape' 'lemon' |
|
1063 | 175 |
'=' |
176 |
'margaritas' 'pina colada' |
|
177 |
'=' |
|
178 |
'smalltalk' 'c++' 'eiffel' 'java'). |
|
119 | 179 |
p values:#(apples bananas grape lemon |
1063 | 180 |
nil |
181 |
'mhmh - so good' 'makes headache' |
|
182 |
nil |
|
183 |
'great' 'another headache' 'not bad' 'neat'). |
|
327
5cd2a6f4f28e
fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
184 |
p selection:'apples'. |
655 | 185 |
p action:[:what | Transcript show:'you selected: '; showCR:what]. |
327
5cd2a6f4f28e
fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
186 |
p open |
1063 | 187 |
[exEnd] |
327
5cd2a6f4f28e
fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
188 |
|
5cd2a6f4f28e
fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
189 |
|
5cd2a6f4f28e
fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
190 |
since the list is actually represented by a menuView, |
5cd2a6f4f28e
fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
191 |
which itself is inheriting from listView, which itself can display |
5cd2a6f4f28e
fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
192 |
things different from strings, arbitrary lists can be constructed: |
1066
d324041c0aaf
examples and values-handling
Claus Gittinger <cg@exept.de>
parents:
1065
diff
changeset
|
193 |
(see ListEntry, LabelAndIcon and Text classes) |
1063 | 194 |
[exBegin] |
327
5cd2a6f4f28e
fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
195 |
|p l| |
5cd2a6f4f28e
fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
196 |
p := PopUpList label:'dummy'. |
5cd2a6f4f28e
fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
197 |
l := OrderedCollection new. |
1065 | 198 |
l add:(Text string:'apples' color:Color red). |
199 |
l add:(Text string:'bananas' color:Color red). |
|
200 |
l add:(Text string:'grape' color:Color red). |
|
201 |
l add:(Text string:'lemon' color:Color red). |
|
327
5cd2a6f4f28e
fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
202 |
l add:'='. |
1065 | 203 |
l add:(Text string:'margaritas' color:Color green darkened darkened). |
204 |
l add:(Text string:'pina colada' color:Color green darkened darkened). |
|
327
5cd2a6f4f28e
fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
205 |
l add:'='. |
1065 | 206 |
l add:(Text string:'smalltalk' color:Color blue). |
207 |
l add:(Text string:'c++' color:Color blue). |
|
208 |
l add:(Text string:'eiffel' color:Color blue). |
|
209 |
l add:(Text string:'java' color:Color blue). |
|
327
5cd2a6f4f28e
fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
210 |
p list:l. |
5cd2a6f4f28e
fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
211 |
p values:#(apples bananas grape lemon |
1063 | 212 |
nil |
213 |
'mhmh - so good' 'makes headache' |
|
214 |
nil |
|
215 |
'great' 'another headache' 'not bad' 'neat'). |
|
119 | 216 |
p selection:'apples'. |
655 | 217 |
p action:[:what | Transcript show:'you selected: '; showCR:what]. |
119 | 218 |
p open |
1063 | 219 |
[exEnd] |
119 | 220 |
|
221 |
||
77 | 222 |
with values different from the label strings: |
1063 | 223 |
[exBegin] |
77 | 224 |
|p| |
225 |
p := PopUpList label:'dummy'. |
|
119 | 226 |
p list:#('apples' 'bananas' 'grape' 'lemon' '-' 'margaritas'). |
77 | 227 |
p selection:'apples'. |
228 |
p values:#(10 20 30 40 nil 50). |
|
655 | 229 |
p action:[:what | Transcript show:'you selected: '; showCR:what]. |
77 | 230 |
p open |
1063 | 231 |
[exEnd] |
119 | 232 |
|
121 | 233 |
|
1069 | 234 |
with values different from the label strings: |
235 |
[exBegin] |
|
236 |
|p| |
|
237 |
||
238 |
p := PopUpList label:'language selection'. |
|
239 |
p list:( #( |
|
240 |
'usa' |
|
241 |
'uk' |
|
242 |
'france' |
|
243 |
'germany' |
|
244 |
'italy' |
|
245 |
) collect:[:country | |
|
246 |
LabelAndIcon |
|
247 |
icon:(Image fromFile:'bitmaps/xpmBitmaps/countries/' , country , '.xpm') |
|
248 |
string:country |
|
249 |
] |
|
250 |
). |
|
251 |
p values:#(us england france germany italy). |
|
252 |
||
253 |
p action:[:what | Transcript show:'you selected: '; showCR:what]. |
|
254 |
p open |
|
255 |
[exEnd] |
|
256 |
||
257 |
||
1064 | 258 |
with a model (see in the inspector, how the index-holders value changes) |
1063 | 259 |
the defaults are setup to allow a SelectionInList directly as model: |
260 |
[exBegin] |
|
119 | 261 |
|p model| |
262 |
||
263 |
model := SelectionInList with:#('apples' 'bananas' 'grape' 'lemon' 'margaritas'). |
|
264 |
||
265 |
p := PopUpList label:'healthy fruit'. |
|
266 |
p model:model. |
|
267 |
p open. |
|
1063 | 268 |
model inspect |
269 |
[exEnd] |
|
121 | 270 |
|
20 | 271 |
|
1071 | 272 |
model provides selection; list is explicit: |
273 |
must change the aspect, since the default setup is for a SelectionInList |
|
274 |
[exBegin] |
|
275 |
|model top b| |
|
276 |
||
277 |
model := 'foo' asValue. |
|
278 |
||
279 |
top := StandardSystemView new. |
|
280 |
top extent:(300 @ 200). |
|
281 |
||
282 |
b := PopUpList in:top. |
|
283 |
b origin:(0.0 @ 0.0) corner:(1.0 @ 0.0). |
|
284 |
b bottomInset:(b preferredExtent y negated). |
|
285 |
||
286 |
b list:#('hello' 'world' 'this' 'is' 'st/x'). |
|
287 |
b model:model; aspect:#value; change:#value:. |
|
288 |
||
289 |
top openModal. |
|
290 |
Transcript showCR:('comboBox''s value: ' , model value). |
|
291 |
[exEnd] |
|
292 |
||
293 |
||
125 | 294 |
a popupList and a SelectionInListView on the same model: |
1063 | 295 |
[exBegin] |
125 | 296 |
|p slv model| |
297 |
||
298 |
model := SelectionInList with:#('apples' 'bananas' 'grape' 'lemon' 'margaritas'). |
|
299 |
model selection:'apples'. |
|
300 |
||
301 |
p := PopUpList on:model. |
|
1064 | 302 |
p open. |
303 |
||
304 |
slv := SelectionInListView on:model. |
|
305 |
slv open. |
|
306 |
[exEnd] |
|
307 |
||
308 |
||
309 |
dynamically changing the list (click button(s) to change): |
|
310 |
[exBegin] |
|
311 |
|p slv model b| |
|
312 |
||
313 |
model := SelectionInList with:#('apples' 'bananas' 'grape' 'lemon' 'margaritas'). |
|
314 |
model selection:'apples'. |
|
315 |
||
316 |
p := PopUpList on:model. |
|
125 | 317 |
p open. |
318 |
||
319 |
slv := SelectionInListView on:model. |
|
320 |
slv open. |
|
321 |
||
1064 | 322 |
b := Button label:'long list' action:[model list:#('1' '2' '3' '4' '5' '6')]. |
323 |
b open. |
|
324 |
b := Button label:'short list' action:[model list:#('1' '2' '3')]. |
|
325 |
b open. |
|
326 |
||
1063 | 327 |
[exEnd] |
328 |
||
329 |
||
125 | 330 |
|
127 | 331 |
two PopUpLists on the same model, different aspects: |
1063 | 332 |
[exBegin] |
121 | 333 |
|top panel p model| |
20 | 334 |
|
121 | 335 |
model := Plug new. |
655 | 336 |
model respondTo:#eat: with:[:val | Transcript showCR:'eat: ' , val]. |
337 |
model respondTo:#drink: with:[:val | Transcript showCR:'drink: ' , val]. |
|
121 | 338 |
model respondTo:#meals with:[#(taco burrito enchilada)]. |
327
5cd2a6f4f28e
fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
339 |
model respondTo:#drinks with:[#(margarita water corona)]. |
20 | 340 |
|
121 | 341 |
top := StandardSystemView new. |
342 |
top extent:(100@100). |
|
343 |
panel := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top. |
|
344 |
panel horizontalLayout:#fitSpace. |
|
77 | 345 |
|
121 | 346 |
p := PopUpList label:'meals'. |
126 | 347 |
p model:model; listMessage:#meals; aspect:nil; change:#eat:. |
121 | 348 |
panel add:p. |
119 | 349 |
|
121 | 350 |
p := PopUpList label:'drinks'. |
126 | 351 |
p model:model; listMessage:#drinks; aspect:nil; change:#drink:. |
121 | 352 |
panel add:p. |
77 | 353 |
|
121 | 354 |
top open |
1063 | 355 |
[exEnd] |
1052
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
356 |
|
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
357 |
|
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
358 |
with separate list- and indexHolders: |
1063 | 359 |
[exBegin] |
1052
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
360 |
|p selectionHolder listHolder| |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
361 |
|
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
362 |
listHolder := #('apples' 'bananas' 'grape' 'lemon' 'margaritas') asValue. |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
363 |
selectionHolder := 'apples' asValue. |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
364 |
|
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
365 |
p := PopUpList label:'healthy fruit'. |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
366 |
p listHolder:listHolder. |
1066
d324041c0aaf
examples and values-handling
Claus Gittinger <cg@exept.de>
parents:
1065
diff
changeset
|
367 |
p model:selectionHolder; aspect:#value; change:#value:. |
1052
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
368 |
p open. |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
369 |
selectionHolder inspect |
1063 | 370 |
[exEnd] |
1052
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
371 |
|
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
372 |
same, using index: |
1063 | 373 |
[exBegin] |
1052
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
374 |
|p selectionIndexHolder listHolder| |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
375 |
|
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
376 |
listHolder := #('apples' 'bananas' 'grape' 'lemon' 'margaritas') asValue. |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
377 |
selectionIndexHolder := 3 asValue. |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
378 |
|
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
379 |
p := PopUpList new. |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
380 |
p listHolder:listHolder. |
1066
d324041c0aaf
examples and values-handling
Claus Gittinger <cg@exept.de>
parents:
1065
diff
changeset
|
381 |
p model:selectionIndexHolder; aspect:#value; change:#value:. |
1052
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
382 |
p useIndex:true. |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
383 |
p open. |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
384 |
selectionIndexHolder inspect |
1063 | 385 |
[exEnd] |
1052
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
386 |
|
1066
d324041c0aaf
examples and values-handling
Claus Gittinger <cg@exept.de>
parents:
1065
diff
changeset
|
387 |
using different values: |
d324041c0aaf
examples and values-handling
Claus Gittinger <cg@exept.de>
parents:
1065
diff
changeset
|
388 |
[exBegin] |
d324041c0aaf
examples and values-handling
Claus Gittinger <cg@exept.de>
parents:
1065
diff
changeset
|
389 |
|p selectionHolder listHolder values| |
d324041c0aaf
examples and values-handling
Claus Gittinger <cg@exept.de>
parents:
1065
diff
changeset
|
390 |
|
d324041c0aaf
examples and values-handling
Claus Gittinger <cg@exept.de>
parents:
1065
diff
changeset
|
391 |
listHolder := #('apples' 'bananas' 'grape' 'lemon' 'margaritas') asValue. |
d324041c0aaf
examples and values-handling
Claus Gittinger <cg@exept.de>
parents:
1065
diff
changeset
|
392 |
values := #(apples bananas grape lemon alcohol). |
d324041c0aaf
examples and values-handling
Claus Gittinger <cg@exept.de>
parents:
1065
diff
changeset
|
393 |
|
d324041c0aaf
examples and values-handling
Claus Gittinger <cg@exept.de>
parents:
1065
diff
changeset
|
394 |
selectionHolder := #alcohol asValue. |
d324041c0aaf
examples and values-handling
Claus Gittinger <cg@exept.de>
parents:
1065
diff
changeset
|
395 |
|
d324041c0aaf
examples and values-handling
Claus Gittinger <cg@exept.de>
parents:
1065
diff
changeset
|
396 |
p := PopUpList label:'healthy fruit'. |
d324041c0aaf
examples and values-handling
Claus Gittinger <cg@exept.de>
parents:
1065
diff
changeset
|
397 |
p listHolder:listHolder. |
d324041c0aaf
examples and values-handling
Claus Gittinger <cg@exept.de>
parents:
1065
diff
changeset
|
398 |
p model:selectionHolder; aspect:#value; change:#value:. |
d324041c0aaf
examples and values-handling
Claus Gittinger <cg@exept.de>
parents:
1065
diff
changeset
|
399 |
p values:values. |
d324041c0aaf
examples and values-handling
Claus Gittinger <cg@exept.de>
parents:
1065
diff
changeset
|
400 |
p open. |
d324041c0aaf
examples and values-handling
Claus Gittinger <cg@exept.de>
parents:
1065
diff
changeset
|
401 |
selectionHolder inspect |
d324041c0aaf
examples and values-handling
Claus Gittinger <cg@exept.de>
parents:
1065
diff
changeset
|
402 |
[exEnd] |
d324041c0aaf
examples and values-handling
Claus Gittinger <cg@exept.de>
parents:
1065
diff
changeset
|
403 |
|
2262 | 404 |
provide your own menu (spec could come from a specMethod): |
405 |
[exBegin] |
|
406 |
|p myMenu selectionHolder| |
|
407 |
||
408 |
selectionHolder := nil asValue. |
|
409 |
myMenu := |
|
410 |
#(#Menu |
|
411 |
#( |
|
412 |
#(#MenuItem |
|
413 |
#label: 'Oranges' |
|
414 |
#translateLabel: true |
|
415 |
#value: #oranges |
|
416 |
) |
|
417 |
#(#MenuItem |
|
418 |
#label: 'Lemons' |
|
419 |
#translateLabel: true |
|
420 |
#value: #lemons |
|
421 |
) |
|
422 |
#(#MenuItem |
|
423 |
#label: 'grape' |
|
424 |
#translateLabel: true |
|
425 |
#value: #grape |
|
426 |
) |
|
427 |
#(#MenuItem |
|
428 |
#label: '-' |
|
429 |
) |
|
430 |
#(#MenuItem |
|
431 |
#label: 'other' |
|
432 |
#translateLabel: true |
|
433 |
#value: #other |
|
434 |
#submenu: |
|
435 |
#(#Menu |
|
436 |
#( |
|
437 |
#(#MenuItem |
|
438 |
#label: 'margarita' |
|
439 |
#translateLabel: true |
|
440 |
#value: #margarita |
|
441 |
) |
|
442 |
#(#MenuItem |
|
443 |
#label: 'vine' |
|
444 |
#translateLabel: true |
|
445 |
#value: #vine |
|
446 |
) |
|
447 |
) |
|
448 |
) |
|
449 |
) |
|
450 |
) |
|
451 |
) decodeAsLiteralArray. |
|
452 |
p := PopUpList label:'healthy fruit'. |
|
453 |
p menu:myMenu. |
|
454 |
p model:selectionHolder; aspect:#value; change:#value:. |
|
455 |
selectionHolder inspect. |
|
456 |
p open. |
|
457 |
[exEnd] |
|
1052
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
458 |
|
121 | 459 |
" |
20 | 460 |
! ! |
461 |
||
998 | 462 |
!PopUpList class methodsFor:'defaults'! |
125 | 463 |
|
464 |
defaultAspectMessage |
|
465 |
^ #selection |
|
466 |
! |
|
467 |
||
468 |
defaultChangeMessage |
|
469 |
^ #selection: |
|
205 | 470 |
! |
471 |
||
472 |
defaultListMessage |
|
473 |
^ #list |
|
474 |
! ! |
|
475 |
||
476 |
!PopUpList methodsFor:'accessing'! |
|
477 |
||
478 |
contents |
|
2262 | 479 |
"return the current contents" |
480 |
||
205 | 481 |
^ self label |
482 |
! |
|
483 |
||
484 |
contents:con |
|
2262 | 485 |
"change the contents" |
486 |
||
205 | 487 |
^ self selection:con |
488 |
||
684 | 489 |
"Modified: 25.5.1996 / 14:20:57 / cg" |
205 | 490 |
! |
491 |
||
1035 | 492 |
defaultLabel:aString |
493 |
"set the defaultLabel, to be shown if nothing is selected" |
|
494 |
||
1368 | 495 |
defaultLabel := aString. |
496 |
shown ifFalse:[ |
|
497 |
super label:defaultLabel |
|
498 |
]. |
|
499 |
||
500 |
"Modified: / 29.10.1997 / 15:50:10 / cg" |
|
1035 | 501 |
! |
502 |
||
1086
76da3ddb3372
label: only affects the actual label, if there is no model.
Claus Gittinger <cg@exept.de>
parents:
1083
diff
changeset
|
503 |
label:aString |
76da3ddb3372
label: only affects the actual label, if there is no model.
Claus Gittinger <cg@exept.de>
parents:
1083
diff
changeset
|
504 |
self defaultLabel:aString. |
76da3ddb3372
label: only affects the actual label, if there is no model.
Claus Gittinger <cg@exept.de>
parents:
1083
diff
changeset
|
505 |
model isNil ifTrue:[ |
1368 | 506 |
super label:aString suppressResize:(self shown) |
1086
76da3ddb3372
label: only affects the actual label, if there is no model.
Claus Gittinger <cg@exept.de>
parents:
1083
diff
changeset
|
507 |
]. |
76da3ddb3372
label: only affects the actual label, if there is no model.
Claus Gittinger <cg@exept.de>
parents:
1083
diff
changeset
|
508 |
|
1368 | 509 |
"Created: / 1.3.1997 / 02:09:02 / cg" |
510 |
"Modified: / 29.10.1997 / 15:49:50 / cg" |
|
1086
76da3ddb3372
label: only affects the actual label, if there is no model.
Claus Gittinger <cg@exept.de>
parents:
1083
diff
changeset
|
511 |
! |
76da3ddb3372
label: only affects the actual label, if there is no model.
Claus Gittinger <cg@exept.de>
parents:
1083
diff
changeset
|
512 |
|
205 | 513 |
list |
514 |
"return the list - i.e. the values shown in the pop-up list" |
|
515 |
||
516 |
^ menu labels |
|
517 |
! |
|
518 |
||
519 |
list:aList |
|
520 |
"set the list - i.e. the values shown in the pop-up list" |
|
521 |
||
522 |
self createMenuFor:aList. |
|
523 |
realized ifTrue:[ |
|
524 |
self computeLabelSize |
|
525 |
] |
|
526 |
||
527 |
" |
|
528 |
|p| |
|
529 |
p := PopUpList label:'fruit ?'. |
|
530 |
p list:#('apples' 'bananas' 'grape' 'lemon' 'margaritas'). |
|
655 | 531 |
p action:[:val | Transcript showCR:'selected: ' , val printString]. |
205 | 532 |
p open |
533 |
" |
|
534 |
! |
|
535 |
||
536 |
selection:indexOrString |
|
537 |
"set (force) a selection - usually done to set |
|
538 |
an initial selection without updating others" |
|
539 |
||
1839
75f77fcf458b
fix: defaultLabel with nil-selection and not useIndex.
Claus Gittinger <cg@exept.de>
parents:
1772
diff
changeset
|
540 |
|index menuLabels newLabel| |
205 | 541 |
|
1052
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
542 |
menu isNil ifTrue:[ |
1066
d324041c0aaf
examples and values-handling
Claus Gittinger <cg@exept.de>
parents:
1065
diff
changeset
|
543 |
self getListFromModel. |
1052
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
544 |
]. |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
545 |
menu isNil ifTrue:[^ self]. |
1368 | 546 |
menuLabels := menu labels. |
1052
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
547 |
|
1066
d324041c0aaf
examples and values-handling
Claus Gittinger <cg@exept.de>
parents:
1065
diff
changeset
|
548 |
(useIndex not and:[values notNil]) ifTrue:[ |
2494
6e3fc702b1af
care for nil list, when setting the model
Claus Gittinger <cg@exept.de>
parents:
2464
diff
changeset
|
549 |
values notNil ifTrue:[ |
6e3fc702b1af
care for nil list, when setting the model
Claus Gittinger <cg@exept.de>
parents:
2464
diff
changeset
|
550 |
index := values indexOf:indexOrString |
6e3fc702b1af
care for nil list, when setting the model
Claus Gittinger <cg@exept.de>
parents:
2464
diff
changeset
|
551 |
] |
1066
d324041c0aaf
examples and values-handling
Claus Gittinger <cg@exept.de>
parents:
1065
diff
changeset
|
552 |
] ifFalse:[ |
1237 | 553 |
indexOrString isNumber ifTrue:[ |
554 |
index := indexOrString |
|
555 |
] ifFalse:[ |
|
2494
6e3fc702b1af
care for nil list, when setting the model
Claus Gittinger <cg@exept.de>
parents:
2464
diff
changeset
|
556 |
menuLabels notNil ifTrue:[ |
6e3fc702b1af
care for nil list, when setting the model
Claus Gittinger <cg@exept.de>
parents:
2464
diff
changeset
|
557 |
index := menuLabels indexOf:indexOrString. |
6e3fc702b1af
care for nil list, when setting the model
Claus Gittinger <cg@exept.de>
parents:
2464
diff
changeset
|
558 |
] |
1237 | 559 |
]. |
1079 | 560 |
"/ fails if list consists of symbols ... |
561 |
"/ index := menu indexOf:indexOrString. |
|
1066
d324041c0aaf
examples and values-handling
Claus Gittinger <cg@exept.de>
parents:
1065
diff
changeset
|
562 |
]. |
2494
6e3fc702b1af
care for nil list, when setting the model
Claus Gittinger <cg@exept.de>
parents:
2464
diff
changeset
|
563 |
(index isNil or:[index > menuLabels size]) ifTrue:[ |
1368 | 564 |
index := 0 |
565 |
]. |
|
566 |
||
1035 | 567 |
index == 0 ifTrue:[ |
1839
75f77fcf458b
fix: defaultLabel with nil-selection and not useIndex.
Claus Gittinger <cg@exept.de>
parents:
1772
diff
changeset
|
568 |
newLabel := defaultLabel |
75f77fcf458b
fix: defaultLabel with nil-selection and not useIndex.
Claus Gittinger <cg@exept.de>
parents:
1772
diff
changeset
|
569 |
] ifFalse:[ |
75f77fcf458b
fix: defaultLabel with nil-selection and not useIndex.
Claus Gittinger <cg@exept.de>
parents:
1772
diff
changeset
|
570 |
newLabel := (menuLabels at:index) printString |
1035 | 571 |
]. |
205 | 572 |
|
573 |
"kludge: dont want label to resize ..." |
|
2266 | 574 |
|
1839
75f77fcf458b
fix: defaultLabel with nil-selection and not useIndex.
Claus Gittinger <cg@exept.de>
parents:
1772
diff
changeset
|
575 |
self label:newLabel suppressResize:true. |
205 | 576 |
|
577 |
" |
|
578 |
|p| |
|
579 |
p := PopUpList label:'what fruit ?'. |
|
580 |
p list:#('apples' 'bananas' 'grape' 'lemon' 'margaritas'). |
|
581 |
p selection:'grape'. |
|
582 |
p open |
|
583 |
||
584 |
|p| |
|
585 |
p := PopUpList label:'what fruit ?'. |
|
586 |
p list:#('apples' 'bananas' 'grape' 'lemon' 'margaritas'). |
|
587 |
p selection:'blabla'. |
|
588 |
p open |
|
1066
d324041c0aaf
examples and values-handling
Claus Gittinger <cg@exept.de>
parents:
1065
diff
changeset
|
589 |
|
d324041c0aaf
examples and values-handling
Claus Gittinger <cg@exept.de>
parents:
1065
diff
changeset
|
590 |
|p| |
d324041c0aaf
examples and values-handling
Claus Gittinger <cg@exept.de>
parents:
1065
diff
changeset
|
591 |
p := PopUpList label:'what fruit ?'. |
d324041c0aaf
examples and values-handling
Claus Gittinger <cg@exept.de>
parents:
1065
diff
changeset
|
592 |
p list:#('apples' 'bananas' 'grape' 'lemon' 'margaritas'). |
d324041c0aaf
examples and values-handling
Claus Gittinger <cg@exept.de>
parents:
1065
diff
changeset
|
593 |
p defaultLabel:'nothing selected'. |
d324041c0aaf
examples and values-handling
Claus Gittinger <cg@exept.de>
parents:
1065
diff
changeset
|
594 |
p selection:'blabla'. |
d324041c0aaf
examples and values-handling
Claus Gittinger <cg@exept.de>
parents:
1065
diff
changeset
|
595 |
p open |
205 | 596 |
" |
327
5cd2a6f4f28e
fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
597 |
|
1368 | 598 |
"Modified: / 29.10.1997 / 15:50:12 / cg" |
205 | 599 |
! |
600 |
||
593 | 601 |
values:aList |
602 |
"set a value list - these are reported via the action or changeSymbol instead of |
|
1052
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
603 |
the label strings." |
593 | 604 |
|
605 |
values := aList. |
|
606 |
||
607 |
" |
|
608 |
|p| |
|
609 |
p := PopUpList label:'fruit ?'. |
|
610 |
p list:#('apples' 'bananas' 'grape' 'lemon' 'margaritas'). |
|
611 |
p values:#(1 2 3 4 'mhmh - good'). |
|
655 | 612 |
p action:[:val | Transcript showCR:'selected: ' , val printString]. |
593 | 613 |
p open. |
614 |
" |
|
1066
d324041c0aaf
examples and values-handling
Claus Gittinger <cg@exept.de>
parents:
1065
diff
changeset
|
615 |
|
d324041c0aaf
examples and values-handling
Claus Gittinger <cg@exept.de>
parents:
1065
diff
changeset
|
616 |
"Modified: 27.2.1997 / 10:24:12 / cg" |
593 | 617 |
! ! |
618 |
||
619 |
!PopUpList methodsFor:'accessing-behavior'! |
|
620 |
||
621 |
action:aOneArgBlock |
|
622 |
"set the action to be performed on selection changes; |
|
623 |
the argument, aOneArgBlock will be evaluated with the |
|
624 |
selection-value as argument" |
|
625 |
||
626 |
menuAction := aOneArgBlock |
|
627 |
! |
|
628 |
||
2262 | 629 |
menu:aMenu |
630 |
"explicit change of the menu; |
|
631 |
allows for non-list-based, or MenuBuilder-constructed menus to be used. |
|
632 |
Attention: this bypasses the list/listHolder" |
|
633 |
||
634 |
menu := aMenu. |
|
635 |
! |
|
636 |
||
1098 | 637 |
menu:aMenu default:label |
2262 | 638 |
"explicit change of the menu and default value; |
639 |
allows for non-list-based, or MenuBuilder-constructed menus to be used. |
|
640 |
Attention: this bypasses the list/listHolder" |
|
641 |
||
1098 | 642 |
menu := aMenu. |
643 |
defaultLabel := label |
|
644 |
! |
|
645 |
||
1311 | 646 |
useIndex |
647 |
"tell the popuplist to pass the index (instead of the value) |
|
648 |
to both the actionBlock and model. Notice, that if you use a model, |
|
649 |
the default changeSelector is not ok for using index and a SelectionInList" |
|
650 |
||
651 |
^ useIndex |
|
652 |
! |
|
653 |
||
205 | 654 |
useIndex:aBoolean |
655 |
"tell the popuplist to pass the index (instead of the value) |
|
656 |
to both the actionBlock and model. Notice, that if you use a model, |
|
657 |
the default changeSelector is not ok for using index and a SelectionInList" |
|
658 |
||
659 |
useIndex := aBoolean |
|
660 |
||
661 |
" |
|
662 |
|p| |
|
663 |
p := PopUpList label:'fruit ?'. |
|
664 |
p list:#('apples' 'bananas' 'grape' 'lemon' 'margaritas'). |
|
655 | 665 |
p action:[:val | Transcript showCR:'selected: ' , val printString]. |
205 | 666 |
p open. |
667 |
" |
|
668 |
" |
|
669 |
|p| |
|
670 |
p := PopUpList label:'fruit ?'. |
|
671 |
p list:#('apples' 'bananas' 'grape' 'lemon' 'margaritas'). |
|
655 | 672 |
p action:[:val | Transcript showCR:'selected: ' , val printString]. |
205 | 673 |
p useIndex:true. |
674 |
p open. |
|
675 |
" |
|
125 | 676 |
! ! |
677 |
||
1921 | 678 |
!PopUpList methodsFor:'accessing-look'! |
679 |
||
680 |
showHandle |
|
681 |
"return true if the pull-handle is to be drawn; default is true" |
|
682 |
||
683 |
^ showHandle |
|
684 |
||
685 |
"Created: / 6.3.1999 / 21:26:40 / cg" |
|
686 |
! |
|
687 |
||
688 |
showHandle:aBoolean |
|
689 |
"controls if the pull-handle is to be drawn; default is true" |
|
690 |
||
2267 | 691 |
showHandle ~~ aBoolean ifTrue:[ |
692 |
showHandle := aBoolean. |
|
693 |
self computeLabelSize |
|
694 |
]. |
|
1921 | 695 |
|
696 |
"Modified: / 6.3.1999 / 21:58:21 / cg" |
|
697 |
! ! |
|
698 |
||
205 | 699 |
!PopUpList methodsFor:'accessing-mvc'! |
700 |
||
701 |
addModelInterfaceTo:aDictionary |
|
702 |
"see comment in View>>modelInterface" |
|
703 |
||
704 |
super addModelInterfaceTo:aDictionary. |
|
705 |
aDictionary at:#listMessage put:listMsg |
|
1063 | 706 |
|
707 |
"Modified: 26.2.1997 / 19:08:04 / cg" |
|
205 | 708 |
! |
709 |
||
1063 | 710 |
listHolder |
711 |
"return the listHolder if any" |
|
712 |
||
713 |
^ listHolder |
|
714 |
! |
|
715 |
||
716 |
listHolder:aValueHolder |
|
717 |
"set the listHolder - if non nil, that one is assumed to provide the |
|
718 |
list via #value. |
|
719 |
If a listHolder was defined, the model is never asked for the list." |
|
720 |
||
721 |
listHolder notNil ifTrue:[ |
|
722 |
listHolder removeDependent:self. |
|
723 |
]. |
|
724 |
listHolder := aValueHolder. |
|
725 |
listHolder notNil ifTrue:[ |
|
726 |
listHolder addDependent:self. |
|
727 |
]. |
|
728 |
shown ifTrue:[ |
|
729 |
self getListFromModel |
|
730 |
] |
|
731 |
||
732 |
"Modified: 26.2.1997 / 19:06:01 / cg" |
|
205 | 733 |
! |
734 |
||
735 |
listMessage |
|
1063 | 736 |
"return the selector by which we ask the model or listHolder for the list. |
737 |
The default is #list. |
|
738 |
If a listHolder was defined, the model is never asked for the list." |
|
205 | 739 |
|
740 |
^ listMsg |
|
1063 | 741 |
|
742 |
"Modified: 26.2.1997 / 19:05:27 / cg" |
|
205 | 743 |
! |
744 |
||
745 |
listMessage:aSelector |
|
746 |
"set the selector by which we ask the model for the list. |
|
1063 | 747 |
The default is #list. |
748 |
If a listHolder was defined, the model is never asked for the list." |
|
205 | 749 |
|
750 |
listMsg := aSelector |
|
1063 | 751 |
|
752 |
"Modified: 26.2.1997 / 19:05:18 / cg" |
|
1083
13e64cc1c493
fetch models value when a model is assigned;
Claus Gittinger <cg@exept.de>
parents:
1079
diff
changeset
|
753 |
! |
13e64cc1c493
fetch models value when a model is assigned;
Claus Gittinger <cg@exept.de>
parents:
1079
diff
changeset
|
754 |
|
13e64cc1c493
fetch models value when a model is assigned;
Claus Gittinger <cg@exept.de>
parents:
1079
diff
changeset
|
755 |
model:aModel |
2262 | 756 |
"set the model which provides the selection and/or the list" |
757 |
||
1083
13e64cc1c493
fetch models value when a model is assigned;
Claus Gittinger <cg@exept.de>
parents:
1079
diff
changeset
|
758 |
super model:aModel. |
13e64cc1c493
fetch models value when a model is assigned;
Claus Gittinger <cg@exept.de>
parents:
1079
diff
changeset
|
759 |
self getListFromModel. |
13e64cc1c493
fetch models value when a model is assigned;
Claus Gittinger <cg@exept.de>
parents:
1079
diff
changeset
|
760 |
self getSelectionFromModel. |
13e64cc1c493
fetch models value when a model is assigned;
Claus Gittinger <cg@exept.de>
parents:
1079
diff
changeset
|
761 |
|
13e64cc1c493
fetch models value when a model is assigned;
Claus Gittinger <cg@exept.de>
parents:
1079
diff
changeset
|
762 |
"Created: 28.2.1997 / 19:12:08 / cg" |
205 | 763 |
! ! |
764 |
||
765 |
!PopUpList methodsFor:'change & update'! |
|
766 |
||
767 |
update:something with:aParameter from:changedObject |
|
1052
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
768 |
changedObject == listHolder ifTrue:[ |
1063 | 769 |
self getListFromModel. |
770 |
^ self |
|
1052
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
771 |
]. |
205 | 772 |
changedObject == model ifTrue:[ |
1078 | 773 |
aspectMsg notNil ifTrue:[ |
2267 | 774 |
|
1063 | 775 |
self getSelectionFromModel. |
776 |
]. |
|
1586
e4e6e12cbd1f
ST-80 compatibility changes.
Claus Gittinger <cg@exept.de>
parents:
1492
diff
changeset
|
777 |
listHolder notNil ifTrue:[ |
e4e6e12cbd1f
ST-80 compatibility changes.
Claus Gittinger <cg@exept.de>
parents:
1492
diff
changeset
|
778 |
"/ that one holds the list; |
e4e6e12cbd1f
ST-80 compatibility changes.
Claus Gittinger <cg@exept.de>
parents:
1492
diff
changeset
|
779 |
"/ model holds the value |
e4e6e12cbd1f
ST-80 compatibility changes.
Claus Gittinger <cg@exept.de>
parents:
1492
diff
changeset
|
780 |
self getSelectionFromModel |
e4e6e12cbd1f
ST-80 compatibility changes.
Claus Gittinger <cg@exept.de>
parents:
1492
diff
changeset
|
781 |
] ifFalse:[ |
e4e6e12cbd1f
ST-80 compatibility changes.
Claus Gittinger <cg@exept.de>
parents:
1492
diff
changeset
|
782 |
listMsg notNil ifTrue:[ |
e4e6e12cbd1f
ST-80 compatibility changes.
Claus Gittinger <cg@exept.de>
parents:
1492
diff
changeset
|
783 |
self getListFromModel. |
e4e6e12cbd1f
ST-80 compatibility changes.
Claus Gittinger <cg@exept.de>
parents:
1492
diff
changeset
|
784 |
] |
1063 | 785 |
]. |
786 |
^ self |
|
205 | 787 |
]. |
788 |
super update:something with:aParameter from:changedObject |
|
1063 | 789 |
|
1586
e4e6e12cbd1f
ST-80 compatibility changes.
Claus Gittinger <cg@exept.de>
parents:
1492
diff
changeset
|
790 |
"Modified: / 18.6.1998 / 23:48:47 / cg" |
205 | 791 |
! ! |
792 |
||
793 |
!PopUpList methodsFor:'drawing'! |
|
794 |
||
795 |
drawWith:fgColor and:bgColor |
|
796 |
|mmH mmV mW mH| |
|
136 | 797 |
|
205 | 798 |
controller pressed ifTrue:[ |
1758 | 799 |
super drawWith:enteredFgColor and:enteredBgColor |
205 | 800 |
] ifFalse:[ |
1758 | 801 |
super drawWith:fgColor and:bgColor. |
205 | 802 |
]. |
803 |
||
1758 | 804 |
showHandle ifTrue:[ |
1772 | 805 |
mmH := device horizontalPixelPerMillimeter. |
806 |
mmV := device verticalPixelPerMillimeter. |
|
807 |
mW := (mmH * 2.5) rounded. |
|
808 |
mH := (mmV * 1.5) rounded. |
|
1758 | 809 |
|
2497
e3e1a719e31d
support etched color (win32 style)
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
810 |
self |
e3e1a719e31d
support etched color (win32 style)
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
811 |
drawEdgesForX:(width - mW - (hSpace*2)) y:(height - mmV rounded // 2) |
e3e1a719e31d
support etched color (win32 style)
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
812 |
width:mW height:mH |
e3e1a719e31d
support etched color (win32 style)
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
813 |
level:2 |
1758 | 814 |
]. |
1772 | 815 |
|
816 |
"Modified: / 6.3.1999 / 21:56:13 / cg" |
|
205 | 817 |
! |
818 |
||
819 |
showActive |
|
820 |
"no need to redraw - will pop menu ontop of me anyway ..." |
|
821 |
||
822 |
^ self |
|
823 |
! |
|
824 |
||
825 |
showPassive |
|
826 |
"no need to redraw - will redraw from unpopped menu anyway ..." |
|
827 |
||
828 |
^ self |
|
829 |
! ! |
|
830 |
||
831 |
!PopUpList methodsFor:'event handling'! |
|
832 |
||
1492 | 833 |
keyPress:key x:x y:y |
2398 | 834 |
<resource: #keyboard (#Return)> |
835 |
||
2262 | 836 |
(key == Character space or:[key == #Return])ifTrue:[ |
1492 | 837 |
self popMenu. |
838 |
^ self |
|
839 |
]. |
|
840 |
super keyPress:key x:x y:y |
|
841 |
||
842 |
"Created: / 21.4.1998 / 20:05:19 / cg" |
|
843 |
! |
|
844 |
||
205 | 845 |
popMenu |
2495 | 846 |
|org theMenu val| |
205 | 847 |
|
848 |
menu notNil ifTrue:[ |
|
1098 | 849 |
theMenu := menu value |
850 |
]. |
|
851 |
||
852 |
theMenu notNil ifTrue:[ |
|
853 |
self turnOffWithoutRedraw. |
|
1035 | 854 |
|
1098 | 855 |
theMenu value labels size == 0 ifTrue:[ |
856 |
^ self |
|
857 |
]. |
|
1035 | 858 |
|
1098 | 859 |
theMenu isView ifTrue:[ |
2464 | 860 |
"/ oldStyle - theMenu is a PopUpMenu / MenuPanel |
1098 | 861 |
theMenu font:font. |
136 | 862 |
|
1098 | 863 |
" |
864 |
adjust the menus width to my current width |
|
865 |
" |
|
2464 | 866 |
menu preferredWidth:(self width). |
205 | 867 |
|
1098 | 868 |
" |
869 |
the popupMenu wants Display coordinates in its showAt: method |
|
870 |
" |
|
2434
a9b9d8f2ab5b
use new translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2398
diff
changeset
|
871 |
org := device translatePoint:0@0 fromView:self toView:nil. |
205 | 872 |
|
1098 | 873 |
theMenu showAt:org "resizing:false" |
874 |
] ifFalse:[ |
|
875 |
"/ newStyle - theMenu is a Menu |
|
2174 | 876 |
val := theMenu startUpOrNil. |
1586
e4e6e12cbd1f
ST-80 compatibility changes.
Claus Gittinger <cg@exept.de>
parents:
1492
diff
changeset
|
877 |
(theMenu isKindOf:PopUpMenu) ifFalse:[ |
e4e6e12cbd1f
ST-80 compatibility changes.
Claus Gittinger <cg@exept.de>
parents:
1492
diff
changeset
|
878 |
"/ sigh - brand new ... |
2174 | 879 |
val notNil ifTrue:[ |
880 |
self sendChangeMessage:changeMsg with:val. |
|
881 |
menuAction notNil ifTrue:[ |
|
882 |
menuAction value:val |
|
883 |
] |
|
2172
411ac4dcf8b4
action invocation for VW compatibility.
Claus Gittinger <cg@exept.de>
parents:
1988
diff
changeset
|
884 |
]. |
1586
e4e6e12cbd1f
ST-80 compatibility changes.
Claus Gittinger <cg@exept.de>
parents:
1492
diff
changeset
|
885 |
]. |
1098 | 886 |
] |
205 | 887 |
]. |
1586
e4e6e12cbd1f
ST-80 compatibility changes.
Claus Gittinger <cg@exept.de>
parents:
1492
diff
changeset
|
888 |
|
2464 | 889 |
"Modified: / 15.11.2001 / 16:53:53 / cg" |
205 | 890 |
! ! |
891 |
||
892 |
!PopUpList methodsFor:'initialization'! |
|
893 |
||
894 |
defaultControllerClass |
|
895 |
^ PopUpListController |
|
896 |
! |
|
897 |
||
898 |
initialize |
|
899 |
super initialize. |
|
900 |
||
901 |
controller beTriggerOnDown. |
|
902 |
controller action:[self popMenu]. |
|
903 |
useIndex := false. |
|
1035 | 904 |
defaultLabel := 'popup'. |
1758 | 905 |
showHandle := true. |
1840 | 906 |
self adjust:#left. |
1758 | 907 |
|
1086
76da3ddb3372
label: only affects the actual label, if there is no model.
Claus Gittinger <cg@exept.de>
parents:
1083
diff
changeset
|
908 |
super label:defaultLabel. |
1063 | 909 |
|
205 | 910 |
listMsg := self class defaultListMessage. |
911 |
||
912 |
onLevel := offLevel. |
|
1063 | 913 |
|
1086
76da3ddb3372
label: only affects the actual label, if there is no model.
Claus Gittinger <cg@exept.de>
parents:
1083
diff
changeset
|
914 |
"Modified: 1.3.1997 / 02:12:55 / cg" |
136 | 915 |
! ! |
916 |
||
20 | 917 |
!PopUpList methodsFor:'private'! |
918 |
||
919 |
computeLabelSize |
|
920 |
"compute the extent needed to hold the label plus the mark" |
|
921 |
||
1052
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
922 |
|mmH mmV savedLogo longest longestWidth labels| |
20 | 923 |
|
2267 | 924 |
(menu isNil |
2268 | 925 |
or:[adjust == #right |
926 |
or:[adjust == #center]]) ifTrue:[ |
|
1098 | 927 |
super computeLabelSize |
20 | 928 |
] ifFalse:[ |
1098 | 929 |
"hack: simulate logo change to longest menu entry" |
20 | 930 |
|
1988 | 931 |
font := font onDevice:device. |
1098 | 932 |
longest := logo. |
933 |
logo isNil ifTrue:[ |
|
934 |
longestWidth := 0 |
|
935 |
] ifFalse:[ |
|
936 |
longestWidth := font widthOf:logo. |
|
937 |
]. |
|
938 |
labels := menu value labels. |
|
939 |
labels notNil ifTrue:[ |
|
940 |
labels do:[:entry | |
|
941 |
|this| |
|
1052
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
942 |
|
1098 | 943 |
this := font widthOf:entry printString. |
944 |
this > longestWidth ifTrue:[ |
|
945 |
longest := entry. |
|
946 |
longestWidth := this |
|
947 |
]. |
|
948 |
]. |
|
949 |
]. |
|
950 |
savedLogo := logo. |
|
951 |
logo := longest printString. |
|
952 |
super computeLabelSize. |
|
953 |
logo := savedLogo. |
|
20 | 954 |
]. |
1772 | 955 |
showHandle ifTrue:[ |
956 |
mmH := device horizontalPixelPerMillimeter. |
|
957 |
mmV := device verticalPixelPerMillimeter. |
|
958 |
labelWidth := labelWidth + hSpace + (mmH * 2.5) rounded + hSpace. |
|
959 |
labelHeight := labelHeight max: (mmV * 2) rounded |
|
960 |
] |
|
327
5cd2a6f4f28e
fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
961 |
|
1772 | 962 |
"Modified: / 6.3.1999 / 21:51:14 / cg" |
121 | 963 |
! |
964 |
||
965 |
createMenuFor:aList |
|
2464 | 966 |
|index| |
967 |
||
1586
e4e6e12cbd1f
ST-80 compatibility changes.
Claus Gittinger <cg@exept.de>
parents:
1492
diff
changeset
|
968 |
(aList isKindOf:Menu) ifTrue:[ |
e4e6e12cbd1f
ST-80 compatibility changes.
Claus Gittinger <cg@exept.de>
parents:
1492
diff
changeset
|
969 |
menu := aList. |
e4e6e12cbd1f
ST-80 compatibility changes.
Claus Gittinger <cg@exept.de>
parents:
1492
diff
changeset
|
970 |
^ self. |
e4e6e12cbd1f
ST-80 compatibility changes.
Claus Gittinger <cg@exept.de>
parents:
1492
diff
changeset
|
971 |
]. |
e4e6e12cbd1f
ST-80 compatibility changes.
Claus Gittinger <cg@exept.de>
parents:
1492
diff
changeset
|
972 |
|
2464 | 973 |
"/ old code (uses old PopUpMenu) |
974 |
"/ menu := PopUpMenu |
|
975 |
"/ labels:aList |
|
976 |
"/ selectors:#select: |
|
977 |
"/ args:(1 to:aList size) |
|
978 |
"/ receiver:self |
|
979 |
"/ for:self. |
|
1586
e4e6e12cbd1f
ST-80 compatibility changes.
Claus Gittinger <cg@exept.de>
parents:
1492
diff
changeset
|
980 |
|
2464 | 981 |
"/ new code - uses (scrollable) MenuPanel |
982 |
menu := MenuPanel labels:aList. |
|
983 |
||
984 |
index := 1. |
|
985 |
menu do:[:el | el value:#select:. el argument:index. index := index + 1. ]. |
|
986 |
menu receiver:self. |
|
987 |
menu font:font. |
|
988 |
menu preferredWidth:(self width). |
|
989 |
||
990 |
"/ end of change |
|
991 |
||
992 |
"Modified: / 15.11.2001 / 16:51:34 / cg" |
|
128 | 993 |
! |
994 |
||
1066
d324041c0aaf
examples and values-handling
Claus Gittinger <cg@exept.de>
parents:
1065
diff
changeset
|
995 |
getListFromModel |
d324041c0aaf
examples and values-handling
Claus Gittinger <cg@exept.de>
parents:
1065
diff
changeset
|
996 |
"if I have a listHolder, ask it for the list; |
d324041c0aaf
examples and values-handling
Claus Gittinger <cg@exept.de>
parents:
1065
diff
changeset
|
997 |
otherwise, if I have a model and a listMsg, get my list from there" |
d324041c0aaf
examples and values-handling
Claus Gittinger <cg@exept.de>
parents:
1065
diff
changeset
|
998 |
|
d324041c0aaf
examples and values-handling
Claus Gittinger <cg@exept.de>
parents:
1065
diff
changeset
|
999 |
listHolder notNil ifTrue:[ |
1586
e4e6e12cbd1f
ST-80 compatibility changes.
Claus Gittinger <cg@exept.de>
parents:
1492
diff
changeset
|
1000 |
self list:listHolder value. |
1587 | 1001 |
"/ model notNil ifTrue:[ |
1002 |
"/ self halt. |
|
1003 |
"/ ] |
|
1066
d324041c0aaf
examples and values-handling
Claus Gittinger <cg@exept.de>
parents:
1065
diff
changeset
|
1004 |
] ifFalse:[ |
d324041c0aaf
examples and values-handling
Claus Gittinger <cg@exept.de>
parents:
1065
diff
changeset
|
1005 |
(listMsg notNil and:[model notNil]) ifTrue:[ |
1067 | 1006 |
(model respondsTo:listMsg) ifTrue:[ |
1007 |
self list:(model perform:listMsg). |
|
1008 |
] |
|
1066
d324041c0aaf
examples and values-handling
Claus Gittinger <cg@exept.de>
parents:
1065
diff
changeset
|
1009 |
]. |
d324041c0aaf
examples and values-handling
Claus Gittinger <cg@exept.de>
parents:
1065
diff
changeset
|
1010 |
] |
d324041c0aaf
examples and values-handling
Claus Gittinger <cg@exept.de>
parents:
1065
diff
changeset
|
1011 |
|
1587 | 1012 |
"Modified: / 19.6.1998 / 01:54:17 / cg" |
1066
d324041c0aaf
examples and values-handling
Claus Gittinger <cg@exept.de>
parents:
1065
diff
changeset
|
1013 |
! |
d324041c0aaf
examples and values-handling
Claus Gittinger <cg@exept.de>
parents:
1065
diff
changeset
|
1014 |
|
d324041c0aaf
examples and values-handling
Claus Gittinger <cg@exept.de>
parents:
1065
diff
changeset
|
1015 |
getSelectionFromModel |
d324041c0aaf
examples and values-handling
Claus Gittinger <cg@exept.de>
parents:
1065
diff
changeset
|
1016 |
"if I have a model and an aspectMsg, get my current value from it" |
d324041c0aaf
examples and values-handling
Claus Gittinger <cg@exept.de>
parents:
1065
diff
changeset
|
1017 |
|
1839
75f77fcf458b
fix: defaultLabel with nil-selection and not useIndex.
Claus Gittinger <cg@exept.de>
parents:
1772
diff
changeset
|
1018 |
|aspect val newLabel| |
1075
662f7e5069fd
allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
1019 |
|
1066
d324041c0aaf
examples and values-handling
Claus Gittinger <cg@exept.de>
parents:
1065
diff
changeset
|
1020 |
(model notNil and:[aspectMsg notNil]) ifTrue:[ |
1075
662f7e5069fd
allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
1021 |
"/ kludge - try #value if aspect is the default and |
662f7e5069fd
allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
1022 |
"/ not understood by the model |
662f7e5069fd
allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
1023 |
"/ this allows a valueHolder to be used, even |
662f7e5069fd
allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
1024 |
"/ if the aspectMessage was not setup correctly. |
662f7e5069fd
allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
1025 |
|
662f7e5069fd
allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
1026 |
aspect := aspectMsg. |
662f7e5069fd
allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
1027 |
aspect == self class defaultAspectMessage ifTrue:[ |
662f7e5069fd
allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
1028 |
(model respondsTo:aspect) ifFalse:[ |
662f7e5069fd
allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
1029 |
aspect := #value |
662f7e5069fd
allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
1030 |
] |
662f7e5069fd
allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
1031 |
]. |
1586
e4e6e12cbd1f
ST-80 compatibility changes.
Claus Gittinger <cg@exept.de>
parents:
1492
diff
changeset
|
1032 |
val := (model perform:aspect). |
e4e6e12cbd1f
ST-80 compatibility changes.
Claus Gittinger <cg@exept.de>
parents:
1492
diff
changeset
|
1033 |
|
e4e6e12cbd1f
ST-80 compatibility changes.
Claus Gittinger <cg@exept.de>
parents:
1492
diff
changeset
|
1034 |
useIndex ifFalse:[ |
1839
75f77fcf458b
fix: defaultLabel with nil-selection and not useIndex.
Claus Gittinger <cg@exept.de>
parents:
1772
diff
changeset
|
1035 |
val isNil ifTrue:[ |
75f77fcf458b
fix: defaultLabel with nil-selection and not useIndex.
Claus Gittinger <cg@exept.de>
parents:
1772
diff
changeset
|
1036 |
newLabel := defaultLabel |
75f77fcf458b
fix: defaultLabel with nil-selection and not useIndex.
Claus Gittinger <cg@exept.de>
parents:
1772
diff
changeset
|
1037 |
] ifFalse:[ |
75f77fcf458b
fix: defaultLabel with nil-selection and not useIndex.
Claus Gittinger <cg@exept.de>
parents:
1772
diff
changeset
|
1038 |
newLabel := val printString. |
75f77fcf458b
fix: defaultLabel with nil-selection and not useIndex.
Claus Gittinger <cg@exept.de>
parents:
1772
diff
changeset
|
1039 |
]. |
75f77fcf458b
fix: defaultLabel with nil-selection and not useIndex.
Claus Gittinger <cg@exept.de>
parents:
1772
diff
changeset
|
1040 |
^ self label:newLabel suppressResize:true. |
1586
e4e6e12cbd1f
ST-80 compatibility changes.
Claus Gittinger <cg@exept.de>
parents:
1492
diff
changeset
|
1041 |
]. |
e4e6e12cbd1f
ST-80 compatibility changes.
Claus Gittinger <cg@exept.de>
parents:
1492
diff
changeset
|
1042 |
self selection:val |
1066
d324041c0aaf
examples and values-handling
Claus Gittinger <cg@exept.de>
parents:
1065
diff
changeset
|
1043 |
]. |
d324041c0aaf
examples and values-handling
Claus Gittinger <cg@exept.de>
parents:
1065
diff
changeset
|
1044 |
|
1586
e4e6e12cbd1f
ST-80 compatibility changes.
Claus Gittinger <cg@exept.de>
parents:
1492
diff
changeset
|
1045 |
"Modified: / 18.6.1998 / 23:54:34 / cg" |
121 | 1046 |
! ! |
1047 |
||
205 | 1048 |
!PopUpList methodsFor:'private-controller access'! |
121 | 1049 |
|
205 | 1050 |
menu |
1051 |
"return the menu component" |
|
125 | 1052 |
|
205 | 1053 |
^ menu |
126 | 1054 |
! ! |
1055 |
||
136 | 1056 |
!PopUpList methodsFor:'queries'! |
1057 |
||
1058 |
preferredExtent |
|
1059 |
"redefined to make certain that the menu is fully defined" |
|
1060 |
||
799 | 1061 |
"/ If I have an explicit preferredExtent .. |
1062 |
||
714
5ff02d2d9fa7
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
1063 |
preferredExtent notNil ifTrue:[ |
1052
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
1064 |
^ preferredExtent |
714
5ff02d2d9fa7
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
1065 |
]. |
5ff02d2d9fa7
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
1066 |
|
136 | 1067 |
menu isNil ifTrue:[ |
1052
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
1068 |
self getListFromModel |
136 | 1069 |
]. |
1070 |
self computeLabelSize. |
|
1071 |
^ super preferredExtent. |
|
714
5ff02d2d9fa7
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
1072 |
|
799 | 1073 |
"Modified: 19.7.1996 / 20:45:16 / cg" |
155 | 1074 |
! |
1075 |
||
1076 |
specClass |
|
1376 | 1077 |
"XXX no longer needed (inherited default works here)" |
1078 |
||
155 | 1079 |
self class == PopUpList ifTrue:[^ PopUpListSpec]. |
1052
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
1080 |
^ super specClass |
1376 | 1081 |
|
1082 |
"Modified: / 31.10.1997 / 19:48:02 / cg" |
|
136 | 1083 |
! ! |
1084 |
||
20 | 1085 |
!PopUpList methodsFor:'user actions'! |
1086 |
||
1069 | 1087 |
select:anIndex |
119 | 1088 |
"this is sent from the popupmenu when an entry was selected" |
1089 |
||
1368 | 1090 |
|value menuLabels label chg| |
77 | 1091 |
|
1368 | 1092 |
menuLabels := menu labels. |
1069 | 1093 |
values isNil ifTrue:[ |
1094 |
value := anIndex. |
|
1095 |
useIndex ifFalse:[ |
|
1368 | 1096 |
value := menuLabels at:anIndex. |
1069 | 1097 |
] |
1098 |
] ifFalse:[ |
|
1099 |
value := values at:anIndex |
|
1100 |
]. |
|
1101 |
||
1142
406d3829ddcc
always change my label on select:;
Claus Gittinger <cg@exept.de>
parents:
1098
diff
changeset
|
1102 |
"/ model isNil ifTrue:[ |
1066
d324041c0aaf
examples and values-handling
Claus Gittinger <cg@exept.de>
parents:
1065
diff
changeset
|
1103 |
"/ if there is a model, |
d324041c0aaf
examples and values-handling
Claus Gittinger <cg@exept.de>
parents:
1065
diff
changeset
|
1104 |
"/ the update will change my logo ... |
d324041c0aaf
examples and values-handling
Claus Gittinger <cg@exept.de>
parents:
1065
diff
changeset
|
1105 |
|
1368 | 1106 |
"/ self sizeFixed:true. |
1107 |
label := menuLabels at:anIndex. |
|
1108 |
super label:label printString suppressResize:true. |
|
1142
406d3829ddcc
always change my label on select:;
Claus Gittinger <cg@exept.de>
parents:
1098
diff
changeset
|
1109 |
"/ ]. |
327
5cd2a6f4f28e
fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
1110 |
|
1075
662f7e5069fd
allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
1111 |
(model notNil and:[changeMsg notNil]) ifTrue:[ |
662f7e5069fd
allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
1112 |
"/ |
662f7e5069fd
allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
1113 |
"/ ST-80 way of doing it |
662f7e5069fd
allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
1114 |
"/ tell my model - if any |
662f7e5069fd
allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
1115 |
"/ |
662f7e5069fd
allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
1116 |
|
662f7e5069fd
allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
1117 |
"/ kludge - try #value: if changeMsg is the default and |
662f7e5069fd
allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
1118 |
"/ not understood by the model |
662f7e5069fd
allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
1119 |
"/ this allows a valueHolder to be used, even |
662f7e5069fd
allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
1120 |
"/ if the aspectMessage was not setup correctly. |
662f7e5069fd
allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
1121 |
|
662f7e5069fd
allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
1122 |
chg := changeMsg. |
662f7e5069fd
allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
1123 |
chg == self class defaultChangeMessage ifTrue:[ |
662f7e5069fd
allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
1124 |
(model respondsTo:chg) ifFalse:[ |
1076 | 1125 |
chg := #value: |
1075
662f7e5069fd
allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
1126 |
] |
662f7e5069fd
allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
1127 |
]. |
662f7e5069fd
allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
1128 |
|
662f7e5069fd
allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
1129 |
self sendChangeMessage:chg with:value. |
662f7e5069fd
allow use of a valueHolder, without setting change/aspect
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
1130 |
]. |
1052
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
1131 |
|
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
1132 |
"/ |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
1133 |
"/ ST/X action blocks |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
1134 |
"/ |
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
1135 |
menuAction notNil ifTrue:[ |
1063 | 1136 |
menuAction value:value. |
1052
59f182d1304f
added list- and selectionHolders
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
1137 |
]. |
327
5cd2a6f4f28e
fixes to allow use of ListEntries (and an example)
Claus Gittinger <cg@exept.de>
parents:
205
diff
changeset
|
1138 |
|
1369 | 1139 |
"Modified: / 29.10.1997 / 21:08:50 / cg" |
20 | 1140 |
! ! |
121 | 1141 |
|
998 | 1142 |
!PopUpList class methodsFor:'documentation'! |
121 | 1143 |
|
205 | 1144 |
version |
2497
e3e1a719e31d
support etched color (win32 style)
Claus Gittinger <cg@exept.de>
parents:
2495
diff
changeset
|
1145 |
^ '$Header: /cvs/stx/stx/libwidg/PopUpList.st,v 1.77 2001-12-08 13:29:15 cg Exp $' |
121 | 1146 |
! ! |