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