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