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