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