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