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