author | Claus Gittinger <cg@exept.de> |
Thu, 16 Mar 2006 20:43:27 +0100 | |
changeset 2949 | 6337ac4747cf |
parent 2946 | 4df68d94779c |
child 2963 | 0e53c2bb4424 |
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 |
2946 | 329 |
have 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 |
341 |
aList notNil ifTrue:[ |
|
2421 | 342 |
aList isHierarchicalItem ifTrue:[ |
2595
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2554
diff
changeset
|
343 |
self list root:aList. |
2421 | 344 |
aList expand. |
2595
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2554
diff
changeset
|
345 |
^ self |
2421 | 346 |
]. |
2595
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2554
diff
changeset
|
347 |
showRoot := aList showRoot. |
1390 | 348 |
]. |
2595
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2554
diff
changeset
|
349 |
super list:aList |
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2554
diff
changeset
|
350 |
! |
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2554
diff
changeset
|
351 |
|
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2554
diff
changeset
|
352 |
newDefaultList |
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2554
diff
changeset
|
353 |
"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
|
354 |
" |
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2554
diff
changeset
|
355 |
|list| |
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2554
diff
changeset
|
356 |
|
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2554
diff
changeset
|
357 |
list := HierarchicalList new. |
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2554
diff
changeset
|
358 |
list showRoot:(showRoot ? true). |
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2554
diff
changeset
|
359 |
^ list |
2408 | 360 |
! |
361 |
||
362 |
root |
|
363 |
"returns the anchor of the list or nil |
|
364 |
" |
|
2595
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2554
diff
changeset
|
365 |
^ self list root |
1390 | 366 |
! ! |
367 |
||
2224 | 368 |
!HierarchicalListView methodsFor:'accessing-behavior'! |
369 |
||
370 |
autoScrollHorizontal |
|
2780 | 371 |
"returns true if automatic horizontal scrolling |
372 |
(upto the text label of the selected line) |
|
2898 | 373 |
is allowed (the default is as specified in the styleSheet)." |
2780 | 374 |
|
2866
01d609cfb3d9
autoscrollHorizontal confusion cleanup
Claus Gittinger <cg@exept.de>
parents:
2822
diff
changeset
|
375 |
^ autoScrollHorizontal == true |
2224 | 376 |
! |
377 |
||
378 |
autoScrollHorizontal:aBoolean |
|
379 |
"true, than automatically scroll horizontal upto the text label |
|
2898 | 380 |
of the current selected line." |
381 |
||
2224 | 382 |
autoScrollHorizontal := aBoolean. |
383 |
! |
|
384 |
||
385 |
expandOnSelect |
|
386 |
"true, than the item selected by a buttonPress event will |
|
387 |
be immediately expanded. |
|
388 |
" |
|
389 |
^ expandOnSelect |
|
390 |
! |
|
391 |
||
392 |
expandOnSelect:aBoolean |
|
393 |
"true, than the item selected by a buttonPress event will |
|
394 |
be immediately expanded. |
|
395 |
" |
|
396 |
expandOnSelect := aBoolean. |
|
397 |
! ! |
|
398 |
||
1818 | 399 |
!HierarchicalListView methodsFor:'accessing-colors'! |
1390 | 400 |
|
401 |
lineColor |
|
2307 | 402 |
"get the color of the horizontal and vertical lines |
1390 | 403 |
" |
404 |
^ lineColor |
|
405 |
! |
|
406 |
||
407 |
lineColor:aColor |
|
2307 | 408 |
"set the color of the horizontal and vertical lines |
1390 | 409 |
" |
410 |
(aColor notNil and:[aColor ~= lineColor]) ifTrue:[ |
|
411 |
lineColor := aColor. |
|
412 |
||
413 |
shown ifTrue:[ |
|
2099 | 414 |
lineColor := lineColor onDevice:device. |
2307 | 415 |
showLines ifTrue:[ self invalidate ] |
1390 | 416 |
] |
2307 | 417 |
]. |
1390 | 418 |
! ! |
419 |
||
1818 | 420 |
!HierarchicalListView methodsFor:'accessing-look'! |
1390 | 421 |
|
1568 | 422 |
alignTextRight |
423 |
"align the text right |
|
424 |
" |
|
425 |
^ alignTextRight |
|
426 |
! |
|
427 |
||
1757 | 428 |
alignTextRight:aBool |
429 |
"align the text right |
|
430 |
" |
|
431 |
alignTextRight := aBool ? false. |
|
432 |
! |
|
1568 | 433 |
|
1904 | 434 |
alignTextRightX |
435 |
"returns the minimum used text inset, if text is aligned right. |
|
436 |
" |
|
437 |
^ alignTextRightX |
|
438 |
! |
|
439 |
||
440 |
alignTextRightX:aNumber |
|
441 |
"set the minimum used text inset, if text is aligned right. |
|
442 |
" |
|
2383 | 443 |
aNumber > 0 ifTrue:[ |
1904 | 444 |
alignTextRightX := aNumber. |
445 |
||
446 |
(alignTextRight and:[widthOfContents notNil]) ifTrue:[ |
|
447 |
widthOfContents := alignTextRightX + maxWidthOfText. |
|
448 |
||
449 |
shown ifTrue:[ |
|
450 |
self invalidate. |
|
451 |
self contentsChanged. |
|
452 |
] |
|
453 |
] |
|
454 |
]. |
|
455 |
! |
|
456 |
||
2094 | 457 |
iconAt:aKey ifAbsentPut:aBlock |
458 |
"return the icon stored under a key; if not present,the |
|
459 |
result of the block if not nil is stored under the key |
|
460 |
and returned. |
|
461 |
" |
|
462 |
|icon| |
|
463 |
||
464 |
icon := icons at:aKey ifAbsent:nil. |
|
2307 | 465 |
icon notNil ifTrue:[^ icon]. |
2094 | 466 |
|
467 |
icon := aBlock value. |
|
2307 | 468 |
icon isNil ifTrue:[^ nil]. |
2094 | 469 |
|
470 |
realized ifTrue:[ |
|
2488
74c81c1e30d7
imageOnDevice -> imageOnMyDevice
Claus Gittinger <cg@exept.de>
parents:
2421
diff
changeset
|
471 |
icon := self imageOnMyDevice:icon |
2094 | 472 |
]. |
473 |
icons at:aKey put:icon. |
|
2814 | 474 |
^ icon |
2094 | 475 |
! |
476 |
||
1390 | 477 |
registerKeysAndIcons:aDictionary |
478 |
"register icons by key and value derived from a directory |
|
479 |
" |
|
480 |
|image| |
|
481 |
||
2880
74b81246abf1
isEmptyOrNil / notEmptyOrNil refactoring
Claus Gittinger <cg@exept.de>
parents:
2866
diff
changeset
|
482 |
(aDictionary isEmptyOrNil) ifTrue:[ |
1390 | 483 |
^ self |
484 |
]. |
|
485 |
||
486 |
aDictionary keysAndValuesDo:[:aKey :anImage| |
|
2488
74c81c1e30d7
imageOnDevice -> imageOnMyDevice
Claus Gittinger <cg@exept.de>
parents:
2421
diff
changeset
|
487 |
(image := self imageOnMyDevice:anImage) notNil ifTrue:[ |
1390 | 488 |
icons at:aKey put:image |
1746 | 489 |
] ifFalse:[ |
490 |
icons removeKey:aKey ifAbsent:nil |
|
1390 | 491 |
] |
492 |
] |
|
493 |
! |
|
494 |
||
2392 | 495 |
showIndicators |
496 |
"returns true if indicators are shown |
|
497 |
" |
|
498 |
^ showIndicators |
|
499 |
! |
|
500 |
||
501 |
showIndicators:aBoolean |
|
502 |
"true if indicators are shown |
|
503 |
" |
|
504 |
showIndicators ~~ aBoolean ifTrue:[ |
|
505 |
showIndicators := aBoolean. |
|
2659
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2645
diff
changeset
|
506 |
self invalidate. |
2392 | 507 |
]. |
508 |
! |
|
509 |
||
1390 | 510 |
showLeftIndicators |
511 |
"show or hide the indicators for the most left items |
|
512 |
" |
|
513 |
^ showLeftIndicators |
|
514 |
||
515 |
! |
|
516 |
||
2307 | 517 |
showLeftIndicators:aBoolean |
1390 | 518 |
"show or hide the indicators for the most left items |
519 |
" |
|
2392 | 520 |
|oldInset newInset| |
521 |
||
522 |
aBoolean == showLeftIndicators ifTrue:[ ^ self ]. |
|
523 |
||
2408 | 524 |
(widthOfContents isNil or:[self size == 0]) ifTrue:[ |
2307 | 525 |
showLeftIndicators := aBoolean. |
2392 | 526 |
^ self |
527 |
]. |
|
2383 | 528 |
|
2392 | 529 |
oldInset := self xVisibleOfIconAtLevel:3. |
530 |
showLeftIndicators := aBoolean. |
|
531 |
newInset := self xVisibleOfIconAtLevel:3. |
|
532 |
||
533 |
newInset ~~ oldInset ifTrue:[ |
|
534 |
widthOfContents := widthOfContents + (newInset - oldInset). |
|
535 |
]. |
|
536 |
||
2659
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2645
diff
changeset
|
537 |
self invalidate. |
2392 | 538 |
|
539 |
newInset ~~ oldInset ifTrue:[ |
|
540 |
self contentsChanged |
|
1390 | 541 |
]. |
542 |
! |
|
543 |
||
544 |
showLines |
|
545 |
"returns true if lines are shown |
|
546 |
" |
|
2307 | 547 |
^ showLines |
1390 | 548 |
! |
549 |
||
2307 | 550 |
showLines:aBoolean |
1390 | 551 |
"show or hide lines |
552 |
" |
|
2307 | 553 |
aBoolean ~~ showLines ifTrue:[ |
554 |
showLines := aBoolean. |
|
2659
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2645
diff
changeset
|
555 |
self invalidate. |
1390 | 556 |
]. |
557 |
! |
|
558 |
||
2421 | 559 |
showRoot |
560 |
"true if the root is shown |
|
561 |
" |
|
562 |
^ showRoot |
|
563 |
! |
|
564 |
||
565 |
showRoot:aBoolean |
|
566 |
"true if the root is shown |
|
567 |
" |
|
568 |
showRoot ~~ aBoolean ifTrue:[ |
|
569 |
showRoot := aBoolean. |
|
2595
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2554
diff
changeset
|
570 |
self list showRoot:showRoot. |
2659
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2645
diff
changeset
|
571 |
self invalidate |
2421 | 572 |
]. |
573 |
! |
|
574 |
||
1390 | 575 |
useDefaultIcons |
576 |
"use the default icons if no icon for an item is specified; |
|
577 |
** default: true |
|
578 |
" |
|
579 |
^ useDefaultIcons |
|
580 |
! |
|
581 |
||
2307 | 582 |
useDefaultIcons:aBoolean |
1390 | 583 |
"use the default icons if no icon for an item is specified; |
584 |
** default: true |
|
585 |
" |
|
2307 | 586 |
useDefaultIcons ~~ aBoolean ifTrue:[ |
587 |
useDefaultIcons := aBoolean. |
|
2659
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2645
diff
changeset
|
588 |
self invalidate. |
1390 | 589 |
] |
590 |
! ! |
|
591 |
||
592 |
!HierarchicalListView methodsFor:'actions'! |
|
593 |
||
594 |
indicatorAction |
|
2392 | 595 |
"the action evaluated if an indicator is pressed; otherwise |
596 |
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
|
597 |
|
a0b7d30a4073
instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents:
2414
diff
changeset
|
598 |
The arguments to the block are: |
a0b7d30a4073
instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents:
2414
diff
changeset
|
599 |
- no argument |
a0b7d30a4073
instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents:
2414
diff
changeset
|
600 |
- 1 argument index |
a0b7d30a4073
instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents:
2414
diff
changeset
|
601 |
- 2 argument index, self |
1390 | 602 |
" |
603 |
^ indicatorAction |
|
604 |
! |
|
605 |
||
606 |
indicatorAction:anAction |
|
2392 | 607 |
"the action evaluated if an indicator is pressed; otherwise |
608 |
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
|
609 |
|
a0b7d30a4073
instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents:
2414
diff
changeset
|
610 |
The arguments to the block are: |
a0b7d30a4073
instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents:
2414
diff
changeset
|
611 |
- no argument |
a0b7d30a4073
instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents:
2414
diff
changeset
|
612 |
- 1 argument index |
a0b7d30a4073
instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents:
2414
diff
changeset
|
613 |
- 2 argument index, self |
1390 | 614 |
" |
615 |
indicatorAction := anAction. |
|
616 |
! ! |
|
617 |
||
618 |
!HierarchicalListView methodsFor:'change & update'! |
|
619 |
||
1782 | 620 |
indicatorPressedAt:aLnNr |
2224 | 621 |
"handle indicator pressed action; |
622 |
if the item changed expanded, we try to show all |
|
2822 | 623 |
new visible children" |
624 |
||
625 |
|item expanded dl| |
|
2224 | 626 |
|
2392 | 627 |
showIndicators ifFalse:[^ self]. |
2224 | 628 |
|
2408 | 629 |
item := self at:aLnNr ifAbsent:nil. |
2307 | 630 |
item isNil ifTrue:[^ self]. |
2224 | 631 |
|
632 |
item hasIndicator ifFalse:[^ self]. |
|
633 |
||
634 |
expanded := item isExpanded. |
|
2392 | 635 |
|
636 |
indicatorAction notNil ifTrue:[ |
|
2417
a0b7d30a4073
instead of #numArgs use: #valueWithOptionalArgument:and
ca
parents:
2414
diff
changeset
|
637 |
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
|
638 |
] ifFalse:[ |sensor| |
9a907b626499
Do recursive toggelExpand if an indicator is pressed with shift or control
Stefan Vogel <sv@exept.de>
parents:
2518
diff
changeset
|
639 |
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
|
640 |
(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
|
641 |
item recursiveToggleExpand |
9a907b626499
Do recursive toggelExpand if an indicator is pressed with shift or control
Stefan Vogel <sv@exept.de>
parents:
2518
diff
changeset
|
642 |
] ifFalse:[ |
9a907b626499
Do recursive toggelExpand if an indicator is pressed with shift or control
Stefan Vogel <sv@exept.de>
parents:
2518
diff
changeset
|
643 |
item toggleExpand |
9a907b626499
Do recursive toggelExpand if an indicator is pressed with shift or control
Stefan Vogel <sv@exept.de>
parents:
2518
diff
changeset
|
644 |
]. |
2392 | 645 |
]. |
646 |
||
2224 | 647 |
(expanded or:[item isExpanded not]) ifTrue:[^ self]. |
1783
ffe767ea66ea
check whether children exists before calling indicatorPressed action
ca
parents:
1782
diff
changeset
|
648 |
|
2769
1315a31fa1e8
do not scroll when expanding
Claus Gittinger <cg@exept.de>
parents:
2726
diff
changeset
|
649 |
(self yVisibleOfLine:aLnNr+1) > self height ifTrue:[ |
1315a31fa1e8
do not scroll when expanding
Claus Gittinger <cg@exept.de>
parents:
2726
diff
changeset
|
650 |
dl := (self yVisibleOfLine:aLnNr+1) - (self yVisibleOfLine:aLnNr). |
1315a31fa1e8
do not scroll when expanding
Claus Gittinger <cg@exept.de>
parents:
2726
diff
changeset
|
651 |
self scrollTo:(viewOrigin x @ (viewOrigin y + dl)). |
1315a31fa1e8
do not scroll when expanding
Claus Gittinger <cg@exept.de>
parents:
2726
diff
changeset
|
652 |
]. |
2224 | 653 |
|
2769
1315a31fa1e8
do not scroll when expanding
Claus Gittinger <cg@exept.de>
parents:
2726
diff
changeset
|
654 |
"/ numChildren := item numberOfVisibleChildren. |
1315a31fa1e8
do not scroll when expanding
Claus Gittinger <cg@exept.de>
parents:
2726
diff
changeset
|
655 |
"/ numChildren == 0 ifTrue:[ |
1315a31fa1e8
do not scroll when expanding
Claus Gittinger <cg@exept.de>
parents:
2726
diff
changeset
|
656 |
"/ ^ self |
1315a31fa1e8
do not scroll when expanding
Claus Gittinger <cg@exept.de>
parents:
2726
diff
changeset
|
657 |
"/ ]. |
1315a31fa1e8
do not scroll when expanding
Claus Gittinger <cg@exept.de>
parents:
2726
diff
changeset
|
658 |
^ self |
2224 | 659 |
|
2769
1315a31fa1e8
do not scroll when expanding
Claus Gittinger <cg@exept.de>
parents:
2726
diff
changeset
|
660 |
"/ idx := aLnNr + numChildren. |
1315a31fa1e8
do not scroll when expanding
Claus Gittinger <cg@exept.de>
parents:
2726
diff
changeset
|
661 |
"/ vwOrgY := viewOrigin y. |
1315a31fa1e8
do not scroll when expanding
Claus Gittinger <cg@exept.de>
parents:
2726
diff
changeset
|
662 |
"/ availY := (self yVisibleOfLine:aLnNr) - (self yVisibleOfLine:1). |
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 |
"/ availY > margin ifTrue:[ |
1315a31fa1e8
do not scroll when expanding
Claus Gittinger <cg@exept.de>
parents:
2726
diff
changeset
|
665 |
"/ usedY := (self yVisibleOfLine:(idx + 1)) - (height - margin - margin). |
1315a31fa1e8
do not scroll when expanding
Claus Gittinger <cg@exept.de>
parents:
2726
diff
changeset
|
666 |
"/ |
1315a31fa1e8
do not scroll when expanding
Claus Gittinger <cg@exept.de>
parents:
2726
diff
changeset
|
667 |
"/ usedY > 1 ifTrue:[ |
1315a31fa1e8
do not scroll when expanding
Claus Gittinger <cg@exept.de>
parents:
2726
diff
changeset
|
668 |
"/ vwOrgY := vwOrgY + (usedY min:availY). |
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 |
"/ ]. |
1315a31fa1e8
do not scroll when expanding
Claus Gittinger <cg@exept.de>
parents:
2726
diff
changeset
|
671 |
"/ vwOrgX := self computeViewOriginXat:aLnNr. |
1315a31fa1e8
do not scroll when expanding
Claus Gittinger <cg@exept.de>
parents:
2726
diff
changeset
|
672 |
"/ self scrollTo:(vwOrgX @ vwOrgY). |
1782 | 673 |
! |
674 |
||
1390 | 675 |
lineChangedAt:aLnNr with:arg |
676 |
"line changed at position; check whether line height changed |
|
677 |
" |
|
678 |
|item |
|
2317 | 679 |
level "{ Class:SmallInteger }" |
1390 | 680 |
x0 "{ Class:SmallInteger }" |
681 |
x1 "{ Class:SmallInteger }" |
|
682 |
y0 "{ Class:SmallInteger }" |
|
683 |
y1 "{ Class:SmallInteger }" |
|
2303 | 684 |
yB "{ Class:SmallInteger }" |
1390 | 685 |
| |
686 |
||
2408 | 687 |
item := self at:aLnNr ifAbsent:nil. |
2317 | 688 |
item isNil ifTrue:[^ self]. |
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
689 |
|
1399 | 690 |
(arg == #icon or:[arg == #hierarchy]) ifFalse:[ |
2224 | 691 |
super lineChangedAt:aLnNr with:arg. |
692 |
||
693 |
(arg ~~ #redraw and:[widthOfContents notNil]) ifTrue:[ |
|
2327 | 694 |
x0 := (self xVisibleOfTextAtLevel:(item level)) |
2353 | 695 |
+ (renderer widthFor:item) |
2229 | 696 |
+ (viewOrigin x). |
2224 | 697 |
|
698 |
x0 > widthOfContents ifTrue:[ |
|
699 |
widthOfContents := x0. |
|
700 |
self contentsChanged. |
|
701 |
] |
|
702 |
]. |
|
703 |
^ self |
|
1390 | 704 |
]. |
2317 | 705 |
level := item level. |
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
706 |
|
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
707 |
(alignTextRight and:[arg == #hierarchy]) ifTrue:[ |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
708 |
"/ must test whether alignTextRightX is enough |
2317 | 709 |
(item isExpanded and:[item hasChildren]) ifTrue:[ |
2327 | 710 |
x0 := self xVisibleOfIconAtLevel:(level + 2). |
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
711 |
|
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
712 |
alignTextRightX < x0 ifTrue:[ |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
713 |
alignTextRightX := x0. |
2659
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2645
diff
changeset
|
714 |
self invalidate. |
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
715 |
|
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
716 |
widthOfContents notNil ifTrue:[ |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
717 |
widthOfContents := alignTextRightX + maxWidthOfText. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
718 |
self contentsChanged. |
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 |
^ self. |
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 |
] |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
723 |
]. |
1568 | 724 |
shown ifFalse:[^ self]. |
725 |
||
2303 | 726 |
yB := height - margin. |
727 |
y0 := (self yVisibleOfLine:aLnNr) max:margin. |
|
728 |
y0 < yB ifFalse:[ ^ self ]. |
|
1390 | 729 |
|
2303 | 730 |
y1 := (self yVisibleOfLine:(aLnNr + 1)) min:yB. |
731 |
y1 > y0 ifFalse:[^ self]. |
|
1399 | 732 |
|
2327 | 733 |
x1 := (self xVisibleOfTextAtLevel:level) - 1. |
2317 | 734 |
x1 > margin ifFalse:[^ self]. |
1390 | 735 |
|
2383 | 736 |
x0 := (self xVisibleOfIndicatorAtLevel:level) max:margin. |
2317 | 737 |
x1 := x1 min:(width - margin). |
2303 | 738 |
|
2317 | 739 |
x0 < x1 ifTrue:[ |
740 |
self invalidate:(Rectangle left:x0 top:y0 width:(x1 - x0) height:(y1 - y0)) |
|
741 |
repairNow:false. |
|
2303 | 742 |
]. |
1976
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
743 |
! |
1390 | 744 |
|
1976
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
745 |
listChangedInsert:firstAddedIndex nItems:nLines |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
746 |
"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
|
747 |
" |
2210 | 748 |
|item level yTop yBot xLft start maxY| |
1390 | 749 |
|
1976
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
750 |
super listChangedInsert:firstAddedIndex nItems:nLines. |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
751 |
|
2408 | 752 |
item := self last. |
2210 | 753 |
levelOfLastItem := item level. |
754 |
||
1976
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
755 |
( shown |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
756 |
and:[showLines |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
757 |
and:[firstAddedIndex > 1 |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
758 |
and:[nLines ~~ 0 |
2408 | 759 |
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
|
760 |
and:[(level := item level) > 1]]]]] |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
761 |
) ifFalse:[ |
2383 | 762 |
^ self. |
1976
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
763 |
]. |
2383 | 764 |
xLft := self xVisibleOfVerticalLineAt:level. |
1390 | 765 |
|
1976
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
766 |
(xLft > margin and:[xLft < (width - margin)]) ifFalse:[ |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
767 |
^ self |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
768 |
]. |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
769 |
start := firstAddedIndex - 1. |
1390 | 770 |
|
1976
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
771 |
start to:1 by:-1 do:[:i| |el| |
2408 | 772 |
el := self at:i. |
1399 | 773 |
|
1976
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
774 |
el level <= level ifTrue:[ |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
775 |
i == start ifTrue:[^ self]. |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
776 |
|
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
777 |
yTop := (self yVisibleOfLine:i + 1) max:margin. |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
778 |
maxY := height - margin. |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
779 |
|
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
780 |
yTop < maxY ifTrue:[ |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
781 |
yBot := (self yVisibleOfLine:firstAddedIndex) - 1 min:maxY. |
2383 | 782 |
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
|
783 |
]. |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
784 |
^ self |
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 |
]. |
1390 | 787 |
! |
788 |
||
2208 | 789 |
listChangedRemove:aStart toIndex:aStop |
790 |
"test whether last items are deleted; |
|
791 |
than we have to redraw lines because of different levels |
|
792 |
" |
|
2210 | 793 |
|listSize index y0 searchLevel| |
2208 | 794 |
|
2408 | 795 |
listSize := self size. |
2210 | 796 |
searchLevel := levelOfLastItem. |
2208 | 797 |
|
2307 | 798 |
listSize == 0 ifTrue:[ levelOfLastItem := 1 ] |
2408 | 799 |
ifFalse:[ levelOfLastItem := self last level ]. |
2208 | 800 |
|
2307 | 801 |
(shown and:[showLines and:[listSize ~~ 0 and:[aStart > listSize]]]) ifTrue:[ |
2408 | 802 |
index := self findLast:[:el| el level <= searchLevel ]. |
2208 | 803 |
|
804 |
(index ~~ 0 and:[index < listSize]) ifTrue:[ |
|
805 |
y0 := (self yVisibleOfLine:index) max:margin. |
|
806 |
self invalidateX:0 y:y0 width:width height:(height - margin - y0). |
|
807 |
] |
|
808 |
]. |
|
809 |
^ super listChangedRemove:aStart toIndex:aStop |
|
810 |
! |
|
811 |
||
2644 | 812 |
updateFromList:what with:aPara |
1390 | 813 |
"get the status of <showRoot> from the list |
814 |
" |
|
2644 | 815 |
|newState| |
816 |
||
817 |
newState := self list showRoot. |
|
818 |
||
819 |
showRoot ~~ newState ifTrue:[ |
|
820 |
showRoot := newState. |
|
821 |
self invalidate. |
|
1390 | 822 |
]. |
2644 | 823 |
super updateFromList:what with:aPara. |
1390 | 824 |
! ! |
825 |
||
826 |
!HierarchicalListView methodsFor:'drawing basics'! |
|
827 |
||
1568 | 828 |
drawElementsFrom:start to:stop x:xLeft y:yT w:w |
1390 | 829 |
"draw the items between start to stop without clearing the background |
830 |
" |
|
2383 | 831 |
|item prevParent icon showIndc showIcon showText |
1568 | 832 |
yTop "{ Class:SmallInteger }" |
833 |
yCtr "{ Class:SmallInteger }" |
|
834 |
yBot "{ Class:SmallInteger }" |
|
2383 | 835 |
level "{ Class:SmallInteger }" |
1390 | 836 |
|
1568 | 837 |
xIndc "{ Class:SmallInteger }" |
838 |
xIcon "{ Class:SmallInteger }" |
|
839 |
xText "{ Class:SmallInteger }" |
|
840 |
xL "{ Class:SmallInteger }" |
|
841 |
xR "{ Class:SmallInteger }" |
|
842 |
height "{ Class:SmallInteger }" |
|
1390 | 843 |
|
1568 | 844 |
offIndcY "{ Class:SmallInteger }" |
1390 | 845 |
| |
2383 | 846 |
xL := xLeft. |
847 |
xR := xL + w. |
|
1390 | 848 |
|
2392 | 849 |
showIndicators ifTrue:[ |
2383 | 850 |
offIndcY := openIndicator width // 2. |
1390 | 851 |
]. |
852 |
||
853 |
showLines ifTrue:[ |
|
1399 | 854 |
self drawLinesFrom:start to:stop x:xL y:yT toX:xR |
1390 | 855 |
]. |
2383 | 856 |
prevParent := #NIL. "/ to force a recompute |
857 |
yBot := yT. |
|
858 |
showIndc := false. |
|
1390 | 859 |
|
860 |
start to:stop do:[:anIndex| |
|
2408 | 861 |
(item := self at:anIndex ifAbsent:nil) isNil ifTrue:[ |
1390 | 862 |
^ self "/ list changed |
863 |
]. |
|
2383 | 864 |
yTop := yBot. |
865 |
yBot := self yVisibleOfLine:(anIndex + 1). |
|
1532
56e0fafc4349
change display protocol for item
Claus Gittinger <cg@exept.de>
parents:
1509
diff
changeset
|
866 |
height := yBot - yTop. |
2383 | 867 |
yCtr := yTop + (height // 2). |
1390 | 868 |
|
2383 | 869 |
item parent ~~ prevParent ifTrue:[ |
870 |
prevParent := item parent. |
|
871 |
level := item level. |
|
872 |
xIcon := self xVisibleOfIconAtLevel:level. |
|
873 |
xText := self xVisibleOfTextAtLevel:level. |
|
874 |
showText := (xText < xR). |
|
875 |
showIcon := (xIcon < xR and:[xText > xL]). |
|
1390 | 876 |
|
2392 | 877 |
showIndicators ifTrue:[ |
2383 | 878 |
xIndc := self xVisibleOfIndicatorAtLevel:level. |
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
879 |
showIndc := (xIcon > xL and:[xIndc < xR]). |
1390 | 880 |
|
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
881 |
showIndc ifTrue:[ |
2383 | 882 |
showIndc := prevParent notNil or:[showLeftIndicators] |
1756 | 883 |
] |
1390 | 884 |
] |
885 |
]. |
|
886 |
||
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
887 |
(showIcon and:[(icon := self validateDrawableIconFor:item) notNil]) ifTrue:[ |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
888 |
(xIcon + icon width) > xL ifTrue:[ |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
889 |
icon displayOn:self x:xIcon y:(yCtr - (icon height // 2)) |
1568 | 890 |
] |
1390 | 891 |
]. |
892 |
||
893 |
showText ifTrue:[ |
|
1532
56e0fafc4349
change display protocol for item
Claus Gittinger <cg@exept.de>
parents:
1509
diff
changeset
|
894 |
self drawLabelAt:anIndex x:xText y:yTop h:height |
1390 | 895 |
]. |
2201
aa74fa6137a5
make indicator dependent on hasIndicator and not hasChildren
ca
parents:
2181
diff
changeset
|
896 |
(showIndc and:[item hasIndicator]) ifTrue:[ |
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
897 |
item isExpanded ifTrue:[icon := openIndicator ] |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
898 |
ifFalse:[icon := closeIndicator]. |
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
899 |
|
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
900 |
icon displayOn:self x:xIndc y:(yCtr - offIndcY) |
1390 | 901 |
]. |
2383 | 902 |
]. |
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 |
]. |
2224 | 1175 |
self makeLineVisible:newIdx. |
1176 |
]. |
|
1757 | 1177 |
! |
1178 |
||
1179 |
keyPress:aKey x:x y:y |
|
1180 |
"a key was pressed - handle page-keys here |
|
1181 |
" |
|
1784 | 1182 |
<resource: #keyboard( #CursorLeft #CursorRight )> |
1757 | 1183 |
|
2377 | 1184 |
|item lineNr isCursorLeft| |
1757 | 1185 |
|
1782 | 1186 |
enabled ifFalse:[^ self]. |
2377 | 1187 |
|
1188 |
( aKey == Character space |
|
1189 |
or:[aKey == #CursorRight |
|
1190 |
or:[aKey == #CursorLeft]] |
|
1191 |
) ifFalse:[ |
|
1192 |
super keyPress:aKey x:x y:y. |
|
1193 |
^ self |
|
1194 |
]. |
|
1195 |
||
1196 |
lineNr := self cursorLine. |
|
1197 |
||
1198 |
lineNr ~~ 0 ifTrue:[ |
|
1199 |
item := cursorItem |
|
1200 |
] ifFalse:[ |
|
1201 |
lineNr := self selectedIndex. |
|
1202 |
lineNr == 0 ifTrue:[^ self]. |
|
1203 |
||
2408 | 1204 |
item := self at:lineNr ifAbsent:nil. |
2377 | 1205 |
item isNil ifTrue:[^ self]. |
1206 |
]. |
|
1782 | 1207 |
|
1208 |
aKey == Character space ifTrue:[ |
|
2378 | 1209 |
item toggleExpand. |
2377 | 1210 |
^ self |
1211 |
]. |
|
1212 |
isCursorLeft := aKey == #CursorLeft. |
|
1213 |
||
1214 |
item isExpanded == isCursorLeft ifTrue:[ |
|
2378 | 1215 |
item toggleExpand. |
2377 | 1216 |
^ self |
1782 | 1217 |
]. |
2377 | 1218 |
isCursorLeft ifTrue:[ |
1219 |
(item := item parent) isNil ifTrue:[^ self]. |
|
2408 | 1220 |
lineNr := self identityIndexOf:item. |
2377 | 1221 |
] ifFalse:[ |
1222 |
item hasChildren ifFalse:[^ self]. |
|
1223 |
lineNr := lineNr + 1. |
|
2179 | 1224 |
]. |
2377 | 1225 |
|
2408 | 1226 |
item := self at:lineNr ifAbsent:nil. |
2377 | 1227 |
item isNil ifTrue:[^ self]. |
1228 |
||
1229 |
(self canSelectIndex:lineNr forAdd:false) ifTrue:[ |
|
1230 |
self selection:lineNr |
|
1231 |
]. |
|
1390 | 1232 |
! ! |
1233 |
||
1757 | 1234 |
!HierarchicalListView methodsFor:'fetch resources'! |
1235 |
||
1236 |
fetchResources |
|
1237 |
"fetch device colors and ..., to avoid reallocation at redraw time; |
|
1238 |
*** called after a create or snapin to fetch all device resources |
|
1239 |
" |
|
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1240 |
|image defaultWidth| |
1757 | 1241 |
|
1242 |
super fetchResources. |
|
1243 |
||
1244 |
lineColor := lineColor onDevice:device. |
|
2488
74c81c1e30d7
imageOnDevice -> imageOnMyDevice
Claus Gittinger <cg@exept.de>
parents:
2421
diff
changeset
|
1245 |
openIndicator := self imageOnMyDevice:openIndicator. |
74c81c1e30d7
imageOnDevice -> imageOnMyDevice
Claus Gittinger <cg@exept.de>
parents:
2421
diff
changeset
|
1246 |
closeIndicator := self imageOnMyDevice:closeIndicator. |
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1247 |
defaultWidth := imageWidth. |
1757 | 1248 |
|
1249 |
icons keysAndValuesDo:[:aKey :anImage| |
|
1250 |
anImage isNil ifTrue:[ |
|
1251 |
('HierachicalListView [warning]: missing image: ' , aKey) errorPrintCR. |
|
1252 |
] ifFalse:[ |
|
2488
74c81c1e30d7
imageOnDevice -> imageOnMyDevice
Claus Gittinger <cg@exept.de>
parents:
2421
diff
changeset
|
1253 |
image := self imageOnMyDevice:anImage. |
1757 | 1254 |
icons at:aKey put:image. |
1255 |
imageWidth := image width max:imageWidth. |
|
1256 |
] |
|
1257 |
]. |
|
2316
f91a9635462e
bug fix for alignTextRight; recomputation of alignTextRightX
ca
parents:
2313
diff
changeset
|
1258 |
imageWidth := (imageWidth + 1 // 2 * 2) max:defaultWidth. |
1904 | 1259 |
alignTextRightX := imageWidth + 20 max:alignTextRightX. |
1757 | 1260 |
! ! |
1261 |
||
2500 | 1262 |
!HierarchicalListView methodsFor:'initialization & release'! |
1390 | 1263 |
|
1264 |
initStyle |
|
1265 |
"setup viewStyle specifics |
|
1266 |
" |
|
2923 | 1267 |
<resource: #style (#'selection.highlightEnterItem' |
1268 |
#'selection.expandOnSelect' |
|
1269 |
#'selection.autoScrollHorizontal' |
|
1270 |
)> |
|
1271 |
||
1390 | 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 |
|
2328 | 1295 |
highlightEnterItem := styleSheet at:#'selection.highlightEnterItem' default:false. |
2310 | 1296 |
expandOnSelect := styleSheet at:#'selection.expandOnSelect' default:false. |
2898 | 1297 |
autoScrollHorizontal := styleSheet at:#'selection.autoScrollHorizontal' default:nil. |
2210 | 1298 |
! |
1299 |
||
1300 |
initialize |
|
1301 |
super initialize. |
|
1302 |
levelOfLastItem := 1. |
|
2898 | 1303 |
autoScrollHorizontal := true. |
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 |
|
2866
01d609cfb3d9
autoscrollHorizontal confusion cleanup
Claus Gittinger <cg@exept.de>
parents:
2822
diff
changeset
|
1541 |
self autoScrollHorizontal ifFalse:[^ vwOrgX ]. |
2644 | 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 |
|
2949 | 1647 |
^ '$Header: /cvs/stx/stx/libwidg2/HierarchicalListView.st,v 1.103 2006-03-16 19:43:27 cg Exp $' |
1390 | 1648 |
! ! |