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