author | ca |
Fri, 06 Dec 2002 10:04:41 +0100 | |
changeset 2399 | 949ec827ab3a |
parent 2381 | 713c81fd86ad |
child 2401 | c0c3b44afb43 |
permissions | -rw-r--r-- |
1431 | 1 |
" |
2 |
COPYRIGHT (c) 1999 by eXept Software AG |
|
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 |
||
1752 | 14 |
"{ Package: 'stx:libwidg2' }" |
15 |
||
1390 | 16 |
ListModelView subclass:#SelectionInListModelView |
2228 | 17 |
instanceVariableNames:'selection multipleSelectOk selectOnButtomMenu actionBlock |
18 |
doubleClickActionBlock selectConditionBlock clickLine |
|
19 |
highlightMode useIndex ignoreReselect toggleSelect hilightFgColor |
|
20 |
hilightBgColor hilightLevel hilightFrameColor hilightStyle |
|
2250
e95303644fac
add an closeEditor action to allow the user to accept the contents
james
parents:
2245
diff
changeset
|
21 |
dragAccessPoint dropTarget dropSource editorView openEditorAction |
2377 | 22 |
closeEditorAction highlightEnterItem enterItem cursorItem |
23 |
lineMask' |
|
1390 | 24 |
classVariableNames:'DefaultHilightStyle DefaultHilightBackgroundColor |
25 |
DefaultHilightForegroundColor DefaultHilightLevel |
|
26 |
DefaultHilightFrameColor' |
|
27 |
poolDictionaries:'' |
|
1430 | 28 |
category:'Views-Lists' |
1390 | 29 |
! |
30 |
||
31 |
!SelectionInListModelView class methodsFor:'documentation'! |
|
32 |
||
1431 | 33 |
copyright |
34 |
" |
|
35 |
COPYRIGHT (c) 1999 by eXept Software AG |
|
36 |
All Rights Reserved |
|
37 |
||
38 |
This software is furnished under a license and may be used |
|
39 |
only in accordance with the terms of that license and with the |
|
40 |
inclusion of the above copyright notice. This software may not |
|
41 |
be provided or otherwise made available to, or used by, any |
|
42 |
other person. No title to or ownership of the software is |
|
43 |
hereby transferred. |
|
44 |
" |
|
45 |
||
46 |
! |
|
47 |
||
1390 | 48 |
documentation |
49 |
" |
|
50 |
SelectionInListModelView is mostly like SelectionInListView, |
|
51 |
but derives from the ListModelView and thus the list is kept |
|
52 |
by the model. |
|
53 |
||
54 |
[Instance variables:] |
|
2228 | 55 |
|
56 |
selection <misc> the current selection. nil, a number or collection of numbers |
|
57 |
multipleSelectOk <Boolean> allow/disallow multiple selections( default:false ) |
|
58 |
selectOnButtomMenu <Boolean> enable/disable selection will change on menu pressed |
|
59 |
||
60 |
actionBlock <Block> action evaluated on single click |
|
61 |
doubleClickActionBlock <Block> action evaluated on double click |
|
62 |
selectConditionBlock |
|
63 |
||
64 |
clickLine <Number> clicked line during button motion |
|
65 |
useIndex <Boolean> representation of the model selection |
|
66 |
||
67 |
ignoreReselect <Boolean> if set, a click on an already selected entry is ignored |
|
68 |
toggleSelect <Boolean> a click on an entry unselects it and vice versa |
|
69 |
||
70 |
highlightMode <Symbol> how to draw the selection |
|
71 |
hilightFgColor <Color> foregroundColor of highlighted items |
|
72 |
hilightBgColor <Color> backgroundColor of highlighted items |
|
73 |
hilightLevel <Integer> level to draw selections (i.e. for 3D effect) |
|
74 |
hilightFrameColor <Color> rectangle around highlighted items |
|
75 |
hilightStyle <Boolean> actions on widget are enabled/disabled |
|
76 |
||
77 |
dragAccessPoint <Point> point where the drag operation starts from |
|
78 |
dropTarget <DropTarget> keeps information about the drop operation |
|
79 |
dropSource <DropSource> keeps information about the drag operation |
|
80 |
||
81 |
editorView <View> editor on current selected item |
|
82 |
openEditorAction <Action> action to get an editor on the current selection from user |
|
2250
e95303644fac
add an closeEditor action to allow the user to accept the contents
james
parents:
2245
diff
changeset
|
83 |
closeEditorAction <Action> action invoked before the editor is closed. |
1390 | 84 |
|
2323 | 85 |
enterItem <Item/nil> item over which the mouse pointer is located |
86 |
or nil |
|
87 |
highlightEnterItem <Boolean> enable or disable highlight of enterItem |
|
88 |
||
1390 | 89 |
[author:] |
90 |
Claus Atzkern |
|
91 |
||
92 |
[see also:] |
|
93 |
||
94 |
ListModelView |
|
95 |
HierarchicalListView |
|
96 |
" |
|
97 |
! |
|
98 |
||
99 |
examples |
|
100 |
" |
|
101 |
[exBegin] |
|
102 |
|top list view| |
|
103 |
||
104 |
list := List new. |
|
105 |
||
106 |
1 to:100 do:[:i| list add:('element: ', i printString) ]. |
|
107 |
top := StandardSystemView new; extent:300@300. |
|
108 |
view := ScrollableView for:SelectionInListModelView miniScroller:true |
|
109 |
origin:0.0@0.0 corner:1.0@1.0 in:top. |
|
110 |
view list:list. |
|
111 |
top open. |
|
112 |
[exEnd] |
|
113 |
||
114 |
||
115 |
[exBegin] |
|
1915 | 116 |
|top list view| |
117 |
||
118 |
list := List new. |
|
119 |
||
120 |
1 to:100 do:[:i| list add:('element: ', i printString) ]. |
|
121 |
top := StandardSystemView new; extent:300@300. |
|
122 |
view := ScrollableView for:SelectionInListModelView miniScroller:true |
|
123 |
origin:0.0@0.0 corner:1.0@1.0 in:top. |
|
124 |
view list:list. |
|
125 |
||
126 |
view openEditorAction:[:ln :aGC| |field| |
|
127 |
field := EditField new. |
|
128 |
field level:0. |
|
129 |
field acceptOnLostFocus:true. |
|
130 |
field acceptAction:[:x| list at:ln put:(field contents) ]. |
|
131 |
field font:(aGC font). |
|
132 |
field contents:(list at:ln). |
|
133 |
field |
|
134 |
]. |
|
135 |
top open. |
|
136 |
[exEnd] |
|
137 |
||
138 |
[exBegin] |
|
1390 | 139 |
|top list view item| |
140 |
||
141 |
list := HierarchicalList new. |
|
142 |
item := HierarchicalItem::Example labeled:'Test'. |
|
143 |
item expand. |
|
144 |
list showRoot:false. |
|
145 |
list root:item. |
|
146 |
||
147 |
top := StandardSystemView new; extent:300@300. |
|
148 |
view := ScrollableView for:SelectionInListModelView miniScroller:true |
|
149 |
origin:0.0@0.0 corner:1.0@1.0 in:top. |
|
150 |
||
151 |
view list:list. |
|
152 |
view doubleClickAction:[:i| (list at:i) toggleExpand ]. |
|
153 |
top open. |
|
154 |
[exEnd] |
|
155 |
||
156 |
" |
|
157 |
! ! |
|
158 |
||
159 |
!SelectionInListModelView class methodsFor:'defaults'! |
|
160 |
||
161 |
updateStyleCache |
|
162 |
"extract values from the styleSheet and cache them in class variables" |
|
163 |
||
164 |
<resource: #style ( |
|
165 |
#'selection.hilightForegroundColor' #'selection.hilightBackgroundColor' |
|
166 |
#'selection.hilightFrameColor' #'selection.hilightLevel' |
|
167 |
#'selection.foregroundColor' #'selection.backgroundColor' |
|
168 |
#'selection.shadowColor' #'selection.lightColor' |
|
169 |
#'selection.font' #'selection.hilightStyle' |
|
170 |
#'text.foregroundColor' |
|
171 |
)> |
|
172 |
||
173 |
DefaultHilightForegroundColor := StyleSheet colorAt:'selection.hilightForegroundColor'. |
|
174 |
DefaultHilightBackgroundColor := StyleSheet colorAt:'selection.hilightBackgroundColor'. |
|
175 |
DefaultHilightFrameColor := StyleSheet colorAt:'selection.hilightFrameColor'. |
|
176 |
DefaultHilightLevel := StyleSheet at:'selection.hilightLevel' default:0. |
|
177 |
DefaultHilightStyle := StyleSheet at:'selection.hilightStyle' default:(StyleSheet name). |
|
178 |
DefaultForegroundColor := StyleSheet colorAt:'selection.foregroundColor'. |
|
179 |
DefaultBackgroundColor := StyleSheet colorAt:'selection.backgroundColor'. |
|
180 |
DefaultShadowColor := StyleSheet colorAt:'selection.shadowColor'. |
|
181 |
DefaultLightColor := StyleSheet colorAt:'selection.lightColor'. |
|
182 |
||
183 |
DefaultForegroundColor isNil ifTrue:[ |
|
184 |
DefaultForegroundColor := StyleSheet colorAt:'text.foregroundColor' default:Black |
|
185 |
]. |
|
186 |
" |
|
187 |
self updateStyleCache |
|
188 |
" |
|
189 |
||
190 |
||
191 |
! ! |
|
192 |
||
193 |
!SelectionInListModelView methodsFor:'accessing'! |
|
194 |
||
2377 | 195 |
cursorLine |
196 |
"returns the index of the cursor line or 0 |
|
197 |
" |
|
198 |
|index| |
|
199 |
||
200 |
cursorItem isNil ifTrue:[^ 0 ]. |
|
201 |
||
202 |
index := list identityIndexOf:cursorItem. |
|
203 |
index == 0 ifTrue:[ cursorItem := nil ]. |
|
204 |
^ index |
|
205 |
! |
|
206 |
||
1390 | 207 |
list:aList |
208 |
"get the status of <showRoot> from the list |
|
209 |
" |
|
1547 | 210 |
self deselectWithoutRedraw. |
1390 | 211 |
^ super list:aList |
212 |
! ! |
|
213 |
||
2225 | 214 |
!SelectionInListModelView methodsFor:'accessing editor'! |
215 |
||
216 |
closeEditor |
|
217 |
"close the current editor |
|
218 |
" |
|
219 |
|editor| |
|
220 |
||
221 |
(editor := editorView) notNil ifTrue:[ |
|
222 |
editorView := nil. |
|
2308 | 223 |
closeEditorAction notNil ifTrue:[ |
2250
e95303644fac
add an closeEditor action to allow the user to accept the contents
james
parents:
2245
diff
changeset
|
224 |
closeEditorAction value:editor. |
e95303644fac
add an closeEditor action to allow the user to accept the contents
james
parents:
2245
diff
changeset
|
225 |
]. |
2225 | 226 |
editor destroy. |
227 |
]. |
|
2250
e95303644fac
add an closeEditor action to allow the user to accept the contents
james
parents:
2245
diff
changeset
|
228 |
! |
2225 | 229 |
|
2250
e95303644fac
add an closeEditor action to allow the user to accept the contents
james
parents:
2245
diff
changeset
|
230 |
closeEditorAction |
e95303644fac
add an closeEditor action to allow the user to accept the contents
james
parents:
2245
diff
changeset
|
231 |
"get the block which is evaluated before the editor is closed; the argument |
e95303644fac
add an closeEditor action to allow the user to accept the contents
james
parents:
2245
diff
changeset
|
232 |
to the action is the editor. |
e95303644fac
add an closeEditor action to allow the user to accept the contents
james
parents:
2245
diff
changeset
|
233 |
" |
e95303644fac
add an closeEditor action to allow the user to accept the contents
james
parents:
2245
diff
changeset
|
234 |
^ closeEditorAction |
e95303644fac
add an closeEditor action to allow the user to accept the contents
james
parents:
2245
diff
changeset
|
235 |
! |
2225 | 236 |
|
2250
e95303644fac
add an closeEditor action to allow the user to accept the contents
james
parents:
2245
diff
changeset
|
237 |
closeEditorAction:anOneArgAction |
e95303644fac
add an closeEditor action to allow the user to accept the contents
james
parents:
2245
diff
changeset
|
238 |
"get the block which is evaluated before the editor is closed; the argument |
e95303644fac
add an closeEditor action to allow the user to accept the contents
james
parents:
2245
diff
changeset
|
239 |
to the action is the editor. |
e95303644fac
add an closeEditor action to allow the user to accept the contents
james
parents:
2245
diff
changeset
|
240 |
" |
e95303644fac
add an closeEditor action to allow the user to accept the contents
james
parents:
2245
diff
changeset
|
241 |
closeEditorAction := anOneArgAction. |
2225 | 242 |
! |
243 |
||
244 |
openEditor |
|
245 |
"opens the editor on the current selection; |
|
246 |
returns the editorView or nil if no openEditorAction is defined |
|
247 |
or no single selection exists ... |
|
248 |
" |
|
249 |
|numArgs lnNr| |
|
250 |
||
251 |
self closeEditor. |
|
252 |
shown ifFalse:[^ nil]. |
|
2308 | 253 |
openEditorAction isNil ifTrue:[^ nil]. |
2225 | 254 |
lnNr := self selectedIndex. |
255 |
lnNr == 0 ifTrue:[^ nil]. |
|
256 |
||
257 |
self makeSelectionVisible. |
|
258 |
||
259 |
numArgs := openEditorAction numArgs. |
|
260 |
||
261 |
numArgs == 0 ifTrue:[ |
|
262 |
editorView := openEditorAction value |
|
263 |
] ifFalse:[ |
|
264 |
numArgs == 1 ifTrue:[editorView := openEditorAction value:lnNr] |
|
265 |
ifFalse:[editorView := openEditorAction value:lnNr value:self] |
|
266 |
]. |
|
2308 | 267 |
editorView isNil ifTrue:[^ nil]. |
2225 | 268 |
|
2308 | 269 |
editorView superView isNil ifTrue:[ |
2225 | 270 |
self addSubView:editorView |
271 |
]. |
|
272 |
self computeEditorLayout. |
|
273 |
editorView realize. |
|
274 |
self windowGroup focusView:editorView. |
|
275 |
^ editorView |
|
276 |
! |
|
277 |
||
278 |
openEditorAction |
|
279 |
"get the block which is evaluated to get the editor which is set for the |
|
280 |
line; the arguments to the block is the line number and the widget itself |
|
281 |
" |
|
282 |
^ openEditorAction |
|
283 |
||
284 |
! |
|
285 |
||
286 |
openEditorAction:aTwoArgAction |
|
287 |
"set the block which is evaluated to get the editor which is set for the |
|
288 |
line; the arguments to the block is the line number and the widget itself |
|
289 |
" |
|
290 |
openEditorAction := aTwoArgAction. |
|
291 |
! ! |
|
292 |
||
1818 | 293 |
!SelectionInListModelView methodsFor:'accessing-actions'! |
1641 | 294 |
|
295 |
action |
|
296 |
"get the action block to be performed on select |
|
297 |
" |
|
298 |
^ actionBlock |
|
299 |
! |
|
300 |
||
301 |
action:aOneArgAction |
|
302 |
"set the action block to be performed on select |
|
303 |
" |
|
304 |
actionBlock := aOneArgAction |
|
305 |
||
306 |
||
307 |
! |
|
308 |
||
309 |
doubleClickAction |
|
310 |
"get the action block to be performed on doubleclick |
|
311 |
" |
|
312 |
^ doubleClickActionBlock |
|
313 |
||
314 |
! |
|
315 |
||
316 |
doubleClickAction:aOneArgAction |
|
317 |
"set the action block to be performed on doubleclick |
|
318 |
" |
|
319 |
doubleClickActionBlock := aOneArgAction |
|
320 |
||
321 |
! |
|
322 |
||
323 |
selectConditionBlock |
|
324 |
"set the conditionBlock; this block is evaluated before a selection |
|
325 |
change is performed; the change will not be done, if the evaluation |
|
326 |
returns false |
|
327 |
" |
|
328 |
^ selectConditionBlock |
|
329 |
||
330 |
! |
|
331 |
||
332 |
selectConditionBlock:aOneArgBlock |
|
333 |
"set the conditionBlock; this block is evaluated before a selection |
|
334 |
change is performed; the change will not be done, if the evaluation |
|
335 |
returns false |
|
336 |
" |
|
337 |
selectConditionBlock := aOneArgBlock. |
|
338 |
||
339 |
||
340 |
||
341 |
! ! |
|
342 |
||
1818 | 343 |
!SelectionInListModelView methodsFor:'accessing-behavior'! |
1390 | 344 |
|
2323 | 345 |
highlightEnterItem |
346 |
"enable or disable to highlight the item over which the mouse pointer is located |
|
347 |
" |
|
348 |
^ highlightEnterItem |
|
349 |
! |
|
350 |
||
351 |
highlightEnterItem:aBool |
|
352 |
"enable or disable to highlight the item over which the mouse pointer is located |
|
353 |
" |
|
354 |
highlightEnterItem ~~ aBool ifTrue:[ |
|
355 |
highlightEnterItem := aBool. |
|
356 |
self pointerEntersItem:nil. |
|
357 |
]. |
|
358 |
! |
|
359 |
||
1390 | 360 |
highlightMode |
361 |
"get the mode how to draw a selected line: |
|
362 |
#line draw whole line selected |
|
363 |
#label draw label selected |
|
364 |
" |
|
365 |
^ highlightMode |
|
366 |
||
367 |
||
368 |
! |
|
369 |
||
370 |
highlightMode:aMode |
|
371 |
"set the mode how to draw a selected line: |
|
372 |
#line draw whole line selected |
|
373 |
#label draw label selected |
|
374 |
" |
|
1561 | 375 |
highlightMode := aMode. |
1390 | 376 |
! |
377 |
||
1741
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
378 |
ignoreReselect |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
379 |
"get the ignoreReselect flag - see method #ignoreReselect: for more details |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
380 |
" |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
381 |
^ ignoreReselect |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
382 |
! |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
383 |
|
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
384 |
ignoreReselect:aBoolean |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
385 |
"set/clear the ignoreReselect flag - |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
386 |
if set, a click on an already selected entry is ignored. |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
387 |
Otherwise the notification is done, even if no |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
388 |
change in the selection occurs. |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
389 |
(for example, in browser to update a method). |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
390 |
Setting ignoreReselect to false makes sense if data is shown |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
391 |
which may change by itself (i.e. without the user doing anything) |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
392 |
For example, the inspector uses this, and redisplays the value, |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
393 |
if the selection is the same. |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
394 |
The default is true, meaning that a click on an already selected |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
395 |
does not lead to a notification via the actionBlock/change mechanism. |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
396 |
" |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
397 |
ignoreReselect := aBoolean |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
398 |
|
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
399 |
! |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
400 |
|
1390 | 401 |
multipleSelectOk |
402 |
"allow/disallow multiple selections; the default is false |
|
403 |
" |
|
404 |
^ multipleSelectOk |
|
405 |
||
406 |
||
407 |
! |
|
408 |
||
409 |
multipleSelectOk:aState |
|
2381 | 410 |
"allow/disallow multiple selections. If enabled, the |
411 |
user may select multiple entries in the list, and the program |
|
412 |
always gets a collection of selected items (indexes if useIndex is true, |
|
413 |
values otherwise). The default is false, for single selections. |
|
1390 | 414 |
" |
2381 | 415 |
|state| |
416 |
||
417 |
state := aState ? false. |
|
418 |
||
419 |
multipleSelectOk == state ifTrue:[ ^ self ]. |
|
420 |
||
421 |
selection isNil ifTrue:[ |
|
422 |
multipleSelectOk := state. |
|
423 |
^ self. |
|
424 |
]. |
|
425 |
||
426 |
multipleSelectOk ifFalse:[ |
|
427 |
selection := Array with:selection. |
|
428 |
multipleSelectOk := true. |
|
429 |
^ self |
|
430 |
]. |
|
431 |
||
432 |
selection size == 1 ifTrue:[ |
|
433 |
selection := selection first. |
|
434 |
] ifFalse:[ |
|
435 |
self selection:nil |
|
436 |
]. |
|
437 |
multipleSelectOk := false. |
|
1390 | 438 |
! |
439 |
||
2228 | 440 |
selectOnButtomMenu |
441 |
"define the button-menu-press behavior; if true the line under the mouse |
|
442 |
will be selected before the menu is opened. Otherwise the menu is opened |
|
443 |
on the current selection. |
|
444 |
" |
|
445 |
^ selectOnButtomMenu |
|
446 |
! |
|
447 |
||
448 |
selectOnButtomMenu:aBoolean |
|
449 |
"define the button-menu-press behavior; if true the line under the mouse |
|
450 |
will be selected before the menu is opened. Otherwise the menu is opened |
|
451 |
on the current selection. |
|
452 |
" |
|
453 |
selectOnButtomMenu := aBoolean. |
|
454 |
! |
|
455 |
||
1741
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
456 |
toggleSelect |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
457 |
"get the toggleSelect flag - see method #toggleSelect: for more details |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
458 |
" |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
459 |
^ toggleSelect |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
460 |
! |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
461 |
|
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
462 |
toggleSelect:aBoolean |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
463 |
"turn on/off toggle select. If true, clicking on a selected entry |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
464 |
unselects it and vice versa. The default is false, which means |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
465 |
that clicking on an already selected entry does not change its |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
466 |
select status (see also ignoreReselect:). |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
467 |
" |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
468 |
toggleSelect := aBoolean. |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
469 |
|
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
470 |
|
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
471 |
! |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
472 |
|
1390 | 473 |
useIndex |
474 |
"set/clear the useIndex flag. |
|
475 |
the selection writen to the model are the indices into the list |
|
476 |
or the elements selected. |
|
477 |
" |
|
478 |
^ useIndex |
|
479 |
||
480 |
||
481 |
! |
|
482 |
||
483 |
useIndex:aBoolean |
|
484 |
"set/clear the useIndex flag. |
|
485 |
the selection writen to the model are the indices into the list |
|
486 |
or the elements selected. |
|
487 |
" |
|
488 |
useIndex := aBoolean ? true |
|
489 |
||
490 |
||
491 |
! ! |
|
492 |
||
493 |
!SelectionInListModelView methodsFor:'change & update'! |
|
494 |
||
495 |
argForChangeMessage |
|
496 |
"return the argument for a selectionChange; |
|
497 |
depending on the setting of useIndex, this is either the numeric |
|
498 |
index of the selection or the value (i.e. the string) |
|
499 |
" |
|
1554 | 500 |
selection isNil ifTrue:[ |
501 |
multipleSelectOk ifTrue:[^ #()]. |
|
502 |
^ useIndex ifTrue:[0] ifFalse:[nil] |
|
1390 | 503 |
]. |
1564 | 504 |
useIndex ifTrue:[^ selection]. |
1554 | 505 |
|
506 |
multipleSelectOk ifFalse:[ |
|
507 |
^ list at:selection ifAbsent:nil |
|
1390 | 508 |
]. |
1554 | 509 |
^ selection collect:[:nr| list at:nr ifAbsent:nil ] |
1390 | 510 |
! |
511 |
||
1755 | 512 |
contentsChanged |
513 |
super contentsChanged. |
|
514 |
self computeEditorLayout. |
|
515 |
! |
|
516 |
||
517 |
lineChangedAt:aLnNr with:arg |
|
518 |
super lineChangedAt:aLnNr with:arg. |
|
519 |
||
520 |
(editorView notNil and:[aLnNr == self selectedIndex]) ifTrue:[ |
|
521 |
self computeEditorLayout. |
|
522 |
] |
|
523 |
! |
|
524 |
||
1390 | 525 |
listSizeChanged:aLnNr nLines:aDeltaLines |
526 |
"update selection |
|
527 |
" |
|
1563 | 528 |
|changed cnts| |
1390 | 529 |
|
530 |
super listSizeChanged:aLnNr nLines:aDeltaLines. |
|
531 |
||
532 |
selection isNil ifTrue:[^ self]. |
|
533 |
||
534 |
list size == 0 ifTrue:[ |
|
1563 | 535 |
selection := nil. |
536 |
^ self selectionChanged |
|
1390 | 537 |
]. |
538 |
||
1563 | 539 |
multipleSelectOk ifFalse:[ |
540 |
selection < aLnNr ifTrue:[^ self]. |
|
541 |
||
542 |
selection := selection + aDeltaLines. |
|
1390 | 543 |
|
1563 | 544 |
(aDeltaLines < 0 and:[selection < aLnNr]) ifTrue:[ |
545 |
selection := nil. |
|
546 |
^ self selectionChanged |
|
547 |
] |
|
548 |
] ifTrue:[ |
|
549 |
changed := false. |
|
1390 | 550 |
|
1563 | 551 |
aDeltaLines < 0 ifFalse:[ |
552 |
selection keysAndValuesDo:[:i :ln| |
|
553 |
ln >= aLnNr ifTrue:[ |
|
554 |
changed := true. |
|
555 |
selection at:i put:(ln + aDeltaLines) |
|
556 |
] |
|
1390 | 557 |
] |
1563 | 558 |
] ifTrue:[ |
559 |
cnts := 0. |
|
560 |
||
561 |
selection keysAndValuesDo:[:i :ln||new| |
|
562 |
ln >= aLnNr ifTrue:[ |
|
563 |
changed := true. |
|
564 |
||
565 |
(new := ln + aDeltaLines) < aLnNr ifTrue:[ |
|
566 |
cnts := cnts + 1. |
|
567 |
new := nil |
|
568 |
]. |
|
569 |
selection at:i put:new |
|
570 |
] |
|
571 |
]. |
|
572 |
cnts ~~ 0 ifTrue:[ |
|
573 |
cnts == selection size ifTrue:[ |
|
574 |
selection := nil |
|
575 |
] ifFalse:[ |
|
576 |
selection := selection select:[:ln| ln notNil] |
|
577 |
]. |
|
578 |
^ self selectionChanged. |
|
579 |
]. |
|
1390 | 580 |
]. |
1563 | 581 |
changed ifFalse:[^ self]. |
1390 | 582 |
]. |
583 |
||
1563 | 584 |
(useIndex and:[model notNil]) ifTrue:[ |
585 |
model setValue:(self argForChangeMessage) |
|
586 |
]. |
|
587 |
||
1390 | 588 |
|
589 |
! |
|
590 |
||
1755 | 591 |
originChanged:delta |
592 |
"setup the origin of the editing view |
|
593 |
" |
|
594 |
self computeEditorLayout. |
|
595 |
super originChanged:delta. |
|
596 |
||
597 |
||
598 |
! |
|
599 |
||
1390 | 600 |
selectionChanged |
601 |
"selection has changed. Call actionblock and/or send changeMessage if defined |
|
602 |
" |
|
1554 | 603 |
|arg| |
1390 | 604 |
|
1755 | 605 |
self closeEditor. |
606 |
||
1390 | 607 |
(model isNil and:[actionBlock isNil]) ifTrue:[ |
608 |
^ self |
|
609 |
]. |
|
610 |
||
611 |
arg := self argForChangeMessage. |
|
612 |
||
613 |
model notNil ifTrue:[ |
|
614 |
model removeDependent:self. |
|
1741
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
615 |
"/ change models value to force a change notification: reselect mode |
1758
d8d45bbbd3ba
check whether model value differs from current selection.
ca
parents:
1755
diff
changeset
|
616 |
arg = model value ifTrue:[ |
d8d45bbbd3ba
check whether model value differs from current selection.
ca
parents:
1755
diff
changeset
|
617 |
model setValue:(arg isNil ifTrue:[0] ifFalse:[nil]). |
d8d45bbbd3ba
check whether model value differs from current selection.
ca
parents:
1755
diff
changeset
|
618 |
]. |
1390 | 619 |
self sendChangeMessage:#value: with:arg. |
2225 | 620 |
model notNil ifTrue:[ "/ argggh could be nilled |
621 |
model addDependent:self. |
|
622 |
] |
|
1390 | 623 |
]. |
624 |
||
625 |
actionBlock notNil ifTrue:[ |
|
2070
cb8b952f7214
use new #valueWithOptionalArg
Claus Gittinger <cg@exept.de>
parents:
2055
diff
changeset
|
626 |
actionBlock valueWithOptionalArgument:arg |
1390 | 627 |
]. |
628 |
! |
|
629 |
||
1554 | 630 |
updateFromModel |
2302
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2275
diff
changeset
|
631 |
"update selection from the model |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2275
diff
changeset
|
632 |
" |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2275
diff
changeset
|
633 |
|value nsel sensor| |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2275
diff
changeset
|
634 |
|
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2275
diff
changeset
|
635 |
model isNil ifTrue:[ |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2275
diff
changeset
|
636 |
^ self |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2275
diff
changeset
|
637 |
]. |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2275
diff
changeset
|
638 |
( multipleSelectOk |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2275
diff
changeset
|
639 |
and:[clickLine notNil |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2275
diff
changeset
|
640 |
and:[(sensor := self sensor) notNil |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2275
diff
changeset
|
641 |
and:[sensor leftButtonPressed]]] |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2275
diff
changeset
|
642 |
) ifTrue:[ |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2275
diff
changeset
|
643 |
"running in button motion; discard change notification |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2275
diff
changeset
|
644 |
" |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2275
diff
changeset
|
645 |
^ self |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2275
diff
changeset
|
646 |
]. |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2275
diff
changeset
|
647 |
|
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2275
diff
changeset
|
648 |
value := model value. |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2275
diff
changeset
|
649 |
|
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2275
diff
changeset
|
650 |
(useIndex or:[value isNil or:[value isNumber]]) ifFalse:[ |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2275
diff
changeset
|
651 |
multipleSelectOk ifFalse:[ |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2275
diff
changeset
|
652 |
value := list identityIndexOf:value |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2275
diff
changeset
|
653 |
] ifTrue:[ |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2275
diff
changeset
|
654 |
value isEmpty ifTrue:[ |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2275
diff
changeset
|
655 |
value := nil |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2275
diff
changeset
|
656 |
] ifFalse:[ |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2275
diff
changeset
|
657 |
nsel := OrderedCollection new. |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2275
diff
changeset
|
658 |
value do:[:e||i|(i := list identityIndexOf:e) ~~ 0 ifTrue:[nsel add:i]]. |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2275
diff
changeset
|
659 |
value := nsel notEmpty ifTrue:[nsel] ifFalse:[nil] |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2275
diff
changeset
|
660 |
] |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2275
diff
changeset
|
661 |
]. |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2275
diff
changeset
|
662 |
]. |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2275
diff
changeset
|
663 |
self setSelection:value. |
1390 | 664 |
! ! |
665 |
||
666 |
!SelectionInListModelView methodsFor:'drag & drop'! |
|
667 |
||
668 |
canDrag |
|
669 |
"returns true if dragging is enabled |
|
670 |
" |
|
671 |
^ dropSource notNil |
|
672 |
||
673 |
! |
|
674 |
||
675 |
dropSource |
|
676 |
"returns the dropSource or nil |
|
677 |
" |
|
678 |
^ dropSource |
|
679 |
||
680 |
! |
|
681 |
||
682 |
dropSource:aDropSourceOrNil |
|
683 |
"set the dropSource or nil |
|
684 |
" |
|
685 |
dropSource := aDropSourceOrNil. |
|
686 |
||
687 |
! |
|
688 |
||
689 |
dropTarget |
|
690 |
"returns the dropTarget or nil |
|
691 |
" |
|
692 |
^ dropTarget |
|
693 |
||
694 |
||
695 |
! |
|
696 |
||
697 |
dropTarget:aDropTragetOrNil |
|
698 |
"set the dropTarget or nil |
|
699 |
" |
|
700 |
dropTarget := aDropTragetOrNil. |
|
701 |
||
702 |
! |
|
703 |
||
704 |
startDragAt:aPoint |
|
705 |
"start drag at a point |
|
706 |
" |
|
707 |
dropSource notNil ifTrue:[ |
|
708 |
dropSource startDragSelector notNil ifTrue:[ |
|
709 |
dropSource startDragIn:self at:aPoint |
|
710 |
] ifFalse:[ |
|
711 |
DragAndDropManager new startDragFrom:self |
|
712 |
dropSource:dropSource |
|
713 |
offset:#center |
|
714 |
] |
|
715 |
] |
|
716 |
||
717 |
! ! |
|
718 |
||
719 |
!SelectionInListModelView methodsFor:'drawing'! |
|
720 |
||
1533 | 721 |
drawFrom:start to:stop x:x y:y w:w |
1390 | 722 |
"draw the lines between start to stop without clearing the background |
723 |
" |
|
1557 | 724 |
highlightMode notNil ifTrue:[ |
725 |
self selectionDo:[:lnNr| |
|
726 |
(lnNr between:start and:stop) ifTrue:[ |
|
727 |
self drawSelectionFrameAt:lnNr x:x w:w |
|
728 |
] |
|
1390 | 729 |
] |
730 |
]. |
|
1533 | 731 |
self drawElementsFrom:start to:stop x:x y:y w:w. |
1390 | 732 |
|
733 |
||
734 |
! |
|
735 |
||
2377 | 736 |
drawLabelAt:anIndex x:xI y:y h:h |
1390 | 737 |
"draw the label at position x/y without clearing the background |
738 |
" |
|
2377 | 739 |
|item y0 x1 x w| |
1554 | 740 |
|
2377 | 741 |
x := xI + 1. |
1755 | 742 |
editorView notNil ifTrue:[ |
743 |
"/ there is an open editor for the line; thus no redraw for the label (hidden by editor) |
|
744 |
self selectedIndex == anIndex ifTrue:[^ self]. |
|
745 |
]. |
|
746 |
||
1508
9c54f2e53da1
check whether #at:ifAbsent returns nil.
Claus Gittinger <cg@exept.de>
parents:
1468
diff
changeset
|
747 |
item := list at:anIndex ifAbsent:nil. |
2377 | 748 |
item isNil ifTrue:[^ self]. |
1390 | 749 |
|
2377 | 750 |
(highlightMode notNil and:[self isInSelection:anIndex]) ifTrue:[ |
751 |
self paint:hilightFgColor on:hilightBgColor |
|
752 |
] ifFalse:[ |
|
753 |
enterItem == item ifTrue:[ |
|
754 |
self paint:hilightBgColor on:bgColor. |
|
1557 | 755 |
] ifFalse:[ |
2377 | 756 |
self paint:fgColor on:bgColor. |
1557 | 757 |
]. |
2377 | 758 |
]. |
759 |
renderer display:item atX:x y:y lineHeight:h. |
|
1390 | 760 |
|
2377 | 761 |
cursorItem == item ifFalse:[ |
2323 | 762 |
enterItem == item ifTrue:[ |
763 |
y0 := y + h - 2. |
|
2352 | 764 |
x1 := x + (renderer widthFor:item). |
1390 | 765 |
|
2323 | 766 |
self displayLineFromX:x y:y0 toX:x1 y:y0. |
767 |
]. |
|
2377 | 768 |
^ self |
769 |
]. |
|
770 |
"/ textStartLeft |
|
771 |
self setMaskOrigin:(self viewOrigin + (0 @ 1) \\ (lineMask extent)). |
|
772 |
self mask:lineMask. |
|
773 |
w := renderer widthFor:item. |
|
774 |
self displayRectangleX:x -1 y:(y+2) width:w+2 height:(h - 4). |
|
775 |
self mask:nil. |
|
776 |
||
777 |
||
778 |
" |
|
779 |
" |
|
1390 | 780 |
! |
781 |
||
1554 | 782 |
drawSelectionFrameAt:lnNr x:x w:w |
783 |
"draw the background and foreground of the selection frame |
|
784 |
at a lineNr. |
|
1390 | 785 |
" |
1554 | 786 |
|item |
787 |
x0 "{ Class:SmallInteger }" |
|
1390 | 788 |
x1 "{ Class: SmallInteger }" |
1554 | 789 |
y0 "{ Class:SmallInteger }" |
790 |
y1 "{ Class:SmallInteger }" |
|
791 |
hL "{ Class:SmallInteger }" |
|
792 |
wL "{ Class:SmallInteger }" |
|
1390 | 793 |
| |
1755 | 794 |
editorView notNil ifTrue:[ |
795 |
"/ there is an open editor; do not redraw selected |
|
796 |
^ self |
|
797 |
]. |
|
798 |
||
1554 | 799 |
(item := list at:lnNr ifAbsent:nil) isNil ifTrue:[ |
1755 | 800 |
"/ list might change during drawing; item no longer visible |
1554 | 801 |
^ self |
802 |
]. |
|
803 |
||
804 |
"/ CLEAR THE BACKGROUND |
|
805 |
||
806 |
y0 := self yVisibleOfLine:lnNr. |
|
807 |
y1 := self yVisibleOfLine:(lnNr + 1). |
|
808 |
hL := y1 - y0. |
|
809 |
||
810 |
highlightMode == #line ifTrue:[ |
|
811 |
x0 := x. |
|
812 |
x1 := x0 + w. |
|
813 |
] ifFalse:[ |
|
814 |
highlightMode == #label ifFalse:[^ self]. |
|
815 |
x0 := (self xVisibleOfItem:item) - (textStartLeft // 2). |
|
2377 | 816 |
x1 := x0 + (renderer widthFor:item) + textStartLeft + 1. |
1554 | 817 |
]. |
818 |
wL := x1 - x0. |
|
819 |
||
820 |
wL > 0 ifFalse:[^ self]. |
|
821 |
||
822 |
self paint:hilightBgColor. |
|
823 |
self fillRectangleX:x0 y:y0 width:wL height:hL. |
|
824 |
||
825 |
"/ DRAW THE FRAME |
|
1390 | 826 |
|
827 |
hilightFrameColor notNil ifTrue:[ |
|
828 |
hilightLevel == 0 ifTrue:[ |
|
829 |
self paint:hilightFrameColor. |
|
830 |
||
831 |
highlightMode == #line ifTrue:[ |
|
832 |
self displayLineFromX:x0 y:y0 toX:x1 y:y0. |
|
1554 | 833 |
y1 := y0 + hL - 1. |
834 |
self displayLineFromX:x0 y:y1 toX:x1 y:y1. |
|
1390 | 835 |
] ifFalse:[ |
1554 | 836 |
self displayRectangleX:x0 y:y0 width:wL height:hL |
1390 | 837 |
]. |
838 |
^ self. |
|
839 |
] |
|
840 |
] ifFalse:[ |
|
841 |
hilightStyle == #motif ifTrue:[ |
|
842 |
self paint:bgColor. |
|
1554 | 843 |
y1 := y0 + 1. |
1390 | 844 |
highlightMode == #line ifTrue:[ |
1554 | 845 |
self displayLineFromX:x0 y:y1 toX:x1 y:y1. |
846 |
y1 := y0 + hL - 2. |
|
847 |
self displayLineFromX:x0 y:y1 toX:x1 y:y1. |
|
1390 | 848 |
] ifFalse:[ |
1554 | 849 |
self displayRectangleX:x0 + 1 y:y1 width:wL - 2 height:hL - 2 |
1390 | 850 |
] |
851 |
] |
|
852 |
]. |
|
853 |
||
854 |
hilightLevel ~~ 0 ifTrue:[ |
|
855 |
"/ draw edge |
|
856 |
highlightMode == #line ifTrue:[ |
|
1554 | 857 |
x0 := margin. |
858 |
wL := width - x0 - x0. |
|
1390 | 859 |
]. |
1554 | 860 |
self drawEdgesForX:x0 y:y0 width:wL height:hL level:hilightLevel. |
1390 | 861 |
] |
862 |
! |
|
863 |
||
2245
546c6e5d0951
change #redrawSelectionAt: to #invalidateSelectionAt: (because is a invalidate)
ca
parents:
2228
diff
changeset
|
864 |
invalidateSelectionAt:aLineNr |
1569 | 865 |
"redraw a line which changed its selection status. |
866 |
optimized when drawing only the label. |
|
1390 | 867 |
" |
2323 | 868 |
|item x| |
1569 | 869 |
|
1755 | 870 |
editorView notNil ifTrue:[ |
871 |
"/ there is an open editor; do not redraw selected |
|
872 |
^ self |
|
873 |
]. |
|
874 |
||
1569 | 875 |
(shown and:[aLineNr notNil and:[highlightMode notNil]]) ifFalse:[ |
876 |
^ self |
|
1557 | 877 |
]. |
878 |
||
2323 | 879 |
highlightMode == #label ifTrue:[ |
880 |
item := list at:aLineNr ifAbsent:nil. |
|
1569 | 881 |
|
2323 | 882 |
item isNil ifTrue:[ |
883 |
^ self |
|
884 |
]. |
|
885 |
x := (self xVisibleOfItem:item) - (textStartLeft // 2) |
|
1569 | 886 |
] ifFalse:[ |
2323 | 887 |
x := 0. |
1569 | 888 |
]. |
2323 | 889 |
self invalidateLineAt:aLineNr fromX:x |
1390 | 890 |
! ! |
891 |
||
892 |
!SelectionInListModelView methodsFor:'event handling'! |
|
893 |
||
894 |
buttonMotion:buttonMask x:x y:y |
|
895 |
"mouse-move while button was pressed - handle selection changes |
|
896 |
" |
|
2323 | 897 |
|dragPoint lnNr d0 nsel viewOrgY yAbsLine item |
1747
f46c5941c028
better alghorithm for button motion in multipleSelection mode
ca
parents:
1745
diff
changeset
|
898 |
step "{ Class:SmallInteger }" |
f46c5941c028
better alghorithm for button motion in multipleSelection mode
ca
parents:
1745
diff
changeset
|
899 |
| |
2323 | 900 |
enabled ifFalse:[^ self]. |
1747
f46c5941c028
better alghorithm for button motion in multipleSelection mode
ca
parents:
1745
diff
changeset
|
901 |
|
2323 | 902 |
clickLine isNil ifTrue:[ |
903 |
highlightEnterItem ifTrue:[ |
|
904 |
self sensor anyButtonPressed ifFalse:[ |
|
905 |
lnNr := self yVisibleToLineNr:y. |
|
1390 | 906 |
|
2323 | 907 |
lnNr notNil ifTrue:[ item := list at:lnNr ifAbsent:nil ] |
908 |
ifFalse:[ item := nil ]. |
|
909 |
||
910 |
self pointerEntersItem:item. |
|
911 |
] |
|
912 |
]. |
|
913 |
^ self |
|
914 |
]. |
|
915 |
||
916 |
self hasSelection ifFalse:[^ self]. |
|
1390 | 917 |
|
918 |
dragAccessPoint notNil ifTrue:[ |
|
1747
f46c5941c028
better alghorithm for button motion in multipleSelection mode
ca
parents:
1745
diff
changeset
|
919 |
dragPoint := x @ y. |
1390 | 920 |
|
1747
f46c5941c028
better alghorithm for button motion in multipleSelection mode
ca
parents:
1745
diff
changeset
|
921 |
(dragAccessPoint dist:dragPoint) > 5.0 ifTrue:[ |
1390 | 922 |
dragAccessPoint := nil. |
1747
f46c5941c028
better alghorithm for button motion in multipleSelection mode
ca
parents:
1745
diff
changeset
|
923 |
self startDragAt:dragPoint |
1390 | 924 |
]. |
925 |
^ self |
|
926 |
]. |
|
927 |
||
928 |
(multipleSelectOk and:[self sensor leftButtonPressed]) ifFalse:[ |
|
929 |
^ self |
|
930 |
]. |
|
931 |
||
1747
f46c5941c028
better alghorithm for button motion in multipleSelection mode
ca
parents:
1745
diff
changeset
|
932 |
(lnNr := self yVisibleToLineNr:y) isNil ifTrue:[ |
f46c5941c028
better alghorithm for button motion in multipleSelection mode
ca
parents:
1745
diff
changeset
|
933 |
lnNr := list size |
f46c5941c028
better alghorithm for button motion in multipleSelection mode
ca
parents:
1745
diff
changeset
|
934 |
] ifFalse:[ |
f46c5941c028
better alghorithm for button motion in multipleSelection mode
ca
parents:
1745
diff
changeset
|
935 |
lnNr := lnNr max:1 |
f46c5941c028
better alghorithm for button motion in multipleSelection mode
ca
parents:
1745
diff
changeset
|
936 |
]. |
f46c5941c028
better alghorithm for button motion in multipleSelection mode
ca
parents:
1745
diff
changeset
|
937 |
lnNr == clickLine ifTrue:[^ self]. |
f46c5941c028
better alghorithm for button motion in multipleSelection mode
ca
parents:
1745
diff
changeset
|
938 |
|
1748 | 939 |
autoScroll ifTrue:[ |
940 |
"/ if moved outside of view, start autoscroll |
|
941 |
(y < 0) ifTrue:[ |
|
942 |
^ self startAutoScroll:[self scrollUp] distance:y. |
|
943 |
]. |
|
944 |
(y > height) ifTrue:[ |
|
945 |
^ self startAutoScroll:[self scrollDown] distance:(y - height). |
|
946 |
]. |
|
947 |
]. |
|
948 |
||
949 |
"move inside - stop autoscroll if any" |
|
950 |
self stopAutoScroll. |
|
951 |
||
1747
f46c5941c028
better alghorithm for button motion in multipleSelection mode
ca
parents:
1745
diff
changeset
|
952 |
nsel := OrderedCollection new. |
f46c5941c028
better alghorithm for button motion in multipleSelection mode
ca
parents:
1745
diff
changeset
|
953 |
step := lnNr > clickLine ifTrue:[1] ifFalse:[-1]. |
1390 | 954 |
|
1747
f46c5941c028
better alghorithm for button motion in multipleSelection mode
ca
parents:
1745
diff
changeset
|
955 |
clickLine to:lnNr by:step do:[:i| |
1920 | 956 |
((self isInSelection:i) or:[self canSelectIndex:i forAdd:true]) ifTrue:[nsel add:i]. |
1747
f46c5941c028
better alghorithm for button motion in multipleSelection mode
ca
parents:
1745
diff
changeset
|
957 |
]. |
f46c5941c028
better alghorithm for button motion in multipleSelection mode
ca
parents:
1745
diff
changeset
|
958 |
(self selectWithoutScroll:nsel redraw:true) ifFalse:[^ self]. |
f46c5941c028
better alghorithm for button motion in multipleSelection mode
ca
parents:
1745
diff
changeset
|
959 |
|
f46c5941c028
better alghorithm for button motion in multipleSelection mode
ca
parents:
1745
diff
changeset
|
960 |
viewOrgY := viewOrigin y. |
f46c5941c028
better alghorithm for button motion in multipleSelection mode
ca
parents:
1745
diff
changeset
|
961 |
yAbsLine := self yAbsoluteOfLine:lnNr. |
f46c5941c028
better alghorithm for button motion in multipleSelection mode
ca
parents:
1745
diff
changeset
|
962 |
|
f46c5941c028
better alghorithm for button motion in multipleSelection mode
ca
parents:
1745
diff
changeset
|
963 |
yAbsLine < viewOrgY ifTrue:[ |
f46c5941c028
better alghorithm for button motion in multipleSelection mode
ca
parents:
1745
diff
changeset
|
964 |
self scrollTo:( viewOrigin x @ yAbsLine) redraw:true |
1390 | 965 |
] ifFalse:[ |
1747
f46c5941c028
better alghorithm for button motion in multipleSelection mode
ca
parents:
1745
diff
changeset
|
966 |
yAbsLine - viewOrgY > height ifTrue:[ |
f46c5941c028
better alghorithm for button motion in multipleSelection mode
ca
parents:
1745
diff
changeset
|
967 |
d0 := yAbsLine - height. |
f46c5941c028
better alghorithm for button motion in multipleSelection mode
ca
parents:
1745
diff
changeset
|
968 |
self scrollTo:( viewOrigin x @ d0) redraw:true. |
1390 | 969 |
]. |
970 |
]. |
|
1747
f46c5941c028
better alghorithm for button motion in multipleSelection mode
ca
parents:
1745
diff
changeset
|
971 |
self repairDamage. |
f46c5941c028
better alghorithm for button motion in multipleSelection mode
ca
parents:
1745
diff
changeset
|
972 |
self selectionChanged. |
1390 | 973 |
! |
974 |
||
975 |
buttonMultiPress:button x:x y:y |
|
976 |
"button was pressed multiple - handle a doubleClick action |
|
977 |
" |
|
978 |
clickLine := nil. |
|
979 |
dragAccessPoint := nil. |
|
980 |
||
981 |
enabled ifFalse:[^ self]. |
|
982 |
||
983 |
((button == 1) or:[button == #select]) ifFalse:[ |
|
984 |
^ super buttonMultiPress:button x:x y:y |
|
985 |
]. |
|
986 |
self doubleClicked |
|
987 |
! |
|
988 |
||
989 |
buttonPress:button x:x y:y |
|
990 |
"a button was pressed - handle selection here |
|
991 |
" |
|
2399 | 992 |
|sensor item menu appl isInSelection lineNr| |
1390 | 993 |
|
994 |
clickLine := nil. |
|
995 |
dragAccessPoint := nil. |
|
996 |
||
2323 | 997 |
self pointerEntersItem:nil. |
2377 | 998 |
self cursorEntersItem:nil. |
2361 | 999 |
self closeEditor. |
2323 | 1000 |
|
1390 | 1001 |
enabled ifFalse:[^ self]. |
1002 |
||
2228 | 1003 |
sensor := self sensor. |
2399 | 1004 |
sensor isNil ifTrue:[^ self]. |
1005 |
||
1006 |
lineNr := self yVisibleToLineNr:y. |
|
2228 | 1007 |
|
1578 | 1008 |
((button == 2) or:[button == #menu]) ifTrue:[ |
2228 | 1009 |
selectOnButtomMenu ifTrue:[ |
1010 |
( lineNr notNil |
|
1011 |
and:[lineNr ~~ self selectedIndex |
|
1012 |
and:[self canSelectIndex:lineNr forAdd:false ]] |
|
1013 |
) ifTrue:[ |
|
1014 |
(self selectWithoutScroll:lineNr redraw:true) ifTrue:[ |
|
1015 |
self selectionChanged |
|
1016 |
]. |
|
1017 |
item := self selectedElement. |
|
1018 |
] ifFalse:[ |
|
1019 |
item := nil |
|
1020 |
] |
|
1021 |
] ifFalse:[ |
|
1022 |
item := self selectedElement. |
|
1023 |
]. |
|
1578 | 1024 |
|
2308 | 1025 |
item notNil ifTrue:[ |
1026 |
self makeSelectionVisible. |
|
2228 | 1027 |
|
1028 |
menu := item perform:#middleButtonMenu ifNotUnderstood:nil. |
|
1029 |
||
2308 | 1030 |
menu notNil ifTrue:[ |
2228 | 1031 |
menu isCollection ifTrue:[ |
1032 |
menu := Menu new fromLiteralArrayEncoding:menu. |
|
1033 |
appl := self application. |
|
1034 |
||
1035 |
appl notNil ifTrue:[ |
|
1036 |
menu findGuiResourcesIn:appl. |
|
1037 |
"/ menu receiver:appl -- now done in findGuiResources ... |
|
1038 |
] ifFalse:[ |
|
1039 |
menu receiver:item |
|
1040 |
] |
|
1041 |
]. |
|
2333 | 1042 |
self startUpMenu:menu. |
2361 | 1043 |
^ self |
2228 | 1044 |
] |
1578 | 1045 |
]. |
2228 | 1046 |
super buttonPress:button x:x y:y. |
2361 | 1047 |
^ self |
1390 | 1048 |
]. |
2399 | 1049 |
lineNr isNil ifTrue:[ ^ self ]. |
1050 |
isInSelection := self isInSelection:lineNr. |
|
1578 | 1051 |
|
2399 | 1052 |
sensor shiftDown ifTrue:[ |
1053 |
multipleSelectOk ifTrue:[ |min| |
|
1054 |
min := self firstInSelection. |
|
2228 | 1055 |
|
2399 | 1056 |
min notNil ifTrue:[ |
1057 |
self selectFrom:(min min:lineNr) |
|
1058 |
to:(self lastInSelection max:lineNr). |
|
1059 |
^ self |
|
1060 |
]. |
|
1061 |
] ifFalse:[ |
|
1062 |
isInSelection ifTrue:[^ self]. |
|
1063 |
]. |
|
1390 | 1064 |
|
2399 | 1065 |
(self canSelectIndex:lineNr forAdd:false) ifTrue:[ |
1066 |
self buttonPressOrReleaseAtLine:lineNr x:x y:y. |
|
1067 |
]. |
|
1068 |
^ self |
|
1069 |
]. |
|
1070 |
||
1071 |
clickLine := lineNr. |
|
1072 |
||
1073 |
sensor ctrlDown ifTrue:[ |
|
1074 |
multipleSelectOk ifTrue:[ |
|
1920 | 1075 |
(isInSelection or:[self canSelectIndex:clickLine forAdd:true]) ifTrue:[ |
1644 | 1076 |
self toggleSelection:clickLine. |
1077 |
self selectionChanged |
|
1078 |
]. |
|
1079 |
^ self |
|
1390 | 1080 |
]. |
1920 | 1081 |
|
2399 | 1082 |
isInSelection ifTrue:[ |
1083 |
self deselect. |
|
1084 |
clickLine := nil. |
|
1390 | 1085 |
^ self |
1086 |
] |
|
1087 |
]. |
|
1088 |
||
2399 | 1089 |
(self canSelectIndex:clickLine forAdd:false) ifFalse:[^ self]. |
1090 |
||
1915 | 1091 |
(isInSelection and:[self canDrag]) ifTrue:[ |
1092 |
dragAccessPoint := x @ y. |
|
1093 |
] ifFalse:[ |
|
1094 |
self buttonPressOrReleaseAtLine:clickLine x:x y:y |
|
1095 |
]. |
|
1096 |
! |
|
1097 |
||
1098 |
buttonPressOrReleaseAtLine:aLnNr x:x y:y |
|
1099 |
"handle a button press or release at a line |
|
1100 |
" |
|
1101 |
aLnNr == self selectedIndex ifTrue:[ |
|
1102 |
editorView notNil ifTrue:[^ self]. |
|
1103 |
||
1104 |
openEditorAction notNil ifTrue:[ |
|
1105 |
self openEditorAtX:x y:y. |
|
1106 |
editorView notNil ifTrue:[^ self]. |
|
1741
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
1107 |
]. |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
1108 |
|
1915 | 1109 |
ignoreReselect ifFalse:[ |
1110 |
(toggleSelect and:[self sensor ctrlDown]) ifTrue:[ |
|
1111 |
self selection:nil |
|
1112 |
] ifFalse:[ |
|
1113 |
self selectionChanged |
|
1741
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
1114 |
]. |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
1115 |
]. |
1915 | 1116 |
] ifFalse:[ |
1117 |
(self selectWithoutScroll:aLnNr redraw:true) ifTrue:[ |
|
1118 |
self selectionChanged |
|
1119 |
] |
|
1741
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
1120 |
]. |
1390 | 1121 |
! |
1122 |
||
1123 |
buttonRelease:button x:x y:y |
|
1124 |
"a button was released |
|
1125 |
" |
|
1915 | 1126 |
|dragPoint clickLnNr| |
1127 |
||
1128 |
dragPoint := dragAccessPoint. |
|
1129 |
clickLnNr := clickLine. |
|
1130 |
clickLine := dragAccessPoint := nil. |
|
1131 |
||
2377 | 1132 |
self cursorEntersItem:nil. |
1748 | 1133 |
self stopAutoScroll. |
1134 |
||
1915 | 1135 |
(enabled and:[dragPoint notNil and:[clickLnNr notNil]]) ifTrue:[ |
1136 |
self buttonPressOrReleaseAtLine:clickLnNr x:(dragPoint x) y:(dragPoint y). |
|
1390 | 1137 |
]. |
1138 |
! |
|
1139 |
||
1140 |
characterPress:aKey x:x y:y |
|
1141 |
" a character is pressed - lookup and change selection |
|
1142 |
" |
|
1143 |
|lnNr size idx sensor stp to1 fr2| |
|
1144 |
||
1145 |
(enabled and:[(size := self size) > 1]) ifFalse:[ |
|
1146 |
^ self |
|
1147 |
]. |
|
1148 |
lnNr := self firstInSelection ? 0. |
|
1149 |
||
1150 |
((sensor := self sensor) notNil and:[sensor shiftDown]) ifTrue:[ |
|
1151 |
stp := -1. "/ search backward |
|
1152 |
to1 := 1. |
|
1153 |
fr2 := size. |
|
1154 |
] ifFalse:[ |
|
1155 |
stp := 1. "/ search forward |
|
1156 |
to1 := size. |
|
1157 |
fr2 := 1. |
|
1158 |
]. |
|
1159 |
||
1160 |
idx := self findLineFrom:lnNr+stp to:to1 by:stp startingWithCharacter:aKey. |
|
1161 |
||
1162 |
idx == 0 ifTrue:[ |
|
1163 |
idx := self findLineFrom:fr2 to:lnNr-stp by:stp startingWithCharacter:aKey |
|
1164 |
]. |
|
1165 |
idx ~~ 0 ifTrue:[^ self selection:idx] |
|
1166 |
! |
|
1167 |
||
1768
04b330a75f75
allow for subclasses to redefine character search
Claus Gittinger <cg@exept.de>
parents:
1758
diff
changeset
|
1168 |
characterSearchItemStringAt:anIndex |
04b330a75f75
allow for subclasses to redefine character search
Claus Gittinger <cg@exept.de>
parents:
1758
diff
changeset
|
1169 |
|item| |
04b330a75f75
allow for subclasses to redefine character search
Claus Gittinger <cg@exept.de>
parents:
1758
diff
changeset
|
1170 |
|
04b330a75f75
allow for subclasses to redefine character search
Claus Gittinger <cg@exept.de>
parents:
1758
diff
changeset
|
1171 |
item := list at:anIndex ifAbsent:nil. |
04b330a75f75
allow for subclasses to redefine character search
Claus Gittinger <cg@exept.de>
parents:
1758
diff
changeset
|
1172 |
item isNil ifTrue:[^ item]. |
04b330a75f75
allow for subclasses to redefine character search
Claus Gittinger <cg@exept.de>
parents:
1758
diff
changeset
|
1173 |
|
04b330a75f75
allow for subclasses to redefine character search
Claus Gittinger <cg@exept.de>
parents:
1758
diff
changeset
|
1174 |
^ item perform:#string ifNotUnderstood:nil. |
04b330a75f75
allow for subclasses to redefine character search
Claus Gittinger <cg@exept.de>
parents:
1758
diff
changeset
|
1175 |
|
04b330a75f75
allow for subclasses to redefine character search
Claus Gittinger <cg@exept.de>
parents:
1758
diff
changeset
|
1176 |
! |
04b330a75f75
allow for subclasses to redefine character search
Claus Gittinger <cg@exept.de>
parents:
1758
diff
changeset
|
1177 |
|
1917
21964f5b1cc1
fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents:
1915
diff
changeset
|
1178 |
containerChangedSize |
21964f5b1cc1
fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents:
1915
diff
changeset
|
1179 |
"/ stupid kludge for motif-style (which draws a frame at the right-edge) |
21964f5b1cc1
fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents:
1915
diff
changeset
|
1180 |
"/ cg: I think it should not (see normal SelectionInListView, which does only |
21964f5b1cc1
fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents:
1915
diff
changeset
|
1181 |
"/ draw the frame at the top and bottom, but NOT at the left and right |
21964f5b1cc1
fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents:
1915
diff
changeset
|
1182 |
|
21964f5b1cc1
fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents:
1915
diff
changeset
|
1183 |
selection notNil ifTrue:[ |
21964f5b1cc1
fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents:
1915
diff
changeset
|
1184 |
(hilightFrameColor notNil |
21964f5b1cc1
fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents:
1915
diff
changeset
|
1185 |
or:[hilightStyle == #motif |
21964f5b1cc1
fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents:
1915
diff
changeset
|
1186 |
or:[hilightLevel ~~ 0]]) ifTrue:[ |
21964f5b1cc1
fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents:
1915
diff
changeset
|
1187 |
"/ invalidate the right-edge |
21964f5b1cc1
fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents:
1915
diff
changeset
|
1188 |
self invalidate:(((width-3) @ 0) corner:((width-1) @ (height-1))). |
21964f5b1cc1
fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents:
1915
diff
changeset
|
1189 |
] |
21964f5b1cc1
fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents:
1915
diff
changeset
|
1190 |
]. |
21964f5b1cc1
fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents:
1915
diff
changeset
|
1191 |
|
21964f5b1cc1
fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents:
1915
diff
changeset
|
1192 |
super containerChangedSize. |
21964f5b1cc1
fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents:
1915
diff
changeset
|
1193 |
! |
21964f5b1cc1
fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents:
1915
diff
changeset
|
1194 |
|
2377 | 1195 |
cursorEntersItem:anItemOrNil |
1196 |
"the cursor enters an item or nil |
|
1197 |
" |
|
1198 |
|lnNr x| |
|
1199 |
||
1200 |
(shown and:[list size ~~ 0]) ifFalse:[ |
|
1201 |
cursorItem := nil. |
|
1202 |
^ self. |
|
1203 |
]. |
|
1204 |
||
1205 |
anItemOrNil == cursorItem ifTrue:[ ^ self ]. |
|
1206 |
||
1207 |
2 timesRepeat:[ |
|
1208 |
cursorItem notNil ifTrue:[ |
|
1209 |
lnNr := list identityIndexOf:cursorItem. |
|
1210 |
lnNr notNil ifTrue:[ |
|
1211 |
x := self xVisibleOfItem:cursorItem. |
|
1212 |
self invalidateLineAt:lnNr fromX:x |
|
1213 |
]. |
|
1214 |
]. |
|
1215 |
"/ set the new item |
|
1216 |
cursorItem := anItemOrNil. |
|
1217 |
]. |
|
1218 |
cursorItem notNil ifTrue:[ |
|
1219 |
self makeLineVisible:lnNr |
|
1220 |
]. |
|
1221 |
! |
|
1222 |
||
1390 | 1223 |
doubleClicked |
1224 |
"handle a double click |
|
1225 |
" |
|
1226 |
(doubleClickActionBlock notNil and:[self numberOfSelections == 1]) ifTrue:[ |
|
1227 |
(doubleClickActionBlock numArgs == 1) ifTrue:[ |
|
1228 |
doubleClickActionBlock value:(self selectedIndex) |
|
1229 |
] ifFalse:[ |
|
1230 |
doubleClickActionBlock value |
|
1231 |
] |
|
1232 |
] |
|
1233 |
||
1234 |
! |
|
1235 |
||
1236 |
findLineFrom:aStart to:aStop by:aStep startingWithCharacter:aCharacter |
|
1237 |
"find a line starting with a character |
|
1238 |
" |
|
1239 |
|item char lbl cmp |
|
1240 |
size "{ Class:SmallInteger }" |
|
1241 |
start "{ Class:SmallInteger }" |
|
1242 |
stop "{ Class:SmallInteger }" |
|
1243 |
| |
|
1244 |
(size := list size) ~~ 0 ifTrue:[ |
|
1245 |
aStep > 0 ifTrue:[ |
|
1246 |
aStart > aStop ifTrue:[^ 0]. |
|
1247 |
] ifFalse:[ |
|
1248 |
(aStep == 0 or:[aStop > aStart]) ifTrue:[^ 0] |
|
1249 |
]. |
|
1250 |
||
1251 |
start := aStart < 0 ifTrue:[1] ifFalse:[aStart min:size]. |
|
1252 |
stop := aStop < 0 ifTrue:[1] ifFalse:[aStop min:size]. |
|
1253 |
char := aCharacter asUppercase. |
|
1254 |
||
1255 |
start to:stop by:aStep do:[:anIndex| |
|
1920 | 1256 |
(self canSelectIndex:anIndex forAdd:false) ifTrue:[ |
1772 | 1257 |
lbl := self characterSearchItemStringAt:anIndex. |
1258 |
lbl notNil ifTrue:[ |
|
1259 |
cmp := lbl string at:1 ifAbsent:nil. |
|
1390 | 1260 |
|
1772 | 1261 |
cmp notNil ifTrue:[ |
1262 |
(char == cmp or:[char == cmp asUppercase]) ifTrue:[ |
|
1263 |
^ anIndex |
|
1264 |
] |
|
1390 | 1265 |
] |
1266 |
] |
|
1267 |
] |
|
1268 |
] |
|
1269 |
]. |
|
1270 |
^ 0 |
|
1271 |
! |
|
1272 |
||
1273 |
keyPress:aKey x:x y:y |
|
1274 |
"a key was pressed - handle page-keys here |
|
1275 |
" |
|
2365
bdf6954a0358
key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents:
2361
diff
changeset
|
1276 |
<resource: #keyboard( #CursorUp #CursorDown #EndOfText #EndOfLine |
2377 | 1277 |
#BeginOfText #BeginOfLine #Return |
1278 |
#CmdReturn #CmdCursorUp #CmdCursorDown )> |
|
1390 | 1279 |
|
2377 | 1280 |
|lineNr listSize sensor shifted newSel step start| |
1390 | 1281 |
|
2377 | 1282 |
enabled ifFalse:[ ^ self ]. |
1283 |
||
1284 |
listSize := list size. |
|
1285 |
listSize == 0 ifTrue:[^ self]. |
|
1286 |
||
2365
bdf6954a0358
key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents:
2361
diff
changeset
|
1287 |
aKey isCharacter ifTrue:[ |
bdf6954a0358
key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents:
2361
diff
changeset
|
1288 |
self characterPress:aKey x:x y:y. |
bdf6954a0358
key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents:
2361
diff
changeset
|
1289 |
^ self |
1390 | 1290 |
]. |
1291 |
||
2377 | 1292 |
aKey == #Escape ifTrue:[ |
1293 |
cursorItem notNil ifTrue:[ |
|
1294 |
self cursorEntersItem:nil. |
|
1295 |
self makeSelectionVisible. |
|
1296 |
]. |
|
1297 |
super keyPress:aKey x:x y:y. |
|
2365
bdf6954a0358
key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents:
2361
diff
changeset
|
1298 |
^ self |
1390 | 1299 |
]. |
1300 |
||
2365
bdf6954a0358
key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents:
2361
diff
changeset
|
1301 |
((aKey == #BeginOfText) or:[aKey == #BeginOfLine]) ifTrue:[ |
2377 | 1302 |
self cursorEntersItem:nil. |
1303 |
||
2368 | 1304 |
1 to:listSize do:[:i| |
2377 | 1305 |
(self canSelectIndex:i forAdd:false) ifTrue:[ |
1306 |
self selection:i. |
|
1307 |
^ self |
|
1308 |
]. |
|
2368 | 1309 |
]. |
1390 | 1310 |
^ self |
1311 |
]. |
|
1312 |
||
2365
bdf6954a0358
key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents:
2361
diff
changeset
|
1313 |
((aKey == #EndOfText) or:[aKey == #EndOfLine]) ifTrue:[ |
2377 | 1314 |
self cursorEntersItem:nil. |
1315 |
||
2368 | 1316 |
listSize to:1 by:-1 do:[:i| |
2377 | 1317 |
(self canSelectIndex:i forAdd:false) ifTrue:[ |
1318 |
self selection:i. |
|
1319 |
^ self |
|
1320 |
]. |
|
1321 |
]. |
|
1322 |
^ self |
|
1323 |
]. |
|
1324 |
lineNr := self cursorLine. |
|
1325 |
||
1326 |
aKey == #CmdReturn ifTrue:[ |
|
1327 |
"/ toggle item under selection |
|
1328 |
lineNr == 0 ifTrue:[ |
|
1329 |
lineNr := self selectedIndex. |
|
1330 |
lineNr == 0 ifTrue:[^ self]. |
|
1331 |
]. |
|
1332 |
( (self isInSelection:lineNr) |
|
1333 |
or:[(self canSelectIndex:lineNr forAdd:true)] |
|
1334 |
) ifTrue:[ |
|
1335 |
self toggleSelection:lineNr. |
|
1336 |
self selectionChanged. |
|
2368 | 1337 |
]. |
2365
bdf6954a0358
key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents:
2361
diff
changeset
|
1338 |
^ self |
1390 | 1339 |
]. |
1340 |
||
2377 | 1341 |
aKey == #Return ifTrue:[ |
1342 |
lineNr ~~ 0 ifTrue:[ |
|
1343 |
self cursorEntersItem:nil. |
|
1344 |
||
1345 |
(self canSelectIndex:lineNr forAdd:false) ifTrue:[ |
|
1346 |
self selection:lineNr |
|
1347 |
]. |
|
1348 |
]. |
|
1349 |
self numberOfSelections == 1 ifTrue:[ self doubleClicked ]. |
|
1350 |
^ self |
|
1351 |
]. |
|
1352 |
||
1353 |
(aKey == #CursorUp or:[aKey == #CursorDown or:[aKey == #CmdCursorDown or:[aKey == #CmdCursorUp]]] |
|
1354 |
) ifFalse:[ |
|
2365
bdf6954a0358
key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents:
2361
diff
changeset
|
1355 |
super keyPress:aKey x:x y:y. |
bdf6954a0358
key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents:
2361
diff
changeset
|
1356 |
^ self |
bdf6954a0358
key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents:
2361
diff
changeset
|
1357 |
]. |
1909 | 1358 |
|
2368 | 1359 |
multipleSelectOk ifFalse:[ |
2377 | 1360 |
shifted := false. |
1361 |
lineNr == 0 ifTrue:[ lineNr := selection ? 0 ]. |
|
2368 | 1362 |
] ifTrue:[ |
1363 |
sensor := self sensor. |
|
1364 |
shifted := sensor notNil and:[sensor shiftDown]. |
|
1772 | 1365 |
|
2377 | 1366 |
lineNr == 0 ifTrue:[ |
1367 |
selection size ~~ 0 ifTrue:[ lineNr := selection last ]. |
|
2368 | 1368 |
] |
1369 |
]. |
|
2365
bdf6954a0358
key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents:
2361
diff
changeset
|
1370 |
|
2377 | 1371 |
aKey == #CmdCursorDown ifTrue:[ |
1372 |
lineNr := lineNr + 1. |
|
1373 |
lineNr > listSize ifTrue:[ lineNr := 1]. |
|
1374 |
self cursorEntersItem:(list at:lineNr). |
|
1375 |
^ self |
|
1376 |
]. |
|
1377 |
||
1378 |
aKey == #CmdCursorUp ifTrue:[ |
|
1379 |
lineNr := lineNr - 1. |
|
1380 |
lineNr < 1 ifTrue:[ lineNr := listSize]. |
|
1381 |
self cursorEntersItem:(list at:lineNr). |
|
2368 | 1382 |
^ self |
1390 | 1383 |
]. |
2377 | 1384 |
self cursorEntersItem:nil. |
1385 |
||
1386 |
aKey == #CursorDown ifTrue:[ step := 1 ] |
|
1387 |
ifFalse:[ step := -1 ]. |
|
1388 |
start := lineNr. |
|
1389 |
lineNr := lineNr + step. |
|
2368 | 1390 |
|
2377 | 1391 |
[ lineNr ~~ start ] whileTrue:[ |
1392 |
(lineNr between:1 and:listSize) ifFalse:[ |
|
1393 |
lineNr < 1 ifTrue:[ lineNr := listSize ] |
|
1394 |
ifFalse:[ lineNr := 1 ]. |
|
1395 |
] ifTrue:[ |
|
1396 |
(self canSelectIndex:lineNr forAdd:shifted) ifTrue:[ |
|
1397 |
shifted ifFalse:[ |
|
1398 |
self selection:lineNr. |
|
1399 |
^ self |
|
1400 |
]. |
|
1401 |
(self isInSelection:lineNr) ifFalse:[ |
|
1402 |
selection isNil ifTrue:[ newSel := Array with:lineNr ] |
|
1403 |
ifFalse:[ newSel := selection copyWith:lineNr ]. |
|
1404 |
] ifTrue:[ |
|
1405 |
(start ~~ 0 and:[selection size > 1]) ifFalse:[ |
|
1406 |
^ self |
|
1407 |
]. |
|
1408 |
newSel := selection copyWithout:start. |
|
1409 |
]. |
|
1410 |
self selectWithoutScroll:newSel redraw:true. |
|
1411 |
self makeLineVisible:lineNr. |
|
1412 |
self selectionChanged. |
|
1413 |
^ self |
|
1414 |
]. |
|
1415 |
lineNr := lineNr + step. |
|
1416 |
] |
|
1417 |
]. |
|
1917
21964f5b1cc1
fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents:
1915
diff
changeset
|
1418 |
! |
21964f5b1cc1
fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents:
1915
diff
changeset
|
1419 |
|
2323 | 1420 |
pointerEntersItem:anItemOrNil |
1421 |
"the pointer moves over an item or nil |
|
1422 |
" |
|
1423 |
|lnNr x newItem| |
|
1424 |
||
1425 |
(shown and:[list size ~~ 0]) ifFalse:[ |
|
1426 |
enterItem := nil. |
|
1427 |
^ self. |
|
1428 |
]. |
|
1429 |
||
1430 |
highlightEnterItem ifTrue:[ newItem := anItemOrNil ] |
|
1431 |
ifFalse:[ newItem := nil ]. |
|
1432 |
||
1433 |
anItemOrNil == enterItem ifTrue:[ ^ self ]. |
|
1434 |
||
1435 |
2 timesRepeat:[ |
|
1436 |
enterItem notNil ifTrue:[ |
|
1437 |
lnNr := list identityIndexOf:enterItem. |
|
1438 |
lnNr notNil ifTrue:[ |
|
1439 |
x := self xVisibleOfItem:enterItem. |
|
1440 |
self invalidateLineAt:lnNr fromX:x |
|
1441 |
]. |
|
1442 |
]. |
|
1443 |
"/ set the new item |
|
1444 |
enterItem := anItemOrNil. |
|
1445 |
]. |
|
1446 |
! |
|
1447 |
||
1448 |
pointerLeave:state |
|
1449 |
self pointerEntersItem:nil. |
|
1450 |
super pointerLeave:state. |
|
1451 |
! |
|
1452 |
||
1917
21964f5b1cc1
fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents:
1915
diff
changeset
|
1453 |
sizeChanged:how |
2274
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2250
diff
changeset
|
1454 |
|selectionWasVisible| |
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2250
diff
changeset
|
1455 |
|
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2250
diff
changeset
|
1456 |
selectionWasVisible := false. |
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2250
diff
changeset
|
1457 |
|
1917
21964f5b1cc1
fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents:
1915
diff
changeset
|
1458 |
"/ stupid kludge for motif-style (which draws a frame at the right-edge) |
21964f5b1cc1
fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents:
1915
diff
changeset
|
1459 |
"/ cg: I think it should not (see normal SelectionInListView, which does only |
21964f5b1cc1
fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents:
1915
diff
changeset
|
1460 |
"/ draw the frame at the top and bottom, but NOT at the left and right |
21964f5b1cc1
fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents:
1915
diff
changeset
|
1461 |
selection notNil ifTrue:[ |
2275 | 1462 |
selectionWasVisible := self isSelectionVisibleIn:(previousExtent ? self extent). |
2274
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2250
diff
changeset
|
1463 |
|
1917
21964f5b1cc1
fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents:
1915
diff
changeset
|
1464 |
(hilightFrameColor notNil |
21964f5b1cc1
fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents:
1915
diff
changeset
|
1465 |
or:[hilightStyle == #motif |
21964f5b1cc1
fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents:
1915
diff
changeset
|
1466 |
or:[hilightLevel ~~ 0]]) ifTrue:[ |
21964f5b1cc1
fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents:
1915
diff
changeset
|
1467 |
"/ invalidate the right-edge |
21964f5b1cc1
fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents:
1915
diff
changeset
|
1468 |
self invalidate:(((width-3) @ 0) corner:((width-1) @ (height-1))). |
2225 | 1469 |
]. |
1917
21964f5b1cc1
fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents:
1915
diff
changeset
|
1470 |
]. |
21964f5b1cc1
fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents:
1915
diff
changeset
|
1471 |
super sizeChanged:how. |
2274
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2250
diff
changeset
|
1472 |
|
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2250
diff
changeset
|
1473 |
selectionWasVisible ifTrue:[ |
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2250
diff
changeset
|
1474 |
self makeSelectionVisible |
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2250
diff
changeset
|
1475 |
]. |
1390 | 1476 |
! ! |
1477 |
||
1421 | 1478 |
!SelectionInListModelView methodsFor:'focus handling'! |
1479 |
||
1480 |
wantsFocusWithPointerEnter |
|
1481 |
"return true, if I want the focus when |
|
1482 |
the mouse pointer enters" |
|
1483 |
||
1484 |
|pref| |
|
1485 |
||
1486 |
pref := UserPreferences current focusFollowsMouse. |
|
1487 |
(pref ~~ false |
|
1488 |
and:[(styleSheet at:#'selection.requestFocusOnPointerEnter' default:true) |
|
1489 |
]) ifTrue:[ |
|
2055
964a2cac4e55
take focus on pointer enter only if the list is not empty.
Claus Gittinger <cg@exept.de>
parents:
1920
diff
changeset
|
1490 |
list size > 0 ifTrue:[ |
964a2cac4e55
take focus on pointer enter only if the list is not empty.
Claus Gittinger <cg@exept.de>
parents:
1920
diff
changeset
|
1491 |
^ true |
964a2cac4e55
take focus on pointer enter only if the list is not empty.
Claus Gittinger <cg@exept.de>
parents:
1920
diff
changeset
|
1492 |
] |
1421 | 1493 |
]. |
1494 |
^ false |
|
1495 |
! ! |
|
1496 |
||
1390 | 1497 |
!SelectionInListModelView methodsFor:'initialize / release'! |
1498 |
||
1499 |
fetchResources |
|
1500 |
"fetch device colors and ..., to avoid reallocation at redraw time; |
|
1501 |
*** called after a create or snapin to fetch all device resources |
|
1502 |
" |
|
1503 |
||
1504 |
super fetchResources. |
|
1505 |
||
1506 |
hilightFgColor := self colorOnDevice:hilightFgColor. |
|
1507 |
hilightBgColor := self colorOnDevice:hilightBgColor. |
|
1508 |
hilightFrameColor := self colorOnDevice:hilightFrameColor. |
|
2377 | 1509 |
lineMask := lineMask onDevice:device. |
1390 | 1510 |
! |
1511 |
||
1512 |
initStyle |
|
1513 |
"setup viewStyle specifics |
|
1514 |
" |
|
1515 |
super initStyle. |
|
1516 |
||
2377 | 1517 |
lineMask isNil ifTrue:[ |
1518 |
lineMask := Form width:2 height:2 fromArray:#[16rAA 16r55]. |
|
1519 |
]. |
|
1520 |
||
2228 | 1521 |
hilightFrameColor := nil. |
1522 |
hilightStyle := DefaultHilightStyle. |
|
1523 |
highlightMode := #label. |
|
1524 |
textStartLeft := 4. |
|
2309 | 1525 |
selectOnButtomMenu := styleSheet at:#'selection.selectOnButtomMenu' default:false. |
1390 | 1526 |
|
1741
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
1527 |
super font:(styleSheet fontAt:#'selection.font'). |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
1528 |
|
1390 | 1529 |
device hasGrayscales ifTrue:[ |
1530 |
" |
|
1531 |
must get rid of these hard codings |
|
1532 |
" |
|
1533 |
(hilightStyle == #next) ifTrue:[ |
|
1534 |
hilightFgColor := fgColor. |
|
1535 |
hilightBgColor := White. |
|
1536 |
hilightFrameColor := fgColor |
|
1537 |
] ifFalse:[ |
|
1538 |
(hilightStyle == #motif) ifTrue:[ |
|
1539 |
fgColor := White. |
|
1540 |
bgColor := Grey. |
|
1541 |
viewBackground := bgColor. |
|
1542 |
hilightFgColor := bgColor. |
|
1543 |
hilightBgColor := fgColor. |
|
1544 |
] ifFalse:[ |
|
1545 |
(hilightStyle == #openwin) ifTrue:[ |
|
1546 |
hilightFgColor := fgColor. |
|
1547 |
hilightBgColor := Color grey. |
|
1548 |
] |
|
1549 |
] |
|
1550 |
] |
|
1551 |
]. |
|
1552 |
||
1553 |
hilightFgColor isNil ifTrue:[ |
|
1554 |
hilightFgColor := bgColor. |
|
1555 |
]. |
|
1556 |
hilightBgColor isNil ifTrue:[ |
|
1557 |
hilightBgColor := fgColor. |
|
1558 |
]. |
|
1559 |
DefaultForegroundColor notNil ifTrue:[ |
|
1560 |
fgColor := DefaultForegroundColor |
|
1561 |
]. |
|
1562 |
DefaultBackgroundColor notNil ifTrue:[ |
|
1563 |
bgColor := viewBackground := DefaultBackgroundColor |
|
1564 |
]. |
|
1565 |
||
1566 |
DefaultHilightForegroundColor notNil ifTrue:[ |
|
1567 |
hilightFgColor := DefaultHilightForegroundColor |
|
1568 |
]. |
|
1569 |
DefaultHilightBackgroundColor notNil ifTrue:[ |
|
1570 |
hilightBgColor := DefaultHilightBackgroundColor |
|
1571 |
]. |
|
1572 |
DefaultHilightFrameColor notNil ifTrue:[ |
|
1573 |
hilightFrameColor := DefaultHilightFrameColor |
|
1574 |
]. |
|
1575 |
||
1741
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
1576 |
hilightLevel := DefaultHilightLevel ? 0. |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
1577 |
lineSpacing := (hilightLevel abs > 0) ifTrue:[3] ifFalse:[2]. |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
1578 |
|
1390 | 1579 |
hilightFgColor isNil ifTrue:[ |
1580 |
hilightFgColor := bgColor. |
|
1581 |
hilightBgColor := fgColor |
|
1582 |
]. |
|
1583 |
! |
|
1584 |
||
1585 |
initialize |
|
1586 |
"setup default attributes/behavior |
|
1587 |
" |
|
2323 | 1588 |
multipleSelectOk := false. |
1589 |
useIndex := true. |
|
1590 |
ignoreReselect := true. |
|
1591 |
toggleSelect := false. |
|
1592 |
highlightEnterItem := false. |
|
2324 | 1593 |
|
1594 |
super initialize. |
|
1390 | 1595 |
! |
1596 |
||
1745 | 1597 |
mapped |
1598 |
"get selection from model; scroll to selection |
|
1599 |
" |
|
1600 |
super mapped. |
|
1601 |
self makeSelectionVisible. |
|
1602 |
! |
|
1603 |
||
1390 | 1604 |
realize |
1605 |
"get selection from model; scroll to selection |
|
1606 |
" |
|
2302
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2275
diff
changeset
|
1607 |
self updateFromModel. |
1390 | 1608 |
super realize. |
1609 |
! ! |
|
1610 |
||
1755 | 1611 |
!SelectionInListModelView methodsFor:'private editor'! |
1612 |
||
1613 |
computeEditorLayout |
|
1614 |
"update the layout of the editor |
|
1615 |
" |
|
1616 |
|lnNr item y x h| |
|
1617 |
||
1618 |
editorView isNil ifTrue:[ |
|
1619 |
^ self |
|
1620 |
]. |
|
1621 |
||
1622 |
( (lnNr := self selectedIndex) == 0 |
|
1623 |
or:[(item := list at:lnNr ifAbsent:nil) isNil] |
|
1624 |
) ifTrue:[ |
|
1625 |
"/ there is no more single selection; thus close the editor |
|
1626 |
^ self closeEditor |
|
1627 |
]. |
|
1628 |
||
1629 |
y := self yVisibleOfLine:lnNr. |
|
1630 |
x := (self xVisibleOfItem:item) - (textStartLeft // 2). |
|
1631 |
h := self yVisibleOfLine:(lnNr + 1). |
|
1632 |
||
1633 |
editorView layout:( Rectangle left:x top:y right:(width - 1 - margin) bottom:(h - 1) ). |
|
1634 |
! |
|
1635 |
||
1636 |
openEditorAtX:x y:y |
|
1637 |
"opens an editor on the current single selection |
|
1638 |
" |
|
2225 | 1639 |
|item lnNr x0 y0 editor| |
1755 | 1640 |
|
1641 |
self closeEditor. |
|
2308 | 1642 |
shown ifFalse:[^ self ]. |
1643 |
openEditorAction isNil ifTrue:[^ self]. |
|
1755 | 1644 |
|
2225 | 1645 |
lnNr := self selectedIndex. |
1646 |
lnNr == 0 ifTrue:[^ self]. |
|
1647 |
||
1648 |
item := list at:lnNr ifAbsent:nil. |
|
2308 | 1649 |
item isNil ifTrue:[^ self]. |
1755 | 1650 |
|
1915 | 1651 |
x < (self xVisibleOfItem:item) ifTrue:[ |
1652 |
"/ not part of the selection frame; ignorre |
|
1653 |
^ self |
|
1755 | 1654 |
]. |
2225 | 1655 |
editor := self openEditor. |
2308 | 1656 |
editor isNil ifTrue:[^ self]. |
1755 | 1657 |
|
2225 | 1658 |
y0 := (y - editor origin y) max:0. |
1659 |
x0 := (x - editor origin x) max:0. |
|
1755 | 1660 |
|
2125 | 1661 |
"/ simulate clicking into the editor |
2225 | 1662 |
self sensor pushEvent:(WindowEvent buttonPress:#select x:x0 y:y0 view:editor). |
1663 |
self sensor pushEvent:(WindowEvent buttonRelease:#select x:x0 y:y0 view:editor). |
|
1755 | 1664 |
|
1665 |
"/ to clear the selection |
|
2245
546c6e5d0951
change #redrawSelectionAt: to #invalidateSelectionAt: (because is a invalidate)
ca
parents:
2228
diff
changeset
|
1666 |
self invalidateLineAt:lnNr. |
1755 | 1667 |
! ! |
1668 |
||
1390 | 1669 |
!SelectionInListModelView methodsFor:'protocol'! |
1670 |
||
1533 | 1671 |
drawElementsFrom:start to:stop x:x y:y w:w |
1390 | 1672 |
"draw the items between start to stop without clearing the background |
1673 |
" |
|
1674 |
|y0 "{ Class:SmallInteger }" |
|
1675 |
y1 "{ Class:SmallInteger }" |
|
1676 |
x0 "{ Class:SmallInteger }" |
|
1677 |
| |
|
1678 |
x0 := textStartLeft - viewOrigin x. |
|
1533 | 1679 |
y1 := y. |
1390 | 1680 |
|
1681 |
start to:stop do:[:i| |
|
1682 |
y0 := y1. |
|
1683 |
y1 := self yVisibleOfLine:(i + 1). |
|
1533 | 1684 |
self drawLabelAt:i x:x0 y:y0 h:(y1 - y0) |
1390 | 1685 |
]. |
1686 |
||
1687 |
||
1688 |
! |
|
1689 |
||
1458 | 1690 |
lostSynchronisation |
1691 |
"called when the changes derived from the model are faster than the handling |
|
1692 |
" |
|
1547 | 1693 |
self deselectWithoutRedraw. |
1458 | 1694 |
super lostSynchronisation. |
1554 | 1695 |
! |
1696 |
||
1697 |
xVisibleOfItem:anItem |
|
1698 |
"returns the visible x of the labeled text |
|
1699 |
" |
|
1700 |
^ textStartLeft - viewOrigin x |
|
1701 |
||
1702 |
||
1390 | 1703 |
! ! |
1704 |
||
2330 | 1705 |
!SelectionInListModelView methodsFor:'queries'! |
1706 |
||
1707 |
isCursorKeyConsumer |
|
1708 |
"return true, if the receiver can be controlled by cursor keys; |
|
1709 |
i.e. it can handle some keyboard input, |
|
1710 |
isCursorKeyConsumer are potential candidates for getting the keyboard |
|
1711 |
focus initially within dialogBoxes, or when the focus-follows-pointer |
|
1712 |
mode is off. |
|
1713 |
Return false here, this is redefined in SelectionInListView." |
|
1714 |
||
1715 |
^ true |
|
1716 |
! ! |
|
1717 |
||
1390 | 1718 |
!SelectionInListModelView methodsFor:'selection'! |
1719 |
||
1720 |
deselect |
|
1721 |
"clear selection |
|
1722 |
" |
|
1723 |
self selection:nil |
|
1724 |
||
1725 |
! |
|
1726 |
||
1727 |
firstInSelection |
|
2399 | 1728 |
"returns the minimum index of selected indices or nil if nothing is selected |
1390 | 1729 |
" |
2365
bdf6954a0358
key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents:
2361
diff
changeset
|
1730 |
|size min| |
bdf6954a0358
key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents:
2361
diff
changeset
|
1731 |
|
bdf6954a0358
key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents:
2361
diff
changeset
|
1732 |
selection isNil ifTrue:[^ nil]. |
bdf6954a0358
key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents:
2361
diff
changeset
|
1733 |
|
1545 | 1734 |
multipleSelectOk ifFalse:[ |
1735 |
^ selection |
|
1390 | 1736 |
]. |
2365
bdf6954a0358
key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents:
2361
diff
changeset
|
1737 |
size := selection size. |
bdf6954a0358
key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents:
2361
diff
changeset
|
1738 |
size == 0 ifTrue:[ ^ nil ]. |
bdf6954a0358
key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents:
2361
diff
changeset
|
1739 |
|
bdf6954a0358
key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents:
2361
diff
changeset
|
1740 |
min := selection at:1. |
bdf6954a0358
key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents:
2361
diff
changeset
|
1741 |
|
bdf6954a0358
key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents:
2361
diff
changeset
|
1742 |
size > 1 ifTrue:[ |
bdf6954a0358
key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents:
2361
diff
changeset
|
1743 |
selection do:[:aNumber| min := min min:aNumber ]. |
bdf6954a0358
key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents:
2361
diff
changeset
|
1744 |
]. |
bdf6954a0358
key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents:
2361
diff
changeset
|
1745 |
^ min |
1390 | 1746 |
! |
1747 |
||
1748 |
hasSelection |
|
1749 |
"returns true if a selection exists |
|
1750 |
" |
|
1751 |
^ selection notNil |
|
1752 |
||
1753 |
! |
|
1754 |
||
1755 |
isInSelection:aNumber |
|
1756 |
"return true, if line, aNumber is in the selection |
|
1757 |
" |
|
1545 | 1758 |
multipleSelectOk ifFalse:[ |
1759 |
^ aNumber == selection |
|
1760 |
]. |
|
1761 |
^ selection isNil ifTrue:[false] |
|
1762 |
ifFalse:[selection includesIdentical:aNumber] |
|
1390 | 1763 |
! |
1764 |
||
2274
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2250
diff
changeset
|
1765 |
isSelectionVisible |
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2250
diff
changeset
|
1766 |
"returns true if any selected element is visible" |
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2250
diff
changeset
|
1767 |
|
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2250
diff
changeset
|
1768 |
^ self isSelectionVisibleIn:self extent |
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2250
diff
changeset
|
1769 |
! |
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2250
diff
changeset
|
1770 |
|
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2250
diff
changeset
|
1771 |
isSelectionVisibleIn:anExtentPoint |
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2250
diff
changeset
|
1772 |
"returns true if any selected element is visible" |
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2250
diff
changeset
|
1773 |
|
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2250
diff
changeset
|
1774 |
self selectionDo:[:aLineNr| |
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2250
diff
changeset
|
1775 |
(self isLineVisible:aLineNr in:anExtentPoint) ifTrue:[^ true]. |
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2250
diff
changeset
|
1776 |
]. |
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2250
diff
changeset
|
1777 |
^ false |
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2250
diff
changeset
|
1778 |
! |
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2250
diff
changeset
|
1779 |
|
2330 | 1780 |
lastInSelection |
2399 | 1781 |
"returns the maximum index of selected indices or nil if nothing is selected |
2330 | 1782 |
" |
2365
bdf6954a0358
key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents:
2361
diff
changeset
|
1783 |
|size max| |
bdf6954a0358
key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents:
2361
diff
changeset
|
1784 |
|
bdf6954a0358
key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents:
2361
diff
changeset
|
1785 |
selection isNil ifTrue:[^ nil]. |
2330 | 1786 |
|
1787 |
multipleSelectOk ifFalse:[ |
|
1788 |
^ selection |
|
1789 |
]. |
|
1790 |
size := selection size. |
|
2365
bdf6954a0358
key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents:
2361
diff
changeset
|
1791 |
size == 0 ifTrue:[ ^ nil ]. |
bdf6954a0358
key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents:
2361
diff
changeset
|
1792 |
size == 1 ifTrue:[ ^ selection at:1 ]. |
2330 | 1793 |
|
2365
bdf6954a0358
key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents:
2361
diff
changeset
|
1794 |
max := 1. |
bdf6954a0358
key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents:
2361
diff
changeset
|
1795 |
selection do:[:aNumber| max := max max:aNumber ]. |
bdf6954a0358
key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents:
2361
diff
changeset
|
1796 |
^ max |
2330 | 1797 |
! |
1798 |
||
1799 |
makeSelectionVisible |
|
1800 |
"scroll to make the selection line visible |
|
1801 |
" |
|
2368 | 1802 |
self makeLineVisible:(self firstInSelection). |
2365
bdf6954a0358
key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents:
2361
diff
changeset
|
1803 |
! |
bdf6954a0358
key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents:
2361
diff
changeset
|
1804 |
|
1390 | 1805 |
numberOfSelections |
1806 |
"return the number of selected items |
|
1807 |
" |
|
2330 | 1808 |
selection isNil ifTrue:[ ^ 0 ]. |
1809 |
multipleSelectOk ifFalse:[ ^ 1 ]. |
|
1810 |
^ selection size |
|
1390 | 1811 |
! |
1812 |
||
1813 |
selectElement:anElement |
|
1814 |
"select the element. Scroll to make the new selection visible. |
|
1815 |
Model and/or actionBlock notification IS done. |
|
1816 |
" |
|
2178 | 1817 |
self selectElement:anElement ifAbsent:[self deselect] |
1818 |
! |
|
1819 |
||
1820 |
selectElement:anElement ifAbsent:exceptionalValue |
|
1821 |
|idx| |
|
1822 |
||
1823 |
idx := list identityIndexOf:anElement. |
|
1824 |
idx == 0 ifTrue:[ |
|
1825 |
^ exceptionalValue value |
|
1826 |
]. |
|
1827 |
self selection:idx |
|
1390 | 1828 |
! |
1829 |
||
2399 | 1830 |
selectFrom:aStart to:aStop |
1831 |
"select lines between start and stop |
|
1832 |
" |
|
1833 |
|start stop step nsel| |
|
1834 |
||
1835 |
multipleSelectOk ifFalse:[^ self]. |
|
1836 |
||
1837 |
start := aStart. |
|
1838 |
stop := aStop. |
|
1839 |
||
1840 |
aStart < aStop ifTrue:[ |
|
1841 |
start := aStart max:1. |
|
1842 |
stop := aStop min:(list size). |
|
1843 |
step := 1. |
|
1844 |
start > stop ifTrue:[^ self]. |
|
1845 |
||
1846 |
] ifFalse:[ |
|
1847 |
start := aStart min:(list size). |
|
1848 |
stop := aStop max:1. |
|
1849 |
step := -1. |
|
1850 |
start < stop ifTrue:[^ self]. |
|
1851 |
]. |
|
1852 |
nsel := OrderedCollection new. |
|
1853 |
||
1854 |
start to:stop by:step do:[:i| |
|
1855 |
(self canSelectIndex:i forAdd:true) ifTrue:[ |
|
1856 |
nsel add:i. |
|
1857 |
]. |
|
1858 |
]. |
|
1859 |
||
1860 |
(self selectWithoutScroll:nsel redraw:true) ifTrue:[ |
|
1861 |
self selectionChanged |
|
1862 |
]. |
|
1863 |
! |
|
1864 |
||
1390 | 1865 |
selectedElement |
1866 |
"return the single selected item or nil |
|
1867 |
" |
|
1545 | 1868 |
|index| |
1390 | 1869 |
|
1545 | 1870 |
(index := self selectedIndex) ~~ 0 ifTrue:[ |
1871 |
^ list at:index ifAbsent:nil |
|
1872 |
]. |
|
1873 |
^ nil |
|
1390 | 1874 |
! |
1875 |
||
1876 |
selectedIndex |
|
1877 |
"returns the index of the selected line or 0. If more |
|
1878 |
lines are selected, 0 is returned |
|
1879 |
" |
|
2365
bdf6954a0358
key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents:
2361
diff
changeset
|
1880 |
selection notNil ifTrue:[ |
bdf6954a0358
key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents:
2361
diff
changeset
|
1881 |
multipleSelectOk ifFalse:[ ^ selection ]. |
bdf6954a0358
key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents:
2361
diff
changeset
|
1882 |
|
bdf6954a0358
key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents:
2361
diff
changeset
|
1883 |
selection size == 1 ifTrue:[ |
bdf6954a0358
key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents:
2361
diff
changeset
|
1884 |
^ selection at:1 |
bdf6954a0358
key handling: EndOfText EndOfLine BeginOfText BeginOfLine
ca
parents:
2361
diff
changeset
|
1885 |
] |
1545 | 1886 |
]. |
1887 |
^ 0 |
|
1390 | 1888 |
! |
1889 |
||
1890 |
selection |
|
1891 |
"return the selection index or collection of indices |
|
1892 |
in case of multiple selection enabled |
|
1893 |
" |
|
1894 |
^ selection |
|
1895 |
||
1896 |
! |
|
1897 |
||
1545 | 1898 |
selection:something |
1899 |
"select something or deselect if the argument is nil; |
|
1390 | 1900 |
scroll to make the selected line visible. |
1901 |
The model and/or actionBlock IS notified. |
|
1902 |
" |
|
1545 | 1903 |
(self selectWithoutScroll:something redraw:true) ifTrue:[ |
1904 |
self makeSelectionVisible. |
|
1390 | 1905 |
self selectionChanged |
1545 | 1906 |
]. |
1390 | 1907 |
|
1908 |
! |
|
1909 |
||
2330 | 1910 |
selectionAsCollection |
1911 |
"return the selection as a collection of line numbers. |
|
1912 |
This allows users of this class to enumerate independent of |
|
1913 |
the multipleSelect style. |
|
1914 |
" |
|
1915 |
selection isNil ifTrue:[ ^ #() ]. |
|
1916 |
multipleSelectOk ifTrue:[ ^ selection ]. |
|
1917 |
||
1918 |
^ OrderedCollection with:selection |
|
1919 |
! |
|
1920 |
||
1390 | 1921 |
selectionDo:aBlock |
1922 |
"perform aBlock for each nr in the selection. |
|
1923 |
For single selection, it is called once for the items nr. |
|
1924 |
For multiple selections, it is called for each. |
|
1925 |
" |
|
1926 |
selection notNil ifTrue:[ |
|
1927 |
multipleSelectOk ifTrue:[ |
|
1928 |
selection do:aBlock |
|
1929 |
] ifFalse:[ |
|
1930 |
aBlock value:selection |
|
1931 |
]. |
|
1932 |
]. |
|
1933 |
||
1934 |
||
1935 |
! |
|
1936 |
||
2330 | 1937 |
selectionValue |
1938 |
"return the selection value i.e. the text in the selected line. |
|
1939 |
For multiple selections a collection containing the entries is returned. |
|
1940 |
" |
|
1941 |
multipleSelectOk ifTrue:[ |
|
1942 |
selection isNil ifTrue:[^ #()]. |
|
1943 |
^ selection collect:[:nr| list at:nr ] |
|
1944 |
]. |
|
1945 |
selection isNil ifTrue:[^ nil]. |
|
1946 |
^ list at:selection ifAbsent:nil. |
|
1947 |
! |
|
1948 |
||
2346 | 1949 |
selectionValueAsCollection |
1950 |
"return the selection values as a collection - allows selectionValues to |
|
1951 |
be enumerated independent of the multiSelect settings |
|
1952 |
" |
|
1953 |
|value| |
|
1954 |
||
1955 |
value := self selectionValue. |
|
1956 |
multipleSelectOk ifTrue:[^ value]. |
|
1957 |
||
1958 |
value notNil ifTrue:[^ Array with:value ]. |
|
1959 |
^ #() |
|
1960 |
! |
|
1961 |
||
1542
8607d072c319
accessing selection through to selector
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
1962 |
setSelection:something |
1545 | 1963 |
"select something or deselect if the argument is nil; |
1390 | 1964 |
scroll to make the selected line visible. |
1965 |
*** No model and/or actionBlock notification is done here. |
|
1966 |
" |
|
1545 | 1967 |
(self selectWithoutScroll:something redraw:true) ifTrue:[ |
1390 | 1968 |
self makeSelectionVisible |
1969 |
] |
|
1970 |
||
1971 |
! ! |
|
1972 |
||
1973 |
!SelectionInListModelView methodsFor:'selection private'! |
|
1974 |
||
1641 | 1975 |
canSelectIndex:anIndex |
1976 |
"return true, if the object identified by its index is selectable |
|
1977 |
" |
|
1920 | 1978 |
^ self canSelectIndex:anIndex forAdd:false |
1979 |
! |
|
1980 |
||
1981 |
canSelectIndex:anIndex forAdd:isForAdd |
|
1982 |
"return true, if the object identified by its index is selectable |
|
1983 |
" |
|
1984 |
|item isOk| |
|
1649 | 1985 |
|
1986 |
selectConditionBlock notNil ifTrue:[ |
|
1920 | 1987 |
selectConditionBlock numArgs == 2 ifTrue:[ |
1988 |
isOk := selectConditionBlock value:anIndex value:isForAdd. |
|
1989 |
] ifFalse:[ |
|
1990 |
isOk := selectConditionBlock value:anIndex. |
|
1991 |
]. |
|
1992 |
isOk ifFalse:[ |
|
1649 | 1993 |
^ false |
1994 |
] |
|
1641 | 1995 |
]. |
1996 |
||
1752 | 1997 |
item := list at:anIndex ifAbsent:nil. |
1998 |
item isNil ifTrue:[^ false]. |
|
1999 |
item isHierarchicalItem ifTrue:[ |
|
1649 | 2000 |
^ item isSelectable |
2001 |
]. |
|
2002 |
^ true |
|
1641 | 2003 |
! |
2004 |
||
1547 | 2005 |
deselectWithoutRedraw |
2006 |
"clear the selection without redraw and scrolling; |
|
2007 |
the model and/or actionBlock is notified |
|
2008 |
" |
|
2009 |
(self selectWithoutScroll:nil redraw:false) ifTrue:[ |
|
2010 |
self selectionChanged |
|
2011 |
] |
|
2012 |
! |
|
2013 |
||
1545 | 2014 |
selectWithoutScroll:something redraw:doRedraw |
2015 |
"change selection to something; returns true if selection changed |
|
1390 | 2016 |
" |
2017 |
|oldSelect| |
|
2018 |
||
1554 | 2019 |
selection = something ifTrue:[^ false]. |
2020 |
||
1390 | 2021 |
oldSelect := selection. |
2022 |
||
1545 | 2023 |
(something isNil or:[something == 0]) ifTrue:[ |
2024 |
selection := nil |
|
2025 |
] ifFalse:[ |
|
2026 |
something isNumber ifTrue:[ |
|
1564 | 2027 |
selection := multipleSelectOk ifTrue:[Array with:something] |
2028 |
ifFalse:[something] |
|
1545 | 2029 |
] ifFalse:[ |
2030 |
something size == 0 ifTrue:[ |
|
2031 |
selection := nil |
|
2032 |
] ifFalse:[ |
|
2033 |
selection := multipleSelectOk ifTrue:[something] |
|
2034 |
ifFalse:[something at:1] |
|
2035 |
] |
|
2036 |
] |
|
2037 |
]. |
|
2038 |
selection = oldSelect ifTrue:[^ false]. |
|
1755 | 2039 |
self closeEditor. |
2377 | 2040 |
self cursorEntersItem:nil. |
1545 | 2041 |
|
2042 |
(doRedraw and:[shown]) ifFalse:[ |
|
2043 |
^ true |
|
1390 | 2044 |
]. |
2045 |
||
2046 |
multipleSelectOk ifFalse:[ |
|
2245
546c6e5d0951
change #redrawSelectionAt: to #invalidateSelectionAt: (because is a invalidate)
ca
parents:
2228
diff
changeset
|
2047 |
oldSelect notNil ifTrue:[self invalidateSelectionAt:oldSelect]. |
546c6e5d0951
change #redrawSelectionAt: to #invalidateSelectionAt: (because is a invalidate)
ca
parents:
2228
diff
changeset
|
2048 |
selection notNil ifTrue:[self invalidateSelectionAt:selection]. |
1390 | 2049 |
] ifTrue:[ |
1545 | 2050 |
(selection notNil and:[oldSelect notNil]) ifTrue:[ |
2245
546c6e5d0951
change #redrawSelectionAt: to #invalidateSelectionAt: (because is a invalidate)
ca
parents:
2228
diff
changeset
|
2051 |
selection do:[:i|(oldSelect includesIdentical:i) ifFalse:[self invalidateSelectionAt:i]]. |
546c6e5d0951
change #redrawSelectionAt: to #invalidateSelectionAt: (because is a invalidate)
ca
parents:
2228
diff
changeset
|
2052 |
oldSelect do:[:i|(selection includesIdentical:i) ifFalse:[self invalidateSelectionAt:i]]. |
1390 | 2053 |
] ifFalse:[ |
1545 | 2054 |
oldSelect isNil ifTrue:[oldSelect := selection]. |
2245
546c6e5d0951
change #redrawSelectionAt: to #invalidateSelectionAt: (because is a invalidate)
ca
parents:
2228
diff
changeset
|
2055 |
oldSelect do:[:i|self invalidateSelectionAt:i] |
1390 | 2056 |
] |
2057 |
]. |
|
1545 | 2058 |
^ true |
1561 | 2059 |
! |
2060 |
||
2061 |
toggleSelection:aNumber |
|
2062 |
"add a number to the selection. No scrolling is done. |
|
2063 |
*** No model and/or actionBlock notification is done here. |
|
2064 |
" |
|
2245
546c6e5d0951
change #redrawSelectionAt: to #invalidateSelectionAt: (because is a invalidate)
ca
parents:
2228
diff
changeset
|
2065 |
|oldSelect doRemove| |
1561 | 2066 |
|
2067 |
multipleSelectOk ifFalse:[ |
|
2068 |
aNumber == selection ifTrue:[ "/ remove from selection |
|
2069 |
selection := nil. |
|
2070 |
] ifFalse:[ "/ add to selection |
|
2071 |
oldSelect := selection. |
|
2072 |
selection := aNumber. |
|
2073 |
||
2074 |
oldSelect notNil ifTrue:[ |
|
2245
546c6e5d0951
change #redrawSelectionAt: to #invalidateSelectionAt: (because is a invalidate)
ca
parents:
2228
diff
changeset
|
2075 |
self invalidateSelectionAt:oldSelect |
1561 | 2076 |
] |
2077 |
]. |
|
2245
546c6e5d0951
change #redrawSelectionAt: to #invalidateSelectionAt: (because is a invalidate)
ca
parents:
2228
diff
changeset
|
2078 |
self invalidateSelectionAt:aNumber. |
1561 | 2079 |
^ self |
2080 |
]. |
|
2081 |
||
2082 |
selection isNil ifTrue:[ "/ add to empty selection |
|
2083 |
selection := OrderedCollection with:aNumber. |
|
2245
546c6e5d0951
change #redrawSelectionAt: to #invalidateSelectionAt: (because is a invalidate)
ca
parents:
2228
diff
changeset
|
2084 |
self invalidateSelectionAt:aNumber. |
1561 | 2085 |
^ self |
2086 |
]. |
|
2087 |
||
2088 |
doRemove := selection includesIdentical:aNumber. |
|
2089 |
||
2090 |
(doRemove and:[selection size == 1]) ifTrue:[ "/ remove selection |
|
2091 |
selection := nil. |
|
2245
546c6e5d0951
change #redrawSelectionAt: to #invalidateSelectionAt: (because is a invalidate)
ca
parents:
2228
diff
changeset
|
2092 |
self invalidateSelectionAt:aNumber. |
1561 | 2093 |
^ self |
2094 |
]. |
|
2095 |
||
2096 |
selection := selection asOrderedCollection. |
|
2097 |
||
2098 |
doRemove ifTrue:[ |
|
2099 |
selection removeIdentical:aNumber. |
|
2100 |
] ifFalse:[ |
|
2101 |
selection add:aNumber. |
|
2102 |
]. |
|
2245
546c6e5d0951
change #redrawSelectionAt: to #invalidateSelectionAt: (because is a invalidate)
ca
parents:
2228
diff
changeset
|
2103 |
self invalidateSelectionAt:aNumber. |
1390 | 2104 |
! ! |
2105 |
||
2106 |
!SelectionInListModelView class methodsFor:'documentation'! |
|
2107 |
||
2108 |
version |
|
2399 | 2109 |
^ '$Header: /cvs/stx/stx/libwidg2/SelectionInListModelView.st,v 1.71 2002-12-06 09:04:41 ca Exp $' |
1390 | 2110 |
! ! |