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