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