author | Claus Gittinger <cg@exept.de> |
Tue, 06 Jul 1999 18:51:00 +0200 | |
changeset 1431 | 0cc20a8f2f7c |
parent 1415 | 3727e58ab63b |
child 1477 | b607b899c4df |
permissions | -rw-r--r-- |
444 | 1 |
" |
2 |
COPYRIGHT (c) 1997 by eXept Software AG / Claus Gittinger |
|
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 |
||
14 |
SelectionInListView subclass:#SelectionInTreeView |
|
847 | 15 |
instanceVariableNames:'validateDoubleClickBlock selectionHolder rootHolder imageWidth |
16 |
showLines listOfNodes imageInset textInset labelOffsetY lineMask |
|
1171 | 17 |
itemClass lineColor computeResources showRoot |
18 |
showDirectoryIndicator closeIndicator openIndicator |
|
19 |
showDirectoryIndicatorForRoot imageOpened imageClosed imageItem |
|
20 |
discardMotionEvents registeredImages supportsExpandAll |
|
21 |
buildInArray drawVLinesFromLevel highlightMode editorWidget |
|
1202
b9a3beb20ca7
added an extra validateExpandability block,
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
22 |
editorIndex editValueFgColor validateExpandabilityBlock' |
1171 | 23 |
classVariableNames:'DefaultHilightMode SelectionInset' |
847 | 24 |
poolDictionaries:'' |
1233 | 25 |
category:'Views-Trees' |
444 | 26 |
! |
27 |
||
28 |
!SelectionInTreeView class methodsFor:'documentation'! |
|
29 |
||
30 |
copyright |
|
31 |
" |
|
32 |
COPYRIGHT (c) 1997 by eXept Software AG / Claus Gittinger |
|
33 |
All Rights Reserved |
|
34 |
||
35 |
This software is furnished under a license and may be used |
|
36 |
only in accordance with the terms of that license and with the |
|
37 |
inclusion of the above copyright notice. This software may not |
|
38 |
be provided or otherwise made available to, or used by, any |
|
39 |
other person. No title to or ownership of the software is |
|
40 |
hereby transferred. |
|
41 |
" |
|
42 |
||
43 |
! |
|
44 |
||
45 |
documentation |
|
46 |
" |
|
47 |
somewhat like a SelectionInListView; but specialized for hierarchical (i.e. tree-like) |
|
48 |
lists and adds the functions to show/hide subtrees. |
|
456 | 49 |
Requires SelectionInTree as model and TreeItem (or compatible) list entries. |
444 | 50 |
|
1431 | 51 |
This class obsoletes SelectionInHierarchyView, which is no longer |
446 | 52 |
maintained but kept for backward compatibility. |
53 |
||
1431 | 54 |
Notice: |
55 |
This class obsoletes SelectionInHierarchyView, which is no longer |
|
56 |
maintained but kept for backward compatibility. |
|
57 |
||
58 |
Notice2: |
|
59 |
Even for this class, an improved replacement now exists: |
|
60 |
HierarchicalListView. |
|
61 |
Please consider using that one. |
|
62 |
(however, this class is kept for backward compatibility). |
|
446 | 63 |
|
444 | 64 |
[see also:] |
456 | 65 |
SelectionInTree |
66 |
TreeItem |
|
444 | 67 |
SelectionInListView |
494 | 68 |
FileSelectionTree |
444 | 69 |
|
70 |
[author:] |
|
71 |
Claus Atzkern |
|
72 |
" |
|
73 |
||
74 |
! |
|
75 |
||
76 |
examples |
|
77 |
" |
|
78 |
shows the tree of smalltalk classes: |
|
79 |
[exBegin] |
|
514 | 80 |
|top sel| |
456 | 81 |
|
514 | 82 |
top := StandardSystemView new; extent:300@300. |
456 | 83 |
sel := SelectionInTreeView new. |
514 | 84 |
sel root:(TreeItem newAsTreeFromSmalltalkClass:Object). |
456 | 85 |
sel action:[:nr | Transcript show:'selected:'; showCR:nr]. |
86 |
top add:(ScrollableView forView:sel) in:((0.0 @ 0.0 ) corner:( 1.0 @ 1.0)). |
|
87 |
top open. |
|
88 |
[exEnd] |
|
89 |
||
90 |
||
485 | 91 |
|
456 | 92 |
same, including nil-subclasses (i.e. really all classes): |
93 |
[exBegin] |
|
514 | 94 |
|top sel| |
444 | 95 |
|
514 | 96 |
top := StandardSystemView new; extent:300@300. |
456 | 97 |
sel := SelectionInTreeView new. |
514 | 98 |
sel root:(TreeItem newAsTreeFromSmalltalkClass:nil). |
456 | 99 |
sel action:[:nr | Transcript show:'selected:'; showCR:nr]. |
685 | 100 |
sel lineColor:(Color red). |
456 | 101 |
top add:(ScrollableView forView:sel) in:((0.0 @ 0.0 ) corner:( 1.0 @ 1.0)). |
102 |
top open. |
|
103 |
[exEnd] |
|
104 |
||
485 | 105 |
|
483 | 106 |
|
485 | 107 |
shows the tree of smalltalk classes; show directory indication and no |
108 |
lines. |
|
109 |
[exBegin] |
|
514 | 110 |
|top sel| |
483 | 111 |
|
514 | 112 |
top := StandardSystemView new; extent:300@300. |
483 | 113 |
sel := SelectionInTreeView new. |
485 | 114 |
sel showLines:false. |
115 |
sel showDirectoryIndicator:true. |
|
514 | 116 |
sel root:(TreeItem newAsTreeFromSmalltalkClass:Object). |
485 | 117 |
sel action:[:nr | Transcript show:'selected:'; showCR:nr]. |
483 | 118 |
top add:(ScrollableView forView:sel) in:((0.0 @ 0.0 ) corner:( 1.0 @ 1.0)). |
119 |
top open. |
|
485 | 120 |
[exEnd] |
121 |
" |
|
122 |
||
514 | 123 |
|
444 | 124 |
! ! |
125 |
||
126 |
!SelectionInTreeView class methodsFor:'constants'! |
|
127 |
||
494 | 128 |
minImageInset |
129 |
"returns minimum inset from directory indication to image |
|
471 | 130 |
" |
494 | 131 |
^ 6 |
490 | 132 |
|
133 |
||
134 |
! ! |
|
135 |
||
900 | 136 |
!SelectionInTreeView class methodsFor:'defaults'! |
137 |
||
1171 | 138 |
defaultModelClass |
139 |
"returns the default model |
|
140 |
" |
|
141 |
^ SelectionInTree |
|
142 |
! |
|
143 |
||
900 | 144 |
updateStyleCache |
145 |
"extract values from the styleSheet and cache them in class variables" |
|
146 |
||
147 |
<resource: #style (#'selection.highlightMode')> |
|
148 |
||
1171 | 149 |
SelectionInset := 4. |
900 | 150 |
DefaultHilightMode := StyleSheet at:'selection.highlightMode' default:#line. |
151 |
" |
|
152 |
self updateStyleCache |
|
153 |
" |
|
154 |
||
155 |
||
156 |
! ! |
|
157 |
||
811 | 158 |
!SelectionInTreeView class methodsFor:'resources'! |
490 | 159 |
|
160 |
closeIndicator |
|
1278 | 161 |
"returns a little [+] bitmap" |
162 |
||
589 | 163 |
<resource: #fileImage> |
164 |
||
811 | 165 |
^ Icon |
166 |
constantNamed:#plus |
|
1415
3727e58ab63b
use new Icon>> constantNamed:ifAbsentPutImageFromFile:
Claus Gittinger <cg@exept.de>
parents:
1328
diff
changeset
|
167 |
ifAbsentPutImageFromFile:'xpmBitmaps/plus.xpm' |
811 | 168 |
|
589 | 169 |
|
811 | 170 |
|
171 |
||
172 |
||
173 |
||
471 | 174 |
! |
175 |
||
444 | 176 |
imageClosed |
1278 | 177 |
"returns a closed file-directory bitmap" |
178 |
||
589 | 179 |
<resource: #fileImage> |
180 |
||
811 | 181 |
^ Icon |
182 |
constantNamed:#directory |
|
1415
3727e58ab63b
use new Icon>> constantNamed:ifAbsentPutImageFromFile:
Claus Gittinger <cg@exept.de>
parents:
1328
diff
changeset
|
183 |
ifAbsentPutImageFromFile:'xpmBitmaps/document_images/tiny_yellow_dir.xpm' |
444 | 184 |
|
185 |
! |
|
186 |
||
187 |
imageItem |
|
1278 | 188 |
"returns a regular file bitmap" |
189 |
||
589 | 190 |
<resource: #fileImage> |
191 |
||
811 | 192 |
^ Icon |
193 |
constantNamed:#plainFile |
|
1415
3727e58ab63b
use new Icon>> constantNamed:ifAbsentPutImageFromFile:
Claus Gittinger <cg@exept.de>
parents:
1328
diff
changeset
|
194 |
ifAbsentPutImageFromFile:'xpmBitmaps/document_images/tiny_file_plain.xpm' |
444 | 195 |
|
811 | 196 |
|
444 | 197 |
|
811 | 198 |
|
199 |
||
444 | 200 |
! |
201 |
||
202 |
imageOpened |
|
1278 | 203 |
"returns an opened file-directory bitmap" |
204 |
||
589 | 205 |
<resource: #fileImage> |
206 |
||
811 | 207 |
^ Icon |
208 |
constantNamed:#directoryOpened |
|
1415
3727e58ab63b
use new Icon>> constantNamed:ifAbsentPutImageFromFile:
Claus Gittinger <cg@exept.de>
parents:
1328
diff
changeset
|
209 |
ifAbsentPutImageFromFile:'xpmBitmaps/document_images/tiny_yellow_dir_open.xpm' |
444 | 210 |
|
490 | 211 |
! |
212 |
||
213 |
openIndicator |
|
1278 | 214 |
"returns a little [-] bitmap" |
215 |
||
589 | 216 |
<resource: #fileImage> |
217 |
||
811 | 218 |
^ Icon |
219 |
constantNamed:#minus |
|
1415
3727e58ab63b
use new Icon>> constantNamed:ifAbsentPutImageFromFile:
Claus Gittinger <cg@exept.de>
parents:
1328
diff
changeset
|
220 |
ifAbsentPutImageFromFile:'xpmBitmaps/minus.xpm' |
490 | 221 |
|
811 | 222 |
|
444 | 223 |
! ! |
224 |
||
225 |
!SelectionInTreeView methodsFor:'accessing'! |
|
226 |
||
900 | 227 |
highlightMode |
228 |
"get the mode how to draw a selected line: |
|
229 |
#line draw whole line selected |
|
230 |
#label draw label selected |
|
231 |
" |
|
232 |
^ highlightMode |
|
233 |
! |
|
234 |
||
235 |
highlightMode:aMode |
|
236 |
"set the mode how to draw a selected line: |
|
237 |
#line draw whole line selected |
|
238 |
#label draw label selected |
|
239 |
" |
|
240 |
|mode| |
|
241 |
||
242 |
(mode := aMode) == #label ifFalse:[ |
|
243 |
mode := #line |
|
244 |
]. |
|
245 |
||
246 |
mode ~~ highlightMode ifTrue:[ |
|
247 |
highlightMode := mode. |
|
248 |
||
249 |
shown ifTrue:[ |
|
250 |
self invalidate |
|
251 |
] |
|
252 |
] |
|
253 |
! |
|
254 |
||
1171 | 255 |
itemClass |
256 |
"returns current itemClass used |
|
257 |
" |
|
258 |
^ itemClass |
|
259 |
||
260 |
||
261 |
! |
|
262 |
||
263 |
itemClass:anItemClass |
|
264 |
"set itemClass to be used |
|
265 |
" |
|
266 |
||
267 |
(anItemClass notNil and:[anItemClass ~~ itemClass]) ifTrue:[ |
|
268 |
itemClass := anItemClass. |
|
269 |
computeResources := true. |
|
270 |
self refetchDeviceResources. |
|
271 |
]. |
|
272 |
||
273 |
! |
|
274 |
||
685 | 275 |
lineColor |
276 |
"returns user configured line color or nil |
|
277 |
" |
|
278 |
^ lineColor |
|
279 |
||
280 |
! |
|
281 |
||
282 |
lineColor:aColor |
|
283 |
"returns user configured line color or nil |
|
284 |
" |
|
285 |
|col| |
|
286 |
||
287 |
col := aColor = fgColor ifTrue:[nil] ifFalse:[aColor]. |
|
288 |
||
289 |
col = lineColor ifFalse:[ |
|
290 |
lineColor := col. |
|
291 |
||
292 |
shown ifTrue:[ |
|
293 |
lineColor notNil ifTrue:[lineColor := lineColor on:device]. |
|
294 |
self invalidate |
|
295 |
] |
|
296 |
] |
|
297 |
! |
|
298 |
||
490 | 299 |
nodeAtIndex:anIndex |
300 |
"returns node at an index or nil |
|
301 |
" |
|
785 | 302 |
(anIndex notNil and:[anIndex between:1 and:listOfNodes size]) ifTrue:[ |
490 | 303 |
^ listOfNodes at:anIndex |
304 |
]. |
|
305 |
^ nil |
|
306 |
! |
|
307 |
||
507 | 308 |
root |
309 |
"gets the root of the model; the first item into list. |
|
310 |
" |
|
311 |
^ self nodeAtIndex:1 |
|
312 |
! |
|
313 |
||
314 |
root:aRoot |
|
315 |
"sets the root of the model; the first item into list. |
|
316 |
" |
|
514 | 317 |
aRoot notNil ifTrue:[aRoot expand]. |
507 | 318 |
model root:aRoot |
319 |
! |
|
320 |
||
490 | 321 |
textInset |
322 |
"get the left inset of the text label |
|
323 |
" |
|
324 |
^ textInset |
|
325 |
! |
|
326 |
||
327 |
textInset:anInset |
|
328 |
"set the left inset of the text label |
|
329 |
" |
|
330 |
anInset ~~ textInset ifTrue:[ |
|
331 |
anInset >= 0 ifTrue:[ |
|
332 |
textInset := anInset. |
|
333 |
self invalidate |
|
334 |
] ifFalse:[ |
|
335 |
self error |
|
336 |
] |
|
337 |
]. |
|
338 |
! ! |
|
339 |
||
340 |
!SelectionInTreeView methodsFor:'accessing-behavior'! |
|
341 |
||
855 | 342 |
drawVLinesFromLevel |
343 |
"returns the level vertical lines are drawn from; |
|
344 |
starting at 1 up to n |
|
345 |
" |
|
346 |
^ drawVLinesFromLevel |
|
347 |
! |
|
348 |
||
349 |
drawVLinesFromLevel:aLevel |
|
350 |
"set the level vertical lines are drawn from; |
|
351 |
starting at 1 up to n |
|
352 |
" |
|
353 |
|lv| |
|
354 |
||
355 |
lv := (aLevel ? 1) max:1. |
|
356 |
||
357 |
lv ~~ drawVLinesFromLevel ifTrue:[ |
|
358 |
drawVLinesFromLevel := lv. |
|
359 |
self invalidate |
|
360 |
] |
|
361 |
! |
|
362 |
||
835 | 363 |
supportsExpandAll |
364 |
^ supportsExpandAll |
|
365 |
! |
|
366 |
||
367 |
supportsExpandAll:aBool |
|
368 |
||
369 |
supportsExpandAll := aBool |
|
370 |
! |
|
371 |
||
517 | 372 |
validateDoubleClickBlock |
1202
b9a3beb20ca7
added an extra validateExpandability block,
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
373 |
"return the conditionBlock; this block is evaluated before a doubleClick action |
517 | 374 |
on a node will be performed. In case of returning false, the doubleClick will |
375 |
not be handled. |
|
376 |
" |
|
377 |
^ validateDoubleClickBlock |
|
378 |
||
379 |
||
380 |
! |
|
381 |
||
382 |
validateDoubleClickBlock:aOneArgBlock |
|
383 |
"set the conditionBlock; this block is evaluated before a doubleClick action |
|
384 |
on a node will be performed. In case of returning false, the doubleClick will |
|
385 |
not be handled. |
|
386 |
" |
|
387 |
validateDoubleClickBlock := aOneArgBlock |
|
388 |
||
389 |
||
1202
b9a3beb20ca7
added an extra validateExpandability block,
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
390 |
! |
b9a3beb20ca7
added an extra validateExpandability block,
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
391 |
|
b9a3beb20ca7
added an extra validateExpandability block,
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
392 |
validateExpandabilityBlock |
b9a3beb20ca7
added an extra validateExpandability block,
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
393 |
"return the expand conditionBlock; this block is evaluated before an expand due to |
b9a3beb20ca7
added an extra validateExpandability block,
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
394 |
a doubleClick on a node will be performed. In case of returning false, |
b9a3beb20ca7
added an extra validateExpandability block,
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
395 |
the node will not be expanded. |
b9a3beb20ca7
added an extra validateExpandability block,
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
396 |
" |
b9a3beb20ca7
added an extra validateExpandability block,
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
397 |
^ validateExpandabilityBlock |
b9a3beb20ca7
added an extra validateExpandability block,
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
398 |
|
b9a3beb20ca7
added an extra validateExpandability block,
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
399 |
|
b9a3beb20ca7
added an extra validateExpandability block,
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
400 |
! |
b9a3beb20ca7
added an extra validateExpandability block,
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
401 |
|
b9a3beb20ca7
added an extra validateExpandability block,
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
402 |
validateExpandabilityBlock:aOneArgBlock |
b9a3beb20ca7
added an extra validateExpandability block,
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
403 |
"set the expand conditionBlock; this block is evaluated before an expand due to |
b9a3beb20ca7
added an extra validateExpandability block,
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
404 |
a doubleClick on a node will be performed. In case of returning false, |
b9a3beb20ca7
added an extra validateExpandability block,
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
405 |
the node will not be expanded. |
b9a3beb20ca7
added an extra validateExpandability block,
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
406 |
" |
b9a3beb20ca7
added an extra validateExpandability block,
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
407 |
validateExpandabilityBlock := aOneArgBlock |
b9a3beb20ca7
added an extra validateExpandability block,
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
408 |
|
b9a3beb20ca7
added an extra validateExpandability block,
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
409 |
|
514 | 410 |
! ! |
411 |
||
412 |
!SelectionInTreeView methodsFor:'accessing-channels'! |
|
413 |
||
414 |
rootHolder |
|
415 |
"get the holder which keeps the hierarchical list entry or nil |
|
416 |
" |
|
417 |
^ rootHolder |
|
418 |
! |
|
419 |
||
420 |
rootHolder:aValueHolder |
|
421 |
"set the holder which keeps the hierarchical list entry or nil |
|
422 |
" |
|
423 |
rootHolder notNil ifTrue:[ |
|
424 |
rootHolder removeDependent:self |
|
425 |
]. |
|
855 | 426 |
|
514 | 427 |
(rootHolder := aValueHolder) notNil ifTrue:[ |
428 |
rootHolder addDependent:self. |
|
429 |
self rootFromModel. |
|
494 | 430 |
]. |
514 | 431 |
! |
432 |
||
433 |
selectionHolder |
|
434 |
"get the holder which keeps a list of selected items or nil |
|
435 |
" |
|
436 |
^ selectionHolder |
|
437 |
||
438 |
! |
|
439 |
||
440 |
selectionHolder:aHolder |
|
441 |
"set the holder which keeps a list of selected items or nil |
|
442 |
" |
|
443 |
selectionHolder notNil ifTrue:[ |
|
444 |
selectionHolder removeDependent:self |
|
445 |
]. |
|
446 |
||
447 |
(selectionHolder := aHolder) notNil ifTrue:[ |
|
448 |
selectionHolder addDependent:self. |
|
449 |
self selectionFromModel |
|
450 |
]. |
|
451 |
||
490 | 452 |
! ! |
453 |
||
454 |
!SelectionInTreeView methodsFor:'accessing-images'! |
|
455 |
||
448
7f9f3531660c
cache device images for fast drawing
Claus Gittinger <cg@exept.de>
parents:
446
diff
changeset
|
456 |
imageClosed |
1278 | 457 |
"return the value of the instance variable 'imageClosed'. |
458 |
Thats the (default) bitmap image shown for closed folders |
|
459 |
(initialized to a file-directory bitmap)" |
|
448
7f9f3531660c
cache device images for fast drawing
Claus Gittinger <cg@exept.de>
parents:
446
diff
changeset
|
460 |
|
7f9f3531660c
cache device images for fast drawing
Claus Gittinger <cg@exept.de>
parents:
446
diff
changeset
|
461 |
^ imageClosed |
7f9f3531660c
cache device images for fast drawing
Claus Gittinger <cg@exept.de>
parents:
446
diff
changeset
|
462 |
|
7f9f3531660c
cache device images for fast drawing
Claus Gittinger <cg@exept.de>
parents:
446
diff
changeset
|
463 |
"Created: 3.7.1997 / 12:34:31 / cg" |
7f9f3531660c
cache device images for fast drawing
Claus Gittinger <cg@exept.de>
parents:
446
diff
changeset
|
464 |
! |
7f9f3531660c
cache device images for fast drawing
Claus Gittinger <cg@exept.de>
parents:
446
diff
changeset
|
465 |
|
7f9f3531660c
cache device images for fast drawing
Claus Gittinger <cg@exept.de>
parents:
446
diff
changeset
|
466 |
imageItem |
1278 | 467 |
"return the value of the instance variable 'imageItem'. |
468 |
Thats the (default) bitmap image shown for regular items |
|
469 |
(initialized to a plain-file bitmap)" |
|
448
7f9f3531660c
cache device images for fast drawing
Claus Gittinger <cg@exept.de>
parents:
446
diff
changeset
|
470 |
|
7f9f3531660c
cache device images for fast drawing
Claus Gittinger <cg@exept.de>
parents:
446
diff
changeset
|
471 |
^ imageItem |
7f9f3531660c
cache device images for fast drawing
Claus Gittinger <cg@exept.de>
parents:
446
diff
changeset
|
472 |
|
7f9f3531660c
cache device images for fast drawing
Claus Gittinger <cg@exept.de>
parents:
446
diff
changeset
|
473 |
"Created: 3.7.1997 / 12:34:34 / cg" |
7f9f3531660c
cache device images for fast drawing
Claus Gittinger <cg@exept.de>
parents:
446
diff
changeset
|
474 |
! |
7f9f3531660c
cache device images for fast drawing
Claus Gittinger <cg@exept.de>
parents:
446
diff
changeset
|
475 |
|
569 | 476 |
imageOnDevice:anImage |
846 | 477 |
"associate image to device and clear pixel mask (in case of realized); |
569 | 478 |
returns the new image. |
479 |
" |
|
480 |
|img| |
|
448
7f9f3531660c
cache device images for fast drawing
Claus Gittinger <cg@exept.de>
parents:
446
diff
changeset
|
481 |
|
846 | 482 |
img := anImage. |
1070
856d037fe133
care for non-existing images.
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
483 |
img notNil ifTrue:[ |
856d037fe133
care for non-existing images.
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
484 |
img device ~~ device ifTrue:[ |
856d037fe133
care for non-existing images.
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
485 |
img := img copy. |
856d037fe133
care for non-existing images.
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
486 |
]. |
856d037fe133
care for non-existing images.
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
487 |
img := img on:device. |
856d037fe133
care for non-existing images.
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
488 |
img := img clearMaskedPixels. |
569 | 489 |
]. |
1070
856d037fe133
care for non-existing images.
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
490 |
^ img |
846 | 491 |
|
1070
856d037fe133
care for non-existing images.
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
492 |
"Modified: / 12.8.1998 / 12:46:38 / cg" |
448
7f9f3531660c
cache device images for fast drawing
Claus Gittinger <cg@exept.de>
parents:
446
diff
changeset
|
493 |
! |
7f9f3531660c
cache device images for fast drawing
Claus Gittinger <cg@exept.de>
parents:
446
diff
changeset
|
494 |
|
7f9f3531660c
cache device images for fast drawing
Claus Gittinger <cg@exept.de>
parents:
446
diff
changeset
|
495 |
imageOpened |
1278 | 496 |
"return the value of the instance variable 'imageOpened'. |
497 |
Thats the (default) bitmap image shown for opened folders |
|
498 |
(initialized to an open file-directory bitmap)" |
|
448
7f9f3531660c
cache device images for fast drawing
Claus Gittinger <cg@exept.de>
parents:
446
diff
changeset
|
499 |
|
7f9f3531660c
cache device images for fast drawing
Claus Gittinger <cg@exept.de>
parents:
446
diff
changeset
|
500 |
^ imageOpened |
7f9f3531660c
cache device images for fast drawing
Claus Gittinger <cg@exept.de>
parents:
446
diff
changeset
|
501 |
|
7f9f3531660c
cache device images for fast drawing
Claus Gittinger <cg@exept.de>
parents:
446
diff
changeset
|
502 |
"Created: 3.7.1997 / 12:34:28 / cg" |
471 | 503 |
! ! |
504 |
||
1275 | 505 |
!SelectionInTreeView methodsFor:'accessing-look'! |
506 |
||
507 |
showDirectoryIndicator |
|
508 |
"returns true if directories has an open/closed indicator |
|
509 |
" |
|
510 |
^ showDirectoryIndicator |
|
511 |
! |
|
512 |
||
513 |
showDirectoryIndicator:aState |
|
514 |
"set or clear open/closed indicator for directories |
|
515 |
" |
|
516 |
"show or hide lines |
|
517 |
" |
|
518 |
aState ~~ showDirectoryIndicator ifTrue:[ |
|
519 |
showDirectoryIndicator := aState. |
|
520 |
self recomputeDirectoryIndicator. |
|
521 |
self invalidate |
|
522 |
]. |
|
523 |
! |
|
524 |
||
525 |
showDirectoryIndicatorForRoot |
|
526 |
"returns true if root directory has an open/closed indicator if |
|
527 |
the common showDirectoryIndicator is enabled |
|
528 |
" |
|
529 |
^ showDirectoryIndicatorForRoot |
|
530 |
! |
|
531 |
||
532 |
showDirectoryIndicatorForRoot:aState |
|
533 |
"true if root directory has an open/closed indicator if |
|
534 |
the common showDirectoryIndicator is enabled |
|
535 |
" |
|
536 |
aState ~~ showDirectoryIndicatorForRoot ifTrue:[ |
|
537 |
showDirectoryIndicatorForRoot := aState. |
|
538 |
self recomputeDirectoryIndicator. |
|
539 |
self invalidate |
|
540 |
]. |
|
541 |
! |
|
542 |
||
543 |
showLines |
|
544 |
"returns true if lines are shown |
|
545 |
" |
|
546 |
^ showLines |
|
547 |
! |
|
548 |
||
549 |
showLines:aState |
|
550 |
"show or hide lines |
|
551 |
" |
|
552 |
aState ~~ showLines ifTrue:[ |
|
553 |
showLines := aState. |
|
554 |
self invalidate |
|
555 |
]. |
|
556 |
! |
|
557 |
||
558 |
showRoot |
|
559 |
"list with or without root |
|
560 |
" |
|
561 |
^ showRoot |
|
562 |
! |
|
563 |
||
564 |
showRoot:aState |
|
565 |
"list with or without root |
|
566 |
" |
|
567 |
showRoot ~~ aState ifTrue:[ |
|
568 |
model showRoot:(showRoot := aState). |
|
569 |
]. |
|
570 |
! ! |
|
571 |
||
514 | 572 |
!SelectionInTreeView methodsFor:'change & update'! |
573 |
||
855 | 574 |
modelChanged:what with:aPara |
575 |
"hierarchical list changed |
|
576 |
" |
|
577 |
|start size visLn h y0 y1 cY parent pvLv ndLv| |
|
578 |
||
579 |
aPara isNil ifTrue:[ |
|
580 |
what == #list ifTrue:[ self getListFromModel ] |
|
581 |
ifFalse:[ super update:what with:aPara from:model ]. |
|
582 |
^ self |
|
583 |
]. |
|
584 |
||
585 |
(what == #insertCollection: or:[what == #removeFrom:]) ifFalse:[ |
|
586 |
what == #at: ifTrue:[ ^ self redrawLine:aPara ]. |
|
587 |
what == #replace ifTrue:[ ^ self invalidateRepairNow:true ]. |
|
588 |
||
589 |
^ super update:what with:aPara from:model. |
|
590 |
]. |
|
591 |
list := self listFromModel. |
|
592 |
||
593 |
shown ifFalse:[ |
|
594 |
^ self contentsChanged |
|
595 |
]. |
|
596 |
(self sensor notNil and: [self sensor hasExposeEventFor:self]) ifTrue:[ "/ outstanding expose events |
|
597 |
self invalidateRepairNow:true. |
|
598 |
^ self contentsChanged |
|
599 |
]. |
|
600 |
||
601 |
start := aPara at:1. |
|
602 |
size := aPara at:2. |
|
603 |
parent := aPara at:3. |
|
604 |
||
860 | 605 |
what == #removeFrom: ifTrue:[ |
606 |
size := size - start + 1 |
|
607 |
]. |
|
608 |
||
855 | 609 |
start > 1 ifTrue:[ |
610 |
pvLv := (list at:start - 1) level. |
|
611 |
ndLv := parent level + 1. |
|
612 |
||
613 |
ndLv < pvLv ifTrue:[ |
|
614 |
what == #insertCollection: ifTrue:[ |
|
615 |
visLn := start + size. |
|
616 |
] ifFalse:[ |
|
617 |
visLn := start. |
|
618 |
]. |
|
619 |
||
620 |
(visLn > list size or:[(list at:visLn) level ~~ ndLv]) ifTrue:[ |
|
621 |
[(start := start - 1) ~~ 1] whileTrue:[ |
|
622 |
(list at:start) level <= ndLv ifTrue:[ |
|
623 |
self redrawFromLine:start. |
|
624 |
^ self contentsChanged. |
|
625 |
] |
|
626 |
]. |
|
627 |
self invalidateRepairNow:true. |
|
628 |
^ self contentsChanged |
|
629 |
] |
|
630 |
]. |
|
631 |
self redrawIconAndIndicatorAt:(start - 1) |
|
632 |
]. |
|
633 |
(visLn := self listLineToVisibleLine:start) isNil ifTrue:[ |
|
634 |
^ self contentsChanged |
|
635 |
]. |
|
636 |
||
637 |
h := size * fontHeight. |
|
638 |
y0 := self yOfVisibleLine:visLn. |
|
639 |
y1 := y0 + h. |
|
640 |
cY := height - y1 - 1. |
|
641 |
||
642 |
cY < 40 ifTrue:[ |
|
643 |
self redrawFromLine:start. |
|
644 |
] ifFalse:[ |
|
645 |
self catchExpose. |
|
646 |
||
647 |
what == #insertCollection: ifTrue:[ |
|
648 |
self copyFrom:self x:0 y:y0 toX:0 y:y1 width:width height:cY async:true. |
|
649 |
] ifFalse:[ |
|
650 |
self copyFrom:self x:0 y:y1 toX:0 y:y0 width:width height:cY async:true. |
|
651 |
y0 := y0 + cY. |
|
652 |
h := height - y0. |
|
653 |
]. |
|
654 |
self redrawX:0 y:y0 width:width height:h. |
|
655 |
self waitForExpose. |
|
656 |
]. |
|
657 |
device flush. |
|
658 |
self contentsChanged. |
|
659 |
! |
|
660 |
||
514 | 661 |
update:something with:aParameter from:aModel |
662 |
"one of my models changed its value |
|
785 | 663 |
" |
664 |
|idx| |
|
665 |
||
514 | 666 |
aModel == rootHolder ifTrue:[ |
667 |
^ self rootFromModel |
|
668 |
]. |
|
855 | 669 |
|
514 | 670 |
aModel == selectionHolder ifTrue:[ |
763
dd29c58e8ea6
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
760
diff
changeset
|
671 |
^ self selectionFromModel |
514 | 672 |
]. |
673 |
||
763
dd29c58e8ea6
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
760
diff
changeset
|
674 |
aModel == model ifTrue:[ |
855 | 675 |
^ self modelChanged:something with:aParameter |
676 |
]. |
|
677 |
||
678 |
(aModel isKindOf:TreeItem) ifTrue:[ |
|
679 |
(something == #size or:[something == #children]) ifTrue:[ |
|
680 |
model recomputeList. |
|
681 |
^ self |
|
682 |
]. |
|
683 |
||
684 |
(idx := self indexOfNode:aModel) ~~ 0 ifTrue:[ |
|
685 |
something == #value ifTrue:[ |
|
686 |
^ self redrawLine:idx. |
|
785 | 687 |
]. |
811 | 688 |
|
855 | 689 |
something == #indication ifTrue:[ |
690 |
^ self redrawIndicatorLine:idx. |
|
811 | 691 |
]. |
1308 | 692 |
"/ assume that the nodes string has changed |
693 |
^ self redrawLine:idx. |
|
855 | 694 |
]. |
695 |
^ self |
|
763
dd29c58e8ea6
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
760
diff
changeset
|
696 |
]. |
855 | 697 |
super update:something with:aParameter from:aModel. |
811 | 698 |
|
514 | 699 |
! ! |
700 |
||
444 | 701 |
!SelectionInTreeView methodsFor:'drawing'! |
702 |
||
481 | 703 |
drawLine:line atX:atX inVisible:visLineNr with:fg and:bg |
704 |
self drawFromVisibleLine:visLineNr to:visLineNr with:fg and:bg |
|
444 | 705 |
|
706 |
! |
|
707 |
||
708 |
drawLine:line fromX:x inVisible:visLineNr with:fg and:bg |
|
481 | 709 |
self drawFromVisibleLine:visLineNr to:visLineNr with:fg and:bg |
444 | 710 |
|
711 |
! |
|
712 |
||
713 |
drawLine:line inVisible:visLineNr with:fg and:bg |
|
481 | 714 |
self drawFromVisibleLine:visLineNr to:visLineNr with:fg and:bg |
444 | 715 |
|
716 |
! |
|
717 |
||
718 |
drawVisibleLine:visLineNr col:col with:fg and:bg |
|
481 | 719 |
self drawFromVisibleLine:visLineNr to:visLineNr with:fg and:bg |
444 | 720 |
|
721 |
! |
|
722 |
||
723 |
drawVisibleLine:visLineNr from:startCol to:endCol with:fg and:bg |
|
481 | 724 |
self drawFromVisibleLine:visLineNr to:visLineNr with:fg and:bg |
725 |
||
444 | 726 |
! |
727 |
||
728 |
drawVisibleLine:visLineNr from:startCol with:fg and:bg |
|
481 | 729 |
self drawFromVisibleLine:visLineNr to:visLineNr with:fg and:bg |
444 | 730 |
|
846 | 731 |
! |
732 |
||
733 |
redrawFromVisibleLine:startVisLineNr to:endVisLineNr |
|
734 |
self redrawX:0 |
|
735 |
y:(self yOfVisibleLine:startVisLineNr) |
|
736 |
width:width |
|
737 |
height:(endVisLineNr - startVisLineNr + 1 * fontHeight) |
|
738 |
||
739 |
||
848 | 740 |
! |
444 | 741 |
|
848 | 742 |
redrawIconAndIndicatorAt:aLnNr |
743 |
|visLineNr x0 x1 lv| |
|
481 | 744 |
|
769 | 745 |
shown ifTrue:[ |
848 | 746 |
visLineNr := self listLineToVisibleLine:aLnNr. |
747 |
visLineNr notNil ifTrue:[ |
|
748 |
lv := (listOfNodes at:aLnNr) level. |
|
749 |
x1 := (imageWidth + (self xOfFigureLevel:lv)) min:width. |
|
750 |
x0 := (self xOfFigureLevel:(lv - 1)) max:0. |
|
769 | 751 |
|
848 | 752 |
(x0 > width or:[x1 < 0]) ifFalse:[ |
753 |
self redrawX:x0 |
|
754 |
y:(self yOfVisibleLine:visLineNr) |
|
755 |
width:(x1 - x0) |
|
756 |
height:fontHeight |
|
757 |
] |
|
769 | 758 |
] |
848 | 759 |
]. |
769 | 760 |
! |
761 |
||
811 | 762 |
redrawIndicatorLine:aLineNr |
763 |
"redraw the directory indicator for a line |
|
764 |
" |
|
765 |
|node ext img visLn |
|
766 |
x "{ Class:SmallInteger }" |
|
767 |
y "{ Class:SmallInteger }" |
|
768 |
dX "{ Class:SmallInteger }" |
|
769 |
| |
|
770 |
||
771 |
( shown |
|
772 |
and:[showDirectoryIndicator |
|
773 |
and:[(visLn := self listLineToVisibleLine:aLineNr) notNil]] |
|
774 |
) ifFalse:[ |
|
775 |
^ self |
|
776 |
]. |
|
777 |
||
778 |
node := listOfNodes at:aLineNr. |
|
779 |
||
846 | 780 |
(node parent notNil or:[showDirectoryIndicatorForRoot]) ifFalse:[ |
811 | 781 |
^ self |
782 |
]. |
|
783 |
||
846 | 784 |
x := imageWidth // 2. |
785 |
x := x + (self xOfFigureLevel:(node level - 1)). |
|
811 | 786 |
|
787 |
"/ draw directory indicator |
|
788 |
||
789 |
img := node isCollapsable ifTrue:[openIndicator] ifFalse:[closeIndicator]. |
|
790 |
ext := img extent // 2. |
|
791 |
dX := ext x. |
|
792 |
||
793 |
(x + dX > 0 and:[(x := x - dX) < (width - margin)]) ifTrue:[ |
|
794 |
(self isInSelection:aLineNr) ifTrue:[ self paint:hilightFgColor on:hilightBgColor ] |
|
795 |
ifFalse:[ self paint:fgColor on:bgColor ]. |
|
796 |
||
797 |
y := (self yOfVisibleLine:visLn) + (fontHeight // 2) - 1. |
|
798 |
self displayForm:img x:x y:(y - ext y) |
|
799 |
]. |
|
800 |
||
801 |
||
802 |
||
900 | 803 |
! |
804 |
||
805 |
redrawVisibleLine:visLineNr |
|
806 |
self drawFromVisibleLine:visLineNr to:visLineNr with:fgColor and:bgColor |
|
807 |
! |
|
808 |
||
809 |
redrawVisibleLine:visLineNr from:startCol to:endCol |
|
810 |
self drawFromVisibleLine:visLineNr to:visLineNr with:fgColor and:bgColor |
|
848 | 811 |
! ! |
812 |
||
813 |
!SelectionInTreeView methodsFor:'drawing basics'! |
|
814 |
||
900 | 815 |
drawFromVisibleLine:startVisLineNr to:endVisLineNr with:fg and:bg |
816 |
"redraw a visible line range with clearing the background |
|
848 | 817 |
" |
900 | 818 |
|y h| |
848 | 819 |
|
900 | 820 |
y := self yOfVisibleLine:startVisLineNr. |
821 |
h := endVisLineNr - startVisLineNr + 1 * fontHeight. |
|
822 |
||
823 |
y + h > height ifTrue:[ |
|
824 |
h := height - y |
|
825 |
]. |
|
826 |
self redrawX:0 y:y width:width height:h. |
|
848 | 827 |
! |
828 |
||
829 |
drawVHLinesX:x0 y:y0 toX:x1 start:start stop:stop |
|
830 |
"redraw from line to line without clearing the background |
|
831 |
" |
|
832 |
|node prevNode parent p1 p2 showVLines showHLine lv nxtPrnt |
|
1305
c8f2fe1fac85
fix drawing horizontal lines for the root element(s)
Claus Gittinger <cg@exept.de>
parents:
1278
diff
changeset
|
833 |
showRootNot isFirst |
848 | 834 |
|
835 |
x "{ Class:SmallInteger }" |
|
836 |
y "{ Class:SmallInteger }" |
|
837 |
||
838 |
yTop "{ Class:SmallInteger }" |
|
839 |
yBot "{ Class:SmallInteger }" |
|
840 |
yCtr "{ Class:SmallInteger }" |
|
841 |
||
842 |
begHLnY "{ Class:SmallInteger }" |
|
843 |
begHLnX "{ Class:SmallInteger }" |
|
844 |
endHLnX "{ Class:SmallInteger }" |
|
845 |
||
846 |
widthLvl "{ Class:SmallInteger }" |
|
847 |
offsHLnX "{ Class:SmallInteger }" |
|
848 |
||
849 |
level "{ Class:SmallInteger }" |
|
855 | 850 |
startLvI "{ Class:SmallInteger }" |
851 |
startLvX "{ Class:SmallInteger }" |
|
852 |
limitLvI "{ Class:SmallInteger }" |
|
853 |
limitLvX "{ Class:SmallInteger }" |
|
848 | 854 |
| |
1305
c8f2fe1fac85
fix drawing horizontal lines for the root element(s)
Claus Gittinger <cg@exept.de>
parents:
1278
diff
changeset
|
855 |
|
848 | 856 |
yBot := y0. |
857 |
yCtr := yBot - (fontHeight // 2). |
|
858 |
widthLvl := imageInset + imageWidth. |
|
859 |
offsHLnX := imageWidth // 2 + (self xOfFigureLevel:-1). |
|
860 |
||
861 |
parent := 4711. "/ to force a recompute |
|
862 |
prevNode := 4711. "/ to force a recomputation of the level |
|
863 |
||
864 |
self setMaskOrigin:(self viewOrigin + (0 @ 1) \\ (lineMask extent)). |
|
865 |
self paint:lineColor on:bgColor. |
|
866 |
self mask:lineMask. |
|
867 |
begHLnY := y0. |
|
855 | 868 |
startLvI := self smallestLevelOfNodesBetween:start and:stop. |
869 |
startLvX := self xOfFigureLevel:startLvI. |
|
870 |
limitLvI := drawVLinesFromLevel + 1. |
|
871 |
limitLvX := limitLvI * widthLvl + offsHLnX. |
|
848 | 872 |
|
873 |
buildInArray atAllPut:0. |
|
874 |
||
875 |
start == 1 ifTrue:[ |
|
876 |
begHLnY := yCtr + fontHeight. |
|
877 |
]. |
|
1305
c8f2fe1fac85
fix drawing horizontal lines for the root element(s)
Claus Gittinger <cg@exept.de>
parents:
1278
diff
changeset
|
878 |
showRootNot := showRoot not. |
848 | 879 |
|
880 |
start to:stop do:[:anIndex| |
|
881 |
node := listOfNodes at:anIndex. |
|
882 |
yTop := yBot - 1. |
|
883 |
yBot := yBot + fontHeight. |
|
884 |
yCtr := yCtr + fontHeight. |
|
885 |
||
886 |
(nxtPrnt := node parent) ~~ parent ifTrue:[ |
|
887 |
parent := nxtPrnt. |
|
888 |
||
889 |
prevNode == parent ifTrue:[ |
|
890 |
level := level + 1. |
|
891 |
begHLnX := endHLnX. |
|
892 |
] ifFalse:[ |
|
893 |
level := node level. |
|
1309 | 894 |
begHLnX := level * widthLvl + offsHLnX. |
848 | 895 |
]. |
896 |
||
1305
c8f2fe1fac85
fix drawing horizontal lines for the root element(s)
Claus Gittinger <cg@exept.de>
parents:
1278
diff
changeset
|
897 |
isFirst := parent isNil or:[(showRootNot and:[level == 2])]. |
c8f2fe1fac85
fix drawing horizontal lines for the root element(s)
Claus Gittinger <cg@exept.de>
parents:
1278
diff
changeset
|
898 |
endHLnX := begHLnX + widthLvl. |
855 | 899 |
showVLines := begHLnX >= x0 and:[level > drawVLinesFromLevel]. |
1305
c8f2fe1fac85
fix drawing horizontal lines for the root element(s)
Claus Gittinger <cg@exept.de>
parents:
1278
diff
changeset
|
900 |
showHLine := x0 < endHLnX and:[x1 > begHLnX]. |
c8f2fe1fac85
fix drawing horizontal lines for the root element(s)
Claus Gittinger <cg@exept.de>
parents:
1278
diff
changeset
|
901 |
|
c8f2fe1fac85
fix drawing horizontal lines for the root element(s)
Claus Gittinger <cg@exept.de>
parents:
1278
diff
changeset
|
902 |
(showHLine and:[isFirst]) ifTrue:[ |
c8f2fe1fac85
fix drawing horizontal lines for the root element(s)
Claus Gittinger <cg@exept.de>
parents:
1278
diff
changeset
|
903 |
showHLine := showDirectoryIndicatorForRoot and:[showDirectoryIndicator] |
c8f2fe1fac85
fix drawing horizontal lines for the root element(s)
Claus Gittinger <cg@exept.de>
parents:
1278
diff
changeset
|
904 |
] |
848 | 905 |
]. |
906 |
||
907 |
showHLine ifTrue:[ |
|
908 |
self displayLineFromX:begHLnX y:yCtr toX:endHLnX y:yCtr |
|
909 |
]. |
|
910 |
||
911 |
showVLines ifTrue:[ |
|
912 |
y := (parent basicLastChild == node) ifTrue:[yCtr] ifFalse:[yBot]. |
|
913 |
x := begHLnX. |
|
914 |
p2 := parent. |
|
915 |
lv := level - 1. |
|
916 |
self displayLineFromX:x y:begHLnY toX:x y:y. |
|
917 |
||
855 | 918 |
[((p1 := p2 parent) notNil and:[(x := x - widthLvl) >= limitLvX])] whileTrue:[ |
848 | 919 |
(p1 basicLastChild ~~ p2 and:[x <= x1]) ifTrue:[ |
855 | 920 |
x >= startLvX ifTrue:[ |
848 | 921 |
self displayLineFromX:x y:yTop toX:x y:yBot |
922 |
] ifFalse:[ |
|
923 |
buildInArray at:lv put:yBot |
|
924 |
]. |
|
925 |
]. |
|
926 |
lv := lv - 1. |
|
927 |
p2 := p1 |
|
928 |
] |
|
929 |
]. |
|
930 |
prevNode := node. |
|
931 |
begHLnY := yCtr. |
|
932 |
]. |
|
933 |
||
855 | 934 |
"/ |
935 |
"/ draw outstanding verical lines to left |
|
936 |
"/ |
|
937 |
x := limitLvX. |
|
938 |
y := (start ~~ 1) ifTrue:[y0] ifFalse:[y0 + (fontHeight // 2)]. |
|
848 | 939 |
|
855 | 940 |
limitLvI to:startLvI do:[:i| |
941 |
(yBot := buildInArray at:i) ~~ 0 ifTrue:[ |
|
942 |
self displayLineFromX:x y:y toX:x y:yBot |
|
943 |
]. |
|
944 |
x := x + widthLvl. |
|
848 | 945 |
]. |
946 |
self mask:nil. |
|
947 |
||
811 | 948 |
! |
949 |
||
900 | 950 |
drawVisibleLineSelected:visLineNr with:fg and:bg |
951 |
"redraw a single line as selected." |
|
952 |
||
953 |
(self visibleLineToListLine:visLineNr) isNil ifTrue:[ |
|
954 |
^ super drawVisibleLine:visLineNr with:fg and:bg |
|
955 |
]. |
|
956 |
self redrawX:0 |
|
957 |
y:(self yOfVisibleLine:visLineNr) |
|
958 |
width:width |
|
959 |
height:fontHeight |
|
960 |
! |
|
961 |
||
902 | 962 |
redrawElement:anIndex |
963 |
||
964 |
|vln x0 xT y| |
|
965 |
||
966 |
shown ifTrue:[ |
|
967 |
( highlightMode ~~ #label |
|
908 | 968 |
or:[(vln := self listLineToVisibleLine:anIndex) isNil |
969 |
or:[anIndex > listOfNodes size]] |
|
902 | 970 |
) ifTrue:[ |
971 |
super redrawElement:anIndex |
|
972 |
] ifFalse:[ |
|
973 |
y := self yOfVisibleLine:vln. |
|
974 |
xT := self xOfStringLevel:((listOfNodes at:anIndex) level). |
|
975 |
x0 := xT - textInset. |
|
976 |
self paint:bgColor. |
|
977 |
self fillRectangleX:x0 y:y width:(width - x0) height:fontHeight. |
|
978 |
self redrawLabelAt:xT y:y index:anIndex |
|
979 |
] |
|
980 |
] |
|
981 |
||
982 |
! |
|
983 |
||
900 | 984 |
redrawLabelAt:x y:yTop index:anIndex |
1171 | 985 |
|isSel y0 x0 w label node value xV wV| |
986 |
||
987 |
node := listOfNodes at:anIndex. |
|
988 |
label := node name. |
|
989 |
isSel := self isInSelection:anIndex. |
|
990 |
xV := 0. |
|
991 |
wV := 0. |
|
992 |
y0 := yTop + (fontHeight // 2) + labelOffsetY. |
|
993 |
||
994 |
(value := node printableEditValue) notNil ifTrue:[ |
|
995 |
xV := (self xOfValueNode:node) - SelectionInset |
|
996 |
]. |
|
900 | 997 |
|
998 |
highlightMode == #label ifTrue:[ |
|
999 |
x0 := x + 4. |
|
1000 |
||
1171 | 1001 |
isSel ifTrue:[ |
900 | 1002 |
w := (label notNil ifTrue:[label widthOn:self] ifFalse:[60]) + 8. |
1003 |
self paint:hilightBgColor. |
|
1004 |
self fillRectangleX:x y:yTop width:w height:fontHeight. |
|
1171 | 1005 |
|
1006 |
(value notNil and:[(editorWidget isNil or:[editorIndex ~~ anIndex])]) ifTrue:[ |
|
1007 |
wV := SelectionInset + SelectionInset + (value widthOn:self). |
|
1008 |
self fillRectangleX:xV y:yTop width:wV height:fontHeight. |
|
1009 |
] |
|
900 | 1010 |
] |
1011 |
] ifFalse:[ |
|
1012 |
x0 := x |
|
1013 |
]. |
|
1014 |
||
1015 |
label notNil ifTrue:[ |
|
1171 | 1016 |
isSel ifTrue:[self paint:hilightFgColor on:hilightBgColor] |
1017 |
ifFalse:[self paint:fgColor on:bgColor]. |
|
1018 |
||
1019 |
self displayOpaqueString:label x:x0 y:y0. |
|
1020 |
||
1021 |
value notNil ifTrue:[ |
|
1175 | 1022 |
isSel ifFalse:[ |
1023 |
self paint:editValueFgColor on:bgColor |
|
1024 |
]. |
|
1171 | 1025 |
self displayOpaqueString:value x:(xV + SelectionInset) y:y0 |
1026 |
]. |
|
1027 |
||
900 | 1028 |
]. |
1029 |
||
1171 | 1030 |
(isSel and:[highlightMode == #label]) ifTrue:[ |
1031 |
self redrawSelFrameAtX:x y:yTop toX:(x + w). |
|
1032 |
||
1033 |
wV ~~ 0 ifTrue:[ |
|
1034 |
self redrawSelFrameAtX:xV y:yTop toX:(xV + wV) |
|
1035 |
] |
|
900 | 1036 |
]. |
1037 |
||
1171 | 1038 |
|
900 | 1039 |
! |
1040 |
||
769 | 1041 |
redrawLinesX:x0 y:y0 toX:x1 start:start stop:stop |
1042 |
"redraw from line to line without clearing the background |
|
1043 |
" |
|
848 | 1044 |
|node prevNode parent icon showIndc showIcon showText nxtPrnt |
846 | 1045 |
|
1046 |
end "{ Class:SmallInteger }" |
|
1047 |
||
1048 |
yBot "{ Class:SmallInteger }" |
|
1049 |
yCtr "{ Class:SmallInteger }" |
|
1050 |
||
848 | 1051 |
xIndc "{ Class:SmallInteger }" |
846 | 1052 |
xIcon "{ Class:SmallInteger }" |
1053 |
xText "{ Class:SmallInteger }" |
|
1054 |
||
1055 |
widthLvl "{ Class:SmallInteger }" |
|
1056 |
insetTxt "{ Class:SmallInteger }" |
|
848 | 1057 |
|
1058 |
offIndcX "{ Class:SmallInteger }" |
|
1059 |
offIndcY "{ Class:SmallInteger }" |
|
1060 |
offIconX "{ Class:SmallInteger }" |
|
769 | 1061 |
| |
848 | 1062 |
(end := stop min:(listOfNodes size)) < start ifTrue:[ |
1063 |
^ self |
|
1064 |
]. |
|
846 | 1065 |
yBot := y0. |
1066 |
yCtr := yBot - (fontHeight // 2). |
|
1067 |
widthLvl := imageInset + imageWidth. |
|
1068 |
insetTxt := imageWidth + textInset. |
|
848 | 1069 |
offIconX := self xOfFigureLevel:0. |
1070 |
showIndc := false. |
|
846 | 1071 |
|
1072 |
showDirectoryIndicator ifTrue:[ |
|
1072
1888703adc18
care for non-existing open/close indicators.
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
1073 |
offIndcX := imageWidth // 2 - widthLvl. |
1888703adc18
care for non-existing open/close indicators.
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
1074 |
offIndcY := 0. |
1888703adc18
care for non-existing open/close indicators.
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
1075 |
openIndicator notNil ifTrue:[ |
1888703adc18
care for non-existing open/close indicators.
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
1076 |
icon := openIndicator extent // 2. |
1888703adc18
care for non-existing open/close indicators.
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
1077 |
offIndcX := offIndcX - icon x. |
1888703adc18
care for non-existing open/close indicators.
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
1078 |
offIndcY := icon y. |
1888703adc18
care for non-existing open/close indicators.
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
1079 |
] |
846 | 1080 |
]. |
785 | 1081 |
|
1082 |
showLines ifTrue:[ |
|
848 | 1083 |
self drawVHLinesX:x0 y:y0 toX:x1 start:start stop:end |
785 | 1084 |
]. |
485 | 1085 |
|
846 | 1086 |
parent := 4711. "/ to force a recompute |
1087 |
prevNode := 4711. "/ to force a recomputation of the level |
|
1088 |
||
1089 |
start to:end do:[:anIndex| |
|
1090 |
node := listOfNodes at:anIndex. |
|
1091 |
yBot := yBot + fontHeight. |
|
494 | 1092 |
yCtr := yCtr + fontHeight. |
485 | 1093 |
|
848 | 1094 |
(nxtPrnt := node parent) ~~ parent ifTrue:[ |
1095 |
parent := nxtPrnt. |
|
1096 |
xIcon := prevNode == parent ifTrue:[xIcon + widthLvl] |
|
1097 |
ifFalse:[node level * widthLvl + offIconX]. |
|
481 | 1098 |
|
848 | 1099 |
xText := xIcon + insetTxt. |
1100 |
showIcon := xIcon < x1 and:[xText > x0]. |
|
1101 |
showText := xText < x1. |
|
769 | 1102 |
|
848 | 1103 |
showDirectoryIndicator ifTrue:[ |
1104 |
xIndc := xIcon + offIndcX. |
|
481 | 1105 |
|
848 | 1106 |
showIndc := ( (parent notNil or:[showDirectoryIndicatorForRoot]) |
1107 |
and:[(xIcon > x0 and:[xIndc < x1])] |
|
1108 |
) |
|
1109 |
] |
|
785 | 1110 |
]. |
481 | 1111 |
|
846 | 1112 |
(showIcon and:[(icon := self figureFor:node) notNil]) ifTrue:[ |
1113 |
self displayForm:icon x:xIcon y:(yCtr - (icon height // 2)) |
|
770 | 1114 |
]. |
848 | 1115 |
|
846 | 1116 |
showText ifTrue:[ |
900 | 1117 |
self redrawLabelAt:xText y:(yBot - fontHeight) index:anIndex |
485 | 1118 |
]. |
848 | 1119 |
(showIndc and:[node showIndicator]) ifTrue:[ |
846 | 1120 |
icon := node isCollapsable ifTrue:[openIndicator] ifFalse:[closeIndicator]. |
1091
2e86163cfb17
care for non-existing icon image
Claus Gittinger <cg@exept.de>
parents:
1072
diff
changeset
|
1121 |
icon notNil ifTrue:[ |
2e86163cfb17
care for non-existing icon image
Claus Gittinger <cg@exept.de>
parents:
1072
diff
changeset
|
1122 |
self displayForm:icon x:xIndc y:(yCtr - offIndcY) |
2e86163cfb17
care for non-existing icon image
Claus Gittinger <cg@exept.de>
parents:
1072
diff
changeset
|
1123 |
] |
846 | 1124 |
]. |
1125 |
prevNode := node. |
|
769 | 1126 |
] |
1072
1888703adc18
care for non-existing open/close indicators.
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
1127 |
|
1091
2e86163cfb17
care for non-existing icon image
Claus Gittinger <cg@exept.de>
parents:
1072
diff
changeset
|
1128 |
"Modified: / 22.8.1998 / 12:56:50 / cg" |
792 | 1129 |
! |
1130 |
||
900 | 1131 |
redrawSelFrameAtX:x0 y:y0 toX:x1 |
1132 |
"redraw selection frame for a line |
|
792 | 1133 |
" |
900 | 1134 |
| |
792 | 1135 |
w "{ Class: SmallInteger }" |
1136 |
y "{ Class: SmallInteger }" |
|
1137 |
x "{ Class: SmallInteger }" |
|
1138 |
| |
|
1139 |
||
1140 |
hilightFrameColor notNil ifTrue:[ |
|
1141 |
hilightLevel == 0 ifTrue:[ |
|
1142 |
self paint:hilightFrameColor. |
|
1105
c79bb5824b74
draw closed frames around selections if highlightMode ~~ #line
tz
parents:
1091
diff
changeset
|
1143 |
highlightMode == #line ifTrue:[ |
c79bb5824b74
draw closed frames around selections if highlightMode ~~ #line
tz
parents:
1091
diff
changeset
|
1144 |
self displayLineFromX:x0 y:y0 toX:x1 y:y0. |
c79bb5824b74
draw closed frames around selections if highlightMode ~~ #line
tz
parents:
1091
diff
changeset
|
1145 |
y := y0 + fontHeight - 1. |
c79bb5824b74
draw closed frames around selections if highlightMode ~~ #line
tz
parents:
1091
diff
changeset
|
1146 |
^self displayLineFromX:x0 y:y toX:x1 y:y. |
c79bb5824b74
draw closed frames around selections if highlightMode ~~ #line
tz
parents:
1091
diff
changeset
|
1147 |
] ifFalse:[ |
c79bb5824b74
draw closed frames around selections if highlightMode ~~ #line
tz
parents:
1091
diff
changeset
|
1148 |
^self displayRectangleX:x0 y:y0 width:x1 - x0 height:fontHeight |
c79bb5824b74
draw closed frames around selections if highlightMode ~~ #line
tz
parents:
1091
diff
changeset
|
1149 |
] |
792 | 1150 |
] |
1151 |
] ifFalse:[ |
|
1152 |
hilightStyle == #motif ifTrue:[ |
|
1153 |
self paint:bgColor. |
|
900 | 1154 |
y := y0 + 1. |
1105
c79bb5824b74
draw closed frames around selections if highlightMode ~~ #line
tz
parents:
1091
diff
changeset
|
1155 |
highlightMode == #line ifTrue:[ |
c79bb5824b74
draw closed frames around selections if highlightMode ~~ #line
tz
parents:
1091
diff
changeset
|
1156 |
self displayLineFromX:x0 y:y toX:x1 y:y. |
c79bb5824b74
draw closed frames around selections if highlightMode ~~ #line
tz
parents:
1091
diff
changeset
|
1157 |
y := y0 + fontHeight - 2. |
c79bb5824b74
draw closed frames around selections if highlightMode ~~ #line
tz
parents:
1091
diff
changeset
|
1158 |
self displayLineFromX:x0 y:y toX:x1 y:y. |
c79bb5824b74
draw closed frames around selections if highlightMode ~~ #line
tz
parents:
1091
diff
changeset
|
1159 |
] ifFalse:[ |
c79bb5824b74
draw closed frames around selections if highlightMode ~~ #line
tz
parents:
1091
diff
changeset
|
1160 |
self displayRectangleX:x0 + 1 y:y width:x1 - x0 - 2 height:fontHeight - 2 |
c79bb5824b74
draw closed frames around selections if highlightMode ~~ #line
tz
parents:
1091
diff
changeset
|
1161 |
] |
792 | 1162 |
] |
1163 |
]. |
|
1164 |
||
1165 |
hilightLevel ~~ 0 ifTrue:[ |
|
1166 |
"/ draw edge |
|
1167 |
||
900 | 1168 |
highlightMode == #line ifTrue:[ |
1169 |
w := ((width - (2 * margin)) max:(self widthOfContents)) + leftOffset. |
|
1170 |
x := margin - leftOffset. |
|
1171 |
] ifFalse:[ |
|
1172 |
w := x1 - x0. |
|
1173 |
x := x0. |
|
1174 |
]. |
|
1175 |
self drawEdgesForX:x y:y0 width:w height:fontHeight level:hilightLevel. |
|
792 | 1176 |
] |
1177 |
||
1178 |
||
1179 |
||
900 | 1180 |
! |
1181 |
||
1182 |
redrawX:x y:y width:w height:h |
|
1183 |
"a region must be redrawn" |
|
1184 |
||
1185 |
|savClip startLn sel |
|
1186 |
y0 "{ Class:SmallInteger }" |
|
1187 |
y1 "{ Class:SmallInteger }" |
|
1188 |
visStart "{ Class:SmallInteger }" |
|
1189 |
visEnd "{ Class:SmallInteger }" |
|
1190 |
stopLn "{ Class:SmallInteger }" |
|
1191 |
maxY "{ Class:SmallInteger }" |
|
1192 |
maxX "{ Class:SmallInteger }" |
|
1193 |
dltLine "{ Class:SmallInteger }" |
|
1194 |
startY "{ Class:SmallInteger }"| |
|
1195 |
||
1196 |
shown ifFalse:[^ self]. |
|
1197 |
||
1198 |
visStart := self visibleLineOfY:(y + 1). |
|
1199 |
startLn := self visibleLineToAbsoluteLine:visStart. |
|
1200 |
||
1201 |
self paint:bgColor. |
|
1202 |
self fillRectangleX:x y:y width:w height:h. |
|
1203 |
startLn isNil ifTrue:[ ^ self ]. |
|
1204 |
||
1205 |
sel := nil. |
|
1206 |
maxX := x + w. |
|
1207 |
maxY := y + h. |
|
1208 |
visEnd := self visibleLineOfY:maxY. |
|
1209 |
startY := self yOfVisibleLine:visStart. |
|
1210 |
dltLine := startLn - visStart. |
|
1211 |
stopLn := dltLine + visEnd. |
|
1212 |
savClip := clipRect. |
|
1213 |
||
1214 |
self clippingRectangle:(Rectangle left:x top:y width:w height:h). |
|
1215 |
||
1216 |
(highlightMode == #line and:[self hasSelection]) ifTrue:[ |
|
1217 |
"/ redraw the background for all selected lines in the invalid range |
|
1218 |
||
1219 |
self selectionDo:[:lnNr| |
|
1220 |
(lnNr between:startLn and:stopLn) ifTrue:[ |
|
1221 |
sel isNil ifTrue:[ |
|
1222 |
sel := OrderedCollection new. |
|
1223 |
self paint:hilightBgColor. |
|
1224 |
]. |
|
1225 |
sel add:(y0 := self yOfVisibleLine:(lnNr - dltLine)). |
|
1226 |
y1 := y0 + fontHeight min:maxY. |
|
1227 |
y0 := y0 max:y. |
|
1228 |
self fillRectangleX:x y:y0 width:w height:y1 - y0. |
|
1229 |
] |
|
1230 |
] |
|
1231 |
]. |
|
1232 |
self redrawLinesX:x y:startY toX:maxX start:startLn stop:stopLn. |
|
1233 |
||
1234 |
"/ draw selection frames |
|
1235 |
sel notNil ifTrue:[ |
|
1236 |
sel do:[:y0| self redrawSelFrameAtX:x y:y0 toX:maxX] |
|
1237 |
]. |
|
1238 |
||
1239 |
self clippingRectangle:savClip. |
|
444 | 1240 |
! ! |
1241 |
||
494 | 1242 |
!SelectionInTreeView methodsFor:'enumerating'! |
490 | 1243 |
|
494 | 1244 |
detectNode:aOneArgBlock |
1245 |
"evaluate the argument, aBlock for each node in the list until |
|
1246 |
the block returns true; in this case return the node which caused |
|
1247 |
the true evaluation. If none node is detected, nil is returned. |
|
1248 |
" |
|
1249 |
^ listOfNodes detect:aOneArgBlock ifNone:nil |
|
507 | 1250 |
! |
1251 |
||
1252 |
selectedNodesDo:aOneArgBlock |
|
1253 |
"evaluate the block on each node selected |
|
1254 |
" |
|
1255 |
self selectionDo:[:i| aOneArgBlock value:(listOfNodes at:i) ] |
|
490 | 1256 |
! ! |
1257 |
||
569 | 1258 |
!SelectionInTreeView methodsFor:'event handling'! |
1259 |
||
639 | 1260 |
buttonMotion:buttonMask x:x y:y |
1261 |
"mouse-move while button was pressed - handle selection changes" |
|
1262 |
||
1263 |
discardMotionEvents ifFalse:[ |
|
1264 |
super buttonMotion:buttonMask x:x y:y |
|
1265 |
] |
|
1266 |
||
1267 |
||
1268 |
! |
|
1269 |
||
569 | 1270 |
buttonMultiPress:button x:x y:y |
1271 |
||
1272 |
(self indicatiorLineForButton:button atX:x y:y) == 0 ifTrue:[ |
|
1273 |
^ super buttonMultiPress:button x:x y:y |
|
1274 |
]. |
|
1275 |
"/ discard doubleClick on indicator |
|
1276 |
! |
|
1277 |
||
1278 |
buttonPress:button x:x y:y |
|
1171 | 1279 |
"handle button press event |
1280 |
" |
|
1268 | 1281 |
|node menu| |
1171 | 1282 |
|
1283 |
((button == 2) or:[button == #menu]) ifTrue:[ |
|
1284 |
( (node := self selectedNode) notNil |
|
1285 |
and:[(menu := node middleButtonMenu) notNil] |
|
1286 |
) ifTrue:[ |
|
1188 | 1287 |
menu isCollection ifTrue:[ |
1288 |
|appl| |
|
1289 |
||
1290 |
menu := Menu new fromLiteralArrayEncoding:menu. |
|
1291 |
||
1292 |
(appl := self application) notNil ifTrue:[ |
|
1293 |
menu findGuiResourcesIn:appl |
|
1294 |
]. |
|
1295 |
menu receiver:appl. |
|
1296 |
]. |
|
1171 | 1297 |
menu startUp |
1298 |
] ifFalse:[ |
|
1299 |
super buttonPress:button x:x y:y |
|
1300 |
] |
|
1301 |
] ifFalse:[ |
|
1302 |
self handleSelectButtonAtX:x y:y. |
|
1303 |
||
1304 |
( editorWidget isNil |
|
1305 |
and:[(node := self selectedNode) notNil |
|
1306 |
and:[node canEdit |
|
1307 |
and:[x >= (self xOfValueNode:node)]]] |
|
1308 |
) ifTrue:[ |
|
1309 |
self openEditor |
|
1310 |
] |
|
1311 |
] |
|
1312 |
! |
|
1313 |
||
1314 |
buttonRelease:button x:x y:y |
|
1315 |
"stop any autoscroll" |
|
1316 |
||
1317 |
discardMotionEvents ifTrue:[ |
|
1318 |
clickPosition := nil. |
|
1319 |
discardMotionEvents := false. |
|
1320 |
]. |
|
1321 |
super buttonRelease:button x:x y:y |
|
1322 |
||
1323 |
! |
|
1324 |
||
1325 |
doubleClicked |
|
1326 |
"handle a double click; collapse or expand selected entry |
|
1327 |
in case of having children |
|
1328 |
" |
|
1329 |
|node| |
|
1330 |
||
1331 |
(node := self selectedNode) notNil ifTrue:[ |
|
1202
b9a3beb20ca7
added an extra validateExpandability block,
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
1332 |
(validateDoubleClickBlock isNil |
b9a3beb20ca7
added an extra validateExpandability block,
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
1333 |
or:[(validateDoubleClickBlock value:node) ~~ false]) ifTrue:[ |
b9a3beb20ca7
added an extra validateExpandability block,
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
1334 |
(validateExpandabilityBlock isNil |
b9a3beb20ca7
added an extra validateExpandability block,
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
1335 |
or:[(validateExpandabilityBlock value:node) ~~ false]) ifTrue:[ |
b9a3beb20ca7
added an extra validateExpandability block,
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
1336 |
self selectedNodeExpand:(node isExpandable). |
b9a3beb20ca7
added an extra validateExpandability block,
Claus Gittinger <cg@exept.de>
parents:
1191
diff
changeset
|
1337 |
]. |
1171 | 1338 |
super doubleClicked |
1339 |
] |
|
1340 |
] |
|
1341 |
||
1342 |
! |
|
1343 |
||
1344 |
handleSelectButtonAtX:x y:y |
|
1345 |
"handle a select button click |
|
569 | 1346 |
" |
1268 | 1347 |
|node lineNr sensor isExpd| |
569 | 1348 |
|
1171 | 1349 |
lineNr := self indicatiorLineForButton:#select atX:x y:y. |
569 | 1350 |
|
1351 |
lineNr == 0 ifTrue:[ |
|
1171 | 1352 |
^ super buttonPress:#select x:x y:y |
569 | 1353 |
]. |
1354 |
node := listOfNodes at:lineNr. |
|
1355 |
||
639 | 1356 |
discardMotionEvents := true. |
569 | 1357 |
dragIsActive := false. |
1358 |
clickPosition := nil. |
|
1359 |
||
639 | 1360 |
self hasSelection ifTrue:[ |
1361 |
(selectConditionBlock isNil or:[selectConditionBlock value:lineNr]) ifTrue:[ |
|
1362 |
self selection:lineNr |
|
1363 |
] ifFalse:[ |
|
1364 |
self selection:nil |
|
569 | 1365 |
] |
1366 |
]. |
|
855 | 1367 |
|
1368 |
isExpd := node isExpandable. |
|
835 | 1369 |
|
855 | 1370 |
( supportsExpandAll |
1371 |
and:[(sensor := self sensor) notNil |
|
1372 |
and:[(sensor ctrlDown or:[sensor shiftDown])]] |
|
1373 |
) ifTrue:[ |
|
1374 |
isExpd ifTrue:[model doExpandAll:node] |
|
1375 |
ifFalse:[model doCollapseAll:node] |
|
835 | 1376 |
] ifFalse:[ |
855 | 1377 |
isExpd ifTrue:[model doExpand:node] |
1378 |
ifFalse:[model doCollapse:node]. |
|
835 | 1379 |
]. |
848 | 1380 |
|
639 | 1381 |
! |
1382 |
||
569 | 1383 |
indicatiorLineForButton:aButton atX:x y:y |
1384 |
"returns linenumber assigned to indicator at x/y or 0 |
|
1385 |
" |
|
1268 | 1386 |
|nr x0 node| |
569 | 1387 |
|
1388 |
( enabled |
|
1389 |
and:[showDirectoryIndicator |
|
1390 |
and:[aButton == 1 or:[aButton == #select]]] |
|
1391 |
) ifTrue:[ |
|
835 | 1392 |
nr := self visibleLineToListLine:(self visibleLineOfY:y). |
569 | 1393 |
|
835 | 1394 |
nr notNil ifTrue:[ |
1395 |
node := listOfNodes at:nr. |
|
1396 |
node hasChildren ifTrue:[ |
|
1397 |
x0 := self xOfFigureLevel:(node level - 1). |
|
569 | 1398 |
|
835 | 1399 |
(x > x0 and:[(x0 + imageWidth) > x and:[node children notEmpty]]) ifTrue:[ |
1400 |
^ nr |
|
569 | 1401 |
] |
1402 |
] |
|
1403 |
] |
|
1404 |
]. |
|
1405 |
^ 0 |
|
756 | 1406 |
! |
1407 |
||
835 | 1408 |
isCtrlMetaAltOrShiftPressed |
1409 |
"returns true if CTRL, META, ALT or SHIFT is pressed |
|
1410 |
" |
|
1411 |
|sensor| |
|
1412 |
||
1413 |
(sensor := self sensor) notNil ifTrue:[ |
|
1414 |
^ ( sensor ctrlDown |
|
1415 |
or:[sensor altDown |
|
1416 |
or:[sensor shiftDown |
|
1417 |
or:[sensor metaDown]]] |
|
1418 |
) |
|
1419 |
]. |
|
1420 |
^ false |
|
1421 |
! |
|
1422 |
||
756 | 1423 |
key:key select:index x:x y:y |
1424 |
"select an entry by a keyboard action. This is treated like a doubleClick |
|
1425 |
on that entry. |
|
1426 |
Add on: In case that the entry is not selectable, scroll to the entry |
|
1427 |
" |
|
1428 |
(enabled and:[keyActionStyle notNil]) ifFalse:[ |
|
1429 |
^ self |
|
1430 |
]. |
|
1431 |
||
1432 |
(selectConditionBlock isNil or:[selectConditionBlock value:index]) ifTrue:[ |
|
780 | 1433 |
^ super key:key select:index x:x y:y |
756 | 1434 |
]. |
1435 |
||
1436 |
keyActionStyle == #pass ifTrue:[ |
|
1437 |
^ self |
|
1438 |
]. |
|
1439 |
||
1440 |
self gotoLine:index |
|
785 | 1441 |
! |
1442 |
||
811 | 1443 |
keyPress:key x:x y:y |
1444 |
"handle keyboard input" |
|
1445 |
||
1446 |
<resource: #keyboard ( #CursorLeft #CursorRight ) > |
|
1447 |
||
1448 |
|idx node inc end| |
|
1449 |
||
1450 |
enabled ifFalse:[ |
|
1451 |
^ self |
|
1452 |
]. |
|
1453 |
||
1454 |
(key == #CursorLeft or:[key == #CursorRight]) ifTrue:[ |
|
1455 |
(idx := self selectedIndex) == 0 ifTrue:[ ^ self ]. |
|
1456 |
||
1457 |
(key == #CursorLeft) ifTrue:[ inc := -1. end := 0 ] |
|
1458 |
ifFalse:[ inc := 1. end := 1 + listOfNodes size ]. |
|
1459 |
||
1460 |
[(idx := idx + inc) ~~ end] whileTrue:[ |
|
1461 |
node := listOfNodes at:idx. |
|
825 | 1462 |
node hasChildren ifTrue:[ |
811 | 1463 |
^ self key:key select:idx x:x y:y |
1464 |
] |
|
1465 |
]. |
|
1466 |
^ self |
|
1467 |
]. |
|
1468 |
^ super keyPress:key x:x y:y |
|
1469 |
||
1470 |
||
1471 |
||
1472 |
||
569 | 1473 |
! ! |
1474 |
||
1328 | 1475 |
!SelectionInTreeView methodsFor:'initialize / release'! |
444 | 1476 |
|
685 | 1477 |
create |
1478 |
super create. |
|
695
3e5240577e37
dont use Image>>on: -> use Image>>onDevice:
Claus Gittinger <cg@exept.de>
parents:
685
diff
changeset
|
1479 |
lineMask := lineMask onDevice:device. |
685 | 1480 |
|
846 | 1481 |
lineColor := lineColor isNil ifTrue:[fgColor] |
1482 |
ifFalse:[lineColor onDevice:device]. |
|
1175 | 1483 |
|
1484 |
editValueFgColor := editValueFgColor onDevice:device. |
|
685 | 1485 |
! |
1486 |
||
514 | 1487 |
destroy |
1488 |
"remove dependencies |
|
1489 |
" |
|
811 | 1490 |
rootHolder removeDependent:self. |
1491 |
selectionHolder removeDependent:self. |
|
1492 |
||
1493 |
model notNil ifTrue:[ |
|
1494 |
model stopRunningTasks |
|
514 | 1495 |
]. |
1496 |
super destroy. |
|
1497 |
||
1498 |
! |
|
1499 |
||
785 | 1500 |
fetchDefaultImages |
1501 |
"returns a directory with default keys and images; could be |
|
1502 |
redefined by subclass. |
|
1503 |
" |
|
1171 | 1504 |
^ itemClass notNil ifTrue:[itemClass keysAndIcons] |
1505 |
ifFalse:[nil] |
|
785 | 1506 |
! |
1507 |
||
448
7f9f3531660c
cache device images for fast drawing
Claus Gittinger <cg@exept.de>
parents:
446
diff
changeset
|
1508 |
fetchDeviceResources |
7f9f3531660c
cache device images for fast drawing
Claus Gittinger <cg@exept.de>
parents:
446
diff
changeset
|
1509 |
"initialize heavily used device resources - to avoid rendering |
7f9f3531660c
cache device images for fast drawing
Claus Gittinger <cg@exept.de>
parents:
446
diff
changeset
|
1510 |
images again and again later" |
7f9f3531660c
cache device images for fast drawing
Claus Gittinger <cg@exept.de>
parents:
446
diff
changeset
|
1511 |
|
7f9f3531660c
cache device images for fast drawing
Claus Gittinger <cg@exept.de>
parents:
446
diff
changeset
|
1512 |
super fetchDeviceResources. |
478 | 1513 |
self refetchDeviceResources |
448
7f9f3531660c
cache device images for fast drawing
Claus Gittinger <cg@exept.de>
parents:
446
diff
changeset
|
1514 |
! |
7f9f3531660c
cache device images for fast drawing
Claus Gittinger <cg@exept.de>
parents:
446
diff
changeset
|
1515 |
|
478 | 1516 |
fetchImageResources |
1517 |
"initialize heavily used device resources - to avoid rendering |
|
1518 |
images again and again later; returns maximum extent of the images used. |
|
1519 |
Could be redefined by subclass |
|
471 | 1520 |
" |
785 | 1521 |
|img x y keysAndIcons| |
494 | 1522 |
|
1070
856d037fe133
care for non-existing images.
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
1523 |
x := y := 0. |
494 | 1524 |
imageOpened isNil ifTrue:[ |
846 | 1525 |
imageOpened := self imageOnDevice:(self class imageOpened) |
494 | 1526 |
]. |
1070
856d037fe133
care for non-existing images.
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
1527 |
imageOpened notNil ifTrue:[ |
856d037fe133
care for non-existing images.
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
1528 |
x := x max:(imageOpened width). |
856d037fe133
care for non-existing images.
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
1529 |
y := y max:(imageOpened height). |
856d037fe133
care for non-existing images.
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
1530 |
]. |
444 | 1531 |
|
494 | 1532 |
imageClosed isNil ifTrue:[ |
569 | 1533 |
imageClosed := self imageOnDevice:(self class imageClosed) |
533
d7867efb6f60
#fetchImageResources returned the max extent only on the first invocation
Stefan Vogel <sv@exept.de>
parents:
532
diff
changeset
|
1534 |
]. |
1070
856d037fe133
care for non-existing images.
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
1535 |
imageClosed notNil ifTrue:[ |
856d037fe133
care for non-existing images.
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
1536 |
x := x max:(imageClosed width). |
856d037fe133
care for non-existing images.
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
1537 |
y := y max:(imageClosed height). |
856d037fe133
care for non-existing images.
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
1538 |
]. |
494 | 1539 |
|
1540 |
imageItem isNil ifTrue:[ |
|
569 | 1541 |
imageItem := self imageOnDevice:(self class imageItem) |
533
d7867efb6f60
#fetchImageResources returned the max extent only on the first invocation
Stefan Vogel <sv@exept.de>
parents:
532
diff
changeset
|
1542 |
]. |
1070
856d037fe133
care for non-existing images.
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
1543 |
imageItem notNil ifTrue:[ |
856d037fe133
care for non-existing images.
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
1544 |
x := x max:(imageItem width). |
856d037fe133
care for non-existing images.
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
1545 |
y := y max:(imageItem height). |
856d037fe133
care for non-existing images.
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
1546 |
]. |
763
dd29c58e8ea6
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
760
diff
changeset
|
1547 |
|
785 | 1548 |
(keysAndIcons := self fetchDefaultImages) notNil ifTrue:[ |
1549 |
keysAndIcons keysAndValuesDo:[:aKey :anIcon| |
|
1550 |
(anIcon isImage and:[aKey notNil]) ifTrue:[ |
|
846 | 1551 |
registeredImages at:aKey put:(self imageOnDevice:anIcon) |
785 | 1552 |
] |
1553 |
] |
|
1554 |
]. |
|
1555 |
registeredImages keysAndValuesDo:[:k :img| |
|
1556 |
x := (img width) max:x. |
|
1557 |
y := (img height) max:y. |
|
1558 |
]. |
|
763
dd29c58e8ea6
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
760
diff
changeset
|
1559 |
|
785 | 1560 |
(listOfNodes size > 0 and:[(img := listOfNodes first icon) isImage]) ifTrue:[ |
1561 |
x := (img width) max:x. |
|
1562 |
y := (img height) max:y. |
|
1563 |
]. |
|
1564 |
^ x @ y |
|
1070
856d037fe133
care for non-existing images.
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
1565 |
|
856d037fe133
care for non-existing images.
Claus Gittinger <cg@exept.de>
parents:
1061
diff
changeset
|
1566 |
"Modified: / 12.8.1998 / 12:45:53 / cg" |
444 | 1567 |
! |
1568 |
||
480 | 1569 |
getFontParameters |
546 | 1570 |
"save old computed height derived from images |
1571 |
" |
|
1572 |
|lineHeight| |
|
1573 |
||
1574 |
lineHeight := fontHeight ? 0. |
|
480 | 1575 |
super getFontParameters. |
569 | 1576 |
labelOffsetY := fontAscent - (fontHeight - lineSpacing // 2). |
480 | 1577 |
|
546 | 1578 |
lineHeight > fontHeight ifTrue:[ |
1579 |
fontHeight := lineHeight |
|
1580 |
]. |
|
685 | 1581 |
fontHeight odd ifTrue:[ |
1582 |
fontHeight := fontHeight + 1 |
|
1583 |
] |
|
480 | 1584 |
! |
1585 |
||
900 | 1586 |
initStyle |
1587 |
"setup viewStyle specifics" |
|
1588 |
||
1589 |
super initStyle. |
|
1171 | 1590 |
highlightMode := DefaultHilightMode ? #label. |
900 | 1591 |
|
1592 |
! |
|
1593 |
||
444 | 1594 |
initialize |
471 | 1595 |
"setup instance attributes |
1596 |
" |
|
444 | 1597 |
super initialize. |
1171 | 1598 |
|
1599 |
itemClass isNil ifTrue:[ |
|
1600 |
itemClass := TreeItem |
|
1601 |
]. |
|
1602 |
||
835 | 1603 |
supportsExpandAll := true. |
569 | 1604 |
self bitGravity:#NorthWest. |
773 | 1605 |
showRoot := showDirectoryIndicatorForRoot := showLines := computeResources := true. |
1606 |
showDirectoryIndicator := discardMotionEvents := false. |
|
1275 | 1607 |
leftMargin := 2. |
1608 |
lineMask := Form width:2 height:2 fromArray:#[16rAA 16r55]. |
|
773 | 1609 |
registeredImages := IdentityDictionary new. |
855 | 1610 |
drawVLinesFromLevel := 1. |
659 | 1611 |
textInset := 4. |
494 | 1612 |
imageInset := 0. "/ set during indication enabled |
1613 |
imageWidth := 8. "/ default: will change during startup |
|
848 | 1614 |
|
1615 |
buildInArray := Array new:50. "/ used for temporary calculation |
|
1616 |
"/ suppress garbage collection |
|
1617 |
||
514 | 1618 |
self model:nil. "/ creates a default model. |
1171 | 1619 |
highlightMode := #label. |
1175 | 1620 |
editValueFgColor := Color blue. |
478 | 1621 |
! |
1622 |
||
569 | 1623 |
realize |
1624 |
super realize. |
|
1625 |
self refetchDeviceResources. |
|
1626 |
! |
|
1627 |
||
811 | 1628 |
recomputeDirectoryIndicator |
1629 |
"setup attributes used by directory indicator |
|
1630 |
" |
|
1631 |
|x w| |
|
1632 |
||
1633 |
imageInset := 0. |
|
1634 |
||
1635 |
(showDirectoryIndicator and:[computeResources not]) ifFalse:[ |
|
1636 |
^ self |
|
1637 |
]. |
|
1072
1888703adc18
care for non-existing open/close indicators.
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
1638 |
|
1888703adc18
care for non-existing open/close indicators.
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
1639 |
x := 0. |
811 | 1640 |
openIndicator isNil ifTrue:[ |
1641 |
openIndicator := self imageOnDevice:(self class openIndicator) |
|
1642 |
]. |
|
1072
1888703adc18
care for non-existing open/close indicators.
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
1643 |
openIndicator notNil ifTrue:[ |
1888703adc18
care for non-existing open/close indicators.
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
1644 |
x := openIndicator width |
1888703adc18
care for non-existing open/close indicators.
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
1645 |
]. |
1888703adc18
care for non-existing open/close indicators.
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
1646 |
|
811 | 1647 |
closeIndicator isNil ifTrue:[ |
1648 |
closeIndicator := self imageOnDevice:(self class closeIndicator) |
|
1649 |
]. |
|
1072
1888703adc18
care for non-existing open/close indicators.
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
1650 |
closeIndicator notNil ifTrue:[ |
1888703adc18
care for non-existing open/close indicators.
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
1651 |
x := x max:(closeIndicator width) |
1888703adc18
care for non-existing open/close indicators.
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
1652 |
]. |
1888703adc18
care for non-existing open/close indicators.
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
1653 |
|
811 | 1654 |
x := x // 2. |
1655 |
w := imageWidth // 2. |
|
1656 |
||
1657 |
(x := x + self class minImageInset) > w ifTrue:[ |
|
1658 |
imageInset := x - w. |
|
1659 |
]. |
|
1660 |
||
1072
1888703adc18
care for non-existing open/close indicators.
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
1661 |
"Modified: / 13.8.1998 / 12:02:04 / cg" |
811 | 1662 |
! |
1663 |
||
478 | 1664 |
refetchDeviceResources |
1665 |
"reinitialize heavily used device resources - to avoid rendering |
|
1666 |
images again and again later |
|
1667 |
" |
|
551 | 1668 |
|extent| |
478 | 1669 |
|
569 | 1670 |
(realized and:[computeResources and:[listOfNodes size ~~ 0]]) ifTrue:[ |
546 | 1671 |
computeResources := false. |
1672 |
extent := self fetchImageResources. |
|
494 | 1673 |
|
546 | 1674 |
extent y >= fontHeight ifTrue:[ |
1675 |
fontHeight := 1 + extent y. |
|
494 | 1676 |
]. |
685 | 1677 |
fontHeight odd ifTrue:[ |
1678 |
fontHeight := fontHeight + 1 |
|
1679 |
]. |
|
846 | 1680 |
"/ round and not odd: because of line drawing |
685 | 1681 |
|
846 | 1682 |
imageWidth := (extent x) // 2. |
1683 |
imageWidth odd ifTrue:[imageWidth := imageWidth + 1]. |
|
1684 |
imageWidth := imageWidth * 2. |
|
1685 |
||
546 | 1686 |
self recomputeDirectoryIndicator. |
569 | 1687 |
self computeNumberOfLinesShown. |
546 | 1688 |
] |
444 | 1689 |
! ! |
1690 |
||
483 | 1691 |
!SelectionInTreeView methodsFor:'model'! |
444 | 1692 |
|
1693 |
getListFromModel |
|
1694 |
"if I have a model, get my list from it using the listMessage. |
|
1695 |
If listMessage is nil, try aspectMessage for backward compatibilty. |
|
1696 |
" |
|
483 | 1697 |
super list:(self listFromModel) keepSelection:true |
1698 |
! |
|
444 | 1699 |
|
483 | 1700 |
listFromModel |
1701 |
"get list from model and return the new list. |
|
1702 |
If listMessage is nil, try aspectMessage for backward compatibilty. |
|
1703 |
" |
|
846 | 1704 |
|msg| |
838 | 1705 |
|
846 | 1706 |
widthOfWidestLine := nil. |
847 | 1707 |
list := listOfNodes := (msg := listMsg ? aspectMsg) notNil ifTrue:[model perform:msg] ifFalse:[#()]. |
1708 |
self refetchDeviceResources. |
|
846 | 1709 |
^ listOfNodes |
494 | 1710 |
! |
1711 |
||
1712 |
model:aModel |
|
514 | 1713 |
"check whether model is nil; than a default model is created |
1714 |
" |
|
855 | 1715 |
|model root| |
514 | 1716 |
|
811 | 1717 |
model notNil ifTrue:[ |
1718 |
model stopRunningTasks |
|
1719 |
]. |
|
1720 |
||
1171 | 1721 |
model := aModel ? (self class defaultModelClass new). |
1722 |
self itemClass:(model class defaultItemClass). |
|
855 | 1723 |
root := model root. |
1724 |
||
514 | 1725 |
model showRoot:showRoot. |
855 | 1726 |
|
1727 |
root notNil ifTrue:[ |
|
1728 |
root expand |
|
1729 |
]. |
|
514 | 1730 |
super model:model. |
855 | 1731 |
self getListFromModel |
811 | 1732 |
|
514 | 1733 |
! |
1734 |
||
1735 |
rootFromModel |
|
1736 |
"update hierarchical list from root model; 'rootHolder' |
|
1737 |
" |
|
1738 |
|root| |
|
1739 |
||
585 | 1740 |
root := rootHolder root. |
514 | 1741 |
|
1742 |
self root == root ifFalse:[ |
|
1743 |
self selection:nil. |
|
1744 |
self root:root. |
|
585 | 1745 |
]. |
514 | 1746 |
! |
1747 |
||
1748 |
selectionFromModel |
|
1749 |
"set the selection derived from the selectionHolder |
|
1750 |
" |
|
855 | 1751 |
|coll value size idx| |
514 | 1752 |
|
1214 | 1753 |
(value := selectionHolder value) isNil ifFalse:[ |
1754 |
(multipleSelectOk and:[value isCollection]) ifFalse:[ |
|
1755 |
^ self selectNode:value |
|
860 | 1756 |
]. |
1214 | 1757 |
|
1758 |
(size := value size) ~~ 0 ifTrue:[ |
|
1759 |
size == 1 ifTrue:[ |
|
1760 |
^ self selectNode:(value at:1) |
|
1761 |
]. |
|
1762 |
||
1763 |
model doMakeVisible:value. |
|
1764 |
||
1765 |
coll := OrderedCollection new:size. |
|
1766 |
||
1767 |
value do:[:el| |
|
1768 |
idx := el isNumber ifTrue:[el] ifFalse:[self indexOfNode:el]. |
|
1769 |
||
1770 |
idx ~~ 0 ifTrue:[ |
|
1771 |
coll add:idx |
|
1772 |
]. |
|
1773 |
]. |
|
1774 |
||
1775 |
coll isEmpty ifTrue:[ |
|
1776 |
coll := nil |
|
1777 |
]. |
|
1778 |
]. |
|
848 | 1779 |
]. |
1780 |
self selection:coll |
|
514 | 1781 |
! |
1782 |
||
1783 |
selectionToModel |
|
1784 |
"write selection to selection holder |
|
1785 |
" |
|
1786 |
|newSel oldSel| |
|
1787 |
||
1788 |
oldSel := selectionHolder value. |
|
1789 |
||
1790 |
multipleSelectOk ifFalse:[ |
|
1791 |
(newSel := self selectedNode) ~~ oldSel ifTrue:[ |
|
1792 |
selectionHolder value:newSel |
|
1793 |
] |
|
1794 |
] ifTrue:[ |
|
1795 |
selection size == 0 ifTrue:[ |
|
1796 |
oldSel notNil ifTrue:[ |
|
1797 |
selectionHolder value:nil |
|
1798 |
] |
|
1799 |
] ifFalse:[ |
|
1800 |
newSel := selection collect:[:i| listOfNodes at:i]. |
|
1801 |
||
1802 |
newSel size ~~ oldSel size ifTrue:[ |
|
1803 |
selectionHolder value:newSel. |
|
1804 |
] ifFalse:[ |
|
1805 |
newSel do:[:aNode| |
|
785 | 1806 |
(oldSel includesIdentical:aNode) ifFalse:[ |
514 | 1807 |
^ selectionHolder value:newSel |
1808 |
] |
|
1809 |
] |
|
1810 |
] |
|
1811 |
] |
|
1812 |
] |
|
444 | 1813 |
! ! |
1814 |
||
490 | 1815 |
!SelectionInTreeView methodsFor:'private'! |
1816 |
||
1171 | 1817 |
closeEditor |
1818 |
"close the editor |
|
1819 |
" |
|
1820 |
editorWidget notNil ifTrue:[ |
|
1821 |
editorWidget destroy. |
|
1822 |
editorIndex := 0. |
|
1823 |
editorWidget := nil. |
|
1824 |
]. |
|
1825 |
||
1826 |
! |
|
1827 |
||
490 | 1828 |
list:aList keepSelection:keepSelection |
585 | 1829 |
"setup new list; keep selection dependent on the boolean state |
1830 |
keepSelection |
|
1831 |
" |
|
1268 | 1832 |
|list| |
490 | 1833 |
|
846 | 1834 |
list := (aList size == 0) ifTrue:[#()] ifFalse:[aList]. |
1835 |
super list:list keepSelection:keepSelection. |
|
1836 |
self refetchDeviceResources. |
|
490 | 1837 |
|
1171 | 1838 |
! |
1839 |
||
1840 |
openEditor |
|
1841 |
"open an editor on selection |
|
1842 |
" |
|
1175 | 1843 |
|node x0 x1 y0| |
1171 | 1844 |
|
1845 |
editorWidget notNil ifTrue:[ |
|
1846 |
^ self |
|
1847 |
]. |
|
1848 |
editorIndex := self selectedIndex. |
|
1849 |
||
1850 |
( (node := listOfNodes at:editorIndex ifAbsent:nil) isNil |
|
1851 |
or:[(y0 := self listLineToVisibleLine:editorIndex) isNil |
|
1852 |
or:[(editorWidget := node editor) isNil]] |
|
1853 |
) ifTrue:[ |
|
1854 |
^ self |
|
1855 |
]. |
|
1175 | 1856 |
editorWidget withAllSubViewsDo:[:v| v font:font ]. |
1857 |
||
1171 | 1858 |
y0 := self yOfVisibleLine:y0. |
1859 |
x0 := self xOfValueNode:node. |
|
1860 |
x1 := (editorWidget preferredExtent x) max:50. |
|
1861 |
x1 := (x0 + x1) min:(self width - 5). |
|
1862 |
||
1863 |
editorWidget geometryLayout:(Rectangle left:x0 right:x1 top:y0 bottom:y0 + fontHeight). |
|
1864 |
||
1865 |
self addComponent:editorWidget. |
|
1866 |
editorWidget realize. |
|
1867 |
self paint:bgColor. |
|
1868 |
||
1869 |
self fillRectangleX:(x0 - SelectionInset) |
|
1870 |
y:y0 |
|
1871 |
width:SelectionInset + SelectionInset + (x1 - x0) |
|
1872 |
height:fontHeight. |
|
1873 |
||
1874 |
||
1875 |
||
1876 |
||
1877 |
||
811 | 1878 |
! ! |
1879 |
||
1880 |
!SelectionInTreeView methodsFor:'private - drag and drop'! |
|
569 | 1881 |
|
811 | 1882 |
collectionOfDragObjects |
1883 |
"returns collection of dragable objects assigned to selection |
|
1884 |
Here, by default, a collection of text-dragObjects is generated; |
|
1885 |
however, if a dragObjectConverter is defined, that one gets a chance |
|
1886 |
to convert as appropriate." |
|
1887 |
||
1888 |
|collection converted selection dLbl dObj node| |
|
1889 |
||
1890 |
selection := self selectionAsCollection. |
|
1891 |
||
1892 |
collection := selection collect:[:nr| |
|
1893 |
node := listOfNodes at:nr. |
|
1894 |
dObj := self dragObjectForNode:node. |
|
1895 |
dObj theObject:(node contents). |
|
846 | 1896 |
dLbl := LabelAndIcon icon:(self figureFor:node) string:(node name). |
811 | 1897 |
dObj displayObject:dLbl. |
1898 |
dObj |
|
1899 |
]. |
|
1900 |
||
1901 |
dragObjectConverter notNil ifTrue:[ |
|
1902 |
converted := OrderedCollection new. |
|
1903 |
collection keysAndValuesDo:[:nr :obj | |
|
1904 |
(dObj := dragObjectConverter value:obj) notNil ifTrue:[ |
|
846 | 1905 |
node := listOfNodes at:nr. |
1906 |
dLbl := LabelAndIcon icon:(self figureFor:node) string:(node name). |
|
811 | 1907 |
converted displayObject:dLbl. |
1908 |
converted add:dObj |
|
1909 |
] |
|
1910 |
]. |
|
1911 |
collection := converted |
|
1912 |
]. |
|
1913 |
^ collection. |
|
1914 |
||
1915 |
||
569 | 1916 |
|
1917 |
! |
|
1918 |
||
811 | 1919 |
dragObjectForNode:aNode |
1920 |
"returns the dragable object for a node; could be redefined in subclass |
|
546 | 1921 |
" |
811 | 1922 |
^ DropObject new:aNode. |
546 | 1923 |
|
811 | 1924 |
|
1925 |
! |
|
546 | 1926 |
|
811 | 1927 |
startDragX:x y:y |
1928 |
"start drag |
|
1929 |
" |
|
1930 |
dragIsActive := true. |
|
546 | 1931 |
|
811 | 1932 |
DragAndDropManager startDrag:(self collectionOfDragObjects) |
1933 |
from:self |
|
1934 |
atEnd:endDragAction |
|
546 | 1935 |
|
1936 |
||
490 | 1937 |
! ! |
1938 |
||
468 | 1939 |
!SelectionInTreeView methodsFor:'private queries'! |
1940 |
||
1941 |
lengthOfLongestLineBetween:firstLine and:lastLine |
|
1942 |
"return the length (in characters) of the longest line in a line-range |
|
1943 |
" |
|
846 | 1944 |
^ self widthOfContents // fontWidth + 1 |
468 | 1945 |
! |
1946 |
||
848 | 1947 |
smallestLevelOfNodesBetween:start and:stop |
1948 |
"returns the smallest level of the nodes in a line range |
|
1949 |
" |
|
1950 |
|prevNode currParent nextParent |
|
1951 |
||
1952 |
lvl "{ Class:SmallInteger }" |
|
1953 |
min "{ Class:SmallInteger }" |
|
1954 |
end "{ Class:SmallInteger }" |
|
1955 |
beg "{ Class:SmallInteger }" |
|
1956 |
| |
|
1957 |
||
1958 |
(end := stop min:(listOfNodes size)) < start ifTrue:[ |
|
1959 |
^ 0 |
|
1960 |
]. |
|
1961 |
||
1962 |
prevNode := listOfNodes at:start. |
|
1963 |
currParent := prevNode parent. |
|
1964 |
||
1965 |
currParent isNil ifTrue:[ |
|
1966 |
^ 1 |
|
1967 |
]. |
|
1968 |
||
1969 |
(min := prevNode level) == 2 ifTrue:[ |
|
1970 |
^ min |
|
1971 |
]. |
|
1972 |
beg := start + 1. |
|
1973 |
||
1974 |
listOfNodes from:beg to:end do:[:currNode| |
|
1975 |
(nextParent := currNode parent) == currParent ifFalse:[ |
|
1976 |
(currParent := nextParent) == prevNode ifFalse:[ |
|
1977 |
(lvl := currNode level) == 2 ifTrue:[ |
|
1978 |
^ 2 |
|
1979 |
]. |
|
1980 |
min := min min:lvl |
|
1981 |
] |
|
1982 |
]. |
|
1983 |
prevNode := currNode |
|
1984 |
]. |
|
1985 |
^ min |
|
1986 |
||
1987 |
||
1988 |
||
1989 |
||
1990 |
! |
|
1991 |
||
468 | 1992 |
widthOfContents |
1993 |
"return the width of the contents in pixels |
|
1994 |
- used for scrollbar interface" |
|
1995 |
||
846 | 1996 |
listOfNodes isNil ifTrue:[^ 0]. |
468 | 1997 |
|
1998 |
(widthOfWidestLine isNil or:[widthOfWidestLine == 0]) ifTrue:[ |
|
846 | 1999 |
widthOfWidestLine := self widthOfLongestLine |
468 | 2000 |
]. |
2001 |
^ widthOfWidestLine + (leftMargin * 2) |
|
2002 |
||
2003 |
! |
|
2004 |
||
846 | 2005 |
widthOfLongestLine |
2006 |
"return the width of the longest line in pixels |
|
468 | 2007 |
" |
848 | 2008 |
|parent pItem p |
846 | 2009 |
startX "{ Class: SmallInteger }" |
2010 |
deltaX "{ Class: SmallInteger }" |
|
838 | 2011 |
level "{ Class: SmallInteger }" |
2012 |
width "{ Class: SmallInteger }" |
|
2013 |
maxSz "{ Class: SmallInteger }"| |
|
468 | 2014 |
|
848 | 2015 |
buildInArray atAllPut:0. |
846 | 2016 |
parent := nil. |
2017 |
maxSz := 1. |
|
838 | 2018 |
level := 1. |
846 | 2019 |
|
2020 |
listOfNodes do:[:anItem| |
|
848 | 2021 |
(p := anItem parent) ~~ parent ifTrue:[ |
2022 |
buildInArray at:level put:maxSz. |
|
846 | 2023 |
|
848 | 2024 |
(parent := p) == pItem ifTrue:[level := level + 1] |
2025 |
ifFalse:[level := anItem level]. |
|
2026 |
||
2027 |
maxSz := buildInArray at:level. |
|
846 | 2028 |
]. |
2029 |
pItem := anItem. |
|
2030 |
maxSz := maxSz max:(anItem name size). |
|
2031 |
]. |
|
848 | 2032 |
buildInArray at:level put:maxSz. |
468 | 2033 |
|
846 | 2034 |
startX := self xOfStringLevel:1. |
2035 |
deltaX := imageInset + imageWidth. |
|
2036 |
width := '1' widthOn:self. |
|
2037 |
maxSz := 0. |
|
468 | 2038 |
|
848 | 2039 |
buildInArray do:[:el| |
846 | 2040 |
el == 0 ifTrue:[ ^ maxSz + leftOffset ]. |
2041 |
maxSz := maxSz max:(el * width + startX). |
|
2042 |
startX := startX + deltaX. |
|
468 | 2043 |
]. |
846 | 2044 |
! ! |
2045 |
||
2046 |
!SelectionInTreeView methodsFor:'private redefinitions'! |
|
2047 |
||
2048 |
expandTabs |
|
2049 |
"nothing to do |
|
2050 |
" |
|
838 | 2051 |
|
2052 |
||
468 | 2053 |
! |
2054 |
||
846 | 2055 |
list:aCollection expandTabs:expand scanForNonStrings:scan |
2056 |
||
2057 |
includesNonStrings := false. |
|
2058 |
self list:aCollection expandTabs:false scanForNonStrings:false includesNonStrings:false |
|
2059 |
! |
|
2060 |
||
468 | 2061 |
withoutRedrawAt:anIndex put:aString |
2062 |
"change a line without redisplay" |
|
2063 |
||
2064 |
|width| |
|
2065 |
||
2066 |
width := widthOfWidestLine. |
|
2067 |
widthOfWidestLine := nil. |
|
2068 |
super withoutRedrawAt:anIndex put:aString. |
|
846 | 2069 |
widthOfWidestLine := width. |
468 | 2070 |
|
846 | 2071 |
(widthOfWidestLine notNil and:[aString size ~~ 0]) ifTrue:[ |
2072 |
width := self xOfStringNode:(listOfNodes at:anIndex) |
|
2073 |
+ (aString widthOn:self) |
|
2074 |
+ leftOffset. |
|
2075 |
||
838 | 2076 |
widthOfWidestLine := widthOfWidestLine max:width. |
468 | 2077 |
]. |
2078 |
! ! |
|
2079 |
||
483 | 2080 |
!SelectionInTreeView methodsFor:'queries'! |
2081 |
||
2082 |
figureFor:aNode |
|
1278 | 2083 |
"return a (bitmap) figure for a node" |
2084 |
||
785 | 2085 |
|icon img| |
2086 |
||
1278 | 2087 |
"/ the item may provide an icon |
2088 |
"/ (it knows for itself if its open or closed) |
|
2089 |
||
785 | 2090 |
(icon := aNode icon) notNil ifTrue:[ |
2091 |
img := registeredImages at:icon ifAbsent:nil. |
|
2092 |
img notNil ifTrue:[ |
|
2093 |
^ img |
|
763
dd29c58e8ea6
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
760
diff
changeset
|
2094 |
]. |
785 | 2095 |
icon isImage ifTrue:[ |
846 | 2096 |
img := self imageOnDevice:icon. |
785 | 2097 |
registeredImages at:icon put:img. |
1278 | 2098 |
^ img |
785 | 2099 |
] |
763
dd29c58e8ea6
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
760
diff
changeset
|
2100 |
]. |
dd29c58e8ea6
supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents:
760
diff
changeset
|
2101 |
|
1278 | 2102 |
"/ ok, node did not return an icon - use default. |
2103 |
||
846 | 2104 |
aNode hasChildren ifFalse:[ |
1278 | 2105 |
"/ regular |
2106 |
^ imageItem |
|
846 | 2107 |
]. |
1278 | 2108 |
"/ folder |
846 | 2109 |
^ aNode hidden ifTrue:[imageClosed] ifFalse:[imageOpened] |
785 | 2110 |
|
483 | 2111 |
! |
2112 |
||
2113 |
indexOfNode:aNode |
|
2114 |
"returns index of a node |
|
2115 |
" |
|
785 | 2116 |
^ listOfNodes identityIndexOf:aNode |
483 | 2117 |
! |
2118 |
||
494 | 2119 |
xOfFigureLevel:aLevel |
2120 |
"origin x where to draw the icon |
|
2121 |
" |
|
785 | 2122 |
|l "{ Class:SmallInteger }"| |
494 | 2123 |
|
785 | 2124 |
l := showRoot ifTrue:[aLevel] ifFalse:[aLevel - 1]. |
494 | 2125 |
|
659 | 2126 |
showDirectoryIndicator ifFalse:[ |
2127 |
l := l - 1 |
|
2128 |
] ifTrue:[ |
|
2129 |
showDirectoryIndicatorForRoot ifFalse:[ |
|
2130 |
l := l - 1 |
|
2131 |
] |
|
2132 |
]. |
|
494 | 2133 |
^ (l * (imageInset + imageWidth)) + imageInset - leftOffset + leftMargin |
2134 |
||
2135 |
! |
|
2136 |
||
483 | 2137 |
xOfFigureNode:aNode |
2138 |
"origin x where to draw the icon |
|
2139 |
" |
|
494 | 2140 |
^ self xOfFigureLevel:(aNode level) |
2141 |
! |
|
490 | 2142 |
|
494 | 2143 |
xOfStringLevel:aLevel |
2144 |
"origin x where to draw the text( label ) |
|
2145 |
" |
|
2146 |
^ (self xOfFigureLevel:aLevel) + imageWidth + textInset |
|
483 | 2147 |
|
2148 |
! |
|
2149 |
||
2150 |
xOfStringNode:aNode |
|
2151 |
"origin x where to draw the text( label ) |
|
2152 |
" |
|
494 | 2153 |
^ self xOfStringLevel:(aNode level) |
483 | 2154 |
|
1171 | 2155 |
! |
2156 |
||
2157 |
xOfValueNode:aNode |
|
2158 |
"returns the left x position of the start of the value |
|
2159 |
" |
|
2160 |
|p x| |
|
2161 |
||
2162 |
p := aNode parent. |
|
2163 |
||
2164 |
x := p notNil ifTrue:[30 + (p childrenWidthOn:self)] |
|
2165 |
ifFalse:[0]. |
|
2166 |
||
2167 |
^ x + (self xOfStringNode:aNode) |
|
2168 |
||
483 | 2169 |
! ! |
2170 |
||
1061
8eba9d898259
scroll to bring selection into upper half of view
Claus Gittinger <cg@exept.de>
parents:
908
diff
changeset
|
2171 |
!SelectionInTreeView methodsFor:'scrolling'! |
8eba9d898259
scroll to bring selection into upper half of view
Claus Gittinger <cg@exept.de>
parents:
908
diff
changeset
|
2172 |
|
8eba9d898259
scroll to bring selection into upper half of view
Claus Gittinger <cg@exept.de>
parents:
908
diff
changeset
|
2173 |
needScrollToMakeLine:aListLineNr |
8eba9d898259
scroll to bring selection into upper half of view
Claus Gittinger <cg@exept.de>
parents:
908
diff
changeset
|
2174 |
"redefined to scroll whenever line is not in top half" |
8eba9d898259
scroll to bring selection into upper half of view
Claus Gittinger <cg@exept.de>
parents:
908
diff
changeset
|
2175 |
|
8eba9d898259
scroll to bring selection into upper half of view
Claus Gittinger <cg@exept.de>
parents:
908
diff
changeset
|
2176 |
(aListLineNr >= firstLineShown) ifTrue:[ |
1162 | 2177 |
(aListLineNr < (firstLineShown + nFullLinesShown)) ifTrue:[ |
1061
8eba9d898259
scroll to bring selection into upper half of view
Claus Gittinger <cg@exept.de>
parents:
908
diff
changeset
|
2178 |
^ false |
8eba9d898259
scroll to bring selection into upper half of view
Claus Gittinger <cg@exept.de>
parents:
908
diff
changeset
|
2179 |
] |
8eba9d898259
scroll to bring selection into upper half of view
Claus Gittinger <cg@exept.de>
parents:
908
diff
changeset
|
2180 |
]. |
8eba9d898259
scroll to bring selection into upper half of view
Claus Gittinger <cg@exept.de>
parents:
908
diff
changeset
|
2181 |
^ true |
8eba9d898259
scroll to bring selection into upper half of view
Claus Gittinger <cg@exept.de>
parents:
908
diff
changeset
|
2182 |
|
1171 | 2183 |
! |
2184 |
||
2185 |
originChanged:delta |
|
2186 |
"sent after scrolling - have to update origin of editor |
|
2187 |
" |
|
2188 |
super originChanged:delta. |
|
2189 |
||
2190 |
editorWidget notNil ifTrue:[ |
|
2191 |
editorWidget origin:(editorWidget origin - delta) |
|
2192 |
] |
|
2193 |
||
1061
8eba9d898259
scroll to bring selection into upper half of view
Claus Gittinger <cg@exept.de>
parents:
908
diff
changeset
|
2194 |
! ! |
8eba9d898259
scroll to bring selection into upper half of view
Claus Gittinger <cg@exept.de>
parents:
908
diff
changeset
|
2195 |
|
444 | 2196 |
!SelectionInTreeView methodsFor:'selection'! |
2197 |
||
468 | 2198 |
selectNode:aNode |
2199 |
"change selection to a node |
|
2200 |
" |
|
855 | 2201 |
|index| |
848 | 2202 |
|
860 | 2203 |
(index := aNode) notNil ifTrue:[ |
2204 |
index isNumber ifFalse:[ |
|
2205 |
(index := self indexOfNode:aNode) == 0 ifTrue:[ |
|
2206 |
model doMakeVisible:aNode. |
|
2207 |
index := self indexOfNode:aNode. |
|
2208 |
] |
|
855 | 2209 |
]. |
848 | 2210 |
index == 0 ifTrue:[ |
855 | 2211 |
index := nil |
848 | 2212 |
] |
2213 |
]. |
|
2214 |
self selection:index |
|
468 | 2215 |
|
2216 |
||
2217 |
! |
|
2218 |
||
456 | 2219 |
selectedIndex |
2220 |
"get single selected index or 0 |
|
2221 |
" |
|
483 | 2222 |
selection size == 1 ifTrue:[^ selection first]. |
2223 |
selection isNumber ifTrue:[^ selection]. |
|
456 | 2224 |
^ 0 |
444 | 2225 |
! |
2226 |
||
2227 |
selectedNode |
|
2228 |
"get the single selected node or nil |
|
2229 |
" |
|
456 | 2230 |
|idx| |
2231 |
||
2232 |
(idx := self selectedIndex) ~~ 0 ifTrue:[ |
|
2233 |
^ listOfNodes at:idx |
|
444 | 2234 |
]. |
2235 |
^ nil |
|
514 | 2236 |
! |
2237 |
||
2238 |
selectionChangedFrom:oldSelection |
|
2239 |
"update selectionHolder if not nil |
|
2240 |
" |
|
1171 | 2241 |
self closeEditor. |
514 | 2242 |
|
623
4de870640523
first change selectionHolders value,
Claus Gittinger <cg@exept.de>
parents:
589
diff
changeset
|
2243 |
"/ first change my selectionHolders value ... |
514 | 2244 |
selectionHolder notNil ifTrue:[ |
2245 |
self selectionToModel. |
|
2246 |
]. |
|
2247 |
||
623
4de870640523
first change selectionHolders value,
Claus Gittinger <cg@exept.de>
parents:
589
diff
changeset
|
2248 |
"/ ... then make notifications. |
4de870640523
first change selectionHolders value,
Claus Gittinger <cg@exept.de>
parents:
589
diff
changeset
|
2249 |
super selectionChangedFrom:oldSelection. |
4de870640523
first change selectionHolders value,
Claus Gittinger <cg@exept.de>
parents:
589
diff
changeset
|
2250 |
|
4de870640523
first change selectionHolders value,
Claus Gittinger <cg@exept.de>
parents:
589
diff
changeset
|
2251 |
|
1171 | 2252 |
! |
2253 |
||
2254 |
setSelection:aSelection |
|
2255 |
"if no selection exists, close the editor |
|
2256 |
" |
|
2257 |
(aSelection isNil or:[aSelection == 0]) ifTrue:[ |
|
2258 |
self closeEditor |
|
2259 |
]. |
|
2260 |
super setSelection:aSelection |
|
2261 |
||
2262 |
||
444 | 2263 |
! ! |
2264 |
||
855 | 2265 |
!SelectionInTreeView methodsFor:'selection actions'! |
507 | 2266 |
|
2267 |
selectedNodeAdd:something |
|
2268 |
"add a node or collection of nodes after selected node |
|
2269 |
" |
|
2270 |
|node| |
|
2271 |
||
2272 |
something notNil ifTrue:[ |
|
2273 |
(node := self selectedNode) notNil ifTrue:[ |
|
2274 |
node parent notNil ifTrue:[ |
|
2275 |
node isCollapsable ifTrue:[ |
|
2276 |
model add:something beforeIndex:1 below:node |
|
2277 |
] ifFalse:[ |
|
2278 |
model add:something after:node |
|
2279 |
] |
|
2280 |
] ifFalse:[ |
|
2281 |
model add:something beforeIndex:1 below:(self root) |
|
2282 |
] |
|
2283 |
] |
|
2284 |
] |
|
2285 |
||
2286 |
! |
|
2287 |
||
2288 |
selectedNodeBecomeChildOfNext |
|
2289 |
"become node a child of followd node |
|
2290 |
" |
|
2291 |
|idx node cprt nprt| |
|
2292 |
||
2293 |
((node := self selectedNode) isNil or:[(cprt := node parent) isNil]) ifFalse:[ |
|
2294 |
idx := cprt indexOfChild:node. |
|
2295 |
||
2296 |
idx == cprt children size ifFalse:[ |
|
2297 |
nprt := cprt childAt:(idx + 1). |
|
2298 |
||
2299 |
nprt notNil ifTrue:[ |
|
855 | 2300 |
self setSelection:nil. |
2301 |
model remove:node. |
|
507 | 2302 |
model add:node beforeIndex:1 below:nprt. |
2303 |
self selectNode:node. |
|
2304 |
] |
|
2305 |
] |
|
2306 |
] |
|
2307 |
! |
|
2308 |
||
2309 |
selectedNodeBecomeSisterOfParent |
|
2310 |
"become node a sister of its current parent |
|
2311 |
" |
|
2312 |
|node cprt nprt| |
|
2313 |
||
2314 |
( (node := self selectedNode) isNil |
|
2315 |
or:[(cprt := node parent) isNil |
|
2316 |
or:[(nprt := cprt parent) isNil]] |
|
2317 |
) ifFalse:[ |
|
855 | 2318 |
self setSelection:nil. |
2319 |
model remove:node. |
|
507 | 2320 |
model add:node afterIndex:(nprt indexOfChild:cprt) below:nprt. |
855 | 2321 |
self selectNode:node. |
507 | 2322 |
] |
2323 |
||
2324 |
! |
|
2325 |
||
2326 |
selectedNodeChangeSequenceOrder:anOffset |
|
2327 |
"move child 'anOffset' forward or backward in list of children |
|
2328 |
" |
|
2329 |
|idx node size parent| |
|
2330 |
||
2331 |
( (node := self selectedNode) notNil |
|
2332 |
and:[(parent := node parent) notNil |
|
2333 |
and:[(size := parent children size) > 1]] |
|
2334 |
) ifTrue:[ |
|
2335 |
idx := parent indexOfChild:node. |
|
855 | 2336 |
self setSelection:nil. |
2337 |
model remove:node. |
|
507 | 2338 |
|
2339 |
(idx := idx + anOffset) < 1 ifTrue:[ |
|
2340 |
idx := size |
|
2341 |
] ifFalse:[ |
|
2342 |
idx > size ifTrue:[idx := 1] |
|
2343 |
]. |
|
2344 |
model add:node beforeIndex:idx below:parent. |
|
2345 |
self selectNode:node. |
|
2346 |
] |
|
2347 |
! |
|
2348 |
||
2349 |
selectedNodeExpand:doExpand |
|
2350 |
"collapse or expand selected node |
|
2351 |
" |
|
855 | 2352 |
|node| |
507 | 2353 |
|
855 | 2354 |
(node := self selectedNode) notNil ifTrue:[ |
2355 |
doExpand ifTrue:[model doExpand:node] |
|
2356 |
ifFalse:[model doCollapse:node] |
|
2357 |
] |
|
507 | 2358 |
! |
2359 |
||
2360 |
selectedNodesRemove |
|
2361 |
"remove selected nodes |
|
2362 |
" |
|
855 | 2363 |
|selection| |
2364 |
||
2365 |
selection := self selection. |
|
507 | 2366 |
self selection:nil. |
855 | 2367 |
model remove:selection. |
507 | 2368 |
! ! |
2369 |
||
444 | 2370 |
!SelectionInTreeView class methodsFor:'documentation'! |
2371 |
||
2372 |
version |
|
1431 | 2373 |
^ '$Header: /cvs/stx/stx/libwidg2/SelectionInTreeView.st,v 1.85 1999-07-06 16:51:00 cg Exp $' |
444 | 2374 |
! ! |