author | Stefan Vogel <sv@exept.de> |
Mon, 30 May 2005 17:45:13 +0200 | |
changeset 2822 | 3538a17ef98c |
parent 2814 | 612c60d1a9ba |
child 2866 | 01d609cfb3d9 |
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 |
|
2780 | 374 |
"returns true if automatic horizontal scrolling |
375 |
(upto the text label of the selected line) |
|
376 |
is allowed (the default is true)." |
|
377 |
||
2644 | 378 |
autoScrollHorizontal == true ifTrue:[ |
379 |
^ renderer autoScrollHorizontal |
|
380 |
]. |
|
381 |
^ false |
|
2224 | 382 |
! |
383 |
||
384 |
autoScrollHorizontal:aBoolean |
|
385 |
"true, than automatically scroll horizontal upto the text label |
|
386 |
of the current selected line. |
|
387 |
" |
|
388 |
autoScrollHorizontal := aBoolean. |
|
389 |
! |
|
390 |
||
391 |
expandOnSelect |
|
392 |
"true, than the item selected by a buttonPress event will |
|
393 |
be immediately expanded. |
|
394 |
" |
|
395 |
^ expandOnSelect |
|
396 |
! |
|
397 |
||
398 |
expandOnSelect:aBoolean |
|
399 |
"true, than the item selected by a buttonPress event will |
|
400 |
be immediately expanded. |
|
401 |
" |
|
402 |
expandOnSelect := aBoolean. |
|
403 |
! ! |
|
404 |
||
1818 | 405 |
!HierarchicalListView methodsFor:'accessing-colors'! |
1390 | 406 |
|
407 |
lineColor |
|
2307 | 408 |
"get the color of the horizontal and vertical lines |
1390 | 409 |
" |
410 |
^ lineColor |
|
411 |
! |
|
412 |
||
413 |
lineColor:aColor |
|
2307 | 414 |
"set the color of the horizontal and vertical lines |
1390 | 415 |
" |
416 |
(aColor notNil and:[aColor ~= lineColor]) ifTrue:[ |
|
417 |
lineColor := aColor. |
|
418 |
||
419 |
shown ifTrue:[ |
|
2099 | 420 |
lineColor := lineColor onDevice:device. |
2307 | 421 |
showLines ifTrue:[ self invalidate ] |
1390 | 422 |
] |
2307 | 423 |
]. |
1390 | 424 |
! ! |
425 |
||
1818 | 426 |
!HierarchicalListView methodsFor:'accessing-look'! |
1390 | 427 |
|
1568 | 428 |
alignTextRight |
429 |
"align the text right |
|
430 |
" |
|
431 |
^ alignTextRight |
|
432 |
! |
|
433 |
||
1757 | 434 |
alignTextRight:aBool |
435 |
"align the text right |
|
436 |
" |
|
437 |
alignTextRight := aBool ? false. |
|
438 |
! |
|
1568 | 439 |
|
1904 | 440 |
alignTextRightX |
441 |
"returns the minimum used text inset, if text is aligned right. |
|
442 |
" |
|
443 |
^ alignTextRightX |
|
444 |
! |
|
445 |
||
446 |
alignTextRightX:aNumber |
|
447 |
"set the minimum used text inset, if text is aligned right. |
|
448 |
" |
|
2383 | 449 |
aNumber > 0 ifTrue:[ |
1904 | 450 |
alignTextRightX := aNumber. |
451 |
||
452 |
(alignTextRight and:[widthOfContents notNil]) ifTrue:[ |
|
453 |
widthOfContents := alignTextRightX + maxWidthOfText. |
|
454 |
||
455 |
shown ifTrue:[ |
|
456 |
self invalidate. |
|
457 |
self contentsChanged. |
|
458 |
] |
|
459 |
] |
|
460 |
]. |
|
461 |
! |
|
462 |
||
2094 | 463 |
iconAt:aKey ifAbsentPut:aBlock |
464 |
"return the icon stored under a key; if not present,the |
|
465 |
result of the block if not nil is stored under the key |
|
466 |
and returned. |
|
467 |
" |
|
468 |
|icon| |
|
469 |
||
470 |
icon := icons at:aKey ifAbsent:nil. |
|
2307 | 471 |
icon notNil ifTrue:[^ icon]. |
2094 | 472 |
|
473 |
icon := aBlock value. |
|
2307 | 474 |
icon isNil ifTrue:[^ nil]. |
2094 | 475 |
|
476 |
realized ifTrue:[ |
|
2488
74c81c1e30d7
imageOnDevice -> imageOnMyDevice
Claus Gittinger <cg@exept.de>
parents:
2421
diff
changeset
|
477 |
icon := self imageOnMyDevice:icon |
2094 | 478 |
]. |
479 |
icons at:aKey put:icon. |
|
2814 | 480 |
^ icon |
2094 | 481 |
! |
482 |
||
1390 | 483 |
registerKeysAndIcons:aDictionary |
484 |
"register icons by key and value derived from a directory |
|
485 |
" |
|
486 |
|image| |
|
487 |
||
488 |
(aDictionary isNil or:[aDictionary isEmpty]) ifTrue:[ |
|
489 |
^ self |
|
490 |
]. |
|
491 |
||
492 |
aDictionary keysAndValuesDo:[:aKey :anImage| |
|
2488
74c81c1e30d7
imageOnDevice -> imageOnMyDevice
Claus Gittinger <cg@exept.de>
parents:
2421
diff
changeset
|
493 |
(image := self imageOnMyDevice:anImage) notNil ifTrue:[ |
1390 | 494 |
icons at:aKey put:image |
1746 | 495 |
] ifFalse:[ |
496 |
icons removeKey:aKey ifAbsent:nil |
|
1390 | 497 |
] |
498 |
] |
|
499 |
! |
|
500 |
||
2392 | 501 |
showIndicators |
502 |
"returns true if indicators are shown |
|
503 |
" |
|
504 |
^ showIndicators |
|
505 |
! |
|
506 |
||
507 |
showIndicators:aBoolean |
|
508 |
"true if indicators are shown |
|
509 |
" |
|
510 |
showIndicators ~~ aBoolean ifTrue:[ |
|
511 |
showIndicators := aBoolean. |
|
2659
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2645
diff
changeset
|
512 |
self invalidate. |
2392 | 513 |
]. |
514 |
! |
|
515 |
||
1390 | 516 |
showLeftIndicators |
517 |
"show or hide the indicators for the most left items |
|
518 |
" |
|
519 |
^ showLeftIndicators |
|
520 |
||
521 |
! |
|
522 |
||
2307 | 523 |
showLeftIndicators:aBoolean |
1390 | 524 |
"show or hide the indicators for the most left items |
525 |
" |
|
2392 | 526 |
|oldInset newInset| |
527 |
||
528 |
aBoolean == showLeftIndicators ifTrue:[ ^ self ]. |
|
529 |
||
2408 | 530 |
(widthOfContents isNil or:[self size == 0]) ifTrue:[ |
2307 | 531 |
showLeftIndicators := aBoolean. |
2392 | 532 |
^ self |
533 |
]. |
|
2383 | 534 |
|
2392 | 535 |
oldInset := self xVisibleOfIconAtLevel:3. |
536 |
showLeftIndicators := aBoolean. |
|
537 |
newInset := self xVisibleOfIconAtLevel:3. |
|
538 |
||
539 |
newInset ~~ oldInset ifTrue:[ |
|
540 |
widthOfContents := widthOfContents + (newInset - oldInset). |
|
541 |
]. |
|
542 |
||
2659
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2645
diff
changeset
|
543 |
self invalidate. |
2392 | 544 |
|
545 |
newInset ~~ oldInset ifTrue:[ |
|
546 |
self contentsChanged |
|
1390 | 547 |
]. |
548 |
! |
|
549 |
||
550 |
showLines |
|
551 |
"returns true if lines are shown |
|
552 |
" |
|
2307 | 553 |
^ showLines |
1390 | 554 |
! |
555 |
||
2307 | 556 |
showLines:aBoolean |
1390 | 557 |
"show or hide lines |
558 |
" |
|
2307 | 559 |
aBoolean ~~ showLines ifTrue:[ |
560 |
showLines := aBoolean. |
|
2659
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2645
diff
changeset
|
561 |
self invalidate. |
1390 | 562 |
]. |
563 |
! |
|
564 |
||
2421 | 565 |
showRoot |
566 |
"true if the root is shown |
|
567 |
" |
|
568 |
^ showRoot |
|
569 |
! |
|
570 |
||
571 |
showRoot:aBoolean |
|
572 |
"true if the root is shown |
|
573 |
" |
|
574 |
showRoot ~~ aBoolean ifTrue:[ |
|
575 |
showRoot := aBoolean. |
|
2595
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2554
diff
changeset
|
576 |
self list showRoot:showRoot. |
2659
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2645
diff
changeset
|
577 |
self invalidate |
2421 | 578 |
]. |
579 |
! |
|
580 |
||
1390 | 581 |
useDefaultIcons |
582 |
"use the default icons if no icon for an item is specified; |
|
583 |
** default: true |
|
584 |
" |
|
585 |
^ useDefaultIcons |
|
586 |
! |
|
587 |
||
2307 | 588 |
useDefaultIcons:aBoolean |
1390 | 589 |
"use the default icons if no icon for an item is specified; |
590 |
** default: true |
|
591 |
" |
|
2307 | 592 |
useDefaultIcons ~~ aBoolean ifTrue:[ |
593 |
useDefaultIcons := aBoolean. |
|
2659
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2645
diff
changeset
|
594 |
self invalidate. |
1390 | 595 |
] |
596 |
! ! |
|
597 |
||
598 |
!HierarchicalListView methodsFor:'actions'! |
|
599 |
||
600 |
indicatorAction |
|
2392 | 601 |
"the action evaluated if an indicator is pressed; otherwise |
602 |
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
|
603 |
|
a0b7d30a4073
instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents:
2414
diff
changeset
|
604 |
The arguments to the block are: |
a0b7d30a4073
instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents:
2414
diff
changeset
|
605 |
- no argument |
a0b7d30a4073
instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents:
2414
diff
changeset
|
606 |
- 1 argument index |
a0b7d30a4073
instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents:
2414
diff
changeset
|
607 |
- 2 argument index, self |
1390 | 608 |
" |
609 |
^ indicatorAction |
|
610 |
! |
|
611 |
||
612 |
indicatorAction:anAction |
|
2392 | 613 |
"the action evaluated if an indicator is pressed; otherwise |
614 |
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
|
615 |
|
a0b7d30a4073
instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents:
2414
diff
changeset
|
616 |
The arguments to the block are: |
a0b7d30a4073
instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents:
2414
diff
changeset
|
617 |
- no argument |
a0b7d30a4073
instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents:
2414
diff
changeset
|
618 |
- 1 argument index |
a0b7d30a4073
instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents:
2414
diff
changeset
|
619 |
- 2 argument index, self |
1390 | 620 |
" |
621 |
indicatorAction := anAction. |
|
622 |
! ! |
|
623 |
||
624 |
!HierarchicalListView methodsFor:'change & update'! |
|
625 |
||
1782 | 626 |
indicatorPressedAt:aLnNr |
2224 | 627 |
"handle indicator pressed action; |
628 |
if the item changed expanded, we try to show all |
|
2822 | 629 |
new visible children" |
630 |
||
631 |
|item expanded dl| |
|
2224 | 632 |
|
2392 | 633 |
showIndicators ifFalse:[^ self]. |
2224 | 634 |
|
2408 | 635 |
item := self at:aLnNr ifAbsent:nil. |
2307 | 636 |
item isNil ifTrue:[^ self]. |
2224 | 637 |
|
638 |
item hasIndicator ifFalse:[^ self]. |
|
639 |
||
640 |
expanded := item isExpanded. |
|
2392 | 641 |
|
642 |
indicatorAction notNil ifTrue:[ |
|
2417
a0b7d30a4073
instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents:
2414
diff
changeset
|
643 |
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
|
644 |
] ifFalse:[ |sensor| |
9a907b626499
Do recursive toggelExpand if an indicator is pressed with shift or control
Stefan Vogel <sv@exept.de>
parents:
2518
diff
changeset
|
645 |
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
|
646 |
(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
|
647 |
item recursiveToggleExpand |
9a907b626499
Do recursive toggelExpand if an indicator is pressed with shift or control
Stefan Vogel <sv@exept.de>
parents:
2518
diff
changeset
|
648 |
] ifFalse:[ |
9a907b626499
Do recursive toggelExpand if an indicator is pressed with shift or control
Stefan Vogel <sv@exept.de>
parents:
2518
diff
changeset
|
649 |
item toggleExpand |
9a907b626499
Do recursive toggelExpand if an indicator is pressed with shift or control
Stefan Vogel <sv@exept.de>
parents:
2518
diff
changeset
|
650 |
]. |
2392 | 651 |
]. |
652 |
||
2224 | 653 |
(expanded or:[item isExpanded not]) ifTrue:[^ self]. |
1783
ffe767ea66ea
check whether children exists before calling indicatorPressed action
ca
parents:
1782
diff
changeset
|
654 |
|
2769
1315a31fa1e8
do not scroll when expanding
Claus Gittinger <cg@exept.de>
parents:
2726
diff
changeset
|
655 |
(self yVisibleOfLine:aLnNr+1) > self height ifTrue:[ |
1315a31fa1e8
do not scroll when expanding
Claus Gittinger <cg@exept.de>
parents:
2726
diff
changeset
|
656 |
dl := (self yVisibleOfLine:aLnNr+1) - (self yVisibleOfLine:aLnNr). |
1315a31fa1e8
do not scroll when expanding
Claus Gittinger <cg@exept.de>
parents:
2726
diff
changeset
|
657 |
self scrollTo:(viewOrigin x @ (viewOrigin y + dl)). |
1315a31fa1e8
do not scroll when expanding
Claus Gittinger <cg@exept.de>
parents:
2726
diff
changeset
|
658 |
]. |
2224 | 659 |
|
2769
1315a31fa1e8
do not scroll when expanding
Claus Gittinger <cg@exept.de>
parents:
2726
diff
changeset
|
660 |
"/ numChildren := item numberOfVisibleChildren. |
1315a31fa1e8
do not scroll when expanding
Claus Gittinger <cg@exept.de>
parents:
2726
diff
changeset
|
661 |
"/ numChildren == 0 ifTrue:[ |
1315a31fa1e8
do not scroll when expanding
Claus Gittinger <cg@exept.de>
parents:
2726
diff
changeset
|
662 |
"/ ^ self |
1315a31fa1e8
do not scroll when expanding
Claus Gittinger <cg@exept.de>
parents:
2726
diff
changeset
|
663 |
"/ ]. |
1315a31fa1e8
do not scroll when expanding
Claus Gittinger <cg@exept.de>
parents:
2726
diff
changeset
|
664 |
^ self |
2224 | 665 |
|
2769
1315a31fa1e8
do not scroll when expanding
Claus Gittinger <cg@exept.de>
parents:
2726
diff
changeset
|
666 |
"/ idx := aLnNr + numChildren. |
1315a31fa1e8
do not scroll when expanding
Claus Gittinger <cg@exept.de>
parents:
2726
diff
changeset
|
667 |
"/ vwOrgY := viewOrigin y. |
1315a31fa1e8
do not scroll when expanding
Claus Gittinger <cg@exept.de>
parents:
2726
diff
changeset
|
668 |
"/ availY := (self yVisibleOfLine:aLnNr) - (self yVisibleOfLine:1). |
1315a31fa1e8
do not scroll when expanding
Claus Gittinger <cg@exept.de>
parents:
2726
diff
changeset
|
669 |
"/ |
1315a31fa1e8
do not scroll when expanding
Claus Gittinger <cg@exept.de>
parents:
2726
diff
changeset
|
670 |
"/ availY > margin ifTrue:[ |
1315a31fa1e8
do not scroll when expanding
Claus Gittinger <cg@exept.de>
parents:
2726
diff
changeset
|
671 |
"/ usedY := (self yVisibleOfLine:(idx + 1)) - (height - margin - margin). |
1315a31fa1e8
do not scroll when expanding
Claus Gittinger <cg@exept.de>
parents:
2726
diff
changeset
|
672 |
"/ |
1315a31fa1e8
do not scroll when expanding
Claus Gittinger <cg@exept.de>
parents:
2726
diff
changeset
|
673 |
"/ usedY > 1 ifTrue:[ |
1315a31fa1e8
do not scroll when expanding
Claus Gittinger <cg@exept.de>
parents:
2726
diff
changeset
|
674 |
"/ vwOrgY := vwOrgY + (usedY min:availY). |
1315a31fa1e8
do not scroll when expanding
Claus Gittinger <cg@exept.de>
parents:
2726
diff
changeset
|
675 |
"/ ]. |
1315a31fa1e8
do not scroll when expanding
Claus Gittinger <cg@exept.de>
parents:
2726
diff
changeset
|
676 |
"/ ]. |
1315a31fa1e8
do not scroll when expanding
Claus Gittinger <cg@exept.de>
parents:
2726
diff
changeset
|
677 |
"/ vwOrgX := self computeViewOriginXat:aLnNr. |
1315a31fa1e8
do not scroll when expanding
Claus Gittinger <cg@exept.de>
parents:
2726
diff
changeset
|
678 |
"/ self scrollTo:(vwOrgX @ vwOrgY). |
1782 | 679 |
! |
680 |
||
1390 | 681 |
lineChangedAt:aLnNr with:arg |
682 |
"line changed at position; check whether line height changed |
|
683 |
" |
|
684 |
|item |
|
2317 | 685 |
level "{ Class:SmallInteger }" |
1390 | 686 |
x0 "{ Class:SmallInteger }" |
687 |
x1 "{ Class:SmallInteger }" |
|
688 |
y0 "{ Class:SmallInteger }" |
|
689 |
y1 "{ Class:SmallInteger }" |
|
2303 | 690 |
yB "{ Class:SmallInteger }" |
1390 | 691 |
| |
692 |
||
2408 | 693 |
item := self at:aLnNr ifAbsent:nil. |
2317 | 694 |
item isNil ifTrue:[^ self]. |
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
695 |
|
1399 | 696 |
(arg == #icon or:[arg == #hierarchy]) ifFalse:[ |
2224 | 697 |
super lineChangedAt:aLnNr with:arg. |
698 |
||
699 |
(arg ~~ #redraw and:[widthOfContents notNil]) ifTrue:[ |
|
2327 | 700 |
x0 := (self xVisibleOfTextAtLevel:(item level)) |
2353 | 701 |
+ (renderer widthFor:item) |
2229 | 702 |
+ (viewOrigin x). |
2224 | 703 |
|
704 |
x0 > widthOfContents ifTrue:[ |
|
705 |
widthOfContents := x0. |
|
706 |
self contentsChanged. |
|
707 |
] |
|
708 |
]. |
|
709 |
^ self |
|
1390 | 710 |
]. |
2317 | 711 |
level := item level. |
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
712 |
|
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
713 |
(alignTextRight and:[arg == #hierarchy]) ifTrue:[ |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
714 |
"/ must test whether alignTextRightX is enough |
2317 | 715 |
(item isExpanded and:[item hasChildren]) ifTrue:[ |
2327 | 716 |
x0 := self xVisibleOfIconAtLevel:(level + 2). |
2316
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 |
alignTextRightX < x0 ifTrue:[ |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
719 |
alignTextRightX := x0. |
2659
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2645
diff
changeset
|
720 |
self invalidate. |
2316
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 |
widthOfContents notNil ifTrue:[ |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
723 |
widthOfContents := alignTextRightX + maxWidthOfText. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
724 |
self contentsChanged. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
725 |
]. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
726 |
^ self. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
727 |
] |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
728 |
] |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
729 |
]. |
1568 | 730 |
shown ifFalse:[^ self]. |
731 |
||
2303 | 732 |
yB := height - margin. |
733 |
y0 := (self yVisibleOfLine:aLnNr) max:margin. |
|
734 |
y0 < yB ifFalse:[ ^ self ]. |
|
1390 | 735 |
|
2303 | 736 |
y1 := (self yVisibleOfLine:(aLnNr + 1)) min:yB. |
737 |
y1 > y0 ifFalse:[^ self]. |
|
1399 | 738 |
|
2327 | 739 |
x1 := (self xVisibleOfTextAtLevel:level) - 1. |
2317 | 740 |
x1 > margin ifFalse:[^ self]. |
1390 | 741 |
|
2383 | 742 |
x0 := (self xVisibleOfIndicatorAtLevel:level) max:margin. |
2317 | 743 |
x1 := x1 min:(width - margin). |
2303 | 744 |
|
2317 | 745 |
x0 < x1 ifTrue:[ |
746 |
self invalidate:(Rectangle left:x0 top:y0 width:(x1 - x0) height:(y1 - y0)) |
|
747 |
repairNow:false. |
|
2303 | 748 |
]. |
1976
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
749 |
! |
1390 | 750 |
|
1976
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
751 |
listChangedInsert:firstAddedIndex nItems:nLines |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
752 |
"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
|
753 |
" |
2210 | 754 |
|item level yTop yBot xLft start maxY| |
1390 | 755 |
|
1976
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
756 |
super listChangedInsert:firstAddedIndex nItems:nLines. |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
757 |
|
2408 | 758 |
item := self last. |
2210 | 759 |
levelOfLastItem := item level. |
760 |
||
1976
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
761 |
( shown |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
762 |
and:[showLines |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
763 |
and:[firstAddedIndex > 1 |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
764 |
and:[nLines ~~ 0 |
2408 | 765 |
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
|
766 |
and:[(level := item level) > 1]]]]] |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
767 |
) ifFalse:[ |
2383 | 768 |
^ self. |
1976
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
769 |
]. |
2383 | 770 |
xLft := self xVisibleOfVerticalLineAt:level. |
1390 | 771 |
|
1976
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
772 |
(xLft > margin and:[xLft < (width - margin)]) ifFalse:[ |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
773 |
^ self |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
774 |
]. |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
775 |
start := firstAddedIndex - 1. |
1390 | 776 |
|
1976
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
777 |
start to:1 by:-1 do:[:i| |el| |
2408 | 778 |
el := self at:i. |
1399 | 779 |
|
1976
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
780 |
el level <= level ifTrue:[ |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
781 |
i == start ifTrue:[^ self]. |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
782 |
|
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
783 |
yTop := (self yVisibleOfLine:i + 1) max:margin. |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
784 |
maxY := height - margin. |
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 |
yTop < maxY ifTrue:[ |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
787 |
yBot := (self yVisibleOfLine:firstAddedIndex) - 1 min:maxY. |
2383 | 788 |
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
|
789 |
]. |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
790 |
^ self |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
791 |
] |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
792 |
]. |
1390 | 793 |
! |
794 |
||
2208 | 795 |
listChangedRemove:aStart toIndex:aStop |
796 |
"test whether last items are deleted; |
|
797 |
than we have to redraw lines because of different levels |
|
798 |
" |
|
2210 | 799 |
|listSize index y0 searchLevel| |
2208 | 800 |
|
2408 | 801 |
listSize := self size. |
2210 | 802 |
searchLevel := levelOfLastItem. |
2208 | 803 |
|
2307 | 804 |
listSize == 0 ifTrue:[ levelOfLastItem := 1 ] |
2408 | 805 |
ifFalse:[ levelOfLastItem := self last level ]. |
2208 | 806 |
|
2307 | 807 |
(shown and:[showLines and:[listSize ~~ 0 and:[aStart > listSize]]]) ifTrue:[ |
2408 | 808 |
index := self findLast:[:el| el level <= searchLevel ]. |
2208 | 809 |
|
810 |
(index ~~ 0 and:[index < listSize]) ifTrue:[ |
|
811 |
y0 := (self yVisibleOfLine:index) max:margin. |
|
812 |
self invalidateX:0 y:y0 width:width height:(height - margin - y0). |
|
813 |
] |
|
814 |
]. |
|
815 |
^ super listChangedRemove:aStart toIndex:aStop |
|
816 |
! |
|
817 |
||
2644 | 818 |
updateFromList:what with:aPara |
1390 | 819 |
"get the status of <showRoot> from the list |
820 |
" |
|
2644 | 821 |
|newState| |
822 |
||
823 |
newState := self list showRoot. |
|
824 |
||
825 |
showRoot ~~ newState ifTrue:[ |
|
826 |
showRoot := newState. |
|
827 |
self invalidate. |
|
1390 | 828 |
]. |
2644 | 829 |
super updateFromList:what with:aPara. |
1390 | 830 |
! ! |
831 |
||
832 |
!HierarchicalListView methodsFor:'drawing basics'! |
|
833 |
||
1568 | 834 |
drawElementsFrom:start to:stop x:xLeft y:yT w:w |
1390 | 835 |
"draw the items between start to stop without clearing the background |
836 |
" |
|
2383 | 837 |
|item prevParent icon showIndc showIcon showText |
1568 | 838 |
yTop "{ Class:SmallInteger }" |
839 |
yCtr "{ Class:SmallInteger }" |
|
840 |
yBot "{ Class:SmallInteger }" |
|
2383 | 841 |
level "{ Class:SmallInteger }" |
1390 | 842 |
|
1568 | 843 |
xIndc "{ Class:SmallInteger }" |
844 |
xIcon "{ Class:SmallInteger }" |
|
845 |
xText "{ Class:SmallInteger }" |
|
846 |
xL "{ Class:SmallInteger }" |
|
847 |
xR "{ Class:SmallInteger }" |
|
848 |
height "{ Class:SmallInteger }" |
|
1390 | 849 |
|
1568 | 850 |
offIndcY "{ Class:SmallInteger }" |
1390 | 851 |
| |
2383 | 852 |
xL := xLeft. |
853 |
xR := xL + w. |
|
1390 | 854 |
|
2392 | 855 |
showIndicators ifTrue:[ |
2383 | 856 |
offIndcY := openIndicator width // 2. |
1390 | 857 |
]. |
858 |
||
859 |
showLines ifTrue:[ |
|
1399 | 860 |
self drawLinesFrom:start to:stop x:xL y:yT toX:xR |
1390 | 861 |
]. |
2383 | 862 |
prevParent := #NIL. "/ to force a recompute |
863 |
yBot := yT. |
|
864 |
showIndc := false. |
|
1390 | 865 |
|
866 |
start to:stop do:[:anIndex| |
|
2408 | 867 |
(item := self at:anIndex ifAbsent:nil) isNil ifTrue:[ |
1390 | 868 |
^ self "/ list changed |
869 |
]. |
|
2383 | 870 |
yTop := yBot. |
871 |
yBot := self yVisibleOfLine:(anIndex + 1). |
|
1532
56e0fafc4349
change display protocol for item
Claus Gittinger <cg@exept.de>
parents:
1509
diff
changeset
|
872 |
height := yBot - yTop. |
2383 | 873 |
yCtr := yTop + (height // 2). |
1390 | 874 |
|
2383 | 875 |
item parent ~~ prevParent ifTrue:[ |
876 |
prevParent := item parent. |
|
877 |
level := item level. |
|
878 |
xIcon := self xVisibleOfIconAtLevel:level. |
|
879 |
xText := self xVisibleOfTextAtLevel:level. |
|
880 |
showText := (xText < xR). |
|
881 |
showIcon := (xIcon < xR and:[xText > xL]). |
|
1390 | 882 |
|
2392 | 883 |
showIndicators ifTrue:[ |
2383 | 884 |
xIndc := self xVisibleOfIndicatorAtLevel:level. |
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
885 |
showIndc := (xIcon > xL and:[xIndc < xR]). |
1390 | 886 |
|
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
887 |
showIndc ifTrue:[ |
2383 | 888 |
showIndc := prevParent notNil or:[showLeftIndicators] |
1756 | 889 |
] |
1390 | 890 |
] |
891 |
]. |
|
892 |
||
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
893 |
(showIcon and:[(icon := self validateDrawableIconFor:item) notNil]) ifTrue:[ |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
894 |
(xIcon + icon width) > xL ifTrue:[ |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
895 |
icon displayOn:self x:xIcon y:(yCtr - (icon height // 2)) |
1568 | 896 |
] |
1390 | 897 |
]. |
898 |
||
899 |
showText ifTrue:[ |
|
1532
56e0fafc4349
change display protocol for item
Claus Gittinger <cg@exept.de>
parents:
1509
diff
changeset
|
900 |
self drawLabelAt:anIndex x:xText y:yTop h:height |
1390 | 901 |
]. |
2201
aa74fa6137a5
make indicator dependent on hasIndicator and not hasChildren
ca
parents:
2181
diff
changeset
|
902 |
(showIndc and:[item hasIndicator]) ifTrue:[ |
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
903 |
item isExpanded ifTrue:[icon := openIndicator ] |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
904 |
ifFalse:[icon := closeIndicator]. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
905 |
|
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
906 |
icon displayOn:self x:xIndc y:(yCtr - offIndcY) |
1390 | 907 |
]. |
2383 | 908 |
]. |
1390 | 909 |
! |
910 |
||
1399 | 911 |
drawLinesFrom:start to:stop x:xL y:yT toX:xR |
1390 | 912 |
"draw the lines between start to stop without clearing the background |
913 |
" |
|
2383 | 914 |
|item prevItem parent p1 p2 showVLines showHLine lv buildInArray showLeftIdc |
1390 | 915 |
|
916 |
x "{ Class:SmallInteger }" |
|
1570 | 917 |
xText "{ Class:SmallInteger }" |
918 |
||
1390 | 919 |
y "{ Class:SmallInteger }" |
920 |
yTop "{ Class:SmallInteger }" |
|
921 |
yBot "{ Class:SmallInteger }" |
|
922 |
yCtr "{ Class:SmallInteger }" |
|
923 |
||
924 |
begHLnY "{ Class:SmallInteger }" |
|
925 |
runHLnY "{ Class:SmallInteger }" |
|
2383 | 926 |
lftVrtX "{ Class:SmallInteger }" |
927 |
rgtVrtX "{ Class:SmallInteger }" |
|
928 |
level "{ Class:SmallInteger }" |
|
1390 | 929 |
|
2383 | 930 |
minVertLevel "{ Class:SmallInteger }" |
931 |
minHorzLevel "{ Class:SmallInteger }" |
|
932 |
smallestLevel "{ Class:SmallInteger }" |
|
1390 | 933 |
| |
2383 | 934 |
parent := prevItem := 4711. "/ to force a recompute |
1390 | 935 |
|
936 |
self setMaskOrigin:(self viewOrigin + (0 @ 1) \\ (lineMask extent)). |
|
937 |
self paint:lineColor on:bgColor. |
|
938 |
self mask:lineMask. |
|
2383 | 939 |
|
940 |
smallestLevel := self smallestLevelBetween:start and:stop. |
|
2392 | 941 |
minVertLevel := 2. |
942 |
||
943 |
showLeftIndicators ifTrue:[ |
|
944 |
showLeftIdc := showIndicators. |
|
945 |
showRoot ifFalse:[ minVertLevel := 3 ] |
|
946 |
] ifFalse:[ |
|
947 |
showLeftIdc := false. |
|
948 |
]. |
|
2383 | 949 |
|
950 |
showRoot ifFalse:[ minHorzLevel := 2 ] |
|
951 |
ifTrue:[ minHorzLevel := 1 ]. |
|
1390 | 952 |
|
2392 | 953 |
showLeftIdc ifFalse:[ |
954 |
minHorzLevel := minHorzLevel + 1. |
|
1897
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
955 |
]. |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
956 |
|
2383 | 957 |
yBot := begHLnY := runHLnY := yT. |
958 |
level := 1. |
|
1570 | 959 |
|
1390 | 960 |
start to:stop do:[:anIndex| |
2408 | 961 |
(item := self at:anIndex ifAbsent:nil) isNil ifTrue:[ |
1390 | 962 |
^ self mask:nil "/ list changed |
963 |
]. |
|
964 |
yTop := yBot. |
|
965 |
yBot := self yVisibleOfLine:(anIndex + 1). |
|
966 |
yCtr := yTop + (yBot - yTop // 2). |
|
967 |
||
2383 | 968 |
item parent ~~ parent ifTrue:[ |
969 |
anIndex == 1 ifTrue:[ begHLnY := runHLnY := yCtr ]. |
|
970 |
parent := item parent. |
|
1390 | 971 |
|
972 |
prevItem == parent ifTrue:[ |
|
1567 | 973 |
level := level + 1. |
2383 | 974 |
lftVrtX := rgtVrtX. |
1390 | 975 |
] ifFalse:[ |
976 |
level := item level. |
|
2383 | 977 |
lftVrtX := self xVisibleOfVerticalLineAt:level. |
1390 | 978 |
]. |
2383 | 979 |
showVLines := (level >= minVertLevel and:[lftVrtX >= xL]). |
980 |
rgtVrtX := self xVisibleOfVerticalLineAt:level + 1. |
|
1570 | 981 |
|
2383 | 982 |
level >= minHorzLevel ifTrue:[ |
983 |
xText := (self xVisibleOfTextAtLevel:level) - textStartLeft. |
|
984 |
showHLine := (xL < xText and:[xR > lftVrtX]). |
|
985 |
] ifFalse:[ |
|
986 |
showHLine := false |
|
1570 | 987 |
]. |
1390 | 988 |
]. |
989 |
||
990 |
showHLine ifTrue:[ |
|
2383 | 991 |
( level ~~ 2 |
992 |
or:[showRoot or:[(showLeftIdc and:[item hasIndicator])]] |
|
993 |
) ifTrue:[ |
|
994 |
item drawHorizontalLineUpToText ifTrue:[ x := xText ] |
|
995 |
ifFalse:[ x := rgtVrtX ]. |
|
996 |
||
997 |
self displayLineFromX:lftVrtX y:yCtr toX:x y:yCtr. |
|
1570 | 998 |
]. |
2383 | 999 |
]. |
1000 |
||
1001 |
anIndex == start ifTrue:[ |
|
1002 |
(item isExpanded and:[item hasChildren]) ifTrue:[ |
|
1003 |
self displayLineFromX:rgtVrtX y:yCtr toX:rgtVrtX y:yBot. |
|
1570 | 1004 |
] |
1390 | 1005 |
]. |
1006 |
||
1007 |
showVLines ifTrue:[ |
|
2383 | 1008 |
parent last == item ifTrue:[ y := yCtr ] |
1009 |
ifFalse:[ y := yBot ]. |
|
1010 |
x := lftVrtX. |
|
1390 | 1011 |
p2 := parent. |
1012 |
lv := level - 1. |
|
1897
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
1013 |
|
2383 | 1014 |
level >= smallestLevel ifTrue:[ |
1897
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
1015 |
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
|
1016 |
]. |
1390 | 1017 |
|
2383 | 1018 |
[ (p2 notNil and:[lv >= minVertLevel]) ] whileTrue:[ |
1019 |
p1 := p2 parent. |
|
1020 |
||
1021 |
p1 notNil ifTrue:[ |
|
1022 |
x := self xVisibleOfVerticalLineAt:lv. |
|
1023 |
||
1024 |
x < xL ifTrue:[ |
|
1025 |
p1 := nil. |
|
1390 | 1026 |
] ifFalse:[ |
2383 | 1027 |
p1 last ~~ p2 ifTrue:[ |
1028 |
lv >= smallestLevel ifTrue:[ |
|
1029 |
self displayLineFromX:x y:(yTop - 1) toX:x y:yBot |
|
1030 |
] ifFalse:[ |
|
1031 |
buildInArray isNil ifTrue:[buildInArray := Array new:smallestLevel]. |
|
1032 |
buildInArray at:lv put:yBot |
|
1033 |
] |
|
1034 |
]. |
|
1390 | 1035 |
]. |
1036 |
]. |
|
2383 | 1037 |
p2 := p1. |
1390 | 1038 |
lv := lv - 1. |
2383 | 1039 |
]. |
1390 | 1040 |
]. |
1041 |
prevItem := item. |
|
1042 |
runHLnY := yCtr. |
|
1043 |
]. |
|
1044 |
||
1567 | 1045 |
buildInArray notNil ifTrue:[ |
1046 |
y := begHLnY. |
|
1390 | 1047 |
|
2383 | 1048 |
2 to:smallestLevel do:[:i| |u yB| |
1049 |
(yB := buildInArray at:i) notNil ifTrue:[ |
|
1050 |
x := self xVisibleOfVerticalLineAt:i. |
|
1596 | 1051 |
|
2383 | 1052 |
x >= xL ifTrue:[ |
1897
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
1053 |
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
|
1054 |
] |
1567 | 1055 |
]. |
1390 | 1056 |
] |
1057 |
]. |
|
1058 |
self mask:nil. |
|
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1059 |
! |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1060 |
|
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1061 |
validateDrawableIconFor:anItem |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1062 |
"returns the icon to be drawn for an item or nil |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1063 |
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
|
1064 |
" |
2383 | 1065 |
|width needMore icon maxLevel startOfText oldX newX| |
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1066 |
|
2327 | 1067 |
icon := self iconFor:anItem. |
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1068 |
icon isNil ifTrue:[^ nil]. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1069 |
|
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1070 |
width := icon width. |
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 |
(constantHeight notNil and:[icon height > constantHeight]) ifTrue:[ |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1073 |
constantHeight := icon height + lineSpacing. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1074 |
self recomputeHeightOfContents. |
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 |
width <= imageWidth ifTrue:[ |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1077 |
self contentsChanged. |
2551 | 1078 |
StopRedrawSignal raiseRequest |
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1079 |
]. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1080 |
] ifFalse:[ |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1081 |
width <= imageWidth ifTrue:[ ^ icon ]. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1082 |
]. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1083 |
|
2383 | 1084 |
maxLevel := 1. |
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1085 |
|
2595
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2554
diff
changeset
|
1086 |
self list criticalDo:[ |
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2554
diff
changeset
|
1087 |
self list do:[:el| maxLevel := maxLevel max:(el level) ]. |
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1088 |
]. |
2383 | 1089 |
|
1090 |
needMore := (width - imageWidth) max:2. |
|
1091 |
oldX := self xVisibleOfIconAtLevel:(maxLevel + 1). |
|
1092 |
imageWidth := imageWidth + needMore. |
|
1093 |
newX := self xVisibleOfIconAtLevel:(maxLevel + 1). |
|
1094 |
alignTextRightX := alignTextRightX max:newX. |
|
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1095 |
|
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1096 |
widthOfContents notNil ifTrue:[ |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1097 |
alignTextRight ifTrue:[ |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1098 |
widthOfContents := alignTextRightX + maxWidthOfText |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1099 |
] ifFalse:[ |
2383 | 1100 |
widthOfContents := widthOfContents + (newX - oldX) |
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1101 |
]. |
2353 | 1102 |
width := renderer widthFor:anItem. |
2327 | 1103 |
startOfText := self xVisibleOfTextAtLevel:(anItem level). |
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1104 |
widthOfContents := widthOfContents max:(startOfText + width). |
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 |
width > maxWidthOfText ifTrue:[ |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1107 |
maxWidthOfText := width |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1108 |
]. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1109 |
]. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1110 |
self contentsChanged. |
2554 | 1111 |
StopRedrawSignal raiseRequest. |
2353 | 1112 |
^ icon |
1390 | 1113 |
! ! |
1114 |
||
1115 |
!HierarchicalListView methodsFor:'event handling'! |
|
1116 |
||
1757 | 1117 |
buttonPress:button x:x y:y |
2791 | 1118 |
"handle a button press event" |
1119 |
||
2313 | 1120 |
|line item x0 y0| |
2224 | 1121 |
|
1122 |
enabled ifFalse:[^ self]. |
|
2361 | 1123 |
self closeEditor. |
2224 | 1124 |
|
2313 | 1125 |
line := self yVisibleToLineNr:y. |
1126 |
line notNil ifTrue:[ |
|
2408 | 1127 |
item := self at:line ifAbsent:nil. |
2313 | 1128 |
item notNil ifTrue:[ |
2518 | 1129 |
x0 := self xVisibleOfIconAtLevel:(item level). |
2313 | 1130 |
x >= x0 ifTrue:[ |
2518 | 1131 |
x0 := self xVisibleOfTextAtLevel:(item level). |
2313 | 1132 |
y0 := self yVisibleOfLine:line. |
2224 | 1133 |
|
2518 | 1134 |
x >= x0 ifTrue:[ |
1135 |
(item processButtonPress:button x:(x - x0) y:(y - y0) on:self) == true ifTrue:[ |
|
1136 |
^ self |
|
1137 |
] |
|
1138 |
] ifFalse:[ |
|
1139 |
(item processButtonPressOnIcon:button on:self) == true ifTrue:[ |
|
1140 |
^ self |
|
1141 |
] |
|
1142 |
] |
|
2313 | 1143 |
]. |
1144 |
] |
|
1145 |
] ifFalse:[ |
|
1146 |
item := nil |
|
1147 |
]. |
|
1148 |
||
2392 | 1149 |
showIndicators ifTrue:[ |
1150 |
(button == 1 or:[button == #select]) ifTrue:[ |
|
1151 |
(item notNil and:[item hasIndicator]) ifTrue:[ |
|
1152 |
x0 := self xVisibleOfIndicatorAtLevel:(item level). |
|
2313 | 1153 |
|
2392 | 1154 |
(x between:x0 and:(x0 + openIndicator width)) ifTrue:[ |
1155 |
self indicatorPressedAt:line. |
|
1156 |
^ self |
|
1157 |
]. |
|
2313 | 1158 |
]. |
2224 | 1159 |
]. |
1160 |
]. |
|
2313 | 1161 |
|
2224 | 1162 |
super buttonPress:button x:x y:y. |
1163 |
! |
|
1390 | 1164 |
|
2224 | 1165 |
buttonPressOrReleaseAtLine:aLnNr x:x y:y |
1166 |
"handle a button press or release at a line |
|
1167 |
" |
|
1168 |
|oldIdx newIdx newItem| |
|
1169 |
||
1170 |
oldIdx := self selectedIndex. |
|
1171 |
super buttonPressOrReleaseAtLine:aLnNr x:x y:y. |
|
1172 |
newIdx := self selectedIndex. |
|
1173 |
||
1174 |
(newIdx ~~ oldIdx and:[newIdx ~~ 0]) ifTrue:[ |
|
1175 |
expandOnSelect ifTrue:[ |
|
2408 | 1176 |
newItem := self at:newIdx ifAbsent:nil. |
2307 | 1177 |
newItem isNil ifTrue:[^ self]. |
2224 | 1178 |
newItem expand |
1390 | 1179 |
]. |
2224 | 1180 |
self makeLineVisible:newIdx. |
1181 |
]. |
|
1757 | 1182 |
! |
1183 |
||
1184 |
keyPress:aKey x:x y:y |
|
1185 |
"a key was pressed - handle page-keys here |
|
1186 |
" |
|
1784 | 1187 |
<resource: #keyboard( #CursorLeft #CursorRight )> |
1757 | 1188 |
|
2377 | 1189 |
|item lineNr isCursorLeft| |
1757 | 1190 |
|
1782 | 1191 |
enabled ifFalse:[^ self]. |
2377 | 1192 |
|
1193 |
( aKey == Character space |
|
1194 |
or:[aKey == #CursorRight |
|
1195 |
or:[aKey == #CursorLeft]] |
|
1196 |
) ifFalse:[ |
|
1197 |
super keyPress:aKey x:x y:y. |
|
1198 |
^ self |
|
1199 |
]. |
|
1200 |
||
1201 |
lineNr := self cursorLine. |
|
1202 |
||
1203 |
lineNr ~~ 0 ifTrue:[ |
|
1204 |
item := cursorItem |
|
1205 |
] ifFalse:[ |
|
1206 |
lineNr := self selectedIndex. |
|
1207 |
lineNr == 0 ifTrue:[^ self]. |
|
1208 |
||
2408 | 1209 |
item := self at:lineNr ifAbsent:nil. |
2377 | 1210 |
item isNil ifTrue:[^ self]. |
1211 |
]. |
|
1782 | 1212 |
|
1213 |
aKey == Character space ifTrue:[ |
|
2378 | 1214 |
item toggleExpand. |
2377 | 1215 |
^ self |
1216 |
]. |
|
1217 |
isCursorLeft := aKey == #CursorLeft. |
|
1218 |
||
1219 |
item isExpanded == isCursorLeft ifTrue:[ |
|
2378 | 1220 |
item toggleExpand. |
2377 | 1221 |
^ self |
1782 | 1222 |
]. |
2377 | 1223 |
isCursorLeft ifTrue:[ |
1224 |
(item := item parent) isNil ifTrue:[^ self]. |
|
2408 | 1225 |
lineNr := self identityIndexOf:item. |
2377 | 1226 |
] ifFalse:[ |
1227 |
item hasChildren ifFalse:[^ self]. |
|
1228 |
lineNr := lineNr + 1. |
|
2179 | 1229 |
]. |
2377 | 1230 |
|
2408 | 1231 |
item := self at:lineNr ifAbsent:nil. |
2377 | 1232 |
item isNil ifTrue:[^ self]. |
1233 |
||
1234 |
(self canSelectIndex:lineNr forAdd:false) ifTrue:[ |
|
1235 |
self selection:lineNr |
|
1236 |
]. |
|
1390 | 1237 |
! ! |
1238 |
||
1757 | 1239 |
!HierarchicalListView methodsFor:'fetch resources'! |
1240 |
||
1241 |
fetchResources |
|
1242 |
"fetch device colors and ..., to avoid reallocation at redraw time; |
|
1243 |
*** called after a create or snapin to fetch all device resources |
|
1244 |
" |
|
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1245 |
|image defaultWidth| |
1757 | 1246 |
|
1247 |
super fetchResources. |
|
1248 |
||
1249 |
lineColor := lineColor onDevice:device. |
|
2488
74c81c1e30d7
imageOnDevice -> imageOnMyDevice
Claus Gittinger <cg@exept.de>
parents:
2421
diff
changeset
|
1250 |
openIndicator := self imageOnMyDevice:openIndicator. |
74c81c1e30d7
imageOnDevice -> imageOnMyDevice
Claus Gittinger <cg@exept.de>
parents:
2421
diff
changeset
|
1251 |
closeIndicator := self imageOnMyDevice:closeIndicator. |
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1252 |
defaultWidth := imageWidth. |
1757 | 1253 |
|
1254 |
icons keysAndValuesDo:[:aKey :anImage| |
|
1255 |
anImage isNil ifTrue:[ |
|
1256 |
('HierachicalListView [warning]: missing image: ' , aKey) errorPrintCR. |
|
1257 |
] ifFalse:[ |
|
2488
74c81c1e30d7
imageOnDevice -> imageOnMyDevice
Claus Gittinger <cg@exept.de>
parents:
2421
diff
changeset
|
1258 |
image := self imageOnMyDevice:anImage. |
1757 | 1259 |
icons at:aKey put:image. |
1260 |
imageWidth := image width max:imageWidth. |
|
1261 |
] |
|
1262 |
]. |
|
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1263 |
imageWidth := (imageWidth + 1 // 2 * 2) max:defaultWidth. |
1904 | 1264 |
alignTextRightX := imageWidth + 20 max:alignTextRightX. |
1757 | 1265 |
! ! |
1266 |
||
2500 | 1267 |
!HierarchicalListView methodsFor:'initialization & release'! |
1390 | 1268 |
|
1269 |
initStyle |
|
1270 |
"setup viewStyle specifics |
|
1271 |
" |
|
1272 |
|cls| |
|
1273 |
||
1274 |
super initStyle. |
|
1275 |
||
2377 | 1276 |
cls := self class. |
1277 |
icons := Dictionary new. |
|
1390 | 1278 |
|
1279 |
openIndicator := self class openIndicator. |
|
1280 |
closeIndicator := self class closeIndicator. |
|
2312 | 1281 |
minLineHeight := (openIndicator height) max:(closeIndicator height). |
1282 |
||
1390 | 1283 |
lineColor := fgColor. |
1284 |
highlightMode := #label. |
|
1285 |
showRoot := true. |
|
1286 |
showLeftIndicators := true. |
|
1287 |
useDefaultIcons := true. |
|
1288 |
showLines := true. |
|
1289 |
imageInset := 4. |
|
2383 | 1290 |
imageWidth := 0. |
1568 | 1291 |
alignTextRight := false. |
1292 |
alignTextRightX := 8. |
|
1293 |
maxWidthOfText := 0. |
|
2224 | 1294 |
|
2325 | 1295 |
|
2328 | 1296 |
highlightEnterItem := styleSheet at:#'selection.highlightEnterItem' default:false. |
2310 | 1297 |
expandOnSelect := styleSheet at:#'selection.expandOnSelect' default:false. |
2224 | 1298 |
autoScrollHorizontal := true. |
2210 | 1299 |
! |
1300 |
||
1301 |
initialize |
|
1302 |
super initialize. |
|
1303 |
levelOfLastItem := 1. |
|
2392 | 1304 |
|
1305 |
self showIndicators:true. |
|
1390 | 1306 |
! ! |
1307 |
||
1308 |
!HierarchicalListView methodsFor:'private'! |
|
1309 |
||
2327 | 1310 |
iconFor:anItem |
1311 |
"returns an icon or image for the item or nil if the item |
|
1312 |
provides no image and #useDefaultIcons is switched off. |
|
1390 | 1313 |
" |
2307 | 1314 |
|iconOrKey image| |
1390 | 1315 |
|
2307 | 1316 |
"/ get the icon or access key from the item |
1317 |
iconOrKey := anItem icon. |
|
1390 | 1318 |
|
2307 | 1319 |
iconOrKey notNil ifTrue:[ |
1320 |
iconOrKey isImageOrForm ifTrue:[ |
|
1321 |
"/ got an image; have to register the image on my device |
|
1390 | 1322 |
|
2307 | 1323 |
iconOrKey device == device ifTrue:[ |
1324 |
^ iconOrKey |
|
1325 |
]. |
|
2488
74c81c1e30d7
imageOnDevice -> imageOnMyDevice
Claus Gittinger <cg@exept.de>
parents:
2421
diff
changeset
|
1326 |
^ icons at:iconOrKey ifAbsentPut:[ self imageOnMyDevice:iconOrKey ]. |
1390 | 1327 |
]. |
1328 |
||
2307 | 1329 |
image := icons at:iconOrKey ifAbsent:nil. |
1330 |
image notNil ifTrue:[ ^ image ]. |
|
1331 |
]. |
|
1332 |
||
1333 |
"/ test whether a default image should be returned |
|
1334 |
useDefaultIcons ifFalse:[ |
|
1335 |
^ nil |
|
1390 | 1336 |
]. |
1337 |
||
2307 | 1338 |
anItem hasChildren ifFalse:[ |
2488
74c81c1e30d7
imageOnDevice -> imageOnMyDevice
Claus Gittinger <cg@exept.de>
parents:
2421
diff
changeset
|
1339 |
^ icons at:#empty ifAbsentPut:[ self imageOnMyDevice:(self class emptyIcon) ] |
1390 | 1340 |
]. |
1898 | 1341 |
|
2307 | 1342 |
anItem isExpanded ifTrue:[ |
2488
74c81c1e30d7
imageOnDevice -> imageOnMyDevice
Claus Gittinger <cg@exept.de>
parents:
2421
diff
changeset
|
1343 |
^ icons at:#expanded ifAbsentPut:[ self imageOnMyDevice:(self class expandedIcon) ]. |
1898 | 1344 |
]. |
2488
74c81c1e30d7
imageOnDevice -> imageOnMyDevice
Claus Gittinger <cg@exept.de>
parents:
2421
diff
changeset
|
1345 |
^ icons at:#collapsed ifAbsentPut:[ self imageOnMyDevice:(self class collapsedIcon) ]. |
1390 | 1346 |
! |
1347 |
||
2353 | 1348 |
lineHeightFor:anItem |
1349 |
"returns the computed line height for an item |
|
1350 |
" |
|
1351 |
|image height| |
|
1352 |
||
1353 |
height := renderer heightFor:anItem. |
|
1354 |
image := self iconFor:anItem. |
|
1355 |
||
1356 |
image notNil ifTrue:[ |
|
1357 |
height := image height max:height. |
|
1358 |
]. |
|
1359 |
||
1360 |
hasConstantHeight ifTrue:[ |
|
1361 |
icons size ~~ 0 ifTrue:[ |
|
1362 |
icons do:[:anIcon| height := anIcon height max:height ] |
|
1363 |
] ifFalse:[ |
|
1364 |
image isNil ifTrue:[ height := height max:16 ] |
|
1365 |
] |
|
1366 |
]. |
|
1367 |
height := height + lineSpacing. |
|
1368 |
^ height max:minLineHeight |
|
1369 |
! |
|
1370 |
||
1390 | 1371 |
smallestLevelBetween:start and:stop |
2327 | 1372 |
"returns the smallest level of all items in a range |
1390 | 1373 |
" |
1374 |
|prevItem currParent nextParent item |
|
1375 |
||
1376 |
lvl "{ Class:SmallInteger }" |
|
1377 |
min "{ Class:SmallInteger }" |
|
1378 |
beg "{ Class:SmallInteger }" |
|
1379 |
| |
|
1380 |
||
2408 | 1381 |
prevItem := self at:start ifAbsent:nil. |
1390 | 1382 |
|
1508
9c54f2e53da1
check whether #at:ifAbsent returns nil.
Claus Gittinger <cg@exept.de>
parents:
1431
diff
changeset
|
1383 |
(prevItem isNil or:[(currParent := prevItem parent) isNil]) ifTrue:[ |
1390 | 1384 |
^ 1 |
1385 |
]. |
|
1386 |
||
1387 |
(min := prevItem level) == 2 ifTrue:[ |
|
1388 |
^ min |
|
1389 |
]. |
|
1390 |
beg := start + 1. |
|
1391 |
||
1392 |
beg to:stop do:[:i| |
|
2408 | 1393 |
item := self at:i ifAbsent:nil. |
1508
9c54f2e53da1
check whether #at:ifAbsent returns nil.
Claus Gittinger <cg@exept.de>
parents:
1431
diff
changeset
|
1394 |
item isNil ifTrue:[^ min]. |
1390 | 1395 |
|
1396 |
(nextParent := item parent) == currParent ifFalse:[ |
|
1397 |
(currParent := nextParent) == prevItem ifFalse:[ |
|
1398 |
(lvl := item level) == 2 ifTrue:[ |
|
1399 |
^ 2 |
|
1400 |
]. |
|
1401 |
min := min min:lvl |
|
1402 |
] |
|
1403 |
]. |
|
1404 |
prevItem := item |
|
1405 |
]. |
|
1406 |
^ min |
|
1407 |
! |
|
1408 |
||
1409 |
widthOfWidestLineBetween:firstLine and:lastLine |
|
2327 | 1410 |
"returns the width of the longest line in pixels in a range |
1390 | 1411 |
" |
2645 | 1412 |
|parent item textX level width widthOfLabel| |
1413 |
||
2644 | 1414 |
width := renderer widthOfWidestLineBetween:firstLine and:lastLine. |
1415 |
width notNil ifTrue:[^ width]. |
|
1416 |
||
2383 | 1417 |
width := 20. |
1568 | 1418 |
|
1419 |
alignTextRight ifTrue:[ |
|
2383 | 1420 |
parent := nil. |
1421 |
level := 1. |
|
1422 |
||
1568 | 1423 |
firstLine to:lastLine do:[:idx| |
2408 | 1424 |
item := self at:idx ifAbsent:nil. |
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1425 |
|
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1426 |
item notNil ifTrue:[ |
2353 | 1427 |
width := (renderer widthFor:item) max:width. |
1568 | 1428 |
|
2383 | 1429 |
item parent ~~ parent ifTrue:[ |
1430 |
level := item level max:level. |
|
1431 |
parent := item parent. |
|
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1432 |
]. |
1568 | 1433 |
]. |
1434 |
]. |
|
1435 |
maxWidthOfText := maxWidthOfText max:width. |
|
2383 | 1436 |
textX := self xVisibleOfIconAtLevel:(level + 1). |
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1437 |
|
2383 | 1438 |
alignTextRightX < textX ifTrue:[ |
2417
a0b7d30a4073
instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents:
2414
diff
changeset
|
1439 |
alignTextRightX := textX. |
2659
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2645
diff
changeset
|
1440 |
self invalidate. |
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1441 |
]. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1442 |
^ alignTextRightX + width |
1568 | 1443 |
]. |
1390 | 1444 |
|
2383 | 1445 |
parent := 4711. "/ force a computation |
1390 | 1446 |
|
1447 |
firstLine to:lastLine do:[:idx| |
|
2408 | 1448 |
item := self at:idx ifAbsent:nil. |
1390 | 1449 |
|
2383 | 1450 |
item notNil ifTrue:[ |
1451 |
item parent ~~ parent ifTrue:[ |
|
1452 |
textX := self xVisibleOfTextAtLevel:(item level). |
|
1453 |
parent := item parent. |
|
1454 |
]. |
|
1455 |
widthOfLabel := renderer widthFor:item. |
|
1456 |
maxWidthOfText := maxWidthOfText max:widthOfLabel. |
|
1457 |
width := widthOfLabel + textX max:width |
|
1390 | 1458 |
]. |
1459 |
]. |
|
2383 | 1460 |
^ width + viewOrigin x. |
1390 | 1461 |
! |
1462 |
||
2327 | 1463 |
xVisibleOfIconAtLevel:aLevel |
1464 |
"returns the visible origin x of the icon at a level. |
|
1390 | 1465 |
" |
2383 | 1466 |
|x| |
1390 | 1467 |
|
2383 | 1468 |
x := self xVisibleOfVerticalLineAt:aLevel. |
1390 | 1469 |
|
2383 | 1470 |
(showRoot and:[aLevel == 1]) ifTrue:[ |
2392 | 1471 |
showLeftIndicators ifFalse:[ |
2383 | 1472 |
^ x - (imageWidth // 2) |
1473 |
]. |
|
1390 | 1474 |
]. |
2383 | 1475 |
^ x + (openIndicator width // 2) + imageInset |
1476 |
! |
|
1477 |
||
1478 |
xVisibleOfIndicatorAtLevel:aLevel |
|
1479 |
"returns the visible origin x of the vertical line at a level. |
|
1480 |
" |
|
1481 |
|x| |
|
1482 |
||
1483 |
x := self xVisibleOfVerticalLineAt:aLevel. |
|
1484 |
x := x - (openIndicator width // 2). |
|
1485 |
^ x |
|
1390 | 1486 |
! |
1487 |
||
2327 | 1488 |
xVisibleOfItem:anItem |
1489 |
"returns the visible origin x of the item's label. |
|
1490 |
" |
|
1491 |
^ self xVisibleOfTextAtLevel:(anItem level) |
|
1492 |
! |
|
1493 |
||
1494 |
xVisibleOfTextAtLevel:aLevel |
|
1495 |
"returns the visible origin x of the text label at a level. |
|
1757 | 1496 |
" |
1497 |
alignTextRight ifTrue:[ |
|
1498 |
^ alignTextRightX - (viewOrigin x) |
|
1499 |
]. |
|
2327 | 1500 |
^ (self xVisibleOfIconAtLevel:aLevel) + imageWidth + textStartLeft |
2383 | 1501 |
! |
1502 |
||
1503 |
xVisibleOfVerticalLineAt:aLevel |
|
1504 |
"returns the visible origin x of the vertical line assigned to a level. |
|
1505 |
" |
|
1506 |
|xOffset opWidth2 igWidth2 firstLevel| |
|
1507 |
||
1508 |
opWidth2 := openIndicator width // 2. |
|
1509 |
igWidth2 := imageWidth // 2. |
|
1510 |
xOffset := igWidth2 + opWidth2 + imageInset. |
|
1511 |
||
1512 |
showRoot ifTrue:[ firstLevel := 1 ] |
|
1513 |
ifFalse:[ firstLevel := 2 ]. |
|
1514 |
||
2392 | 1515 |
showLeftIndicators ifTrue:[ |
2383 | 1516 |
aLevel < firstLevel ifTrue:[ |
1517 |
xOffset := opWidth2 - (firstLevel * xOffset) |
|
1518 |
] ifFalse:[ |
|
1519 |
xOffset := opWidth2 + (aLevel - firstLevel * xOffset) |
|
1520 |
] |
|
1521 |
] ifFalse:[ |
|
1522 |
aLevel < 2 ifTrue:[ |
|
1523 |
xOffset := igWidth2 - (aLevel - firstLevel * xOffset) |
|
1524 |
] ifFalse:[ |
|
1525 |
xOffset := igWidth2 + (aLevel - firstLevel - 1 * xOffset) |
|
1526 |
]. |
|
1527 |
]. |
|
1528 |
"/ 2 := a left margin |
|
1529 |
^ xOffset + 2 - (viewOrigin x) |
|
1390 | 1530 |
! ! |
1531 |
||
2224 | 1532 |
!HierarchicalListView methodsFor:'scrolling'! |
1533 |
||
1534 |
computeViewOriginXat:aLnrNr |
|
2327 | 1535 |
"returns the viewOrigin x to make the item at a line visisble |
2224 | 1536 |
" |
2383 | 1537 |
|item xLft xRgt level vwOrgX useX| |
2224 | 1538 |
|
2233 | 1539 |
vwOrgX := viewOrigin x. |
2224 | 1540 |
|
2644 | 1541 |
renderer autoScrollHorizontal ifFalse:[^ vwOrgX ]. |
1542 |
||
2383 | 1543 |
alignTextRight ifTrue:[ ^ vwOrgX ]. |
1544 |
aLnrNr == 1 ifTrue:[ ^ 0 ]. |
|
1545 |
||
2408 | 1546 |
item := self at:aLnrNr ifAbsent:nil. |
2307 | 1547 |
item isNil ifTrue:[ ^ vwOrgX ]. |
2224 | 1548 |
|
1549 |
level := item level. |
|
2383 | 1550 |
level == 1 ifTrue:[ ^ 0 ]. "/ is root item |
1551 |
||
1552 |
level == 2 ifTrue:[ "/ parent is root |
|
1553 |
(showRoot and:[showLeftIndicators]) ifFalse:[ ^ 0 ]. |
|
1554 |
]. |
|
2224 | 1555 |
|
2327 | 1556 |
xLft := self xVisibleOfIconAtLevel:(level - 1). |
2383 | 1557 |
xLft > 0 ifFalse:[ ^ vwOrgX + xLft max:0 ]. |
2224 | 1558 |
|
2353 | 1559 |
xRgt := (self xVisibleOfTextAtLevel:level) + (renderer widthFor:item). |
2383 | 1560 |
useX := xRgt - width. |
2224 | 1561 |
|
2383 | 1562 |
useX > 0 ifFalse:[ ^ vwOrgX ]. |
1563 |
useX := useX + 16 min:xLft. |
|
1564 |
^ vwOrgX + useX. |
|
2224 | 1565 |
! |
1566 |
||
2726 | 1567 |
makeItemVisible:anItem withMinimumLines:aNumber |
1568 |
"handle indicator pressed action; |
|
1569 |
if the item changed expanded, we try to show all |
|
1570 |
new visible children |
|
1571 |
" |
|
1572 |
|availY usedY vwOrgX vwOrgY lineNr numLines| |
|
1573 |
||
1574 |
lineNr := list identityIndexOf:anItem. |
|
1575 |
lineNr == 0 ifTrue:[ ^ self]. |
|
1576 |
||
1577 |
numLines := anItem numberOfVisibleChildren. |
|
1578 |
numLines := numLines max:(aNumber ? 5). |
|
1579 |
numLines := lineNr + numLines min:(list size). |
|
1580 |
||
1581 |
vwOrgY := viewOrigin y. |
|
1582 |
availY := (self yVisibleOfLine:lineNr) - (self yVisibleOfLine:1). |
|
1583 |
||
1584 |
availY > margin ifTrue:[ |
|
1585 |
usedY := (self yVisibleOfLine:(numLines + 1)) - (height - margin - margin). |
|
1586 |
||
1587 |
usedY > 1 ifTrue:[ |
|
1588 |
vwOrgY := vwOrgY + (usedY min:availY). |
|
1589 |
]. |
|
1590 |
]. |
|
1591 |
vwOrgX := self computeViewOriginXat:lineNr. |
|
1592 |
||
1593 |
self scrollTo:(vwOrgX @ vwOrgY). |
|
1594 |
! |
|
1595 |
||
2780 | 1596 |
makeLineVisible:aLineNumber |
1597 |
"make the line horizontally and vertically visible |
|
2224 | 1598 |
" |
2780 | 1599 |
|newY item y0 oldX newX wLine| |
2224 | 1600 |
|
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1601 |
alignTextRight ifTrue:[^ self]. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1602 |
|
2780 | 1603 |
(shown and:[aLineNumber notNil]) ifFalse:[^ self]. |
2224 | 1604 |
|
2780 | 1605 |
aLineNumber < 1 ifTrue:[ |
2353 | 1606 |
^ self |
2224 | 1607 |
]. |
1608 |
||
2780 | 1609 |
newX := oldX := viewOrigin x. |
2224 | 1610 |
|
2780 | 1611 |
aLineNumber == 1 ifTrue:[ |
1612 |
newX := self computeViewOriginXat:1. |
|
1613 |
newY := 0. |
|
1614 |
] ifFalse:[ |
|
1615 |
item := self at:aLineNumber ifAbsent:nil. |
|
1616 |
item isNil ifTrue:[^ self]. |
|
1617 |
||
1618 |
y0 := self yVisibleOfLine:aLineNumber. |
|
2224 | 1619 |
|
2780 | 1620 |
( y0 < margin |
1621 |
or:[(y0 + (renderer heightFor:item)) > (height - margin)] |
|
1622 |
) ifTrue:[ |
|
1623 |
newY := ((self yAbsoluteOfLine:aLineNumber) - (height // 2)) max:0. |
|
1624 |
] ifFalse:[ |
|
1625 |
newY := viewOrigin y. |
|
1626 |
]. |
|
2224 | 1627 |
|
2780 | 1628 |
self autoScrollHorizontal ifTrue:[ |
1629 |
wLine := self widthOfWidestLineBetween:aLineNumber and:aLineNumber. |
|
1630 |
(wLine < self innerWidth) ifTrue:[ |
|
1631 |
(oldX == 0) ifTrue:[ |
|
1632 |
newX := self computeViewOriginXat:aLineNumber. |
|
1633 |
] ifFalse:[ |
|
1634 |
newX := 0 |
|
1635 |
]. |
|
1636 |
] ifFalse:[ |
|
1637 |
newX := self computeViewOriginXat:aLineNumber. |
|
1638 |
]. |
|
1639 |
]. |
|
2224 | 1640 |
]. |
1641 |
self scrollTo:(newX @ newY). |
|
1642 |
! ! |
|
1643 |
||
1390 | 1644 |
!HierarchicalListView class methodsFor:'documentation'! |
1645 |
||
1646 |
version |
|
2822 | 1647 |
^ '$Header: /cvs/stx/stx/libwidg2/HierarchicalListView.st,v 1.97 2005-05-30 15:45:13 stefan Exp $' |
1390 | 1648 |
! ! |