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