0
|
1 |
"
|
5
|
2 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
59
|
3 |
All Rights Reserved
|
0
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
|
12 |
|
|
13 |
ListView subclass:#SelectionInListView
|
|
14 |
instanceVariableNames:'selection actionBlock enabled
|
59
|
15 |
hilightFgColor hilightBgColor
|
|
16 |
halfIntensityFgColor
|
|
17 |
doubleClickActionBlock
|
|
18 |
selectConditionBlock
|
|
19 |
listAttributes multipleSelectOk clickLine
|
|
20 |
listSymbol initialSelectionSymbol printItems oneItem
|
|
21 |
hilightLevel hilightFrameColor ignoreReselect
|
63
|
22 |
arrowLevel smallArrow keyActionStyle toggleSelect
|
|
23 |
strikeOut iSearchString'
|
59
|
24 |
classVariableNames:'RightArrowShadowForm RightArrowLightForm RightArrowForm
|
|
25 |
SmallRightArrowShadowForm SmallRightArrowLightForm
|
|
26 |
DefaultForegroundColor DefaultBackgroundColor
|
|
27 |
DefaultHilightForegroundColor DefaultHilightBackgroundColor
|
|
28 |
DefaultHilightFrameColor DefaultHilightLevel DefaultFont
|
|
29 |
DefaultRightArrowStyle DefaultRightArrowLevel
|
|
30 |
DefaultDisabledForegroundColor
|
|
31 |
DefaultShadowColor DefaultLightColor'
|
0
|
32 |
poolDictionaries:''
|
|
33 |
category:'Views-Text'
|
|
34 |
!
|
|
35 |
|
|
36 |
SelectionInListView comment:'
|
5
|
37 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
59
|
38 |
All Rights Reserved
|
38
|
39 |
|
77
|
40 |
$Header: /cvs/stx/stx/libwidg/SelectionInListView.st,v 1.16 1995-02-06 00:53:18 claus Exp $
|
7
|
41 |
'!
|
0
|
42 |
|
7
|
43 |
!SelectionInListView class methodsFor:'documentation'!
|
|
44 |
|
38
|
45 |
copyright
|
|
46 |
"
|
|
47 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
59
|
48 |
All Rights Reserved
|
38
|
49 |
|
|
50 |
This software is furnished under a license and may be used
|
|
51 |
only in accordance with the terms of that license and with the
|
|
52 |
inclusion of the above copyright notice. This software may not
|
|
53 |
be provided or otherwise made available to, or used by, any
|
|
54 |
other person. No title to or ownership of the software is
|
|
55 |
hereby transferred.
|
|
56 |
"
|
|
57 |
!
|
|
58 |
|
|
59 |
version
|
|
60 |
"
|
77
|
61 |
$Header: /cvs/stx/stx/libwidg/SelectionInListView.st,v 1.16 1995-02-06 00:53:18 claus Exp $
|
38
|
62 |
"
|
|
63 |
!
|
|
64 |
|
7
|
65 |
documentation
|
|
66 |
"
|
31
|
67 |
this one is a ListView with a selected line (which is shown highlighted)
|
38
|
68 |
If multipleSelectionsOk is true, it is also allowed to shift-click multiple
|
|
69 |
entries.
|
63
|
70 |
If toggleSelect is true, clicking toggles (i.e. click on a seleted item
|
|
71 |
will deselect).
|
31
|
72 |
|
38
|
73 |
Whenever the selection changes, an action-block is evaluated, passing the
|
|
74 |
current selection as argument.
|
|
75 |
Currently, the selection can be nil, aNumber or a collection of numbers;
|
|
76 |
this will change to be either nil or a collection, making selection handling
|
70
|
77 |
easier in the future. (this stupid behavior is due to the multiple
|
|
78 |
select feature being added later - the first implementation used to support
|
|
79 |
only single selections).
|
|
80 |
|
59
|
81 |
The actionBlock is called with the current selection (single number or
|
|
82 |
collection of numbers) as argument.
|
|
83 |
|
|
84 |
Also, to support ST-80 MVC-style use, the model (if nonNil) is notified
|
|
85 |
by the change mechanism (performs changeSymbol).
|
|
86 |
|
60
|
87 |
Before actually adding entries to the the selection, a checkBlock (if non-nil) is evaluated
|
|
88 |
passing the number of the entry whch is about to be selected as argument.
|
|
89 |
The select change operation is only done if this returns true. This allows
|
59
|
90 |
interception of select, for example to query the user if he/she wants to save
|
60
|
91 |
the old contents before (see uses in SystemBrowser and FileBrowser), or to
|
|
92 |
disable individual entries.
|
31
|
93 |
|
38
|
94 |
It is also possible to select entries with the keyboard; use the cursor up/
|
|
95 |
down keys to select prev/next, Home- and End-keys to select first/last.
|
|
96 |
Use the return key to apply the double-click-action to the current selection.
|
|
97 |
Also, alphabetic keys will select the next entry starting with that key.
|
|
98 |
|
|
99 |
The keyboard behavior can be further controlled with the keyActionStyle
|
|
100 |
instance variable (see SelectionInListView>>keyActionStyle:).
|
|
101 |
|
59
|
102 |
Finally, ignoreReselect controls if pressing on an already selected item
|
|
103 |
triggers the action or not. For some applications it is useful to allow
|
|
104 |
reselects (for example, the SystemBrowsers method-list updates the
|
|
105 |
source code in this case).
|
38
|
106 |
|
60
|
107 |
Currently, some limited form of line attributes are supported. These
|
|
108 |
are kept in the instance variable lineAttributes.
|
|
109 |
This may change (using mechanisms similar to MultiColListEntry), so
|
63
|
110 |
be prepared. (dont use the listAttributes instvar directly; if possible,
|
|
111 |
use MultiColListEntry or subclasses of it.
|
|
112 |
Although currently based on the listAttributes instVar, the implementation of
|
|
113 |
text attributes will be changed in the near future. However, the protocol
|
|
114 |
will probably be kept (i.e. use attributeAt: / attributeAt:put etc.).
|
60
|
115 |
|
31
|
116 |
InstanceVariables:
|
59
|
117 |
selection <misc> the current selection. nil, a number or collection of numbers
|
31
|
118 |
|
59
|
119 |
actionBlock <Block> block to be evaluated on selection changes
|
31
|
120 |
|
59
|
121 |
enabled <Boolean> true: selection changes allowed; false: ignore clicks
|
31
|
122 |
|
59
|
123 |
hilightFgColor
|
|
124 |
hilightBgColor <Color> how highlighted items are drawn
|
31
|
125 |
|
59
|
126 |
halfIntensityColor <Color> foreground for disabled items
|
31
|
127 |
|
59
|
128 |
selectConditionBlock <Block> if non-nil, this nlock can decide if selection is ok
|
0
|
129 |
|
59
|
130 |
doubleClickActionBlock <Block> action to perform on double-click
|
31
|
131 |
|
59
|
132 |
listAttributes dont use - will vanish
|
31
|
133 |
|
59
|
134 |
hilightLevel <Integer> level to draw selections (i.e. for 3D effect)
|
|
135 |
hilightFrameColor <Color> rectangle around highlighted items
|
31
|
136 |
|
63
|
137 |
multipleSelectOk <Boolean> if true, multiple selections (with shift) are ok.
|
|
138 |
default: false
|
|
139 |
|
59
|
140 |
ignoreReselect <Boolean> if true, selecting same again does not trigger action;
|
63
|
141 |
if false, every select triggers it.
|
|
142 |
default: true
|
|
143 |
|
|
144 |
toggleSelect <Boolean> if true, click toggles;
|
|
145 |
if false, click selects.
|
|
146 |
default: false
|
0
|
147 |
|
59
|
148 |
arrowLevel <Integer> level to draw right-arrows (for submenus etc.)
|
|
149 |
smallArrow <Boolean> if true, uses a small arrow bitmap
|
31
|
150 |
|
59
|
151 |
listSymbol if non-nil, use ST-80 style (model-access)
|
|
152 |
initialSelectionSymbol
|
|
153 |
printItems
|
|
154 |
oneItem
|
31
|
155 |
|
59
|
156 |
keyActionStyle <Symbol> controls how to respond to keyboard selects
|
31
|
157 |
|
|
158 |
written spring/summer 89 by claus
|
|
159 |
3D Jan 90 by claus
|
38
|
160 |
multiselect Jun 92 by claus
|
|
161 |
keyboard-select jun 94 by claus
|
7
|
162 |
"
|
|
163 |
! !
|
0
|
164 |
|
22
|
165 |
!SelectionInListView class methodsFor:'defaults'!
|
|
166 |
|
59
|
167 |
updateStyleCache
|
60
|
168 |
DefaultDisabledForegroundColor := StyleSheet colorAt:'selectionDisabledForegroundColor'.
|
|
169 |
DefaultHilightForegroundColor := StyleSheet colorAt:'selectionHilightForegroundColor'.
|
|
170 |
DefaultHilightBackgroundColor := StyleSheet colorAt:'selectionHilightBackgroundColor'.
|
|
171 |
DefaultHilightFrameColor := StyleSheet colorAt:'selectionHilightFrameColor'.
|
59
|
172 |
DefaultHilightLevel := StyleSheet at:'selectionHilightLevel' default:0.
|
|
173 |
DefaultRightArrowStyle := StyleSheet at:'selectionRightArrowStyle'.
|
|
174 |
DefaultRightArrowLevel := StyleSheet at:'selectionRightArrowLevel'.
|
60
|
175 |
DefaultForegroundColor := StyleSheet colorAt:'selectionForegroundColor'.
|
|
176 |
DefaultBackgroundColor := StyleSheet colorAt:'selectionBackgroundColor'.
|
|
177 |
DefaultShadowColor := StyleSheet colorAt:'selectionShadowColor'.
|
|
178 |
DefaultLightColor := StyleSheet colorAt:'selectionLightColor'.
|
|
179 |
DefaultFont := StyleSheet fontAt:'selectionFont'.
|
59
|
180 |
|
|
181 |
"
|
|
182 |
self updateStyleCache
|
|
183 |
"
|
|
184 |
!
|
|
185 |
|
22
|
186 |
rightArrowLightFormOn:aDevice
|
|
187 |
"return the form used for the right arrow light pixels (3D only)"
|
|
188 |
|
|
189 |
|f|
|
|
190 |
|
|
191 |
((aDevice == Display) and:[RightArrowLightForm notNil]) ifTrue:[
|
59
|
192 |
^ RightArrowLightForm
|
22
|
193 |
].
|
|
194 |
f := Form fromFile:'RightArrowLight.xbm' resolution:100 on:aDevice.
|
|
195 |
f isNil ifTrue:[
|
59
|
196 |
f := Form width:16 height:16 fromArray:#[2r00000000 2r00000000
|
|
197 |
2r00000000 2r00000000
|
|
198 |
2r00000000 2r00000000
|
|
199 |
2r00000110 2r00000000
|
|
200 |
2r00000101 2r00000000
|
|
201 |
2r00000100 2r10000000
|
|
202 |
2r00000100 2r01000000
|
|
203 |
2r00000100 2r00100000
|
|
204 |
2r00000100 2r00000000
|
|
205 |
2r00000100 2r00000000
|
|
206 |
2r00000100 2r00000000
|
|
207 |
2r00000100 2r00000000
|
|
208 |
2r00000100 2r00000000
|
|
209 |
2r00000100 2r00000000
|
|
210 |
2r00000000 2r00000000
|
|
211 |
2r00000000 2r00000000]
|
|
212 |
on:aDevice
|
22
|
213 |
].
|
|
214 |
(aDevice == Display) ifTrue:[
|
59
|
215 |
RightArrowLightForm := f
|
22
|
216 |
].
|
|
217 |
^ f
|
|
218 |
!
|
|
219 |
|
|
220 |
rightArrowShadowFormOn:aDevice
|
|
221 |
"return the form used for the right arrow light pixels (3D only)"
|
|
222 |
|
|
223 |
|f|
|
|
224 |
|
|
225 |
((aDevice == Display) and:[RightArrowShadowForm notNil]) ifTrue:[
|
59
|
226 |
^ RightArrowShadowForm
|
22
|
227 |
].
|
|
228 |
f := Form fromFile:'RightArrowShadow.xbm' resolution:100 on:aDevice.
|
|
229 |
f isNil ifTrue:[
|
59
|
230 |
f := Form width:16 height:16 fromArray:#[2r00000000 2r00000000
|
|
231 |
2r00000000 2r00000000
|
|
232 |
2r00000000 2r00000000
|
|
233 |
2r00000000 2r00000000
|
|
234 |
2r00000000 2r00000000
|
|
235 |
2r00000000 2r00000000
|
|
236 |
2r00000000 2r00000000
|
|
237 |
2r00000000 2r00000000
|
|
238 |
2r00000000 2r00010000
|
|
239 |
2r00000000 2r00100000
|
|
240 |
2r00000000 2r01000000
|
|
241 |
2r00000000 2r10000000
|
|
242 |
2r00000001 2r00000000
|
|
243 |
2r00000010 2r00000000
|
|
244 |
2r00000000 2r00000000
|
|
245 |
2r00000000 2r00000000]
|
|
246 |
on:aDevice
|
22
|
247 |
].
|
|
248 |
(aDevice == Display) ifTrue:[
|
59
|
249 |
RightArrowShadowForm := f
|
22
|
250 |
].
|
|
251 |
^ f
|
|
252 |
!
|
|
253 |
|
|
254 |
rightArrowFormOn:aDevice
|
|
255 |
"return the form used for the right arrow (non 3D)"
|
|
256 |
|
|
257 |
|f|
|
|
258 |
|
|
259 |
((aDevice == Display) and:[RightArrowForm notNil]) ifTrue:[
|
59
|
260 |
^ RightArrowForm
|
22
|
261 |
].
|
|
262 |
f := Form fromFile:'RightArrow.xbm' resolution:100 on:aDevice.
|
|
263 |
f isNil ifTrue:[
|
59
|
264 |
f := Form width:16 height:16 fromArray:#[2r00000000 2r00000000
|
|
265 |
2r00000000 2r00000000
|
|
266 |
2r00000000 2r00000000
|
|
267 |
2r00000110 2r00000000
|
|
268 |
2r00000101 2r00000000
|
|
269 |
2r00000100 2r10000000
|
|
270 |
2r00000100 2r01000000
|
|
271 |
2r00000100 2r00100000
|
|
272 |
2r00000100 2r00010000
|
|
273 |
2r00000100 2r00100000
|
|
274 |
2r00000100 2r01000000
|
|
275 |
2r00000100 2r10000000
|
|
276 |
2r00000101 2r00000000
|
|
277 |
2r00000110 2r00000000
|
|
278 |
2r00000000 2r00000000
|
|
279 |
2r00000000 2r00000000]
|
|
280 |
on:aDevice
|
22
|
281 |
].
|
|
282 |
(aDevice == Display) ifTrue:[
|
59
|
283 |
RightArrowForm := f
|
22
|
284 |
].
|
|
285 |
^ f
|
31
|
286 |
!
|
|
287 |
|
|
288 |
smallRightArrowLightFormOn:aDevice
|
|
289 |
"return the form used for the small right arrow light pixels (3D only)"
|
|
290 |
|
|
291 |
|f|
|
|
292 |
|
|
293 |
((aDevice == Display) and:[SmallRightArrowLightForm notNil]) ifTrue:[
|
59
|
294 |
^ SmallRightArrowLightForm
|
31
|
295 |
].
|
|
296 |
f := Form fromFile:'SmallRightArrowLight.xbm' resolution:100 on:aDevice.
|
|
297 |
f isNil ifTrue:[
|
59
|
298 |
f := Form width:9 height:9 fromArray:#[2r00000000 2r00000000
|
|
299 |
2r01100000 2r00000000
|
|
300 |
2r01011000 2r00000000
|
|
301 |
2r01000110 2r00000000
|
|
302 |
2r01000000 2r00000000
|
|
303 |
2r01000000 2r00000000
|
|
304 |
2r01000000 2r00000000
|
|
305 |
2r01000000 2r00000000
|
|
306 |
2r00000000 2r00000000]
|
|
307 |
on:aDevice
|
31
|
308 |
].
|
|
309 |
(aDevice == Display) ifTrue:[
|
59
|
310 |
SmallRightArrowLightForm := f
|
31
|
311 |
].
|
|
312 |
^ f
|
|
313 |
!
|
|
314 |
|
|
315 |
smallRightArrowShadowFormOn:aDevice
|
|
316 |
"return the form used for the small right arrow light pixels (3D only)"
|
|
317 |
|
|
318 |
|f|
|
|
319 |
|
|
320 |
((aDevice == Display) and:[SmallRightArrowShadowForm notNil]) ifTrue:[
|
59
|
321 |
^ SmallRightArrowShadowForm
|
31
|
322 |
].
|
|
323 |
f := Form fromFile:'SmallRightArrowShadow.xbm' resolution:100 on:aDevice.
|
|
324 |
f isNil ifTrue:[
|
59
|
325 |
f := Form width:9 height:9 fromArray:#[2r00000000 2r00000000
|
|
326 |
2r00000000 2r00000000
|
|
327 |
2r00000000 2r00000000
|
|
328 |
2r00000000 2r00000000
|
|
329 |
2r00000001 2r00000000
|
|
330 |
2r00000110 2r00000000
|
|
331 |
2r00011000 2r00000000
|
|
332 |
2r00100000 2r00000000
|
|
333 |
2r00000000 2r00000000]
|
|
334 |
on:aDevice
|
31
|
335 |
].
|
|
336 |
(aDevice == Display) ifTrue:[
|
59
|
337 |
SmallRightArrowShadowForm := f
|
31
|
338 |
].
|
|
339 |
^ f
|
22
|
340 |
! !
|
|
341 |
|
0
|
342 |
!SelectionInListView class methodsFor:'instance creation'!
|
|
343 |
|
|
344 |
on:aModel printItems:print oneItem:one aspect:aspect
|
59
|
345 |
change:change list:list menu:menu
|
|
346 |
initialSelection:initial
|
0
|
347 |
|
|
348 |
"for ST-80 compatibility"
|
|
349 |
|
|
350 |
^ (self new) on:aModel printItems:print oneItem:one aspect:aspect
|
59
|
351 |
change:change list:list menu:menu
|
|
352 |
initialSelection:initial
|
0
|
353 |
! !
|
|
354 |
|
|
355 |
!SelectionInListView methodsFor:'initialization'!
|
|
356 |
|
|
357 |
initialize
|
|
358 |
super initialize.
|
|
359 |
|
|
360 |
fontHeight := font height + lineSpacing.
|
63
|
361 |
enabled := true.
|
0
|
362 |
multipleSelectOk := false.
|
7
|
363 |
ignoreReselect := true.
|
63
|
364 |
toggleSelect := false.
|
|
365 |
strikeOut := false.
|
38
|
366 |
keyActionStyle := #select.
|
0
|
367 |
!
|
|
368 |
|
|
369 |
initStyle
|
59
|
370 |
|nm|
|
|
371 |
|
0
|
372 |
super initStyle.
|
|
373 |
|
59
|
374 |
DefaultFont notNil ifTrue:[
|
|
375 |
font := DefaultFont on:device
|
|
376 |
].
|
|
377 |
|
0
|
378 |
bgColor := viewBackground.
|
7
|
379 |
hilightFrameColor := nil.
|
|
380 |
hilightLevel := 0.
|
31
|
381 |
arrowLevel := 1.
|
|
382 |
smallArrow := false.
|
0
|
383 |
|
59
|
384 |
device hasGreyscales ifTrue:[
|
|
385 |
"
|
63
|
386 |
must get rid of these hard codings
|
59
|
387 |
"
|
|
388 |
nm := StyleSheet name asSymbol.
|
|
389 |
(nm == #next) ifTrue:[
|
|
390 |
hilightFgColor := fgColor.
|
|
391 |
hilightBgColor := White.
|
|
392 |
hilightFrameColor := fgColor
|
|
393 |
] ifFalse:[
|
|
394 |
(nm == #motif) ifTrue:[
|
|
395 |
fgColor := White.
|
|
396 |
bgColor := Grey.
|
|
397 |
viewBackground := bgColor.
|
|
398 |
hilightFgColor := bgColor "fgColor" "White".
|
|
399 |
hilightBgColor := fgColor "bgColor lightened" "darkened".
|
|
400 |
] ifFalse:[
|
|
401 |
(nm == #openwin) ifTrue:[
|
|
402 |
hilightFgColor := fgColor.
|
|
403 |
hilightBgColor := Color grey.
|
|
404 |
smallArrow := true.
|
|
405 |
]
|
|
406 |
]
|
|
407 |
]
|
|
408 |
].
|
|
409 |
|
|
410 |
hilightFgColor isNil ifTrue:[
|
|
411 |
hilightFgColor := bgColor.
|
|
412 |
].
|
|
413 |
hilightBgColor isNil ifTrue:[
|
|
414 |
hilightBgColor := fgColor.
|
|
415 |
].
|
|
416 |
DefaultForegroundColor notNil ifTrue:[
|
|
417 |
fgColor := DefaultForegroundColor
|
|
418 |
].
|
|
419 |
DefaultBackgroundColor notNil ifTrue:[
|
63
|
420 |
bgColor := viewBackground := DefaultBackgroundColor
|
59
|
421 |
].
|
|
422 |
DefaultHilightForegroundColor notNil ifTrue:[
|
|
423 |
hilightFgColor := DefaultHilightForegroundColor
|
|
424 |
].
|
|
425 |
DefaultHilightBackgroundColor notNil ifTrue:[
|
|
426 |
hilightBgColor := DefaultHilightBackgroundColor
|
|
427 |
].
|
|
428 |
DefaultHilightFrameColor notNil ifTrue:[
|
|
429 |
hilightFrameColor := DefaultHilightFrameColor
|
|
430 |
].
|
|
431 |
DefaultHilightLevel notNil ifTrue:[
|
|
432 |
hilightLevel := DefaultHilightLevel
|
|
433 |
].
|
|
434 |
DefaultRightArrowLevel notNil ifTrue:[
|
|
435 |
arrowLevel := DefaultRightArrowLevel
|
|
436 |
].
|
|
437 |
|
|
438 |
DefaultShadowColor notNil ifTrue:[
|
|
439 |
shadowColor := DefaultShadowColor on:device
|
|
440 |
].
|
|
441 |
DefaultLightColor notNil ifTrue:[
|
|
442 |
lightColor := DefaultLightColor on:device
|
0
|
443 |
].
|
|
444 |
|
31
|
445 |
(hilightLevel abs > 0) ifTrue:[
|
59
|
446 |
lineSpacing := 3
|
31
|
447 |
] ifFalse:[
|
59
|
448 |
lineSpacing := 2
|
31
|
449 |
].
|
|
450 |
|
0
|
451 |
hilightFgColor isNil ifTrue:[
|
59
|
452 |
hilightFgColor := bgColor.
|
|
453 |
hilightBgColor := fgColor
|
0
|
454 |
].
|
|
455 |
|
59
|
456 |
DefaultDisabledForegroundColor notNil ifTrue:[
|
|
457 |
halfIntensityFgColor := DefaultDisabledForegroundColor
|
|
458 |
] ifFalse:[
|
|
459 |
halfIntensityFgColor := Color darkGrey.
|
|
460 |
].
|
|
461 |
|
|
462 |
fgColor := fgColor on:device.
|
|
463 |
bgColor := bgColor on:device.
|
|
464 |
halfIntensityFgColor := halfIntensityFgColor on:device.
|
|
465 |
hilightFrameColor notNil ifTrue:[hilightFrameColor := hilightFrameColor on:device].
|
|
466 |
hilightFgColor := hilightFgColor on:device.
|
|
467 |
hilightBgColor := hilightBgColor on:device.
|
0
|
468 |
!
|
|
469 |
|
|
470 |
initCursor
|
|
471 |
"set the cursor - a hand"
|
|
472 |
|
|
473 |
cursor := Cursor hand
|
|
474 |
!
|
|
475 |
|
|
476 |
initEvents
|
|
477 |
super initEvents.
|
|
478 |
self enableButtonEvents
|
|
479 |
!
|
|
480 |
|
|
481 |
realize
|
|
482 |
super realize.
|
|
483 |
selection notNil ifTrue:[
|
59
|
484 |
self makeLineVisible:selection
|
0
|
485 |
]
|
|
486 |
! !
|
|
487 |
|
|
488 |
!SelectionInListView methodsFor:'accessing'!
|
|
489 |
|
38
|
490 |
keyActionStyle:aSymbol
|
|
491 |
"defines how the view should respond to alpha-keys pressed.
|
|
492 |
Possible values are:
|
59
|
493 |
#select -> will select next entry starting with that
|
|
494 |
character and perform the click-action
|
38
|
495 |
|
59
|
496 |
#selectAndDoubleclick -> will select next & perform double-click action
|
38
|
497 |
|
59
|
498 |
#pass -> will pass key to superclass (i.e. no special treatment)
|
38
|
499 |
|
59
|
500 |
nil -> will ignore key
|
63
|
501 |
|
|
502 |
the default (set in #initialize) is #select
|
38
|
503 |
"
|
|
504 |
|
|
505 |
keyActionStyle := aSymbol
|
|
506 |
!
|
|
507 |
|
63
|
508 |
contents:aCollection
|
|
509 |
"set the list - redefined, since setting the list implies unselecting
|
|
510 |
and clearing attributes."
|
0
|
511 |
|
|
512 |
selection := nil.
|
63
|
513 |
listAttributes := nil.
|
|
514 |
super contents:aCollection.
|
|
515 |
!
|
|
516 |
|
|
517 |
setList:aCollection
|
|
518 |
"set the list - redefined, since setting the list implies unselecting
|
|
519 |
and clearing attributes.
|
|
520 |
No redraw is done - the caller should make sure to redraw afterwards
|
|
521 |
(or use this only before the view is visible)."
|
|
522 |
|
|
523 |
selection := nil.
|
|
524 |
listAttributes := nil.
|
|
525 |
super setList:aCollection.
|
0
|
526 |
!
|
|
527 |
|
|
528 |
list:aCollection
|
63
|
529 |
"set the list - redefined, since setting the list implies unselecting
|
|
530 |
and clearing attributes."
|
0
|
531 |
|
7
|
532 |
"somewhat of a kludge: if selection is first line,
|
|
533 |
we have to remove the highlight frame by hand here"
|
|
534 |
|
|
535 |
(shown and:[hilightLevel ~~ 0]) ifTrue:[
|
59
|
536 |
selection == firstLineShown ifTrue:[
|
|
537 |
self paint:bgColor.
|
|
538 |
self fillRectangleX:margin y:margin
|
|
539 |
width:(width - (margin * 2))
|
|
540 |
height:(hilightLevel abs).
|
|
541 |
].
|
7
|
542 |
].
|
|
543 |
|
0
|
544 |
selection := nil.
|
63
|
545 |
listAttributes := nil.
|
|
546 |
super list:aCollection.
|
0
|
547 |
!
|
|
548 |
|
63
|
549 |
setAttributes:aList
|
|
550 |
"set the attribute list.
|
|
551 |
No redraw is done - the caller should make sure to redraw afterwards
|
|
552 |
(or use this only before the view is visible)."
|
0
|
553 |
|
63
|
554 |
listAttributes := aList
|
0
|
555 |
!
|
|
556 |
|
|
557 |
attributeAt:index
|
63
|
558 |
"return the line attribute of list line index.
|
|
559 |
currently supported are:
|
|
560 |
#halfIntensity
|
|
561 |
#disabled
|
|
562 |
#bold
|
|
563 |
"
|
0
|
564 |
|
|
565 |
listAttributes isNil ifFalse:[
|
59
|
566 |
(index > listAttributes size) ifFalse:[
|
|
567 |
^ listAttributes at:index
|
|
568 |
]
|
0
|
569 |
].
|
|
570 |
^ nil
|
|
571 |
!
|
|
572 |
|
60
|
573 |
attributeAt:index put:aSymbolOrCollectionOfSymbolsOrNil
|
63
|
574 |
"set a lines attribute(s);
|
60
|
575 |
currently supported are:
|
|
576 |
#halfIntensity
|
|
577 |
#disabled
|
63
|
578 |
#bold
|
0
|
579 |
"
|
|
580 |
|
|
581 |
(index > list size) ifFalse:[
|
59
|
582 |
listAttributes isNil ifTrue:[
|
63
|
583 |
listAttributes := (OrderedCollection new:index) grow:index
|
59
|
584 |
] ifFalse:[
|
|
585 |
(index > listAttributes size) ifTrue:[
|
|
586 |
listAttributes grow:index
|
|
587 |
]
|
|
588 |
].
|
60
|
589 |
aSymbolOrCollectionOfSymbolsOrNil = (listAttributes at:index) ifFalse:[
|
|
590 |
listAttributes at:index put:aSymbolOrCollectionOfSymbolsOrNil.
|
59
|
591 |
self redrawLine:index
|
|
592 |
]
|
0
|
593 |
]
|
|
594 |
!
|
|
595 |
|
63
|
596 |
attributeAt:index add:aSymbolOrCollectionOfSymbols
|
|
597 |
"add to a lines attribute(s);
|
|
598 |
currently supported are:
|
|
599 |
#halfIntensity
|
|
600 |
#disabled
|
|
601 |
#bold
|
|
602 |
"
|
|
603 |
|
|
604 |
|current|
|
|
605 |
|
|
606 |
current := self attributeAt:index.
|
|
607 |
current isNil ifTrue:[
|
|
608 |
current := Set new.
|
|
609 |
] ifFalse:[
|
|
610 |
current isSymbol ifTrue:[
|
|
611 |
current == aSymbolOrCollectionOfSymbols ifTrue:[^ self].
|
|
612 |
current := Set with:current
|
|
613 |
]
|
|
614 |
].
|
|
615 |
|
|
616 |
aSymbolOrCollectionOfSymbols isSymbol ifTrue:[
|
|
617 |
current := current add:aSymbolOrCollectionOfSymbols
|
|
618 |
] ifFalse:[
|
|
619 |
(current includes:aSymbolOrCollectionOfSymbols) ifTrue:[^ self].
|
|
620 |
current addAll:aSymbolOrCollectionOfSymbols
|
|
621 |
].
|
|
622 |
self attributeAt:index put:current
|
|
623 |
!
|
|
624 |
|
|
625 |
attributeAt:index remove:aSymbolOrCollectionOfSymbols
|
|
626 |
"remove a line attribute;
|
|
627 |
currently supported are:
|
|
628 |
#halfIntensity
|
|
629 |
#disabled
|
|
630 |
#bold
|
|
631 |
"
|
|
632 |
|
|
633 |
|current|
|
|
634 |
|
|
635 |
current := self attributeAt:index.
|
|
636 |
current isNil ifTrue:[^ self].
|
|
637 |
current isSymbol ifTrue:[
|
|
638 |
aSymbolOrCollectionOfSymbols isSymbol ifTrue:[
|
|
639 |
current == aSymbolOrCollectionOfSymbols ifTrue:[current := nil]
|
|
640 |
] ifFalse:[
|
|
641 |
(aSymbolOrCollectionOfSymbols includes:current) ifTrue:[
|
|
642 |
current := nil
|
|
643 |
]
|
|
644 |
]
|
|
645 |
] ifFalse:[
|
|
646 |
aSymbolOrCollectionOfSymbols isSymbol ifTrue:[
|
|
647 |
current := current remove:aSymbolOrCollectionOfSymbols ifAbsent:[]
|
|
648 |
] ifFalse:[
|
|
649 |
aSymbolOrCollectionOfSymbols removeAll:aSymbolOrCollectionOfSymbols
|
|
650 |
]
|
|
651 |
].
|
|
652 |
self attributeAt:index put:current
|
|
653 |
!
|
|
654 |
|
60
|
655 |
line:lineNr hasAttribute:aSymbol
|
|
656 |
"return true, if line nr has attribute, aSymbol;
|
63
|
657 |
currently supported attributes are:
|
60
|
658 |
#halfIntensity
|
|
659 |
#disabled
|
63
|
660 |
#bold
|
60
|
661 |
"
|
|
662 |
|
|
663 |
|attr|
|
|
664 |
|
|
665 |
(lineNr > listAttributes size) ifTrue:[^ false].
|
|
666 |
attr := listAttributes at:lineNr.
|
|
667 |
attr isNil ifTrue:[^ false].
|
|
668 |
attr isSymbol ifTrue:[^ attr == aSymbol].
|
|
669 |
^ (attr includes:aSymbol)
|
|
670 |
!
|
|
671 |
|
7
|
672 |
removeIndexWithoutRedraw:lineNr
|
|
673 |
"delete line - no redraw;
|
|
674 |
return true, if something was really deleted.
|
|
675 |
Redefined since we have to care for selection"
|
|
676 |
|
|
677 |
self checkRemovingSelection:lineNr.
|
|
678 |
^ super removeIndexWithoutRedraw:lineNr
|
|
679 |
!
|
|
680 |
|
|
681 |
removeIndex:lineNr
|
|
682 |
"delete line - with redraw.
|
|
683 |
Redefined since we have to care for selection"
|
|
684 |
|
|
685 |
self checkRemovingSelection:lineNr.
|
|
686 |
^ super removeIndex:lineNr
|
|
687 |
!
|
|
688 |
|
0
|
689 |
action:aBlock
|
|
690 |
"set the action block to be performed on select"
|
|
691 |
|
|
692 |
actionBlock := aBlock
|
|
693 |
!
|
|
694 |
|
|
695 |
doubleClickAction:aBlock
|
|
696 |
"set the double click action block to be performed on select"
|
|
697 |
|
|
698 |
doubleClickActionBlock := aBlock
|
|
699 |
!
|
|
700 |
|
59
|
701 |
on:aModel printItems:print oneItem:one aspect:aspect
|
|
702 |
change:change list:list menu:menu
|
|
703 |
initialSelection:initial
|
|
704 |
|
|
705 |
"ST-80 compatibility"
|
|
706 |
|
|
707 |
aspectSymbol := aspect.
|
|
708 |
changeSymbol := change.
|
|
709 |
listSymbol := list.
|
|
710 |
menuSymbol := menu.
|
|
711 |
initialSelectionSymbol := initial.
|
|
712 |
printItems := print.
|
|
713 |
oneItem := one.
|
|
714 |
|
|
715 |
model := aModel.
|
|
716 |
|
|
717 |
listSymbol notNil ifTrue:[
|
|
718 |
self list:(aModel perform:listSymbol) asText
|
|
719 |
].
|
|
720 |
model addDependent:self
|
|
721 |
! !
|
|
722 |
|
|
723 |
!SelectionInListView methodsFor:'selections'!
|
|
724 |
|
63
|
725 |
toggleSelect:aBoolean
|
|
726 |
"turn on/off toggle select"
|
|
727 |
|
|
728 |
toggleSelect := aBoolean.
|
|
729 |
!
|
|
730 |
|
|
731 |
strikeOut:aBoolean
|
|
732 |
"turn on/off strikeOut mode"
|
|
733 |
|
|
734 |
strikeOut := aBoolean.
|
|
735 |
!
|
|
736 |
|
59
|
737 |
multipleSelectOk:aBoolean
|
|
738 |
"allow/disallow multiple selections"
|
|
739 |
|
|
740 |
multipleSelectOk := aBoolean.
|
|
741 |
aBoolean ifTrue:[
|
|
742 |
self enableButtonMotionEvents
|
|
743 |
] ifFalse:[
|
|
744 |
self disableButtonMotionEvents
|
|
745 |
]
|
|
746 |
!
|
|
747 |
|
|
748 |
ignoreReselect:aBoolean
|
|
749 |
"set/clear the ignoreReselect flag -
|
|
750 |
if set, a click on an already selected entry is ignored.
|
|
751 |
Otherwise the notification is done, even if no
|
|
752 |
change in the selection occurs.
|
|
753 |
(for example, in browser to update a method)"
|
|
754 |
|
|
755 |
ignoreReselect := aBoolean
|
|
756 |
!
|
|
757 |
|
|
758 |
enable
|
|
759 |
"enable selections"
|
|
760 |
|
|
761 |
enabled := true
|
|
762 |
!
|
|
763 |
|
|
764 |
disable
|
|
765 |
"disable selections"
|
|
766 |
|
|
767 |
enabled := false
|
|
768 |
!
|
|
769 |
|
3
|
770 |
selectConditionBlock:aBlock
|
|
771 |
"set the conditionBlock; this block is evaluated before a selection
|
|
772 |
change is performed; the change will not be done, if the evaluation
|
|
773 |
returns false. For example, this allows confirmation queries in
|
|
774 |
the SystemBrowser"
|
|
775 |
|
|
776 |
selectConditionBlock := aBlock
|
|
777 |
!
|
7
|
778 |
|
|
779 |
numberOfSelections
|
|
780 |
"return the number of selected entries"
|
|
781 |
|
|
782 |
|sz|
|
|
783 |
|
|
784 |
selection isNil ifTrue:[^ 0].
|
|
785 |
sz := selection size.
|
|
786 |
sz > 0 ifTrue:[^ sz].
|
|
787 |
^ 1
|
|
788 |
!
|
|
789 |
|
63
|
790 |
isInSelection:aNumber
|
|
791 |
"return true, if line, aNumber is in the selection"
|
|
792 |
|
|
793 |
selection isNil ifTrue:[^ false].
|
|
794 |
(selection isKindOf:Collection) ifTrue:[
|
|
795 |
^ (selection includes:aNumber)
|
|
796 |
].
|
|
797 |
^ (aNumber == selection)
|
|
798 |
!
|
|
799 |
|
|
800 |
valueIsInSelection:someString
|
|
801 |
"return true, if someString is in the selection"
|
|
802 |
|
|
803 |
|sel|
|
|
804 |
|
|
805 |
selection isNil ifTrue:[^ false].
|
|
806 |
sel := self selectionValue.
|
|
807 |
self numberOfSelections > 1 ifTrue:[
|
|
808 |
^ (sel includes:someString)
|
|
809 |
].
|
|
810 |
^ (someString = sel)
|
|
811 |
!
|
|
812 |
|
60
|
813 |
hasSelection
|
63
|
814 |
"return true, if the view has a selection"
|
|
815 |
|
|
816 |
^ selection notNil
|
60
|
817 |
!
|
|
818 |
|
0
|
819 |
selectionValue
|
7
|
820 |
"return the selection value i.e. the text in the selected line.
|
|
821 |
For multiple selections a collection containing the entries is returned."
|
0
|
822 |
|
|
823 |
selection isNil ifTrue:[^ nil].
|
7
|
824 |
(selection isKindOf:Collection) ifTrue:[
|
59
|
825 |
^ selection collect:[:nr | list at:nr]
|
7
|
826 |
].
|
0
|
827 |
^ list at:selection
|
|
828 |
!
|
|
829 |
|
|
830 |
selection
|
7
|
831 |
"return the selection line nr or collection of line numbers"
|
0
|
832 |
|
|
833 |
^ selection
|
|
834 |
!
|
|
835 |
|
|
836 |
deselect
|
|
837 |
"deselect"
|
|
838 |
|
|
839 |
self selection:nil
|
|
840 |
!
|
|
841 |
|
|
842 |
deselectWithoutRedraw
|
|
843 |
"deselect - no redraw"
|
|
844 |
|
|
845 |
selection := nil
|
|
846 |
!
|
|
847 |
|
59
|
848 |
selectElementWithoutScroll:anObject
|
|
849 |
"select the element with same printString as the argument, anObject.
|
|
850 |
Do not scroll."
|
0
|
851 |
|
|
852 |
|lineNo|
|
|
853 |
|
|
854 |
list notNil ifTrue:[
|
63
|
855 |
lineNo := list indexOf:(anObject printString) ifAbsent:[].
|
|
856 |
lineNo notNil ifTrue:[self selectWithoutScroll:lineNo]
|
59
|
857 |
]
|
|
858 |
!
|
|
859 |
|
|
860 |
selectElement:anObject
|
|
861 |
"select the element with same printString as the argument, anObject.
|
|
862 |
Scroll to make the new selection visible."
|
|
863 |
|
|
864 |
|lineNo|
|
|
865 |
|
|
866 |
list notNil ifTrue:[
|
63
|
867 |
lineNo := list indexOf:(anObject printString) ifAbsent:[].
|
|
868 |
lineNo notNil ifTrue:[self selection:lineNo]
|
0
|
869 |
]
|
|
870 |
!
|
|
871 |
|
|
872 |
selectWithoutScroll:aNumberOrNil
|
|
873 |
"select line, aNumber or deselect if argument is nil"
|
|
874 |
|
|
875 |
|prevSelection newSelection|
|
|
876 |
|
|
877 |
newSelection := aNumberOrNil.
|
|
878 |
newSelection notNil ifTrue:[
|
59
|
879 |
(self isValidSelection:newSelection) ifFalse:[
|
|
880 |
newSelection := nil
|
|
881 |
]
|
0
|
882 |
].
|
|
883 |
|
|
884 |
(newSelection == selection) ifTrue: [^ self].
|
|
885 |
|
|
886 |
selection notNil ifTrue: [
|
59
|
887 |
prevSelection := selection.
|
|
888 |
selection := nil.
|
|
889 |
(prevSelection isKindOf:Collection) ifTrue:[
|
|
890 |
prevSelection do:[:line |
|
|
891 |
self redrawElement:line
|
|
892 |
]
|
|
893 |
] ifFalse:[
|
|
894 |
self redrawElement:prevSelection
|
|
895 |
]
|
0
|
896 |
].
|
|
897 |
selection := newSelection.
|
|
898 |
selection notNil ifTrue:[
|
59
|
899 |
self redrawElement:selection
|
0
|
900 |
]
|
|
901 |
!
|
|
902 |
|
|
903 |
selection:aNumberOrNil
|
|
904 |
"select line, aNumber or deselect if argument is nil;
|
59
|
905 |
scroll to make the selected line visible"
|
0
|
906 |
|
|
907 |
self selectWithoutScroll:aNumberOrNil.
|
|
908 |
selection notNil ifTrue:[
|
63
|
909 |
"/ shown ifTrue:[
|
59
|
910 |
self makeLineVisible:selection
|
63
|
911 |
"/ ]
|
0
|
912 |
]
|
|
913 |
!
|
|
914 |
|
63
|
915 |
selectAll
|
|
916 |
"select all entries."
|
|
917 |
|
|
918 |
selection := OrderedCollection withAll:(1 to:list size).
|
|
919 |
shown ifTrue:[self redraw]
|
|
920 |
!
|
|
921 |
|
7
|
922 |
addElementToSelection:anObject
|
|
923 |
"add the element with the same printstring as the argument, anObject
|
63
|
924 |
to the selection. The entry is searched by comparing printStrings.
|
|
925 |
No scrolling is done. Returns true, if ok, false if no such entry
|
|
926 |
was found."
|
|
927 |
|
|
928 |
|lineNo str|
|
7
|
929 |
|
63
|
930 |
str := anObject printString.
|
|
931 |
lineNo := list findFirst:[:entry | str = entry printString].
|
|
932 |
lineNo ~~ 0 ifTrue:[
|
|
933 |
self addToSelection:lineNo.
|
|
934 |
^ true
|
|
935 |
].
|
|
936 |
^ false
|
7
|
937 |
!
|
|
938 |
|
|
939 |
addToSelection:aNumber
|
63
|
940 |
"add entry, aNumber to the selection. No scrolling is done."
|
|
941 |
|
|
942 |
(self isValidSelection:aNumber) ifFalse:[^ self].
|
7
|
943 |
|
|
944 |
selection isNil ifTrue:[^ self selectWithoutScroll:aNumber].
|
|
945 |
(selection isKindOf:Collection) ifTrue:[
|
59
|
946 |
(selection includes:aNumber) ifTrue:[^ self].
|
|
947 |
selection add:aNumber
|
7
|
948 |
] ifFalse:[
|
59
|
949 |
(aNumber == selection) ifTrue:[^ self].
|
|
950 |
selection := OrderedCollection with:selection with:aNumber
|
7
|
951 |
].
|
|
952 |
self redrawElement:aNumber
|
|
953 |
!
|
|
954 |
|
63
|
955 |
removeFromSelection:aNumber
|
|
956 |
"remove entry, aNumber from the selection."
|
|
957 |
|
|
958 |
selection isNil ifTrue:[^ self].
|
|
959 |
|
|
960 |
(selection isKindOf:Collection) ifTrue:[
|
|
961 |
(selection includes:aNumber) ifFalse:[^ self].
|
70
|
962 |
selection remove:aNumber.
|
|
963 |
selection size == 1 ifTrue:[
|
|
964 |
selection := selection first
|
|
965 |
] ifFalse:[
|
|
966 |
selection size == 0 ifTrue:[
|
|
967 |
selection := nil
|
|
968 |
]
|
|
969 |
]
|
63
|
970 |
] ifFalse:[
|
|
971 |
(aNumber == selection) ifFalse:[^ self].
|
|
972 |
selection := nil
|
|
973 |
].
|
|
974 |
self redrawElement:aNumber
|
|
975 |
!
|
|
976 |
|
|
977 |
toggleSelection:aNumber
|
|
978 |
"toggle selection-state of entry, aNumber"
|
|
979 |
|
|
980 |
(self isInSelection:aNumber) ifTrue:[
|
|
981 |
self removeFromSelection:aNumber
|
|
982 |
] ifFalse:[
|
|
983 |
self addToSelection:aNumber
|
|
984 |
]
|
|
985 |
!
|
|
986 |
|
60
|
987 |
nextAfterSelection
|
|
988 |
"return the number of the next selectable entry after the selection.
|
59
|
989 |
Wrap at end."
|
|
990 |
|
|
991 |
|next|
|
0
|
992 |
|
|
993 |
selection isNil ifTrue:[
|
59
|
994 |
next := firstLineShown
|
0
|
995 |
] ifFalse:[
|
59
|
996 |
selection size ~~ 0 ifTrue:[
|
|
997 |
next := selection max + 1
|
|
998 |
] ifFalse:[
|
|
999 |
next := selection + 1
|
|
1000 |
].
|
|
1001 |
].
|
60
|
1002 |
(self isValidSelection:next) ifFalse:[
|
77
|
1003 |
next > list size ifTrue:[
|
|
1004 |
next := 1.
|
|
1005 |
] ifFalse:[
|
|
1006 |
[next <= list size
|
|
1007 |
and:[(self isValidSelection:next) not]] whileTrue:[
|
|
1008 |
next := next + 1
|
|
1009 |
].
|
|
1010 |
].
|
60
|
1011 |
].
|
|
1012 |
(self isValidSelection:next) ifFalse:[
|
|
1013 |
next := nil
|
|
1014 |
].
|
|
1015 |
^ next
|
0
|
1016 |
!
|
|
1017 |
|
60
|
1018 |
previousBeforeSelection
|
|
1019 |
"return the number of the previous selectable entry before the selection.
|
59
|
1020 |
Wrap at beginning."
|
|
1021 |
|
|
1022 |
|prev|
|
0
|
1023 |
|
|
1024 |
selection isNil ifTrue:[
|
59
|
1025 |
prev := firstLineShown - 1
|
0
|
1026 |
] ifFalse:[
|
59
|
1027 |
selection size ~~ 0 ifTrue:[
|
|
1028 |
prev := selection min - 1
|
|
1029 |
] ifFalse:[
|
|
1030 |
prev := selection - 1
|
|
1031 |
].
|
|
1032 |
].
|
60
|
1033 |
(self isValidSelection:prev) ifFalse:[
|
77
|
1034 |
prev < 1 ifTrue:[
|
|
1035 |
prev := list size.
|
|
1036 |
] ifFalse:[
|
|
1037 |
[prev >= 1
|
|
1038 |
and:[(self isValidSelection:prev) not]] whileTrue:[
|
|
1039 |
prev := prev - 1
|
|
1040 |
].
|
|
1041 |
].
|
60
|
1042 |
].
|
|
1043 |
(self isValidSelection:prev) ifFalse:[
|
|
1044 |
prev := nil
|
|
1045 |
].
|
|
1046 |
^ prev
|
|
1047 |
!
|
|
1048 |
|
63
|
1049 |
selectNext
|
|
1050 |
"select next line or first visible if there is currrently no selection.
|
|
1051 |
Wrap at end."
|
|
1052 |
|
|
1053 |
self selection:(self nextAfterSelection)
|
|
1054 |
!
|
|
1055 |
|
60
|
1056 |
selectPrevious
|
|
1057 |
"select previous line or previous visible if there is currently no selection.
|
|
1058 |
Wrap at beginning."
|
|
1059 |
|
|
1060 |
self selection:(self previouseBeforeSelection).
|
63
|
1061 |
!
|
|
1062 |
|
|
1063 |
selectionDo:aBlock
|
|
1064 |
"perform aBlock for each nr in the selection.
|
|
1065 |
For single selection, it is called once for the items nr.
|
|
1066 |
For multiple selections, it is called for each."
|
|
1067 |
|
|
1068 |
|sz|
|
|
1069 |
|
|
1070 |
selection isNil ifTrue:[^ self].
|
|
1071 |
sz := selection size.
|
|
1072 |
sz > 0 ifTrue:[
|
|
1073 |
selection do:aBlock
|
|
1074 |
] ifFalse:[
|
|
1075 |
aBlock value:selection
|
|
1076 |
].
|
0
|
1077 |
! !
|
|
1078 |
|
|
1079 |
!SelectionInListView methodsFor:'private'!
|
|
1080 |
|
7
|
1081 |
checkRemovingSelection:lineNr
|
|
1082 |
"when a line is removed, we have to adjust selection"
|
|
1083 |
|
|
1084 |
|newSelection|
|
|
1085 |
|
|
1086 |
selection notNil ifTrue:[
|
59
|
1087 |
(selection size > 0) ifTrue:[
|
|
1088 |
newSelection := OrderedCollection new.
|
|
1089 |
selection do:[:sel |
|
|
1090 |
sel < lineNr ifTrue:[
|
|
1091 |
newSelection add:sel
|
|
1092 |
] ifFalse:[
|
|
1093 |
sel > lineNr ifTrue:[
|
|
1094 |
newSelection add:(sel - 1)
|
|
1095 |
]
|
|
1096 |
"otherwise remove it from the selection"
|
|
1097 |
]
|
|
1098 |
].
|
|
1099 |
newSelection size == 1 ifTrue:[
|
|
1100 |
selection := newSelection first
|
|
1101 |
] ifFalse:[
|
|
1102 |
newSelection size == 0 ifTrue:[
|
|
1103 |
selection := nil
|
|
1104 |
] ifFalse:[
|
|
1105 |
selection := newSelection
|
|
1106 |
]
|
|
1107 |
]
|
|
1108 |
] ifFalse:[
|
|
1109 |
selection == lineNr ifTrue:[
|
|
1110 |
selection := nil
|
|
1111 |
] ifFalse:[
|
|
1112 |
selection > lineNr ifTrue:[
|
|
1113 |
selection := selection - 1
|
|
1114 |
]
|
|
1115 |
]
|
|
1116 |
]
|
7
|
1117 |
]
|
|
1118 |
!
|
|
1119 |
|
0
|
1120 |
isValidSelection:aNumber
|
7
|
1121 |
"return true, if aNumber is ok for a selection lineNo"
|
0
|
1122 |
|
|
1123 |
aNumber isNil ifTrue:[^ false].
|
|
1124 |
^ (aNumber between:1 and:list size)
|
|
1125 |
!
|
|
1126 |
|
|
1127 |
positionToSelectionX:x y:y
|
|
1128 |
"given a click position, return the selection lineNo"
|
|
1129 |
|
|
1130 |
|visibleLine|
|
|
1131 |
|
|
1132 |
(x between:0 and:width) ifTrue:[
|
59
|
1133 |
(y between:0 and:height) ifTrue:[
|
|
1134 |
visibleLine := self visibleLineOfY:y.
|
|
1135 |
^ self visibleLineToListLine:visibleLine
|
|
1136 |
]
|
0
|
1137 |
].
|
|
1138 |
^ nil
|
|
1139 |
!
|
|
1140 |
|
|
1141 |
widthForScrollBetween:start and:end
|
|
1142 |
"has to be redefined since WHOLE line is inverted/modified sometimes"
|
|
1143 |
|
|
1144 |
| anySelectionInRange |
|
|
1145 |
|
|
1146 |
selection notNil ifTrue:[
|
59
|
1147 |
(selection isKindOf:Collection) ifTrue:[
|
|
1148 |
anySelectionInRange := false.
|
|
1149 |
selection do:[:s |
|
|
1150 |
(s between:start and:end) ifTrue:[
|
|
1151 |
anySelectionInRange := true
|
|
1152 |
]
|
|
1153 |
]
|
|
1154 |
] ifFalse:[
|
|
1155 |
anySelectionInRange := selection between:start and:end
|
|
1156 |
]
|
0
|
1157 |
] ifFalse:[
|
59
|
1158 |
anySelectionInRange := false
|
0
|
1159 |
].
|
|
1160 |
|
|
1161 |
anySelectionInRange ifTrue:[
|
59
|
1162 |
^ width
|
31
|
1163 |
"
|
59
|
1164 |
self is3D ifFalse:[
|
|
1165 |
^ width
|
|
1166 |
].
|
|
1167 |
( #(next openwin) includes:style) ifTrue:[
|
|
1168 |
^ width
|
|
1169 |
].
|
|
1170 |
viewBackground = background ifFalse:[
|
|
1171 |
^ width
|
|
1172 |
]
|
31
|
1173 |
"
|
0
|
1174 |
].
|
|
1175 |
^ super widthForScrollBetween:start and:end
|
|
1176 |
!
|
|
1177 |
|
|
1178 |
visibleLineNeedsSpecialCare:visLineNr
|
|
1179 |
|listLine|
|
|
1180 |
|
|
1181 |
listLine := self visibleLineToListLine:visLineNr.
|
|
1182 |
listLine isNil ifTrue:[^ false].
|
|
1183 |
(self isInSelection:listLine) ifTrue:[^ true].
|
|
1184 |
listAttributes notNil ifTrue:[
|
59
|
1185 |
(listLine <= listAttributes size) ifTrue:[
|
|
1186 |
^ (listAttributes at:listLine) notNil
|
|
1187 |
]
|
0
|
1188 |
].
|
|
1189 |
^ false
|
|
1190 |
!
|
|
1191 |
|
|
1192 |
scrollSelectDown
|
|
1193 |
"auto scroll action; scroll and reinstall timed-block"
|
|
1194 |
|
38
|
1195 |
self scrollDown.
|
|
1196 |
Processor addTimedBlock:autoScrollBlock afterSeconds:autoScrollDeltaT.
|
0
|
1197 |
!
|
|
1198 |
|
|
1199 |
scrollSelectUp
|
|
1200 |
"auto scroll action; scroll and reinstall timed-block"
|
|
1201 |
|
38
|
1202 |
self scrollUp.
|
|
1203 |
Processor addTimedBlock:autoScrollBlock afterSeconds:autoScrollDeltaT.
|
0
|
1204 |
! !
|
|
1205 |
|
|
1206 |
!SelectionInListView methodsFor:'redrawing'!
|
|
1207 |
|
22
|
1208 |
drawRightArrowInVisibleLine:visLineNr
|
|
1209 |
"draw a right arrow (for submenus).
|
|
1210 |
This method is not used here, but provided for subclasses such
|
|
1211 |
as menus or file-lists."
|
|
1212 |
|
38
|
1213 |
|y x form form2 topLeftColor botRightColor t|
|
22
|
1214 |
|
|
1215 |
x := width - 16.
|
59
|
1216 |
y := (self yOfVisibleLine:visLineNr).
|
22
|
1217 |
|
|
1218 |
device depth == 1 ifTrue:[
|
59
|
1219 |
form := self class rightArrowFormOn:device.
|
|
1220 |
y := y + ((font height - form height) // 2).
|
|
1221 |
self foreground:Black.
|
|
1222 |
self displayForm:form x:x y:y.
|
22
|
1223 |
] ifFalse:[
|
59
|
1224 |
smallArrow ifTrue:[
|
|
1225 |
form := self class smallRightArrowLightFormOn:device.
|
|
1226 |
form2 := self class smallRightArrowShadowFormOn:device.
|
|
1227 |
] ifFalse:[
|
|
1228 |
form := self class rightArrowLightFormOn:device.
|
|
1229 |
form2 := self class rightArrowShadowFormOn:device.
|
|
1230 |
].
|
|
1231 |
y := y + ((font height - form height) // 2).
|
22
|
1232 |
|
59
|
1233 |
topLeftColor := lightColor.
|
|
1234 |
botRightColor := shadowColor.
|
22
|
1235 |
|
59
|
1236 |
"openwin arrow stays down"
|
|
1237 |
style ~~ #openwin ifTrue:[
|
|
1238 |
(self isInSelection:(self visibleLineToListLine:visLineNr)) ifTrue:[
|
|
1239 |
t := topLeftColor.
|
|
1240 |
topLeftColor := botRightColor.
|
|
1241 |
botRightColor := t.
|
|
1242 |
]
|
|
1243 |
].
|
|
1244 |
arrowLevel < 0 ifTrue:[
|
|
1245 |
t := topLeftColor.
|
|
1246 |
topLeftColor := botRightColor.
|
|
1247 |
botRightColor := t.
|
|
1248 |
].
|
31
|
1249 |
|
59
|
1250 |
"/ self foreground:topLeftColor.
|
|
1251 |
self paint:topLeftColor.
|
|
1252 |
self displayForm:form x:x y:y.
|
|
1253 |
"/ self foreground:botRightColor.
|
|
1254 |
self paint:botRightColor.
|
|
1255 |
self displayForm:form2 x:x y:y.
|
22
|
1256 |
]
|
|
1257 |
!
|
|
1258 |
|
0
|
1259 |
redrawElement:aNumber
|
|
1260 |
"redraw an individual element"
|
|
1261 |
|
|
1262 |
^ self redrawLine:aNumber
|
|
1263 |
!
|
|
1264 |
|
|
1265 |
redrawVisibleLine:visLineNr col:colNr
|
31
|
1266 |
"redraw a single character.
|
|
1267 |
Must check, if its in the selection and handle this case."
|
|
1268 |
|
0
|
1269 |
(self visibleLineNeedsSpecialCare:visLineNr) ifTrue:[
|
59
|
1270 |
^ self redrawVisibleLine:visLineNr
|
0
|
1271 |
].
|
|
1272 |
super redrawVisibleLine:visLineNr col:colNr
|
|
1273 |
!
|
|
1274 |
|
|
1275 |
redrawVisibleLine:visLineNr from:startCol
|
31
|
1276 |
"redraw from a col to the right end.
|
|
1277 |
Must check, if its in the selection and handle this case."
|
|
1278 |
|
0
|
1279 |
(self visibleLineNeedsSpecialCare:visLineNr) ifTrue:[
|
59
|
1280 |
^ self redrawVisibleLine:visLineNr
|
0
|
1281 |
].
|
|
1282 |
super redrawVisibleLine:visLineNr from:startCol
|
|
1283 |
!
|
|
1284 |
|
|
1285 |
redrawVisibleLine:visLineNr from:startCol to:endCol
|
31
|
1286 |
"redraw from a startCol to endCol.
|
|
1287 |
Must check, if its in the selection and handle this case."
|
|
1288 |
|
0
|
1289 |
(self visibleLineNeedsSpecialCare:visLineNr) ifTrue:[
|
59
|
1290 |
^ self redrawVisibleLine:visLineNr
|
0
|
1291 |
].
|
|
1292 |
super redrawVisibleLine:visLineNr from:startCol to:endCol
|
|
1293 |
!
|
|
1294 |
|
|
1295 |
redrawFromVisibleLine:startVisLineNr to:endVisLineNr
|
31
|
1296 |
"redraw a range of lines.
|
|
1297 |
Must check, if any is in the selection and handle this case.
|
|
1298 |
Otherwise draw it en-bloque using supers method."
|
|
1299 |
|
0
|
1300 |
|special sel
|
|
1301 |
selNo "{ Class: SmallInteger }" |
|
|
1302 |
|
|
1303 |
((selection isKindOf:Collection) or:[listAttributes notNil]) ifTrue:[
|
59
|
1304 |
startVisLineNr to:endVisLineNr do:[:visLine |
|
|
1305 |
self redrawVisibleLine:visLine
|
|
1306 |
].
|
|
1307 |
^ self
|
0
|
1308 |
].
|
|
1309 |
|
31
|
1310 |
"XXX only if -1/+1"
|
|
1311 |
"/ hilightLevel ~~ 0 ifTrue:[
|
|
1312 |
"/ self paint:bgColor.
|
59
|
1313 |
"/ self fillRectangleX:0 y:(self yOfVisibleLine:startVisLineNr)-1 width:width height:1
|
31
|
1314 |
"/ ].
|
0
|
1315 |
special := true.
|
|
1316 |
selection isNil ifTrue:[
|
59
|
1317 |
special := false
|
0
|
1318 |
] ifFalse:[
|
59
|
1319 |
sel := self listLineToVisibleLine:selection.
|
|
1320 |
sel isNil ifTrue:[
|
|
1321 |
special := false
|
|
1322 |
] ifFalse:[
|
|
1323 |
special := (sel between:startVisLineNr and:endVisLineNr)
|
|
1324 |
]
|
0
|
1325 |
].
|
|
1326 |
special ifFalse:[
|
|
1327 |
^ super redrawFromVisibleLine:startVisLineNr
|
59
|
1328 |
to:endVisLineNr
|
0
|
1329 |
].
|
|
1330 |
|
|
1331 |
selNo := sel.
|
|
1332 |
selNo > startVisLineNr ifTrue:[
|
59
|
1333 |
super redrawFromVisibleLine:startVisLineNr to:(selNo - 1)
|
0
|
1334 |
].
|
|
1335 |
self redrawVisibleLine:selNo.
|
|
1336 |
selNo < endVisLineNr ifTrue:[
|
59
|
1337 |
super redrawFromVisibleLine:(selNo + 1) to:endVisLineNr
|
0
|
1338 |
]
|
|
1339 |
!
|
|
1340 |
|
|
1341 |
redrawVisibleLine:visLineNr
|
31
|
1342 |
"redraw a single line.
|
|
1343 |
Must check, if any is in the selection and handle this case.
|
|
1344 |
Otherwise draw using supers method."
|
|
1345 |
|
65
|
1346 |
|listLine fg bg attr oldFont newFont|
|
0
|
1347 |
|
|
1348 |
fg := fgColor.
|
|
1349 |
bg := bgColor.
|
|
1350 |
listLine := self visibleLineToListLine:visLineNr.
|
|
1351 |
listLine notNil ifTrue:[
|
59
|
1352 |
(self isInSelection:listLine) ifTrue:[
|
|
1353 |
^ self drawVisibleLineSelected:visLineNr
|
|
1354 |
].
|
63
|
1355 |
(self line:listLine hasAttribute:#halfIntensity) ifTrue:[
|
|
1356 |
fg := halfIntensityFgColor
|
|
1357 |
] ifFalse:[
|
|
1358 |
(self line:listLine hasAttribute:#disabled) ifTrue:[
|
60
|
1359 |
fg := halfIntensityFgColor
|
65
|
1360 |
].
|
|
1361 |
].
|
|
1362 |
(self line:listLine hasAttribute:#bold) ifTrue:[
|
|
1363 |
font bold ifTrue:[
|
77
|
1364 |
"
|
|
1365 |
mhmh - what can be done, if the font is already bold ?
|
|
1366 |
"
|
|
1367 |
newFont := font.
|
|
1368 |
fgColor brightness > 0.5 ifTrue:[
|
|
1369 |
fg := fgColor darkened darkened.
|
|
1370 |
] ifFalse:[
|
|
1371 |
fg := fgColor lightened lightened
|
|
1372 |
].
|
63
|
1373 |
] ifFalse:[
|
65
|
1374 |
newFont := font asBold
|
|
1375 |
].
|
|
1376 |
device setFont:(newFont on:device) fontId in:gcId.
|
|
1377 |
self drawVisibleLine:visLineNr with:fg and:bg.
|
|
1378 |
device setFont:(font on:device) fontId in:gcId.
|
|
1379 |
^ self
|
63
|
1380 |
]
|
31
|
1381 |
].
|
|
1382 |
^ self drawVisibleLine:visLineNr with:fg and:bg
|
|
1383 |
!
|
|
1384 |
|
|
1385 |
drawVisibleLineSelected:visLineNr
|
|
1386 |
"redraw a single line as selected."
|
|
1387 |
|
|
1388 |
|listLine fg bg
|
|
1389 |
y "{ Class: SmallInteger }"
|
|
1390 |
wEdge|
|
|
1391 |
|
|
1392 |
bg := hilightBgColor.
|
|
1393 |
fg := hilightFgColor.
|
|
1394 |
listLine := self visibleLineToListLine:visLineNr.
|
|
1395 |
listLine notNil ifTrue:[
|
|
1396 |
"XXX only if -1/+1"
|
|
1397 |
"/ hilightLevel ~~ 0 ifTrue:[
|
|
1398 |
"/ self paint:bg.
|
59
|
1399 |
"/ self fillRectangleX:0 y:(self yOfVisibleLine:visLineNr)-1 width:width height:1
|
31
|
1400 |
"/ ].
|
|
1401 |
|
63
|
1402 |
strikeOut ifTrue:[
|
|
1403 |
self drawVisibleLine:visLineNr with:fgColor and:bgColor.
|
|
1404 |
y := self yOfVisibleLine:visLineNr.
|
|
1405 |
|
|
1406 |
self paint:fgColor.
|
|
1407 |
y := y + (fontHeight // 2).
|
|
1408 |
self displayLineFromX:0 y:y toX:width y:y.
|
|
1409 |
^ self
|
|
1410 |
].
|
|
1411 |
|
59
|
1412 |
self drawVisibleLine:visLineNr with:fg and:bg.
|
|
1413 |
y := self yOfVisibleLine:visLineNr.
|
31
|
1414 |
|
59
|
1415 |
"
|
|
1416 |
a line above and below
|
|
1417 |
"
|
|
1418 |
hilightFrameColor notNil ifTrue:[
|
|
1419 |
self paint:hilightFrameColor.
|
|
1420 |
self displayLineFromX:0 y:y toX:width y:y.
|
|
1421 |
y := y + fontHeight - 1.
|
|
1422 |
self displayLineFromX:0 y:y toX:width y:y.
|
|
1423 |
^ self
|
|
1424 |
].
|
31
|
1425 |
|
59
|
1426 |
"
|
|
1427 |
an edge it around
|
|
1428 |
"
|
|
1429 |
(hilightLevel ~~ 0) ifTrue:[
|
31
|
1430 |
"XXX the -1/+1 need some more work"
|
|
1431 |
"/ self drawEdgesForX:0 y:y-1
|
|
1432 |
"/ width:width height:fontHeight+1
|
|
1433 |
"/ level:hilightLevel.
|
|
1434 |
|
59
|
1435 |
"
|
|
1436 |
let edge start at left, extending to the full width
|
|
1437 |
XXX: widthOfContents should be cached in ListView
|
60
|
1438 |
(instead of recomputing all over)
|
59
|
1439 |
"
|
|
1440 |
wEdge := width-(2 * margin).
|
60
|
1441 |
includesNonStrings ifFalse:[
|
59
|
1442 |
wEdge := wEdge max:(self widthOfContents).
|
60
|
1443 |
].
|
59
|
1444 |
self drawEdgesForX:(margin - leftOffset) y:y
|
|
1445 |
width:wEdge height:fontHeight
|
|
1446 |
level:hilightLevel.
|
31
|
1447 |
|
|
1448 |
|
59
|
1449 |
^ self
|
|
1450 |
]
|
0
|
1451 |
].
|
31
|
1452 |
^ super drawVisibleLine:visLineNr with:fg and:bg
|
0
|
1453 |
! !
|
|
1454 |
|
|
1455 |
!SelectionInListView methodsFor:'event handling'!
|
|
1456 |
|
|
1457 |
sizeChanged:how
|
|
1458 |
"if there is a selection, make certain, its visible
|
|
1459 |
after the sizechange"
|
|
1460 |
|
63
|
1461 |
|first wasAtEnd|
|
|
1462 |
|
|
1463 |
wasAtEnd := (firstLineShown + nFullLinesShown) >= list size.
|
0
|
1464 |
|
|
1465 |
super sizeChanged:how.
|
63
|
1466 |
|
0
|
1467 |
shown ifTrue:[
|
59
|
1468 |
selection notNil ifTrue:[
|
|
1469 |
(selection isKindOf:Collection) ifTrue:[
|
65
|
1470 |
selection notEmpty ifTrue:[
|
63
|
1471 |
first := selection first
|
|
1472 |
]
|
59
|
1473 |
] ifFalse:[
|
|
1474 |
first := selection
|
|
1475 |
].
|
65
|
1476 |
first notNil ifTrue:[self makeLineVisible:first]
|
63
|
1477 |
] ifFalse:[
|
65
|
1478 |
"
|
|
1479 |
if we where at the end before, move to the end again.
|
63
|
1480 |
Still to be seen, if this is better in real life ...
|
|
1481 |
"
|
|
1482 |
wasAtEnd ifTrue:[
|
|
1483 |
"at end"
|
|
1484 |
self scrollToBottom
|
|
1485 |
]
|
59
|
1486 |
]
|
0
|
1487 |
]
|
|
1488 |
!
|
|
1489 |
|
38
|
1490 |
key:key select:selectAction x:x y:y
|
|
1491 |
"perform keyaction after a key-select"
|
|
1492 |
|
|
1493 |
keyActionStyle notNil ifTrue:[
|
59
|
1494 |
keyActionStyle == #pass ifTrue:[
|
|
1495 |
^ super keyPress:key x:x y:y
|
|
1496 |
].
|
|
1497 |
selectAction value.
|
|
1498 |
actionBlock notNil ifTrue:[actionBlock value:selection].
|
|
1499 |
keyActionStyle == #selectAndDoubleClick ifTrue:[
|
|
1500 |
doubleClickActionBlock notNil ifTrue:[doubleClickActionBlock value:selection].
|
|
1501 |
]
|
38
|
1502 |
].
|
|
1503 |
!
|
|
1504 |
|
0
|
1505 |
keyPress:key x:x y:y
|
|
1506 |
"handle keyboard input"
|
|
1507 |
|
63
|
1508 |
|index startSearch backSearch searchPrefix|
|
38
|
1509 |
|
0
|
1510 |
(keyboardHandler notNil
|
|
1511 |
and:[keyboardHandler canHandle:key]) ifTrue:[
|
59
|
1512 |
keyboardHandler keyPress:key x:x y:y.
|
|
1513 |
^ self
|
|
1514 |
].
|
|
1515 |
(key == #CursorUp) ifTrue:[
|
60
|
1516 |
index := self previousBeforeSelection.
|
|
1517 |
(selectConditionBlock isNil or:[selectConditionBlock value:index]) ifTrue:[
|
|
1518 |
self key:key select:[self selection:index] x:x y:y
|
59
|
1519 |
].
|
|
1520 |
^ self
|
0
|
1521 |
].
|
59
|
1522 |
(key == #CursorDown) ifTrue:[
|
60
|
1523 |
index := self nextAfterSelection.
|
|
1524 |
(selectConditionBlock isNil or:[selectConditionBlock value:index]) ifTrue:[
|
|
1525 |
self key:key select:[self selection:index] x:x y:y
|
59
|
1526 |
].
|
|
1527 |
^ self
|
|
1528 |
].
|
|
1529 |
(key == #Home) ifTrue:[
|
60
|
1530 |
(selectConditionBlock isNil or:[selectConditionBlock value:1]) ifTrue:[
|
59
|
1531 |
self key:key select:[self selection:1] x:x y:y
|
|
1532 |
].
|
|
1533 |
^ self
|
|
1534 |
].
|
|
1535 |
(key == #End) ifTrue:[
|
60
|
1536 |
index := list size.
|
|
1537 |
(selectConditionBlock isNil or:[selectConditionBlock value:index]) ifTrue:[
|
|
1538 |
self key:key select:[self selection:index] x:x y:y
|
59
|
1539 |
].
|
|
1540 |
^ self
|
38
|
1541 |
].
|
|
1542 |
key == #Return ifTrue:[
|
59
|
1543 |
selection notNil ifTrue:[
|
|
1544 |
doubleClickActionBlock notNil ifTrue:[
|
|
1545 |
doubleClickActionBlock value:selection
|
|
1546 |
].
|
63
|
1547 |
].
|
|
1548 |
^ self
|
38
|
1549 |
].
|
|
1550 |
"
|
|
1551 |
alphabetic keys: search for next entry
|
63
|
1552 |
starting with keys character. If shift is pressed, search backward
|
38
|
1553 |
"
|
63
|
1554 |
(list size > 0
|
|
1555 |
and:[key isCharacter
|
|
1556 |
and:[key isLetter]]) ifTrue:[
|
|
1557 |
keyActionStyle isNil ifTrue:[^ self].
|
|
1558 |
keyActionStyle == #pass ifFalse:[
|
|
1559 |
searchPrefix := key asLowercase asString.
|
|
1560 |
|
|
1561 |
"/ ... isISearch... ifFalse:[
|
|
1562 |
"/ iSearchString := ''
|
|
1563 |
"/ ] ifTrue:[
|
|
1564 |
"/ iSearchString := iSearchString , searchPrefix.
|
|
1565 |
"/ searchPrefix := iSearchString
|
|
1566 |
"/ ].
|
|
1567 |
|
|
1568 |
backSearch := device shiftDown.
|
|
1569 |
backSearch ifTrue:[
|
|
1570 |
selection notNil ifTrue:[
|
|
1571 |
selection size > 0 ifTrue:[
|
|
1572 |
startSearch := selection first - 1
|
59
|
1573 |
] ifFalse:[
|
63
|
1574 |
startSearch := selection - 1
|
|
1575 |
]
|
|
1576 |
] ifFalse:[
|
|
1577 |
startSearch := list size
|
|
1578 |
].
|
|
1579 |
startSearch < 1 ifTrue:[
|
|
1580 |
startSearch := list size.
|
|
1581 |
].
|
|
1582 |
] ifFalse:[
|
|
1583 |
selection notNil ifTrue:[
|
|
1584 |
selection size > 0 ifTrue:[
|
|
1585 |
startSearch := selection last + 1
|
|
1586 |
] ifFalse:[
|
|
1587 |
startSearch := selection + 1
|
59
|
1588 |
]
|
63
|
1589 |
] ifFalse:[
|
|
1590 |
startSearch := 1
|
|
1591 |
].
|
|
1592 |
startSearch > list size ifTrue:[
|
|
1593 |
startSearch := 1.
|
|
1594 |
].
|
|
1595 |
].
|
|
1596 |
index := startSearch.
|
|
1597 |
[true] whileTrue:[
|
|
1598 |
(((list at:index) asString) asLowercase startsWith:searchPrefix) ifTrue:[
|
|
1599 |
index = selection ifTrue:[^ self].
|
|
1600 |
^ self key:key select:[self selection:index] x:x y:y
|
|
1601 |
].
|
|
1602 |
backSearch ifTrue:[
|
|
1603 |
index := index - 1.
|
|
1604 |
index < 1 ifTrue:[index := list size]
|
|
1605 |
] ifFalse:[
|
|
1606 |
index := index + 1.
|
|
1607 |
index > list size ifTrue:[index := 1].
|
|
1608 |
].
|
|
1609 |
index == startSearch ifTrue:[
|
|
1610 |
^ self
|
59
|
1611 |
]
|
|
1612 |
]
|
|
1613 |
].
|
3
|
1614 |
].
|
|
1615 |
^ super keyPress:key x:x y:y
|
0
|
1616 |
!
|
|
1617 |
|
|
1618 |
buttonPress:button x:x y:y
|
7
|
1619 |
|oldSelection listLineNr|
|
0
|
1620 |
|
31
|
1621 |
((button == 1) or:[button == #select]) ifTrue:[
|
59
|
1622 |
enabled ifTrue:[
|
60
|
1623 |
listLineNr := self visibleLineToListLine:(self visibleLineOfY:y).
|
|
1624 |
listLineNr notNil ifTrue:[
|
63
|
1625 |
(toggleSelect
|
|
1626 |
and:[self isInSelection:listLineNr]) ifTrue:[
|
70
|
1627 |
oldSelection := selection copy.
|
63
|
1628 |
self removeFromSelection:listLineNr
|
|
1629 |
] ifFalse:[
|
|
1630 |
(self line:listLineNr hasAttribute:#disabled) ifTrue:[^ self].
|
|
1631 |
|
|
1632 |
(selectConditionBlock notNil
|
|
1633 |
and:[(selectConditionBlock value:listLineNr) not]) ifTrue:[^ self].
|
60
|
1634 |
|
63
|
1635 |
(toggleSelect and:[multipleSelectOk]) ifTrue:[
|
70
|
1636 |
oldSelection := selection copy.
|
63
|
1637 |
self addToSelection:listLineNr
|
|
1638 |
] ifFalse:[
|
70
|
1639 |
oldSelection := selection copy.
|
63
|
1640 |
self selectWithoutScroll:listLineNr.
|
|
1641 |
].
|
|
1642 |
].
|
|
1643 |
((ignoreReselect not and:[selection notNil])
|
|
1644 |
or:[selection ~= oldSelection]) ifTrue:[
|
|
1645 |
"
|
|
1646 |
the ST/X way of doing things - perform actionBlock
|
|
1647 |
"
|
|
1648 |
actionBlock notNil ifTrue:[actionBlock value:selection].
|
|
1649 |
"
|
|
1650 |
the ST-80 way of doing things - notify model via changeSymbol
|
|
1651 |
"
|
|
1652 |
(model notNil and:[changeSymbol notNil]) ifTrue:[
|
|
1653 |
model perform:changeSymbol with:(self selectionValue)
|
|
1654 |
]
|
|
1655 |
].
|
|
1656 |
clickLine := listLineNr
|
60
|
1657 |
].
|
59
|
1658 |
]
|
0
|
1659 |
] ifFalse:[
|
59
|
1660 |
super buttonPress:button x:x y:y
|
0
|
1661 |
]
|
|
1662 |
!
|
|
1663 |
|
|
1664 |
buttonShiftPress:button x:x y:y
|
|
1665 |
|oldSelection listLineNr|
|
|
1666 |
|
31
|
1667 |
((button == 1) or:[button == #select]) ifTrue:[
|
63
|
1668 |
toggleSelect ifTrue:[
|
|
1669 |
^ self buttonPress:button x:x y:y
|
|
1670 |
].
|
59
|
1671 |
enabled ifTrue:[
|
60
|
1672 |
listLineNr := self visibleLineToListLine:(self visibleLineOfY:y).
|
|
1673 |
listLineNr notNil ifTrue:[
|
|
1674 |
(self line:listLineNr hasAttribute:#disabled) ifTrue:[^ self].
|
|
1675 |
|
|
1676 |
(selectConditionBlock notNil
|
|
1677 |
and:[(selectConditionBlock value:listLineNr) not]) ifTrue:[^ self].
|
|
1678 |
].
|
|
1679 |
oldSelection := selection copy.
|
|
1680 |
listLineNr notNil ifTrue: [
|
|
1681 |
multipleSelectOk ifTrue:[
|
|
1682 |
(self isInSelection:listLineNr) ifTrue:[
|
|
1683 |
self removeFromSelection:listLineNr
|
59
|
1684 |
] ifFalse:[
|
60
|
1685 |
self addToSelection:listLineNr
|
59
|
1686 |
]
|
60
|
1687 |
] ifFalse:[
|
|
1688 |
self selectWithoutScroll:listLineNr
|
|
1689 |
]
|
|
1690 |
].
|
|
1691 |
(selection ~= oldSelection) ifTrue:[
|
|
1692 |
actionBlock notNil ifTrue:[actionBlock value:selection].
|
|
1693 |
"the ST-80 way of doing things"
|
|
1694 |
(model notNil and:[changeSymbol notNil]) ifTrue:[
|
|
1695 |
model perform:changeSymbol with:(self selectionValue)
|
|
1696 |
]
|
|
1697 |
].
|
|
1698 |
clickLine := listLineNr
|
59
|
1699 |
]
|
0
|
1700 |
] ifFalse:[
|
59
|
1701 |
super buttonShiftPress:button x:x y:y
|
0
|
1702 |
]
|
|
1703 |
!
|
|
1704 |
|
|
1705 |
buttonMultiPress:button x:x y:y
|
31
|
1706 |
((button == 1) or:[button == #select]) ifTrue:[
|
59
|
1707 |
doubleClickActionBlock isNil ifTrue:[
|
|
1708 |
self buttonPress:button x:x y:y
|
|
1709 |
] ifFalse:[
|
|
1710 |
doubleClickActionBlock value:selection
|
|
1711 |
]
|
0
|
1712 |
] ifFalse:[
|
59
|
1713 |
super buttonMultiPress:button x:x y:y
|
0
|
1714 |
]
|
|
1715 |
!
|
|
1716 |
|
|
1717 |
buttonRelease:button x:x y:y
|
|
1718 |
"stop any autoscroll"
|
|
1719 |
|
|
1720 |
self stopAutoScroll
|
|
1721 |
!
|
|
1722 |
|
63
|
1723 |
buttonMotion:buttonMask x:x y:y
|
0
|
1724 |
"mouse-move while button was pressed - handle selection changes"
|
|
1725 |
|
|
1726 |
|movedVisibleLine movedLine delta oldSelection oldSelCount|
|
|
1727 |
|
63
|
1728 |
"is it the select or 1-button ?"
|
|
1729 |
(device buttonMotionMask:buttonMask includesButton:#select) ifFalse:[
|
|
1730 |
(device buttonMotionMask:buttonMask includesButton:1) ifFalse:[
|
|
1731 |
^ self
|
|
1732 |
].
|
|
1733 |
].
|
|
1734 |
|
0
|
1735 |
clickLine isNil ifTrue:[^ self].
|
|
1736 |
|
|
1737 |
"if moved outside of view, start autoscroll"
|
|
1738 |
(y < 0) ifTrue:[
|
59
|
1739 |
self compressMotionEvents:false.
|
|
1740 |
self startAutoScrollUp:y.
|
|
1741 |
^ self
|
0
|
1742 |
].
|
|
1743 |
(y > height) ifTrue:[
|
59
|
1744 |
self compressMotionEvents:false.
|
|
1745 |
self startAutoScrollDown:(y - height).
|
|
1746 |
^ self
|
0
|
1747 |
].
|
|
1748 |
|
|
1749 |
"move inside - stop autoscroll if any"
|
|
1750 |
self stopAutoScroll.
|
|
1751 |
|
|
1752 |
movedVisibleLine := self visibleLineOfY:y.
|
|
1753 |
movedLine := self visibleLineToAbsoluteLine:movedVisibleLine.
|
|
1754 |
(movedLine == clickLine) ifTrue:[^ self].
|
|
1755 |
|
|
1756 |
multipleSelectOk ifTrue:[
|
59
|
1757 |
delta := (clickLine < movedLine) ifTrue:[1] ifFalse:[-1].
|
0
|
1758 |
|
59
|
1759 |
oldSelection := selection.
|
|
1760 |
oldSelCount := selection size.
|
0
|
1761 |
|
59
|
1762 |
(clickLine+delta) to:movedLine by:delta do:[:line |
|
|
1763 |
(self isInSelection:line) ifTrue:[
|
|
1764 |
self removeFromSelection:line
|
|
1765 |
] ifFalse:[
|
|
1766 |
self addToSelection:line
|
|
1767 |
]
|
|
1768 |
].
|
|
1769 |
((selection ~= oldSelection)
|
|
1770 |
or:[selection size ~~ oldSelCount]) ifTrue:[
|
|
1771 |
actionBlock notNil ifTrue:[actionBlock value:selection]
|
|
1772 |
]
|
0
|
1773 |
] ifFalse:[
|
59
|
1774 |
self selectWithoutScroll:movedLine
|
0
|
1775 |
].
|
|
1776 |
|
|
1777 |
clickLine := movedLine
|
|
1778 |
!
|
|
1779 |
|
|
1780 |
update:aParameter
|
|
1781 |
|newList|
|
|
1782 |
|
|
1783 |
(aParameter == initialSelectionSymbol) ifTrue:[
|
59
|
1784 |
self selectElement:(model perform:initialSelectionSymbol).
|
|
1785 |
^ self
|
0
|
1786 |
].
|
|
1787 |
(aParameter == listSymbol) ifTrue:[
|
59
|
1788 |
newList := (model perform:listSymbol) asText.
|
|
1789 |
(newList = list) ifFalse:[
|
|
1790 |
self list:newList
|
|
1791 |
]
|
0
|
1792 |
]
|
|
1793 |
! !
|