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