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