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