author | penk |
Fri, 27 Sep 2002 13:53:27 +0200 | |
changeset 2225 | d785c9d86aa3 |
parent 2185 | 639d20ab5667 |
child 2228 | 5268b9c3be4a |
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 |
17 |
instanceVariableNames:'selection multipleSelectOk actionBlock doubleClickActionBlock |
|
1641 | 18 |
selectConditionBlock clickLine highlightMode useIndex |
1741
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
19 |
ignoreReselect toggleSelect hilightFgColor hilightBgColor |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
20 |
hilightLevel hilightFrameColor hilightStyle dragAccessPoint |
1755 | 21 |
dropTarget dropSource editorView openEditorAction' |
1390 | 22 |
classVariableNames:'DefaultHilightStyle DefaultHilightBackgroundColor |
23 |
DefaultHilightForegroundColor DefaultHilightLevel |
|
24 |
DefaultHilightFrameColor' |
|
25 |
poolDictionaries:'' |
|
1430 | 26 |
category:'Views-Lists' |
1390 | 27 |
! |
28 |
||
29 |
!SelectionInListModelView class methodsFor:'documentation'! |
|
30 |
||
1431 | 31 |
copyright |
32 |
" |
|
33 |
COPYRIGHT (c) 1999 by eXept Software AG |
|
34 |
All Rights Reserved |
|
35 |
||
36 |
This software is furnished under a license and may be used |
|
37 |
only in accordance with the terms of that license and with the |
|
38 |
inclusion of the above copyright notice. This software may not |
|
39 |
be provided or otherwise made available to, or used by, any |
|
40 |
other person. No title to or ownership of the software is |
|
41 |
hereby transferred. |
|
42 |
" |
|
43 |
||
44 |
! |
|
45 |
||
1390 | 46 |
documentation |
47 |
" |
|
48 |
SelectionInListModelView is mostly like SelectionInListView, |
|
49 |
but derives from the ListModelView and thus the list is kept |
|
50 |
by the model. |
|
51 |
||
52 |
[Instance variables:] |
|
53 |
selection <misc> the current selection. nil, a number or collection of numbers |
|
54 |
multipleSelectOk <Boolean> allow/disallow multiple selections( default:false ) |
|
55 |
actionBlock <Block> action evaluated on single click |
|
56 |
doubleClickActionBlock <Block> action evaluated on double click |
|
57 |
clickPosition <Point> internal use |
|
58 |
highlightMode <Symbol> how to draw the selection |
|
59 |
useIndex <Boolean> representation of the model selection |
|
1741
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
60 |
ignoreReselect <Boolean> if set, a click on an already selected entry is ignored |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
61 |
toggleSelect <Boolean> a click on an entry unselects it and vice versa |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
62 |
hilightFgColor <Color> foregroundColor of highlighted items |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
63 |
hilightBgColor <Color> backgroundColor of highlighted items |
1390 | 64 |
hilightLevel <Integer> level to draw selections (i.e. for 3D effect) |
65 |
hilightFrameColor <Color> rectangle around highlighted items |
|
66 |
hilightStyle <Boolean> actions on widget are enabled/disabled |
|
67 |
||
68 |
[author:] |
|
69 |
Claus Atzkern |
|
70 |
||
71 |
[see also:] |
|
72 |
||
73 |
ListModelView |
|
74 |
HierarchicalListView |
|
75 |
" |
|
76 |
||
77 |
||
78 |
! |
|
79 |
||
80 |
examples |
|
81 |
" |
|
82 |
[exBegin] |
|
83 |
|top list view| |
|
84 |
||
85 |
list := List new. |
|
86 |
||
87 |
1 to:100 do:[:i| list add:('element: ', i printString) ]. |
|
88 |
top := StandardSystemView new; extent:300@300. |
|
89 |
view := ScrollableView for:SelectionInListModelView miniScroller:true |
|
90 |
origin:0.0@0.0 corner:1.0@1.0 in:top. |
|
91 |
view list:list. |
|
92 |
top open. |
|
93 |
[exEnd] |
|
94 |
||
95 |
||
96 |
[exBegin] |
|
1915 | 97 |
|top list view| |
98 |
||
99 |
list := List new. |
|
100 |
||
101 |
1 to:100 do:[:i| list add:('element: ', i printString) ]. |
|
102 |
top := StandardSystemView new; extent:300@300. |
|
103 |
view := ScrollableView for:SelectionInListModelView miniScroller:true |
|
104 |
origin:0.0@0.0 corner:1.0@1.0 in:top. |
|
105 |
view list:list. |
|
106 |
||
107 |
view openEditorAction:[:ln :aGC| |field| |
|
108 |
field := EditField new. |
|
109 |
field level:0. |
|
110 |
field acceptOnLostFocus:true. |
|
111 |
field acceptAction:[:x| list at:ln put:(field contents) ]. |
|
112 |
field font:(aGC font). |
|
113 |
field contents:(list at:ln). |
|
114 |
field |
|
115 |
]. |
|
116 |
top open. |
|
117 |
[exEnd] |
|
118 |
||
119 |
[exBegin] |
|
1390 | 120 |
|top list view item| |
121 |
||
122 |
list := HierarchicalList new. |
|
123 |
item := HierarchicalItem::Example labeled:'Test'. |
|
124 |
item expand. |
|
125 |
list showRoot:false. |
|
126 |
list root:item. |
|
127 |
||
128 |
top := StandardSystemView new; extent:300@300. |
|
129 |
view := ScrollableView for:SelectionInListModelView miniScroller:true |
|
130 |
origin:0.0@0.0 corner:1.0@1.0 in:top. |
|
131 |
||
132 |
view list:list. |
|
133 |
view doubleClickAction:[:i| (list at:i) toggleExpand ]. |
|
134 |
top open. |
|
135 |
[exEnd] |
|
136 |
||
137 |
" |
|
138 |
! ! |
|
139 |
||
140 |
!SelectionInListModelView class methodsFor:'defaults'! |
|
141 |
||
142 |
updateStyleCache |
|
143 |
"extract values from the styleSheet and cache them in class variables" |
|
144 |
||
145 |
<resource: #style ( |
|
146 |
#'selection.hilightForegroundColor' #'selection.hilightBackgroundColor' |
|
147 |
#'selection.hilightFrameColor' #'selection.hilightLevel' |
|
148 |
#'selection.foregroundColor' #'selection.backgroundColor' |
|
149 |
#'selection.shadowColor' #'selection.lightColor' |
|
150 |
#'selection.font' #'selection.hilightStyle' |
|
151 |
#'text.foregroundColor' |
|
152 |
)> |
|
153 |
||
154 |
DefaultHilightForegroundColor := StyleSheet colorAt:'selection.hilightForegroundColor'. |
|
155 |
DefaultHilightBackgroundColor := StyleSheet colorAt:'selection.hilightBackgroundColor'. |
|
156 |
DefaultHilightFrameColor := StyleSheet colorAt:'selection.hilightFrameColor'. |
|
157 |
DefaultHilightLevel := StyleSheet at:'selection.hilightLevel' default:0. |
|
158 |
DefaultHilightStyle := StyleSheet at:'selection.hilightStyle' default:(StyleSheet name). |
|
159 |
DefaultForegroundColor := StyleSheet colorAt:'selection.foregroundColor'. |
|
160 |
DefaultBackgroundColor := StyleSheet colorAt:'selection.backgroundColor'. |
|
161 |
DefaultShadowColor := StyleSheet colorAt:'selection.shadowColor'. |
|
162 |
DefaultLightColor := StyleSheet colorAt:'selection.lightColor'. |
|
163 |
||
164 |
DefaultForegroundColor isNil ifTrue:[ |
|
165 |
DefaultForegroundColor := StyleSheet colorAt:'text.foregroundColor' default:Black |
|
166 |
]. |
|
167 |
" |
|
168 |
self updateStyleCache |
|
169 |
" |
|
170 |
||
171 |
||
172 |
! ! |
|
173 |
||
174 |
!SelectionInListModelView methodsFor:'accessing'! |
|
175 |
||
176 |
list:aList |
|
177 |
"get the status of <showRoot> from the list |
|
178 |
" |
|
1547 | 179 |
self deselectWithoutRedraw. |
1390 | 180 |
^ super list:aList |
181 |
! ! |
|
182 |
||
2225 | 183 |
!SelectionInListModelView methodsFor:'accessing editor'! |
184 |
||
185 |
closeEditor |
|
186 |
"close the current editor |
|
187 |
" |
|
188 |
|editor| |
|
189 |
||
190 |
(editor := editorView) notNil ifTrue:[ |
|
191 |
editorView := nil. |
|
192 |
editor destroy. |
|
193 |
]. |
|
194 |
||
195 |
||
196 |
! |
|
197 |
||
198 |
openEditor |
|
199 |
"opens the editor on the current selection; |
|
200 |
returns the editorView or nil if no openEditorAction is defined |
|
201 |
or no single selection exists ... |
|
202 |
" |
|
203 |
|numArgs lnNr| |
|
204 |
||
205 |
self closeEditor. |
|
206 |
shown ifFalse:[^ nil]. |
|
207 |
openEditorAction ifNil:[^ nil]. |
|
208 |
lnNr := self selectedIndex. |
|
209 |
lnNr == 0 ifTrue:[^ nil]. |
|
210 |
||
211 |
self makeSelectionVisible. |
|
212 |
||
213 |
numArgs := openEditorAction numArgs. |
|
214 |
||
215 |
numArgs == 0 ifTrue:[ |
|
216 |
editorView := openEditorAction value |
|
217 |
] ifFalse:[ |
|
218 |
numArgs == 1 ifTrue:[editorView := openEditorAction value:lnNr] |
|
219 |
ifFalse:[editorView := openEditorAction value:lnNr value:self] |
|
220 |
]. |
|
221 |
editorView ifNil:[^ nil]. |
|
222 |
||
223 |
editorView superView ifNil:[ |
|
224 |
self addSubView:editorView |
|
225 |
]. |
|
226 |
self computeEditorLayout. |
|
227 |
editorView realize. |
|
228 |
self windowGroup focusView:editorView. |
|
229 |
^ editorView |
|
230 |
! |
|
231 |
||
232 |
openEditorAction |
|
233 |
"get the block which is evaluated to get the editor which is set for the |
|
234 |
line; the arguments to the block is the line number and the widget itself |
|
235 |
" |
|
236 |
^ openEditorAction |
|
237 |
||
238 |
! |
|
239 |
||
240 |
openEditorAction:aTwoArgAction |
|
241 |
"set the block which is evaluated to get the editor which is set for the |
|
242 |
line; the arguments to the block is the line number and the widget itself |
|
243 |
" |
|
244 |
openEditorAction := aTwoArgAction. |
|
245 |
! ! |
|
246 |
||
1818 | 247 |
!SelectionInListModelView methodsFor:'accessing-actions'! |
1641 | 248 |
|
249 |
action |
|
250 |
"get the action block to be performed on select |
|
251 |
" |
|
252 |
^ actionBlock |
|
253 |
! |
|
254 |
||
255 |
action:aOneArgAction |
|
256 |
"set the action block to be performed on select |
|
257 |
" |
|
258 |
actionBlock := aOneArgAction |
|
259 |
||
260 |
||
261 |
! |
|
262 |
||
263 |
doubleClickAction |
|
264 |
"get the action block to be performed on doubleclick |
|
265 |
" |
|
266 |
^ doubleClickActionBlock |
|
267 |
||
268 |
! |
|
269 |
||
270 |
doubleClickAction:aOneArgAction |
|
271 |
"set the action block to be performed on doubleclick |
|
272 |
" |
|
273 |
doubleClickActionBlock := aOneArgAction |
|
274 |
||
275 |
! |
|
276 |
||
277 |
selectConditionBlock |
|
278 |
"set the conditionBlock; this block is evaluated before a selection |
|
279 |
change is performed; the change will not be done, if the evaluation |
|
280 |
returns false |
|
281 |
" |
|
282 |
^ selectConditionBlock |
|
283 |
||
284 |
! |
|
285 |
||
286 |
selectConditionBlock:aOneArgBlock |
|
287 |
"set the conditionBlock; this block is evaluated before a selection |
|
288 |
change is performed; the change will not be done, if the evaluation |
|
289 |
returns false |
|
290 |
" |
|
291 |
selectConditionBlock := aOneArgBlock. |
|
292 |
||
293 |
||
294 |
||
295 |
! ! |
|
296 |
||
1818 | 297 |
!SelectionInListModelView methodsFor:'accessing-behavior'! |
1390 | 298 |
|
299 |
highlightMode |
|
300 |
"get the mode how to draw a selected line: |
|
301 |
#line draw whole line selected |
|
302 |
#label draw label selected |
|
303 |
" |
|
304 |
^ highlightMode |
|
305 |
||
306 |
||
307 |
! |
|
308 |
||
309 |
highlightMode:aMode |
|
310 |
"set the mode how to draw a selected line: |
|
311 |
#line draw whole line selected |
|
312 |
#label draw label selected |
|
313 |
" |
|
1561 | 314 |
highlightMode := aMode. |
1390 | 315 |
! |
316 |
||
1741
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
317 |
ignoreReselect |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
318 |
"get the ignoreReselect flag - see method #ignoreReselect: for more details |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
319 |
" |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
320 |
^ ignoreReselect |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
321 |
! |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
322 |
|
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
323 |
ignoreReselect:aBoolean |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
324 |
"set/clear the ignoreReselect flag - |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
325 |
if set, a click on an already selected entry is ignored. |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
326 |
Otherwise the notification is done, even if no |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
327 |
change in the selection occurs. |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
328 |
(for example, in browser to update a method). |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
329 |
Setting ignoreReselect to false makes sense if data is shown |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
330 |
which may change by itself (i.e. without the user doing anything) |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
331 |
For example, the inspector uses this, and redisplays the value, |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
332 |
if the selection is the same. |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
333 |
The default is true, meaning that a click on an already selected |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
334 |
does not lead to a notification via the actionBlock/change mechanism. |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
335 |
" |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
336 |
ignoreReselect := aBoolean |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
337 |
|
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
338 |
! |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
339 |
|
1390 | 340 |
multipleSelectOk |
341 |
"allow/disallow multiple selections; the default is false |
|
342 |
" |
|
343 |
^ multipleSelectOk |
|
344 |
||
345 |
||
346 |
! |
|
347 |
||
348 |
multipleSelectOk:aState |
|
349 |
"allow/disallow multiple selections; the default is false |
|
350 |
" |
|
1537 | 351 |
multipleSelectOk := aState ? false. |
1390 | 352 |
! |
353 |
||
1741
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
354 |
toggleSelect |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
355 |
"get the toggleSelect flag - see method #toggleSelect: for more details |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
356 |
" |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
357 |
^ toggleSelect |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
358 |
! |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
359 |
|
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
360 |
toggleSelect:aBoolean |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
361 |
"turn on/off toggle select. If true, clicking on a selected entry |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
362 |
unselects it and vice versa. The default is false, which means |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
363 |
that clicking on an already selected entry does not change its |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
364 |
select status (see also ignoreReselect:). |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
365 |
" |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
366 |
toggleSelect := aBoolean. |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
367 |
|
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
368 |
|
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
369 |
! |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
370 |
|
1390 | 371 |
useIndex |
372 |
"set/clear the useIndex flag. |
|
373 |
the selection writen to the model are the indices into the list |
|
374 |
or the elements selected. |
|
375 |
" |
|
376 |
^ useIndex |
|
377 |
||
378 |
||
379 |
! |
|
380 |
||
381 |
useIndex:aBoolean |
|
382 |
"set/clear the useIndex flag. |
|
383 |
the selection writen to the model are the indices into the list |
|
384 |
or the elements selected. |
|
385 |
" |
|
386 |
useIndex := aBoolean ? true |
|
387 |
||
388 |
||
389 |
! ! |
|
390 |
||
391 |
!SelectionInListModelView methodsFor:'change & update'! |
|
392 |
||
393 |
argForChangeMessage |
|
394 |
"return the argument for a selectionChange; |
|
395 |
depending on the setting of useIndex, this is either the numeric |
|
396 |
index of the selection or the value (i.e. the string) |
|
397 |
" |
|
1554 | 398 |
selection isNil ifTrue:[ |
399 |
multipleSelectOk ifTrue:[^ #()]. |
|
400 |
^ useIndex ifTrue:[0] ifFalse:[nil] |
|
1390 | 401 |
]. |
1564 | 402 |
useIndex ifTrue:[^ selection]. |
1554 | 403 |
|
404 |
multipleSelectOk ifFalse:[ |
|
405 |
^ list at:selection ifAbsent:nil |
|
1390 | 406 |
]. |
1554 | 407 |
^ selection collect:[:nr| list at:nr ifAbsent:nil ] |
1390 | 408 |
! |
409 |
||
2185
639d20ab5667
updateFromModel renamed to asyncUpdateFromModel
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
410 |
asyncUpdateFromModel |
639d20ab5667
updateFromModel renamed to asyncUpdateFromModel
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
411 |
"update selection from the model |
639d20ab5667
updateFromModel renamed to asyncUpdateFromModel
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
412 |
" |
639d20ab5667
updateFromModel renamed to asyncUpdateFromModel
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
413 |
|value nsel sensor| |
639d20ab5667
updateFromModel renamed to asyncUpdateFromModel
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
414 |
|
639d20ab5667
updateFromModel renamed to asyncUpdateFromModel
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
415 |
model isNil ifTrue:[ |
639d20ab5667
updateFromModel renamed to asyncUpdateFromModel
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
416 |
^ self |
639d20ab5667
updateFromModel renamed to asyncUpdateFromModel
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
417 |
]. |
639d20ab5667
updateFromModel renamed to asyncUpdateFromModel
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
418 |
( multipleSelectOk |
639d20ab5667
updateFromModel renamed to asyncUpdateFromModel
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
419 |
and:[clickLine notNil |
639d20ab5667
updateFromModel renamed to asyncUpdateFromModel
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
420 |
and:[(sensor := self sensor) notNil |
639d20ab5667
updateFromModel renamed to asyncUpdateFromModel
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
421 |
and:[sensor leftButtonPressed]]] |
639d20ab5667
updateFromModel renamed to asyncUpdateFromModel
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
422 |
) ifTrue:[ |
639d20ab5667
updateFromModel renamed to asyncUpdateFromModel
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
423 |
"running in button motion; discard change notification |
639d20ab5667
updateFromModel renamed to asyncUpdateFromModel
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
424 |
" |
639d20ab5667
updateFromModel renamed to asyncUpdateFromModel
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
425 |
^ self |
639d20ab5667
updateFromModel renamed to asyncUpdateFromModel
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
426 |
]. |
639d20ab5667
updateFromModel renamed to asyncUpdateFromModel
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
427 |
|
639d20ab5667
updateFromModel renamed to asyncUpdateFromModel
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
428 |
self syncFlushEvent:#asyncUpdateFromModel. |
639d20ab5667
updateFromModel renamed to asyncUpdateFromModel
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
429 |
|
639d20ab5667
updateFromModel renamed to asyncUpdateFromModel
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
430 |
value := model value. |
639d20ab5667
updateFromModel renamed to asyncUpdateFromModel
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
431 |
|
639d20ab5667
updateFromModel renamed to asyncUpdateFromModel
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
432 |
(useIndex or:[value isNil or:[value isNumber]]) ifFalse:[ |
639d20ab5667
updateFromModel renamed to asyncUpdateFromModel
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
433 |
multipleSelectOk ifFalse:[ |
639d20ab5667
updateFromModel renamed to asyncUpdateFromModel
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
434 |
value := list identityIndexOf:value |
639d20ab5667
updateFromModel renamed to asyncUpdateFromModel
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
435 |
] ifTrue:[ |
639d20ab5667
updateFromModel renamed to asyncUpdateFromModel
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
436 |
value isEmpty ifTrue:[ |
639d20ab5667
updateFromModel renamed to asyncUpdateFromModel
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
437 |
value := nil |
639d20ab5667
updateFromModel renamed to asyncUpdateFromModel
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
438 |
] ifFalse:[ |
639d20ab5667
updateFromModel renamed to asyncUpdateFromModel
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
439 |
nsel := OrderedCollection new. |
639d20ab5667
updateFromModel renamed to asyncUpdateFromModel
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
440 |
value do:[:e||i|(i := list identityIndexOf:e) ~~ 0 ifTrue:[nsel add:i]]. |
639d20ab5667
updateFromModel renamed to asyncUpdateFromModel
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
441 |
value := nsel notEmpty ifTrue:[nsel] ifFalse:[nil] |
639d20ab5667
updateFromModel renamed to asyncUpdateFromModel
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
442 |
] |
639d20ab5667
updateFromModel renamed to asyncUpdateFromModel
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
443 |
]. |
639d20ab5667
updateFromModel renamed to asyncUpdateFromModel
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
444 |
]. |
639d20ab5667
updateFromModel renamed to asyncUpdateFromModel
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
445 |
self setSelection:value. |
639d20ab5667
updateFromModel renamed to asyncUpdateFromModel
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
446 |
! |
639d20ab5667
updateFromModel renamed to asyncUpdateFromModel
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
447 |
|
1755 | 448 |
contentsChanged |
449 |
super contentsChanged. |
|
450 |
self computeEditorLayout. |
|
451 |
! |
|
452 |
||
453 |
lineChangedAt:aLnNr with:arg |
|
454 |
super lineChangedAt:aLnNr with:arg. |
|
455 |
||
456 |
(editorView notNil and:[aLnNr == self selectedIndex]) ifTrue:[ |
|
457 |
self computeEditorLayout. |
|
458 |
] |
|
459 |
! |
|
460 |
||
1390 | 461 |
listSizeChanged:aLnNr nLines:aDeltaLines |
462 |
"update selection |
|
463 |
" |
|
1563 | 464 |
|changed cnts| |
1390 | 465 |
|
466 |
super listSizeChanged:aLnNr nLines:aDeltaLines. |
|
467 |
||
468 |
selection isNil ifTrue:[^ self]. |
|
469 |
||
470 |
list size == 0 ifTrue:[ |
|
1563 | 471 |
selection := nil. |
472 |
^ self selectionChanged |
|
1390 | 473 |
]. |
474 |
||
1563 | 475 |
multipleSelectOk ifFalse:[ |
476 |
selection < aLnNr ifTrue:[^ self]. |
|
477 |
||
478 |
selection := selection + aDeltaLines. |
|
1390 | 479 |
|
1563 | 480 |
(aDeltaLines < 0 and:[selection < aLnNr]) ifTrue:[ |
481 |
selection := nil. |
|
482 |
^ self selectionChanged |
|
483 |
] |
|
484 |
] ifTrue:[ |
|
485 |
changed := false. |
|
1390 | 486 |
|
1563 | 487 |
aDeltaLines < 0 ifFalse:[ |
488 |
selection keysAndValuesDo:[:i :ln| |
|
489 |
ln >= aLnNr ifTrue:[ |
|
490 |
changed := true. |
|
491 |
selection at:i put:(ln + aDeltaLines) |
|
492 |
] |
|
1390 | 493 |
] |
1563 | 494 |
] ifTrue:[ |
495 |
cnts := 0. |
|
496 |
||
497 |
selection keysAndValuesDo:[:i :ln||new| |
|
498 |
ln >= aLnNr ifTrue:[ |
|
499 |
changed := true. |
|
500 |
||
501 |
(new := ln + aDeltaLines) < aLnNr ifTrue:[ |
|
502 |
cnts := cnts + 1. |
|
503 |
new := nil |
|
504 |
]. |
|
505 |
selection at:i put:new |
|
506 |
] |
|
507 |
]. |
|
508 |
cnts ~~ 0 ifTrue:[ |
|
509 |
cnts == selection size ifTrue:[ |
|
510 |
selection := nil |
|
511 |
] ifFalse:[ |
|
512 |
selection := selection select:[:ln| ln notNil] |
|
513 |
]. |
|
514 |
^ self selectionChanged. |
|
515 |
]. |
|
1390 | 516 |
]. |
1563 | 517 |
changed ifFalse:[^ self]. |
1390 | 518 |
]. |
519 |
||
1563 | 520 |
(useIndex and:[model notNil]) ifTrue:[ |
521 |
model setValue:(self argForChangeMessage) |
|
522 |
]. |
|
523 |
||
1390 | 524 |
|
525 |
! |
|
526 |
||
1755 | 527 |
originChanged:delta |
528 |
"setup the origin of the editing view |
|
529 |
" |
|
530 |
self computeEditorLayout. |
|
531 |
super originChanged:delta. |
|
532 |
||
533 |
||
534 |
! |
|
535 |
||
1390 | 536 |
selectionChanged |
537 |
"selection has changed. Call actionblock and/or send changeMessage if defined |
|
538 |
" |
|
1554 | 539 |
|arg| |
1390 | 540 |
|
1755 | 541 |
self closeEditor. |
542 |
||
1390 | 543 |
(model isNil and:[actionBlock isNil]) ifTrue:[ |
544 |
^ self |
|
545 |
]. |
|
546 |
||
547 |
arg := self argForChangeMessage. |
|
548 |
||
549 |
model notNil ifTrue:[ |
|
550 |
model removeDependent:self. |
|
1741
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
551 |
"/ 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
|
552 |
arg = model value ifTrue:[ |
d8d45bbbd3ba
check whether model value differs from current selection.
ca
parents:
1755
diff
changeset
|
553 |
model setValue:(arg isNil ifTrue:[0] ifFalse:[nil]). |
d8d45bbbd3ba
check whether model value differs from current selection.
ca
parents:
1755
diff
changeset
|
554 |
]. |
1390 | 555 |
self sendChangeMessage:#value: with:arg. |
2225 | 556 |
model notNil ifTrue:[ "/ argggh could be nilled |
557 |
model addDependent:self. |
|
558 |
] |
|
1390 | 559 |
]. |
560 |
||
561 |
actionBlock notNil ifTrue:[ |
|
2070
cb8b952f7214
use new #valueWithOptionalArg
Claus Gittinger <cg@exept.de>
parents:
2055
diff
changeset
|
562 |
actionBlock valueWithOptionalArgument:arg |
1390 | 563 |
]. |
564 |
! |
|
565 |
||
1554 | 566 |
updateFromModel |
2185
639d20ab5667
updateFromModel renamed to asyncUpdateFromModel
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
567 |
self syncPushEvent:#asyncUpdateFromModel |
1390 | 568 |
! ! |
569 |
||
570 |
!SelectionInListModelView methodsFor:'drag & drop'! |
|
571 |
||
572 |
canDrag |
|
573 |
"returns true if dragging is enabled |
|
574 |
" |
|
575 |
^ dropSource notNil |
|
576 |
||
577 |
! |
|
578 |
||
579 |
dropSource |
|
580 |
"returns the dropSource or nil |
|
581 |
" |
|
582 |
^ dropSource |
|
583 |
||
584 |
! |
|
585 |
||
586 |
dropSource:aDropSourceOrNil |
|
587 |
"set the dropSource or nil |
|
588 |
" |
|
589 |
dropSource := aDropSourceOrNil. |
|
590 |
||
591 |
! |
|
592 |
||
593 |
dropTarget |
|
594 |
"returns the dropTarget or nil |
|
595 |
" |
|
596 |
^ dropTarget |
|
597 |
||
598 |
||
599 |
! |
|
600 |
||
601 |
dropTarget:aDropTragetOrNil |
|
602 |
"set the dropTarget or nil |
|
603 |
" |
|
604 |
dropTarget := aDropTragetOrNil. |
|
605 |
||
606 |
! |
|
607 |
||
608 |
startDragAt:aPoint |
|
609 |
"start drag at a point |
|
610 |
" |
|
611 |
dropSource notNil ifTrue:[ |
|
612 |
dropSource startDragSelector notNil ifTrue:[ |
|
613 |
dropSource startDragIn:self at:aPoint |
|
614 |
] ifFalse:[ |
|
615 |
DragAndDropManager new startDragFrom:self |
|
616 |
dropSource:dropSource |
|
617 |
offset:#center |
|
618 |
] |
|
619 |
] |
|
620 |
||
621 |
! ! |
|
622 |
||
623 |
!SelectionInListModelView methodsFor:'drawing'! |
|
624 |
||
1533 | 625 |
drawFrom:start to:stop x:x y:y w:w |
1390 | 626 |
"draw the lines between start to stop without clearing the background |
627 |
" |
|
1557 | 628 |
highlightMode notNil ifTrue:[ |
629 |
self selectionDo:[:lnNr| |
|
630 |
(lnNr between:start and:stop) ifTrue:[ |
|
631 |
self drawSelectionFrameAt:lnNr x:x w:w |
|
632 |
] |
|
1390 | 633 |
] |
634 |
]. |
|
1533 | 635 |
self drawElementsFrom:start to:stop x:x y:y w:w. |
1390 | 636 |
|
637 |
||
638 |
! |
|
639 |
||
1533 | 640 |
drawLabelAt:anIndex x:x y:y h:h |
1390 | 641 |
"draw the label at position x/y without clearing the background |
642 |
" |
|
1554 | 643 |
|item| |
644 |
||
1755 | 645 |
editorView notNil ifTrue:[ |
646 |
"/ there is an open editor for the line; thus no redraw for the label (hidden by editor) |
|
647 |
self selectedIndex == anIndex ifTrue:[^ self]. |
|
648 |
]. |
|
649 |
||
1508
9c54f2e53da1
check whether #at:ifAbsent returns nil.
Claus Gittinger <cg@exept.de>
parents:
1468
diff
changeset
|
650 |
item := list at:anIndex ifAbsent:nil. |
1390 | 651 |
|
1557 | 652 |
item notNil ifTrue:[ |
653 |
(highlightMode notNil and:[self isInSelection:anIndex]) ifTrue:[ |
|
654 |
self paint:hilightFgColor on:hilightBgColor |
|
655 |
] ifFalse:[ |
|
656 |
self paint:fgColor on:bgColor. |
|
657 |
]. |
|
658 |
self displayElement:item x:x y:y h:h. |
|
659 |
] |
|
1390 | 660 |
|
661 |
||
662 |
! |
|
663 |
||
1554 | 664 |
drawSelectionFrameAt:lnNr x:x w:w |
665 |
"draw the background and foreground of the selection frame |
|
666 |
at a lineNr. |
|
1390 | 667 |
" |
1554 | 668 |
|item |
669 |
x0 "{ Class:SmallInteger }" |
|
1390 | 670 |
x1 "{ Class: SmallInteger }" |
1554 | 671 |
y0 "{ Class:SmallInteger }" |
672 |
y1 "{ Class:SmallInteger }" |
|
673 |
hL "{ Class:SmallInteger }" |
|
674 |
wL "{ Class:SmallInteger }" |
|
1390 | 675 |
| |
1755 | 676 |
editorView notNil ifTrue:[ |
677 |
"/ there is an open editor; do not redraw selected |
|
678 |
^ self |
|
679 |
]. |
|
680 |
||
1554 | 681 |
(item := list at:lnNr ifAbsent:nil) isNil ifTrue:[ |
1755 | 682 |
"/ list might change during drawing; item no longer visible |
1554 | 683 |
^ self |
684 |
]. |
|
685 |
||
686 |
"/ CLEAR THE BACKGROUND |
|
687 |
||
688 |
y0 := self yVisibleOfLine:lnNr. |
|
689 |
y1 := self yVisibleOfLine:(lnNr + 1). |
|
690 |
hL := y1 - y0. |
|
691 |
||
692 |
highlightMode == #line ifTrue:[ |
|
693 |
x0 := x. |
|
694 |
x1 := x0 + w. |
|
695 |
] ifFalse:[ |
|
696 |
highlightMode == #label ifFalse:[^ self]. |
|
697 |
x0 := (self xVisibleOfItem:item) - (textStartLeft // 2). |
|
698 |
x1 := x0 + (item widthOn:self) + textStartLeft. |
|
699 |
]. |
|
700 |
wL := x1 - x0. |
|
701 |
||
702 |
wL > 0 ifFalse:[^ self]. |
|
703 |
||
704 |
self paint:hilightBgColor. |
|
705 |
self fillRectangleX:x0 y:y0 width:wL height:hL. |
|
706 |
||
707 |
"/ DRAW THE FRAME |
|
1390 | 708 |
|
709 |
hilightFrameColor notNil ifTrue:[ |
|
710 |
hilightLevel == 0 ifTrue:[ |
|
711 |
self paint:hilightFrameColor. |
|
712 |
||
713 |
highlightMode == #line ifTrue:[ |
|
714 |
self displayLineFromX:x0 y:y0 toX:x1 y:y0. |
|
1554 | 715 |
y1 := y0 + hL - 1. |
716 |
self displayLineFromX:x0 y:y1 toX:x1 y:y1. |
|
1390 | 717 |
] ifFalse:[ |
1554 | 718 |
self displayRectangleX:x0 y:y0 width:wL height:hL |
1390 | 719 |
]. |
720 |
^ self. |
|
721 |
] |
|
722 |
] ifFalse:[ |
|
723 |
hilightStyle == #motif ifTrue:[ |
|
724 |
self paint:bgColor. |
|
1554 | 725 |
y1 := y0 + 1. |
1390 | 726 |
highlightMode == #line ifTrue:[ |
1554 | 727 |
self displayLineFromX:x0 y:y1 toX:x1 y:y1. |
728 |
y1 := y0 + hL - 2. |
|
729 |
self displayLineFromX:x0 y:y1 toX:x1 y:y1. |
|
1390 | 730 |
] ifFalse:[ |
1554 | 731 |
self displayRectangleX:x0 + 1 y:y1 width:wL - 2 height:hL - 2 |
1390 | 732 |
] |
733 |
] |
|
734 |
]. |
|
735 |
||
736 |
hilightLevel ~~ 0 ifTrue:[ |
|
737 |
"/ draw edge |
|
738 |
highlightMode == #line ifTrue:[ |
|
1554 | 739 |
x0 := margin. |
740 |
wL := width - x0 - x0. |
|
1390 | 741 |
]. |
1554 | 742 |
self drawEdgesForX:x0 y:y0 width:wL height:hL level:hilightLevel. |
1390 | 743 |
] |
744 |
||
745 |
! |
|
746 |
||
1554 | 747 |
redrawSelectionAt:aLineNr |
1569 | 748 |
"redraw a line which changed its selection status. |
749 |
optimized when drawing only the label. |
|
1390 | 750 |
" |
1569 | 751 |
|item |
752 |
y0 "{ Class:SmallInteger }" |
|
753 |
y1 "{ Class:SmallInteger }" |
|
754 |
yB "{ Class:SmallInteger }" |
|
755 |
x0 "{ Class:SmallInteger }" |
|
756 |
x1 "{ Class:SmallInteger }" |
|
757 |
| |
|
758 |
||
1755 | 759 |
editorView notNil ifTrue:[ |
760 |
"/ there is an open editor; do not redraw selected |
|
761 |
^ self |
|
762 |
]. |
|
763 |
||
1569 | 764 |
(shown and:[aLineNr notNil and:[highlightMode notNil]]) ifFalse:[ |
765 |
^ self |
|
1557 | 766 |
]. |
767 |
||
1569 | 768 |
yB := height - margin. |
769 |
y0 := (self yVisibleOfLine:aLineNr) max:margin. |
|
770 |
||
771 |
y0 >= yB ifTrue:[ |
|
772 |
^ self |
|
773 |
]. |
|
774 |
||
775 |
y1 := (self yVisibleOfLine:(aLineNr + 1)) min:yB. |
|
776 |
||
777 |
y1 <= margin ifTrue:[ |
|
778 |
^ self |
|
779 |
]. |
|
780 |
||
1739
195eefc3656f
invalidate line in label mode to width of view (bug fix for detemobil)
ca
parents:
1649
diff
changeset
|
781 |
x1 := width. |
195eefc3656f
invalidate line in label mode to width of view (bug fix for detemobil)
ca
parents:
1649
diff
changeset
|
782 |
|
1569 | 783 |
( highlightMode == #label |
784 |
and:[(item := list at:aLineNr ifAbsent:nil) notNil] |
|
785 |
) ifTrue:[ |
|
786 |
x0 := (self xVisibleOfItem:item) - (textStartLeft // 2). |
|
787 |
x0 := x0 max:0. |
|
788 |
x1 > x0 ifFalse:[^ self]. |
|
789 |
] ifFalse:[ |
|
790 |
x0 := 0. |
|
791 |
x1 := width. |
|
792 |
]. |
|
2148
4e7157e02e9e
invalide: leftover pixel-row under win32 (how did this happen ?)
Claus Gittinger <cg@exept.de>
parents:
2125
diff
changeset
|
793 |
self invalidateX:x0 y:y0 width:(x1 - x0) height:(y1 - y0+1). |
1390 | 794 |
! ! |
795 |
||
796 |
!SelectionInListModelView methodsFor:'event handling'! |
|
797 |
||
798 |
buttonMotion:buttonMask x:x y:y |
|
799 |
"mouse-move while button was pressed - handle selection changes |
|
800 |
" |
|
1747
f46c5941c028
better alghorithm for button motion in multipleSelection mode
ca
parents:
1745
diff
changeset
|
801 |
|dragPoint lnNr dY d0 nsel viewOrgY yAbsLine |
f46c5941c028
better alghorithm for button motion in multipleSelection mode
ca
parents:
1745
diff
changeset
|
802 |
step "{ Class:SmallInteger }" |
f46c5941c028
better alghorithm for button motion in multipleSelection mode
ca
parents:
1745
diff
changeset
|
803 |
| |
f46c5941c028
better alghorithm for button motion in multipleSelection mode
ca
parents:
1745
diff
changeset
|
804 |
|
1390 | 805 |
|
1542
8607d072c319
accessing selection through to selector
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
806 |
(enabled and:[self hasSelection]) ifFalse:[^ self]. |
1390 | 807 |
|
808 |
dragAccessPoint notNil ifTrue:[ |
|
1747
f46c5941c028
better alghorithm for button motion in multipleSelection mode
ca
parents:
1745
diff
changeset
|
809 |
dragPoint := x @ y. |
1390 | 810 |
|
1747
f46c5941c028
better alghorithm for button motion in multipleSelection mode
ca
parents:
1745
diff
changeset
|
811 |
(dragAccessPoint dist:dragPoint) > 5.0 ifTrue:[ |
1390 | 812 |
dragAccessPoint := nil. |
1747
f46c5941c028
better alghorithm for button motion in multipleSelection mode
ca
parents:
1745
diff
changeset
|
813 |
self startDragAt:dragPoint |
1390 | 814 |
]. |
815 |
^ self |
|
816 |
]. |
|
817 |
||
818 |
(multipleSelectOk and:[self sensor leftButtonPressed]) ifFalse:[ |
|
819 |
^ self |
|
820 |
]. |
|
821 |
||
822 |
clickLine isNil ifTrue:[ |
|
823 |
^ self |
|
824 |
]. |
|
1747
f46c5941c028
better alghorithm for button motion in multipleSelection mode
ca
parents:
1745
diff
changeset
|
825 |
(lnNr := self yVisibleToLineNr:y) isNil ifTrue:[ |
f46c5941c028
better alghorithm for button motion in multipleSelection mode
ca
parents:
1745
diff
changeset
|
826 |
lnNr := list size |
f46c5941c028
better alghorithm for button motion in multipleSelection mode
ca
parents:
1745
diff
changeset
|
827 |
] ifFalse:[ |
f46c5941c028
better alghorithm for button motion in multipleSelection mode
ca
parents:
1745
diff
changeset
|
828 |
lnNr := lnNr max:1 |
f46c5941c028
better alghorithm for button motion in multipleSelection mode
ca
parents:
1745
diff
changeset
|
829 |
]. |
f46c5941c028
better alghorithm for button motion in multipleSelection mode
ca
parents:
1745
diff
changeset
|
830 |
lnNr == clickLine ifTrue:[^ self]. |
f46c5941c028
better alghorithm for button motion in multipleSelection mode
ca
parents:
1745
diff
changeset
|
831 |
|
1748 | 832 |
autoScroll ifTrue:[ |
833 |
"/ if moved outside of view, start autoscroll |
|
834 |
(y < 0) ifTrue:[ |
|
835 |
^ self startAutoScroll:[self scrollUp] distance:y. |
|
836 |
]. |
|
837 |
(y > height) ifTrue:[ |
|
838 |
^ self startAutoScroll:[self scrollDown] distance:(y - height). |
|
839 |
]. |
|
840 |
]. |
|
841 |
||
842 |
"move inside - stop autoscroll if any" |
|
843 |
self stopAutoScroll. |
|
844 |
||
1747
f46c5941c028
better alghorithm for button motion in multipleSelection mode
ca
parents:
1745
diff
changeset
|
845 |
nsel := OrderedCollection new. |
f46c5941c028
better alghorithm for button motion in multipleSelection mode
ca
parents:
1745
diff
changeset
|
846 |
step := lnNr > clickLine ifTrue:[1] ifFalse:[-1]. |
1390 | 847 |
|
1747
f46c5941c028
better alghorithm for button motion in multipleSelection mode
ca
parents:
1745
diff
changeset
|
848 |
clickLine to:lnNr by:step do:[:i| |
1920 | 849 |
((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
|
850 |
]. |
f46c5941c028
better alghorithm for button motion in multipleSelection mode
ca
parents:
1745
diff
changeset
|
851 |
(self selectWithoutScroll:nsel redraw:true) ifFalse:[^ self]. |
f46c5941c028
better alghorithm for button motion in multipleSelection mode
ca
parents:
1745
diff
changeset
|
852 |
|
f46c5941c028
better alghorithm for button motion in multipleSelection mode
ca
parents:
1745
diff
changeset
|
853 |
viewOrgY := viewOrigin y. |
f46c5941c028
better alghorithm for button motion in multipleSelection mode
ca
parents:
1745
diff
changeset
|
854 |
yAbsLine := self yAbsoluteOfLine:lnNr. |
f46c5941c028
better alghorithm for button motion in multipleSelection mode
ca
parents:
1745
diff
changeset
|
855 |
|
f46c5941c028
better alghorithm for button motion in multipleSelection mode
ca
parents:
1745
diff
changeset
|
856 |
yAbsLine < viewOrgY ifTrue:[ |
f46c5941c028
better alghorithm for button motion in multipleSelection mode
ca
parents:
1745
diff
changeset
|
857 |
self scrollTo:( viewOrigin x @ yAbsLine) redraw:true |
1390 | 858 |
] ifFalse:[ |
1747
f46c5941c028
better alghorithm for button motion in multipleSelection mode
ca
parents:
1745
diff
changeset
|
859 |
yAbsLine - viewOrgY > height ifTrue:[ |
f46c5941c028
better alghorithm for button motion in multipleSelection mode
ca
parents:
1745
diff
changeset
|
860 |
d0 := yAbsLine - height. |
f46c5941c028
better alghorithm for button motion in multipleSelection mode
ca
parents:
1745
diff
changeset
|
861 |
self scrollTo:( viewOrigin x @ d0) redraw:true. |
1390 | 862 |
]. |
863 |
]. |
|
1747
f46c5941c028
better alghorithm for button motion in multipleSelection mode
ca
parents:
1745
diff
changeset
|
864 |
self repairDamage. |
f46c5941c028
better alghorithm for button motion in multipleSelection mode
ca
parents:
1745
diff
changeset
|
865 |
self selectionChanged. |
1390 | 866 |
! |
867 |
||
868 |
buttonMultiPress:button x:x y:y |
|
869 |
"button was pressed multiple - handle a doubleClick action |
|
870 |
" |
|
871 |
clickLine := nil. |
|
872 |
dragAccessPoint := nil. |
|
873 |
||
874 |
enabled ifFalse:[^ self]. |
|
875 |
||
876 |
((button == 1) or:[button == #select]) ifFalse:[ |
|
877 |
^ super buttonMultiPress:button x:x y:y |
|
878 |
]. |
|
879 |
self doubleClicked |
|
880 |
! |
|
881 |
||
882 |
buttonPress:button x:x y:y |
|
883 |
"a button was pressed - handle selection here |
|
884 |
" |
|
1644 | 885 |
|sensor nsel start step item menu appl isInSelection| |
1390 | 886 |
|
887 |
clickLine := nil. |
|
888 |
dragAccessPoint := nil. |
|
889 |
||
890 |
enabled ifFalse:[^ self]. |
|
891 |
||
1578 | 892 |
((button == 2) or:[button == #menu]) ifTrue:[ |
893 |
( (item := self selectedElement) notNil |
|
894 |
and:[(menu := item perform:#middleButtonMenu ifNotUnderstood:nil) notNil] |
|
895 |
) ifTrue:[ |
|
896 |
menu isCollection ifTrue:[ |
|
897 |
menu := Menu new fromLiteralArrayEncoding:menu. |
|
898 |
appl := self application. |
|
899 |
||
900 |
appl notNil ifTrue:[ |
|
901 |
menu findGuiResourcesIn:appl. |
|
2055
964a2cac4e55
take focus on pointer enter only if the list is not empty.
Claus Gittinger <cg@exept.de>
parents:
1920
diff
changeset
|
902 |
"/ menu receiver:appl -- now done in findGuiResources ... |
1578 | 903 |
] ifFalse:[ |
904 |
menu receiver:item |
|
905 |
] |
|
906 |
]. |
|
907 |
^ menu startUp |
|
908 |
]. |
|
1390 | 909 |
^ super buttonPress:button x:x y:y |
910 |
]. |
|
1578 | 911 |
|
1741
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
912 |
( (sensor := self sensor) isNil |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
913 |
or:[(clickLine := self yVisibleToLineNr:y) isNil] |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
914 |
) ifTrue:[ |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
915 |
^ self |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
916 |
]. |
1644 | 917 |
isInSelection := self isInSelection:clickLine. |
1390 | 918 |
|
1741
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
919 |
multipleSelectOk ifTrue:[ |
1390 | 920 |
sensor ctrlDown ifTrue:[ |
1920 | 921 |
(isInSelection or:[self canSelectIndex:clickLine forAdd:true]) ifTrue:[ |
1644 | 922 |
self toggleSelection:clickLine. |
923 |
self selectionChanged |
|
924 |
]. |
|
925 |
^ self |
|
1390 | 926 |
]. |
1920 | 927 |
|
928 |
(self canSelectIndex:clickLine forAdd:sensor shiftDown) ifFalse:[^ self]. |
|
1390 | 929 |
|
1545 | 930 |
(sensor shiftDown and:[(start := self firstInSelection) notNil]) ifTrue:[ |
931 |
step := clickLine < start ifTrue:[-1] ifFalse:[1]. |
|
932 |
nsel := OrderedCollection new. |
|
933 |
||
1641 | 934 |
start to:clickLine by:step do:[:i| |
1920 | 935 |
((self isInSelection:i) or:[self canSelectIndex:i forAdd:true]) ifTrue:[nsel add:i] |
1641 | 936 |
]. |
1545 | 937 |
|
938 |
(self selectWithoutScroll:nsel redraw:true) ifTrue:[ |
|
1390 | 939 |
self selectionChanged |
940 |
]. |
|
941 |
^ self |
|
942 |
] |
|
1644 | 943 |
] ifFalse:[ |
1920 | 944 |
(self canSelectIndex:clickLine forAdd:false) ifFalse:[^ self] |
1390 | 945 |
]. |
946 |
||
1915 | 947 |
(isInSelection and:[self canDrag]) ifTrue:[ |
948 |
dragAccessPoint := x @ y. |
|
949 |
] ifFalse:[ |
|
950 |
self buttonPressOrReleaseAtLine:clickLine x:x y:y |
|
951 |
]. |
|
952 |
! |
|
953 |
||
954 |
buttonPressOrReleaseAtLine:aLnNr x:x y:y |
|
955 |
"handle a button press or release at a line |
|
956 |
" |
|
957 |
aLnNr == self selectedIndex ifTrue:[ |
|
958 |
editorView notNil ifTrue:[^ self]. |
|
959 |
||
960 |
openEditorAction notNil ifTrue:[ |
|
961 |
self openEditorAtX:x y:y. |
|
962 |
editorView notNil ifTrue:[^ self]. |
|
1741
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
963 |
]. |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
964 |
|
1915 | 965 |
ignoreReselect ifFalse:[ |
966 |
(toggleSelect and:[self sensor ctrlDown]) ifTrue:[ |
|
967 |
self selection:nil |
|
968 |
] ifFalse:[ |
|
969 |
self selectionChanged |
|
1741
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
970 |
]. |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
971 |
]. |
1915 | 972 |
] ifFalse:[ |
973 |
(self selectWithoutScroll:aLnNr redraw:true) ifTrue:[ |
|
974 |
self selectionChanged |
|
975 |
] |
|
1741
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
976 |
]. |
1390 | 977 |
! |
978 |
||
979 |
buttonRelease:button x:x y:y |
|
980 |
"a button was released |
|
981 |
" |
|
1915 | 982 |
|dragPoint clickLnNr| |
983 |
||
984 |
dragPoint := dragAccessPoint. |
|
985 |
clickLnNr := clickLine. |
|
986 |
clickLine := dragAccessPoint := nil. |
|
987 |
||
1748 | 988 |
self stopAutoScroll. |
989 |
||
1915 | 990 |
(enabled and:[dragPoint notNil and:[clickLnNr notNil]]) ifTrue:[ |
991 |
self buttonPressOrReleaseAtLine:clickLnNr x:(dragPoint x) y:(dragPoint y). |
|
1390 | 992 |
]. |
993 |
! |
|
994 |
||
995 |
characterPress:aKey x:x y:y |
|
996 |
" a character is pressed - lookup and change selection |
|
997 |
" |
|
998 |
|lnNr size idx sensor stp to1 fr2| |
|
999 |
||
1000 |
(enabled and:[(size := self size) > 1]) ifFalse:[ |
|
1001 |
^ self |
|
1002 |
]. |
|
1003 |
lnNr := self firstInSelection ? 0. |
|
1004 |
||
1005 |
((sensor := self sensor) notNil and:[sensor shiftDown]) ifTrue:[ |
|
1006 |
stp := -1. "/ search backward |
|
1007 |
to1 := 1. |
|
1008 |
fr2 := size. |
|
1009 |
] ifFalse:[ |
|
1010 |
stp := 1. "/ search forward |
|
1011 |
to1 := size. |
|
1012 |
fr2 := 1. |
|
1013 |
]. |
|
1014 |
||
1015 |
idx := self findLineFrom:lnNr+stp to:to1 by:stp startingWithCharacter:aKey. |
|
1016 |
||
1017 |
idx == 0 ifTrue:[ |
|
1018 |
idx := self findLineFrom:fr2 to:lnNr-stp by:stp startingWithCharacter:aKey |
|
1019 |
]. |
|
1020 |
idx ~~ 0 ifTrue:[^ self selection:idx] |
|
1021 |
! |
|
1022 |
||
1768
04b330a75f75
allow for subclasses to redefine character search
Claus Gittinger <cg@exept.de>
parents:
1758
diff
changeset
|
1023 |
characterSearchItemStringAt:anIndex |
04b330a75f75
allow for subclasses to redefine character search
Claus Gittinger <cg@exept.de>
parents:
1758
diff
changeset
|
1024 |
|item| |
04b330a75f75
allow for subclasses to redefine character search
Claus Gittinger <cg@exept.de>
parents:
1758
diff
changeset
|
1025 |
|
04b330a75f75
allow for subclasses to redefine character search
Claus Gittinger <cg@exept.de>
parents:
1758
diff
changeset
|
1026 |
item := list at:anIndex ifAbsent:nil. |
04b330a75f75
allow for subclasses to redefine character search
Claus Gittinger <cg@exept.de>
parents:
1758
diff
changeset
|
1027 |
item isNil ifTrue:[^ item]. |
04b330a75f75
allow for subclasses to redefine character search
Claus Gittinger <cg@exept.de>
parents:
1758
diff
changeset
|
1028 |
|
04b330a75f75
allow for subclasses to redefine character search
Claus Gittinger <cg@exept.de>
parents:
1758
diff
changeset
|
1029 |
^ item perform:#string ifNotUnderstood:nil. |
04b330a75f75
allow for subclasses to redefine character search
Claus Gittinger <cg@exept.de>
parents:
1758
diff
changeset
|
1030 |
|
04b330a75f75
allow for subclasses to redefine character search
Claus Gittinger <cg@exept.de>
parents:
1758
diff
changeset
|
1031 |
! |
04b330a75f75
allow for subclasses to redefine character search
Claus Gittinger <cg@exept.de>
parents:
1758
diff
changeset
|
1032 |
|
1917
21964f5b1cc1
fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents:
1915
diff
changeset
|
1033 |
containerChangedSize |
21964f5b1cc1
fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents:
1915
diff
changeset
|
1034 |
"/ 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
|
1035 |
"/ 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
|
1036 |
"/ 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
|
1037 |
|
21964f5b1cc1
fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents:
1915
diff
changeset
|
1038 |
selection notNil ifTrue:[ |
21964f5b1cc1
fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents:
1915
diff
changeset
|
1039 |
(hilightFrameColor notNil |
21964f5b1cc1
fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents:
1915
diff
changeset
|
1040 |
or:[hilightStyle == #motif |
21964f5b1cc1
fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents:
1915
diff
changeset
|
1041 |
or:[hilightLevel ~~ 0]]) ifTrue:[ |
21964f5b1cc1
fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents:
1915
diff
changeset
|
1042 |
"/ invalidate the right-edge |
21964f5b1cc1
fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents:
1915
diff
changeset
|
1043 |
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
|
1044 |
] |
21964f5b1cc1
fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents:
1915
diff
changeset
|
1045 |
]. |
21964f5b1cc1
fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents:
1915
diff
changeset
|
1046 |
|
21964f5b1cc1
fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents:
1915
diff
changeset
|
1047 |
super containerChangedSize. |
21964f5b1cc1
fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents:
1915
diff
changeset
|
1048 |
! |
21964f5b1cc1
fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents:
1915
diff
changeset
|
1049 |
|
1390 | 1050 |
doubleClicked |
1051 |
"handle a double click |
|
1052 |
" |
|
1053 |
(doubleClickActionBlock notNil and:[self numberOfSelections == 1]) ifTrue:[ |
|
1054 |
(doubleClickActionBlock numArgs == 1) ifTrue:[ |
|
1055 |
doubleClickActionBlock value:(self selectedIndex) |
|
1056 |
] ifFalse:[ |
|
1057 |
doubleClickActionBlock value |
|
1058 |
] |
|
1059 |
] |
|
1060 |
||
1061 |
! |
|
1062 |
||
1063 |
findLineFrom:aStart to:aStop by:aStep startingWithCharacter:aCharacter |
|
1064 |
"find a line starting with a character |
|
1065 |
" |
|
1066 |
|item char lbl cmp |
|
1067 |
size "{ Class:SmallInteger }" |
|
1068 |
start "{ Class:SmallInteger }" |
|
1069 |
stop "{ Class:SmallInteger }" |
|
1070 |
| |
|
1071 |
(size := list size) ~~ 0 ifTrue:[ |
|
1072 |
aStep > 0 ifTrue:[ |
|
1073 |
aStart > aStop ifTrue:[^ 0]. |
|
1074 |
] ifFalse:[ |
|
1075 |
(aStep == 0 or:[aStop > aStart]) ifTrue:[^ 0] |
|
1076 |
]. |
|
1077 |
||
1078 |
start := aStart < 0 ifTrue:[1] ifFalse:[aStart min:size]. |
|
1079 |
stop := aStop < 0 ifTrue:[1] ifFalse:[aStop min:size]. |
|
1080 |
char := aCharacter asUppercase. |
|
1081 |
||
1082 |
start to:stop by:aStep do:[:anIndex| |
|
1920 | 1083 |
(self canSelectIndex:anIndex forAdd:false) ifTrue:[ |
1772 | 1084 |
lbl := self characterSearchItemStringAt:anIndex. |
1085 |
lbl notNil ifTrue:[ |
|
1086 |
cmp := lbl string at:1 ifAbsent:nil. |
|
1390 | 1087 |
|
1772 | 1088 |
cmp notNil ifTrue:[ |
1089 |
(char == cmp or:[char == cmp asUppercase]) ifTrue:[ |
|
1090 |
^ anIndex |
|
1091 |
] |
|
1390 | 1092 |
] |
1093 |
] |
|
1094 |
] |
|
1095 |
] |
|
1096 |
]. |
|
1097 |
^ 0 |
|
1098 |
! |
|
1099 |
||
1100 |
keyPress:aKey x:x y:y |
|
1101 |
"a key was pressed - handle page-keys here |
|
1102 |
" |
|
1103 |
<resource: #keyboard( #Return #CursorUp #CursorDown )> |
|
1104 |
||
1920 | 1105 |
|sensor n size lineNr delta| |
1390 | 1106 |
|
1107 |
enabled ifFalse:[ |
|
1108 |
^ super keyPress:aKey x:x y:y |
|
1109 |
]. |
|
1110 |
aKey == #Return ifTrue:[ |
|
1111 |
self numberOfSelections == 1 ifTrue:[self doubleClicked]. |
|
1112 |
^ self |
|
1113 |
]. |
|
1114 |
||
1115 |
aKey isCharacter ifTrue:[ |
|
1116 |
^ self characterPress:aKey x:x y:y |
|
1117 |
]. |
|
1118 |
||
1119 |
(aKey == #CursorUp or:[aKey == #CursorDown]) ifFalse:[ |
|
1120 |
^ super keyPress:aKey x:x y:y |
|
1121 |
]. |
|
1122 |
||
1123 |
(size := self size) == 0 ifTrue:[ |
|
1124 |
^ self |
|
1125 |
]. |
|
1126 |
||
1127 |
lineNr := self selectedIndex. |
|
1128 |
sensor := self sensor. |
|
1129 |
||
1909 | 1130 |
|
1390 | 1131 |
sensor notNil ifTrue:[ |
1132 |
n := (1 + (sensor compressKeyPressEventsWithKey:aKey)) \\ size. |
|
1909 | 1133 |
n == 0 ifTrue:[n := 1]. |
1390 | 1134 |
] ifFalse:[ |
1135 |
n := 1 |
|
1136 |
]. |
|
1137 |
||
1138 |
aKey == #CursorUp ifTrue:[ |
|
1139 |
lineNr == 0 ifTrue:[lineNr := size + 1]. |
|
1772 | 1140 |
(n := lineNr - n) <= 0 ifTrue:[n := size + n]. |
1141 |
lineNr > size ifTrue:[lineNr := size]. |
|
1920 | 1142 |
delta := -1. |
1390 | 1143 |
] ifFalse:[ |
1772 | 1144 |
(n := lineNr + n) > size ifTrue:[n := n - size]. |
1909 | 1145 |
|
1772 | 1146 |
lineNr == 0 ifTrue:[lineNr := 1]. |
1920 | 1147 |
delta := 1. |
1148 |
]. |
|
1772 | 1149 |
|
1920 | 1150 |
"/ TODO: care for shift-Down (add-to-selection) |
1151 |
[ |
|
1152 |
self canSelectIndex:n forAdd:false |
|
1153 |
] whileFalse:[ |
|
1154 |
n := n + delta. |
|
1155 |
n > size ifTrue:[n := 1]. |
|
1156 |
n == 0 ifTrue:[n := size]. |
|
1157 |
n == lineNr ifTrue:[^ self] |
|
1390 | 1158 |
]. |
1920 | 1159 |
|
1390 | 1160 |
self selection:n |
1917
21964f5b1cc1
fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents:
1915
diff
changeset
|
1161 |
! |
21964f5b1cc1
fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents:
1915
diff
changeset
|
1162 |
|
21964f5b1cc1
fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents:
1915
diff
changeset
|
1163 |
sizeChanged:how |
21964f5b1cc1
fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents:
1915
diff
changeset
|
1164 |
"/ 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
|
1165 |
"/ 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
|
1166 |
"/ 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
|
1167 |
selection notNil ifTrue:[ |
21964f5b1cc1
fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents:
1915
diff
changeset
|
1168 |
(hilightFrameColor notNil |
21964f5b1cc1
fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents:
1915
diff
changeset
|
1169 |
or:[hilightStyle == #motif |
21964f5b1cc1
fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents:
1915
diff
changeset
|
1170 |
or:[hilightLevel ~~ 0]]) ifTrue:[ |
21964f5b1cc1
fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents:
1915
diff
changeset
|
1171 |
"/ invalidate the right-edge |
21964f5b1cc1
fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents:
1915
diff
changeset
|
1172 |
self invalidate:(((width-3) @ 0) corner:((width-1) @ (height-1))). |
2225 | 1173 |
]. |
1917
21964f5b1cc1
fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents:
1915
diff
changeset
|
1174 |
]. |
21964f5b1cc1
fixed selection redraw when resizing (larger) in motif mode
Claus Gittinger <cg@exept.de>
parents:
1915
diff
changeset
|
1175 |
super sizeChanged:how. |
2225 | 1176 |
self makeSelectionVisible |
1390 | 1177 |
! ! |
1178 |
||
1421 | 1179 |
!SelectionInListModelView methodsFor:'focus handling'! |
1180 |
||
1181 |
wantsFocusWithPointerEnter |
|
1182 |
"return true, if I want the focus when |
|
1183 |
the mouse pointer enters" |
|
1184 |
||
1185 |
|pref| |
|
1186 |
||
1187 |
pref := UserPreferences current focusFollowsMouse. |
|
1188 |
(pref ~~ false |
|
1189 |
and:[(styleSheet at:#'selection.requestFocusOnPointerEnter' default:true) |
|
1190 |
]) ifTrue:[ |
|
2055
964a2cac4e55
take focus on pointer enter only if the list is not empty.
Claus Gittinger <cg@exept.de>
parents:
1920
diff
changeset
|
1191 |
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
|
1192 |
^ true |
964a2cac4e55
take focus on pointer enter only if the list is not empty.
Claus Gittinger <cg@exept.de>
parents:
1920
diff
changeset
|
1193 |
] |
1421 | 1194 |
]. |
1195 |
^ false |
|
1196 |
! ! |
|
1197 |
||
1390 | 1198 |
!SelectionInListModelView methodsFor:'initialize / release'! |
1199 |
||
1200 |
fetchResources |
|
1201 |
"fetch device colors and ..., to avoid reallocation at redraw time; |
|
1202 |
*** called after a create or snapin to fetch all device resources |
|
1203 |
" |
|
1204 |
||
1205 |
super fetchResources. |
|
1206 |
||
1207 |
hilightFgColor := self colorOnDevice:hilightFgColor. |
|
1208 |
hilightBgColor := self colorOnDevice:hilightBgColor. |
|
1209 |
hilightFrameColor := self colorOnDevice:hilightFrameColor. |
|
1210 |
! |
|
1211 |
||
1212 |
initStyle |
|
1213 |
"setup viewStyle specifics |
|
1214 |
" |
|
1215 |
|h| |
|
1216 |
||
1217 |
super initStyle. |
|
1218 |
||
1595 | 1219 |
DefaultHilightLevel isNil ifTrue:[ |
1220 |
self updateStyleCache |
|
1221 |
]. |
|
1222 |
||
1390 | 1223 |
hilightFrameColor := nil. |
1224 |
hilightStyle := DefaultHilightStyle. |
|
1557 | 1225 |
highlightMode := #label. |
1390 | 1226 |
textStartLeft := 4. |
1227 |
||
1741
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
1228 |
super font:(styleSheet fontAt:#'selection.font'). |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
1229 |
|
1390 | 1230 |
device hasGrayscales ifTrue:[ |
1231 |
" |
|
1232 |
must get rid of these hard codings |
|
1233 |
" |
|
1234 |
(hilightStyle == #next) ifTrue:[ |
|
1235 |
hilightFgColor := fgColor. |
|
1236 |
hilightBgColor := White. |
|
1237 |
hilightFrameColor := fgColor |
|
1238 |
] ifFalse:[ |
|
1239 |
(hilightStyle == #motif) ifTrue:[ |
|
1240 |
fgColor := White. |
|
1241 |
bgColor := Grey. |
|
1242 |
viewBackground := bgColor. |
|
1243 |
hilightFgColor := bgColor. |
|
1244 |
hilightBgColor := fgColor. |
|
1245 |
] ifFalse:[ |
|
1246 |
(hilightStyle == #openwin) ifTrue:[ |
|
1247 |
hilightFgColor := fgColor. |
|
1248 |
hilightBgColor := Color grey. |
|
1249 |
] |
|
1250 |
] |
|
1251 |
] |
|
1252 |
]. |
|
1253 |
||
1254 |
hilightFgColor isNil ifTrue:[ |
|
1255 |
hilightFgColor := bgColor. |
|
1256 |
]. |
|
1257 |
hilightBgColor isNil ifTrue:[ |
|
1258 |
hilightBgColor := fgColor. |
|
1259 |
]. |
|
1260 |
DefaultForegroundColor notNil ifTrue:[ |
|
1261 |
fgColor := DefaultForegroundColor |
|
1262 |
]. |
|
1263 |
DefaultBackgroundColor notNil ifTrue:[ |
|
1264 |
bgColor := viewBackground := DefaultBackgroundColor |
|
1265 |
]. |
|
1266 |
||
1267 |
DefaultHilightForegroundColor notNil ifTrue:[ |
|
1268 |
hilightFgColor := DefaultHilightForegroundColor |
|
1269 |
]. |
|
1270 |
DefaultHilightBackgroundColor notNil ifTrue:[ |
|
1271 |
hilightBgColor := DefaultHilightBackgroundColor |
|
1272 |
]. |
|
1273 |
DefaultHilightFrameColor notNil ifTrue:[ |
|
1274 |
hilightFrameColor := DefaultHilightFrameColor |
|
1275 |
]. |
|
1276 |
||
1741
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
1277 |
hilightLevel := DefaultHilightLevel ? 0. |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
1278 |
lineSpacing := (hilightLevel abs > 0) ifTrue:[3] ifFalse:[2]. |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
1279 |
|
1390 | 1280 |
hilightFgColor isNil ifTrue:[ |
1281 |
hilightFgColor := bgColor. |
|
1282 |
hilightBgColor := fgColor |
|
1283 |
]. |
|
1284 |
! |
|
1285 |
||
1286 |
initialize |
|
1287 |
"setup default attributes/behavior |
|
1288 |
" |
|
1289 |
super initialize. |
|
1290 |
||
1291 |
multipleSelectOk := false. |
|
1292 |
useIndex := true. |
|
1741
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
1293 |
ignoreReselect := true. |
d928cdc5f4e5
add #ignoreReselect #toggleSelect; behaviour like SelectionInListView
ca
parents:
1739
diff
changeset
|
1294 |
toggleSelect := false. |
1390 | 1295 |
! |
1296 |
||
1745 | 1297 |
mapped |
1298 |
"get selection from model; scroll to selection |
|
1299 |
" |
|
1300 |
super mapped. |
|
1301 |
self makeSelectionVisible. |
|
1302 |
! |
|
1303 |
||
1390 | 1304 |
realize |
1305 |
"get selection from model; scroll to selection |
|
1306 |
" |
|
2185
639d20ab5667
updateFromModel renamed to asyncUpdateFromModel
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
1307 |
self asyncUpdateFromModel. |
1390 | 1308 |
super realize. |
1309 |
! ! |
|
1310 |
||
1755 | 1311 |
!SelectionInListModelView methodsFor:'private editor'! |
1312 |
||
1313 |
computeEditorLayout |
|
1314 |
"update the layout of the editor |
|
1315 |
" |
|
1316 |
|lnNr item y x h| |
|
1317 |
||
1318 |
editorView isNil ifTrue:[ |
|
1319 |
^ self |
|
1320 |
]. |
|
1321 |
||
1322 |
( (lnNr := self selectedIndex) == 0 |
|
1323 |
or:[(item := list at:lnNr ifAbsent:nil) isNil] |
|
1324 |
) ifTrue:[ |
|
1325 |
"/ there is no more single selection; thus close the editor |
|
1326 |
^ self closeEditor |
|
1327 |
]. |
|
1328 |
||
1329 |
y := self yVisibleOfLine:lnNr. |
|
1330 |
x := (self xVisibleOfItem:item) - (textStartLeft // 2). |
|
1331 |
h := self yVisibleOfLine:(lnNr + 1). |
|
1332 |
||
1333 |
editorView layout:( Rectangle left:x top:y right:(width - 1 - margin) bottom:(h - 1) ). |
|
1334 |
! |
|
1335 |
||
1336 |
openEditorAtX:x y:y |
|
1337 |
"opens an editor on the current single selection |
|
1338 |
" |
|
2225 | 1339 |
|item lnNr x0 y0 editor| |
1755 | 1340 |
|
1341 |
self closeEditor. |
|
2225 | 1342 |
shown ifFalse:[^ self ]. |
1343 |
openEditorAction ifNil:[^ self]. |
|
1755 | 1344 |
|
2225 | 1345 |
lnNr := self selectedIndex. |
1346 |
lnNr == 0 ifTrue:[^ self]. |
|
1347 |
||
1348 |
item := list at:lnNr ifAbsent:nil. |
|
1349 |
item ifNil:[^ self]. |
|
1755 | 1350 |
|
1915 | 1351 |
x < (self xVisibleOfItem:item) ifTrue:[ |
1352 |
"/ not part of the selection frame; ignorre |
|
1353 |
^ self |
|
1755 | 1354 |
]. |
2225 | 1355 |
editor := self openEditor. |
1356 |
editor ifNil:[^ self]. |
|
1755 | 1357 |
|
2225 | 1358 |
y0 := (y - editor origin y) max:0. |
1359 |
x0 := (x - editor origin x) max:0. |
|
1755 | 1360 |
|
2125 | 1361 |
"/ simulate clicking into the editor |
2225 | 1362 |
self sensor pushEvent:(WindowEvent buttonPress:#select x:x0 y:y0 view:editor). |
1363 |
self sensor pushEvent:(WindowEvent buttonRelease:#select x:x0 y:y0 view:editor). |
|
1755 | 1364 |
|
1365 |
"/ to clear the selection |
|
1366 |
self redrawLineAt:lnNr. |
|
1367 |
! ! |
|
1368 |
||
1390 | 1369 |
!SelectionInListModelView methodsFor:'protocol'! |
1370 |
||
1533 | 1371 |
drawElementsFrom:start to:stop x:x y:y w:w |
1390 | 1372 |
"draw the items between start to stop without clearing the background |
1373 |
" |
|
1374 |
|y0 "{ Class:SmallInteger }" |
|
1375 |
y1 "{ Class:SmallInteger }" |
|
1376 |
x0 "{ Class:SmallInteger }" |
|
1377 |
| |
|
1378 |
x0 := textStartLeft - viewOrigin x. |
|
1533 | 1379 |
y1 := y. |
1390 | 1380 |
|
1381 |
start to:stop do:[:i| |
|
1382 |
y0 := y1. |
|
1383 |
y1 := self yVisibleOfLine:(i + 1). |
|
1533 | 1384 |
self drawLabelAt:i x:x0 y:y0 h:(y1 - y0) |
1390 | 1385 |
]. |
1386 |
||
1387 |
||
1388 |
! |
|
1389 |
||
1458 | 1390 |
lostSynchronisation |
1391 |
"called when the changes derived from the model are faster than the handling |
|
1392 |
" |
|
1547 | 1393 |
self deselectWithoutRedraw. |
1458 | 1394 |
super lostSynchronisation. |
1554 | 1395 |
! |
1396 |
||
1397 |
xVisibleOfItem:anItem |
|
1398 |
"returns the visible x of the labeled text |
|
1399 |
" |
|
1400 |
^ textStartLeft - viewOrigin x |
|
1401 |
||
1402 |
||
1390 | 1403 |
! ! |
1404 |
||
1405 |
!SelectionInListModelView methodsFor:'selection'! |
|
1406 |
||
1407 |
deselect |
|
1408 |
"clear selection |
|
1409 |
" |
|
1410 |
self selection:nil |
|
1411 |
||
1412 |
! |
|
1413 |
||
1414 |
firstInSelection |
|
1415 |
"returns line number of first element selected or nil |
|
1416 |
" |
|
1545 | 1417 |
multipleSelectOk ifFalse:[ |
1418 |
^ selection |
|
1390 | 1419 |
]. |
1545 | 1420 |
^ selection isNil ifTrue:[nil] ifFalse:[selection at:1] |
1390 | 1421 |
! |
1422 |
||
1423 |
hasSelection |
|
1424 |
"returns true if a selection exists |
|
1425 |
" |
|
1426 |
^ selection notNil |
|
1427 |
||
1428 |
! |
|
1429 |
||
1430 |
isInSelection:aNumber |
|
1431 |
"return true, if line, aNumber is in the selection |
|
1432 |
" |
|
1545 | 1433 |
multipleSelectOk ifFalse:[ |
1434 |
^ aNumber == selection |
|
1435 |
]. |
|
1436 |
^ selection isNil ifTrue:[false] |
|
1437 |
ifFalse:[selection includesIdentical:aNumber] |
|
1390 | 1438 |
! |
1439 |
||
1440 |
numberOfSelections |
|
1441 |
"return the number of selected items |
|
1442 |
" |
|
1545 | 1443 |
selection notNil ifTrue:[ |
1444 |
^ multipleSelectOk ifFalse:[1] ifTrue:[selection size] |
|
1445 |
]. |
|
1446 |
^ 0 |
|
1390 | 1447 |
|
1448 |
! |
|
1449 |
||
1450 |
selectElement:anElement |
|
1451 |
"select the element. Scroll to make the new selection visible. |
|
1452 |
Model and/or actionBlock notification IS done. |
|
1453 |
" |
|
2178 | 1454 |
self selectElement:anElement ifAbsent:[self deselect] |
1455 |
! |
|
1456 |
||
1457 |
selectElement:anElement ifAbsent:exceptionalValue |
|
1458 |
|idx| |
|
1459 |
||
1460 |
idx := list identityIndexOf:anElement. |
|
1461 |
idx == 0 ifTrue:[ |
|
1462 |
^ exceptionalValue value |
|
1463 |
]. |
|
1464 |
self selection:idx |
|
1390 | 1465 |
! |
1466 |
||
1467 |
selectedElement |
|
1468 |
"return the single selected item or nil |
|
1469 |
" |
|
1545 | 1470 |
|index| |
1390 | 1471 |
|
1545 | 1472 |
(index := self selectedIndex) ~~ 0 ifTrue:[ |
1473 |
^ list at:index ifAbsent:nil |
|
1474 |
]. |
|
1475 |
^ nil |
|
1390 | 1476 |
! |
1477 |
||
1478 |
selectedIndex |
|
1479 |
"returns the index of the selected line or 0. If more |
|
1480 |
lines are selected, 0 is returned |
|
1481 |
" |
|
1545 | 1482 |
self numberOfSelections == 1 ifTrue:[ |
1483 |
^ self firstInSelection |
|
1484 |
]. |
|
1485 |
^ 0 |
|
1390 | 1486 |
! |
1487 |
||
1488 |
selection |
|
1489 |
"return the selection index or collection of indices |
|
1490 |
in case of multiple selection enabled |
|
1491 |
" |
|
1492 |
^ selection |
|
1493 |
||
1494 |
! |
|
1495 |
||
1545 | 1496 |
selection:something |
1497 |
"select something or deselect if the argument is nil; |
|
1390 | 1498 |
scroll to make the selected line visible. |
1499 |
The model and/or actionBlock IS notified. |
|
1500 |
" |
|
1545 | 1501 |
(self selectWithoutScroll:something redraw:true) ifTrue:[ |
1502 |
self makeSelectionVisible. |
|
1390 | 1503 |
self selectionChanged |
1545 | 1504 |
]. |
1390 | 1505 |
|
1506 |
! |
|
1507 |
||
1508 |
selectionDo:aBlock |
|
1509 |
"perform aBlock for each nr in the selection. |
|
1510 |
For single selection, it is called once for the items nr. |
|
1511 |
For multiple selections, it is called for each. |
|
1512 |
" |
|
1513 |
selection notNil ifTrue:[ |
|
1514 |
multipleSelectOk ifTrue:[ |
|
1515 |
selection do:aBlock |
|
1516 |
] ifFalse:[ |
|
1517 |
aBlock value:selection |
|
1518 |
]. |
|
1519 |
]. |
|
1520 |
||
1521 |
||
1522 |
! |
|
1523 |
||
1542
8607d072c319
accessing selection through to selector
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
1524 |
setSelection:something |
1545 | 1525 |
"select something or deselect if the argument is nil; |
1390 | 1526 |
scroll to make the selected line visible. |
1527 |
*** No model and/or actionBlock notification is done here. |
|
1528 |
" |
|
1545 | 1529 |
(self selectWithoutScroll:something redraw:true) ifTrue:[ |
1390 | 1530 |
self makeSelectionVisible |
1531 |
] |
|
1532 |
||
1533 |
! ! |
|
1534 |
||
1535 |
!SelectionInListModelView methodsFor:'selection private'! |
|
1536 |
||
1641 | 1537 |
canSelectIndex:anIndex |
1538 |
"return true, if the object identified by its index is selectable |
|
1539 |
" |
|
1920 | 1540 |
^ self canSelectIndex:anIndex forAdd:false |
1541 |
! |
|
1542 |
||
1543 |
canSelectIndex:anIndex forAdd:isForAdd |
|
1544 |
"return true, if the object identified by its index is selectable |
|
1545 |
" |
|
1546 |
|item isOk| |
|
1649 | 1547 |
|
1548 |
selectConditionBlock notNil ifTrue:[ |
|
1920 | 1549 |
selectConditionBlock numArgs == 2 ifTrue:[ |
1550 |
isOk := selectConditionBlock value:anIndex value:isForAdd. |
|
1551 |
] ifFalse:[ |
|
1552 |
isOk := selectConditionBlock value:anIndex. |
|
1553 |
]. |
|
1554 |
isOk ifFalse:[ |
|
1649 | 1555 |
^ false |
1556 |
] |
|
1641 | 1557 |
]. |
1558 |
||
1752 | 1559 |
item := list at:anIndex ifAbsent:nil. |
1560 |
item isNil ifTrue:[^ false]. |
|
1561 |
item isHierarchicalItem ifTrue:[ |
|
1649 | 1562 |
^ item isSelectable |
1563 |
]. |
|
1564 |
^ true |
|
1641 | 1565 |
! |
1566 |
||
1547 | 1567 |
deselectWithoutRedraw |
1568 |
"clear the selection without redraw and scrolling; |
|
1569 |
the model and/or actionBlock is notified |
|
1570 |
" |
|
1571 |
(self selectWithoutScroll:nil redraw:false) ifTrue:[ |
|
1572 |
self selectionChanged |
|
1573 |
] |
|
1574 |
! |
|
1575 |
||
1390 | 1576 |
makeSelectionVisible |
1577 |
"scroll to make the selection line visible |
|
1578 |
" |
|
1579 |
|lineNr| |
|
1580 |
||
1564 | 1581 |
lineNr := self firstInSelection. |
1582 |
||
1583 |
lineNr notNil ifTrue:[ |
|
1584 |
self scrollToLine:lineNr |
|
1390 | 1585 |
] |
1586 |
||
1587 |
! |
|
1588 |
||
1545 | 1589 |
selectWithoutScroll:something redraw:doRedraw |
1590 |
"change selection to something; returns true if selection changed |
|
1390 | 1591 |
" |
1592 |
|oldSelect| |
|
1593 |
||
1554 | 1594 |
selection = something ifTrue:[^ false]. |
1595 |
||
1390 | 1596 |
oldSelect := selection. |
1597 |
||
1545 | 1598 |
(something isNil or:[something == 0]) ifTrue:[ |
1599 |
selection := nil |
|
1600 |
] ifFalse:[ |
|
1601 |
something isNumber ifTrue:[ |
|
1564 | 1602 |
selection := multipleSelectOk ifTrue:[Array with:something] |
1603 |
ifFalse:[something] |
|
1545 | 1604 |
] ifFalse:[ |
1605 |
something size == 0 ifTrue:[ |
|
1606 |
selection := nil |
|
1607 |
] ifFalse:[ |
|
1608 |
selection := multipleSelectOk ifTrue:[something] |
|
1609 |
ifFalse:[something at:1] |
|
1610 |
] |
|
1611 |
] |
|
1612 |
]. |
|
1613 |
selection = oldSelect ifTrue:[^ false]. |
|
1755 | 1614 |
self closeEditor. |
1545 | 1615 |
|
1616 |
(doRedraw and:[shown]) ifFalse:[ |
|
1617 |
^ true |
|
1390 | 1618 |
]. |
1619 |
||
1620 |
multipleSelectOk ifFalse:[ |
|
1621 |
oldSelect notNil ifTrue:[self redrawSelectionAt:oldSelect]. |
|
1622 |
selection notNil ifTrue:[self redrawSelectionAt:selection]. |
|
1623 |
] ifTrue:[ |
|
1545 | 1624 |
(selection notNil and:[oldSelect notNil]) ifTrue:[ |
1625 |
selection do:[:i|(oldSelect includesIdentical:i) ifFalse:[self redrawSelectionAt:i]]. |
|
1626 |
oldSelect do:[:i|(selection includesIdentical:i) ifFalse:[self redrawSelectionAt:i]]. |
|
1390 | 1627 |
] ifFalse:[ |
1545 | 1628 |
oldSelect isNil ifTrue:[oldSelect := selection]. |
1629 |
oldSelect do:[:i|self redrawSelectionAt:i] |
|
1390 | 1630 |
] |
1631 |
]. |
|
1545 | 1632 |
^ true |
1390 | 1633 |
|
1634 |
||
1561 | 1635 |
! |
1636 |
||
1637 |
toggleSelection:aNumber |
|
1638 |
"add a number to the selection. No scrolling is done. |
|
1639 |
*** No model and/or actionBlock notification is done here. |
|
1640 |
" |
|
1641 |
|newSelect oldSelect doRemove| |
|
1642 |
||
1643 |
multipleSelectOk ifFalse:[ |
|
1644 |
aNumber == selection ifTrue:[ "/ remove from selection |
|
1645 |
selection := nil. |
|
1646 |
] ifFalse:[ "/ add to selection |
|
1647 |
oldSelect := selection. |
|
1648 |
selection := aNumber. |
|
1649 |
||
1650 |
oldSelect notNil ifTrue:[ |
|
1651 |
self redrawSelectionAt:oldSelect |
|
1652 |
] |
|
1653 |
]. |
|
1654 |
self redrawSelectionAt:aNumber. |
|
1655 |
^ self |
|
1656 |
]. |
|
1657 |
||
1658 |
selection isNil ifTrue:[ "/ add to empty selection |
|
1659 |
selection := OrderedCollection with:aNumber. |
|
1660 |
self redrawSelectionAt:aNumber. |
|
1661 |
^ self |
|
1662 |
]. |
|
1663 |
||
1664 |
doRemove := selection includesIdentical:aNumber. |
|
1665 |
||
1666 |
(doRemove and:[selection size == 1]) ifTrue:[ "/ remove selection |
|
1667 |
selection := nil. |
|
1668 |
self redrawSelectionAt:aNumber. |
|
1669 |
^ self |
|
1670 |
]. |
|
1671 |
||
1672 |
selection := selection asOrderedCollection. |
|
1673 |
||
1674 |
doRemove ifTrue:[ |
|
1675 |
selection removeIdentical:aNumber. |
|
1676 |
] ifFalse:[ |
|
1677 |
selection add:aNumber. |
|
1678 |
]. |
|
1679 |
self redrawSelectionAt:aNumber. |
|
1680 |
||
1681 |
||
1682 |
||
1390 | 1683 |
! ! |
1684 |
||
1685 |
!SelectionInListModelView class methodsFor:'documentation'! |
|
1686 |
||
1687 |
version |
|
2225 | 1688 |
^ '$Header: /cvs/stx/stx/libwidg2/SelectionInListModelView.st,v 1.51 2002-09-27 11:53:27 penk Exp $' |
1390 | 1689 |
! ! |