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