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