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