author | Claus Gittinger <cg@exept.de> |
Thu, 09 Nov 2017 20:09:30 +0100 | |
changeset 6225 | 0122e4e6c587 |
parent 6110 | d4af8f1840d9 |
child 6259 | ebe33a983e14 |
permissions | -rw-r--r-- |
133 | 1 |
" |
2 |
COPYRIGHT (c) 1994 by Claus Gittinger |
|
3 |
All Rights Reserved |
|
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 |
" |
|
2251 | 12 |
"{ Package: 'stx:libwidg' }" |
13 |
||
5871 | 14 |
"{ NameSpace: Smalltalk }" |
15 |
||
129 | 16 |
ValueHolder subclass:#SelectionInList |
359 | 17 |
instanceVariableNames:'listHolder selectionIndexHolder' |
18 |
classVariableNames:'' |
|
19 |
poolDictionaries:'' |
|
20 |
category:'Interface-Support-Models' |
|
114 | 21 |
! |
22 |
||
133 | 23 |
!SelectionInList class methodsFor:'documentation'! |
24 |
||
25 |
copyright |
|
26 |
" |
|
27 |
COPYRIGHT (c) 1994 by Claus Gittinger |
|
28 |
All Rights Reserved |
|
29 |
||
30 |
This software is furnished under a license and may be used |
|
31 |
only in accordance with the terms of that license and with the |
|
32 |
inclusion of the above copyright notice. This software may not |
|
33 |
be provided or otherwise made available to, or used by, any |
|
34 |
other person. No title to or ownership of the software is |
|
35 |
hereby transferred. |
|
36 |
" |
|
37 |
! |
|
38 |
||
39 |
documentation |
|
40 |
" |
|
41 |
Instances of SelectionInList can be used as model for |
|
42 |
a SelectionInListView or a PopUpList. |
|
43 |
They keep two values: a list value and a selection value; |
|
44 |
both are referred to via valueHolders. |
|
45 |
||
577 | 46 |
If any of those two changes, the selectionInList notifies its |
47 |
dependents via a change notification, |
|
48 |
using #list or #selectionIndex as update aspect respectively. |
|
49 |
||
50 |
A popupList also knows how to deal with a selectionInList model; |
|
133 | 51 |
this makes it possible to have popupLists be somewhat exchangable |
52 |
with selectionInListViews. |
|
576 | 53 |
|
577 | 54 |
SelectionInLists only support a single selection within the list; |
55 |
use MultiSelectionInList, if multiple selections are needed. |
|
56 |
||
57 |
[instance variables:] |
|
58 |
listHolder <ValueHolder> holds the list |
|
59 |
selectionIndexHolder <ValueHolder> holdes the selectionIndex |
|
60 |
||
61 |
||
576 | 62 |
[see also:] |
577 | 63 |
SelectionInListView PopUpList |
64 |
MultiSelectionInList Model ValueHolder |
|
583 | 65 |
|
66 |
[author:] |
|
67 |
Claus Gittinger |
|
133 | 68 |
" |
69 |
! |
|
70 |
||
71 |
examples |
|
72 |
" |
|
576 | 73 |
basic setup using a selectionInList as model of a selectionInListView: |
590 | 74 |
[exBegin] |
133 | 75 |
|m v| |
76 |
||
77 |
m := SelectionInList new. |
|
78 |
m list:#('one' 'two' 'three' 'four'). |
|
79 |
m selectionIndex:2. |
|
80 |
||
81 |
v := SelectionInListView on:m. |
|
82 |
v open |
|
590 | 83 |
[exEnd] |
133 | 84 |
|
576 | 85 |
|
86 |
similar, a selectionInList as model of a popUpList: |
|
590 | 87 |
[exBegin] |
576 | 88 |
|m v| |
89 |
||
90 |
m := SelectionInList new. |
|
91 |
m list:#('one' 'two' 'three' 'four'). |
|
92 |
m selectionIndex:2. |
|
93 |
||
94 |
v := PopUpList on:m. |
|
95 |
v open |
|
590 | 96 |
[exEnd] |
576 | 97 |
|
98 |
||
99 |
using a combination-instance creation method: |
|
590 | 100 |
[exBegin] |
576 | 101 |
|m v| |
102 |
||
103 |
m := SelectionInList |
|
104 |
with:#('one' 'two' 'three' 'four') |
|
105 |
initialSelection:2. |
|
106 |
||
107 |
v := PopUpList on:m. |
|
108 |
v open |
|
590 | 109 |
[exEnd] |
576 | 110 |
|
111 |
||
112 |
two different views on the same selectionInList model: |
|
590 | 113 |
[exBegin] |
576 | 114 |
|m v1 v2| |
115 |
||
116 |
m := SelectionInList new. |
|
117 |
m list:#('one' 'two' 'three' 'four'). |
|
118 |
m selectionIndex:2. |
|
119 |
||
120 |
v1 := PopUpList on:m. |
|
121 |
v1 open. |
|
122 |
||
123 |
v2 := SelectionInListView on:m. |
|
124 |
v2 open |
|
590 | 125 |
[exEnd] |
576 | 126 |
|
127 |
||
133 | 128 |
two views on the same selectionInList: |
129 |
and a button, which adds an item to the list. |
|
590 | 130 |
[exBegin] |
133 | 131 |
|m v1 v2 b numItems| |
132 |
||
133 |
numItems := 4. |
|
134 |
||
135 |
m := SelectionInList new. |
|
136 |
m list:((1 to:numItems) collect:[:i | i printString]). |
|
137 |
m selectionIndex:2. |
|
138 |
||
139 |
v1 := ScrollableView forView:(SelectionInListView on:m). |
|
140 |
v1 open. |
|
141 |
||
142 |
v2 := ScrollableView forView:(SelectionInListView on:m). |
|
143 |
v2 open. |
|
144 |
||
145 |
b := Button label:'add item'. |
|
146 |
b action:[numItems := numItems + 1. |
|
576 | 147 |
m list:((1 to:numItems) collect:[:i | i printString]). |
148 |
]. |
|
133 | 149 |
b open |
590 | 150 |
[exEnd] |
133 | 151 |
" |
152 |
! ! |
|
153 |
||
114 | 154 |
!SelectionInList class methodsFor:'instance creation'! |
155 |
||
576 | 156 |
with:aList |
157 |
"return a new instance holding aList" |
|
158 |
||
1541 | 159 |
^ self new listHolder:(ValueHolder with:aList) |
576 | 160 |
|
1541 | 161 |
"Modified: / 21.5.1998 / 03:17:16 / cg" |
576 | 162 |
! |
163 |
||
164 |
with:aList initialSelection:index |
|
165 |
"return a new instance holding aList and initially selecting |
|
166 |
the item at index." |
|
167 |
||
168 |
^ (self with:aList) |
|
1541 | 169 |
selectionIndexHolder:(ValueHolder with:index) |
576 | 170 |
|
1541 | 171 |
"Created: / 24.4.1996 / 08:47:33 / cg" |
172 |
"Modified: / 21.5.1998 / 03:17:31 / cg" |
|
114 | 173 |
! ! |
174 |
||
200 | 175 |
!SelectionInList methodsFor:'accessing-holders'! |
176 |
||
177 |
listHolder |
|
576 | 178 |
"return the valueHolder which holds the list" |
200 | 179 |
|
180 |
^ listHolder |
|
576 | 181 |
|
182 |
"Modified: 24.4.1996 / 08:39:44 / cg" |
|
200 | 183 |
! |
184 |
||
185 |
listHolder:aValueHolder |
|
576 | 186 |
"set the valueHolder which holds the list. |
200 | 187 |
Q: should we forward a change-notification ?" |
188 |
||
189 |
listHolder notNil ifTrue:[ |
|
576 | 190 |
listHolder removeDependent:self |
200 | 191 |
]. |
192 |
listHolder := aValueHolder. |
|
193 |
listHolder addDependent:self |
|
576 | 194 |
|
195 |
"Modified: 24.4.1996 / 08:39:59 / cg" |
|
200 | 196 |
! |
114 | 197 |
|
200 | 198 |
selectionHolder |
576 | 199 |
"return someone holding on the selection itself (not the index). |
200 |
Since we have no one, create an adapter, to get up-to-date values." |
|
200 | 201 |
|
202 |
^ AspectAdaptor |
|
544 | 203 |
subject:self |
564
0739243fcc1c
zeroIndex stuff / ST-80 compatible 0 for empty selection
Claus Gittinger <cg@exept.de>
parents:
544
diff
changeset
|
204 |
sendsUpdates:false |
544 | 205 |
accessWith:#selection |
206 |
assignWith:#'selection:' |
|
207 |
aspect:#selectionIndex |
|
208 |
||
576 | 209 |
"Modified: 24.4.1996 / 08:40:19 / cg" |
200 | 210 |
! |
211 |
||
212 |
selectionIndexHolder |
|
576 | 213 |
"return the valueHolder which holds the index" |
200 | 214 |
|
215 |
^ selectionIndexHolder |
|
576 | 216 |
|
217 |
"Modified: 24.4.1996 / 08:40:31 / cg" |
|
200 | 218 |
! |
219 |
||
220 |
selectionIndexHolder:aValueHolder |
|
576 | 221 |
"set the valueHolder which holdes the index. |
200 | 222 |
Q: should we forward a change-notification ?" |
223 |
||
224 |
selectionIndexHolder notNil ifTrue:[ |
|
576 | 225 |
selectionIndexHolder removeDependent:self |
200 | 226 |
]. |
227 |
selectionIndexHolder := aValueHolder. |
|
228 |
selectionIndexHolder addDependent:self |
|
576 | 229 |
|
230 |
"Modified: 24.4.1996 / 08:40:42 / cg" |
|
114 | 231 |
! ! |
232 |
||
133 | 233 |
!SelectionInList methodsFor:'accessing-values'! |
114 | 234 |
|
129 | 235 |
list |
5871 | 236 |
"return the list - that's the thingy held by the listHolder" |
576 | 237 |
|
129 | 238 |
^ listHolder value |
576 | 239 |
|
240 |
"Modified: 24.4.1996 / 08:41:05 / cg" |
|
129 | 241 |
! |
242 |
||
133 | 243 |
list:aCollection |
5871 | 244 |
"set the list - that's the thingy held by the listHolder" |
577 | 245 |
|
1436
72e392844594
send change notification if same list is assigned
Claus Gittinger <cg@exept.de>
parents:
1412
diff
changeset
|
246 |
aCollection == listHolder value ifTrue:[ |
72e392844594
send change notification if same list is assigned
Claus Gittinger <cg@exept.de>
parents:
1412
diff
changeset
|
247 |
"/ same value set again - send change notification |
1440 | 248 |
"/ manually (valueHolder does not ...) |
249 |
listHolder changed. |
|
2281
40177aeb765c
change notifications when changing the listHolder
Claus Gittinger <cg@exept.de>
parents:
2251
diff
changeset
|
250 |
] ifFalse:[ |
2445
311a83c7d4ee
update fix for SelectionInList/MultiSelectionInList models
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
251 |
aCollection isList ifTrue:[ |
311a83c7d4ee
update fix for SelectionInList/MultiSelectionInList models
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
252 |
self listHolder:aCollection. |
311a83c7d4ee
update fix for SelectionInList/MultiSelectionInList models
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
253 |
listHolder changed. |
311a83c7d4ee
update fix for SelectionInList/MultiSelectionInList models
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
254 |
] ifFalse:[ |
3541
73dd9da193e7
care for List objects in list:
Claus Gittinger <cg@exept.de>
parents:
2748
diff
changeset
|
255 |
listHolder isList ifTrue:[ |
73dd9da193e7
care for List objects in list:
Claus Gittinger <cg@exept.de>
parents:
2748
diff
changeset
|
256 |
listHolder contents:aCollection. |
73dd9da193e7
care for List objects in list:
Claus Gittinger <cg@exept.de>
parents:
2748
diff
changeset
|
257 |
] ifFalse:[ |
73dd9da193e7
care for List objects in list:
Claus Gittinger <cg@exept.de>
parents:
2748
diff
changeset
|
258 |
listHolder value:aCollection. |
73dd9da193e7
care for List objects in list:
Claus Gittinger <cg@exept.de>
parents:
2748
diff
changeset
|
259 |
] |
2445
311a83c7d4ee
update fix for SelectionInList/MultiSelectionInList models
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
260 |
] |
311a83c7d4ee
update fix for SelectionInList/MultiSelectionInList models
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
261 |
"/ listHolder value:aCollection. |
1436
72e392844594
send change notification if same list is assigned
Claus Gittinger <cg@exept.de>
parents:
1412
diff
changeset
|
262 |
]. |
577 | 263 |
|
1440 | 264 |
"Modified: / 2.2.1998 / 13:05:56 / cg" |
133 | 265 |
! |
266 |
||
267 |
selection |
|
577 | 268 |
"return the selections value (i.e. the entry in the list - not its index). |
269 |
If nothing is selected, nil is returned." |
|
129 | 270 |
|
271 |
|idx| |
|
272 |
||
273 |
idx := self selectionIndex. |
|
274 |
(idx isNil or:[idx == 0]) ifTrue:[^ nil]. |
|
275 |
^ self list at:idx |
|
576 | 276 |
|
577 | 277 |
"Modified: 24.4.1996 / 08:53:23 / cg" |
114 | 278 |
! |
279 |
||
133 | 280 |
selection:anObject |
281 |
"set the selection to be anObject. |
|
282 |
If anObject is not in the list, the selection is cleared" |
|
283 |
||
284 |
^ self selectionIndex:(self list indexOf:anObject ifAbsent:0) |
|
200 | 285 |
! |
286 |
||
576 | 287 |
selectionIndex |
5871 | 288 |
"return the selections index (1..). |
289 |
That's the thingy held by the indexHolder. |
|
577 | 290 |
For ST-80 compatibility, 0 is returned if nothing is selected." |
576 | 291 |
|
200 | 292 |
^ selectionIndexHolder value |
576 | 293 |
|
577 | 294 |
"Modified: 24.4.1996 / 08:53:45 / cg" |
200 | 295 |
! |
296 |
||
576 | 297 |
selectionIndex:newIndex |
298 |
"set the selectionIndex" |
|
299 |
||
200 | 300 |
selectionIndexHolder value ~= newIndex ifTrue:[ |
576 | 301 |
selectionIndexHolder value:newIndex |
200 | 302 |
] |
576 | 303 |
|
304 |
"Modified: 24.4.1996 / 08:42:04 / cg" |
|
133 | 305 |
! ! |
306 |
||
307 |
!SelectionInList methodsFor:'change & update'! |
|
308 |
||
309 |
update:something with:aParameter from:changedObject |
|
310 |
"whenever one of my holders value changes, |
|
311 |
tell my dependents about this" |
|
312 |
||
564
0739243fcc1c
zeroIndex stuff / ST-80 compatible 0 for empty selection
Claus Gittinger <cg@exept.de>
parents:
544
diff
changeset
|
313 |
|oldSelection| |
0739243fcc1c
zeroIndex stuff / ST-80 compatible 0 for empty selection
Claus Gittinger <cg@exept.de>
parents:
544
diff
changeset
|
314 |
|
133 | 315 |
changedObject == selectionIndexHolder ifTrue:[ |
526
8203430fbadd
oops - clearing selection was wrong in MultiSelectionInList
ca
parents:
359
diff
changeset
|
316 |
self changed:#selectionIndex |
133 | 317 |
] ifFalse:[ |
526
8203430fbadd
oops - clearing selection was wrong in MultiSelectionInList
ca
parents:
359
diff
changeset
|
318 |
changedObject == listHolder ifTrue:[ |
2445
311a83c7d4ee
update fix for SelectionInList/MultiSelectionInList models
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
319 |
(something == #value |
311a83c7d4ee
update fix for SelectionInList/MultiSelectionInList models
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
320 |
or:[ listHolder isList ]) |
311a83c7d4ee
update fix for SelectionInList/MultiSelectionInList models
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
321 |
ifTrue:[ |
564
0739243fcc1c
zeroIndex stuff / ST-80 compatible 0 for empty selection
Claus Gittinger <cg@exept.de>
parents:
544
diff
changeset
|
322 |
oldSelection := selectionIndexHolder value. |
0739243fcc1c
zeroIndex stuff / ST-80 compatible 0 for empty selection
Claus Gittinger <cg@exept.de>
parents:
544
diff
changeset
|
323 |
self clearSelection. "/ clears without update |
526
8203430fbadd
oops - clearing selection was wrong in MultiSelectionInList
ca
parents:
359
diff
changeset
|
324 |
self changed:#list. |
564
0739243fcc1c
zeroIndex stuff / ST-80 compatible 0 for empty selection
Claus Gittinger <cg@exept.de>
parents:
544
diff
changeset
|
325 |
oldSelection ~= (selectionIndexHolder value) ifTrue:[ |
0739243fcc1c
zeroIndex stuff / ST-80 compatible 0 for empty selection
Claus Gittinger <cg@exept.de>
parents:
544
diff
changeset
|
326 |
selectionIndexHolder changed:#value |
0739243fcc1c
zeroIndex stuff / ST-80 compatible 0 for empty selection
Claus Gittinger <cg@exept.de>
parents:
544
diff
changeset
|
327 |
] |
526
8203430fbadd
oops - clearing selection was wrong in MultiSelectionInList
ca
parents:
359
diff
changeset
|
328 |
] |
8203430fbadd
oops - clearing selection was wrong in MultiSelectionInList
ca
parents:
359
diff
changeset
|
329 |
] |
133 | 330 |
] |
564
0739243fcc1c
zeroIndex stuff / ST-80 compatible 0 for empty selection
Claus Gittinger <cg@exept.de>
parents:
544
diff
changeset
|
331 |
|
0739243fcc1c
zeroIndex stuff / ST-80 compatible 0 for empty selection
Claus Gittinger <cg@exept.de>
parents:
544
diff
changeset
|
332 |
"Modified: 20.4.1996 / 13:08:32 / cg" |
133 | 333 |
! ! |
334 |
||
200 | 335 |
!SelectionInList methodsFor:'initialization'! |
336 |
||
337 |
initialize |
|
576 | 338 |
"initialize; create the valueHolders for the index and the list" |
339 |
||
1541 | 340 |
self listHolder:(ValueHolder with:List new). |
341 |
self selectionIndexHolder:(ValueHolder with:self zeroIndex). |
|
564
0739243fcc1c
zeroIndex stuff / ST-80 compatible 0 for empty selection
Claus Gittinger <cg@exept.de>
parents:
544
diff
changeset
|
342 |
|
1541 | 343 |
"Modified: / 21.5.1998 / 03:17:56 / cg" |
200 | 344 |
! ! |
345 |
||
2748 | 346 |
!SelectionInList methodsFor:'obsolete-backward compatibility'! |
133 | 347 |
|
348 |
index |
|
576 | 349 |
"return the selections index. |
350 |
This is an OBSOLETE backward compatibility interface" |
|
133 | 351 |
|
2368 | 352 |
<resource:#obsolete> |
353 |
||
133 | 354 |
self obsoleteMethodWarning:'use #selectionIndex'. |
355 |
^ self selectionIndex |
|
576 | 356 |
|
357 |
"Modified: 24.4.1996 / 08:43:10 / cg" |
|
114 | 358 |
! |
359 |
||
129 | 360 |
index:newIndex |
576 | 361 |
"set the selections index. |
362 |
This is an OBSOLETE backward compatibility interface" |
|
129 | 363 |
|
2368 | 364 |
<resource:#obsolete> |
365 |
||
133 | 366 |
self obsoleteMethodWarning:'use #selectionIndex:'. |
129 | 367 |
^ self selectionIndex:newIndex |
576 | 368 |
|
369 |
"Modified: 24.4.1996 / 08:43:06 / cg" |
|
129 | 370 |
! |
371 |
||
133 | 372 |
indexHolder |
576 | 373 |
"return the valueHolder of the selections index. |
374 |
This is an OBSOLETE backward compatibility interface" |
|
133 | 375 |
|
2368 | 376 |
<resource:#obsolete> |
377 |
||
133 | 378 |
self obsoleteMethodWarning:'use #selectionIndexHolder'. |
379 |
^ self selectionIndexHolder |
|
576 | 380 |
|
381 |
"Modified: 24.4.1996 / 08:43:35 / cg" |
|
129 | 382 |
! |
383 |
||
133 | 384 |
indexHolder:aValueHolder |
576 | 385 |
"set the valueHolder of the selections index. |
386 |
This is an OBSOLETE backward compatibility interface" |
|
133 | 387 |
|
2368 | 388 |
<resource:#obsolete> |
389 |
||
133 | 390 |
self obsoleteMethodWarning:'use #selectionIndexHolder:'. |
391 |
^ self selectionIndexHolder:aValueHolder |
|
576 | 392 |
|
393 |
"Modified: 24.4.1996 / 08:43:43 / cg" |
|
133 | 394 |
! ! |
395 |
||
1032 | 396 |
!SelectionInList methodsFor:'printing & storing'! |
397 |
||
4442
7c67a011c29b
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
3541
diff
changeset
|
398 |
displayOn:aGCOrStream |
7c67a011c29b
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
3541
diff
changeset
|
399 |
"Compatibility |
6110 | 400 |
append a printed desription on some stream (Dolphin, Squeak) |
4442
7c67a011c29b
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
3541
diff
changeset
|
401 |
OR: |
6110 | 402 |
display the receiver in a graphicsContext at 0@0 (ST80). |
4442
7c67a011c29b
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
3541
diff
changeset
|
403 |
This method allows for any object to be displayed in some view |
7c67a011c29b
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
3541
diff
changeset
|
404 |
(although the fallBack is to display its printString ...)" |
1332 | 405 |
|
4442
7c67a011c29b
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
3541
diff
changeset
|
406 |
"/ what a kludge - Dolphin and Squeak mean: printOn: a stream; |
6110 | 407 |
"/ old ST80 means: draw-yourself on a GC. |
4442
7c67a011c29b
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
3541
diff
changeset
|
408 |
aGCOrStream isStream ifFalse:[ |
7c67a011c29b
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
3541
diff
changeset
|
409 |
^ super displayOn:aGCOrStream. |
7c67a011c29b
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
3541
diff
changeset
|
410 |
]. |
1032 | 411 |
|
4442
7c67a011c29b
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
3541
diff
changeset
|
412 |
aGCOrStream |
7c67a011c29b
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
3541
diff
changeset
|
413 |
nextPutAll:self class name; |
7c67a011c29b
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
3541
diff
changeset
|
414 |
nextPut:$(. |
7c67a011c29b
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
3541
diff
changeset
|
415 |
self selectionIndex displayOn:aGCOrStream. |
7c67a011c29b
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
3541
diff
changeset
|
416 |
aGCOrStream nextPut:$) |
6110 | 417 |
|
418 |
"Modified (comment): / 22-02-2017 / 16:52:55 / cg" |
|
1032 | 419 |
! ! |
420 |
||
526
8203430fbadd
oops - clearing selection was wrong in MultiSelectionInList
ca
parents:
359
diff
changeset
|
421 |
!SelectionInList methodsFor:'private'! |
8203430fbadd
oops - clearing selection was wrong in MultiSelectionInList
ca
parents:
359
diff
changeset
|
422 |
|
8203430fbadd
oops - clearing selection was wrong in MultiSelectionInList
ca
parents:
359
diff
changeset
|
423 |
clearSelection |
576 | 424 |
"clear the selection. |
425 |
For ST-80 compatibility, a non-selection has an index of 0 |
|
426 |
although, nil sounds more natural to me ... (sigh)" |
|
427 |
||
564
0739243fcc1c
zeroIndex stuff / ST-80 compatible 0 for empty selection
Claus Gittinger <cg@exept.de>
parents:
544
diff
changeset
|
428 |
selectionIndexHolder setValue:self zeroIndex. |
0739243fcc1c
zeroIndex stuff / ST-80 compatible 0 for empty selection
Claus Gittinger <cg@exept.de>
parents:
544
diff
changeset
|
429 |
|
576 | 430 |
"Modified: 24.4.1996 / 08:44:37 / cg" |
564
0739243fcc1c
zeroIndex stuff / ST-80 compatible 0 for empty selection
Claus Gittinger <cg@exept.de>
parents:
544
diff
changeset
|
431 |
! ! |
0739243fcc1c
zeroIndex stuff / ST-80 compatible 0 for empty selection
Claus Gittinger <cg@exept.de>
parents:
544
diff
changeset
|
432 |
|
0739243fcc1c
zeroIndex stuff / ST-80 compatible 0 for empty selection
Claus Gittinger <cg@exept.de>
parents:
544
diff
changeset
|
433 |
!SelectionInList methodsFor:'queries'! |
0739243fcc1c
zeroIndex stuff / ST-80 compatible 0 for empty selection
Claus Gittinger <cg@exept.de>
parents:
544
diff
changeset
|
434 |
|
1412 | 435 |
hasSelection |
436 |
"return true, if there is a selection |
|
437 |
" |
|
438 |
^ self numberOfSelections ~~ 0 |
|
439 |
! |
|
440 |
||
441 |
numberOfSelections |
|
442 |
"return the number of selected entries |
|
443 |
" |
|
444 |
|s| |
|
445 |
||
446 |
s:= selectionIndexHolder value. |
|
447 |
^ (s ~~ 0 and:[s notNil]) ifTrue:[1] ifFalse:[0] |
|
448 |
! |
|
449 |
||
564
0739243fcc1c
zeroIndex stuff / ST-80 compatible 0 for empty selection
Claus Gittinger <cg@exept.de>
parents:
544
diff
changeset
|
450 |
zeroIndex |
0739243fcc1c
zeroIndex stuff / ST-80 compatible 0 for empty selection
Claus Gittinger <cg@exept.de>
parents:
544
diff
changeset
|
451 |
"return the selections index returned when nothing |
576 | 452 |
is selected. This method is provided to allow applications |
453 |
to deal transparently with SelectionInList models AND with |
|
454 |
MultSelectionInList models, which use different no-selection values. |
|
455 |
Although I would prefer nil, ST-80 uses 0 to represent `no-selection'. (sigh)" |
|
564
0739243fcc1c
zeroIndex stuff / ST-80 compatible 0 for empty selection
Claus Gittinger <cg@exept.de>
parents:
544
diff
changeset
|
456 |
|
0739243fcc1c
zeroIndex stuff / ST-80 compatible 0 for empty selection
Claus Gittinger <cg@exept.de>
parents:
544
diff
changeset
|
457 |
^ 0 |
0739243fcc1c
zeroIndex stuff / ST-80 compatible 0 for empty selection
Claus Gittinger <cg@exept.de>
parents:
544
diff
changeset
|
458 |
|
0739243fcc1c
zeroIndex stuff / ST-80 compatible 0 for empty selection
Claus Gittinger <cg@exept.de>
parents:
544
diff
changeset
|
459 |
"Created: 20.4.1996 / 13:10:53 / cg" |
576 | 460 |
"Modified: 24.4.1996 / 08:46:18 / cg" |
526
8203430fbadd
oops - clearing selection was wrong in MultiSelectionInList
ca
parents:
359
diff
changeset
|
461 |
! ! |
8203430fbadd
oops - clearing selection was wrong in MultiSelectionInList
ca
parents:
359
diff
changeset
|
462 |
|
204 | 463 |
!SelectionInList class methodsFor:'documentation'! |
464 |
||
465 |
version |
|
5871 | 466 |
^ '$Header$' |
204 | 467 |
! ! |
5871 | 468 |