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