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