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