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