author | ca |
Mon, 11 Nov 2002 15:51:05 +0100 | |
changeset 2366 | efbcecbc7bff |
parent 2361 | c0e70e31ac28 |
child 2377 | 6c368b8b0ec3 |
permissions | -rw-r--r-- |
1431 | 1 |
" |
2 |
COPYRIGHT (c) 1999 by eXept Software AG |
|
3 |
All Rights Reserved |
|
4 |
||
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
13 |
||
1752 | 14 |
"{ Package: 'stx:libwidg2' }" |
15 |
||
1390 | 16 |
SelectionInListModelView subclass:#HierarchicalListView |
2361 | 17 |
instanceVariableNames:'imageInset imageWidth lineMask lineColor showRoot showLines |
18 |
showLeftIndicators indicatorAction useDefaultIcons icons |
|
19 |
openIndicator closeIndicator alignTextRight alignTextRightX |
|
20 |
maxWidthOfText minLineHeight levelOfLastItem expandOnSelect |
|
21 |
autoScrollHorizontal' |
|
22 |
classVariableNames:'' |
|
23 |
poolDictionaries:'' |
|
24 |
category:'Views-Trees' |
|
1390 | 25 |
! |
26 |
||
27 |
!HierarchicalListView class methodsFor:'documentation'! |
|
28 |
||
1431 | 29 |
copyright |
30 |
" |
|
31 |
COPYRIGHT (c) 1999 by eXept Software AG |
|
32 |
All Rights Reserved |
|
33 |
||
34 |
This software is furnished under a license and may be used |
|
35 |
only in accordance with the terms of that license and with the |
|
36 |
inclusion of the above copyright notice. This software may not |
|
37 |
be provided or otherwise made available to, or used by, any |
|
38 |
other person. No title to or ownership of the software is |
|
39 |
hereby transferred. |
|
40 |
" |
|
41 |
||
42 |
! |
|
43 |
||
1757 | 44 |
documentation |
1390 | 45 |
" |
1757 | 46 |
This class implements a hierarchical list view based on a |
47 |
hierachical list. |
|
48 |
It provides functionality similar to SelectionInTreeView, but optimizes |
|
49 |
redraws, and operates directly upon the model (in contrast to |
|
50 |
SelectionInTreeView, which generates a list internally). |
|
1390 | 51 |
|
1757 | 52 |
[Instance variables:] |
53 |
textStartLeft <Integer> inset between icon and text |
|
54 |
imageInset <Integer> inset between left side and icon |
|
55 |
imageWidth <Integer> width of widest icon |
|
2312 | 56 |
minLineHeight <Integer> minimum required line height |
57 |
including open/close indication ... |
|
1757 | 58 |
lineMask <Form> line mask |
59 |
lineColor <Color> line color |
|
60 |
showRoot <Boolean> root element is shown or hidden |
|
61 |
derives from the hierachical list. |
|
62 |
showLines <Boolean> show or hide lines |
|
63 |
useDefaultIcons <Boolean> use the default icons if no icon |
|
64 |
for an item is specified |
|
65 |
icons <IdentityDictionary> list of registered icons; |
|
66 |
identifier := <key> value := <icon> |
|
67 |
showLeftIndicators <Boolean> show or hide indicator for most left items |
|
68 |
indicatorAction <Block> action evaluated if indicator is pressed |
|
69 |
openIndicator <Icon, Image or Form> expanded indicator |
|
70 |
closeIndicator <Icon, Image or Form> collapsed indicator |
|
1390 | 71 |
|
1757 | 72 |
alignTextRight <Boolean> enable disable of align the text right |
73 |
icon text |
|
74 |
icon text of child |
|
75 |
should be set after creation of the widget!! |
|
76 |
alignTextRightX <Integer> left x position of aligned right text |
|
77 |
maxWidthOfText <Integer> keeps the maximum width of a text label |
|
78 |
||
2210 | 79 |
levelOfLastItem <Integer> keeps the level of the last item; |
80 |
in case of a delete last items from list |
|
81 |
we know were to redraw lines from |
|
2229 | 82 |
|
83 |
autoScrollHorizontal <Boolean> true, than automatically scroll horizontal upto |
|
84 |
the text label of the current selected line. |
|
85 |
||
86 |
expandOnSelect <Boolean> true, than the item selected by a buttonPress |
|
87 |
event will be immediately expanded. |
|
88 |
||
1757 | 89 |
[author:] |
90 |
Claus Atzkern |
|
91 |
||
92 |
[see also:] |
|
93 |
ListModelView |
|
94 |
SelectionInListModelView |
|
1390 | 95 |
HierarchicalList |
96 |
HierarchicalItem |
|
97 |
" |
|
1757 | 98 |
! |
99 |
||
100 |
examples |
|
101 |
" |
|
1916 | 102 |
show a hierarchical list |
1757 | 103 |
[exBegin] |
104 |
|top sel list item| |
|
105 |
||
106 |
list := HierarchicalList new. |
|
107 |
item := HierarchicalItem::Example labeled:'Root Item'. |
|
108 |
||
109 |
item expand. |
|
110 |
list showRoot:false. |
|
111 |
list root:item. |
|
112 |
||
113 |
top := StandardSystemView new; extent:300@300. |
|
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
114 |
sel := ScrollableView for:HierarchicalListView miniScrollerH:true |
1757 | 115 |
origin:0.0@0.0 corner:1.0@1.0 in:top. |
116 |
||
117 |
sel list:list. |
|
118 |
sel multipleSelectOk:true. |
|
119 |
||
120 |
sel doubleClickAction:[:i| (list at:i) toggleExpand ]. |
|
121 |
sel indicatorAction:[:i| (list at:i) toggleExpand ]. |
|
122 |
||
123 |
top open. |
|
124 |
[exEnd] |
|
125 |
||
126 |
||
1916 | 127 |
show a hierarchical list; open an editor on reselect a |
128 |
line with label is a string. |
|
129 |
||
130 |
[exBegin] |
|
131 |
|top sel list item| |
|
132 |
||
133 |
list := HierarchicalList new. |
|
134 |
item := HierarchicalItem::Example labeled:'Root Item'. |
|
135 |
||
136 |
item expand. |
|
137 |
list showRoot:false. |
|
138 |
list root:item. |
|
139 |
||
140 |
top := StandardSystemView new; extent:300@300. |
|
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
141 |
sel := ScrollableView for:HierarchicalListView miniScrollerH:true |
1916 | 142 |
origin:0.0@0.0 corner:1.0@1.0 in:top. |
143 |
||
144 |
sel list:list. |
|
145 |
||
146 |
sel openEditorAction:[:ln :aGC| |field item| |
|
147 |
item := list at:ln. |
|
148 |
||
149 |
item label isString ifFalse:[ |
|
150 |
field := nil |
|
151 |
] ifTrue:[ |
|
152 |
field := EditField new. |
|
153 |
field level:0. |
|
154 |
field acceptOnLostFocus:true. |
|
155 |
field acceptAction:[:x| item label:(field contents) ]. |
|
156 |
field font:(aGC font). |
|
157 |
field contents:(item label). |
|
158 |
]. |
|
159 |
field |
|
160 |
]. |
|
161 |
||
162 |
sel multipleSelectOk:true. |
|
163 |
||
164 |
sel doubleClickAction:[:i| (list at:i) toggleExpand ]. |
|
165 |
sel indicatorAction:[:i| (list at:i) toggleExpand ]. |
|
166 |
||
167 |
top open. |
|
168 |
[exEnd] |
|
169 |
||
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
170 |
[exBegin] |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
171 |
|top sel list item| |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
172 |
|
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
173 |
list := HierarchicalList new. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
174 |
item := HierarchicalItem::Example labeled:'Root Item'. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
175 |
|
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
176 |
item expand. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
177 |
list showRoot:false. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
178 |
list root:item. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
179 |
|
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
180 |
top := StandardSystemView new; extent:300@300. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
181 |
sel := ScrollableView for:HierarchicalListView miniScrollerH:true |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
182 |
origin:0.0@0.0 corner:1.0@1.0 in:top. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
183 |
|
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
184 |
sel list:list. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
185 |
sel multipleSelectOk:true. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
186 |
sel alignTextRight:true. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
187 |
sel doubleClickAction:[:i| (list at:i) toggleExpand ]. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
188 |
sel indicatorAction:[:i| (list at:i) toggleExpand ]. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
189 |
|
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
190 |
top open. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
191 |
[exBegin] |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
192 |
|
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
193 |
|
1757 | 194 |
" |
1390 | 195 |
! ! |
196 |
||
197 |
!HierarchicalListView class methodsFor:'resources'! |
|
198 |
||
199 |
closeIndicator |
|
2335 | 200 |
"This resource specification was automatically generated |
201 |
by the ImageEditor of ST/X." |
|
202 |
||
203 |
"Do not manually edit this!! If it is corrupted, |
|
204 |
the ImageEditor may not be able to read the specification." |
|
1390 | 205 |
|
2335 | 206 |
" |
207 |
self closeIndicator inspect |
|
208 |
ImageEditor openOnClass:self andSelector:#closeIndicator |
|
209 |
Icon flushCachedIcons |
|
210 |
" |
|
1390 | 211 |
|
2335 | 212 |
<resource: #image> |
213 |
||
214 |
^Icon |
|
215 |
constantNamed:#'HierarchicalListView class closeIndicator' |
|
216 |
ifAbsentPut:[(Depth2Image new) width: 9; height: 9; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'UUU@Z*)@Z")@Z")@X@I-Z")@Z")KZ*)@UUU;') ; colorMapFromArray:#[0 0 0 128 128 128 255 255 255]; yourself] |
|
1390 | 217 |
! |
218 |
||
1757 | 219 |
collapsedIcon |
2335 | 220 |
"This resource specification was automatically generated |
221 |
by the ImageEditor of ST/X." |
|
222 |
||
223 |
"Do not manually edit this!! If it is corrupted, |
|
224 |
the ImageEditor may not be able to read the specification." |
|
225 |
||
1757 | 226 |
" |
2335 | 227 |
self collapsedIcon inspect |
228 |
ImageEditor openOnClass:self andSelector:#collapsedIcon |
|
229 |
Icon flushCachedIcons |
|
230 |
" |
|
1390 | 231 |
|
2335 | 232 |
<resource: #image> |
233 |
||
234 |
^Icon |
|
235 |
constantNamed:#'HierarchicalListView class collapsedIcon' |
|
236 |
ifAbsentPut:[(Depth2Image new) width: 16; height: 16; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@@@@@@@@@@@@@@@@UP@@@@@@@@EUUUPAUUUT@UUUU@EUUUPAUUUT@UUUU@@@@@@@@@@@@@@@@@@@@@@@@a') ; colorMapFromArray:#[0 0 0 255 255 0]; mask:((ImageMask new) width: 16; height: 16; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@@O@A>@O?<??3??O?<??3??O?<??0@@@@@@@@b') ; yourself); yourself] |
|
1390 | 237 |
! |
238 |
||
239 |
emptyIcon |
|
2335 | 240 |
"This resource specification was automatically generated |
241 |
by the ImageEditor of ST/X." |
|
242 |
||
243 |
"Do not manually edit this!! If it is corrupted, |
|
244 |
the ImageEditor may not be able to read the specification." |
|
245 |
||
1390 | 246 |
" |
2335 | 247 |
self emptyIcon inspect |
248 |
ImageEditor openOnClass:self andSelector:#emptyIcon |
|
249 |
Icon flushCachedIcons |
|
250 |
" |
|
1390 | 251 |
|
2335 | 252 |
<resource: #image> |
253 |
||
254 |
^Icon |
|
255 |
constantNamed:#'HierarchicalListView class emptyIcon' |
|
2336 | 256 |
ifAbsentPut:[(Depth2Image new) width: 16; height: 16; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@@@@@@@@@@EUTP@AUUE@@UUP@@EUUU@AUUUP@UUUT@EUUU@AUUUP@UUUT@@@@@@@@@@@@@@@@@@@@@@@@a') ; colorMapFromArray:#[0 0 0 255 255 255]; mask:((ImageMask new) width: 16; height: 16; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@O?@?>C?<O?8??#?>O?8??#?>O?8?? @@@@@@@@b') ; yourself); yourself] |
1390 | 257 |
! |
258 |
||
259 |
expandedIcon |
|
2335 | 260 |
"This resource specification was automatically generated |
261 |
by the ImageEditor of ST/X." |
|
262 |
||
263 |
"Do not manually edit this!! If it is corrupted, |
|
264 |
the ImageEditor may not be able to read the specification." |
|
265 |
||
1390 | 266 |
" |
2335 | 267 |
self expandedIcon inspect |
268 |
ImageEditor openOnClass:self andSelector:#expandedIcon |
|
269 |
Icon flushCachedIcons |
|
270 |
" |
|
1390 | 271 |
|
2335 | 272 |
<resource: #image> |
273 |
||
274 |
^Icon |
|
275 |
constantNamed:#'HierarchicalListView class expandedIcon' |
|
276 |
ifAbsentPut:[(Depth2Image new) width: 16; height: 16; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@@@@@@@@@@@@@@@@UP@@@UU@@@EUUUPA@@@@@R*** B***(@***(@****@@@@@@@@@@@@@@@@@@@@@@@@a') ; colorMapFromArray:#[0 0 0 179 179 179 255 255 0]; mask:((ImageMask new) width: 16; height: 16; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@@O@A>@O?<??3???????;??/?<??0@@@@@@@@b') ; yourself); yourself] |
|
1390 | 277 |
! |
278 |
||
1757 | 279 |
openIndicator |
2335 | 280 |
"This resource specification was automatically generated |
281 |
by the ImageEditor of ST/X." |
|
282 |
||
283 |
"Do not manually edit this!! If it is corrupted, |
|
284 |
the ImageEditor may not be able to read the specification." |
|
1757 | 285 |
|
2335 | 286 |
" |
287 |
self openIndicator inspect |
|
288 |
ImageEditor openOnClass:self andSelector:#openIndicator |
|
289 |
Icon flushCachedIcons |
|
290 |
" |
|
1757 | 291 |
|
2335 | 292 |
<resource: #image> |
293 |
||
294 |
^Icon |
|
295 |
constantNamed:#'HierarchicalListView class openIndicator' |
|
296 |
ifAbsentPut:[(Depth2Image new) width: 9; height: 9; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'UUU@Z*)@Z*)(Z*)HX@I@Z*)@Z*)@Z*)@UUU.') ; colorMapFromArray:#[0 0 0 128 128 128 255 255 255]; yourself] |
|
1390 | 297 |
! ! |
298 |
||
299 |
!HierarchicalListView methodsFor:'accessing'! |
|
300 |
||
1843 | 301 |
font:aFont |
2307 | 302 |
"set a new font; if the font changed, all my items |
303 |
has to clear their cashed width and height |
|
1843 | 304 |
" |
305 |
|root| |
|
306 |
||
307 |
(aFont isNil or:[aFont = font]) ifFalse:[ |
|
308 |
(list notNil and:[(root := list root) notNil]) ifTrue:[ |
|
309 |
root fontChanged |
|
310 |
]. |
|
311 |
super font:aFont |
|
312 |
]. |
|
313 |
! |
|
314 |
||
1390 | 315 |
list:aList |
316 |
aList notNil ifTrue:[ |
|
317 |
showRoot := aList showRoot |
|
318 |
]. |
|
319 |
super list:aList |
|
1897
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
320 |
! |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
321 |
|
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
322 |
parentToChildInset |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
323 |
"returns the computed inset between parent / child |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
324 |
" |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
325 |
^ imageInset + imageWidth |
1390 | 326 |
! ! |
327 |
||
2224 | 328 |
!HierarchicalListView methodsFor:'accessing-behavior'! |
329 |
||
330 |
autoScrollHorizontal |
|
331 |
"true, than automatically scroll horizontal upto the text label |
|
332 |
of the current selected line. |
|
333 |
" |
|
334 |
^ autoScrollHorizontal ? false |
|
335 |
! |
|
336 |
||
337 |
autoScrollHorizontal:aBoolean |
|
338 |
"true, than automatically scroll horizontal upto the text label |
|
339 |
of the current selected line. |
|
340 |
" |
|
341 |
autoScrollHorizontal := aBoolean. |
|
342 |
! |
|
343 |
||
344 |
expandOnSelect |
|
345 |
"true, than the item selected by a buttonPress event will |
|
346 |
be immediately expanded. |
|
347 |
" |
|
348 |
^ expandOnSelect |
|
349 |
! |
|
350 |
||
351 |
expandOnSelect:aBoolean |
|
352 |
"true, than the item selected by a buttonPress event will |
|
353 |
be immediately expanded. |
|
354 |
" |
|
355 |
expandOnSelect := aBoolean. |
|
356 |
! ! |
|
357 |
||
1818 | 358 |
!HierarchicalListView methodsFor:'accessing-colors'! |
1390 | 359 |
|
360 |
lineColor |
|
2307 | 361 |
"get the color of the horizontal and vertical lines |
1390 | 362 |
" |
363 |
^ lineColor |
|
364 |
! |
|
365 |
||
366 |
lineColor:aColor |
|
2307 | 367 |
"set the color of the horizontal and vertical lines |
1390 | 368 |
" |
369 |
(aColor notNil and:[aColor ~= lineColor]) ifTrue:[ |
|
370 |
lineColor := aColor. |
|
371 |
||
372 |
shown ifTrue:[ |
|
2099 | 373 |
lineColor := lineColor onDevice:device. |
2307 | 374 |
showLines ifTrue:[ self invalidate ] |
1390 | 375 |
] |
2307 | 376 |
]. |
1390 | 377 |
! ! |
378 |
||
1818 | 379 |
!HierarchicalListView methodsFor:'accessing-look'! |
1390 | 380 |
|
1568 | 381 |
alignTextRight |
382 |
"align the text right |
|
383 |
" |
|
384 |
^ alignTextRight |
|
385 |
! |
|
386 |
||
1757 | 387 |
alignTextRight:aBool |
388 |
"align the text right |
|
389 |
" |
|
390 |
alignTextRight := aBool ? false. |
|
391 |
! |
|
1568 | 392 |
|
1904 | 393 |
alignTextRightX |
394 |
"returns the minimum used text inset, if text is aligned right. |
|
395 |
" |
|
396 |
^ alignTextRightX |
|
397 |
! |
|
398 |
||
399 |
alignTextRightX:aNumber |
|
400 |
"set the minimum used text inset, if text is aligned right. |
|
401 |
" |
|
402 |
aNumber > self parentToChildInset ifTrue:[ |
|
403 |
alignTextRightX := aNumber. |
|
404 |
||
405 |
(alignTextRight and:[widthOfContents notNil]) ifTrue:[ |
|
406 |
widthOfContents := alignTextRightX + maxWidthOfText. |
|
407 |
||
408 |
shown ifTrue:[ |
|
409 |
self invalidate. |
|
410 |
self contentsChanged. |
|
411 |
] |
|
412 |
] |
|
413 |
]. |
|
414 |
! |
|
415 |
||
2094 | 416 |
iconAt:aKey ifAbsentPut:aBlock |
417 |
"return the icon stored under a key; if not present,the |
|
418 |
result of the block if not nil is stored under the key |
|
419 |
and returned. |
|
420 |
" |
|
421 |
|icon| |
|
422 |
||
423 |
icon := icons at:aKey ifAbsent:nil. |
|
2307 | 424 |
icon notNil ifTrue:[^ icon]. |
2094 | 425 |
|
426 |
icon := aBlock value. |
|
2307 | 427 |
icon isNil ifTrue:[^ nil]. |
2094 | 428 |
|
429 |
realized ifTrue:[ |
|
430 |
icon := self imageOnDevice:icon |
|
431 |
]. |
|
432 |
icons at:aKey put:icon. |
|
433 |
^ icon |
|
434 |
! |
|
435 |
||
1390 | 436 |
registerKeysAndIcons:aDictionary |
437 |
"register icons by key and value derived from a directory |
|
438 |
" |
|
439 |
|image| |
|
440 |
||
441 |
(aDictionary isNil or:[aDictionary isEmpty]) ifTrue:[ |
|
442 |
^ self |
|
443 |
]. |
|
444 |
||
445 |
aDictionary keysAndValuesDo:[:aKey :anImage| |
|
446 |
(image := self imageOnDevice:anImage) notNil ifTrue:[ |
|
447 |
icons at:aKey put:image |
|
1746 | 448 |
] ifFalse:[ |
449 |
icons removeKey:aKey ifAbsent:nil |
|
1390 | 450 |
] |
451 |
] |
|
452 |
||
453 |
! |
|
454 |
||
455 |
showLeftIndicators |
|
456 |
"show or hide the indicators for the most left items |
|
457 |
" |
|
458 |
^ showLeftIndicators |
|
459 |
||
460 |
! |
|
461 |
||
2307 | 462 |
showLeftIndicators:aBoolean |
1390 | 463 |
"show or hide the indicators for the most left items |
464 |
" |
|
2307 | 465 |
aBoolean ~~ showLeftIndicators ifTrue:[ |
466 |
showLeftIndicators := aBoolean. |
|
467 |
shown ifTrue:[ self invalidate ]. |
|
1390 | 468 |
]. |
469 |
! |
|
470 |
||
471 |
showLines |
|
472 |
"returns true if lines are shown |
|
473 |
" |
|
2307 | 474 |
^ showLines |
1390 | 475 |
! |
476 |
||
2307 | 477 |
showLines:aBoolean |
1390 | 478 |
"show or hide lines |
479 |
" |
|
2307 | 480 |
aBoolean ~~ showLines ifTrue:[ |
481 |
showLines := aBoolean. |
|
482 |
shown ifTrue:[ self invalidate ]. |
|
1390 | 483 |
]. |
484 |
! |
|
485 |
||
486 |
useDefaultIcons |
|
487 |
"use the default icons if no icon for an item is specified; |
|
488 |
** default: true |
|
489 |
" |
|
490 |
^ useDefaultIcons |
|
491 |
! |
|
492 |
||
2307 | 493 |
useDefaultIcons:aBoolean |
1390 | 494 |
"use the default icons if no icon for an item is specified; |
495 |
** default: true |
|
496 |
" |
|
2307 | 497 |
useDefaultIcons ~~ aBoolean ifTrue:[ |
498 |
useDefaultIcons := aBoolean. |
|
499 |
shown ifTrue:[ self invalidate ]. |
|
1390 | 500 |
] |
501 |
! ! |
|
502 |
||
503 |
!HierarchicalListView methodsFor:'actions'! |
|
504 |
||
505 |
indicatorAction |
|
506 |
"if the action is not nil, indicators are shown and a click on the indicator |
|
507 |
will evaluate the action with none or one argument, the index into the list |
|
508 |
" |
|
509 |
^ indicatorAction |
|
510 |
! |
|
511 |
||
512 |
indicatorAction:anAction |
|
513 |
"if the action is not nil, indicators are shown and a click on the indicator |
|
514 |
will evaluate the action with none or one argument, the index into the list |
|
515 |
" |
|
2312 | 516 |
|maxLevel contentsChgSize| |
517 |
||
518 |
(indicatorAction isNil) == (anAction isNil) ifTrue:[ |
|
519 |
indicatorAction := anAction. |
|
520 |
^ self |
|
521 |
]. |
|
1390 | 522 |
|
2312 | 523 |
(widthOfContents isNil or:[list size == 0]) ifTrue:[ |
524 |
indicatorAction := anAction. |
|
525 |
self invalidate. |
|
526 |
^ self |
|
527 |
]. |
|
528 |
||
529 |
"/ must recompute width of contents |
|
530 |
||
531 |
maxLevel := 0. |
|
532 |
list do:[:el| maxLevel := maxLevel max:(el level) ]. |
|
533 |
||
2327 | 534 |
contentsChgSize := self xVisibleOfIconAtLevel:maxLevel. |
1390 | 535 |
indicatorAction := anAction. |
2327 | 536 |
contentsChgSize := (self xVisibleOfIconAtLevel:maxLevel) - contentsChgSize. |
2312 | 537 |
widthOfContents := widthOfContents + contentsChgSize. |
1390 | 538 |
|
2312 | 539 |
self invalidate. |
540 |
contentsChgSize ~~ 0 ifTrue:[ self contentsChanged ]. |
|
1390 | 541 |
! ! |
542 |
||
543 |
!HierarchicalListView methodsFor:'change & update'! |
|
544 |
||
1782 | 545 |
indicatorPressedAt:aLnNr |
2224 | 546 |
"handle indicator pressed action; |
547 |
if the item changed expanded, we try to show all |
|
548 |
new visible children |
|
549 |
" |
|
550 |
|item expanded availY usedY vwOrgX vwOrgY idx| |
|
551 |
||
2307 | 552 |
indicatorAction isNil ifTrue:[^ self]. |
2224 | 553 |
|
554 |
item := list at:aLnNr ifAbsent:nil. |
|
2307 | 555 |
item isNil ifTrue:[^ self]. |
2224 | 556 |
|
557 |
item hasIndicator ifFalse:[^ self]. |
|
558 |
||
559 |
expanded := item isExpanded. |
|
560 |
indicatorAction valueWithOptionalArgument:aLnNr. |
|
561 |
(expanded or:[item isExpanded not]) ifTrue:[^ self]. |
|
1783
ffe767ea66ea
check whether children exists before calling indicatorPressed action
ca
parents:
1782
diff
changeset
|
562 |
|
2224 | 563 |
"/ compute the index of last child assigned to item |
564 |
||
565 |
idx := item numberOfVisibleChildren. "/ no visible children |
|
566 |
idx == 0 ifTrue:[^ self]. |
|
567 |
||
568 |
idx := aLnNr + idx. |
|
569 |
vwOrgY := viewOrigin y. |
|
570 |
availY := (self yVisibleOfLine:aLnNr) - margin. |
|
571 |
||
572 |
availY > margin ifTrue:[ |
|
573 |
usedY := (self yVisibleOfLine:(idx + 1)) - (height - margin - margin). |
|
574 |
||
575 |
usedY > 1 ifTrue:[ |
|
576 |
vwOrgY := vwOrgY + (usedY min:availY). |
|
577 |
]. |
|
578 |
]. |
|
579 |
vwOrgX := self computeViewOriginXat:aLnNr. |
|
580 |
||
581 |
self scrollTo:(vwOrgX @ vwOrgY). |
|
1782 | 582 |
! |
583 |
||
1390 | 584 |
lineChangedAt:aLnNr with:arg |
585 |
"line changed at position; check whether line height changed |
|
586 |
" |
|
587 |
|item |
|
2317 | 588 |
level "{ Class:SmallInteger }" |
1390 | 589 |
x0 "{ Class:SmallInteger }" |
590 |
x1 "{ Class:SmallInteger }" |
|
591 |
y0 "{ Class:SmallInteger }" |
|
592 |
y1 "{ Class:SmallInteger }" |
|
2303 | 593 |
yB "{ Class:SmallInteger }" |
1390 | 594 |
| |
595 |
||
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
596 |
item := list at:aLnNr ifAbsent:nil. |
2317 | 597 |
item isNil ifTrue:[^ self]. |
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
598 |
|
1399 | 599 |
(arg == #icon or:[arg == #hierarchy]) ifFalse:[ |
2224 | 600 |
super lineChangedAt:aLnNr with:arg. |
601 |
||
602 |
(arg ~~ #redraw and:[widthOfContents notNil]) ifTrue:[ |
|
2327 | 603 |
x0 := (self xVisibleOfTextAtLevel:(item level)) |
2353 | 604 |
+ (renderer widthFor:item) |
2229 | 605 |
+ (viewOrigin x). |
2224 | 606 |
|
607 |
x0 > widthOfContents ifTrue:[ |
|
608 |
widthOfContents := x0. |
|
609 |
self contentsChanged. |
|
610 |
] |
|
611 |
]. |
|
612 |
^ self |
|
1390 | 613 |
]. |
2317 | 614 |
level := item level. |
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
615 |
|
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
616 |
(alignTextRight and:[arg == #hierarchy]) ifTrue:[ |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
617 |
"/ must test whether alignTextRightX is enough |
2317 | 618 |
(item isExpanded and:[item hasChildren]) ifTrue:[ |
2327 | 619 |
x0 := self xVisibleOfIconAtLevel:(level + 2). |
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
620 |
|
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
621 |
alignTextRightX < x0 ifTrue:[ |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
622 |
alignTextRightX := x0. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
623 |
shown ifTrue:[ self invalidate ]. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
624 |
|
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
625 |
widthOfContents notNil ifTrue:[ |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
626 |
widthOfContents := alignTextRightX + maxWidthOfText. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
627 |
self contentsChanged. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
628 |
]. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
629 |
^ self. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
630 |
] |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
631 |
] |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
632 |
]. |
1568 | 633 |
shown ifFalse:[^ self]. |
634 |
||
2303 | 635 |
yB := height - margin. |
636 |
y0 := (self yVisibleOfLine:aLnNr) max:margin. |
|
637 |
y0 < yB ifFalse:[ ^ self ]. |
|
1390 | 638 |
|
2303 | 639 |
y1 := (self yVisibleOfLine:(aLnNr + 1)) min:yB. |
640 |
y1 > y0 ifFalse:[^ self]. |
|
1399 | 641 |
|
2327 | 642 |
x1 := (self xVisibleOfTextAtLevel:level) - 1. |
2317 | 643 |
x1 > margin ifFalse:[^ self]. |
1390 | 644 |
|
2317 | 645 |
arg == #hierarchy ifTrue:[ level := level - 1 ]. |
2303 | 646 |
|
2327 | 647 |
x0 := (self xVisibleOfIconAtLevel:level) max:margin. |
2317 | 648 |
x1 := x1 min:(width - margin). |
2303 | 649 |
|
2317 | 650 |
x0 < x1 ifTrue:[ |
651 |
self invalidate:(Rectangle left:x0 top:y0 width:(x1 - x0) height:(y1 - y0)) |
|
652 |
repairNow:false. |
|
2303 | 653 |
]. |
1976
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
654 |
! |
1390 | 655 |
|
1976
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
656 |
listChangedInsert:firstAddedIndex nItems:nLines |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
657 |
"must draw vertical lines above the added items |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
658 |
" |
2210 | 659 |
|item level yTop yBot xLft start maxY| |
1390 | 660 |
|
1976
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
661 |
super listChangedInsert:firstAddedIndex nItems:nLines. |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
662 |
|
2210 | 663 |
item := list last. |
664 |
levelOfLastItem := item level. |
|
665 |
||
1976
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
666 |
( shown |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
667 |
and:[showLines |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
668 |
and:[firstAddedIndex > 1 |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
669 |
and:[nLines ~~ 0 |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
670 |
and:[(item := list at:firstAddedIndex ifAbsent:nil) notNil |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
671 |
and:[(level := item level) > 1]]]]] |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
672 |
) ifFalse:[ |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
673 |
^ self. |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
674 |
]. |
2327 | 675 |
xLft := (self xVisibleOfIconAtLevel:(level - 1)) + (imageWidth // 2) - 1. |
1390 | 676 |
|
1976
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
677 |
(xLft > margin and:[xLft < (width - margin)]) ifFalse:[ |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
678 |
^ self |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
679 |
]. |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
680 |
start := firstAddedIndex - 1. |
1390 | 681 |
|
1976
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
682 |
start to:1 by:-1 do:[:i| |el| |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
683 |
el := list at:i. |
1399 | 684 |
|
1976
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
685 |
el level <= level ifTrue:[ |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
686 |
i == start ifTrue:[^ self]. |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
687 |
|
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
688 |
yTop := (self yVisibleOfLine:i + 1) max:margin. |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
689 |
maxY := height - margin. |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
690 |
|
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
691 |
yTop < maxY ifTrue:[ |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
692 |
yBot := (self yVisibleOfLine:firstAddedIndex) - 1 min:maxY. |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
693 |
self invalidate:(Rectangle left:xLft top:yTop width:3 height:(yBot - yTop)) |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
694 |
]. |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
695 |
^ self |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
696 |
] |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
697 |
]. |
1390 | 698 |
! |
699 |
||
2208 | 700 |
listChangedRemove:aStart toIndex:aStop |
701 |
"test whether last items are deleted; |
|
702 |
than we have to redraw lines because of different levels |
|
703 |
" |
|
2210 | 704 |
|listSize index y0 searchLevel| |
2208 | 705 |
|
2210 | 706 |
listSize := list size. |
707 |
searchLevel := levelOfLastItem. |
|
2208 | 708 |
|
2307 | 709 |
listSize == 0 ifTrue:[ levelOfLastItem := 1 ] |
710 |
ifFalse:[ levelOfLastItem := list last level ]. |
|
2208 | 711 |
|
2307 | 712 |
(shown and:[showLines and:[listSize ~~ 0 and:[aStart > listSize]]]) ifTrue:[ |
2210 | 713 |
index := list findLast:[:el| el level <= searchLevel ]. |
2208 | 714 |
|
715 |
(index ~~ 0 and:[index < listSize]) ifTrue:[ |
|
716 |
y0 := (self yVisibleOfLine:index) max:margin. |
|
717 |
self invalidateX:0 y:y0 width:width height:(height - margin - y0). |
|
718 |
] |
|
719 |
]. |
|
720 |
^ super listChangedRemove:aStart toIndex:aStop |
|
721 |
! |
|
722 |
||
1390 | 723 |
update:what with:aPara from:chgObj |
724 |
"get the status of <showRoot> from the list |
|
725 |
" |
|
726 |
chgObj == list ifTrue:[ |
|
727 |
showRoot ~~ list showRoot ifTrue:[ |
|
728 |
showRoot := list showRoot. |
|
729 |
self invalidate. |
|
730 |
] |
|
731 |
]. |
|
732 |
super update:what with:aPara from:chgObj |
|
733 |
! ! |
|
734 |
||
735 |
!HierarchicalListView methodsFor:'drawing basics'! |
|
736 |
||
1568 | 737 |
drawElementsFrom:start to:stop x:xLeft y:yT w:w |
1390 | 738 |
"draw the items between start to stop without clearing the background |
739 |
" |
|
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
740 |
|item prevItem parent icon showIndc showIcon showText nxtPrnt extent |
1568 | 741 |
yTop "{ Class:SmallInteger }" |
742 |
yCtr "{ Class:SmallInteger }" |
|
743 |
yBot "{ Class:SmallInteger }" |
|
1390 | 744 |
|
1568 | 745 |
xIndc "{ Class:SmallInteger }" |
746 |
xIcon "{ Class:SmallInteger }" |
|
747 |
xText "{ Class:SmallInteger }" |
|
748 |
xL "{ Class:SmallInteger }" |
|
749 |
xR "{ Class:SmallInteger }" |
|
750 |
height "{ Class:SmallInteger }" |
|
1390 | 751 |
|
1568 | 752 |
widthLvl "{ Class:SmallInteger }" |
753 |
insetTxt "{ Class:SmallInteger }" |
|
1390 | 754 |
|
1568 | 755 |
offIndcX "{ Class:SmallInteger }" |
756 |
offIndcY "{ Class:SmallInteger }" |
|
757 |
offIconX "{ Class:SmallInteger }" |
|
1390 | 758 |
| |
2311 | 759 |
widthLvl := self parentToChildInset. |
1390 | 760 |
insetTxt := textStartLeft + imageWidth. |
1568 | 761 |
xL := xLeft. |
762 |
xR := xL + w. |
|
763 |
||
764 |
alignTextRight ifTrue:[ |
|
765 |
xText := alignTextRightX - (viewOrigin x). |
|
766 |
showText := xText < xR. |
|
767 |
]. |
|
768 |
||
2327 | 769 |
offIconX := self xVisibleOfIconAtLevel:0. |
1390 | 770 |
showIndc := false. |
771 |
||
772 |
indicatorAction notNil ifTrue:[ |
|
2049 | 773 |
offIndcX := offIndcY := 0. |
774 |
openIndicator notNil ifTrue:[ |
|
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
775 |
extent := openIndicator extent // 2. |
2049 | 776 |
offIndcX := imageWidth // 2 - widthLvl. |
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
777 |
offIndcX := offIndcX - extent x. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
778 |
offIndcY := extent y. |
2049 | 779 |
] |
1390 | 780 |
]. |
781 |
||
782 |
showLines ifTrue:[ |
|
1399 | 783 |
self drawLinesFrom:start to:stop x:xL y:yT toX:xR |
1390 | 784 |
]. |
785 |
||
786 |
parent := 4711. "/ to force a recompute |
|
787 |
prevItem := 4711. "/ to force a recomputation of the level |
|
1399 | 788 |
yBot := yT. |
1756 | 789 |
xIcon := offIconX. |
1390 | 790 |
|
791 |
start to:stop do:[:anIndex| |
|
792 |
(item := list at:anIndex ifAbsent:nil) isNil ifTrue:[ |
|
793 |
^ self "/ list changed |
|
794 |
]. |
|
795 |
yTop := yBot. |
|
796 |
yBot := self yVisibleOfLine:(anIndex + 1). |
|
1532
56e0fafc4349
change display protocol for item
Claus Gittinger <cg@exept.de>
parents:
1509
diff
changeset
|
797 |
height := yBot - yTop. |
56e0fafc4349
change display protocol for item
Claus Gittinger <cg@exept.de>
parents:
1509
diff
changeset
|
798 |
|
56e0fafc4349
change display protocol for item
Claus Gittinger <cg@exept.de>
parents:
1509
diff
changeset
|
799 |
yCtr := yTop + (height // 2). |
1390 | 800 |
|
801 |
(nxtPrnt := item parent) ~~ parent ifTrue:[ |
|
802 |
parent := nxtPrnt. |
|
803 |
xIcon := prevItem == parent ifTrue:[xIcon + widthLvl] |
|
804 |
ifFalse:[item level * widthLvl + offIconX]. |
|
805 |
||
1568 | 806 |
alignTextRight ifFalse:[ |
807 |
xText := xIcon + insetTxt. |
|
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
808 |
showText := (xText < xR). |
1568 | 809 |
]. |
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
810 |
showIcon := (xIcon < xR and:[xText > xL]). |
1390 | 811 |
|
812 |
indicatorAction notNil ifTrue:[ |
|
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
813 |
xIndc := xIcon + offIndcX. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
814 |
showIndc := (xIcon > xL and:[xIndc < xR]). |
1390 | 815 |
|
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
816 |
showIndc ifTrue:[ |
1756 | 817 |
showIndc := parent notNil or:[showLeftIndicators] |
818 |
] |
|
1390 | 819 |
] |
820 |
]. |
|
821 |
||
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
822 |
(showIcon and:[(icon := self validateDrawableIconFor:item) notNil]) ifTrue:[ |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
823 |
(xIcon + icon width) > xL ifTrue:[ |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
824 |
icon displayOn:self x:xIcon y:(yCtr - (icon height // 2)) |
1568 | 825 |
] |
1390 | 826 |
]. |
827 |
||
828 |
showText ifTrue:[ |
|
1532
56e0fafc4349
change display protocol for item
Claus Gittinger <cg@exept.de>
parents:
1509
diff
changeset
|
829 |
self drawLabelAt:anIndex x:xText y:yTop h:height |
1390 | 830 |
]. |
2201
aa74fa6137a5
make indicator dependent on hasIndicator and not hasChildren
ca
parents:
2181
diff
changeset
|
831 |
(showIndc and:[item hasIndicator]) ifTrue:[ |
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
832 |
item isExpanded ifTrue:[icon := openIndicator ] |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
833 |
ifFalse:[icon := closeIndicator]. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
834 |
|
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
835 |
icon displayOn:self x:xIndc y:(yCtr - offIndcY) |
1390 | 836 |
]. |
837 |
prevItem := item. |
|
838 |
] |
|
839 |
! |
|
840 |
||
1399 | 841 |
drawLinesFrom:start to:stop x:xL y:yT toX:xR |
1390 | 842 |
"draw the lines between start to stop without clearing the background |
843 |
" |
|
844 |
|item prevItem parent p1 p2 showVLines showHLine lv nxtPrnt |
|
845 |
showRootNot isFirst buildInArray |
|
846 |
||
847 |
x "{ Class:SmallInteger }" |
|
1570 | 848 |
xText "{ Class:SmallInteger }" |
849 |
||
1390 | 850 |
y "{ Class:SmallInteger }" |
851 |
yTop "{ Class:SmallInteger }" |
|
852 |
yBot "{ Class:SmallInteger }" |
|
853 |
yCtr "{ Class:SmallInteger }" |
|
854 |
||
855 |
begHLnY "{ Class:SmallInteger }" |
|
856 |
runHLnY "{ Class:SmallInteger }" |
|
857 |
begHLnX "{ Class:SmallInteger }" |
|
858 |
endHLnX "{ Class:SmallInteger }" |
|
859 |
||
1897
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
860 |
widthLvl "{ Class:SmallInteger }" |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
861 |
offsHLnX "{ Class:SmallInteger }" |
1390 | 862 |
|
1897
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
863 |
level "{ Class:SmallInteger }" |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
864 |
startLvI "{ Class:SmallInteger }" |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
865 |
startLvX "{ Class:SmallInteger }" |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
866 |
limitLvI "{ Class:SmallInteger }" |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
867 |
limitLvX "{ Class:SmallInteger }" |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
868 |
imgHWdt "{ Class:SmallInteger }" |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
869 |
minXVLine "{ Class:SmallInteger }" |
1390 | 870 |
| |
1792
26aa6dc38278
draw vertical line not into icon if no children defined
ca
parents:
1784
diff
changeset
|
871 |
imgHWdt := imageWidth // 2. |
2311 | 872 |
widthLvl := self parentToChildInset. |
2327 | 873 |
offsHLnX := imgHWdt + (self xVisibleOfIconAtLevel:-1). |
1390 | 874 |
|
875 |
parent := 4711. "/ to force a recompute |
|
876 |
prevItem := 4711. "/ to force a recomputation of the level |
|
877 |
||
878 |
self setMaskOrigin:(self viewOrigin + (0 @ 1) \\ (lineMask extent)). |
|
879 |
self paint:lineColor on:bgColor. |
|
880 |
self mask:lineMask. |
|
881 |
startLvI := self smallestLevelBetween:start and:stop. |
|
2327 | 882 |
startLvX := self xVisibleOfIconAtLevel:startLvI. |
1390 | 883 |
limitLvI := 2. |
884 |
limitLvX := limitLvI * widthLvl + offsHLnX. |
|
885 |
||
1897
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
886 |
showRoot ifFalse:[ |
2327 | 887 |
minXVLine := (self xVisibleOfIconAtLevel:2) - 2. "/ tolerance |
1897
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
888 |
] ifTrue:[ |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
889 |
minXVLine := 0 |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
890 |
]. |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
891 |
|
1567 | 892 |
showRootNot := showRoot not. |
893 |
yBot := yT. |
|
894 |
begHLnY := runHLnY := yT. |
|
1756 | 895 |
endHLnX := limitLvX. |
896 |
level := 1. |
|
1390 | 897 |
|
1570 | 898 |
alignTextRight ifTrue:[ |
899 |
xText := alignTextRightX - (viewOrigin x) - textStartLeft. |
|
900 |
]. |
|
901 |
||
1390 | 902 |
start to:stop do:[:anIndex| |
903 |
(item := list at:anIndex ifAbsent:nil) isNil ifTrue:[ |
|
904 |
^ self mask:nil "/ list changed |
|
905 |
]. |
|
906 |
yTop := yBot. |
|
907 |
yBot := self yVisibleOfLine:(anIndex + 1). |
|
908 |
yCtr := yTop + (yBot - yTop // 2). |
|
909 |
anIndex == 1 ifTrue:[ begHLnY := runHLnY := yCtr ]. |
|
910 |
||
911 |
(nxtPrnt := item parent) ~~ parent ifTrue:[ |
|
912 |
parent := nxtPrnt. |
|
913 |
||
914 |
prevItem == parent ifTrue:[ |
|
1567 | 915 |
level := level + 1. |
1390 | 916 |
begHLnX := endHLnX. |
917 |
] ifFalse:[ |
|
918 |
level := item level. |
|
1567 | 919 |
begHLnX := level * widthLvl + offsHLnX. |
1390 | 920 |
]. |
921 |
||
922 |
isFirst := parent isNil or:[(showRootNot and:[level == 2])]. |
|
923 |
endHLnX := begHLnX + widthLvl. |
|
1399 | 924 |
showVLines := begHLnX >= xL and:[level > 1]. |
1570 | 925 |
|
926 |
alignTextRight ifFalse:[ |
|
927 |
xText := endHLnX + (widthLvl // 2). |
|
928 |
]. |
|
929 |
showHLine := (xL < xText and:[xR > begHLnX]). |
|
1390 | 930 |
|
931 |
(showHLine and:[isFirst]) ifTrue:[ |
|
932 |
showHLine := showLeftIndicators and:[indicatorAction notNil] |
|
933 |
] |
|
934 |
]. |
|
935 |
||
936 |
showHLine ifTrue:[ |
|
1570 | 937 |
item drawHorizontalLineUpToText ifTrue:[ |
938 |
p1 := xText |
|
939 |
] ifFalse:[ |
|
1792
26aa6dc38278
draw vertical line not into icon if no children defined
ca
parents:
1784
diff
changeset
|
940 |
item hasChildren ifTrue:[ |
26aa6dc38278
draw vertical line not into icon if no children defined
ca
parents:
1784
diff
changeset
|
941 |
p1 := endHLnX. |
26aa6dc38278
draw vertical line not into icon if no children defined
ca
parents:
1784
diff
changeset
|
942 |
] ifFalse:[ |
1897
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
943 |
(showRoot not and:[item parent isRootItem]) ifTrue:[ |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
944 |
p1 := xL - 1 "/ do not draw the horizontal line |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
945 |
] ifFalse:[ |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
946 |
p1 := begHLnX + imgHWdt |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
947 |
] |
1792
26aa6dc38278
draw vertical line not into icon if no children defined
ca
parents:
1784
diff
changeset
|
948 |
] |
1570 | 949 |
]. |
1792
26aa6dc38278
draw vertical line not into icon if no children defined
ca
parents:
1784
diff
changeset
|
950 |
xL < p1 ifTrue:[ |
1570 | 951 |
self displayLineFromX:begHLnX y:yCtr toX:p1 y:yCtr |
952 |
] |
|
1390 | 953 |
]. |
954 |
||
955 |
showVLines ifTrue:[ |
|
956 |
y := (parent last == item) ifTrue:[yCtr] ifFalse:[yBot]. |
|
957 |
x := begHLnX. |
|
958 |
p2 := parent. |
|
959 |
lv := level - 1. |
|
1897
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
960 |
|
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
961 |
x >= minXVLine ifTrue:[ |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
962 |
self displayLineFromX:x y:runHLnY toX:x y:y. |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
963 |
]. |
1390 | 964 |
|
965 |
[((p1 := p2 parent) notNil and:[(x := x - widthLvl) >= limitLvX])] whileTrue:[ |
|
1399 | 966 |
(p1 last ~~ p2 and:[x <= xR]) ifTrue:[ |
1390 | 967 |
x >= startLvX ifTrue:[ |
1897
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
968 |
x >= minXVLine ifTrue:[ |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
969 |
self displayLineFromX:x y:(yTop - 1) toX:x y:yBot |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
970 |
] |
1390 | 971 |
] ifFalse:[ |
1567 | 972 |
buildInArray isNil ifTrue:[buildInArray := Array new:startLvI]. |
1390 | 973 |
buildInArray at:lv put:yBot |
974 |
]. |
|
975 |
]. |
|
976 |
lv := lv - 1. |
|
977 |
p2 := p1 |
|
978 |
] |
|
979 |
]. |
|
980 |
prevItem := item. |
|
981 |
runHLnY := yCtr. |
|
982 |
]. |
|
983 |
||
984 |
"/ |
|
985 |
"/ draw outstanding verical lines to left |
|
986 |
"/ |
|
1897
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
987 |
x := minXVLine max:xL. |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
988 |
|
1567 | 989 |
(item isExpanded and:[item hasChildren]) ifTrue:[ |
1897
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
990 |
(endHLnX >= x and:[endHLnX <= xR]) ifTrue:[ |
1567 | 991 |
self displayLineFromX:endHLnX y:yCtr toX:endHLnX y:yBot. |
992 |
] |
|
1390 | 993 |
]. |
1567 | 994 |
|
995 |
buildInArray notNil ifTrue:[ |
|
996 |
x := limitLvX. |
|
997 |
y := begHLnY. |
|
1390 | 998 |
|
1567 | 999 |
limitLvI to:startLvI do:[:i| |
1597 | 1000 |
|yB| |
1596 | 1001 |
|
1597 | 1002 |
(yB := buildInArray at:i) notNil ifTrue:[ |
1897
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
1003 |
x >= minXVLine ifTrue:[ |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
1004 |
self displayLineFromX:x y:y toX:x y:yB |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
1005 |
] |
1567 | 1006 |
]. |
1007 |
x := x + widthLvl. |
|
1390 | 1008 |
] |
1009 |
]. |
|
1010 |
self mask:nil. |
|
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1011 |
! |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1012 |
|
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1013 |
validateDrawableIconFor:anItem |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1014 |
"returns the icon to be drawn for an item or nil |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1015 |
test the extent of the icopn; on error an exception is raised |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1016 |
" |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1017 |
|width needMore icon maxLevel startOfText| |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1018 |
|
2327 | 1019 |
icon := self iconFor:anItem. |
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1020 |
icon isNil ifTrue:[^ nil]. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1021 |
|
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1022 |
width := icon width. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1023 |
|
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1024 |
(constantHeight notNil and:[icon height > constantHeight]) ifTrue:[ |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1025 |
constantHeight := icon height + lineSpacing. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1026 |
self recomputeHeightOfContents. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1027 |
|
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1028 |
width <= imageWidth ifTrue:[ |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1029 |
self contentsChanged. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1030 |
StopRedrawSignal raise |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1031 |
]. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1032 |
] ifFalse:[ |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1033 |
width <= imageWidth ifTrue:[ ^ icon ]. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1034 |
]. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1035 |
|
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1036 |
needMore := width - imageWidth max:2. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1037 |
imageWidth := imageWidth + needMore. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1038 |
maxLevel := 1. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1039 |
|
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1040 |
list criticalDo:[ |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1041 |
list do:[:el| maxLevel := maxLevel max:(el level) ]. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1042 |
]. |
2327 | 1043 |
alignTextRightX := alignTextRightX max:(self xVisibleOfIconAtLevel:(maxLevel + 1)). |
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1044 |
|
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1045 |
widthOfContents notNil ifTrue:[ |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1046 |
alignTextRight ifTrue:[ |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1047 |
widthOfContents := alignTextRightX + maxWidthOfText |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1048 |
] ifFalse:[ |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1049 |
list showRoot ifFalse:[ maxLevel := maxLevel - 1 ]. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1050 |
widthOfContents := widthOfContents + (maxLevel * needMore) |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1051 |
]. |
2353 | 1052 |
width := renderer widthFor:anItem. |
2327 | 1053 |
startOfText := self xVisibleOfTextAtLevel:(anItem level). |
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1054 |
widthOfContents := widthOfContents max:(startOfText + width). |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1055 |
|
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1056 |
width > maxWidthOfText ifTrue:[ |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1057 |
maxWidthOfText := width |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1058 |
]. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1059 |
]. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1060 |
self contentsChanged. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1061 |
StopRedrawSignal raise. |
2353 | 1062 |
^ icon |
1390 | 1063 |
! ! |
1064 |
||
1065 |
!HierarchicalListView methodsFor:'event handling'! |
|
1066 |
||
1757 | 1067 |
buttonPress:button x:x y:y |
1068 |
"handle a button press event |
|
1069 |
" |
|
2313 | 1070 |
|line item x0 y0| |
2224 | 1071 |
|
1072 |
enabled ifFalse:[^ self]. |
|
2361 | 1073 |
self closeEditor. |
2224 | 1074 |
|
2313 | 1075 |
line := self yVisibleToLineNr:y. |
1076 |
line notNil ifTrue:[ |
|
1077 |
item := list at:line ifAbsent:nil. |
|
1078 |
item notNil ifTrue:[ |
|
2327 | 1079 |
x0 := self xVisibleOfTextAtLevel:(item level). |
2313 | 1080 |
|
1081 |
x >= x0 ifTrue:[ |
|
1082 |
y0 := self yVisibleOfLine:line. |
|
2224 | 1083 |
|
2313 | 1084 |
(item processButtonPress:button x:(x - x0) y:(y - y0)) == true ifTrue:[ |
1085 |
^ self |
|
1086 |
]. |
|
1087 |
]. |
|
1088 |
] |
|
1089 |
] ifFalse:[ |
|
1090 |
item := nil |
|
1091 |
]. |
|
1092 |
||
1093 |
(button == 1 or:[button == #select]) ifTrue:[ |
|
1094 |
(item notNil and:[indicatorAction notNil and:[item hasIndicator]]) ifTrue:[ |
|
2327 | 1095 |
x0 := self xVisibleOfIconAtLevel:(item level - 1). |
2313 | 1096 |
|
1097 |
(x > x0 and:[(x0 + imageWidth) > x]) ifTrue:[ |
|
1098 |
self indicatorPressedAt:line. |
|
2361 | 1099 |
^ self |
2313 | 1100 |
]. |
2224 | 1101 |
]. |
1102 |
]. |
|
2313 | 1103 |
|
2224 | 1104 |
super buttonPress:button x:x y:y. |
1105 |
! |
|
1390 | 1106 |
|
2224 | 1107 |
buttonPressOrReleaseAtLine:aLnNr x:x y:y |
1108 |
"handle a button press or release at a line |
|
1109 |
" |
|
1110 |
|oldIdx newIdx newItem| |
|
1111 |
||
1112 |
oldIdx := self selectedIndex. |
|
1113 |
super buttonPressOrReleaseAtLine:aLnNr x:x y:y. |
|
1114 |
newIdx := self selectedIndex. |
|
1115 |
||
1116 |
(newIdx ~~ oldIdx and:[newIdx ~~ 0]) ifTrue:[ |
|
1117 |
expandOnSelect ifTrue:[ |
|
1118 |
newItem := list at:newIdx ifAbsent:nil. |
|
2307 | 1119 |
newItem isNil ifTrue:[^ self]. |
2224 | 1120 |
newItem expand |
1390 | 1121 |
]. |
2224 | 1122 |
self makeLineVisible:newIdx. |
1123 |
]. |
|
1757 | 1124 |
! |
1125 |
||
1126 |
keyPress:aKey x:x y:y |
|
1127 |
"a key was pressed - handle page-keys here |
|
1128 |
" |
|
1784 | 1129 |
<resource: #keyboard( #CursorLeft #CursorRight )> |
1757 | 1130 |
|
2227 | 1131 |
|item index| |
1757 | 1132 |
|
1782 | 1133 |
enabled ifFalse:[^ self]. |
2179 | 1134 |
index := self selectedIndex. |
1782 | 1135 |
|
1136 |
aKey == Character space ifTrue:[ |
|
2179 | 1137 |
index ~~ 0 ifTrue:[ |
1782 | 1138 |
^ self indicatorPressedAt:index |
1139 |
] |
|
1140 |
]. |
|
2179 | 1141 |
((aKey == #CursorRight) or:[(aKey == #CursorLeft)]) ifTrue:[ |
1142 |
index ~~ 0 ifTrue:[ |
|
1143 |
item := list at:index ifAbsent:nil. |
|
1144 |
item notNil ifTrue:[ |
|
1145 |
(aKey == #CursorLeft) == (item isExpanded) ifTrue:[ |
|
1146 |
^ self indicatorPressedAt:index |
|
1147 |
] ifFalse:[ |
|
1148 |
aKey == #CursorLeft ifTrue:[ |
|
1149 |
self selectElement:item parent ifAbsent:[]. |
|
1150 |
^ self. |
|
2227 | 1151 |
] ifFalse:[ |
1152 |
" select the childrens first item on CursorLeft |
|
1153 |
if there are any" |
|
1154 |
item hasChildren ifTrue:[ |
|
1155 |
self selection:(index + 1) |
|
1156 |
]. |
|
1157 |
^ self. |
|
2179 | 1158 |
]. |
1159 |
]. |
|
1160 |
] |
|
1161 |
] |
|
1162 |
]. |
|
1163 |
^ super keyPress:aKey x:x y:y |
|
1390 | 1164 |
! ! |
1165 |
||
1757 | 1166 |
!HierarchicalListView methodsFor:'fetch resources'! |
1167 |
||
1168 |
fetchResources |
|
1169 |
"fetch device colors and ..., to avoid reallocation at redraw time; |
|
1170 |
*** called after a create or snapin to fetch all device resources |
|
1171 |
" |
|
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1172 |
|image defaultWidth| |
1757 | 1173 |
|
1174 |
super fetchResources. |
|
1175 |
||
1176 |
lineMask := lineMask onDevice:device. |
|
1177 |
lineColor := lineColor onDevice:device. |
|
1178 |
openIndicator := self imageOnDevice:openIndicator. |
|
1179 |
closeIndicator := self imageOnDevice:closeIndicator. |
|
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1180 |
defaultWidth := imageWidth. |
1757 | 1181 |
|
1182 |
icons keysAndValuesDo:[:aKey :anImage| |
|
1183 |
anImage isNil ifTrue:[ |
|
1184 |
('HierachicalListView [warning]: missing image: ' , aKey) errorPrintCR. |
|
1185 |
] ifFalse:[ |
|
1186 |
image := self imageOnDevice:anImage. |
|
1187 |
icons at:aKey put:image. |
|
1188 |
imageWidth := image width max:imageWidth. |
|
1189 |
] |
|
1190 |
]. |
|
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1191 |
imageWidth := (imageWidth + 1 // 2 * 2) max:defaultWidth. |
1904 | 1192 |
alignTextRightX := imageWidth + 20 max:alignTextRightX. |
1757 | 1193 |
! ! |
1194 |
||
1390 | 1195 |
!HierarchicalListView methodsFor:'initialize / release'! |
1196 |
||
1197 |
initStyle |
|
1198 |
"setup viewStyle specifics |
|
1199 |
" |
|
1200 |
|cls| |
|
1201 |
||
1202 |
super initStyle. |
|
1203 |
||
1204 |
cls := self class. |
|
1205 |
||
1206 |
lineMask := Form width:2 height:2 fromArray:#[16rAA 16r55]. |
|
1779
5848ce6ff439
change registeredIcons from IdentityDictionary to Dictionary
ca
parents:
1757
diff
changeset
|
1207 |
icons := Dictionary new. |
1390 | 1208 |
|
1209 |
openIndicator := self class openIndicator. |
|
1210 |
closeIndicator := self class closeIndicator. |
|
2312 | 1211 |
minLineHeight := (openIndicator height) max:(closeIndicator height). |
1212 |
||
1390 | 1213 |
lineColor := fgColor. |
1214 |
highlightMode := #label. |
|
1215 |
showRoot := true. |
|
1216 |
showLeftIndicators := true. |
|
1217 |
useDefaultIcons := true. |
|
1218 |
showLines := true. |
|
1219 |
imageInset := 4. |
|
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1220 |
imageWidth := 16. "/ default |
1568 | 1221 |
alignTextRight := false. |
1222 |
alignTextRightX := 8. |
|
1223 |
maxWidthOfText := 0. |
|
2224 | 1224 |
|
2325 | 1225 |
|
2328 | 1226 |
highlightEnterItem := styleSheet at:#'selection.highlightEnterItem' default:false. |
2310 | 1227 |
expandOnSelect := styleSheet at:#'selection.expandOnSelect' default:false. |
2224 | 1228 |
autoScrollHorizontal := true. |
2210 | 1229 |
! |
1230 |
||
1231 |
initialize |
|
1232 |
super initialize. |
|
1233 |
levelOfLastItem := 1. |
|
1390 | 1234 |
! ! |
1235 |
||
1236 |
!HierarchicalListView methodsFor:'private'! |
|
1237 |
||
2327 | 1238 |
iconFor:anItem |
1239 |
"returns an icon or image for the item or nil if the item |
|
1240 |
provides no image and #useDefaultIcons is switched off. |
|
1390 | 1241 |
" |
2307 | 1242 |
|iconOrKey image| |
1390 | 1243 |
|
2307 | 1244 |
"/ get the icon or access key from the item |
1245 |
iconOrKey := anItem icon. |
|
1390 | 1246 |
|
2307 | 1247 |
iconOrKey notNil ifTrue:[ |
1248 |
iconOrKey isImageOrForm ifTrue:[ |
|
1249 |
"/ got an image; have to register the image on my device |
|
1390 | 1250 |
|
2307 | 1251 |
iconOrKey device == device ifTrue:[ |
1252 |
^ iconOrKey |
|
1253 |
]. |
|
1254 |
^ icons at:iconOrKey ifAbsentPut:[ self imageOnDevice:iconOrKey ]. |
|
1390 | 1255 |
]. |
1256 |
||
2307 | 1257 |
image := icons at:iconOrKey ifAbsent:nil. |
1258 |
image notNil ifTrue:[ ^ image ]. |
|
1259 |
]. |
|
1260 |
||
1261 |
"/ test whether a default image should be returned |
|
1262 |
useDefaultIcons ifFalse:[ |
|
1263 |
^ nil |
|
1390 | 1264 |
]. |
1265 |
||
2307 | 1266 |
anItem hasChildren ifFalse:[ |
1267 |
^ icons at:#empty ifAbsentPut:[ self imageOnDevice:(self class emptyIcon) ] |
|
1390 | 1268 |
]. |
1898 | 1269 |
|
2307 | 1270 |
anItem isExpanded ifTrue:[ |
1271 |
^ icons at:#expanded ifAbsentPut:[ self imageOnDevice:(self class expandedIcon) ]. |
|
1898 | 1272 |
]. |
2307 | 1273 |
^ icons at:#collapsed ifAbsentPut:[ self imageOnDevice:(self class collapsedIcon) ]. |
1390 | 1274 |
! |
1275 |
||
2353 | 1276 |
lineHeightFor:anItem |
1277 |
"returns the computed line height for an item |
|
1278 |
" |
|
1279 |
|image height| |
|
1280 |
||
1281 |
height := renderer heightFor:anItem. |
|
1282 |
image := self iconFor:anItem. |
|
1283 |
||
1284 |
image notNil ifTrue:[ |
|
1285 |
height := image height max:height. |
|
1286 |
]. |
|
1287 |
||
1288 |
hasConstantHeight ifTrue:[ |
|
1289 |
icons size ~~ 0 ifTrue:[ |
|
1290 |
icons do:[:anIcon| height := anIcon height max:height ] |
|
1291 |
] ifFalse:[ |
|
1292 |
image isNil ifTrue:[ height := height max:16 ] |
|
1293 |
] |
|
1294 |
]. |
|
1295 |
height := height + lineSpacing. |
|
1296 |
^ height max:minLineHeight |
|
1297 |
! |
|
1298 |
||
1390 | 1299 |
smallestLevelBetween:start and:stop |
2327 | 1300 |
"returns the smallest level of all items in a range |
1390 | 1301 |
" |
1302 |
|prevItem currParent nextParent item |
|
1303 |
||
1304 |
lvl "{ Class:SmallInteger }" |
|
1305 |
min "{ Class:SmallInteger }" |
|
1306 |
beg "{ Class:SmallInteger }" |
|
1307 |
| |
|
1308 |
||
1508
9c54f2e53da1
check whether #at:ifAbsent returns nil.
Claus Gittinger <cg@exept.de>
parents:
1431
diff
changeset
|
1309 |
prevItem := list at:start ifAbsent:nil. |
1390 | 1310 |
|
1508
9c54f2e53da1
check whether #at:ifAbsent returns nil.
Claus Gittinger <cg@exept.de>
parents:
1431
diff
changeset
|
1311 |
(prevItem isNil or:[(currParent := prevItem parent) isNil]) ifTrue:[ |
1390 | 1312 |
^ 1 |
1313 |
]. |
|
1314 |
||
1315 |
(min := prevItem level) == 2 ifTrue:[ |
|
1316 |
^ min |
|
1317 |
]. |
|
1318 |
beg := start + 1. |
|
1319 |
||
1320 |
beg to:stop do:[:i| |
|
1508
9c54f2e53da1
check whether #at:ifAbsent returns nil.
Claus Gittinger <cg@exept.de>
parents:
1431
diff
changeset
|
1321 |
item := list at:i ifAbsent:nil. |
9c54f2e53da1
check whether #at:ifAbsent returns nil.
Claus Gittinger <cg@exept.de>
parents:
1431
diff
changeset
|
1322 |
item isNil ifTrue:[^ min]. |
1390 | 1323 |
|
1324 |
(nextParent := item parent) == currParent ifFalse:[ |
|
1325 |
(currParent := nextParent) == prevItem ifFalse:[ |
|
1326 |
(lvl := item level) == 2 ifTrue:[ |
|
1327 |
^ 2 |
|
1328 |
]. |
|
1329 |
min := min min:lvl |
|
1330 |
] |
|
1331 |
]. |
|
1332 |
prevItem := item |
|
1333 |
]. |
|
1334 |
^ min |
|
1335 |
! |
|
1336 |
||
1337 |
widthOfWidestLineBetween:firstLine and:lastLine |
|
2327 | 1338 |
"returns the width of the longest line in pixels in a range |
1390 | 1339 |
" |
1756 | 1340 |
|nprnt pprnt pitem item |
1390 | 1341 |
textX "{ Class: SmallInteger }" |
1342 |
level "{ Class: SmallInteger }" |
|
1343 |
width "{ Class: SmallInteger }" |
|
1344 |
deltaX "{ Class: SmallInteger }" |
|
1345 |
startX "{ Class: SmallInteger }" |
|
1568 | 1346 |
itemW "{ Class: SmallInteger }" |
1390 | 1347 |
| |
1568 | 1348 |
width := 20. |
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1349 |
level := 1. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1350 |
pprnt := 4711. "/ force a computation |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1351 |
deltaX := self parentToChildInset. |
1568 | 1352 |
|
1353 |
alignTextRight ifTrue:[ |
|
1354 |
firstLine to:lastLine do:[:idx| |
|
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1355 |
item := list at:idx ifAbsent:nil. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1356 |
|
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1357 |
item notNil ifTrue:[ |
2353 | 1358 |
width := (renderer widthFor:item) max:width. |
1568 | 1359 |
|
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1360 |
nprnt := item parent. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1361 |
nprnt ~~ pprnt ifTrue:[ |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1362 |
level := item level max:level. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1363 |
pprnt := nprnt. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1364 |
]. |
1568 | 1365 |
]. |
1366 |
]. |
|
1367 |
maxWidthOfText := maxWidthOfText max:width. |
|
2327 | 1368 |
startX := self xVisibleOfIconAtLevel:(level + 1). |
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1369 |
|
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1370 |
alignTextRightX < startX ifTrue:[ |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1371 |
shown ifTrue:[ self invalidate]. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1372 |
alignTextRightX := startX |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1373 |
]. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1374 |
^ alignTextRightX + width |
1568 | 1375 |
]. |
1390 | 1376 |
|
1377 |
pitem := 4712. "/ force a computation |
|
2327 | 1378 |
startX := (self xVisibleOfTextAtLevel:1) + (viewOrigin x). |
1756 | 1379 |
textX := 0. |
1380 |
level := 1. |
|
1390 | 1381 |
|
1382 |
firstLine to:lastLine do:[:idx| |
|
1508
9c54f2e53da1
check whether #at:ifAbsent returns nil.
Claus Gittinger <cg@exept.de>
parents:
1431
diff
changeset
|
1383 |
item := list at:idx ifAbsent:nil. |
9c54f2e53da1
check whether #at:ifAbsent returns nil.
Claus Gittinger <cg@exept.de>
parents:
1431
diff
changeset
|
1384 |
item isNil ifTrue:[^ width + startX]. |
1390 | 1385 |
|
1386 |
(nprnt := item parent) ~~ pprnt ifTrue:[ |
|
1387 |
(pprnt := nprnt) == pitem ifTrue:[ |
|
1388 |
level := level + 1. |
|
1389 |
textX := textX + deltaX. |
|
1390 |
] ifFalse:[ |
|
1391 |
level := item level. |
|
1392 |
textX := level - 1 * deltaX. |
|
1393 |
] |
|
1394 |
]. |
|
1395 |
pitem := item. |
|
2353 | 1396 |
itemW := renderer widthFor:item. |
1568 | 1397 |
maxWidthOfText := maxWidthOfText max:itemW. |
1398 |
width := (itemW + textX) max:width |
|
1390 | 1399 |
]. |
1568 | 1400 |
^ width + startX. |
1390 | 1401 |
! |
1402 |
||
2327 | 1403 |
xVisibleOfIconAtLevel:aLevel |
1404 |
"returns the visible origin x of the icon at a level. |
|
1390 | 1405 |
" |
1406 |
|l "{ Class:SmallInteger }"| |
|
1407 |
||
1408 |
l := showRoot ifTrue:[aLevel] ifFalse:[aLevel - 1]. |
|
1409 |
||
1410 |
indicatorAction isNil ifTrue:[ |
|
1411 |
l := l - 1 |
|
1412 |
] ifFalse:[ |
|
1413 |
showLeftIndicators ifFalse:[ |
|
1414 |
l := l - 1 |
|
1415 |
] |
|
1416 |
]. |
|
2311 | 1417 |
^ (l * (self parentToChildInset)) + imageInset - (viewOrigin x) |
1390 | 1418 |
! |
1419 |
||
2327 | 1420 |
xVisibleOfItem:anItem |
1421 |
"returns the visible origin x of the item's label. |
|
1422 |
" |
|
1423 |
^ self xVisibleOfTextAtLevel:(anItem level) |
|
1424 |
! |
|
1425 |
||
1426 |
xVisibleOfTextAtLevel:aLevel |
|
1427 |
"returns the visible origin x of the text label at a level. |
|
1757 | 1428 |
" |
1429 |
alignTextRight ifTrue:[ |
|
1430 |
^ alignTextRightX - (viewOrigin x) |
|
1431 |
]. |
|
2327 | 1432 |
^ (self xVisibleOfIconAtLevel:aLevel) + imageWidth + textStartLeft |
1390 | 1433 |
! ! |
1434 |
||
2224 | 1435 |
!HierarchicalListView methodsFor:'scrolling'! |
1436 |
||
1437 |
computeViewOriginXat:aLnrNr |
|
2327 | 1438 |
"returns the viewOrigin x to make the item at a line visisble |
2224 | 1439 |
" |
2233 | 1440 |
|item xLft xRgt lvWidth level vwOrgX xInset| |
2224 | 1441 |
|
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1442 |
alignTextRight ifTrue:[^ viewOrigin x ]. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1443 |
|
2224 | 1444 |
aLnrNr == 1 ifTrue:[^ 0]. |
1445 |
||
2233 | 1446 |
vwOrgX := viewOrigin x. |
2224 | 1447 |
|
1448 |
item := list at:aLnrNr ifAbsent:nil. |
|
2307 | 1449 |
item isNil ifTrue:[ ^ vwOrgX ]. |
2224 | 1450 |
|
1451 |
level := item level. |
|
1452 |
level <= 2 ifTrue:[^ 0 ]. |
|
1453 |
||
2327 | 1454 |
xLft := self xVisibleOfIconAtLevel:(level - 1). |
2311 | 1455 |
lvWidth := self parentToChildInset. |
2224 | 1456 |
|
2353 | 1457 |
xRgt := (self xVisibleOfTextAtLevel:level) + (renderer widthFor:item). |
2224 | 1458 |
|
2233 | 1459 |
xLft > lvWidth negated ifTrue:[ |
1460 |
xRgt < width ifTrue:[^ vwOrgX] |
|
2224 | 1461 |
]. |
1462 |
||
2233 | 1463 |
xInset := ((width - (xRgt - xLft) // 2) // lvWidth * lvWidth) max:0. |
1464 |
vwOrgX := xLft + vwOrgX - xInset - margin. |
|
1465 |
vwOrgX < lvWidth ifTrue:[^ 0 ]. |
|
2353 | 1466 |
^ vwOrgX |
2224 | 1467 |
! |
1468 |
||
1469 |
makeLineVisible:aLnrNr |
|
2327 | 1470 |
"make the line horizontal and vertical visible |
2224 | 1471 |
" |
1472 |
|newY item y0 newX| |
|
1473 |
||
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1474 |
alignTextRight ifTrue:[^ self]. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1475 |
|
2224 | 1476 |
(shown and:[aLnrNr notNil]) ifFalse:[^ self]. |
1477 |
||
1478 |
aLnrNr <= 1 ifTrue:[ |
|
1479 |
aLnrNr == 1 ifTrue:[ self scrollTo:(0 @ 0) ]. |
|
2353 | 1480 |
^ self |
2224 | 1481 |
]. |
1482 |
||
1483 |
item := list at:aLnrNr ifAbsent:nil. |
|
2307 | 1484 |
item isNil ifTrue:[^ self]. |
2224 | 1485 |
|
1486 |
y0 := self yVisibleOfLine:aLnrNr. |
|
1487 |
||
1488 |
( y0 < margin |
|
2353 | 1489 |
or:[(y0 + (renderer heightFor:item)) > (height - margin)] |
2224 | 1490 |
) ifTrue:[ |
1491 |
newY := ((self yAbsoluteOfLine:aLnrNr) - (height // 2)) max:0. |
|
1492 |
] ifFalse:[ |
|
1493 |
newY := viewOrigin y. |
|
1494 |
]. |
|
1495 |
||
1496 |
newX := viewOrigin x. |
|
1497 |
||
1498 |
(autoScrollHorizontal or:[newX ~~ 0]) ifTrue:[ |
|
1499 |
newX := self computeViewOriginXat:aLnrNr |
|
1500 |
]. |
|
1501 |
self scrollTo:(newX @ newY). |
|
1502 |
! ! |
|
1503 |
||
1390 | 1504 |
!HierarchicalListView class methodsFor:'documentation'! |
1505 |
||
1506 |
version |
|
2366 | 1507 |
^ '$Header: /cvs/stx/stx/libwidg2/HierarchicalListView.st,v 1.72 2002-11-11 14:51:05 ca Exp $' |
1390 | 1508 |
! ! |