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