author | ca |
Mon, 28 Oct 2002 10:56:50 +0100 | |
changeset 2335 | 8f551ed4bdc2 |
parent 2334 | 2884dc92121e |
child 2336 | 9977d831bb08 |
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 |
17 |
instanceVariableNames:'imageInset imageWidth lineMask lineColor showRoot showLines |
|
18 |
showLeftIndicators indicatorAction useDefaultIcons icons |
|
1568 | 19 |
openIndicator closeIndicator alignTextRight alignTextRightX |
2312 | 20 |
maxWidthOfText minLineHeight levelOfLastItem expandOnSelect |
2224 | 21 |
autoScrollHorizontal' |
1390 | 22 |
classVariableNames:'' |
23 |
poolDictionaries:'' |
|
1430 | 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' |
|
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]; 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 |
"get the status of <showRoot> from the list |
|
317 |
" |
|
318 |
aList notNil ifTrue:[ |
|
319 |
showRoot := aList showRoot |
|
320 |
]. |
|
321 |
super list:aList |
|
1897
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
322 |
! |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
323 |
|
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
324 |
parentToChildInset |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
325 |
"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
|
326 |
" |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
327 |
^ imageInset + imageWidth |
1390 | 328 |
! ! |
329 |
||
2224 | 330 |
!HierarchicalListView methodsFor:'accessing-behavior'! |
331 |
||
332 |
autoScrollHorizontal |
|
333 |
"true, than automatically scroll horizontal upto the text label |
|
334 |
of the current selected line. |
|
335 |
" |
|
336 |
^ autoScrollHorizontal ? false |
|
337 |
! |
|
338 |
||
339 |
autoScrollHorizontal:aBoolean |
|
340 |
"true, than automatically scroll horizontal upto the text label |
|
341 |
of the current selected line. |
|
342 |
" |
|
343 |
autoScrollHorizontal := aBoolean. |
|
344 |
! |
|
345 |
||
346 |
expandOnSelect |
|
347 |
"true, than the item selected by a buttonPress event will |
|
348 |
be immediately expanded. |
|
349 |
" |
|
350 |
^ expandOnSelect |
|
351 |
! |
|
352 |
||
353 |
expandOnSelect:aBoolean |
|
354 |
"true, than the item selected by a buttonPress event will |
|
355 |
be immediately expanded. |
|
356 |
" |
|
357 |
expandOnSelect := aBoolean. |
|
358 |
! ! |
|
359 |
||
1818 | 360 |
!HierarchicalListView methodsFor:'accessing-colors'! |
1390 | 361 |
|
362 |
lineColor |
|
2307 | 363 |
"get the color of the horizontal and vertical lines |
1390 | 364 |
" |
365 |
^ lineColor |
|
366 |
! |
|
367 |
||
368 |
lineColor:aColor |
|
2307 | 369 |
"set the color of the horizontal and vertical lines |
1390 | 370 |
" |
371 |
(aColor notNil and:[aColor ~= lineColor]) ifTrue:[ |
|
372 |
lineColor := aColor. |
|
373 |
||
374 |
shown ifTrue:[ |
|
2099 | 375 |
lineColor := lineColor onDevice:device. |
2307 | 376 |
showLines ifTrue:[ self invalidate ] |
1390 | 377 |
] |
2307 | 378 |
]. |
1390 | 379 |
! ! |
380 |
||
1818 | 381 |
!HierarchicalListView methodsFor:'accessing-look'! |
1390 | 382 |
|
1568 | 383 |
alignTextRight |
384 |
"align the text right |
|
385 |
" |
|
386 |
^ alignTextRight |
|
387 |
! |
|
388 |
||
1757 | 389 |
alignTextRight:aBool |
390 |
"align the text right |
|
391 |
" |
|
392 |
alignTextRight := aBool ? false. |
|
393 |
! |
|
1568 | 394 |
|
1904 | 395 |
alignTextRightX |
396 |
"returns the minimum used text inset, if text is aligned right. |
|
397 |
" |
|
398 |
^ alignTextRightX |
|
399 |
! |
|
400 |
||
401 |
alignTextRightX:aNumber |
|
402 |
"set the minimum used text inset, if text is aligned right. |
|
403 |
" |
|
404 |
aNumber > self parentToChildInset ifTrue:[ |
|
405 |
alignTextRightX := aNumber. |
|
406 |
||
407 |
(alignTextRight and:[widthOfContents notNil]) ifTrue:[ |
|
408 |
widthOfContents := alignTextRightX + maxWidthOfText. |
|
409 |
||
410 |
shown ifTrue:[ |
|
411 |
self invalidate. |
|
412 |
self contentsChanged. |
|
413 |
] |
|
414 |
] |
|
415 |
]. |
|
416 |
! |
|
417 |
||
2094 | 418 |
iconAt:aKey ifAbsentPut:aBlock |
419 |
"return the icon stored under a key; if not present,the |
|
420 |
result of the block if not nil is stored under the key |
|
421 |
and returned. |
|
422 |
" |
|
423 |
|icon| |
|
424 |
||
425 |
icon := icons at:aKey ifAbsent:nil. |
|
2307 | 426 |
icon notNil ifTrue:[^ icon]. |
2094 | 427 |
|
428 |
icon := aBlock value. |
|
2307 | 429 |
icon isNil ifTrue:[^ nil]. |
2094 | 430 |
|
431 |
realized ifTrue:[ |
|
432 |
icon := self imageOnDevice:icon |
|
433 |
]. |
|
434 |
icons at:aKey put:icon. |
|
435 |
^ icon |
|
436 |
! |
|
437 |
||
1390 | 438 |
registerKeysAndIcons:aDictionary |
439 |
"register icons by key and value derived from a directory |
|
440 |
" |
|
441 |
|image| |
|
442 |
||
443 |
(aDictionary isNil or:[aDictionary isEmpty]) ifTrue:[ |
|
444 |
^ self |
|
445 |
]. |
|
446 |
||
447 |
aDictionary keysAndValuesDo:[:aKey :anImage| |
|
448 |
(image := self imageOnDevice:anImage) notNil ifTrue:[ |
|
449 |
icons at:aKey put:image |
|
1746 | 450 |
] ifFalse:[ |
451 |
icons removeKey:aKey ifAbsent:nil |
|
1390 | 452 |
] |
453 |
] |
|
454 |
||
455 |
! |
|
456 |
||
457 |
showLeftIndicators |
|
458 |
"show or hide the indicators for the most left items |
|
459 |
" |
|
460 |
^ showLeftIndicators |
|
461 |
||
462 |
! |
|
463 |
||
2307 | 464 |
showLeftIndicators:aBoolean |
1390 | 465 |
"show or hide the indicators for the most left items |
466 |
" |
|
2307 | 467 |
aBoolean ~~ showLeftIndicators ifTrue:[ |
468 |
showLeftIndicators := aBoolean. |
|
469 |
shown ifTrue:[ self invalidate ]. |
|
1390 | 470 |
]. |
471 |
! |
|
472 |
||
473 |
showLines |
|
474 |
"returns true if lines are shown |
|
475 |
" |
|
2307 | 476 |
^ showLines |
1390 | 477 |
! |
478 |
||
2307 | 479 |
showLines:aBoolean |
1390 | 480 |
"show or hide lines |
481 |
" |
|
2307 | 482 |
aBoolean ~~ showLines ifTrue:[ |
483 |
showLines := aBoolean. |
|
484 |
shown ifTrue:[ self invalidate ]. |
|
1390 | 485 |
]. |
486 |
! |
|
487 |
||
488 |
useDefaultIcons |
|
489 |
"use the default icons if no icon for an item is specified; |
|
490 |
** default: true |
|
491 |
" |
|
492 |
^ useDefaultIcons |
|
493 |
! |
|
494 |
||
2307 | 495 |
useDefaultIcons:aBoolean |
1390 | 496 |
"use the default icons if no icon for an item is specified; |
497 |
** default: true |
|
498 |
" |
|
2307 | 499 |
useDefaultIcons ~~ aBoolean ifTrue:[ |
500 |
useDefaultIcons := aBoolean. |
|
501 |
shown ifTrue:[ self invalidate ]. |
|
1390 | 502 |
] |
503 |
! ! |
|
504 |
||
505 |
!HierarchicalListView methodsFor:'actions'! |
|
506 |
||
507 |
indicatorAction |
|
508 |
"if the action is not nil, indicators are shown and a click on the indicator |
|
509 |
will evaluate the action with none or one argument, the index into the list |
|
510 |
" |
|
511 |
^ indicatorAction |
|
512 |
! |
|
513 |
||
514 |
indicatorAction:anAction |
|
515 |
"if the action is not nil, indicators are shown and a click on the indicator |
|
516 |
will evaluate the action with none or one argument, the index into the list |
|
517 |
" |
|
2312 | 518 |
|maxLevel contentsChgSize| |
519 |
||
520 |
(indicatorAction isNil) == (anAction isNil) ifTrue:[ |
|
521 |
indicatorAction := anAction. |
|
522 |
^ self |
|
523 |
]. |
|
1390 | 524 |
|
2312 | 525 |
(widthOfContents isNil or:[list size == 0]) ifTrue:[ |
526 |
indicatorAction := anAction. |
|
527 |
self invalidate. |
|
528 |
^ self |
|
529 |
]. |
|
530 |
||
531 |
"/ must recompute width of contents |
|
532 |
||
533 |
maxLevel := 0. |
|
534 |
list do:[:el| maxLevel := maxLevel max:(el level) ]. |
|
535 |
||
2327 | 536 |
contentsChgSize := self xVisibleOfIconAtLevel:maxLevel. |
1390 | 537 |
indicatorAction := anAction. |
2327 | 538 |
contentsChgSize := (self xVisibleOfIconAtLevel:maxLevel) - contentsChgSize. |
2312 | 539 |
widthOfContents := widthOfContents + contentsChgSize. |
1390 | 540 |
|
2312 | 541 |
self invalidate. |
542 |
contentsChgSize ~~ 0 ifTrue:[ self contentsChanged ]. |
|
1390 | 543 |
! ! |
544 |
||
545 |
!HierarchicalListView methodsFor:'change & update'! |
|
546 |
||
1782 | 547 |
indicatorPressedAt:aLnNr |
2224 | 548 |
"handle indicator pressed action; |
549 |
if the item changed expanded, we try to show all |
|
550 |
new visible children |
|
551 |
" |
|
552 |
|item expanded availY usedY vwOrgX vwOrgY idx| |
|
553 |
||
2307 | 554 |
indicatorAction isNil ifTrue:[^ self]. |
2224 | 555 |
|
556 |
item := list at:aLnNr ifAbsent:nil. |
|
2307 | 557 |
item isNil ifTrue:[^ self]. |
2224 | 558 |
|
559 |
item hasIndicator ifFalse:[^ self]. |
|
560 |
||
561 |
expanded := item isExpanded. |
|
562 |
indicatorAction valueWithOptionalArgument:aLnNr. |
|
563 |
(expanded or:[item isExpanded not]) ifTrue:[^ self]. |
|
1783
ffe767ea66ea
check whether children exists before calling indicatorPressed action
ca
parents:
1782
diff
changeset
|
564 |
|
2224 | 565 |
"/ compute the index of last child assigned to item |
566 |
||
567 |
idx := item numberOfVisibleChildren. "/ no visible children |
|
568 |
idx == 0 ifTrue:[^ self]. |
|
569 |
||
570 |
idx := aLnNr + idx. |
|
571 |
vwOrgY := viewOrigin y. |
|
572 |
availY := (self yVisibleOfLine:aLnNr) - margin. |
|
573 |
||
574 |
availY > margin ifTrue:[ |
|
575 |
usedY := (self yVisibleOfLine:(idx + 1)) - (height - margin - margin). |
|
576 |
||
577 |
usedY > 1 ifTrue:[ |
|
578 |
vwOrgY := vwOrgY + (usedY min:availY). |
|
579 |
]. |
|
580 |
]. |
|
581 |
vwOrgX := self computeViewOriginXat:aLnNr. |
|
582 |
||
583 |
self scrollTo:(vwOrgX @ vwOrgY). |
|
1782 | 584 |
! |
585 |
||
1390 | 586 |
lineChangedAt:aLnNr with:arg |
587 |
"line changed at position; check whether line height changed |
|
588 |
" |
|
589 |
|item |
|
2317 | 590 |
level "{ Class:SmallInteger }" |
1390 | 591 |
x0 "{ Class:SmallInteger }" |
592 |
x1 "{ Class:SmallInteger }" |
|
593 |
y0 "{ Class:SmallInteger }" |
|
594 |
y1 "{ Class:SmallInteger }" |
|
2303 | 595 |
yB "{ Class:SmallInteger }" |
1390 | 596 |
| |
597 |
||
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
598 |
item := list at:aLnNr ifAbsent:nil. |
2317 | 599 |
item isNil ifTrue:[^ self]. |
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
600 |
|
1399 | 601 |
(arg == #icon or:[arg == #hierarchy]) ifFalse:[ |
2224 | 602 |
super lineChangedAt:aLnNr with:arg. |
603 |
||
604 |
(arg ~~ #redraw and:[widthOfContents notNil]) ifTrue:[ |
|
2327 | 605 |
x0 := (self xVisibleOfTextAtLevel:(item level)) |
2229 | 606 |
+ (item widthOn:self) |
607 |
+ (viewOrigin x). |
|
2224 | 608 |
|
609 |
x0 > widthOfContents ifTrue:[ |
|
610 |
widthOfContents := x0. |
|
611 |
self contentsChanged. |
|
612 |
] |
|
613 |
]. |
|
614 |
^ self |
|
1390 | 615 |
]. |
2317 | 616 |
level := item level. |
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
617 |
|
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
618 |
(alignTextRight and:[arg == #hierarchy]) ifTrue:[ |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
619 |
"/ must test whether alignTextRightX is enough |
2317 | 620 |
(item isExpanded and:[item hasChildren]) ifTrue:[ |
2327 | 621 |
x0 := self xVisibleOfIconAtLevel:(level + 2). |
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
622 |
|
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
623 |
alignTextRightX < x0 ifTrue:[ |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
624 |
alignTextRightX := x0. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
625 |
shown ifTrue:[ self invalidate ]. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
626 |
|
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
627 |
widthOfContents notNil ifTrue:[ |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
628 |
widthOfContents := alignTextRightX + maxWidthOfText. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
629 |
self contentsChanged. |
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 |
^ self. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
632 |
] |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
633 |
] |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
634 |
]. |
1568 | 635 |
shown ifFalse:[^ self]. |
636 |
||
2303 | 637 |
yB := height - margin. |
638 |
y0 := (self yVisibleOfLine:aLnNr) max:margin. |
|
639 |
y0 < yB ifFalse:[ ^ self ]. |
|
1390 | 640 |
|
2303 | 641 |
y1 := (self yVisibleOfLine:(aLnNr + 1)) min:yB. |
642 |
y1 > y0 ifFalse:[^ self]. |
|
1399 | 643 |
|
2327 | 644 |
x1 := (self xVisibleOfTextAtLevel:level) - 1. |
2317 | 645 |
x1 > margin ifFalse:[^ self]. |
1390 | 646 |
|
2317 | 647 |
arg == #hierarchy ifTrue:[ level := level - 1 ]. |
2303 | 648 |
|
2327 | 649 |
x0 := (self xVisibleOfIconAtLevel:level) max:margin. |
2317 | 650 |
x1 := x1 min:(width - margin). |
2303 | 651 |
|
2317 | 652 |
x0 < x1 ifTrue:[ |
653 |
self invalidate:(Rectangle left:x0 top:y0 width:(x1 - x0) height:(y1 - y0)) |
|
654 |
repairNow:false. |
|
2303 | 655 |
]. |
1976
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
656 |
! |
1390 | 657 |
|
1976
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
658 |
listChangedInsert:firstAddedIndex nItems:nLines |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
659 |
"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
|
660 |
" |
2210 | 661 |
|item level yTop yBot xLft start maxY| |
1390 | 662 |
|
1976
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
663 |
super listChangedInsert:firstAddedIndex nItems:nLines. |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
664 |
|
2210 | 665 |
item := list last. |
666 |
levelOfLastItem := item level. |
|
667 |
||
1976
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
668 |
( shown |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
669 |
and:[showLines |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
670 |
and:[firstAddedIndex > 1 |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
671 |
and:[nLines ~~ 0 |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
672 |
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
|
673 |
and:[(level := item level) > 1]]]]] |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
674 |
) ifFalse:[ |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
675 |
^ self. |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
676 |
]. |
2327 | 677 |
xLft := (self xVisibleOfIconAtLevel:(level - 1)) + (imageWidth // 2) - 1. |
1390 | 678 |
|
1976
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
679 |
(xLft > margin and:[xLft < (width - margin)]) ifFalse:[ |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
680 |
^ self |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
681 |
]. |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
682 |
start := firstAddedIndex - 1. |
1390 | 683 |
|
1976
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
684 |
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
|
685 |
el := list at:i. |
1399 | 686 |
|
1976
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
687 |
el level <= level ifTrue:[ |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
688 |
i == start ifTrue:[^ self]. |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
689 |
|
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
690 |
yTop := (self yVisibleOfLine:i + 1) max:margin. |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
691 |
maxY := height - margin. |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
692 |
|
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
693 |
yTop < maxY ifTrue:[ |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
694 |
yBot := (self yVisibleOfLine:firstAddedIndex) - 1 min:maxY. |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
695 |
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
|
696 |
]. |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
697 |
^ self |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
698 |
] |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
699 |
]. |
1390 | 700 |
! |
701 |
||
2208 | 702 |
listChangedRemove:aStart toIndex:aStop |
703 |
"test whether last items are deleted; |
|
704 |
than we have to redraw lines because of different levels |
|
705 |
" |
|
2210 | 706 |
|listSize index y0 searchLevel| |
2208 | 707 |
|
2210 | 708 |
listSize := list size. |
709 |
searchLevel := levelOfLastItem. |
|
2208 | 710 |
|
2307 | 711 |
listSize == 0 ifTrue:[ levelOfLastItem := 1 ] |
712 |
ifFalse:[ levelOfLastItem := list last level ]. |
|
2208 | 713 |
|
2307 | 714 |
(shown and:[showLines and:[listSize ~~ 0 and:[aStart > listSize]]]) ifTrue:[ |
2210 | 715 |
index := list findLast:[:el| el level <= searchLevel ]. |
2208 | 716 |
|
717 |
(index ~~ 0 and:[index < listSize]) ifTrue:[ |
|
718 |
y0 := (self yVisibleOfLine:index) max:margin. |
|
719 |
self invalidateX:0 y:y0 width:width height:(height - margin - y0). |
|
720 |
] |
|
721 |
]. |
|
722 |
^ super listChangedRemove:aStart toIndex:aStop |
|
723 |
! |
|
724 |
||
1390 | 725 |
update:what with:aPara from:chgObj |
726 |
"get the status of <showRoot> from the list |
|
727 |
" |
|
728 |
chgObj == list ifTrue:[ |
|
729 |
showRoot ~~ list showRoot ifTrue:[ |
|
730 |
showRoot := list showRoot. |
|
731 |
self invalidate. |
|
732 |
] |
|
733 |
]. |
|
734 |
super update:what with:aPara from:chgObj |
|
735 |
! ! |
|
736 |
||
737 |
!HierarchicalListView methodsFor:'drawing basics'! |
|
738 |
||
1757 | 739 |
displayElement:anItem x:x y:y h:h |
740 |
"draw a label at x/y; fg/bg colors are already set |
|
741 |
" |
|
742 |
anItem displayOn:self x:x y:y h:h |
|
743 |
||
1399 | 744 |
! |
745 |
||
1568 | 746 |
drawElementsFrom:start to:stop x:xLeft y:yT w:w |
1390 | 747 |
"draw the items between start to stop without clearing the background |
748 |
" |
|
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
749 |
|item prevItem parent icon showIndc showIcon showText nxtPrnt extent |
1568 | 750 |
yTop "{ Class:SmallInteger }" |
751 |
yCtr "{ Class:SmallInteger }" |
|
752 |
yBot "{ Class:SmallInteger }" |
|
1390 | 753 |
|
1568 | 754 |
xIndc "{ Class:SmallInteger }" |
755 |
xIcon "{ Class:SmallInteger }" |
|
756 |
xText "{ Class:SmallInteger }" |
|
757 |
xL "{ Class:SmallInteger }" |
|
758 |
xR "{ Class:SmallInteger }" |
|
759 |
height "{ Class:SmallInteger }" |
|
1390 | 760 |
|
1568 | 761 |
widthLvl "{ Class:SmallInteger }" |
762 |
insetTxt "{ Class:SmallInteger }" |
|
1390 | 763 |
|
1568 | 764 |
offIndcX "{ Class:SmallInteger }" |
765 |
offIndcY "{ Class:SmallInteger }" |
|
766 |
offIconX "{ Class:SmallInteger }" |
|
1390 | 767 |
| |
2311 | 768 |
widthLvl := self parentToChildInset. |
1390 | 769 |
insetTxt := textStartLeft + imageWidth. |
1568 | 770 |
xL := xLeft. |
771 |
xR := xL + w. |
|
772 |
||
773 |
alignTextRight ifTrue:[ |
|
774 |
xText := alignTextRightX - (viewOrigin x). |
|
775 |
showText := xText < xR. |
|
776 |
]. |
|
777 |
||
2327 | 778 |
offIconX := self xVisibleOfIconAtLevel:0. |
1390 | 779 |
showIndc := false. |
780 |
||
781 |
indicatorAction notNil ifTrue:[ |
|
2049 | 782 |
offIndcX := offIndcY := 0. |
783 |
openIndicator notNil ifTrue:[ |
|
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
784 |
extent := openIndicator extent // 2. |
2049 | 785 |
offIndcX := imageWidth // 2 - widthLvl. |
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
786 |
offIndcX := offIndcX - extent x. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
787 |
offIndcY := extent y. |
2049 | 788 |
] |
1390 | 789 |
]. |
790 |
||
791 |
showLines ifTrue:[ |
|
1399 | 792 |
self drawLinesFrom:start to:stop x:xL y:yT toX:xR |
1390 | 793 |
]. |
794 |
||
795 |
parent := 4711. "/ to force a recompute |
|
796 |
prevItem := 4711. "/ to force a recomputation of the level |
|
1399 | 797 |
yBot := yT. |
1756 | 798 |
xIcon := offIconX. |
1390 | 799 |
|
800 |
start to:stop do:[:anIndex| |
|
801 |
(item := list at:anIndex ifAbsent:nil) isNil ifTrue:[ |
|
802 |
^ self "/ list changed |
|
803 |
]. |
|
804 |
yTop := yBot. |
|
805 |
yBot := self yVisibleOfLine:(anIndex + 1). |
|
1532
56e0fafc4349
change display protocol for item
Claus Gittinger <cg@exept.de>
parents:
1509
diff
changeset
|
806 |
height := yBot - yTop. |
56e0fafc4349
change display protocol for item
Claus Gittinger <cg@exept.de>
parents:
1509
diff
changeset
|
807 |
|
56e0fafc4349
change display protocol for item
Claus Gittinger <cg@exept.de>
parents:
1509
diff
changeset
|
808 |
yCtr := yTop + (height // 2). |
1390 | 809 |
|
810 |
(nxtPrnt := item parent) ~~ parent ifTrue:[ |
|
811 |
parent := nxtPrnt. |
|
812 |
xIcon := prevItem == parent ifTrue:[xIcon + widthLvl] |
|
813 |
ifFalse:[item level * widthLvl + offIconX]. |
|
814 |
||
1568 | 815 |
alignTextRight ifFalse:[ |
816 |
xText := xIcon + insetTxt. |
|
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
817 |
showText := (xText < xR). |
1568 | 818 |
]. |
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
819 |
showIcon := (xIcon < xR and:[xText > xL]). |
1390 | 820 |
|
821 |
indicatorAction notNil ifTrue:[ |
|
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
822 |
xIndc := xIcon + offIndcX. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
823 |
showIndc := (xIcon > xL and:[xIndc < xR]). |
1390 | 824 |
|
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
825 |
showIndc ifTrue:[ |
1756 | 826 |
showIndc := parent notNil or:[showLeftIndicators] |
827 |
] |
|
1390 | 828 |
] |
829 |
]. |
|
830 |
||
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
831 |
(showIcon and:[(icon := self validateDrawableIconFor:item) notNil]) ifTrue:[ |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
832 |
(xIcon + icon width) > xL ifTrue:[ |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
833 |
icon displayOn:self x:xIcon y:(yCtr - (icon height // 2)) |
1568 | 834 |
] |
1390 | 835 |
]. |
836 |
||
837 |
showText ifTrue:[ |
|
1532
56e0fafc4349
change display protocol for item
Claus Gittinger <cg@exept.de>
parents:
1509
diff
changeset
|
838 |
self drawLabelAt:anIndex x:xText y:yTop h:height |
1390 | 839 |
]. |
2201
aa74fa6137a5
make indicator dependent on hasIndicator and not hasChildren
ca
parents:
2181
diff
changeset
|
840 |
(showIndc and:[item hasIndicator]) ifTrue:[ |
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
841 |
item isExpanded ifTrue:[icon := openIndicator ] |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
842 |
ifFalse:[icon := closeIndicator]. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
843 |
|
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
844 |
icon displayOn:self x:xIndc y:(yCtr - offIndcY) |
1390 | 845 |
]. |
846 |
prevItem := item. |
|
847 |
] |
|
848 |
! |
|
849 |
||
1399 | 850 |
drawLinesFrom:start to:stop x:xL y:yT toX:xR |
1390 | 851 |
"draw the lines between start to stop without clearing the background |
852 |
" |
|
853 |
|item prevItem parent p1 p2 showVLines showHLine lv nxtPrnt |
|
854 |
showRootNot isFirst buildInArray |
|
855 |
||
856 |
x "{ Class:SmallInteger }" |
|
1570 | 857 |
xText "{ Class:SmallInteger }" |
858 |
||
1390 | 859 |
y "{ Class:SmallInteger }" |
860 |
yTop "{ Class:SmallInteger }" |
|
861 |
yBot "{ Class:SmallInteger }" |
|
862 |
yCtr "{ Class:SmallInteger }" |
|
863 |
||
864 |
begHLnY "{ Class:SmallInteger }" |
|
865 |
runHLnY "{ Class:SmallInteger }" |
|
866 |
begHLnX "{ Class:SmallInteger }" |
|
867 |
endHLnX "{ Class:SmallInteger }" |
|
868 |
||
1897
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
869 |
widthLvl "{ Class:SmallInteger }" |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
870 |
offsHLnX "{ Class:SmallInteger }" |
1390 | 871 |
|
1897
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
872 |
level "{ Class:SmallInteger }" |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
873 |
startLvI "{ Class:SmallInteger }" |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
874 |
startLvX "{ Class:SmallInteger }" |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
875 |
limitLvI "{ Class:SmallInteger }" |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
876 |
limitLvX "{ Class:SmallInteger }" |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
877 |
imgHWdt "{ Class:SmallInteger }" |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
878 |
minXVLine "{ Class:SmallInteger }" |
1390 | 879 |
| |
1792
26aa6dc38278
draw vertical line not into icon if no children defined
ca
parents:
1784
diff
changeset
|
880 |
imgHWdt := imageWidth // 2. |
2311 | 881 |
widthLvl := self parentToChildInset. |
2327 | 882 |
offsHLnX := imgHWdt + (self xVisibleOfIconAtLevel:-1). |
1390 | 883 |
|
884 |
parent := 4711. "/ to force a recompute |
|
885 |
prevItem := 4711. "/ to force a recomputation of the level |
|
886 |
||
887 |
self setMaskOrigin:(self viewOrigin + (0 @ 1) \\ (lineMask extent)). |
|
888 |
self paint:lineColor on:bgColor. |
|
889 |
self mask:lineMask. |
|
890 |
startLvI := self smallestLevelBetween:start and:stop. |
|
2327 | 891 |
startLvX := self xVisibleOfIconAtLevel:startLvI. |
1390 | 892 |
limitLvI := 2. |
893 |
limitLvX := limitLvI * widthLvl + offsHLnX. |
|
894 |
||
1897
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
895 |
showRoot ifFalse:[ |
2327 | 896 |
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
|
897 |
] ifTrue:[ |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
898 |
minXVLine := 0 |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
899 |
]. |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
900 |
|
1567 | 901 |
showRootNot := showRoot not. |
902 |
yBot := yT. |
|
903 |
begHLnY := runHLnY := yT. |
|
1756 | 904 |
endHLnX := limitLvX. |
905 |
level := 1. |
|
1390 | 906 |
|
1570 | 907 |
alignTextRight ifTrue:[ |
908 |
xText := alignTextRightX - (viewOrigin x) - textStartLeft. |
|
909 |
]. |
|
910 |
||
1390 | 911 |
start to:stop do:[:anIndex| |
912 |
(item := list at:anIndex ifAbsent:nil) isNil ifTrue:[ |
|
913 |
^ self mask:nil "/ list changed |
|
914 |
]. |
|
915 |
yTop := yBot. |
|
916 |
yBot := self yVisibleOfLine:(anIndex + 1). |
|
917 |
yCtr := yTop + (yBot - yTop // 2). |
|
918 |
anIndex == 1 ifTrue:[ begHLnY := runHLnY := yCtr ]. |
|
919 |
||
920 |
(nxtPrnt := item parent) ~~ parent ifTrue:[ |
|
921 |
parent := nxtPrnt. |
|
922 |
||
923 |
prevItem == parent ifTrue:[ |
|
1567 | 924 |
level := level + 1. |
1390 | 925 |
begHLnX := endHLnX. |
926 |
] ifFalse:[ |
|
927 |
level := item level. |
|
1567 | 928 |
begHLnX := level * widthLvl + offsHLnX. |
1390 | 929 |
]. |
930 |
||
931 |
isFirst := parent isNil or:[(showRootNot and:[level == 2])]. |
|
932 |
endHLnX := begHLnX + widthLvl. |
|
1399 | 933 |
showVLines := begHLnX >= xL and:[level > 1]. |
1570 | 934 |
|
935 |
alignTextRight ifFalse:[ |
|
936 |
xText := endHLnX + (widthLvl // 2). |
|
937 |
]. |
|
938 |
showHLine := (xL < xText and:[xR > begHLnX]). |
|
1390 | 939 |
|
940 |
(showHLine and:[isFirst]) ifTrue:[ |
|
941 |
showHLine := showLeftIndicators and:[indicatorAction notNil] |
|
942 |
] |
|
943 |
]. |
|
944 |
||
945 |
showHLine ifTrue:[ |
|
1570 | 946 |
item drawHorizontalLineUpToText ifTrue:[ |
947 |
p1 := xText |
|
948 |
] ifFalse:[ |
|
1792
26aa6dc38278
draw vertical line not into icon if no children defined
ca
parents:
1784
diff
changeset
|
949 |
item hasChildren ifTrue:[ |
26aa6dc38278
draw vertical line not into icon if no children defined
ca
parents:
1784
diff
changeset
|
950 |
p1 := endHLnX. |
26aa6dc38278
draw vertical line not into icon if no children defined
ca
parents:
1784
diff
changeset
|
951 |
] ifFalse:[ |
1897
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
952 |
(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
|
953 |
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
|
954 |
] ifFalse:[ |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
955 |
p1 := begHLnX + imgHWdt |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
956 |
] |
1792
26aa6dc38278
draw vertical line not into icon if no children defined
ca
parents:
1784
diff
changeset
|
957 |
] |
1570 | 958 |
]. |
1792
26aa6dc38278
draw vertical line not into icon if no children defined
ca
parents:
1784
diff
changeset
|
959 |
xL < p1 ifTrue:[ |
1570 | 960 |
self displayLineFromX:begHLnX y:yCtr toX:p1 y:yCtr |
961 |
] |
|
1390 | 962 |
]. |
963 |
||
964 |
showVLines ifTrue:[ |
|
965 |
y := (parent last == item) ifTrue:[yCtr] ifFalse:[yBot]. |
|
966 |
x := begHLnX. |
|
967 |
p2 := parent. |
|
968 |
lv := level - 1. |
|
1897
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
969 |
|
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
970 |
x >= minXVLine ifTrue:[ |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
971 |
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
|
972 |
]. |
1390 | 973 |
|
974 |
[((p1 := p2 parent) notNil and:[(x := x - widthLvl) >= limitLvX])] whileTrue:[ |
|
1399 | 975 |
(p1 last ~~ p2 and:[x <= xR]) ifTrue:[ |
1390 | 976 |
x >= startLvX ifTrue:[ |
1897
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
977 |
x >= minXVLine ifTrue:[ |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
978 |
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
|
979 |
] |
1390 | 980 |
] ifFalse:[ |
1567 | 981 |
buildInArray isNil ifTrue:[buildInArray := Array new:startLvI]. |
1390 | 982 |
buildInArray at:lv put:yBot |
983 |
]. |
|
984 |
]. |
|
985 |
lv := lv - 1. |
|
986 |
p2 := p1 |
|
987 |
] |
|
988 |
]. |
|
989 |
prevItem := item. |
|
990 |
runHLnY := yCtr. |
|
991 |
]. |
|
992 |
||
993 |
"/ |
|
994 |
"/ draw outstanding verical lines to left |
|
995 |
"/ |
|
1897
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
996 |
x := minXVLine max:xL. |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
997 |
|
1567 | 998 |
(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
|
999 |
(endHLnX >= x and:[endHLnX <= xR]) ifTrue:[ |
1567 | 1000 |
self displayLineFromX:endHLnX y:yCtr toX:endHLnX y:yBot. |
1001 |
] |
|
1390 | 1002 |
]. |
1567 | 1003 |
|
1004 |
buildInArray notNil ifTrue:[ |
|
1005 |
x := limitLvX. |
|
1006 |
y := begHLnY. |
|
1390 | 1007 |
|
1567 | 1008 |
limitLvI to:startLvI do:[:i| |
1597 | 1009 |
|yB| |
1596 | 1010 |
|
1597 | 1011 |
(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
|
1012 |
x >= minXVLine ifTrue:[ |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
1013 |
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
|
1014 |
] |
1567 | 1015 |
]. |
1016 |
x := x + widthLvl. |
|
1390 | 1017 |
] |
1018 |
]. |
|
1019 |
self mask:nil. |
|
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1020 |
! |
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 |
validateDrawableIconFor:anItem |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1023 |
"returns the icon to be drawn for an item or nil |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1024 |
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
|
1025 |
" |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1026 |
|width needMore icon maxLevel startOfText| |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1027 |
|
2327 | 1028 |
icon := self iconFor:anItem. |
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1029 |
icon isNil ifTrue:[^ nil]. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1030 |
|
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1031 |
width := icon width. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1032 |
|
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1033 |
(constantHeight notNil and:[icon height > constantHeight]) ifTrue:[ |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1034 |
constantHeight := icon height + lineSpacing. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1035 |
self recomputeHeightOfContents. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1036 |
|
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1037 |
width <= imageWidth ifTrue:[ |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1038 |
self contentsChanged. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1039 |
StopRedrawSignal raise |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1040 |
]. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1041 |
] ifFalse:[ |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1042 |
width <= imageWidth ifTrue:[ ^ icon ]. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1043 |
]. |
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 |
needMore := width - imageWidth max:2. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1046 |
imageWidth := imageWidth + needMore. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1047 |
maxLevel := 1. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1048 |
|
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1049 |
list criticalDo:[ |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1050 |
list do:[:el| maxLevel := maxLevel max:(el level) ]. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1051 |
]. |
2327 | 1052 |
alignTextRightX := alignTextRightX max:(self xVisibleOfIconAtLevel:(maxLevel + 1)). |
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1053 |
|
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1054 |
widthOfContents notNil ifTrue:[ |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1055 |
alignTextRight ifTrue:[ |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1056 |
widthOfContents := alignTextRightX + maxWidthOfText |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1057 |
] ifFalse:[ |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1058 |
list showRoot ifFalse:[ maxLevel := maxLevel - 1 ]. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1059 |
widthOfContents := widthOfContents + (maxLevel * needMore) |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1060 |
]. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1061 |
width := anItem widthOn:self. |
2327 | 1062 |
startOfText := self xVisibleOfTextAtLevel:(anItem level). |
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1063 |
widthOfContents := widthOfContents max:(startOfText + width). |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1064 |
|
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1065 |
width > maxWidthOfText ifTrue:[ |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1066 |
maxWidthOfText := width |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1067 |
]. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1068 |
]. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1069 |
self contentsChanged. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1070 |
StopRedrawSignal raise. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1071 |
^ icon |
1390 | 1072 |
! ! |
1073 |
||
1074 |
!HierarchicalListView methodsFor:'event handling'! |
|
1075 |
||
1757 | 1076 |
buttonPress:button x:x y:y |
1077 |
"handle a button press event |
|
1078 |
" |
|
2313 | 1079 |
|line item x0 y0| |
2224 | 1080 |
|
1081 |
enabled ifFalse:[^ self]. |
|
1082 |
||
2313 | 1083 |
line := self yVisibleToLineNr:y. |
1084 |
line notNil ifTrue:[ |
|
1085 |
item := list at:line ifAbsent:nil. |
|
1086 |
item notNil ifTrue:[ |
|
2327 | 1087 |
x0 := self xVisibleOfTextAtLevel:(item level). |
2313 | 1088 |
|
1089 |
x >= x0 ifTrue:[ |
|
1090 |
y0 := self yVisibleOfLine:line. |
|
2224 | 1091 |
|
2313 | 1092 |
(item processButtonPress:button x:(x - x0) y:(y - y0)) == true ifTrue:[ |
1093 |
^ self |
|
1094 |
]. |
|
1095 |
]. |
|
1096 |
] |
|
1097 |
] ifFalse:[ |
|
1098 |
item := nil |
|
1099 |
]. |
|
1100 |
||
1101 |
(button == 1 or:[button == #select]) ifTrue:[ |
|
1102 |
(item notNil and:[indicatorAction notNil and:[item hasIndicator]]) ifTrue:[ |
|
2327 | 1103 |
x0 := self xVisibleOfIconAtLevel:(item level - 1). |
2313 | 1104 |
|
1105 |
(x > x0 and:[(x0 + imageWidth) > x]) ifTrue:[ |
|
1106 |
self indicatorPressedAt:line. |
|
1107 |
^ self |
|
1108 |
]. |
|
2224 | 1109 |
]. |
1110 |
]. |
|
2313 | 1111 |
|
2224 | 1112 |
super buttonPress:button x:x y:y. |
1113 |
! |
|
1390 | 1114 |
|
2224 | 1115 |
buttonPressOrReleaseAtLine:aLnNr x:x y:y |
1116 |
"handle a button press or release at a line |
|
1117 |
" |
|
1118 |
|oldIdx newIdx newItem| |
|
1119 |
||
1120 |
oldIdx := self selectedIndex. |
|
1121 |
super buttonPressOrReleaseAtLine:aLnNr x:x y:y. |
|
1122 |
newIdx := self selectedIndex. |
|
1123 |
||
1124 |
(newIdx ~~ oldIdx and:[newIdx ~~ 0]) ifTrue:[ |
|
1125 |
expandOnSelect ifTrue:[ |
|
1126 |
newItem := list at:newIdx ifAbsent:nil. |
|
2307 | 1127 |
newItem isNil ifTrue:[^ self]. |
2224 | 1128 |
newItem expand |
1390 | 1129 |
]. |
2224 | 1130 |
self makeLineVisible:newIdx. |
1131 |
]. |
|
1757 | 1132 |
! |
1133 |
||
1134 |
keyPress:aKey x:x y:y |
|
1135 |
"a key was pressed - handle page-keys here |
|
1136 |
" |
|
1784 | 1137 |
<resource: #keyboard( #CursorLeft #CursorRight )> |
1757 | 1138 |
|
2227 | 1139 |
|item index| |
1757 | 1140 |
|
1782 | 1141 |
enabled ifFalse:[^ self]. |
2179 | 1142 |
index := self selectedIndex. |
1782 | 1143 |
|
1144 |
aKey == Character space ifTrue:[ |
|
2179 | 1145 |
index ~~ 0 ifTrue:[ |
1782 | 1146 |
^ self indicatorPressedAt:index |
1147 |
] |
|
1148 |
]. |
|
2179 | 1149 |
((aKey == #CursorRight) or:[(aKey == #CursorLeft)]) ifTrue:[ |
1150 |
index ~~ 0 ifTrue:[ |
|
1151 |
item := list at:index ifAbsent:nil. |
|
1152 |
item notNil ifTrue:[ |
|
1153 |
(aKey == #CursorLeft) == (item isExpanded) ifTrue:[ |
|
1154 |
^ self indicatorPressedAt:index |
|
1155 |
] ifFalse:[ |
|
1156 |
aKey == #CursorLeft ifTrue:[ |
|
1157 |
self selectElement:item parent ifAbsent:[]. |
|
1158 |
^ self. |
|
2227 | 1159 |
] ifFalse:[ |
1160 |
" select the childrens first item on CursorLeft |
|
1161 |
if there are any" |
|
1162 |
item hasChildren ifTrue:[ |
|
1163 |
self selection:(index + 1) |
|
1164 |
]. |
|
1165 |
^ self. |
|
2179 | 1166 |
]. |
1167 |
]. |
|
1168 |
] |
|
1169 |
] |
|
1170 |
]. |
|
1171 |
^ super keyPress:aKey x:x y:y |
|
1390 | 1172 |
! ! |
1173 |
||
1757 | 1174 |
!HierarchicalListView methodsFor:'fetch resources'! |
1175 |
||
1176 |
fetchResources |
|
1177 |
"fetch device colors and ..., to avoid reallocation at redraw time; |
|
1178 |
*** called after a create or snapin to fetch all device resources |
|
1179 |
" |
|
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1180 |
|image defaultWidth| |
1757 | 1181 |
|
1182 |
super fetchResources. |
|
1183 |
||
1184 |
lineMask := lineMask onDevice:device. |
|
1185 |
lineColor := lineColor onDevice:device. |
|
1186 |
openIndicator := self imageOnDevice:openIndicator. |
|
1187 |
closeIndicator := self imageOnDevice:closeIndicator. |
|
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1188 |
defaultWidth := imageWidth. |
1757 | 1189 |
|
1190 |
icons keysAndValuesDo:[:aKey :anImage| |
|
1191 |
anImage isNil ifTrue:[ |
|
1192 |
('HierachicalListView [warning]: missing image: ' , aKey) errorPrintCR. |
|
1193 |
] ifFalse:[ |
|
1194 |
image := self imageOnDevice:anImage. |
|
1195 |
icons at:aKey put:image. |
|
1196 |
imageWidth := image width max:imageWidth. |
|
1197 |
] |
|
1198 |
]. |
|
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1199 |
imageWidth := (imageWidth + 1 // 2 * 2) max:defaultWidth. |
1904 | 1200 |
alignTextRightX := imageWidth + 20 max:alignTextRightX. |
1757 | 1201 |
! ! |
1202 |
||
1390 | 1203 |
!HierarchicalListView methodsFor:'initialize / release'! |
1204 |
||
1205 |
initStyle |
|
1206 |
"setup viewStyle specifics |
|
1207 |
" |
|
1208 |
|cls| |
|
1209 |
||
1210 |
super initStyle. |
|
1211 |
||
1212 |
cls := self class. |
|
1213 |
||
1214 |
lineMask := Form width:2 height:2 fromArray:#[16rAA 16r55]. |
|
1779
5848ce6ff439
change registeredIcons from IdentityDictionary to Dictionary
ca
parents:
1757
diff
changeset
|
1215 |
icons := Dictionary new. |
1390 | 1216 |
|
1217 |
openIndicator := self class openIndicator. |
|
1218 |
closeIndicator := self class closeIndicator. |
|
2312 | 1219 |
minLineHeight := (openIndicator height) max:(closeIndicator height). |
1220 |
||
1390 | 1221 |
lineColor := fgColor. |
1222 |
highlightMode := #label. |
|
1223 |
showRoot := true. |
|
1224 |
showLeftIndicators := true. |
|
1225 |
useDefaultIcons := true. |
|
1226 |
showLines := true. |
|
1227 |
imageInset := 4. |
|
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1228 |
imageWidth := 16. "/ default |
1568 | 1229 |
alignTextRight := false. |
1230 |
alignTextRightX := 8. |
|
1231 |
maxWidthOfText := 0. |
|
2224 | 1232 |
|
2325 | 1233 |
|
2328 | 1234 |
highlightEnterItem := styleSheet at:#'selection.highlightEnterItem' default:false. |
2310 | 1235 |
expandOnSelect := styleSheet at:#'selection.expandOnSelect' default:false. |
2224 | 1236 |
autoScrollHorizontal := true. |
2210 | 1237 |
! |
1238 |
||
1239 |
initialize |
|
1240 |
super initialize. |
|
1241 |
levelOfLastItem := 1. |
|
1390 | 1242 |
! ! |
1243 |
||
1244 |
!HierarchicalListView methodsFor:'private'! |
|
1245 |
||
2327 | 1246 |
heightOfItem:anItem |
1247 |
"returns the height of an item excluding lineSpacing ... |
|
1248 |
" |
|
1249 |
|image height| |
|
1250 |
||
1251 |
height := anItem heightOn:self. |
|
1252 |
image := self iconFor:anItem. |
|
1253 |
||
1254 |
image notNil ifTrue:[ |
|
1255 |
height := image height max:height. |
|
1256 |
]. |
|
1257 |
||
1258 |
hasConstantHeight ifTrue:[ |
|
1259 |
icons size ~~ 0 ifTrue:[ |
|
1260 |
icons do:[:anIcon| height := anIcon height max:height ] |
|
1261 |
] ifFalse:[ |
|
1262 |
image isNil ifTrue:[ height := height max:16 ] |
|
1263 |
] |
|
1264 |
]. |
|
1265 |
^ height max:minLineHeight |
|
1266 |
! |
|
1267 |
||
1268 |
iconFor:anItem |
|
1269 |
"returns an icon or image for the item or nil if the item |
|
1270 |
provides no image and #useDefaultIcons is switched off. |
|
1390 | 1271 |
" |
2307 | 1272 |
|iconOrKey image| |
1390 | 1273 |
|
2307 | 1274 |
"/ get the icon or access key from the item |
1275 |
iconOrKey := anItem icon. |
|
1390 | 1276 |
|
2307 | 1277 |
iconOrKey notNil ifTrue:[ |
1278 |
iconOrKey isImageOrForm ifTrue:[ |
|
1279 |
"/ got an image; have to register the image on my device |
|
1390 | 1280 |
|
2307 | 1281 |
iconOrKey device == device ifTrue:[ |
1282 |
^ iconOrKey |
|
1283 |
]. |
|
1284 |
^ icons at:iconOrKey ifAbsentPut:[ self imageOnDevice:iconOrKey ]. |
|
1390 | 1285 |
]. |
1286 |
||
2307 | 1287 |
image := icons at:iconOrKey ifAbsent:nil. |
1288 |
image notNil ifTrue:[ ^ image ]. |
|
1289 |
]. |
|
1290 |
||
1291 |
"/ test whether a default image should be returned |
|
1292 |
useDefaultIcons ifFalse:[ |
|
1293 |
^ nil |
|
1390 | 1294 |
]. |
1295 |
||
2307 | 1296 |
anItem hasChildren ifFalse:[ |
1297 |
^ icons at:#empty ifAbsentPut:[ self imageOnDevice:(self class emptyIcon) ] |
|
1390 | 1298 |
]. |
1898 | 1299 |
|
2307 | 1300 |
anItem isExpanded ifTrue:[ |
1301 |
^ icons at:#expanded ifAbsentPut:[ self imageOnDevice:(self class expandedIcon) ]. |
|
1898 | 1302 |
]. |
2307 | 1303 |
^ icons at:#collapsed ifAbsentPut:[ self imageOnDevice:(self class collapsedIcon) ]. |
1390 | 1304 |
! |
1305 |
||
1306 |
smallestLevelBetween:start and:stop |
|
2327 | 1307 |
"returns the smallest level of all items in a range |
1390 | 1308 |
" |
1309 |
|prevItem currParent nextParent item |
|
1310 |
||
1311 |
lvl "{ Class:SmallInteger }" |
|
1312 |
min "{ Class:SmallInteger }" |
|
1313 |
beg "{ Class:SmallInteger }" |
|
1314 |
| |
|
1315 |
||
1508
9c54f2e53da1
check whether #at:ifAbsent returns nil.
Claus Gittinger <cg@exept.de>
parents:
1431
diff
changeset
|
1316 |
prevItem := list at:start ifAbsent:nil. |
1390 | 1317 |
|
1508
9c54f2e53da1
check whether #at:ifAbsent returns nil.
Claus Gittinger <cg@exept.de>
parents:
1431
diff
changeset
|
1318 |
(prevItem isNil or:[(currParent := prevItem parent) isNil]) ifTrue:[ |
1390 | 1319 |
^ 1 |
1320 |
]. |
|
1321 |
||
1322 |
(min := prevItem level) == 2 ifTrue:[ |
|
1323 |
^ min |
|
1324 |
]. |
|
1325 |
beg := start + 1. |
|
1326 |
||
1327 |
beg to:stop do:[:i| |
|
1508
9c54f2e53da1
check whether #at:ifAbsent returns nil.
Claus Gittinger <cg@exept.de>
parents:
1431
diff
changeset
|
1328 |
item := list at:i ifAbsent:nil. |
9c54f2e53da1
check whether #at:ifAbsent returns nil.
Claus Gittinger <cg@exept.de>
parents:
1431
diff
changeset
|
1329 |
item isNil ifTrue:[^ min]. |
1390 | 1330 |
|
1331 |
(nextParent := item parent) == currParent ifFalse:[ |
|
1332 |
(currParent := nextParent) == prevItem ifFalse:[ |
|
1333 |
(lvl := item level) == 2 ifTrue:[ |
|
1334 |
^ 2 |
|
1335 |
]. |
|
1336 |
min := min min:lvl |
|
1337 |
] |
|
1338 |
]. |
|
1339 |
prevItem := item |
|
1340 |
]. |
|
1341 |
^ min |
|
1342 |
! |
|
1343 |
||
1344 |
widthOfWidestLineBetween:firstLine and:lastLine |
|
2327 | 1345 |
"returns the width of the longest line in pixels in a range |
1390 | 1346 |
" |
1756 | 1347 |
|nprnt pprnt pitem item |
1390 | 1348 |
textX "{ Class: SmallInteger }" |
1349 |
level "{ Class: SmallInteger }" |
|
1350 |
width "{ Class: SmallInteger }" |
|
1351 |
deltaX "{ Class: SmallInteger }" |
|
1352 |
startX "{ Class: SmallInteger }" |
|
1568 | 1353 |
itemW "{ Class: SmallInteger }" |
1390 | 1354 |
| |
1568 | 1355 |
width := 20. |
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1356 |
level := 1. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1357 |
pprnt := 4711. "/ force a computation |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1358 |
deltaX := self parentToChildInset. |
1568 | 1359 |
|
1360 |
alignTextRight ifTrue:[ |
|
1361 |
firstLine to:lastLine do:[:idx| |
|
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1362 |
item := list at:idx ifAbsent:nil. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1363 |
|
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1364 |
item notNil ifTrue:[ |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1365 |
width := (item widthOn:self) max:width. |
1568 | 1366 |
|
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1367 |
nprnt := item parent. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1368 |
nprnt ~~ pprnt ifTrue:[ |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1369 |
level := item level max:level. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1370 |
pprnt := nprnt. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1371 |
]. |
1568 | 1372 |
]. |
1373 |
]. |
|
1374 |
maxWidthOfText := maxWidthOfText max:width. |
|
2327 | 1375 |
startX := self xVisibleOfIconAtLevel:(level + 1). |
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1376 |
|
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1377 |
alignTextRightX < startX ifTrue:[ |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1378 |
shown ifTrue:[ self invalidate]. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1379 |
alignTextRightX := startX |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1380 |
]. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1381 |
^ alignTextRightX + width |
1568 | 1382 |
]. |
1390 | 1383 |
|
1384 |
pitem := 4712. "/ force a computation |
|
2327 | 1385 |
startX := (self xVisibleOfTextAtLevel:1) + (viewOrigin x). |
1756 | 1386 |
textX := 0. |
1387 |
level := 1. |
|
1390 | 1388 |
|
1389 |
firstLine to:lastLine do:[:idx| |
|
1508
9c54f2e53da1
check whether #at:ifAbsent returns nil.
Claus Gittinger <cg@exept.de>
parents:
1431
diff
changeset
|
1390 |
item := list at:idx ifAbsent:nil. |
9c54f2e53da1
check whether #at:ifAbsent returns nil.
Claus Gittinger <cg@exept.de>
parents:
1431
diff
changeset
|
1391 |
item isNil ifTrue:[^ width + startX]. |
1390 | 1392 |
|
1393 |
(nprnt := item parent) ~~ pprnt ifTrue:[ |
|
1394 |
(pprnt := nprnt) == pitem ifTrue:[ |
|
1395 |
level := level + 1. |
|
1396 |
textX := textX + deltaX. |
|
1397 |
] ifFalse:[ |
|
1398 |
level := item level. |
|
1399 |
textX := level - 1 * deltaX. |
|
1400 |
] |
|
1401 |
]. |
|
1402 |
pitem := item. |
|
1568 | 1403 |
itemW := item widthOn:self. |
1404 |
maxWidthOfText := maxWidthOfText max:itemW. |
|
1405 |
width := (itemW + textX) max:width |
|
1390 | 1406 |
]. |
1568 | 1407 |
^ width + startX. |
1390 | 1408 |
! |
1409 |
||
2327 | 1410 |
xVisibleOfIconAtLevel:aLevel |
1411 |
"returns the visible origin x of the icon at a level. |
|
1390 | 1412 |
" |
1413 |
|l "{ Class:SmallInteger }"| |
|
1414 |
||
1415 |
l := showRoot ifTrue:[aLevel] ifFalse:[aLevel - 1]. |
|
1416 |
||
1417 |
indicatorAction isNil ifTrue:[ |
|
1418 |
l := l - 1 |
|
1419 |
] ifFalse:[ |
|
1420 |
showLeftIndicators ifFalse:[ |
|
1421 |
l := l - 1 |
|
1422 |
] |
|
1423 |
]. |
|
2311 | 1424 |
^ (l * (self parentToChildInset)) + imageInset - (viewOrigin x) |
1390 | 1425 |
! |
1426 |
||
2327 | 1427 |
xVisibleOfItem:anItem |
1428 |
"returns the visible origin x of the item's label. |
|
1429 |
" |
|
1430 |
^ self xVisibleOfTextAtLevel:(anItem level) |
|
1431 |
! |
|
1432 |
||
1433 |
xVisibleOfTextAtLevel:aLevel |
|
1434 |
"returns the visible origin x of the text label at a level. |
|
1757 | 1435 |
" |
1436 |
alignTextRight ifTrue:[ |
|
1437 |
^ alignTextRightX - (viewOrigin x) |
|
1438 |
]. |
|
2327 | 1439 |
^ (self xVisibleOfIconAtLevel:aLevel) + imageWidth + textStartLeft |
1390 | 1440 |
! ! |
1441 |
||
2224 | 1442 |
!HierarchicalListView methodsFor:'scrolling'! |
1443 |
||
1444 |
computeViewOriginXat:aLnrNr |
|
2327 | 1445 |
"returns the viewOrigin x to make the item at a line visisble |
2224 | 1446 |
" |
2233 | 1447 |
|item xLft xRgt lvWidth level vwOrgX xInset| |
2224 | 1448 |
|
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1449 |
alignTextRight ifTrue:[^ viewOrigin x ]. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1450 |
|
2224 | 1451 |
aLnrNr == 1 ifTrue:[^ 0]. |
1452 |
||
2233 | 1453 |
vwOrgX := viewOrigin x. |
2224 | 1454 |
|
1455 |
item := list at:aLnrNr ifAbsent:nil. |
|
2307 | 1456 |
item isNil ifTrue:[ ^ vwOrgX ]. |
2224 | 1457 |
|
1458 |
level := item level. |
|
1459 |
level <= 2 ifTrue:[^ 0 ]. |
|
1460 |
||
2327 | 1461 |
xLft := self xVisibleOfIconAtLevel:(level - 1). |
2311 | 1462 |
lvWidth := self parentToChildInset. |
2224 | 1463 |
|
2327 | 1464 |
xRgt := (self xVisibleOfTextAtLevel:level) + (item widthOn:self). |
2224 | 1465 |
|
2233 | 1466 |
xLft > lvWidth negated ifTrue:[ |
1467 |
xRgt < width ifTrue:[^ vwOrgX] |
|
2224 | 1468 |
]. |
1469 |
||
2233 | 1470 |
xInset := ((width - (xRgt - xLft) // 2) // lvWidth * lvWidth) max:0. |
1471 |
vwOrgX := xLft + vwOrgX - xInset - margin. |
|
1472 |
vwOrgX < lvWidth ifTrue:[^ 0 ]. |
|
1473 |
^ vwOrgX |
|
2224 | 1474 |
! |
1475 |
||
1476 |
makeLineVisible:aLnrNr |
|
2327 | 1477 |
"make the line horizontal and vertical visible |
2224 | 1478 |
" |
1479 |
|newY item y0 newX| |
|
1480 |
||
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1481 |
alignTextRight ifTrue:[^ self]. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1482 |
|
2224 | 1483 |
(shown and:[aLnrNr notNil]) ifFalse:[^ self]. |
1484 |
||
1485 |
aLnrNr <= 1 ifTrue:[ |
|
1486 |
aLnrNr == 1 ifTrue:[ self scrollTo:(0 @ 0) ]. |
|
1487 |
^ self |
|
1488 |
]. |
|
1489 |
||
1490 |
item := list at:aLnrNr ifAbsent:nil. |
|
2307 | 1491 |
item isNil ifTrue:[^ self]. |
2224 | 1492 |
|
1493 |
y0 := self yVisibleOfLine:aLnrNr. |
|
1494 |
||
1495 |
( y0 < margin |
|
1496 |
or:[(y0 + (item heightOn:self)) > (height - margin)] |
|
1497 |
) ifTrue:[ |
|
1498 |
newY := ((self yAbsoluteOfLine:aLnrNr) - (height // 2)) max:0. |
|
1499 |
] ifFalse:[ |
|
1500 |
newY := viewOrigin y. |
|
1501 |
]. |
|
1502 |
||
1503 |
newX := viewOrigin x. |
|
1504 |
||
1505 |
(autoScrollHorizontal or:[newX ~~ 0]) ifTrue:[ |
|
1506 |
newX := self computeViewOriginXat:aLnrNr |
|
1507 |
]. |
|
1508 |
self scrollTo:(newX @ newY). |
|
1509 |
! |
|
1510 |
||
1511 |
makeSelectionVisible |
|
2327 | 1512 |
"make the firts line in the selection horizontal and vertical visible |
2224 | 1513 |
" |
1514 |
shown ifTrue:[ |
|
1515 |
self makeLineVisible:(self firstInSelection). |
|
1516 |
]. |
|
1517 |
! ! |
|
1518 |
||
1390 | 1519 |
!HierarchicalListView class methodsFor:'documentation'! |
1520 |
||
1521 |
version |
|
2335 | 1522 |
^ '$Header: /cvs/stx/stx/libwidg2/HierarchicalListView.st,v 1.67 2002-10-28 09:56:50 ca Exp $' |
1390 | 1523 |
! ! |