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