author | penk |
Fri, 27 Sep 2002 14:16:14 +0200 | |
changeset 2227 | c5e6912cc6b2 |
parent 2224 | bfcabf142faa |
child 2229 | f1a236f5bd48 |
permissions | -rw-r--r-- |
1431 | 1 |
" |
2 |
COPYRIGHT (c) 1999 by eXept Software AG |
|
3 |
All Rights Reserved |
|
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 |
" |
|
12 |
||
13 |
||
1752 | 14 |
"{ Package: 'stx:libwidg2' }" |
15 |
||
1390 | 16 |
SelectionInListModelView subclass:#HierarchicalListView |
17 |
instanceVariableNames:'imageInset imageWidth lineMask lineColor showRoot showLines |
|
18 |
showLeftIndicators indicatorAction useDefaultIcons icons |
|
1568 | 19 |
openIndicator closeIndicator alignTextRight alignTextRightX |
2224 | 20 |
maxWidthOfText levelOfLastItem expandOnSelect |
21 |
autoScrollHorizontal' |
|
1390 | 22 |
classVariableNames:'' |
23 |
poolDictionaries:'' |
|
1430 | 24 |
category:'Views-Trees' |
1390 | 25 |
! |
26 |
||
27 |
!HierarchicalListView class methodsFor:'documentation'! |
|
28 |
||
1431 | 29 |
copyright |
30 |
" |
|
31 |
COPYRIGHT (c) 1999 by eXept Software AG |
|
32 |
All Rights Reserved |
|
33 |
||
34 |
This software is furnished under a license and may be used |
|
35 |
only in accordance with the terms of that license and with the |
|
36 |
inclusion of the above copyright notice. This software may not |
|
37 |
be provided or otherwise made available to, or used by, any |
|
38 |
other person. No title to or ownership of the software is |
|
39 |
hereby transferred. |
|
40 |
" |
|
41 |
||
42 |
! |
|
43 |
||
1757 | 44 |
documentation |
1390 | 45 |
" |
1757 | 46 |
This class implements a hierarchical list view based on a |
47 |
hierachical list. |
|
48 |
It provides functionality similar to SelectionInTreeView, but optimizes |
|
49 |
redraws, and operates directly upon the model (in contrast to |
|
50 |
SelectionInTreeView, which generates a list internally). |
|
1390 | 51 |
|
1757 | 52 |
[Instance variables:] |
53 |
textStartLeft <Integer> inset between icon and text |
|
54 |
imageInset <Integer> inset between left side and icon |
|
55 |
imageWidth <Integer> width of widest icon |
|
56 |
lineMask <Form> line mask |
|
57 |
lineColor <Color> line color |
|
58 |
showRoot <Boolean> root element is shown or hidden |
|
59 |
derives from the hierachical list. |
|
60 |
showLines <Boolean> show or hide lines |
|
61 |
useDefaultIcons <Boolean> use the default icons if no icon |
|
62 |
for an item is specified |
|
63 |
icons <IdentityDictionary> list of registered icons; |
|
64 |
identifier := <key> value := <icon> |
|
65 |
showLeftIndicators <Boolean> show or hide indicator for most left items |
|
66 |
indicatorAction <Block> action evaluated if indicator is pressed |
|
67 |
openIndicator <Icon, Image or Form> expanded indicator |
|
68 |
closeIndicator <Icon, Image or Form> collapsed indicator |
|
1390 | 69 |
|
1757 | 70 |
alignTextRight <Boolean> enable disable of align the text right |
71 |
icon text |
|
72 |
icon text of child |
|
73 |
should be set after creation of the widget!! |
|
74 |
alignTextRightX <Integer> left x position of aligned right text |
|
75 |
maxWidthOfText <Integer> keeps the maximum width of a text label |
|
76 |
||
2210 | 77 |
levelOfLastItem <Integer> keeps the level of the last item; |
78 |
in case of a delete last items from list |
|
79 |
we know were to redraw lines from |
|
1757 | 80 |
[author:] |
81 |
Claus Atzkern |
|
82 |
||
83 |
[see also:] |
|
84 |
ListModelView |
|
85 |
SelectionInListModelView |
|
1390 | 86 |
HierarchicalList |
87 |
HierarchicalItem |
|
88 |
" |
|
1757 | 89 |
! |
90 |
||
91 |
examples |
|
92 |
" |
|
1916 | 93 |
show a hierarchical list |
1757 | 94 |
[exBegin] |
95 |
|top sel list item| |
|
96 |
||
97 |
list := HierarchicalList new. |
|
98 |
item := HierarchicalItem::Example labeled:'Root Item'. |
|
99 |
||
100 |
item expand. |
|
101 |
list showRoot:false. |
|
102 |
list root:item. |
|
103 |
||
104 |
top := StandardSystemView new; extent:300@300. |
|
105 |
sel := ScrollableView for:HierarchicalListView miniScroller:true |
|
106 |
origin:0.0@0.0 corner:1.0@1.0 in:top. |
|
107 |
||
108 |
sel list:list. |
|
109 |
sel multipleSelectOk:true. |
|
110 |
||
111 |
sel doubleClickAction:[:i| (list at:i) toggleExpand ]. |
|
112 |
sel indicatorAction:[:i| (list at:i) toggleExpand ]. |
|
113 |
||
114 |
top open. |
|
115 |
[exEnd] |
|
116 |
||
117 |
||
1916 | 118 |
show a hierarchical list; open an editor on reselect a |
119 |
line with label is a string. |
|
120 |
||
121 |
[exBegin] |
|
122 |
|top sel list item| |
|
123 |
||
124 |
list := HierarchicalList new. |
|
125 |
item := HierarchicalItem::Example labeled:'Root Item'. |
|
126 |
||
127 |
item expand. |
|
128 |
list showRoot:false. |
|
129 |
list root:item. |
|
130 |
||
131 |
top := StandardSystemView new; extent:300@300. |
|
132 |
sel := ScrollableView for:HierarchicalListView miniScroller:true |
|
133 |
origin:0.0@0.0 corner:1.0@1.0 in:top. |
|
134 |
||
135 |
sel list:list. |
|
136 |
||
137 |
sel openEditorAction:[:ln :aGC| |field item| |
|
138 |
item := list at:ln. |
|
139 |
||
140 |
item label isString ifFalse:[ |
|
141 |
field := nil |
|
142 |
] ifTrue:[ |
|
143 |
field := EditField new. |
|
144 |
field level:0. |
|
145 |
field acceptOnLostFocus:true. |
|
146 |
field acceptAction:[:x| item label:(field contents) ]. |
|
147 |
field font:(aGC font). |
|
148 |
field contents:(item label). |
|
149 |
]. |
|
150 |
field |
|
151 |
]. |
|
152 |
||
153 |
sel multipleSelectOk:true. |
|
154 |
||
155 |
sel doubleClickAction:[:i| (list at:i) toggleExpand ]. |
|
156 |
sel indicatorAction:[:i| (list at:i) toggleExpand ]. |
|
157 |
||
158 |
top open. |
|
159 |
[exEnd] |
|
160 |
||
1757 | 161 |
" |
1390 | 162 |
! ! |
163 |
||
164 |
!HierarchicalListView class methodsFor:'resources'! |
|
165 |
||
166 |
closeIndicator |
|
167 |
"returns a little [+] bitmap" |
|
168 |
||
169 |
<resource: #fileImage> |
|
170 |
||
171 |
^ Icon constantNamed:#plus |
|
1632 | 172 |
ifAbsentPut:[Smalltalk imageFromFileNamed:'plus.xpm' forClass:self] |
1390 | 173 |
|
174 |
||
175 |
! |
|
176 |
||
1757 | 177 |
collapsedIcon |
178 |
"returns icon to indicate a collapsed entry |
|
179 |
" |
|
180 |
<resource: #fileImage> |
|
1390 | 181 |
|
1757 | 182 |
^ Icon constantNamed:#directory |
183 |
ifAbsentPut:[Smalltalk imageFromFileNamed:'dir.xpm' forClass:self] |
|
1390 | 184 |
|
185 |
! |
|
186 |
||
187 |
emptyIcon |
|
188 |
"returns icon to indicate an not extendable entry |
|
189 |
" |
|
190 |
<resource: #fileImage> |
|
191 |
||
192 |
^ Icon constantNamed:#plainFile |
|
1632 | 193 |
ifAbsentPut:[Smalltalk imageFromFileNamed:'file_plain.xpm' forClass:self] |
1390 | 194 |
|
195 |
! |
|
196 |
||
197 |
expandedIcon |
|
198 |
"returns icon to indicate an extended entry |
|
199 |
" |
|
200 |
<resource: #fileImage> |
|
201 |
||
202 |
^ Icon constantNamed:#directoryOpened |
|
1632 | 203 |
ifAbsentPut:[Smalltalk imageFromFileNamed:'dir_open.xpm' forClass:self] |
1390 | 204 |
|
205 |
! |
|
206 |
||
1757 | 207 |
openIndicator |
208 |
"returns a little [-] bitmap" |
|
209 |
||
210 |
<resource: #fileImage> |
|
211 |
||
212 |
^ Icon constantNamed:#minus |
|
213 |
ifAbsentPut:[Smalltalk imageFromFileNamed:'minus.xpm' forClass:self] |
|
1390 | 214 |
|
215 |
! ! |
|
216 |
||
217 |
!HierarchicalListView methodsFor:'accessing'! |
|
218 |
||
1843 | 219 |
font:aFont |
220 |
"set a new font |
|
221 |
" |
|
222 |
|root| |
|
223 |
||
224 |
(aFont isNil or:[aFont = font]) ifFalse:[ |
|
225 |
(list notNil and:[(root := list root) notNil]) ifTrue:[ |
|
226 |
root fontChanged |
|
227 |
]. |
|
228 |
super font:aFont |
|
229 |
]. |
|
230 |
! |
|
231 |
||
1390 | 232 |
list:aList |
233 |
"get the status of <showRoot> from the list |
|
234 |
" |
|
235 |
aList notNil ifTrue:[ |
|
236 |
showRoot := aList showRoot |
|
237 |
]. |
|
238 |
super list:aList |
|
1897
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
239 |
! |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
240 |
|
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
241 |
parentToChildInset |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
242 |
"returns the computed inset between parent / child |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
243 |
" |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
244 |
^ imageInset + imageWidth |
1390 | 245 |
! ! |
246 |
||
2224 | 247 |
!HierarchicalListView methodsFor:'accessing-behavior'! |
248 |
||
249 |
autoScrollHorizontal |
|
250 |
"true, than automatically scroll horizontal upto the text label |
|
251 |
of the current selected line. |
|
252 |
" |
|
253 |
^ autoScrollHorizontal ? false |
|
254 |
! |
|
255 |
||
256 |
autoScrollHorizontal:aBoolean |
|
257 |
"true, than automatically scroll horizontal upto the text label |
|
258 |
of the current selected line. |
|
259 |
" |
|
260 |
autoScrollHorizontal := aBoolean. |
|
261 |
! |
|
262 |
||
263 |
expandOnSelect |
|
264 |
"true, than the item selected by a buttonPress event will |
|
265 |
be immediately expanded. |
|
266 |
" |
|
267 |
^ expandOnSelect |
|
268 |
! |
|
269 |
||
270 |
expandOnSelect:aBoolean |
|
271 |
"true, than the item selected by a buttonPress event will |
|
272 |
be immediately expanded. |
|
273 |
" |
|
274 |
expandOnSelect := aBoolean. |
|
275 |
! ! |
|
276 |
||
1818 | 277 |
!HierarchicalListView methodsFor:'accessing-colors'! |
1390 | 278 |
|
279 |
lineColor |
|
280 |
"get the line color |
|
281 |
" |
|
282 |
^ lineColor |
|
283 |
||
284 |
||
285 |
! |
|
286 |
||
287 |
lineColor:aColor |
|
288 |
"set the line color |
|
289 |
" |
|
290 |
(aColor notNil and:[aColor ~= lineColor]) ifTrue:[ |
|
291 |
lineColor := aColor. |
|
292 |
||
293 |
shown ifTrue:[ |
|
2099 | 294 |
lineColor := lineColor onDevice:device. |
1390 | 295 |
|
296 |
showLines ifTrue:[ |
|
297 |
self invalidate |
|
298 |
] |
|
299 |
] |
|
300 |
] |
|
301 |
! ! |
|
302 |
||
1818 | 303 |
!HierarchicalListView methodsFor:'accessing-look'! |
1390 | 304 |
|
1568 | 305 |
alignTextRight |
306 |
"align the text right |
|
307 |
" |
|
308 |
^ alignTextRight |
|
309 |
! |
|
310 |
||
1757 | 311 |
alignTextRight:aBool |
312 |
"align the text right |
|
313 |
" |
|
314 |
alignTextRight := aBool ? false. |
|
315 |
! |
|
1568 | 316 |
|
1904 | 317 |
alignTextRightX |
318 |
"returns the minimum used text inset, if text is aligned right. |
|
319 |
" |
|
320 |
^ alignTextRightX |
|
321 |
! |
|
322 |
||
323 |
alignTextRightX:aNumber |
|
324 |
"set the minimum used text inset, if text is aligned right. |
|
325 |
" |
|
326 |
aNumber > self parentToChildInset ifTrue:[ |
|
327 |
alignTextRightX := aNumber. |
|
328 |
||
329 |
(alignTextRight and:[widthOfContents notNil]) ifTrue:[ |
|
330 |
widthOfContents := alignTextRightX + maxWidthOfText. |
|
331 |
||
332 |
shown ifTrue:[ |
|
333 |
self invalidate. |
|
334 |
self contentsChanged. |
|
335 |
] |
|
336 |
] |
|
337 |
]. |
|
338 |
! |
|
339 |
||
2094 | 340 |
iconAt:aKey ifAbsentPut:aBlock |
341 |
"return the icon stored under a key; if not present,the |
|
342 |
result of the block if not nil is stored under the key |
|
343 |
and returned. |
|
344 |
" |
|
345 |
|icon| |
|
346 |
||
347 |
icon := icons at:aKey ifAbsent:nil. |
|
348 |
icon ifNotNil:[^ icon]. |
|
349 |
||
350 |
icon := aBlock value. |
|
351 |
icon ifNil:[^ nil]. |
|
352 |
||
353 |
realized ifTrue:[ |
|
354 |
icon := self imageOnDevice:icon |
|
355 |
]. |
|
356 |
icons at:aKey put:icon. |
|
357 |
^ icon |
|
358 |
! |
|
359 |
||
1390 | 360 |
registerKeysAndIcons:aDictionary |
361 |
"register icons by key and value derived from a directory |
|
362 |
" |
|
363 |
|image| |
|
364 |
||
365 |
(aDictionary isNil or:[aDictionary isEmpty]) ifTrue:[ |
|
366 |
^ self |
|
367 |
]. |
|
368 |
||
369 |
aDictionary keysAndValuesDo:[:aKey :anImage| |
|
370 |
(image := self imageOnDevice:anImage) notNil ifTrue:[ |
|
371 |
icons at:aKey put:image |
|
1746 | 372 |
] ifFalse:[ |
373 |
icons removeKey:aKey ifAbsent:nil |
|
1390 | 374 |
] |
375 |
] |
|
376 |
||
377 |
! |
|
378 |
||
379 |
showLeftIndicators |
|
380 |
"show or hide the indicators for the most left items |
|
381 |
" |
|
382 |
^ showLeftIndicators |
|
383 |
||
384 |
! |
|
385 |
||
386 |
showLeftIndicators:aState |
|
387 |
"show or hide the indicators for the most left items |
|
388 |
" |
|
389 |
aState ~~ showLeftIndicators ifTrue:[ |
|
390 |
showLeftIndicators := aState. |
|
391 |
self invalidate |
|
392 |
]. |
|
393 |
||
394 |
! |
|
395 |
||
396 |
showLines |
|
397 |
"returns true if lines are shown |
|
398 |
" |
|
399 |
^ showLines |
|
400 |
||
401 |
! |
|
402 |
||
403 |
showLines:aState |
|
404 |
"show or hide lines |
|
405 |
" |
|
406 |
aState ~~ showLines ifTrue:[ |
|
407 |
showLines := aState. |
|
408 |
self invalidate |
|
409 |
]. |
|
410 |
||
411 |
! |
|
412 |
||
413 |
useDefaultIcons |
|
414 |
"use the default icons if no icon for an item is specified; |
|
415 |
** default: true |
|
416 |
" |
|
417 |
^ useDefaultIcons |
|
418 |
! |
|
419 |
||
420 |
useDefaultIcons:aBool |
|
421 |
"use the default icons if no icon for an item is specified; |
|
422 |
** default: true |
|
423 |
" |
|
424 |
useDefaultIcons ~~ aBool ifTrue:[ |
|
425 |
useDefaultIcons := aBool. |
|
426 |
||
427 |
shown ifTrue:[ |
|
428 |
self invalidate |
|
429 |
] |
|
430 |
] |
|
431 |
! ! |
|
432 |
||
433 |
!HierarchicalListView methodsFor:'actions'! |
|
434 |
||
435 |
indicatorAction |
|
436 |
"if the action is not nil, indicators are shown and a click on the indicator |
|
437 |
will evaluate the action with none or one argument, the index into the list |
|
438 |
" |
|
439 |
^ indicatorAction |
|
440 |
! |
|
441 |
||
442 |
indicatorAction:anAction |
|
443 |
"if the action is not nil, indicators are shown and a click on the indicator |
|
444 |
will evaluate the action with none or one argument, the index into the list |
|
445 |
" |
|
446 |
|wasNilBefore| |
|
447 |
||
448 |
wasNilBefore := indicatorAction isNil. |
|
449 |
indicatorAction := anAction. |
|
450 |
||
451 |
wasNilBefore == (anAction isNil) ifTrue:[ |
|
452 |
self invalidate |
|
453 |
]. |
|
454 |
! ! |
|
455 |
||
456 |
!HierarchicalListView methodsFor:'change & update'! |
|
457 |
||
1782 | 458 |
indicatorPressedAt:aLnNr |
2224 | 459 |
"handle indicator pressed action; |
460 |
if the item changed expanded, we try to show all |
|
461 |
new visible children |
|
462 |
" |
|
463 |
|item expanded availY usedY vwOrgX vwOrgY idx| |
|
464 |
||
465 |
indicatorAction ifNil:[^ self]. |
|
466 |
||
467 |
item := list at:aLnNr ifAbsent:nil. |
|
468 |
item ifNil:[^ self]. |
|
469 |
||
470 |
item hasIndicator ifFalse:[^ self]. |
|
471 |
||
472 |
expanded := item isExpanded. |
|
473 |
indicatorAction valueWithOptionalArgument:aLnNr. |
|
474 |
(expanded or:[item isExpanded not]) ifTrue:[^ self]. |
|
1783
ffe767ea66ea
check whether children exists before calling indicatorPressed action
ca
parents:
1782
diff
changeset
|
475 |
|
2224 | 476 |
"/ compute the index of last child assigned to item |
477 |
||
478 |
idx := item numberOfVisibleChildren. "/ no visible children |
|
479 |
idx == 0 ifTrue:[^ self]. |
|
480 |
||
481 |
idx := aLnNr + idx. |
|
482 |
vwOrgY := viewOrigin y. |
|
483 |
availY := (self yVisibleOfLine:aLnNr) - margin. |
|
484 |
||
485 |
availY > margin ifTrue:[ |
|
486 |
usedY := (self yVisibleOfLine:(idx + 1)) - (height - margin - margin). |
|
487 |
||
488 |
usedY > 1 ifTrue:[ |
|
489 |
vwOrgY := vwOrgY + (usedY min:availY). |
|
490 |
]. |
|
491 |
]. |
|
492 |
vwOrgX := self computeViewOriginXat:aLnNr. |
|
493 |
||
494 |
self scrollTo:(vwOrgX @ vwOrgY). |
|
1782 | 495 |
! |
496 |
||
1390 | 497 |
lineChangedAt:aLnNr with:arg |
498 |
"line changed at position; check whether line height changed |
|
499 |
" |
|
500 |
|item |
|
501 |
lv "{ Class:SmallInteger }" |
|
502 |
x0 "{ Class:SmallInteger }" |
|
503 |
x1 "{ Class:SmallInteger }" |
|
504 |
h "{ Class:SmallInteger }" |
|
505 |
y0 "{ Class:SmallInteger }" |
|
506 |
y1 "{ Class:SmallInteger }" |
|
507 |
| |
|
508 |
||
1399 | 509 |
(arg == #icon or:[arg == #hierarchy]) ifFalse:[ |
2224 | 510 |
item := list at:aLnNr ifAbsent:nil. |
511 |
item ifNil:[^ self]. |
|
512 |
||
513 |
super lineChangedAt:aLnNr with:arg. |
|
514 |
||
515 |
(arg ~~ #redraw and:[widthOfContents notNil]) ifTrue:[ |
|
516 |
x0 := self xOfStringLevel:aLnNr. |
|
517 |
x0 := x0 + (item widthOn:self) + 5. |
|
518 |
||
519 |
x0 > widthOfContents ifTrue:[ |
|
520 |
widthOfContents := x0. |
|
521 |
self contentsChanged. |
|
522 |
] |
|
523 |
]. |
|
524 |
^ self |
|
1390 | 525 |
]. |
1568 | 526 |
shown ifFalse:[^ self]. |
527 |
||
1390 | 528 |
y0 := (self yVisibleOfLine:aLnNr) max:margin. |
529 |
y1 := (self yVisibleOfLine:(aLnNr + 1)) min:(height - margin). |
|
530 |
||
1399 | 531 |
(h := y1 - y0) > 0 ifTrue:[ |
532 |
x0 := margin. |
|
533 |
x1 := width - margin. |
|
534 |
||
535 |
(item := list at:aLnNr ifAbsent:nil) isNil ifFalse:[ |
|
536 |
lv := item level. |
|
1570 | 537 |
x1 := (self xOfStringLevel:lv) - (textStartLeft // 2). |
1390 | 538 |
|
1399 | 539 |
arg == #hierarchy ifTrue:[ |
540 |
x0 := self xOfFigureLevel:(lv -1). |
|
1570 | 541 |
] ifFalse:[ |
542 |
x0 := self xOfFigureLevel:lv |
|
1399 | 543 |
]. |
544 |
x0 := x0 max:margin. |
|
545 |
x1 := x1 min:(width - margin). |
|
1568 | 546 |
x1 > x0 ifFalse:[^ self] |
547 |
]. |
|
548 |
self repairDamage. |
|
549 |
self invalidate:(Rectangle left:x0 top:y0 width:(x1 - x0) height:h) |
|
550 |
repairNow:true. |
|
551 |
] |
|
1976
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
552 |
! |
1390 | 553 |
|
1976
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
554 |
listChangedInsert:firstAddedIndex nItems:nLines |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
555 |
"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
|
556 |
" |
2210 | 557 |
|item level yTop yBot xLft start maxY| |
1390 | 558 |
|
1976
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
559 |
super listChangedInsert:firstAddedIndex nItems:nLines. |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
560 |
|
2210 | 561 |
item := list last. |
562 |
levelOfLastItem := item level. |
|
563 |
||
1976
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
564 |
( shown |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
565 |
and:[showLines |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
566 |
and:[firstAddedIndex > 1 |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
567 |
and:[nLines ~~ 0 |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
568 |
and:[(item := list at:firstAddedIndex ifAbsent:nil) notNil |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
569 |
and:[(level := item level) > 1]]]]] |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
570 |
) ifFalse:[ |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
571 |
^ self. |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
572 |
]. |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
573 |
xLft := (self xOfFigureLevel:(level - 1)) + (imageWidth // 2) - 1. |
1390 | 574 |
|
1976
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
575 |
(xLft > margin and:[xLft < (width - margin)]) ifFalse:[ |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
576 |
^ self |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
577 |
]. |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
578 |
start := firstAddedIndex - 1. |
1390 | 579 |
|
1976
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
580 |
start to:1 by:-1 do:[:i| |el| |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
581 |
el := list at:i. |
1399 | 582 |
|
1976
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
583 |
el level <= level ifTrue:[ |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
584 |
i == start ifTrue:[^ self]. |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
585 |
|
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
586 |
yTop := (self yVisibleOfLine:i + 1) max:margin. |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
587 |
maxY := height - margin. |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
588 |
|
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
589 |
yTop < maxY ifTrue:[ |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
590 |
yBot := (self yVisibleOfLine:firstAddedIndex) - 1 min:maxY. |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
591 |
self invalidate:(Rectangle left:xLft top:yTop width:3 height:(yBot - yTop)) |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
592 |
]. |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
593 |
^ self |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
594 |
] |
1788b0045176
bug fix when adding new elements; must draw vertical lines above
ca
parents:
1916
diff
changeset
|
595 |
]. |
1390 | 596 |
! |
597 |
||
2208 | 598 |
listChangedRemove:aStart toIndex:aStop |
599 |
"test whether last items are deleted; |
|
600 |
than we have to redraw lines because of different levels |
|
601 |
" |
|
2210 | 602 |
|listSize index y0 searchLevel| |
2208 | 603 |
|
2210 | 604 |
listSize := list size. |
605 |
searchLevel := levelOfLastItem. |
|
2208 | 606 |
|
2210 | 607 |
listSize == 0 ifTrue:[ |
608 |
levelOfLastItem := 1 |
|
609 |
] ifFalse:[ |
|
610 |
levelOfLastItem := list last level. |
|
611 |
]. |
|
2208 | 612 |
|
2210 | 613 |
( shown and:[showLines and:[listSize ~~ 0 and:[aStart > listSize]]]) ifTrue:[ |
614 |
index := list findLast:[:el| el level <= searchLevel ]. |
|
2208 | 615 |
|
616 |
(index ~~ 0 and:[index < listSize]) ifTrue:[ |
|
617 |
y0 := (self yVisibleOfLine:index) max:margin. |
|
618 |
self invalidateX:0 y:y0 width:width height:(height - margin - y0). |
|
619 |
] |
|
620 |
]. |
|
621 |
^ super listChangedRemove:aStart toIndex:aStop |
|
622 |
! |
|
623 |
||
1390 | 624 |
update:what with:aPara from:chgObj |
625 |
"get the status of <showRoot> from the list |
|
626 |
" |
|
627 |
chgObj == list ifTrue:[ |
|
628 |
showRoot ~~ list showRoot ifTrue:[ |
|
629 |
showRoot := list showRoot. |
|
630 |
self invalidate. |
|
631 |
] |
|
632 |
]. |
|
633 |
super update:what with:aPara from:chgObj |
|
634 |
! ! |
|
635 |
||
636 |
!HierarchicalListView methodsFor:'drawing basics'! |
|
637 |
||
1757 | 638 |
displayElement:anItem x:x y:y h:h |
639 |
"draw a label at x/y; fg/bg colors are already set |
|
640 |
" |
|
641 |
anItem displayOn:self x:x y:y h:h |
|
642 |
||
1399 | 643 |
! |
644 |
||
1568 | 645 |
drawElementsFrom:start to:stop x:xLeft y:yT w:w |
1390 | 646 |
"draw the items between start to stop without clearing the background |
647 |
" |
|
648 |
|item prevItem parent icon showIndc showIcon showText nxtPrnt |
|
2049 | 649 |
iconExtent |
1568 | 650 |
yTop "{ Class:SmallInteger }" |
651 |
yCtr "{ Class:SmallInteger }" |
|
652 |
yBot "{ Class:SmallInteger }" |
|
1390 | 653 |
|
1568 | 654 |
xIndc "{ Class:SmallInteger }" |
655 |
xIcon "{ Class:SmallInteger }" |
|
656 |
xText "{ Class:SmallInteger }" |
|
657 |
xDeltaIT "{ Class:SmallInteger }" |
|
658 |
xL "{ Class:SmallInteger }" |
|
659 |
xR "{ Class:SmallInteger }" |
|
660 |
height "{ Class:SmallInteger }" |
|
1390 | 661 |
|
1568 | 662 |
widthLvl "{ Class:SmallInteger }" |
663 |
insetTxt "{ Class:SmallInteger }" |
|
1390 | 664 |
|
1568 | 665 |
offIndcX "{ Class:SmallInteger }" |
666 |
offIndcY "{ Class:SmallInteger }" |
|
667 |
offIconX "{ Class:SmallInteger }" |
|
668 |
iconWidth "{ Class:SmallInteger }" |
|
669 |
iconRgtX "{ Class:SmallInteger }" |
|
1390 | 670 |
| |
671 |
widthLvl := imageInset + imageWidth. |
|
672 |
insetTxt := textStartLeft + imageWidth. |
|
1568 | 673 |
xL := xLeft. |
674 |
xR := xL + w. |
|
675 |
||
676 |
alignTextRight ifTrue:[ |
|
677 |
xText := alignTextRightX - (viewOrigin x). |
|
678 |
showText := xText < xR. |
|
679 |
]. |
|
680 |
||
1390 | 681 |
offIconX := self xOfFigureLevel:0. |
682 |
showIndc := false. |
|
683 |
||
684 |
indicatorAction notNil ifTrue:[ |
|
2049 | 685 |
offIndcX := offIndcY := 0. |
686 |
openIndicator notNil ifTrue:[ |
|
687 |
iconExtent := openIndicator extent // 2. |
|
688 |
offIndcX := imageWidth // 2 - widthLvl. |
|
689 |
offIndcX := offIndcX - iconExtent x. |
|
690 |
offIndcY := iconExtent y. |
|
691 |
] |
|
1390 | 692 |
]. |
693 |
||
694 |
showLines ifTrue:[ |
|
1399 | 695 |
self drawLinesFrom:start to:stop x:xL y:yT toX:xR |
1390 | 696 |
]. |
697 |
||
698 |
parent := 4711. "/ to force a recompute |
|
699 |
prevItem := 4711. "/ to force a recomputation of the level |
|
1399 | 700 |
yBot := yT. |
1756 | 701 |
xIcon := offIconX. |
1390 | 702 |
|
703 |
start to:stop do:[:anIndex| |
|
704 |
(item := list at:anIndex ifAbsent:nil) isNil ifTrue:[ |
|
705 |
^ self "/ list changed |
|
706 |
]. |
|
707 |
yTop := yBot. |
|
708 |
yBot := self yVisibleOfLine:(anIndex + 1). |
|
1532
56e0fafc4349
change display protocol for item
Claus Gittinger <cg@exept.de>
parents:
1509
diff
changeset
|
709 |
height := yBot - yTop. |
56e0fafc4349
change display protocol for item
Claus Gittinger <cg@exept.de>
parents:
1509
diff
changeset
|
710 |
|
56e0fafc4349
change display protocol for item
Claus Gittinger <cg@exept.de>
parents:
1509
diff
changeset
|
711 |
yCtr := yTop + (height // 2). |
1390 | 712 |
|
713 |
(nxtPrnt := item parent) ~~ parent ifTrue:[ |
|
714 |
parent := nxtPrnt. |
|
715 |
xIcon := prevItem == parent ifTrue:[xIcon + widthLvl] |
|
716 |
ifFalse:[item level * widthLvl + offIconX]. |
|
717 |
||
1568 | 718 |
|
719 |
alignTextRight ifFalse:[ |
|
720 |
xText := xIcon + insetTxt. |
|
721 |
showText := xText < xR. |
|
722 |
]. |
|
1399 | 723 |
showIcon := xIcon < xR and:[xText > xL]. |
1390 | 724 |
|
725 |
indicatorAction notNil ifTrue:[ |
|
726 |
xIndc := xIcon + offIndcX. |
|
727 |
||
1756 | 728 |
(xIcon > xL and:[xIndc < xR]) ifTrue:[ |
729 |
showIndc := parent notNil or:[showLeftIndicators] |
|
730 |
] ifFalse:[ |
|
731 |
showIndc := false |
|
732 |
] |
|
1390 | 733 |
] |
734 |
]. |
|
735 |
||
736 |
(showIcon and:[(icon := self figureFor:item) notNil]) ifTrue:[ |
|
1568 | 737 |
iconWidth := icon width. |
738 |
iconRgtX := xIcon + iconWidth. |
|
739 |
xDeltaIT := xText - textStartLeft - iconRgtX. |
|
740 |
||
741 |
xDeltaIT < 0 ifTrue:[ |
|
742 |
alignTextRightX := alignTextRightX - xDeltaIT. |
|
743 |
||
744 |
alignTextRight ifFalse:[ |
|
745 |
imageWidth := iconWidth. |
|
746 |
widthOfContents := widthOfContents - xDeltaIT. |
|
747 |
] ifTrue:[ |
|
748 |
widthOfContents := alignTextRightX + maxWidthOfText |
|
749 |
]. |
|
750 |
self contentsChanged. |
|
1390 | 751 |
StopRedrawSignal raise |
752 |
]. |
|
1568 | 753 |
iconRgtX > xL ifTrue:[ |
2181 | 754 |
icon displayOn:self x:xIcon y:(yCtr - (icon height // 2)) |
1568 | 755 |
] |
1390 | 756 |
]. |
757 |
||
758 |
showText ifTrue:[ |
|
1532
56e0fafc4349
change display protocol for item
Claus Gittinger <cg@exept.de>
parents:
1509
diff
changeset
|
759 |
self drawLabelAt:anIndex x:xText y:yTop h:height |
1390 | 760 |
]. |
2201
aa74fa6137a5
make indicator dependent on hasIndicator and not hasChildren
ca
parents:
2181
diff
changeset
|
761 |
(showIndc and:[item hasIndicator]) ifTrue:[ |
1390 | 762 |
icon := item isExpanded ifTrue:[openIndicator] ifFalse:[closeIndicator]. |
2049 | 763 |
icon notNil ifTrue:[ |
2181 | 764 |
icon displayOn:self x:xIndc y:(yCtr - offIndcY) |
2049 | 765 |
] |
1390 | 766 |
]. |
767 |
prevItem := item. |
|
768 |
] |
|
769 |
! |
|
770 |
||
1399 | 771 |
drawLinesFrom:start to:stop x:xL y:yT toX:xR |
1390 | 772 |
"draw the lines between start to stop without clearing the background |
773 |
" |
|
774 |
|item prevItem parent p1 p2 showVLines showHLine lv nxtPrnt |
|
775 |
showRootNot isFirst buildInArray |
|
776 |
||
777 |
x "{ Class:SmallInteger }" |
|
1570 | 778 |
xText "{ Class:SmallInteger }" |
779 |
||
1390 | 780 |
y "{ Class:SmallInteger }" |
781 |
yTop "{ Class:SmallInteger }" |
|
782 |
yBot "{ Class:SmallInteger }" |
|
783 |
yCtr "{ Class:SmallInteger }" |
|
784 |
||
785 |
begHLnY "{ Class:SmallInteger }" |
|
786 |
runHLnY "{ Class:SmallInteger }" |
|
787 |
begHLnX "{ Class:SmallInteger }" |
|
788 |
endHLnX "{ Class:SmallInteger }" |
|
789 |
||
1897
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
790 |
widthLvl "{ Class:SmallInteger }" |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
791 |
offsHLnX "{ Class:SmallInteger }" |
1390 | 792 |
|
1897
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
793 |
level "{ Class:SmallInteger }" |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
794 |
startLvI "{ Class:SmallInteger }" |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
795 |
startLvX "{ Class:SmallInteger }" |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
796 |
limitLvI "{ Class:SmallInteger }" |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
797 |
limitLvX "{ Class:SmallInteger }" |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
798 |
imgHWdt "{ Class:SmallInteger }" |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
799 |
minXVLine "{ Class:SmallInteger }" |
1390 | 800 |
| |
1792
26aa6dc38278
draw vertical line not into icon if no children defined
ca
parents:
1784
diff
changeset
|
801 |
imgHWdt := imageWidth // 2. |
1390 | 802 |
widthLvl := imageInset + imageWidth. |
1792
26aa6dc38278
draw vertical line not into icon if no children defined
ca
parents:
1784
diff
changeset
|
803 |
offsHLnX := imgHWdt + (self xOfFigureLevel:-1). |
1390 | 804 |
|
805 |
parent := 4711. "/ to force a recompute |
|
806 |
prevItem := 4711. "/ to force a recomputation of the level |
|
807 |
||
808 |
self setMaskOrigin:(self viewOrigin + (0 @ 1) \\ (lineMask extent)). |
|
809 |
self paint:lineColor on:bgColor. |
|
810 |
self mask:lineMask. |
|
811 |
startLvI := self smallestLevelBetween:start and:stop. |
|
812 |
startLvX := self xOfFigureLevel:startLvI. |
|
813 |
limitLvI := 2. |
|
814 |
limitLvX := limitLvI * widthLvl + offsHLnX. |
|
815 |
||
1897
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
816 |
showRoot ifFalse:[ |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
817 |
minXVLine := (self xOfFigureLevel:2) - 2. "/ tolerance |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
818 |
] ifTrue:[ |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
819 |
minXVLine := 0 |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
820 |
]. |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
821 |
|
1567 | 822 |
showRootNot := showRoot not. |
823 |
yBot := yT. |
|
824 |
begHLnY := runHLnY := yT. |
|
1756 | 825 |
endHLnX := limitLvX. |
826 |
level := 1. |
|
1390 | 827 |
|
1570 | 828 |
alignTextRight ifTrue:[ |
829 |
xText := alignTextRightX - (viewOrigin x) - textStartLeft. |
|
830 |
]. |
|
831 |
||
1390 | 832 |
start to:stop do:[:anIndex| |
833 |
(item := list at:anIndex ifAbsent:nil) isNil ifTrue:[ |
|
834 |
^ self mask:nil "/ list changed |
|
835 |
]. |
|
836 |
yTop := yBot. |
|
837 |
yBot := self yVisibleOfLine:(anIndex + 1). |
|
838 |
yCtr := yTop + (yBot - yTop // 2). |
|
839 |
anIndex == 1 ifTrue:[ begHLnY := runHLnY := yCtr ]. |
|
840 |
||
841 |
(nxtPrnt := item parent) ~~ parent ifTrue:[ |
|
842 |
parent := nxtPrnt. |
|
843 |
||
844 |
prevItem == parent ifTrue:[ |
|
1567 | 845 |
level := level + 1. |
1390 | 846 |
begHLnX := endHLnX. |
847 |
] ifFalse:[ |
|
848 |
level := item level. |
|
1567 | 849 |
begHLnX := level * widthLvl + offsHLnX. |
1390 | 850 |
]. |
851 |
||
852 |
isFirst := parent isNil or:[(showRootNot and:[level == 2])]. |
|
853 |
endHLnX := begHLnX + widthLvl. |
|
1399 | 854 |
showVLines := begHLnX >= xL and:[level > 1]. |
1570 | 855 |
|
856 |
alignTextRight ifFalse:[ |
|
857 |
xText := endHLnX + (widthLvl // 2). |
|
858 |
]. |
|
859 |
showHLine := (xL < xText and:[xR > begHLnX]). |
|
1390 | 860 |
|
861 |
(showHLine and:[isFirst]) ifTrue:[ |
|
862 |
showHLine := showLeftIndicators and:[indicatorAction notNil] |
|
863 |
] |
|
864 |
]. |
|
865 |
||
866 |
showHLine ifTrue:[ |
|
1570 | 867 |
item drawHorizontalLineUpToText ifTrue:[ |
868 |
p1 := xText |
|
869 |
] ifFalse:[ |
|
1792
26aa6dc38278
draw vertical line not into icon if no children defined
ca
parents:
1784
diff
changeset
|
870 |
item hasChildren ifTrue:[ |
26aa6dc38278
draw vertical line not into icon if no children defined
ca
parents:
1784
diff
changeset
|
871 |
p1 := endHLnX. |
26aa6dc38278
draw vertical line not into icon if no children defined
ca
parents:
1784
diff
changeset
|
872 |
] ifFalse:[ |
1897
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
873 |
(showRoot not and:[item parent isRootItem]) ifTrue:[ |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
874 |
p1 := xL - 1 "/ do not draw the horizontal line |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
875 |
] ifFalse:[ |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
876 |
p1 := begHLnX + imgHWdt |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
877 |
] |
1792
26aa6dc38278
draw vertical line not into icon if no children defined
ca
parents:
1784
diff
changeset
|
878 |
] |
1570 | 879 |
]. |
1792
26aa6dc38278
draw vertical line not into icon if no children defined
ca
parents:
1784
diff
changeset
|
880 |
xL < p1 ifTrue:[ |
1570 | 881 |
self displayLineFromX:begHLnX y:yCtr toX:p1 y:yCtr |
882 |
] |
|
1390 | 883 |
]. |
884 |
||
885 |
showVLines ifTrue:[ |
|
886 |
y := (parent last == item) ifTrue:[yCtr] ifFalse:[yBot]. |
|
887 |
x := begHLnX. |
|
888 |
p2 := parent. |
|
889 |
lv := level - 1. |
|
1897
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
890 |
|
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
891 |
x >= minXVLine ifTrue:[ |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
892 |
self displayLineFromX:x y:runHLnY toX:x y:y. |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
893 |
]. |
1390 | 894 |
|
895 |
[((p1 := p2 parent) notNil and:[(x := x - widthLvl) >= limitLvX])] whileTrue:[ |
|
1399 | 896 |
(p1 last ~~ p2 and:[x <= xR]) ifTrue:[ |
1390 | 897 |
x >= startLvX ifTrue:[ |
1897
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
898 |
x >= minXVLine ifTrue:[ |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
899 |
self displayLineFromX:x y:(yTop - 1) toX:x y:yBot |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
900 |
] |
1390 | 901 |
] ifFalse:[ |
1567 | 902 |
buildInArray isNil ifTrue:[buildInArray := Array new:startLvI]. |
1390 | 903 |
buildInArray at:lv put:yBot |
904 |
]. |
|
905 |
]. |
|
906 |
lv := lv - 1. |
|
907 |
p2 := p1 |
|
908 |
] |
|
909 |
]. |
|
910 |
prevItem := item. |
|
911 |
runHLnY := yCtr. |
|
912 |
]. |
|
913 |
||
914 |
"/ |
|
915 |
"/ draw outstanding verical lines to left |
|
916 |
"/ |
|
1897
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
917 |
x := minXVLine max:xL. |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
918 |
|
1567 | 919 |
(item isExpanded and:[item hasChildren]) ifTrue:[ |
1897
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
920 |
(endHLnX >= x and:[endHLnX <= xR]) ifTrue:[ |
1567 | 921 |
self displayLineFromX:endHLnX y:yCtr toX:endHLnX y:yBot. |
922 |
] |
|
1390 | 923 |
]. |
1567 | 924 |
|
925 |
buildInArray notNil ifTrue:[ |
|
926 |
x := limitLvX. |
|
927 |
y := begHLnY. |
|
1390 | 928 |
|
1567 | 929 |
limitLvI to:startLvI do:[:i| |
1597 | 930 |
|yB| |
1596 | 931 |
|
1597 | 932 |
(yB := buildInArray at:i) notNil ifTrue:[ |
1897
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
933 |
x >= minXVLine ifTrue:[ |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
934 |
self displayLineFromX:x y:y toX:x y:yB |
5609f92e6d4a
do not draw the first vertical line if the rootItem is not visible
ca
parents:
1843
diff
changeset
|
935 |
] |
1567 | 936 |
]. |
937 |
x := x + widthLvl. |
|
1390 | 938 |
] |
939 |
]. |
|
940 |
self mask:nil. |
|
941 |
! ! |
|
942 |
||
943 |
!HierarchicalListView methodsFor:'event handling'! |
|
944 |
||
945 |
buttonMultiPress:button x:x y:y |
|
946 |
"handle a button multiPress event |
|
947 |
" |
|
948 |
|lnNr| |
|
949 |
||
950 |
enabled ifTrue:[ |
|
951 |
( (button == 1 or:[button == #select]) |
|
952 |
and:[(lnNr := self indicatorLineAtX:x y:y) notNil] |
|
953 |
) ifFalse:[ |
|
954 |
super buttonMultiPress:button x:x y:y |
|
955 |
] |
|
956 |
] |
|
957 |
! |
|
958 |
||
1757 | 959 |
buttonPress:button x:x y:y |
960 |
"handle a button press event |
|
961 |
" |
|
2224 | 962 |
|lineNr| |
963 |
||
964 |
enabled ifFalse:[^ self]. |
|
965 |
||
966 |
(button == 1 or:[button == #select]) ifTrue:[ |
|
967 |
lineNr := self indicatorLineAtX:x y:y. |
|
968 |
||
969 |
lineNr ifNotNil:[ |
|
970 |
self indicatorPressedAt:lineNr. |
|
971 |
^ self |
|
972 |
]. |
|
973 |
]. |
|
974 |
super buttonPress:button x:x y:y. |
|
975 |
! |
|
1390 | 976 |
|
2224 | 977 |
buttonPressOrReleaseAtLine:aLnNr x:x y:y |
978 |
"handle a button press or release at a line |
|
979 |
" |
|
980 |
|oldIdx newIdx newItem| |
|
981 |
||
982 |
oldIdx := self selectedIndex. |
|
983 |
super buttonPressOrReleaseAtLine:aLnNr x:x y:y. |
|
984 |
newIdx := self selectedIndex. |
|
985 |
||
986 |
(newIdx ~~ oldIdx and:[newIdx ~~ 0]) ifTrue:[ |
|
987 |
expandOnSelect ifTrue:[ |
|
988 |
newItem := list at:newIdx ifAbsent:nil. |
|
989 |
newItem ifNil:[^ self]. |
|
990 |
newItem expand |
|
1390 | 991 |
]. |
2224 | 992 |
self makeLineVisible:newIdx. |
993 |
]. |
|
1757 | 994 |
! |
995 |
||
996 |
keyPress:aKey x:x y:y |
|
997 |
"a key was pressed - handle page-keys here |
|
998 |
" |
|
1784 | 999 |
<resource: #keyboard( #CursorLeft #CursorRight )> |
1757 | 1000 |
|
2227 | 1001 |
|item index| |
1757 | 1002 |
|
1782 | 1003 |
enabled ifFalse:[^ self]. |
2179 | 1004 |
index := self selectedIndex. |
1782 | 1005 |
|
1006 |
aKey == Character space ifTrue:[ |
|
2179 | 1007 |
index ~~ 0 ifTrue:[ |
1782 | 1008 |
^ self indicatorPressedAt:index |
1009 |
] |
|
1010 |
]. |
|
2179 | 1011 |
((aKey == #CursorRight) or:[(aKey == #CursorLeft)]) ifTrue:[ |
1012 |
index ~~ 0 ifTrue:[ |
|
1013 |
item := list at:index ifAbsent:nil. |
|
1014 |
item notNil ifTrue:[ |
|
1015 |
(aKey == #CursorLeft) == (item isExpanded) ifTrue:[ |
|
1016 |
^ self indicatorPressedAt:index |
|
1017 |
] ifFalse:[ |
|
1018 |
aKey == #CursorLeft ifTrue:[ |
|
1019 |
self selectElement:item parent ifAbsent:[]. |
|
1020 |
^ self. |
|
2227 | 1021 |
] ifFalse:[ |
1022 |
" select the childrens first item on CursorLeft |
|
1023 |
if there are any" |
|
1024 |
item hasChildren ifTrue:[ |
|
1025 |
self selection:(index + 1) |
|
1026 |
]. |
|
1027 |
^ self. |
|
2179 | 1028 |
]. |
1029 |
]. |
|
1030 |
] |
|
1031 |
] |
|
1032 |
]. |
|
1033 |
^ super keyPress:aKey x:x y:y |
|
1390 | 1034 |
! ! |
1035 |
||
1757 | 1036 |
!HierarchicalListView methodsFor:'fetch resources'! |
1037 |
||
1038 |
fetchResources |
|
1039 |
"fetch device colors and ..., to avoid reallocation at redraw time; |
|
1040 |
*** called after a create or snapin to fetch all device resources |
|
1041 |
" |
|
1042 |
|image| |
|
1043 |
||
1044 |
super fetchResources. |
|
1045 |
||
1046 |
lineMask := lineMask onDevice:device. |
|
1047 |
lineColor := lineColor onDevice:device. |
|
1048 |
openIndicator := self imageOnDevice:openIndicator. |
|
1049 |
closeIndicator := self imageOnDevice:closeIndicator. |
|
1050 |
imageWidth := 2. |
|
1051 |
||
1052 |
icons keysAndValuesDo:[:aKey :anImage| |
|
1053 |
anImage isNil ifTrue:[ |
|
1054 |
('HierachicalListView [warning]: missing image: ' , aKey) errorPrintCR. |
|
1055 |
] ifFalse:[ |
|
1056 |
image := self imageOnDevice:anImage. |
|
1057 |
icons at:aKey put:image. |
|
1058 |
imageWidth := image width max:imageWidth. |
|
1059 |
] |
|
1060 |
]. |
|
1061 |
imageWidth := imageWidth + 1 // 2 * 2. |
|
1904 | 1062 |
alignTextRightX := imageWidth + 20 max:alignTextRightX. |
1757 | 1063 |
! ! |
1064 |
||
1390 | 1065 |
!HierarchicalListView methodsFor:'initialize / release'! |
1066 |
||
1067 |
initStyle |
|
1068 |
"setup viewStyle specifics |
|
1069 |
" |
|
1070 |
|cls| |
|
1071 |
||
1072 |
super initStyle. |
|
1073 |
||
1074 |
cls := self class. |
|
1075 |
||
1076 |
lineMask := Form width:2 height:2 fromArray:#[16rAA 16r55]. |
|
1779
5848ce6ff439
change registeredIcons from IdentityDictionary to Dictionary
ca
parents:
1757
diff
changeset
|
1077 |
icons := Dictionary new. |
1390 | 1078 |
|
1079 |
openIndicator := self class openIndicator. |
|
1080 |
closeIndicator := self class closeIndicator. |
|
1081 |
lineColor := fgColor. |
|
1082 |
highlightMode := #label. |
|
1083 |
showRoot := true. |
|
1084 |
showLeftIndicators := true. |
|
1085 |
useDefaultIcons := true. |
|
1086 |
showLines := true. |
|
1087 |
imageInset := 4. |
|
1746 | 1088 |
imageWidth := 4. "/ default |
1568 | 1089 |
alignTextRight := false. |
1090 |
alignTextRightX := 8. |
|
1091 |
maxWidthOfText := 0. |
|
2224 | 1092 |
|
1093 |
expandOnSelect := false. |
|
1094 |
autoScrollHorizontal := true. |
|
2210 | 1095 |
! |
1096 |
||
1097 |
initialize |
|
1098 |
super initialize. |
|
1099 |
levelOfLastItem := 1. |
|
1390 | 1100 |
! ! |
1101 |
||
1102 |
!HierarchicalListView methodsFor:'private'! |
|
1103 |
||
1104 |
figureFor:anItem |
|
1105 |
"return a (bitmap) figure for an item |
|
1106 |
" |
|
1756 | 1107 |
|key image| |
1390 | 1108 |
|
1109 |
"/ the item may provide an icon |
|
1110 |
"/ (it knows for itself if its open or closed) |
|
1111 |
||
1112 |
(key := anItem icon) notNil ifTrue:[ |
|
1113 |
(key isImageOrForm and:[key device == device]) ifTrue:[ |
|
2134 | 1114 |
"/ get a icon from the item |
1390 | 1115 |
^ key |
1116 |
]. |
|
1117 |
||
2134 | 1118 |
"/ get a key from the item |
1390 | 1119 |
(image := icons at:key ifAbsent:nil) notNil ifTrue:[ |
1120 |
^ image |
|
1121 |
]. |
|
1122 |
||
1123 |
key isImageOrForm ifTrue:[ |
|
2134 | 1124 |
"/ associate image to device |
1390 | 1125 |
image := self imageOnDevice:key. |
1126 |
icons at:key put:image. |
|
1127 |
^ image |
|
1128 |
] |
|
1129 |
]. |
|
1130 |
||
1131 |
useDefaultIcons ifFalse:[^ nil]. |
|
1132 |
||
1133 |
"/ ok, item did not return an icon - use default. |
|
1134 |
||
1135 |
anItem hasChildren ifTrue:[ |
|
1136 |
key := anItem isExpanded ifTrue:[#expanded] ifFalse:[#collapsed] |
|
1137 |
] ifFalse:[ |
|
1138 |
key := #empty |
|
1139 |
]. |
|
1898 | 1140 |
image := icons at:key ifAbsent:nil. |
1141 |
||
1142 |
image isNil ifTrue:[ |
|
1143 |
key == #expanded ifTrue:[image := self class expandedIcon]. |
|
1144 |
key == #collapsed ifTrue:[image := self class collapsedIcon]. |
|
1145 |
key == #empty ifTrue:[image := self class emptyIcon]. |
|
1146 |
||
1147 |
image isNil ifTrue:[^ nil]. |
|
1148 |
image := self imageOnDevice:image. |
|
1149 |
icons at:key put:image. |
|
1150 |
]. |
|
1151 |
^ image |
|
1390 | 1152 |
! |
1153 |
||
1154 |
heightOfLineAt:aLineNr |
|
1155 |
"returns the total height for a line at an index, including |
|
1156 |
lineSpacing, the figure and the label |
|
1157 |
" |
|
1158 |
|item icon height| |
|
1159 |
||
1508
9c54f2e53da1
check whether #at:ifAbsent returns nil.
Claus Gittinger <cg@exept.de>
parents:
1431
diff
changeset
|
1160 |
item := list at:aLineNr ifAbsent:nil. |
9c54f2e53da1
check whether #at:ifAbsent returns nil.
Claus Gittinger <cg@exept.de>
parents:
1431
diff
changeset
|
1161 |
item isNil ifTrue:[^ 4]. |
9c54f2e53da1
check whether #at:ifAbsent returns nil.
Claus Gittinger <cg@exept.de>
parents:
1431
diff
changeset
|
1162 |
|
1390 | 1163 |
height := item heightOn:self. |
1164 |
||
1165 |
(icon := self figureFor:item) notNil ifTrue:[ |
|
1391 | 1166 |
height := (icon heightOn:self) max:height. |
1390 | 1167 |
]. |
1168 |
^ lineSpacing + height |
|
1169 |
||
1170 |
||
1171 |
! |
|
1172 |
||
1757 | 1173 |
indicatorLineAtX:x y:y |
1174 |
"returns the lineNumber assigned to an indicator at x/y or nil |
|
1175 |
" |
|
1176 |
|lnNr item x0| |
|
1390 | 1177 |
|
2201
aa74fa6137a5
make indicator dependent on hasIndicator and not hasChildren
ca
parents:
2181
diff
changeset
|
1178 |
indicatorAction ifNil:[^ nil]. "/ no action, thus no indicator defined |
aa74fa6137a5
make indicator dependent on hasIndicator and not hasChildren
ca
parents:
2181
diff
changeset
|
1179 |
|
aa74fa6137a5
make indicator dependent on hasIndicator and not hasChildren
ca
parents:
2181
diff
changeset
|
1180 |
lnNr := self yVisibleToLineNr:y. |
aa74fa6137a5
make indicator dependent on hasIndicator and not hasChildren
ca
parents:
2181
diff
changeset
|
1181 |
lnNr ifNil:[ ^ nil]. "/ y not in a valid line |
aa74fa6137a5
make indicator dependent on hasIndicator and not hasChildren
ca
parents:
2181
diff
changeset
|
1182 |
|
aa74fa6137a5
make indicator dependent on hasIndicator and not hasChildren
ca
parents:
2181
diff
changeset
|
1183 |
item := list at:lnNr ifAbsent:nil. |
aa74fa6137a5
make indicator dependent on hasIndicator and not hasChildren
ca
parents:
2181
diff
changeset
|
1184 |
item ifNil:[ ^ nil]. "/ no item at line |
aa74fa6137a5
make indicator dependent on hasIndicator and not hasChildren
ca
parents:
2181
diff
changeset
|
1185 |
|
aa74fa6137a5
make indicator dependent on hasIndicator and not hasChildren
ca
parents:
2181
diff
changeset
|
1186 |
item hasIndicator ifTrue:[ |
1757 | 1187 |
x0 := self xOfFigureLevel:(item level - 1). |
1188 |
||
1189 |
(x > x0 and:[(x0 + imageWidth) > x]) ifTrue:[ |
|
1190 |
^ lnNr |
|
1191 |
] |
|
1756 | 1192 |
]. |
1757 | 1193 |
^ nil |
1390 | 1194 |
! |
1195 |
||
1196 |
smallestLevelBetween:start and:stop |
|
1197 |
"returns the smallest level between a range |
|
1198 |
" |
|
1199 |
|prevItem currParent nextParent item |
|
1200 |
||
1201 |
lvl "{ Class:SmallInteger }" |
|
1202 |
min "{ Class:SmallInteger }" |
|
1203 |
beg "{ Class:SmallInteger }" |
|
1204 |
| |
|
1205 |
||
1508
9c54f2e53da1
check whether #at:ifAbsent returns nil.
Claus Gittinger <cg@exept.de>
parents:
1431
diff
changeset
|
1206 |
prevItem := list at:start ifAbsent:nil. |
1390 | 1207 |
|
1508
9c54f2e53da1
check whether #at:ifAbsent returns nil.
Claus Gittinger <cg@exept.de>
parents:
1431
diff
changeset
|
1208 |
(prevItem isNil or:[(currParent := prevItem parent) isNil]) ifTrue:[ |
1390 | 1209 |
^ 1 |
1210 |
]. |
|
1211 |
||
1212 |
(min := prevItem level) == 2 ifTrue:[ |
|
1213 |
^ min |
|
1214 |
]. |
|
1215 |
beg := start + 1. |
|
1216 |
||
1217 |
beg to:stop do:[:i| |
|
1508
9c54f2e53da1
check whether #at:ifAbsent returns nil.
Claus Gittinger <cg@exept.de>
parents:
1431
diff
changeset
|
1218 |
item := list at:i ifAbsent:nil. |
9c54f2e53da1
check whether #at:ifAbsent returns nil.
Claus Gittinger <cg@exept.de>
parents:
1431
diff
changeset
|
1219 |
item isNil ifTrue:[^ min]. |
1390 | 1220 |
|
1221 |
(nextParent := item parent) == currParent ifFalse:[ |
|
1222 |
(currParent := nextParent) == prevItem ifFalse:[ |
|
1223 |
(lvl := item level) == 2 ifTrue:[ |
|
1224 |
^ 2 |
|
1225 |
]. |
|
1226 |
min := min min:lvl |
|
1227 |
] |
|
1228 |
]. |
|
1229 |
prevItem := item |
|
1230 |
]. |
|
1231 |
^ min |
|
1232 |
||
1233 |
||
1234 |
||
1235 |
||
1236 |
||
1237 |
! |
|
1238 |
||
1239 |
widthOfWidestLineBetween:firstLine and:lastLine |
|
1240 |
"return the width of the longest line in pixels |
|
1241 |
" |
|
1756 | 1242 |
|nprnt pprnt pitem item |
1390 | 1243 |
textX "{ Class: SmallInteger }" |
1244 |
level "{ Class: SmallInteger }" |
|
1245 |
width "{ Class: SmallInteger }" |
|
1246 |
deltaX "{ Class: SmallInteger }" |
|
1247 |
startX "{ Class: SmallInteger }" |
|
1568 | 1248 |
itemW "{ Class: SmallInteger }" |
1390 | 1249 |
| |
1568 | 1250 |
width := 20. |
1251 |
||
1252 |
alignTextRight ifTrue:[ |
|
1253 |
firstLine to:lastLine do:[:idx| |
|
1254 |
item := list at:idx ifAbsent:nil. |
|
1255 |
||
1256 |
item isNil ifTrue:[ |
|
1257 |
maxWidthOfText := maxWidthOfText max:width. |
|
1258 |
^ alignTextRightX + width |
|
1259 |
]. |
|
1260 |
width := (item widthOn:self) max:width. |
|
1261 |
]. |
|
1262 |
maxWidthOfText := maxWidthOfText max:width. |
|
1263 |
^ alignTextRightX + width |
|
1264 |
]. |
|
1390 | 1265 |
|
1266 |
pprnt := 4711. "/ force a computation |
|
1267 |
pitem := 4712. "/ force a computation |
|
1268 |
deltaX := imageInset + imageWidth. |
|
1568 | 1269 |
|
1390 | 1270 |
startX := self xOfStringLevel:1. |
1568 | 1271 |
startX := startX + (viewOrigin x). |
1756 | 1272 |
textX := 0. |
1273 |
level := 1. |
|
1390 | 1274 |
|
1275 |
firstLine to:lastLine do:[:idx| |
|
1508
9c54f2e53da1
check whether #at:ifAbsent returns nil.
Claus Gittinger <cg@exept.de>
parents:
1431
diff
changeset
|
1276 |
item := list at:idx ifAbsent:nil. |
9c54f2e53da1
check whether #at:ifAbsent returns nil.
Claus Gittinger <cg@exept.de>
parents:
1431
diff
changeset
|
1277 |
item isNil ifTrue:[^ width + startX]. |
1390 | 1278 |
|
1279 |
(nprnt := item parent) ~~ pprnt ifTrue:[ |
|
1280 |
(pprnt := nprnt) == pitem ifTrue:[ |
|
1281 |
level := level + 1. |
|
1282 |
textX := textX + deltaX. |
|
1283 |
] ifFalse:[ |
|
1284 |
level := item level. |
|
1285 |
textX := level - 1 * deltaX. |
|
1286 |
] |
|
1287 |
]. |
|
1288 |
pitem := item. |
|
1568 | 1289 |
itemW := item widthOn:self. |
1290 |
maxWidthOfText := maxWidthOfText max:itemW. |
|
1291 |
width := (itemW + textX) max:width |
|
1390 | 1292 |
]. |
1568 | 1293 |
^ width + startX. |
1390 | 1294 |
|
1295 |
! |
|
1296 |
||
1297 |
xOfFigureLevel:aLevel |
|
1298 |
"origin x where to draw the icon |
|
1299 |
" |
|
1300 |
|l "{ Class:SmallInteger }"| |
|
1301 |
||
1302 |
l := showRoot ifTrue:[aLevel] ifFalse:[aLevel - 1]. |
|
1303 |
||
1304 |
indicatorAction isNil ifTrue:[ |
|
1305 |
l := l - 1 |
|
1306 |
] ifFalse:[ |
|
1307 |
showLeftIndicators ifFalse:[ |
|
1308 |
l := l - 1 |
|
1309 |
] |
|
1310 |
]. |
|
1311 |
^ (l * (imageInset + imageWidth)) + imageInset - (viewOrigin x) |
|
1312 |
! |
|
1313 |
||
1757 | 1314 |
xOfStringLevel:aLevel |
1315 |
"origin x where to draw the text( label ) |
|
1316 |
" |
|
1317 |
alignTextRight ifTrue:[ |
|
1318 |
^ alignTextRightX - (viewOrigin x) |
|
1319 |
]. |
|
1320 |
^ (self xOfFigureLevel:aLevel) + imageWidth + textStartLeft |
|
1756 | 1321 |
|
1554 | 1322 |
! |
1323 |
||
1324 |
xVisibleOfItem:anItem |
|
1325 |
"returns the visible x of the labeled text |
|
1326 |
" |
|
1327 |
^ self xOfStringLevel:(anItem level) |
|
1328 |
||
1390 | 1329 |
! ! |
1330 |
||
2224 | 1331 |
!HierarchicalListView methodsFor:'scrolling'! |
1332 |
||
1333 |
computeViewOriginXat:aLnrNr |
|
1334 |
"compute the visible viewOrigin x for the item at a line |
|
1335 |
" |
|
1336 |
|item xLft xRgt xOrg level viewOriginX offset| |
|
1337 |
||
1338 |
aLnrNr == 1 ifTrue:[^ 0]. |
|
1339 |
||
1340 |
viewOriginX := viewOrigin x. |
|
1341 |
alignTextRight ifTrue:[ ^ viewOriginX ]. |
|
1342 |
||
1343 |
item := list at:aLnrNr ifAbsent:nil. |
|
1344 |
item ifNil:[ ^ viewOriginX ]. |
|
1345 |
||
1346 |
level := item level. |
|
1347 |
level <= 2 ifTrue:[^ 0 ]. |
|
1348 |
||
1349 |
xLft := self xOfFigureLevel:(level - 1). |
|
1350 |
offset := imageInset + imageWidth. |
|
1351 |
||
1352 |
xLft > (offset + margin) ifFalse:[ |
|
1353 |
xLft >= margin ifTrue:[ ^ viewOriginX ]. |
|
1354 |
^ (xLft + viewOriginX) max:0 |
|
1355 |
]. |
|
1356 |
"/ x - left is visible |
|
1357 |
||
1358 |
xRgt := (self xOfStringLevel:level) + (item widthOn:self). |
|
1359 |
||
1360 |
xRgt < width ifTrue:[ |
|
1361 |
"/ x - right and left is visible |
|
1362 |
^ viewOriginX |
|
1363 |
]. |
|
1364 |
xOrg := xLft + viewOriginX. |
|
1365 |
||
1366 |
[ (xLft := xLft - offset) >= margin |
|
1367 |
and:[(xRgt := xRgt - offset) > width] |
|
1368 |
] whileTrue:[ |
|
1369 |
xOrg := xOrg + offset |
|
1370 |
]. |
|
1371 |
^ xOrg |
|
1372 |
! |
|
1373 |
||
1374 |
makeLineVisible:aLnrNr |
|
1375 |
"scroll to make the selection line visible |
|
1376 |
" |
|
1377 |
|newY item y0 newX| |
|
1378 |
||
1379 |
(shown and:[aLnrNr notNil]) ifFalse:[^ self]. |
|
1380 |
||
1381 |
aLnrNr <= 1 ifTrue:[ |
|
1382 |
aLnrNr == 1 ifTrue:[ self scrollTo:(0 @ 0) ]. |
|
1383 |
^ self |
|
1384 |
]. |
|
1385 |
||
1386 |
item := list at:aLnrNr ifAbsent:nil. |
|
1387 |
item ifNil:[^ self]. |
|
1388 |
||
1389 |
y0 := self yVisibleOfLine:aLnrNr. |
|
1390 |
||
1391 |
( y0 < margin |
|
1392 |
or:[(y0 + (item heightOn:self)) > (height - margin)] |
|
1393 |
) ifTrue:[ |
|
1394 |
newY := ((self yAbsoluteOfLine:aLnrNr) - (height // 2)) max:0. |
|
1395 |
] ifFalse:[ |
|
1396 |
newY := viewOrigin y. |
|
1397 |
]. |
|
1398 |
||
1399 |
newX := viewOrigin x. |
|
1400 |
||
1401 |
(autoScrollHorizontal or:[newX ~~ 0]) ifTrue:[ |
|
1402 |
newX := self computeViewOriginXat:aLnrNr |
|
1403 |
]. |
|
1404 |
self scrollTo:(newX @ newY). |
|
1405 |
! |
|
1406 |
||
1407 |
makeSelectionVisible |
|
1408 |
"scroll to make the selection line visible |
|
1409 |
" |
|
1410 |
shown ifTrue:[ |
|
1411 |
self makeLineVisible:(self firstInSelection). |
|
1412 |
]. |
|
1413 |
! ! |
|
1414 |
||
1390 | 1415 |
!HierarchicalListView class methodsFor:'documentation'! |
1416 |
||
1417 |
version |
|
2227 | 1418 |
^ '$Header: /cvs/stx/stx/libwidg2/HierarchicalListView.st,v 1.49 2002-09-27 12:16:14 penk Exp $' |
1390 | 1419 |
! ! |