0
|
1 |
"
|
5
|
2 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
0
|
3 |
All Rights Reserved
|
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
|
12 |
|
|
13 |
ListView subclass:#SelectionInListView
|
|
14 |
instanceVariableNames:'selection actionBlock enabled
|
|
15 |
hilightFgColor hilightBgColor
|
|
16 |
halfIntensityFgColor
|
|
17 |
doubleClickActionBlock
|
3
|
18 |
selectConditionBlock
|
0
|
19 |
listAttributes multipleSelectOk clickLine
|
7
|
20 |
listSymbol initialSelectionSymbol printItems oneItem
|
31
|
21 |
hilightLevel hilightFrameColor ignoreReselect
|
38
|
22 |
arrowLevel smallArrow keyActionStyle'
|
31
|
23 |
classVariableNames: 'RightArrowShadowForm RightArrowLightForm RightArrowForm
|
|
24 |
SmallRightArrowShadowForm SmallRightArrowLightForm'
|
0
|
25 |
poolDictionaries:''
|
|
26 |
category:'Views-Text'
|
|
27 |
!
|
|
28 |
|
|
29 |
SelectionInListView comment:'
|
5
|
30 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
0
|
31 |
All Rights Reserved
|
38
|
32 |
|
51
|
33 |
$Header: /cvs/stx/stx/libwidg/Attic/SelListV.st,v 1.10 1994-08-23 23:38:59 claus Exp $
|
7
|
34 |
'!
|
0
|
35 |
|
7
|
36 |
!SelectionInListView class methodsFor:'documentation'!
|
|
37 |
|
38
|
38 |
copyright
|
|
39 |
"
|
|
40 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
|
41 |
All Rights Reserved
|
|
42 |
|
|
43 |
This software is furnished under a license and may be used
|
|
44 |
only in accordance with the terms of that license and with the
|
|
45 |
inclusion of the above copyright notice. This software may not
|
|
46 |
be provided or otherwise made available to, or used by, any
|
|
47 |
other person. No title to or ownership of the software is
|
|
48 |
hereby transferred.
|
|
49 |
"
|
|
50 |
!
|
|
51 |
|
|
52 |
version
|
|
53 |
"
|
51
|
54 |
$Header: /cvs/stx/stx/libwidg/Attic/SelListV.st,v 1.10 1994-08-23 23:38:59 claus Exp $
|
38
|
55 |
"
|
|
56 |
!
|
|
57 |
|
7
|
58 |
documentation
|
|
59 |
"
|
31
|
60 |
this one is a ListView with a selected line (which is shown highlighted)
|
38
|
61 |
If multipleSelectionsOk is true, it is also allowed to shift-click multiple
|
|
62 |
entries.
|
31
|
63 |
|
38
|
64 |
Whenever the selection changes, an action-block is evaluated, passing the
|
|
65 |
current selection as argument.
|
|
66 |
Currently, the selection can be nil, aNumber or a collection of numbers;
|
|
67 |
this will change to be either nil or a collection, making selection handling
|
|
68 |
easier in the future.
|
31
|
69 |
The actionBlock is called with the current selection as argument.
|
|
70 |
|
38
|
71 |
It is also possible to select entries with the keyboard; use the cursor up/
|
|
72 |
down keys to select prev/next, Home- and End-keys to select first/last.
|
|
73 |
Use the return key to apply the double-click-action to the current selection.
|
|
74 |
Also, alphabetic keys will select the next entry starting with that key.
|
|
75 |
|
|
76 |
The keyboard behavior can be further controlled with the keyActionStyle
|
|
77 |
instance variable (see SelectionInListView>>keyActionStyle:).
|
|
78 |
|
|
79 |
|
31
|
80 |
InstanceVariables:
|
|
81 |
selection <misc> the current selection. nil, a number or collection of numbers
|
|
82 |
|
|
83 |
actionBlock <Block> block to be evaluated on selection changes
|
|
84 |
|
|
85 |
enabled <Boolean> true: selection changes allowed; false: ignore clicks
|
|
86 |
|
|
87 |
hilightFgColor
|
|
88 |
hilightBgColor <Color> how highlighted items are drawn
|
|
89 |
|
|
90 |
halfIntensityColor <Color> foreground for disabled items
|
|
91 |
|
|
92 |
selectConditionBlock <Block> if non-nil, this nlock can decide if selection is ok
|
0
|
93 |
|
31
|
94 |
doubleClickActionBlock <Block> action to perform on double-click
|
|
95 |
|
|
96 |
listAttributes dont use - will vanish
|
|
97 |
|
|
98 |
multipleSelectOk <Boolean> if true, multiple selections (with shift) are ok
|
|
99 |
hilightLevel <Integer> level to draw selections (i.e. for 3D effect)
|
|
100 |
hilightFrameColor <Color> rectangle around highlighted items
|
|
101 |
|
|
102 |
ignoreReselect <Boolean> if true, selecting same again does not trigger action;
|
|
103 |
if false, every select triggers it
|
0
|
104 |
|
31
|
105 |
arrowLevel <Integer> level to draw right-arrows (for submenus etc.)
|
|
106 |
smallArrow <Boolean> if true, uses a small arrow bitmap
|
|
107 |
|
|
108 |
listSymbol if non-nil, use ST-80 style (model-access)
|
|
109 |
initialSelectionSymbol
|
|
110 |
printItems
|
|
111 |
oneItem
|
|
112 |
|
38
|
113 |
keyActionStyle <Symbol> controls how to respond to keyboard selects
|
31
|
114 |
|
|
115 |
written spring/summer 89 by claus
|
|
116 |
3D Jan 90 by claus
|
38
|
117 |
multiselect Jun 92 by claus
|
|
118 |
keyboard-select jun 94 by claus
|
7
|
119 |
"
|
|
120 |
! !
|
0
|
121 |
|
22
|
122 |
!SelectionInListView class methodsFor:'defaults'!
|
|
123 |
|
|
124 |
rightArrowLightFormOn:aDevice
|
|
125 |
"return the form used for the right arrow light pixels (3D only)"
|
|
126 |
|
|
127 |
|f|
|
|
128 |
|
|
129 |
((aDevice == Display) and:[RightArrowLightForm notNil]) ifTrue:[
|
|
130 |
^ RightArrowLightForm
|
|
131 |
].
|
|
132 |
f := Form fromFile:'RightArrowLight.xbm' resolution:100 on:aDevice.
|
|
133 |
f isNil ifTrue:[
|
|
134 |
f := Form width:16 height:16 fromArray:#(2r00000000 2r00000000
|
|
135 |
2r00000000 2r00000000
|
|
136 |
2r00000000 2r00000000
|
|
137 |
2r00000110 2r00000000
|
|
138 |
2r00000101 2r00000000
|
|
139 |
2r00000100 2r10000000
|
|
140 |
2r00000100 2r01000000
|
|
141 |
2r00000100 2r00100000
|
|
142 |
2r00000100 2r00000000
|
|
143 |
2r00000100 2r00000000
|
|
144 |
2r00000100 2r00000000
|
|
145 |
2r00000100 2r00000000
|
|
146 |
2r00000100 2r00000000
|
|
147 |
2r00000100 2r00000000
|
|
148 |
2r00000000 2r00000000
|
|
149 |
2r00000000 2r00000000)
|
|
150 |
on:aDevice
|
|
151 |
].
|
|
152 |
(aDevice == Display) ifTrue:[
|
|
153 |
RightArrowLightForm := f
|
|
154 |
].
|
|
155 |
^ f
|
|
156 |
!
|
|
157 |
|
|
158 |
rightArrowShadowFormOn:aDevice
|
|
159 |
"return the form used for the right arrow light pixels (3D only)"
|
|
160 |
|
|
161 |
|f|
|
|
162 |
|
|
163 |
((aDevice == Display) and:[RightArrowShadowForm notNil]) ifTrue:[
|
|
164 |
^ RightArrowShadowForm
|
|
165 |
].
|
|
166 |
f := Form fromFile:'RightArrowShadow.xbm' resolution:100 on:aDevice.
|
|
167 |
f isNil ifTrue:[
|
|
168 |
f := Form width:16 height:16 fromArray:#(2r00000000 2r00000000
|
|
169 |
2r00000000 2r00000000
|
|
170 |
2r00000000 2r00000000
|
|
171 |
2r00000000 2r00000000
|
|
172 |
2r00000000 2r00000000
|
|
173 |
2r00000000 2r00000000
|
|
174 |
2r00000000 2r00000000
|
|
175 |
2r00000000 2r00000000
|
|
176 |
2r00000000 2r00010000
|
|
177 |
2r00000000 2r00100000
|
|
178 |
2r00000000 2r01000000
|
|
179 |
2r00000000 2r10000000
|
|
180 |
2r00000001 2r00000000
|
|
181 |
2r00000010 2r00000000
|
|
182 |
2r00000000 2r00000000
|
|
183 |
2r00000000 2r00000000)
|
|
184 |
on:aDevice
|
|
185 |
].
|
|
186 |
(aDevice == Display) ifTrue:[
|
|
187 |
RightArrowShadowForm := f
|
|
188 |
].
|
|
189 |
^ f
|
|
190 |
!
|
|
191 |
|
|
192 |
rightArrowFormOn:aDevice
|
|
193 |
"return the form used for the right arrow (non 3D)"
|
|
194 |
|
|
195 |
|f|
|
|
196 |
|
|
197 |
((aDevice == Display) and:[RightArrowForm notNil]) ifTrue:[
|
|
198 |
^ RightArrowForm
|
|
199 |
].
|
|
200 |
f := Form fromFile:'RightArrow.xbm' resolution:100 on:aDevice.
|
|
201 |
f isNil ifTrue:[
|
|
202 |
f := Form width:16 height:16 fromArray:#(2r00000000 2r00000000
|
|
203 |
2r00000000 2r00000000
|
|
204 |
2r00000000 2r00000000
|
|
205 |
2r00000110 2r00000000
|
|
206 |
2r00000101 2r00000000
|
|
207 |
2r00000100 2r10000000
|
|
208 |
2r00000100 2r01000000
|
|
209 |
2r00000100 2r00100000
|
|
210 |
2r00000100 2r00010000
|
|
211 |
2r00000100 2r00100000
|
|
212 |
2r00000100 2r01000000
|
|
213 |
2r00000100 2r10000000
|
|
214 |
2r00000101 2r00000000
|
|
215 |
2r00000110 2r00000000
|
|
216 |
2r00000000 2r00000000
|
|
217 |
2r00000000 2r00000000)
|
|
218 |
on:aDevice
|
|
219 |
].
|
|
220 |
(aDevice == Display) ifTrue:[
|
|
221 |
RightArrowForm := f
|
|
222 |
].
|
|
223 |
^ f
|
31
|
224 |
!
|
|
225 |
|
|
226 |
smallRightArrowLightFormOn:aDevice
|
|
227 |
"return the form used for the small right arrow light pixels (3D only)"
|
|
228 |
|
|
229 |
|f|
|
|
230 |
|
|
231 |
((aDevice == Display) and:[SmallRightArrowLightForm notNil]) ifTrue:[
|
|
232 |
^ SmallRightArrowLightForm
|
|
233 |
].
|
|
234 |
f := Form fromFile:'SmallRightArrowLight.xbm' resolution:100 on:aDevice.
|
|
235 |
f isNil ifTrue:[
|
|
236 |
f := Form width:9 height:9 fromArray:#(2r00000000 2r00000000
|
|
237 |
2r01100000 2r00000000
|
|
238 |
2r01011000 2r00000000
|
|
239 |
2r01000110 2r00000000
|
|
240 |
2r01000000 2r00000000
|
|
241 |
2r01000000 2r00000000
|
|
242 |
2r01000000 2r00000000
|
|
243 |
2r01000000 2r00000000
|
|
244 |
2r00000000 2r00000000)
|
|
245 |
on:aDevice
|
|
246 |
].
|
|
247 |
(aDevice == Display) ifTrue:[
|
|
248 |
SmallRightArrowLightForm := f
|
|
249 |
].
|
|
250 |
^ f
|
|
251 |
!
|
|
252 |
|
|
253 |
smallRightArrowShadowFormOn:aDevice
|
|
254 |
"return the form used for the small right arrow light pixels (3D only)"
|
|
255 |
|
|
256 |
|f|
|
|
257 |
|
|
258 |
((aDevice == Display) and:[SmallRightArrowShadowForm notNil]) ifTrue:[
|
|
259 |
^ SmallRightArrowShadowForm
|
|
260 |
].
|
|
261 |
f := Form fromFile:'SmallRightArrowShadow.xbm' resolution:100 on:aDevice.
|
|
262 |
f isNil ifTrue:[
|
|
263 |
f := Form width:9 height:9 fromArray:#(2r00000000 2r00000000
|
|
264 |
2r00000000 2r00000000
|
|
265 |
2r00000000 2r00000000
|
|
266 |
2r00000000 2r00000000
|
|
267 |
2r00000001 2r00000000
|
|
268 |
2r00000110 2r00000000
|
|
269 |
2r00011000 2r00000000
|
|
270 |
2r00100000 2r00000000
|
|
271 |
2r00000000 2r00000000)
|
|
272 |
on:aDevice
|
|
273 |
].
|
|
274 |
(aDevice == Display) ifTrue:[
|
|
275 |
SmallRightArrowShadowForm := f
|
|
276 |
].
|
|
277 |
^ f
|
22
|
278 |
! !
|
|
279 |
|
0
|
280 |
!SelectionInListView class methodsFor:'instance creation'!
|
|
281 |
|
|
282 |
on:aModel printItems:print oneItem:one aspect:aspect
|
|
283 |
change:change list:list menu:menu
|
|
284 |
initialSelection:initial
|
|
285 |
|
|
286 |
"for ST-80 compatibility"
|
|
287 |
|
|
288 |
^ (self new) on:aModel printItems:print oneItem:one aspect:aspect
|
|
289 |
change:change list:list menu:menu
|
|
290 |
initialSelection:initial
|
|
291 |
! !
|
|
292 |
|
|
293 |
!SelectionInListView methodsFor:'initialization'!
|
|
294 |
|
|
295 |
initialize
|
|
296 |
super initialize.
|
|
297 |
|
|
298 |
fontHeight := font height + lineSpacing.
|
|
299 |
multipleSelectOk := false.
|
7
|
300 |
enabled := true.
|
|
301 |
ignoreReselect := true.
|
38
|
302 |
keyActionStyle := #select.
|
0
|
303 |
!
|
|
304 |
|
|
305 |
initStyle
|
|
306 |
super initStyle.
|
|
307 |
|
|
308 |
bgColor := viewBackground.
|
7
|
309 |
hilightFrameColor := nil.
|
|
310 |
hilightLevel := 0.
|
31
|
311 |
arrowLevel := 1.
|
|
312 |
smallArrow := false.
|
0
|
313 |
|
|
314 |
(style == #next) ifTrue:[
|
|
315 |
device hasGreyscales ifTrue:[
|
|
316 |
hilightFgColor := fgColor.
|
7
|
317 |
hilightBgColor := White.
|
|
318 |
hilightFrameColor := fgColor
|
0
|
319 |
] ifFalse:[
|
|
320 |
hilightFgColor := White.
|
|
321 |
hilightBgColor := Black
|
|
322 |
]
|
|
323 |
] ifFalse:[
|
7
|
324 |
(style == #motif) ifTrue:[
|
0
|
325 |
device hasGreyscales ifTrue:[
|
31
|
326 |
fgColor := White.
|
|
327 |
bgColor := Grey.
|
|
328 |
viewBackground := bgColor.
|
|
329 |
hilightFgColor := bgColor "fgColor" "White".
|
|
330 |
hilightBgColor := fgColor "bgColor lightened" "darkened".
|
|
331 |
hilightLevel := 0 "1".
|
|
332 |
arrowLevel := -1.
|
0
|
333 |
] ifFalse:[
|
|
334 |
hilightFgColor := White.
|
|
335 |
hilightBgColor := Black
|
|
336 |
]
|
|
337 |
] ifFalse:[
|
7
|
338 |
(style == #openwin) ifTrue:[
|
0
|
339 |
device hasGreyscales ifTrue:[
|
7
|
340 |
hilightFgColor := fgColor.
|
|
341 |
hilightBgColor := Color grey.
|
|
342 |
hilightLevel := -1.
|
31
|
343 |
arrowLevel := -1.
|
|
344 |
smallArrow := true.
|
0
|
345 |
] ifFalse:[
|
|
346 |
hilightFgColor := White.
|
|
347 |
hilightBgColor := Black
|
|
348 |
]
|
|
349 |
] ifFalse:[
|
7
|
350 |
(style == #iris) ifTrue:[
|
|
351 |
device hasGreyscales ifTrue:[
|
|
352 |
hilightFgColor := bgColor.
|
|
353 |
hilightBgColor := Black
|
0
|
354 |
] ifFalse:[
|
7
|
355 |
hilightFgColor := White.
|
0
|
356 |
hilightBgColor := Black
|
|
357 |
]
|
7
|
358 |
] ifFalse:[
|
31
|
359 |
(style == #view3D) ifTrue:[
|
7
|
360 |
device hasColors ifTrue:[
|
|
361 |
hilightFgColor := Color name:'yellow'
|
|
362 |
] ifFalse:[
|
|
363 |
hilightFgColor := White
|
|
364 |
].
|
|
365 |
device hasGreyscales ifTrue:[
|
|
366 |
hilightBgColor := viewBackground
|
|
367 |
] ifFalse:[
|
|
368 |
hilightBgColor := Black
|
|
369 |
]
|
|
370 |
]
|
0
|
371 |
]
|
|
372 |
]
|
|
373 |
]
|
|
374 |
].
|
|
375 |
|
31
|
376 |
(hilightLevel abs > 0) ifTrue:[
|
|
377 |
lineSpacing := 3
|
|
378 |
] ifFalse:[
|
|
379 |
lineSpacing := 2
|
|
380 |
].
|
|
381 |
|
0
|
382 |
hilightFgColor isNil ifTrue:[
|
|
383 |
hilightFgColor := bgColor.
|
|
384 |
hilightBgColor := fgColor
|
|
385 |
].
|
|
386 |
|
|
387 |
halfIntensityFgColor := Color darkGrey.
|
|
388 |
!
|
|
389 |
|
|
390 |
initCursor
|
|
391 |
"set the cursor - a hand"
|
|
392 |
|
|
393 |
cursor := Cursor hand
|
|
394 |
!
|
|
395 |
|
|
396 |
initEvents
|
|
397 |
super initEvents.
|
|
398 |
self enableButtonEvents
|
|
399 |
!
|
|
400 |
|
|
401 |
realize
|
|
402 |
super realize.
|
|
403 |
selection notNil ifTrue:[
|
|
404 |
self makeLineVisible:selection
|
|
405 |
]
|
|
406 |
! !
|
|
407 |
|
|
408 |
!SelectionInListView methodsFor:'accessing'!
|
|
409 |
|
|
410 |
multipleSelectOk:aBoolean
|
|
411 |
"allow/disallow multiple selections"
|
|
412 |
|
|
413 |
multipleSelectOk := aBoolean.
|
|
414 |
aBoolean ifTrue:[
|
|
415 |
self enableButtonMotionEvents
|
|
416 |
] ifFalse:[
|
|
417 |
self disableButtonMotionEvents
|
|
418 |
]
|
|
419 |
!
|
|
420 |
|
7
|
421 |
ignoreReselect:aBoolean
|
31
|
422 |
"set/clear the ignoreReselect flag -
|
|
423 |
if set, a click on an already selected entry is ignored.
|
7
|
424 |
Otherwise the notification is done, even if no
|
31
|
425 |
change in the selection occurs.
|
|
426 |
(for example, in browser to update a method)"
|
7
|
427 |
|
|
428 |
ignoreReselect := aBoolean
|
|
429 |
!
|
|
430 |
|
38
|
431 |
keyActionStyle:aSymbol
|
|
432 |
"defines how the view should respond to alpha-keys pressed.
|
|
433 |
Possible values are:
|
|
434 |
#select -> will select next entry starting with that
|
|
435 |
character and perform the click-action
|
|
436 |
|
|
437 |
#selectAndDoubleclick -> will select next & perform double-click action
|
|
438 |
|
|
439 |
#pass -> will pass key to superclass (i.e. no special treatment)
|
|
440 |
|
|
441 |
nil -> will ignore key
|
|
442 |
"
|
|
443 |
|
|
444 |
keyActionStyle := aSymbol
|
|
445 |
!
|
|
446 |
|
0
|
447 |
setList:aCollection
|
|
448 |
"set the list - redefined, since setting the list implies unselecting"
|
|
449 |
|
|
450 |
selection := nil.
|
|
451 |
super setList:aCollection
|
|
452 |
!
|
|
453 |
|
|
454 |
list:aCollection
|
|
455 |
"set the list - redefined, since setting the list implies unselecting"
|
|
456 |
|
7
|
457 |
"somewhat of a kludge: if selection is first line,
|
|
458 |
we have to remove the highlight frame by hand here"
|
|
459 |
|
|
460 |
(shown and:[hilightLevel ~~ 0]) ifTrue:[
|
|
461 |
selection == firstLineShown ifTrue:[
|
|
462 |
self paint:bgColor.
|
|
463 |
self fillRectangleX:margin y:margin
|
|
464 |
width:(width - (margin * 2))
|
|
465 |
height:(hilightLevel abs).
|
|
466 |
].
|
|
467 |
].
|
|
468 |
|
0
|
469 |
selection := nil.
|
|
470 |
super list:aCollection
|
|
471 |
!
|
|
472 |
|
|
473 |
attributes:aList
|
|
474 |
"set the attribute list"
|
|
475 |
|
|
476 |
listAttributes := attributes
|
|
477 |
!
|
|
478 |
|
|
479 |
attributeAt:index
|
|
480 |
"return the line attribute of list line index"
|
|
481 |
|
|
482 |
listAttributes isNil ifFalse:[
|
|
483 |
(index > listAttributes size) ifFalse:[
|
|
484 |
^ listAttributes at:index
|
|
485 |
]
|
|
486 |
].
|
|
487 |
^ nil
|
|
488 |
!
|
|
489 |
|
|
490 |
attributeAt:index put:aSymbol
|
|
491 |
"set a line attribute; currently attributes are:
|
|
492 |
#halfIntensity
|
|
493 |
"
|
|
494 |
|
|
495 |
(index > list size) ifFalse:[
|
|
496 |
listAttributes isNil ifTrue:[
|
|
497 |
listAttributes := VariableArray new:index
|
|
498 |
] ifFalse:[
|
|
499 |
(index > listAttributes size) ifTrue:[
|
|
500 |
listAttributes grow:index
|
|
501 |
]
|
|
502 |
].
|
|
503 |
aSymbol == (listAttributes at:index) ifFalse:[
|
|
504 |
listAttributes at:index put:aSymbol.
|
|
505 |
self redrawLine:index
|
|
506 |
]
|
|
507 |
]
|
|
508 |
!
|
|
509 |
|
7
|
510 |
removeIndexWithoutRedraw:lineNr
|
|
511 |
"delete line - no redraw;
|
|
512 |
return true, if something was really deleted.
|
|
513 |
Redefined since we have to care for selection"
|
|
514 |
|
|
515 |
self checkRemovingSelection:lineNr.
|
|
516 |
^ super removeIndexWithoutRedraw:lineNr
|
|
517 |
!
|
|
518 |
|
|
519 |
removeIndex:lineNr
|
|
520 |
"delete line - with redraw.
|
|
521 |
Redefined since we have to care for selection"
|
|
522 |
|
|
523 |
self checkRemovingSelection:lineNr.
|
|
524 |
^ super removeIndex:lineNr
|
|
525 |
!
|
|
526 |
|
0
|
527 |
action:aBlock
|
|
528 |
"set the action block to be performed on select"
|
|
529 |
|
|
530 |
actionBlock := aBlock
|
|
531 |
!
|
|
532 |
|
|
533 |
doubleClickAction:aBlock
|
|
534 |
"set the double click action block to be performed on select"
|
|
535 |
|
|
536 |
doubleClickActionBlock := aBlock
|
|
537 |
!
|
|
538 |
|
3
|
539 |
selectConditionBlock:aBlock
|
|
540 |
"set the conditionBlock; this block is evaluated before a selection
|
|
541 |
change is performed; the change will not be done, if the evaluation
|
|
542 |
returns false. For example, this allows confirmation queries in
|
|
543 |
the SystemBrowser"
|
|
544 |
|
|
545 |
selectConditionBlock := aBlock
|
|
546 |
!
|
7
|
547 |
|
|
548 |
numberOfSelections
|
|
549 |
"return the number of selected entries"
|
|
550 |
|
|
551 |
|sz|
|
|
552 |
|
|
553 |
selection isNil ifTrue:[^ 0].
|
|
554 |
sz := selection size.
|
|
555 |
sz > 0 ifTrue:[^ sz].
|
|
556 |
^ 1
|
|
557 |
!
|
|
558 |
|
0
|
559 |
selectionValue
|
7
|
560 |
"return the selection value i.e. the text in the selected line.
|
|
561 |
For multiple selections a collection containing the entries is returned."
|
0
|
562 |
|
|
563 |
selection isNil ifTrue:[^ nil].
|
7
|
564 |
(selection isKindOf:Collection) ifTrue:[
|
|
565 |
^ selection collect:[:nr | list at:nr]
|
|
566 |
].
|
0
|
567 |
^ list at:selection
|
|
568 |
!
|
|
569 |
|
|
570 |
selection
|
7
|
571 |
"return the selection line nr or collection of line numbers"
|
0
|
572 |
|
|
573 |
^ selection
|
|
574 |
!
|
|
575 |
|
|
576 |
deselect
|
|
577 |
"deselect"
|
|
578 |
|
|
579 |
self selection:nil
|
|
580 |
!
|
|
581 |
|
|
582 |
deselectWithoutRedraw
|
|
583 |
"deselect - no redraw"
|
|
584 |
|
|
585 |
selection := nil
|
|
586 |
!
|
|
587 |
|
|
588 |
enable
|
|
589 |
"enable selections"
|
|
590 |
|
|
591 |
enabled := true
|
|
592 |
!
|
|
593 |
|
|
594 |
disable
|
|
595 |
"disable selections"
|
|
596 |
|
|
597 |
enabled := false
|
|
598 |
!
|
|
599 |
|
|
600 |
selectElement:anObject
|
|
601 |
"select the element with same printString as the argument, anObject"
|
|
602 |
|
|
603 |
|lineNo|
|
|
604 |
|
|
605 |
list notNil ifTrue:[
|
|
606 |
lineNo := list indexOf:(anObject printString) ifAbsent:[^ self].
|
|
607 |
self selection:lineNo
|
|
608 |
]
|
|
609 |
!
|
|
610 |
|
|
611 |
selectWithoutScroll:aNumberOrNil
|
|
612 |
"select line, aNumber or deselect if argument is nil"
|
|
613 |
|
|
614 |
|prevSelection newSelection|
|
|
615 |
|
|
616 |
newSelection := aNumberOrNil.
|
|
617 |
newSelection notNil ifTrue:[
|
|
618 |
(self isValidSelection:newSelection) ifFalse:[
|
|
619 |
newSelection := nil
|
|
620 |
]
|
|
621 |
].
|
|
622 |
|
|
623 |
(newSelection == selection) ifTrue: [^ self].
|
|
624 |
|
|
625 |
selection notNil ifTrue: [
|
|
626 |
prevSelection := selection.
|
|
627 |
selection := nil.
|
|
628 |
(prevSelection isKindOf:Collection) ifTrue:[
|
|
629 |
prevSelection do:[:line |
|
|
630 |
self redrawElement:line
|
|
631 |
]
|
|
632 |
] ifFalse:[
|
|
633 |
self redrawElement:prevSelection
|
|
634 |
]
|
|
635 |
].
|
|
636 |
selection := newSelection.
|
|
637 |
selection notNil ifTrue:[
|
|
638 |
self redrawElement:selection
|
|
639 |
]
|
|
640 |
!
|
|
641 |
|
|
642 |
selection:aNumberOrNil
|
|
643 |
"select line, aNumber or deselect if argument is nil;
|
|
644 |
make the line visible"
|
|
645 |
|
|
646 |
self selectWithoutScroll:aNumberOrNil.
|
|
647 |
selection notNil ifTrue:[
|
|
648 |
shown ifTrue:[
|
|
649 |
self makeLineVisible:selection
|
|
650 |
]
|
|
651 |
]
|
|
652 |
!
|
|
653 |
|
7
|
654 |
addElementToSelection:anObject
|
|
655 |
"add the element with the same printstring as the argument, anObject
|
|
656 |
to the selection"
|
|
657 |
|
|
658 |
|lineNo|
|
|
659 |
lineNo := list indexOf:(anObject printString) ifAbsent:[^ self].
|
|
660 |
self addToSelection:lineNo
|
|
661 |
!
|
|
662 |
|
|
663 |
addToSelection:aNumber
|
|
664 |
"add line, aNumber to the selection"
|
|
665 |
|
|
666 |
selection isNil ifTrue:[^ self selectWithoutScroll:aNumber].
|
|
667 |
|
|
668 |
(self isValidSelection:aNumber) ifFalse:[^ self].
|
|
669 |
(selection isKindOf:Collection) ifTrue:[
|
|
670 |
(selection includes:aNumber) ifTrue:[^ self].
|
|
671 |
selection add:aNumber
|
|
672 |
] ifFalse:[
|
|
673 |
(aNumber == selection) ifTrue:[^ self].
|
|
674 |
selection := OrderedCollection with:selection with:aNumber
|
|
675 |
].
|
|
676 |
self redrawElement:aNumber
|
|
677 |
!
|
|
678 |
|
0
|
679 |
selectNext
|
|
680 |
"select next line or first if there is currrently no selection"
|
|
681 |
|
|
682 |
selection isNil ifTrue:[
|
|
683 |
self selection:1
|
|
684 |
] ifFalse:[
|
|
685 |
self selection:(selection + 1).
|
|
686 |
selection isNil ifTrue:[
|
|
687 |
self selection:1
|
|
688 |
]
|
|
689 |
]
|
|
690 |
!
|
|
691 |
|
|
692 |
selectPrevious
|
|
693 |
"select previous line or last if there is currently no selection"
|
|
694 |
|
|
695 |
selection isNil ifTrue:[
|
|
696 |
self selection:(list size)
|
|
697 |
] ifFalse:[
|
|
698 |
self selection:(selection - 1).
|
|
699 |
selection isNil ifTrue:[
|
|
700 |
self selection:(list size)
|
|
701 |
]
|
|
702 |
]
|
|
703 |
!
|
|
704 |
|
|
705 |
on:aModel printItems:print oneItem:one aspect:aspect
|
|
706 |
change:change list:list menu:menu
|
|
707 |
initialSelection:initial
|
|
708 |
|
|
709 |
"ST-80 compatibility"
|
|
710 |
|
|
711 |
aspectSymbol := aspect.
|
|
712 |
changeSymbol := change.
|
|
713 |
listSymbol := list.
|
|
714 |
menuSymbol := menu.
|
|
715 |
initialSelectionSymbol := initial.
|
|
716 |
printItems := print.
|
|
717 |
oneItem := one.
|
|
718 |
|
|
719 |
model := aModel.
|
|
720 |
|
|
721 |
listSymbol notNil ifTrue:[
|
|
722 |
self list:(aModel perform:listSymbol) asText
|
|
723 |
].
|
|
724 |
model addDependent:self
|
|
725 |
! !
|
|
726 |
|
|
727 |
!SelectionInListView methodsFor:'private'!
|
|
728 |
|
7
|
729 |
checkRemovingSelection:lineNr
|
|
730 |
"when a line is removed, we have to adjust selection"
|
|
731 |
|
|
732 |
|newSelection|
|
|
733 |
|
|
734 |
selection notNil ifTrue:[
|
31
|
735 |
(selection size > 0) ifTrue:[
|
7
|
736 |
newSelection := OrderedCollection new.
|
|
737 |
selection do:[:sel |
|
|
738 |
sel < lineNr ifTrue:[
|
|
739 |
newSelection add:sel
|
|
740 |
] ifFalse:[
|
|
741 |
sel > lineNr ifTrue:[
|
|
742 |
newSelection add:(sel - 1)
|
|
743 |
]
|
31
|
744 |
"otherwise remove it from the selection"
|
7
|
745 |
]
|
|
746 |
].
|
|
747 |
newSelection size == 1 ifTrue:[
|
|
748 |
selection := newSelection first
|
|
749 |
] ifFalse:[
|
|
750 |
newSelection size == 0 ifTrue:[
|
|
751 |
selection := nil
|
|
752 |
] ifFalse:[
|
|
753 |
selection := newSelection
|
|
754 |
]
|
|
755 |
]
|
|
756 |
] ifFalse:[
|
|
757 |
selection == lineNr ifTrue:[
|
|
758 |
selection := nil
|
|
759 |
] ifFalse:[
|
|
760 |
selection > lineNr ifTrue:[
|
|
761 |
selection := selection - 1
|
|
762 |
]
|
|
763 |
]
|
|
764 |
]
|
|
765 |
]
|
|
766 |
!
|
|
767 |
|
0
|
768 |
isValidSelection:aNumber
|
7
|
769 |
"return true, if aNumber is ok for a selection lineNo"
|
0
|
770 |
|
|
771 |
aNumber isNil ifTrue:[^ false].
|
|
772 |
^ (aNumber between:1 and:list size)
|
|
773 |
!
|
|
774 |
|
|
775 |
isInSelection:aNumber
|
|
776 |
"return true, if line, aNumber is in the selection"
|
|
777 |
|
|
778 |
selection isNil ifTrue:[^ false].
|
|
779 |
(selection isKindOf:Collection) ifTrue:[
|
|
780 |
^ (selection includes:aNumber)
|
|
781 |
].
|
|
782 |
^ (aNumber == selection)
|
|
783 |
!
|
|
784 |
|
|
785 |
positionToSelectionX:x y:y
|
|
786 |
"given a click position, return the selection lineNo"
|
|
787 |
|
|
788 |
|visibleLine|
|
|
789 |
|
|
790 |
(x between:0 and:width) ifTrue:[
|
|
791 |
(y between:0 and:height) ifTrue:[
|
|
792 |
visibleLine := self visibleLineOfY:y.
|
|
793 |
^ self visibleLineToListLine:visibleLine
|
|
794 |
]
|
|
795 |
].
|
|
796 |
^ nil
|
|
797 |
!
|
|
798 |
|
|
799 |
widthForScrollBetween:start and:end
|
|
800 |
"has to be redefined since WHOLE line is inverted/modified sometimes"
|
|
801 |
|
|
802 |
| anySelectionInRange |
|
|
803 |
|
|
804 |
selection notNil ifTrue:[
|
|
805 |
(selection isKindOf:Collection) ifTrue:[
|
|
806 |
anySelectionInRange := false.
|
|
807 |
selection do:[:s |
|
|
808 |
(s between:start and:end) ifTrue:[
|
|
809 |
anySelectionInRange := true
|
|
810 |
]
|
|
811 |
]
|
|
812 |
] ifFalse:[
|
|
813 |
anySelectionInRange := selection between:start and:end
|
|
814 |
]
|
|
815 |
] ifFalse:[
|
|
816 |
anySelectionInRange := false
|
|
817 |
].
|
|
818 |
|
|
819 |
anySelectionInRange ifTrue:[
|
31
|
820 |
^ width
|
|
821 |
"
|
0
|
822 |
self is3D ifFalse:[
|
|
823 |
^ width
|
|
824 |
].
|
|
825 |
( #(next openwin) includes:style) ifTrue:[
|
|
826 |
^ width
|
|
827 |
].
|
|
828 |
viewBackground = background ifFalse:[
|
|
829 |
^ width
|
|
830 |
]
|
31
|
831 |
"
|
0
|
832 |
].
|
|
833 |
^ super widthForScrollBetween:start and:end
|
|
834 |
!
|
|
835 |
|
|
836 |
visibleLineNeedsSpecialCare:visLineNr
|
|
837 |
|listLine|
|
|
838 |
|
|
839 |
listLine := self visibleLineToListLine:visLineNr.
|
|
840 |
listLine isNil ifTrue:[^ false].
|
|
841 |
(self isInSelection:listLine) ifTrue:[^ true].
|
|
842 |
listAttributes notNil ifTrue:[
|
|
843 |
(listLine <= listAttributes size) ifTrue:[
|
|
844 |
^ (listAttributes at:listLine) notNil
|
|
845 |
]
|
|
846 |
].
|
|
847 |
^ false
|
|
848 |
!
|
|
849 |
|
|
850 |
removeFromSelection:aNumber
|
|
851 |
"remove line, aNumber from the selection"
|
|
852 |
|
|
853 |
selection isNil ifTrue:[^ self].
|
|
854 |
|
|
855 |
(selection isKindOf:Collection) ifTrue:[
|
|
856 |
(selection includes:aNumber) ifFalse:[^ self].
|
|
857 |
selection remove:aNumber.
|
|
858 |
(selection size == 1) ifTrue:[
|
|
859 |
selection := selection at:1
|
|
860 |
]
|
|
861 |
] ifFalse:[
|
|
862 |
(aNumber == selection) ifFalse:[^ self].
|
|
863 |
selection := nil
|
|
864 |
].
|
|
865 |
self redrawElement:aNumber
|
|
866 |
!
|
|
867 |
|
|
868 |
scrollSelectDown
|
|
869 |
"auto scroll action; scroll and reinstall timed-block"
|
|
870 |
|
38
|
871 |
self scrollDown.
|
|
872 |
Processor addTimedBlock:autoScrollBlock afterSeconds:autoScrollDeltaT.
|
0
|
873 |
!
|
|
874 |
|
|
875 |
scrollSelectUp
|
|
876 |
"auto scroll action; scroll and reinstall timed-block"
|
|
877 |
|
38
|
878 |
self scrollUp.
|
|
879 |
Processor addTimedBlock:autoScrollBlock afterSeconds:autoScrollDeltaT.
|
0
|
880 |
! !
|
|
881 |
|
|
882 |
!SelectionInListView methodsFor:'redrawing'!
|
|
883 |
|
22
|
884 |
drawRightArrowInVisibleLine:visLineNr
|
|
885 |
"draw a right arrow (for submenus).
|
|
886 |
This method is not used here, but provided for subclasses such
|
|
887 |
as menus or file-lists."
|
|
888 |
|
38
|
889 |
|y x form form2 topLeftColor botRightColor t|
|
22
|
890 |
|
|
891 |
x := width - 16.
|
|
892 |
y := (self yOfLine:visLineNr).
|
|
893 |
|
|
894 |
device depth == 1 ifTrue:[
|
|
895 |
form := self class rightArrowFormOn:device.
|
|
896 |
y := y + ((font height - form height) // 2).
|
|
897 |
self foreground:Black.
|
24
|
898 |
self displayForm:form x:x y:y.
|
22
|
899 |
] ifFalse:[
|
31
|
900 |
smallArrow ifTrue:[
|
|
901 |
form := self class smallRightArrowLightFormOn:device.
|
|
902 |
form2 := self class smallRightArrowShadowFormOn:device.
|
|
903 |
] ifFalse:[
|
|
904 |
form := self class rightArrowLightFormOn:device.
|
|
905 |
form2 := self class rightArrowShadowFormOn:device.
|
|
906 |
].
|
22
|
907 |
y := y + ((font height - form height) // 2).
|
|
908 |
|
31
|
909 |
topLeftColor := lightColor.
|
|
910 |
botRightColor := shadowColor.
|
22
|
911 |
|
31
|
912 |
"openwin arrow stays down"
|
|
913 |
style ~~ #openwin ifTrue:[
|
|
914 |
(self isInSelection:(self visibleLineToListLine:visLineNr)) ifTrue:[
|
|
915 |
t := topLeftColor.
|
|
916 |
topLeftColor := botRightColor.
|
|
917 |
botRightColor := t.
|
|
918 |
]
|
|
919 |
].
|
|
920 |
arrowLevel < 0 ifTrue:[
|
|
921 |
t := topLeftColor.
|
|
922 |
topLeftColor := botRightColor.
|
|
923 |
botRightColor := t.
|
|
924 |
].
|
|
925 |
|
|
926 |
self foreground:topLeftColor.
|
|
927 |
self displayForm:form x:x y:y.
|
|
928 |
self foreground:botRightColor.
|
|
929 |
self displayForm:form2 x:x y:y.
|
22
|
930 |
]
|
|
931 |
!
|
|
932 |
|
0
|
933 |
redrawElement:aNumber
|
|
934 |
"redraw an individual element"
|
|
935 |
|
|
936 |
^ self redrawLine:aNumber
|
|
937 |
!
|
|
938 |
|
|
939 |
redrawVisibleLine:visLineNr col:colNr
|
31
|
940 |
"redraw a single character.
|
|
941 |
Must check, if its in the selection and handle this case."
|
|
942 |
|
0
|
943 |
(self visibleLineNeedsSpecialCare:visLineNr) ifTrue:[
|
|
944 |
^ self redrawVisibleLine:visLineNr
|
|
945 |
].
|
|
946 |
super redrawVisibleLine:visLineNr col:colNr
|
|
947 |
!
|
|
948 |
|
|
949 |
redrawVisibleLine:visLineNr from:startCol
|
31
|
950 |
"redraw from a col to the right end.
|
|
951 |
Must check, if its in the selection and handle this case."
|
|
952 |
|
0
|
953 |
(self visibleLineNeedsSpecialCare:visLineNr) ifTrue:[
|
|
954 |
^ self redrawVisibleLine:visLineNr
|
|
955 |
].
|
|
956 |
super redrawVisibleLine:visLineNr from:startCol
|
|
957 |
!
|
|
958 |
|
|
959 |
redrawVisibleLine:visLineNr from:startCol to:endCol
|
31
|
960 |
"redraw from a startCol to endCol.
|
|
961 |
Must check, if its in the selection and handle this case."
|
|
962 |
|
0
|
963 |
(self visibleLineNeedsSpecialCare:visLineNr) ifTrue:[
|
|
964 |
^ self redrawVisibleLine:visLineNr
|
|
965 |
].
|
|
966 |
super redrawVisibleLine:visLineNr from:startCol to:endCol
|
|
967 |
!
|
|
968 |
|
|
969 |
redrawFromVisibleLine:startVisLineNr to:endVisLineNr
|
31
|
970 |
"redraw a range of lines.
|
|
971 |
Must check, if any is in the selection and handle this case.
|
|
972 |
Otherwise draw it en-bloque using supers method."
|
|
973 |
|
0
|
974 |
|special sel
|
|
975 |
selNo "{ Class: SmallInteger }" |
|
|
976 |
|
|
977 |
((selection isKindOf:Collection) or:[listAttributes notNil]) ifTrue:[
|
|
978 |
startVisLineNr to:endVisLineNr do:[:visLine |
|
|
979 |
self redrawVisibleLine:visLine
|
|
980 |
].
|
|
981 |
^ self
|
|
982 |
].
|
|
983 |
|
31
|
984 |
"XXX only if -1/+1"
|
|
985 |
"/ hilightLevel ~~ 0 ifTrue:[
|
|
986 |
"/ self paint:bgColor.
|
|
987 |
"/ self fillRectangleX:0 y:(self yOfLine:startVisLineNr)-1 width:width height:1
|
|
988 |
"/ ].
|
0
|
989 |
special := true.
|
|
990 |
selection isNil ifTrue:[
|
|
991 |
special := false
|
|
992 |
] ifFalse:[
|
|
993 |
sel := self listLineToVisibleLine:selection.
|
|
994 |
sel isNil ifTrue:[
|
|
995 |
special := false
|
|
996 |
] ifFalse:[
|
|
997 |
special := (sel between:startVisLineNr and:endVisLineNr)
|
|
998 |
]
|
|
999 |
].
|
|
1000 |
special ifFalse:[
|
|
1001 |
^ super redrawFromVisibleLine:startVisLineNr
|
|
1002 |
to:endVisLineNr
|
|
1003 |
].
|
|
1004 |
|
|
1005 |
selNo := sel.
|
|
1006 |
selNo > startVisLineNr ifTrue:[
|
|
1007 |
super redrawFromVisibleLine:startVisLineNr to:(selNo - 1)
|
|
1008 |
].
|
|
1009 |
self redrawVisibleLine:selNo.
|
|
1010 |
selNo < endVisLineNr ifTrue:[
|
|
1011 |
super redrawFromVisibleLine:(selNo + 1) to:endVisLineNr
|
|
1012 |
]
|
|
1013 |
!
|
|
1014 |
|
|
1015 |
redrawVisibleLine:visLineNr
|
31
|
1016 |
"redraw a single line.
|
|
1017 |
Must check, if any is in the selection and handle this case.
|
|
1018 |
Otherwise draw using supers method."
|
|
1019 |
|
|
1020 |
|listLine fg bg|
|
0
|
1021 |
|
|
1022 |
fg := fgColor.
|
|
1023 |
bg := bgColor.
|
|
1024 |
listLine := self visibleLineToListLine:visLineNr.
|
|
1025 |
listLine notNil ifTrue:[
|
31
|
1026 |
(self isInSelection:listLine) ifTrue:[
|
|
1027 |
^ self drawVisibleLineSelected:visLineNr
|
|
1028 |
].
|
0
|
1029 |
(self attributeAt:listLine) == #halfIntensity ifTrue:[
|
|
1030 |
fg := halfIntensityFgColor
|
|
1031 |
].
|
31
|
1032 |
].
|
|
1033 |
^ self drawVisibleLine:visLineNr with:fg and:bg
|
|
1034 |
!
|
|
1035 |
|
|
1036 |
drawVisibleLineSelected:visLineNr
|
|
1037 |
"redraw a single line as selected."
|
|
1038 |
|
|
1039 |
|listLine fg bg
|
|
1040 |
y "{ Class: SmallInteger }"
|
|
1041 |
wEdge|
|
|
1042 |
|
|
1043 |
bg := hilightBgColor.
|
|
1044 |
fg := hilightFgColor.
|
|
1045 |
listLine := self visibleLineToListLine:visLineNr.
|
|
1046 |
listLine notNil ifTrue:[
|
|
1047 |
"XXX only if -1/+1"
|
|
1048 |
"/ hilightLevel ~~ 0 ifTrue:[
|
|
1049 |
"/ self paint:bg.
|
|
1050 |
"/ self fillRectangleX:0 y:(self yOfLine:visLineNr)-1 width:width height:1
|
|
1051 |
"/ ].
|
|
1052 |
|
|
1053 |
self drawVisibleLine:visLineNr with:fg and:bg.
|
|
1054 |
y := self yOfLine:visLineNr.
|
|
1055 |
|
|
1056 |
"
|
|
1057 |
a line above and below
|
|
1058 |
"
|
|
1059 |
hilightFrameColor notNil ifTrue:[
|
|
1060 |
self paint:hilightFrameColor.
|
|
1061 |
self displayLineFromX:0 y:y toX:width y:y.
|
|
1062 |
y := y + fontHeight - 1.
|
|
1063 |
self displayLineFromX:0 y:y toX:width y:y.
|
|
1064 |
^ self
|
|
1065 |
].
|
|
1066 |
|
|
1067 |
"
|
|
1068 |
an edge it around
|
|
1069 |
"
|
|
1070 |
(hilightLevel ~~ 0) ifTrue:[
|
|
1071 |
"XXX the -1/+1 need some more work"
|
|
1072 |
"/ self drawEdgesForX:0 y:y-1
|
|
1073 |
"/ width:width height:fontHeight+1
|
|
1074 |
"/ level:hilightLevel.
|
|
1075 |
|
|
1076 |
"
|
|
1077 |
let edge start at left, extending to the full width
|
|
1078 |
XXX: widthOfContents should be cached in ListView
|
|
1079 |
(instead of recumputing all over)
|
|
1080 |
"
|
|
1081 |
wEdge := width-(2 * margin).
|
|
1082 |
wEdge := wEdge max:(self widthOfContents).
|
|
1083 |
|
|
1084 |
self drawEdgesForX:(margin - leftOffset) y:y
|
|
1085 |
width:wEdge height:fontHeight
|
|
1086 |
level:hilightLevel.
|
|
1087 |
|
|
1088 |
|
|
1089 |
^ self
|
0
|
1090 |
]
|
|
1091 |
].
|
31
|
1092 |
^ super drawVisibleLine:visLineNr with:fg and:bg
|
0
|
1093 |
! !
|
|
1094 |
|
|
1095 |
!SelectionInListView methodsFor:'event handling'!
|
|
1096 |
|
|
1097 |
sizeChanged:how
|
|
1098 |
"if there is a selection, make certain, its visible
|
|
1099 |
after the sizechange"
|
|
1100 |
|
|
1101 |
|first|
|
|
1102 |
|
|
1103 |
super sizeChanged:how.
|
|
1104 |
shown ifTrue:[
|
|
1105 |
selection notNil ifTrue:[
|
|
1106 |
(selection isKindOf:Collection) ifTrue:[
|
|
1107 |
first := selection first
|
|
1108 |
] ifFalse:[
|
|
1109 |
first := selection
|
|
1110 |
].
|
|
1111 |
self makeLineVisible:first
|
|
1112 |
]
|
|
1113 |
]
|
|
1114 |
!
|
|
1115 |
|
38
|
1116 |
key:key select:selectAction x:x y:y
|
|
1117 |
"perform keyaction after a key-select"
|
|
1118 |
|
|
1119 |
keyActionStyle notNil ifTrue:[
|
|
1120 |
keyActionStyle == #pass ifTrue:[
|
|
1121 |
^ super keyPress:key x:x y:y
|
|
1122 |
].
|
|
1123 |
selectAction value.
|
|
1124 |
actionBlock notNil ifTrue:[actionBlock value:selection].
|
|
1125 |
keyActionStyle == #selectAndDoubleClick ifTrue:[
|
|
1126 |
doubleClickActionBlock notNil ifTrue:[doubleClickActionBlock value:selection].
|
|
1127 |
]
|
|
1128 |
].
|
|
1129 |
!
|
|
1130 |
|
0
|
1131 |
keyPress:key x:x y:y
|
|
1132 |
"handle keyboard input"
|
|
1133 |
|
38
|
1134 |
|index startSearch|
|
|
1135 |
|
0
|
1136 |
(keyboardHandler notNil
|
|
1137 |
and:[keyboardHandler canHandle:key]) ifTrue:[
|
|
1138 |
keyboardHandler keyPress:key x:x y:y.
|
|
1139 |
^ self
|
|
1140 |
].
|
38
|
1141 |
(selection size == 0) ifTrue:[
|
|
1142 |
"/ not a multi-selection
|
|
1143 |
(key == #CursorUp) ifTrue:[
|
|
1144 |
(selectConditionBlock isNil or:[selectConditionBlock value]) ifTrue:[
|
|
1145 |
self key:key select:[self selectPrevious] x:x y:y
|
|
1146 |
].
|
|
1147 |
^ self
|
|
1148 |
].
|
|
1149 |
(key == #CursorDown) ifTrue:[
|
3
|
1150 |
(selectConditionBlock isNil or:[selectConditionBlock value]) ifTrue:[
|
38
|
1151 |
self key:key select:[self selectNext] x:x y:y
|
|
1152 |
].
|
|
1153 |
^ self
|
|
1154 |
].
|
|
1155 |
(key == #Home) ifTrue:[
|
|
1156 |
(selectConditionBlock isNil or:[selectConditionBlock value]) ifTrue:[
|
|
1157 |
self key:key select:[self selection:1] x:x y:y
|
|
1158 |
].
|
|
1159 |
^ self
|
|
1160 |
].
|
|
1161 |
(key == #End) ifTrue:[
|
|
1162 |
(selectConditionBlock isNil or:[selectConditionBlock value]) ifTrue:[
|
|
1163 |
self key:key select:[self selection:list size] x:x y:y
|
0
|
1164 |
].
|
3
|
1165 |
^ self
|
|
1166 |
].
|
38
|
1167 |
].
|
|
1168 |
key == #Return ifTrue:[
|
|
1169 |
selection notNil ifTrue:[
|
|
1170 |
doubleClickActionBlock notNil ifTrue:[
|
|
1171 |
doubleClickActionBlock value:selection
|
0
|
1172 |
].
|
3
|
1173 |
^ self
|
38
|
1174 |
]
|
|
1175 |
].
|
|
1176 |
"
|
|
1177 |
alphabetic keys: search for next entry
|
|
1178 |
starting with keys character
|
|
1179 |
"
|
|
1180 |
list size > 0 ifTrue:[
|
|
1181 |
key isCharacter ifTrue:[
|
|
1182 |
key isLetter ifTrue:[
|
|
1183 |
keyActionStyle isNil ifTrue:[^ self].
|
|
1184 |
keyActionStyle == #pass ifFalse:[
|
|
1185 |
selection notNil ifTrue:[
|
|
1186 |
selection size > 0 ifTrue:[
|
|
1187 |
startSearch := selection last + 1
|
|
1188 |
] ifFalse:[
|
|
1189 |
startSearch := selection + 1
|
|
1190 |
]
|
|
1191 |
] ifFalse:[
|
|
1192 |
startSearch := 1
|
|
1193 |
].
|
|
1194 |
startSearch > list size ifTrue:[
|
|
1195 |
startSearch := 1.
|
|
1196 |
].
|
|
1197 |
index := startSearch.
|
|
1198 |
[true] whileTrue:[
|
51
|
1199 |
(((list at:index) asString at:1) asLowercase == key asLowercase) ifTrue:[
|
38
|
1200 |
^ self key:key select:[self selection:index] x:x y:y
|
|
1201 |
].
|
|
1202 |
index := index + 1.
|
|
1203 |
index > list size ifTrue:[
|
|
1204 |
index := 1
|
|
1205 |
].
|
|
1206 |
index == startSearch ifTrue:[
|
|
1207 |
^ self
|
|
1208 |
]
|
|
1209 |
]
|
|
1210 |
]
|
|
1211 |
]
|
3
|
1212 |
].
|
|
1213 |
].
|
|
1214 |
^ super keyPress:key x:x y:y
|
0
|
1215 |
!
|
|
1216 |
|
|
1217 |
buttonPress:button x:x y:y
|
7
|
1218 |
|oldSelection listLineNr|
|
0
|
1219 |
|
31
|
1220 |
((button == 1) or:[button == #select]) ifTrue:[
|
0
|
1221 |
enabled ifTrue:[
|
3
|
1222 |
(selectConditionBlock isNil or:[selectConditionBlock value]) ifTrue:[
|
|
1223 |
oldSelection := selection.
|
|
1224 |
listLineNr := self visibleLineToListLine:(self visibleLineOfY:y).
|
|
1225 |
listLineNr notNil ifTrue: [
|
|
1226 |
self selectWithoutScroll:listLineNr
|
|
1227 |
].
|
7
|
1228 |
((ignoreReselect not and:[selection notNil])
|
|
1229 |
or:[selection ~= oldSelection]) ifTrue:[
|
3
|
1230 |
actionBlock notNil ifTrue:[actionBlock value:selection].
|
|
1231 |
"the ST-80 way of doing things"
|
|
1232 |
model notNil ifTrue:[
|
|
1233 |
model perform:changeSymbol with:(self selectionValue)
|
|
1234 |
]
|
|
1235 |
].
|
|
1236 |
clickLine := listLineNr
|
|
1237 |
]
|
0
|
1238 |
]
|
|
1239 |
] ifFalse:[
|
|
1240 |
super buttonPress:button x:x y:y
|
|
1241 |
]
|
|
1242 |
!
|
|
1243 |
|
|
1244 |
buttonShiftPress:button x:x y:y
|
|
1245 |
|oldSelection listLineNr|
|
|
1246 |
|
31
|
1247 |
((button == 1) or:[button == #select]) ifTrue:[
|
0
|
1248 |
enabled ifTrue:[
|
3
|
1249 |
(selectConditionBlock isNil or:[selectConditionBlock value]) ifTrue:[
|
|
1250 |
oldSelection := selection copy.
|
|
1251 |
listLineNr := self visibleLineToListLine:(self visibleLineOfY:y).
|
|
1252 |
listLineNr notNil ifTrue: [
|
|
1253 |
multipleSelectOk ifTrue:[
|
|
1254 |
(self isInSelection:listLineNr) ifTrue:[
|
|
1255 |
self removeFromSelection:listLineNr
|
|
1256 |
] ifFalse:[
|
|
1257 |
self addToSelection:listLineNr
|
|
1258 |
]
|
0
|
1259 |
] ifFalse:[
|
3
|
1260 |
self selectWithoutScroll:listLineNr
|
0
|
1261 |
]
|
3
|
1262 |
].
|
|
1263 |
(selection ~= oldSelection) ifTrue:[
|
|
1264 |
actionBlock notNil ifTrue:[actionBlock value:selection].
|
|
1265 |
"the ST-80 way of doing things"
|
31
|
1266 |
(model notNil and:[changeSymbol notNil]) ifTrue:[
|
|
1267 |
model perform:changeSymbol with:(self selectionValue)
|
|
1268 |
]
|
3
|
1269 |
].
|
|
1270 |
clickLine := listLineNr
|
|
1271 |
]
|
0
|
1272 |
]
|
|
1273 |
] ifFalse:[
|
|
1274 |
super buttonShiftPress:button x:x y:y
|
|
1275 |
]
|
|
1276 |
!
|
|
1277 |
|
|
1278 |
buttonMultiPress:button x:x y:y
|
31
|
1279 |
((button == 1) or:[button == #select]) ifTrue:[
|
0
|
1280 |
doubleClickActionBlock isNil ifTrue:[
|
|
1281 |
self buttonPress:button x:x y:y
|
|
1282 |
] ifFalse:[
|
|
1283 |
doubleClickActionBlock value:selection
|
|
1284 |
]
|
|
1285 |
] ifFalse:[
|
|
1286 |
super buttonMultiPress:button x:x y:y
|
|
1287 |
]
|
|
1288 |
!
|
|
1289 |
|
|
1290 |
buttonRelease:button x:x y:y
|
|
1291 |
"stop any autoscroll"
|
|
1292 |
|
|
1293 |
self stopAutoScroll
|
|
1294 |
!
|
|
1295 |
|
|
1296 |
buttonMotion:button x:x y:y
|
|
1297 |
"mouse-move while button was pressed - handle selection changes"
|
|
1298 |
|
|
1299 |
|movedVisibleLine movedLine delta oldSelection oldSelCount|
|
|
1300 |
|
|
1301 |
clickLine isNil ifTrue:[^ self].
|
|
1302 |
|
|
1303 |
"if moved outside of view, start autoscroll"
|
|
1304 |
(y < 0) ifTrue:[
|
15
|
1305 |
self compressMotionEvents:false.
|
0
|
1306 |
self startScrollUp:y.
|
|
1307 |
^ self
|
|
1308 |
].
|
|
1309 |
(y > height) ifTrue:[
|
15
|
1310 |
self compressMotionEvents:false.
|
0
|
1311 |
self startScrollDown:(y - height).
|
|
1312 |
^ self
|
|
1313 |
].
|
|
1314 |
|
|
1315 |
"move inside - stop autoscroll if any"
|
|
1316 |
self stopAutoScroll.
|
|
1317 |
|
|
1318 |
movedVisibleLine := self visibleLineOfY:y.
|
|
1319 |
movedLine := self visibleLineToAbsoluteLine:movedVisibleLine.
|
|
1320 |
(movedLine == clickLine) ifTrue:[^ self].
|
|
1321 |
|
|
1322 |
multipleSelectOk ifTrue:[
|
|
1323 |
delta := (clickLine < movedLine) ifTrue:[1] ifFalse:[-1].
|
|
1324 |
|
|
1325 |
oldSelection := selection.
|
|
1326 |
oldSelCount := selection size.
|
|
1327 |
|
|
1328 |
(clickLine+delta) to:movedLine by:delta do:[:line |
|
|
1329 |
(self isInSelection:line) ifTrue:[
|
|
1330 |
self removeFromSelection:line
|
|
1331 |
] ifFalse:[
|
|
1332 |
self addToSelection:line
|
|
1333 |
]
|
|
1334 |
].
|
|
1335 |
((selection ~= oldSelection)
|
|
1336 |
or:[selection size ~~ oldSelCount]) ifTrue:[
|
|
1337 |
actionBlock notNil ifTrue:[actionBlock value:selection]
|
|
1338 |
]
|
|
1339 |
] ifFalse:[
|
|
1340 |
self selectWithoutScroll:movedLine
|
|
1341 |
].
|
|
1342 |
|
|
1343 |
clickLine := movedLine
|
|
1344 |
!
|
|
1345 |
|
|
1346 |
update:aParameter
|
|
1347 |
|newList|
|
|
1348 |
|
|
1349 |
(aParameter == initialSelectionSymbol) ifTrue:[
|
|
1350 |
self selectElement:(model perform:initialSelectionSymbol).
|
|
1351 |
^ self
|
|
1352 |
].
|
|
1353 |
(aParameter == listSymbol) ifTrue:[
|
|
1354 |
newList := (model perform:listSymbol) asText.
|
|
1355 |
(newList = list) ifFalse:[
|
|
1356 |
self list:newList
|
|
1357 |
]
|
|
1358 |
]
|
|
1359 |
! !
|