author | Claus Gittinger <cg@exept.de> |
Wed, 06 Sep 2000 14:41:59 +0200 | |
changeset 1831 | 8efa00e1247a |
parent 1818 | fe99c5c721e9 |
child 1843 | 61595a6b2e37 |
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 |
||
1794 | 14 |
"{ Package: 'stx:libwidg2' }" |
15 |
||
1390 | 16 |
Object subclass:#HierarchicalItem |
1606 | 17 |
instanceVariableNames:'parent children isExpanded height width' |
1390 | 18 |
classVariableNames:'' |
19 |
poolDictionaries:'' |
|
1430 | 20 |
category:'Views-Support' |
1390 | 21 |
! |
22 |
||
23 |
HierarchicalItem subclass:#Example |
|
24 |
instanceVariableNames:'label icon' |
|
25 |
classVariableNames:'PenguinIcon' |
|
26 |
poolDictionaries:'' |
|
27 |
privateIn:HierarchicalItem |
|
28 |
! |
|
29 |
||
30 |
!HierarchicalItem class methodsFor:'documentation'! |
|
31 |
||
1431 | 32 |
copyright |
33 |
" |
|
34 |
COPYRIGHT (c) 1999 by eXept Software AG |
|
35 |
All Rights Reserved |
|
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 |
||
1390 | 47 |
documentation |
48 |
" |
|
49 |
Hierarchical Items are mostly like Models, but the list of |
|
50 |
dependencies are kept by its HierarchicalList. |
|
51 |
The class is used to build up hierarchical trees. |
|
52 |
||
53 |
[Instance variables:] |
|
54 |
parent <Item, List or nil> parent or my HierarchicalList. |
|
55 |
children <Collection or nil> list of children |
|
56 |
isExpanded <Boolean> indicates whether the item is |
|
57 |
expanded or collapsed |
|
58 |
||
59 |
[author:] |
|
60 |
Claus Atzkern |
|
61 |
||
62 |
[see also:] |
|
63 |
HierarchicalList |
|
64 |
HierarchicalListView |
|
65 |
" |
|
66 |
||
67 |
||
68 |
! ! |
|
69 |
||
70 |
!HierarchicalItem class methodsFor:'instance creation'! |
|
71 |
||
72 |
new |
|
73 |
^ (self basicNew) initialize |
|
74 |
! ! |
|
75 |
||
76 |
!HierarchicalItem methodsFor:'accessing'! |
|
77 |
||
78 |
level |
|
79 |
"returns the level starting with 1 |
|
80 |
" |
|
81 |
|parent |
|
82 |
level "{ Class:SmallInteger }" |
|
83 |
| |
|
84 |
level := 0. |
|
85 |
parent := self. |
|
86 |
||
87 |
[(parent := parent parentOrModel) notNil] whileTrue:[ |
|
88 |
level := level + 1 |
|
89 |
]. |
|
90 |
^ level |
|
91 |
||
92 |
! |
|
93 |
||
94 |
parent |
|
95 |
"returns the parent or nil |
|
96 |
" |
|
97 |
^ (parent notNil and:[parent isHierarchicalItem]) ifTrue:[parent] |
|
98 |
ifFalse:[nil] |
|
99 |
! |
|
100 |
||
101 |
parent:aParent |
|
102 |
"set the parent (or the model if the item is the root item) |
|
103 |
" |
|
104 |
parent := aParent |
|
105 |
||
106 |
! ! |
|
107 |
||
1818 | 108 |
!HierarchicalItem methodsFor:'accessing-children'! |
1390 | 109 |
|
110 |
at:anIndex |
|
111 |
"returns the child under an index or nil |
|
112 |
" |
|
113 |
^ self children notNil ifTrue:[children at:anIndex ifAbsent:nil] |
|
114 |
ifFalse:[nil] |
|
115 |
! |
|
116 |
||
117 |
at:anIndex put:anItem |
|
118 |
"replace a child by a new item |
|
119 |
" |
|
120 |
|oldItem itemExpanded size| |
|
121 |
||
122 |
size := self children size. |
|
123 |
||
124 |
(anIndex between:1 and:size) ifFalse:[ |
|
125 |
^ self subscriptBoundsError |
|
126 |
]. |
|
127 |
||
128 |
anItem isNil ifTrue:[ |
|
129 |
^ self removeFromIndex:anIndex toIndex:anIndex. |
|
130 |
]. |
|
1733 | 131 |
self criticalDo:[ |
132 |
oldItem := children at:anIndex. |
|
133 |
oldItem collapse. |
|
134 |
itemExpanded := anItem isExpanded. |
|
135 |
anItem setExpanded:false. |
|
136 |
children at:anIndex put:anItem. |
|
137 |
self changed. |
|
1390 | 138 |
|
1733 | 139 |
itemExpanded ifTrue:[ |
140 |
anItem expand |
|
141 |
] |
|
1390 | 142 |
]. |
143 |
! |
|
144 |
||
145 |
children:aListOfChildren |
|
146 |
"set a new list of children |
|
147 |
" |
|
1733 | 148 |
self criticalDo:[ |
149 |
self removeAll. |
|
150 |
self addAll:aListOfChildren beforeIndex:1 |
|
151 |
]. |
|
152 |
^ aListOfChildren |
|
1390 | 153 |
! |
154 |
||
155 |
first |
|
156 |
"returns the first child |
|
157 |
" |
|
158 |
^ self at:1 |
|
159 |
! |
|
160 |
||
161 |
last |
|
162 |
"returns the last child |
|
163 |
" |
|
164 |
^ self at:(self children size) |
|
165 |
! ! |
|
166 |
||
1818 | 167 |
!HierarchicalItem methodsFor:'accessing-hierarchy'! |
1390 | 168 |
|
169 |
collapse |
|
170 |
"hide children |
|
171 |
" |
|
172 |
|visChd model index| |
|
173 |
||
174 |
self canCollapse ifTrue:[ |
|
175 |
isExpanded := false. |
|
176 |
||
1733 | 177 |
self criticalDo:[ |
178 |
(index := self listIndex) notNil ifTrue:[ |
|
179 |
(visChd := children size) ~~ 0 ifTrue:[ |
|
180 |
children do:[:aChild| |
|
181 |
visChd := visChd + aChild numberOfVisibleChildren |
|
182 |
]. |
|
183 |
self model itemRemoveFromIndex:(index + 1) toIndex:(index + visChd). |
|
184 |
index ~~ 0 ifTrue:[self hierarchyChanged] |
|
1390 | 185 |
] |
186 |
] |
|
187 |
] |
|
188 |
] |
|
189 |
! |
|
190 |
||
191 |
expand |
|
192 |
"expand children |
|
193 |
" |
|
194 |
|index list| |
|
195 |
||
196 |
self canExpand ifTrue:[ |
|
197 |
isExpanded := true. |
|
198 |
||
1733 | 199 |
self criticalDo:[ |
200 |
(index := self listIndex) notNil ifTrue:[ |
|
201 |
(children notNil or:[self children notNil]) ifTrue:[ |
|
202 |
children notEmpty ifTrue:[ |
|
203 |
list := OrderedCollection new:64. |
|
204 |
self addVisibleChildrenTo:list. |
|
205 |
self model itemAddAll:list beforeIndex:(index + 1). |
|
206 |
||
207 |
index ~~ 0 ifTrue:[self hierarchyChanged] |
|
208 |
] |
|
1390 | 209 |
] |
210 |
] |
|
211 |
] |
|
212 |
] |
|
213 |
||
214 |
! |
|
215 |
||
1409 | 216 |
makeVisible |
217 |
"expand all my parents |
|
218 |
" |
|
219 |
(parent notNil and:[parent isHierarchicalItem]) ifTrue:[ |
|
1733 | 220 |
self criticalDo:[ |
221 |
parent expand. |
|
222 |
parent makeVisible |
|
223 |
] |
|
1409 | 224 |
]. |
225 |
! |
|
226 |
||
1390 | 227 |
recursiveCollapse |
228 |
"collapse children and sub-children |
|
229 |
**** must be expanded |
|
230 |
" |
|
231 |
|visChd index| |
|
232 |
||
233 |
self canCollapse ifTrue:[ |
|
1733 | 234 |
self criticalDo:[ |
235 |
(index := self listIndex) notNil ifTrue:[ |
|
236 |
(visChd := children size) ~~ 0 ifTrue:[ |
|
237 |
children do:[:aChild| |
|
238 |
visChd := visChd + aChild numberOfVisibleChildren |
|
239 |
] |
|
240 |
]. |
|
241 |
self recursiveSetCollapsed. |
|
1390 | 242 |
|
1733 | 243 |
visChd ~~ 0 ifTrue:[ |
244 |
self model itemRemoveFromIndex:(index + 1) |
|
245 |
toIndex:(index + visChd) |
|
246 |
]. |
|
247 |
index ~~ 0 ifTrue:[ |
|
248 |
self hierarchyChanged |
|
249 |
] |
|
250 |
] ifFalse:[ |
|
251 |
self recursiveSetCollapsed |
|
1390 | 252 |
] |
253 |
] |
|
254 |
] |
|
255 |
||
256 |
! |
|
257 |
||
258 |
recursiveExpand |
|
259 |
"expand children and sub-children |
|
260 |
**** must be collapsed |
|
261 |
" |
|
262 |
|model index list| |
|
263 |
||
264 |
self canExpand ifTrue:[ |
|
265 |
isExpanded := true. |
|
266 |
||
1733 | 267 |
self criticalDo:[ |
268 |
self children size ~~ 0 ifTrue:[ |
|
269 |
(index := self listIndex) isNil ifTrue:[ |
|
270 |
children do:[:aChild| aChild setExpanded:true ] |
|
271 |
] ifFalse:[ |
|
272 |
list := OrderedCollection new:512. |
|
273 |
self recursiveSetExpandedAndAddToList:list. |
|
274 |
self model itemAddAll:list beforeIndex:(index + 1). |
|
1390 | 275 |
|
1733 | 276 |
index ~~ 0 ifTrue:[self hierarchyChanged] |
1390 | 277 |
] |
278 |
] |
|
279 |
] |
|
280 |
] |
|
281 |
! |
|
282 |
||
283 |
recursiveToggleExpand |
|
284 |
"if the item is collapsed, the children and all sub-children |
|
285 |
are expanded otherwise collapsed |
|
286 |
" |
|
1598
33202082065d
care for uninitialized isExpanded
Claus Gittinger <cg@exept.de>
parents:
1571
diff
changeset
|
287 |
(isExpanded == true) ifTrue:[ |
33202082065d
care for uninitialized isExpanded
Claus Gittinger <cg@exept.de>
parents:
1571
diff
changeset
|
288 |
self recursiveCollapse |
33202082065d
care for uninitialized isExpanded
Claus Gittinger <cg@exept.de>
parents:
1571
diff
changeset
|
289 |
] ifFalse:[ |
33202082065d
care for uninitialized isExpanded
Claus Gittinger <cg@exept.de>
parents:
1571
diff
changeset
|
290 |
self recursiveExpand |
33202082065d
care for uninitialized isExpanded
Claus Gittinger <cg@exept.de>
parents:
1571
diff
changeset
|
291 |
] |
1390 | 292 |
|
293 |
! |
|
294 |
||
295 |
toggleExpand |
|
296 |
"if the item is collapsed, the children are expanded |
|
297 |
otherwise collapsed |
|
298 |
" |
|
1733 | 299 |
self criticalDo:[ |
300 |
(isExpanded == true) ifTrue:[ |
|
301 |
self collapse |
|
302 |
] ifFalse:[ |
|
303 |
self expand |
|
304 |
] |
|
1598
33202082065d
care for uninitialized isExpanded
Claus Gittinger <cg@exept.de>
parents:
1571
diff
changeset
|
305 |
] |
1390 | 306 |
|
307 |
! ! |
|
308 |
||
1818 | 309 |
!HierarchicalItem methodsFor:'accessing-mvc'! |
1390 | 310 |
|
311 |
application |
|
312 |
"returns the responsible application or nil |
|
313 |
" |
|
314 |
|model| |
|
315 |
||
316 |
(model := self model) notNil ifTrue:[ |
|
317 |
^ model application |
|
318 |
]. |
|
319 |
^ nil |
|
320 |
! |
|
321 |
||
322 |
applicationsDo:aOneArgBlock |
|
323 |
"evaluate the block on each dependent application |
|
324 |
" |
|
325 |
|model| |
|
326 |
||
327 |
(model := self model) notNil ifTrue:[ |
|
328 |
model applicationsDo:aOneArgBlock |
|
329 |
] |
|
330 |
||
331 |
! |
|
332 |
||
333 |
model |
|
334 |
"returns the hierachicalList model or nil |
|
335 |
" |
|
336 |
|p model| |
|
337 |
||
338 |
model := self. |
|
339 |
[(p := model parentOrModel) notNil] whileTrue:[model := p]. |
|
340 |
^ model isHierarchicalItem ifFalse:[model] ifTrue:[nil] |
|
341 |
! ! |
|
342 |
||
343 |
!HierarchicalItem methodsFor:'adding & removing'! |
|
344 |
||
345 |
add:aChildItem |
|
346 |
"add a child at end |
|
347 |
" |
|
348 |
^ self add:aChildItem beforeIndex:(self children size + 1). |
|
349 |
! |
|
350 |
||
351 |
add:aChildItem after:aChild |
|
352 |
"add an item after an existing item |
|
353 |
" |
|
354 |
|index| |
|
355 |
||
1539 | 356 |
(index := self identityIndexOf:aChild) ~~ 0 ifTrue:[ |
1390 | 357 |
self subscriptBoundsError |
358 |
] ifFalse:[ |
|
359 |
self add:aChildItem beforeIndex:(index + 1) |
|
360 |
]. |
|
361 |
^ aChildItem |
|
362 |
! |
|
363 |
||
364 |
add:aChildItem afterIndex:anIndex |
|
365 |
"add an item after an index |
|
366 |
" |
|
367 |
^ self add:aChildItem beforeIndex:(anIndex + 1). |
|
368 |
! |
|
369 |
||
370 |
add:aChildItem before:aChild |
|
371 |
"add an item before an existing item |
|
372 |
" |
|
373 |
|index| |
|
374 |
||
375 |
(index := self identityIndexOf:aChild) ~~ 0 ifTrue:[ |
|
376 |
^ self add:aChildItem beforeIndex:index |
|
377 |
]. |
|
378 |
self subscriptBoundsError |
|
379 |
! |
|
380 |
||
381 |
add:aChildItem beforeIndex:anIndex |
|
382 |
"add an item before an index |
|
383 |
" |
|
384 |
aChildItem notNil ifTrue:[ |
|
385 |
self addAll:(Array with:aChildItem) beforeIndex:anIndex |
|
386 |
]. |
|
387 |
^ aChildItem |
|
388 |
! |
|
389 |
||
1488 | 390 |
add:aChild sortBlock:aBlock |
391 |
"add a child sorted |
|
392 |
" |
|
1733 | 393 |
self criticalDo:[ |
394 |
self basicAdd:aChild sortBlock:aBlock |
|
1488 | 395 |
]. |
1733 | 396 |
^ aChild |
1488 | 397 |
! |
398 |
||
1390 | 399 |
addAll:aList |
400 |
"add children at the end |
|
401 |
" |
|
402 |
^ self addAll:aList beforeIndex:(self children size + 1) |
|
403 |
! |
|
404 |
||
1650 | 405 |
addAll:aList before:aChild |
406 |
"add an item before an existing item |
|
407 |
" |
|
408 |
|index| |
|
409 |
||
410 |
(index := self identityIndexOf:aChild) ~~ 0 ifTrue:[ |
|
411 |
^ self addAll:aList beforeIndex:index |
|
412 |
]. |
|
413 |
self subscriptBoundsError |
|
414 |
! |
|
415 |
||
1390 | 416 |
addAll:aList beforeIndex:anIndex |
417 |
"add children before an index |
|
418 |
" |
|
1733 | 419 |
aList size ~~ 0 ifTrue:[ |
420 |
self criticalDo:[ |
|
421 |
self basicAddAll:aList beforeIndex:anIndex |
|
422 |
] |
|
423 |
]. |
|
424 |
^ aList |
|
425 |
! |
|
426 |
||
427 |
addAll:aList sortBlock:aBlock |
|
428 |
"add children sorted |
|
429 |
" |
|
430 |
aList size ~~ 0 ifTrue:[ |
|
431 |
aBlock isNil ifTrue:[ |
|
432 |
self addAll:aList |
|
433 |
] ifFalse:[ |
|
434 |
self criticalDo:[ |
|
435 |
aList do:[:el|self add:el sortBlock:aBlock] |
|
436 |
] |
|
437 |
] |
|
438 |
]. |
|
439 |
^ aList |
|
440 |
! |
|
441 |
||
442 |
addAllFirst:aCollectionOfItems |
|
443 |
"add children at the beginning |
|
444 |
" |
|
445 |
^ self addAll:aCollectionOfItems beforeIndex:1 |
|
446 |
! |
|
447 |
||
448 |
addAllLast:aCollectionOfItems |
|
449 |
"add children at the end |
|
450 |
" |
|
451 |
^ self addAll:aCollectionOfItems |
|
452 |
! |
|
453 |
||
454 |
addFirst:aChildItem |
|
455 |
"add a child at begin |
|
456 |
" |
|
457 |
^ self add:aChildItem beforeIndex:1. |
|
458 |
||
459 |
! |
|
460 |
||
461 |
addLast:anItem |
|
462 |
"add a child at end |
|
463 |
" |
|
464 |
^ self add:anItem |
|
465 |
! |
|
466 |
||
1804 | 467 |
remove |
468 |
"remove the item |
|
469 |
" |
|
470 |
parent notNil ifTrue:[ "check whether parent exists" |
|
471 |
parent isHierarchicalItem ifTrue:[parent remove:self] "parent is HierarchicalItem" |
|
472 |
ifFalse:[parent root:nil] "parent is HierarchicalList" |
|
473 |
]. |
|
474 |
^ self |
|
475 |
! |
|
476 |
||
1733 | 477 |
remove:aChild |
478 |
"remove a child |
|
479 |
" |
|
480 |
self removeIndex:(self identityIndexOf:aChild) |
|
481 |
||
482 |
! |
|
483 |
||
484 |
removeAll |
|
485 |
"remove all children |
|
486 |
" |
|
487 |
|size| |
|
488 |
||
489 |
(size := self children size) ~~ 0 ifTrue:[ |
|
490 |
self removeFromIndex:1 toIndex:size |
|
491 |
] |
|
492 |
! |
|
493 |
||
494 |
removeAll:aList |
|
495 |
"remove all children in the collection |
|
496 |
" |
|
497 |
|index| |
|
498 |
||
499 |
aList size ~~ 0 ifTrue:[ |
|
500 |
self criticalDo:[ |
|
501 |
aList do:[:el| |
|
502 |
(index := self identityIndexOf:el) ~~ 0 ifTrue:[ |
|
503 |
self removeIndex:index |
|
504 |
] |
|
505 |
] |
|
506 |
] |
|
507 |
]. |
|
508 |
^ aList |
|
509 |
! |
|
510 |
||
511 |
removeFromIndex:startIndex toIndex:stopIndex |
|
512 |
"remove the children from startIndex up to and including |
|
513 |
the child under stopIndex. |
|
514 |
" |
|
515 |
self criticalDo:[ |
|
516 |
self basicRemoveFromIndex:startIndex toIndex:stopIndex |
|
517 |
]. |
|
518 |
! |
|
519 |
||
520 |
removeIndex:anIndex |
|
521 |
"remove the child at an index |
|
522 |
" |
|
523 |
anIndex > 0 ifTrue:[ |
|
524 |
self removeFromIndex:anIndex toIndex:anIndex |
|
525 |
] |
|
526 |
! ! |
|
527 |
||
528 |
!HierarchicalItem methodsFor:'basic adding & removing'! |
|
529 |
||
530 |
basicAdd:aChild sortBlock:aBlock |
|
531 |
"add a child sorted |
|
532 |
" |
|
533 |
(aBlock notNil and:[children size ~~ 0]) ifTrue:[ |
|
534 |
self criticalDo:[ |
|
535 |
children keysAndValuesDo:[:index :child| |
|
536 |
(aBlock value:aChild value:child) ifTrue:[ |
|
537 |
^ self add:aChild beforeIndex:index |
|
538 |
] |
|
539 |
] |
|
540 |
] |
|
541 |
]. |
|
542 |
^ self add:aChild. |
|
543 |
! |
|
544 |
||
545 |
basicAddAll:aList beforeIndex:anIndex |
|
546 |
"add children before an index |
|
547 |
" |
|
1602 | 548 |
|coll model notify index size| |
1390 | 549 |
|
550 |
size := self children size. |
|
551 |
||
552 |
anIndex == 1 ifTrue:[ |
|
553 |
notify := self |
|
554 |
] ifFalse:[ |
|
555 |
anIndex > size ifTrue:[ |
|
556 |
anIndex > (1 + size) ifTrue:[ |
|
557 |
^ self subscriptBoundsError |
|
558 |
]. |
|
559 |
notify := self at:size |
|
560 |
] ifFalse:[ |
|
561 |
notify := nil |
|
562 |
] |
|
563 |
]. |
|
1669 | 564 |
children isArray ifTrue:[ |
565 |
children := children asOrderedCollection |
|
566 |
]. |
|
1390 | 567 |
|
568 |
size == 0 ifTrue:[ |
|
569 |
children := OrderedCollection new |
|
570 |
]. |
|
571 |
aList do:[:anItem| anItem parent:self ]. |
|
572 |
children addAll:aList beforeIndex:anIndex. |
|
573 |
||
574 |
(model := self model) isNil ifTrue:[ |
|
575 |
^ aList |
|
576 |
]. |
|
577 |
||
1598
33202082065d
care for uninitialized isExpanded
Claus Gittinger <cg@exept.de>
parents:
1571
diff
changeset
|
578 |
(isExpanded == true) ifFalse:[ |
1390 | 579 |
notify notNil ifTrue:[ |
580 |
notify changed |
|
581 |
]. |
|
582 |
^ aList |
|
583 |
]. |
|
584 |
(index := self listIndex) isNil ifTrue:[ |
|
585 |
^ aList |
|
586 |
]. |
|
587 |
||
588 |
children from:1 to:(anIndex - 1) do:[:anItem| |
|
589 |
index := 1 + index + anItem numberOfVisibleChildren |
|
590 |
]. |
|
591 |
coll := OrderedCollection new. |
|
592 |
||
593 |
aList do:[:anItem| |
|
594 |
coll add:anItem. |
|
595 |
anItem addVisibleChildrenTo:coll. |
|
596 |
]. |
|
597 |
model itemAddAll:coll beforeIndex:(index + 1). |
|
598 |
||
599 |
notify notNil ifTrue:[ |
|
600 |
notify changed |
|
601 |
]. |
|
602 |
^ aList |
|
603 |
! |
|
604 |
||
1733 | 605 |
basicRemoveFromIndex:startIndex toIndex:stopIndex |
1390 | 606 |
"remove the children from startIndex up to and including |
607 |
the child under stopIndex. |
|
608 |
" |
|
609 |
|model notify |
|
610 |
index "{ Class:SmallInteger }" |
|
611 |
start "{ Class:SmallInteger }" |
|
612 |
stop "{ Class:SmallInteger }" |
|
613 |
size "{ Class:SmallInteger }" |
|
614 |
| |
|
615 |
size := self children size. |
|
616 |
stop := stopIndex. |
|
617 |
start := startIndex. |
|
618 |
||
619 |
(stop <= size and:[start between:1 and:stop]) ifFalse:[ |
|
620 |
^ self subscriptBoundsError |
|
621 |
]. |
|
622 |
start == 1 ifTrue:[ |
|
623 |
notify := self |
|
624 |
] ifFalse:[ |
|
625 |
stop == size ifTrue:[ |
|
626 |
notify := self at:(start - 1) |
|
627 |
] ifFalse:[ |
|
628 |
notify := nil |
|
629 |
] |
|
630 |
]. |
|
631 |
||
632 |
(model := self model) notNil ifTrue:[ |
|
633 |
index := model identityIndexOf:(children at:start). |
|
634 |
size := stop - start + 1. |
|
635 |
] ifFalse:[ |
|
636 |
index := 0 |
|
637 |
]. |
|
1669 | 638 |
|
1390 | 639 |
children from:start to:stop do:[:aChild| |
640 |
index ~~ 0 ifTrue:[ |
|
641 |
size := size + aChild numberOfVisibleChildren |
|
642 |
]. |
|
643 |
aChild parent:nil |
|
644 |
]. |
|
645 |
children removeFromIndex:start toIndex:stop. |
|
646 |
||
647 |
index ~~ 0 ifTrue:[ |
|
648 |
model itemRemoveFromIndex:index toIndex:(index + size - 1) |
|
649 |
]. |
|
650 |
notify notNil ifTrue:[ |
|
651 |
notify changed |
|
652 |
]. |
|
653 |
! ! |
|
654 |
||
655 |
!HierarchicalItem methodsFor:'change & update'! |
|
656 |
||
657 |
changed |
|
658 |
"the item changed; raise change notification |
|
659 |
" |
|
660 |
self changed:nil with:nil |
|
661 |
! |
|
662 |
||
663 |
changed:aParameter |
|
664 |
"the item changed; raise change notification |
|
665 |
" |
|
666 |
self changed:aParameter with:nil |
|
667 |
||
668 |
! |
|
669 |
||
1606 | 670 |
changed:what with:anArgument |
1390 | 671 |
"the item changed; raise change notification |
672 |
" |
|
673 |
|model| |
|
674 |
||
1606 | 675 |
(what ~~ #hierarchy and:[what ~~ #icon]) ifTrue:[ |
1831
8efa00e1247a
sort stuff; height fix when label changes
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
676 |
width := height := nil |
1606 | 677 |
]. |
1390 | 678 |
|
1606 | 679 |
(model := self model) notNil ifTrue:[ |
680 |
model itemChanged:what with:anArgument from:self |
|
1390 | 681 |
]. |
1606 | 682 |
super changed:what with:anArgument |
1390 | 683 |
! |
684 |
||
685 |
hierarchyChanged |
|
686 |
"hierarchy changed; optimize redrawing |
|
687 |
" |
|
688 |
self changed:#hierarchy with:nil |
|
689 |
! |
|
690 |
||
691 |
iconChanged |
|
692 |
"icon changed; optimize redrawing |
|
693 |
" |
|
694 |
self changed:#icon with:nil |
|
695 |
! ! |
|
696 |
||
697 |
!HierarchicalItem methodsFor:'enumerating'! |
|
698 |
||
1804 | 699 |
collect:aBlock |
700 |
"for each child in the receiver, evaluate the argument, aBlock |
|
701 |
and return a new collection with the results |
|
702 |
" |
|
703 |
|newCollection| |
|
704 |
||
705 |
self children size == 0 ifTrue:[ |
|
706 |
^ #() |
|
707 |
]. |
|
708 |
||
709 |
self criticalDo:[ |
|
710 |
newCollection := OrderedCollection new. |
|
711 |
children do:[:aChild| newCollection add:(aBlock value:aChild) ] |
|
712 |
]. |
|
713 |
^ newCollection |
|
714 |
! |
|
715 |
||
1390 | 716 |
do:aOneArgBlock |
717 |
"evaluate a block on each child |
|
718 |
" |
|
1733 | 719 |
self from:1 do:aOneArgBlock |
1390 | 720 |
! |
721 |
||
722 |
from:startIndex do:aOneArgBlock |
|
723 |
"evaluate a block on each child starting with the |
|
724 |
child at startIndex to the end. |
|
725 |
" |
|
726 |
self from:startIndex to:self size do:aOneArgBlock |
|
727 |
! |
|
728 |
||
729 |
from:startIndex to:endIndex do:aOneArgBlock |
|
730 |
"evaluate a block on each child starting with the |
|
731 |
child at startIndex to the endIndex. |
|
732 |
" |
|
1831
8efa00e1247a
sort stuff; height fix when label changes
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
733 |
|children| |
8efa00e1247a
sort stuff; height fix when label changes
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
734 |
|
8efa00e1247a
sort stuff; height fix when label changes
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
735 |
children := self children. |
8efa00e1247a
sort stuff; height fix when label changes
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
736 |
|
8efa00e1247a
sort stuff; height fix when label changes
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
737 |
children size ~~ 0 ifTrue:[ |
1733 | 738 |
self criticalDo:[ |
739 |
children from:startIndex to:endIndex do:aOneArgBlock |
|
740 |
] |
|
1390 | 741 |
] |
742 |
! |
|
743 |
||
744 |
from:startIndex to:endIndex reverseDo:aOneArgBlock |
|
745 |
"evaluate a block on each child starting with the |
|
746 |
child at endIndex to the startIndex. |
|
747 |
" |
|
1831
8efa00e1247a
sort stuff; height fix when label changes
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
748 |
|children| |
8efa00e1247a
sort stuff; height fix when label changes
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
749 |
|
8efa00e1247a
sort stuff; height fix when label changes
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
750 |
children := self children. |
8efa00e1247a
sort stuff; height fix when label changes
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
751 |
|
8efa00e1247a
sort stuff; height fix when label changes
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
752 |
children size ~~ 0 ifTrue:[ |
1733 | 753 |
self criticalDo:[ |
754 |
children from:startIndex to:endIndex reverseDo:aOneArgBlock |
|
755 |
] |
|
1390 | 756 |
] |
757 |
! |
|
758 |
||
1804 | 759 |
recursiveCollect:aBlock |
760 |
"for each child in the receiver, evaluate the argument, aBlock |
|
761 |
and return a new collection with the results |
|
762 |
" |
|
763 |
|newCollection| |
|
764 |
||
765 |
self children size == 0 ifTrue:[ |
|
766 |
^ #() |
|
767 |
]. |
|
768 |
newCollection := OrderedCollection new. |
|
769 |
||
770 |
self recursiveDo:[:aChild| |
|
771 |
newCollection add:(aBlock value:aChild) |
|
772 |
]. |
|
773 |
^ newCollection |
|
774 |
! |
|
775 |
||
1390 | 776 |
recursiveDo:aOneArgBlock |
777 |
"evaluate a block on each item and all the sub-items |
|
778 |
" |
|
779 |
self do:[:aChild| |
|
780 |
aOneArgBlock value:aChild. |
|
781 |
aChild recursiveDo:aOneArgBlock |
|
782 |
]. |
|
783 |
||
784 |
! |
|
785 |
||
1804 | 786 |
recursiveReverseDo:aOneArgBlock |
787 |
"evaluate a block on each item and all the sub-items; |
|
788 |
proccesing children in reverse direction |
|
789 |
" |
|
1831
8efa00e1247a
sort stuff; height fix when label changes
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
790 |
|children| |
8efa00e1247a
sort stuff; height fix when label changes
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
791 |
|
8efa00e1247a
sort stuff; height fix when label changes
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
792 |
children := self children. |
8efa00e1247a
sort stuff; height fix when label changes
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
793 |
|
8efa00e1247a
sort stuff; height fix when label changes
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
794 |
children size ~~ 0 ifTrue:[ |
1804 | 795 |
self criticalDo:[ |
796 |
children reverseDo:[:aChild| |
|
797 |
aChild reverseRecursiveDo:aOneArgBlock. |
|
798 |
aOneArgBlock value:aChild. |
|
799 |
] |
|
800 |
] |
|
801 |
]. |
|
802 |
! |
|
803 |
||
804 |
recursiveSelect:aBlock |
|
805 |
"return a new collection with all children and subChildren from the receiver, for which |
|
806 |
the argument aBlock evaluates to true. |
|
807 |
" |
|
808 |
|newCollection| |
|
809 |
||
810 |
self children size == 0 ifTrue:[ |
|
811 |
^ #() |
|
812 |
]. |
|
813 |
newCollection := OrderedCollection new. |
|
814 |
||
815 |
self recursiveDo:[:aChild| |
|
816 |
(aBlock value:aChild) ifTrue:[newCollection add:aChild] |
|
817 |
]. |
|
818 |
^ newCollection |
|
819 |
! |
|
820 |
||
1390 | 821 |
reverseDo:aOneArgBlock |
822 |
"evaluate a block on each child |
|
1804 | 823 |
proccesing children in reverse direction |
1390 | 824 |
" |
1831
8efa00e1247a
sort stuff; height fix when label changes
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
825 |
|children| |
8efa00e1247a
sort stuff; height fix when label changes
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
826 |
|
8efa00e1247a
sort stuff; height fix when label changes
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
827 |
children := self children. |
8efa00e1247a
sort stuff; height fix when label changes
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
828 |
|
8efa00e1247a
sort stuff; height fix when label changes
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
829 |
children size ~~ 0 ifTrue:[ |
1733 | 830 |
self criticalDo:[children reverseDo:aOneArgBlock] |
831 |
] |
|
1804 | 832 |
! |
833 |
||
834 |
select:aBlock |
|
835 |
"return a new collection with all children from the receiver, for which |
|
836 |
the argument aBlock evaluates to true. |
|
837 |
" |
|
1831
8efa00e1247a
sort stuff; height fix when label changes
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
838 |
|newCollection children| |
1804 | 839 |
|
1831
8efa00e1247a
sort stuff; height fix when label changes
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
840 |
children := self children. |
8efa00e1247a
sort stuff; height fix when label changes
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
841 |
|
8efa00e1247a
sort stuff; height fix when label changes
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
842 |
children size == 0 ifTrue:[ |
1804 | 843 |
^ #() |
844 |
]. |
|
845 |
||
846 |
self criticalDo:[ |
|
847 |
newCollection := OrderedCollection new. |
|
848 |
||
849 |
children do:[:aChild| |
|
850 |
(aBlock value:aChild) ifTrue:[newCollection add:aChild] |
|
851 |
] |
|
852 |
]. |
|
853 |
^ newCollection |
|
854 |
! ! |
|
855 |
||
856 |
!HierarchicalItem methodsFor:'enumerating parents'! |
|
857 |
||
858 |
parentsDetect:aBlock |
|
859 |
"find the first parent, for which evaluation of the block returns |
|
860 |
true; if none does so, report an error |
|
861 |
" |
|
862 |
^ self parentsDetect:aBlock ifNone:[self errorNotFound] |
|
863 |
! |
|
864 |
||
865 |
parentsDetect:aBlock ifNone:anExceptionBlock |
|
866 |
"find the first parent, for which evaluation of the block returns |
|
867 |
true; if none does so, return the evaluation of anExceptionBlock |
|
868 |
" |
|
869 |
|prnt| |
|
870 |
||
871 |
prnt := self. |
|
872 |
||
873 |
self criticalDo:[ |
|
874 |
[(prnt := prnt parent) notNil and:[prnt isHierarchicalItem]] whileTrue:[ |
|
875 |
(aBlock value:prnt) ifTrue:[^ prnt] |
|
876 |
] |
|
877 |
]. |
|
878 |
^ anExceptionBlock value |
|
879 |
! |
|
880 |
||
881 |
parentsDo:aBlock |
|
882 |
"evaluate a block on each parent |
|
883 |
" |
|
884 |
|prnt| |
|
885 |
||
886 |
prnt := self. |
|
887 |
||
888 |
self criticalDo:[ |
|
889 |
[(prnt := prnt parent) notNil and:[prnt isHierarchicalItem]] whileTrue:[ |
|
890 |
aBlock value:prnt |
|
891 |
] |
|
892 |
]. |
|
1390 | 893 |
! ! |
894 |
||
895 |
!HierarchicalItem methodsFor:'initialization'! |
|
896 |
||
897 |
initialize |
|
898 |
isExpanded := false |
|
899 |
! ! |
|
900 |
||
901 |
!HierarchicalItem methodsFor:'private'! |
|
902 |
||
903 |
addVisibleChildrenTo:aList |
|
904 |
"add all visible children and sub-children to the list |
|
905 |
" |
|
1598
33202082065d
care for uninitialized isExpanded
Claus Gittinger <cg@exept.de>
parents:
1571
diff
changeset
|
906 |
isExpanded == true ifTrue:[ |
1390 | 907 |
(children notNil or:[self children notNil]) ifTrue:[ |
908 |
children do:[:aChild| |
|
909 |
aList add:aChild. |
|
910 |
aChild addVisibleChildrenTo:aList |
|
911 |
] |
|
912 |
] |
|
913 |
] |
|
914 |
||
915 |
||
916 |
||
917 |
||
918 |
||
919 |
! |
|
920 |
||
1733 | 921 |
criticalDo:aBlock |
922 |
|model| |
|
923 |
||
924 |
(model := self model) notNil ifTrue:[ |
|
925 |
model recursionLock critical:aBlock |
|
926 |
] ifFalse:[ |
|
927 |
aBlock value |
|
928 |
] |
|
929 |
! |
|
930 |
||
1390 | 931 |
listIndex |
932 |
"returns the visible index or nil; for a none visible root |
|
933 |
0 is returned |
|
934 |
" |
|
935 |
|index model| |
|
936 |
||
937 |
(model := self model) notNil ifTrue:[ |
|
938 |
index := model identityIndexOf:self. |
|
939 |
||
940 |
(index ~~ 0 or:[parent == model]) ifTrue:[ |
|
941 |
^ index |
|
942 |
] |
|
943 |
]. |
|
944 |
^ nil |
|
945 |
! |
|
946 |
||
947 |
numberOfVisibleChildren |
|
948 |
"returns number of all visible children including subchildren |
|
949 |
" |
|
950 |
|size "{ Class: SmallInteger }" |
|
951 |
| |
|
1598
33202082065d
care for uninitialized isExpanded
Claus Gittinger <cg@exept.de>
parents:
1571
diff
changeset
|
952 |
(isExpanded == true) ifTrue:[ |
1390 | 953 |
(children notNil or:[self children notNil]) ifTrue:[ |
954 |
(size := children size) ~~ 0 ifTrue:[ |
|
1733 | 955 |
self criticalDo:[ |
956 |
children do:[:el| size := size + el numberOfVisibleChildren ]. |
|
957 |
]. |
|
958 |
^ size |
|
1390 | 959 |
] |
960 |
] |
|
961 |
]. |
|
962 |
^ 0 |
|
963 |
||
964 |
||
965 |
||
966 |
||
967 |
! |
|
968 |
||
969 |
parentOrModel |
|
970 |
"returns the parent without checking for item or model |
|
971 |
" |
|
972 |
^ parent |
|
973 |
! |
|
974 |
||
975 |
setExpanded:aBoolean |
|
976 |
"set expanded flag without any computation or notification |
|
977 |
" |
|
978 |
isExpanded := aBoolean |
|
979 |
! ! |
|
980 |
||
1540
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
981 |
!HierarchicalItem methodsFor:'private displaying'! |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
982 |
|
1606 | 983 |
displayLabel:aLabel h:lH on:aGC x:x y:y h:h |
1540
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
984 |
"display the label at x@y |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
985 |
" |
1606 | 986 |
|y0 hF| |
1540
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
987 |
|
1606 | 988 |
lH ~~ 0 ifTrue:[ |
989 |
y0 := y - (lH + 1 - h // 2). |
|
1540
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
990 |
|
1606 | 991 |
aLabel isImageOrForm ifTrue:[ |
992 |
^ aLabel displayOn:aGC x:x y:y0 |
|
993 |
]. |
|
994 |
y0 := y0 + (aGC font ascent). |
|
1540
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
995 |
|
1606 | 996 |
aLabel isString ifFalse:[ |
997 |
^ aLabel displayOn:aGC x:x y:y0 |
|
998 |
]. |
|
1540
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
999 |
|
1606 | 1000 |
(aLabel indexOf:(Character cr)) == 0 ifTrue:[ |
1001 |
^ aLabel displayOn:aGC x:x y:y0 |
|
1002 |
]. |
|
1540
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1003 |
|
1606 | 1004 |
hF := aGC font height. |
1540
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1005 |
|
1606 | 1006 |
aLabel asCollectionOfLines do:[:el| |
1007 |
el displayOn:aGC x:x y:y0. |
|
1008 |
y0 := y0 + hF |
|
1009 |
] |
|
1540
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1010 |
]. |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1011 |
! |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1012 |
|
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1013 |
heightOf:aLabel on:aGC |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1014 |
"returns the height of the label or 0 |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1015 |
" |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1016 |
|h| |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1017 |
|
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1018 |
aLabel isSequenceable ifFalse:[ |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1019 |
^ aLabel notNil ifTrue:[aLabel heightOn:aGC] ifFalse:[0] |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1020 |
]. |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1021 |
|
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1022 |
aLabel isString ifFalse:[ |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1023 |
h := 0. |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1024 |
aLabel do:[:el|h := h max:(self heightOf:el on:aGC)]. |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1025 |
^ h |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1026 |
]. |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1027 |
|
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1028 |
h := 1 + (aLabel occurrencesOf:(Character cr)). |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1029 |
^ h * (aGC font height) |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1030 |
! |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1031 |
|
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1032 |
widthOf:aLabel on:aGC |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1033 |
"returns the height of the label or 0 |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1034 |
" |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1035 |
|w| |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1036 |
|
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1037 |
aLabel isSequenceable ifFalse:[ |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1038 |
^ aLabel notNil ifTrue:[aLabel widthOn:aGC] ifFalse:[0] |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1039 |
]. |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1040 |
|
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1041 |
aLabel isString ifFalse:[ |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1042 |
w := -5. |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1043 |
aLabel do:[:el|w := w + 5 + (self widthOf:el on:aGC)]. |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1044 |
^ w |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1045 |
]. |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1046 |
|
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1047 |
(aLabel indexOf:(Character cr)) == 0 ifTrue:[ |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1048 |
^ aLabel widthOn:aGC |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1049 |
]. |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1050 |
|
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1051 |
w := 0. |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1052 |
aLabel asCollectionOfLines do:[:el|w := w max:(el widthOn:aGC)]. |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1053 |
^ w |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1054 |
! ! |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1055 |
|
1390 | 1056 |
!HierarchicalItem methodsFor:'private hierarchy'! |
1057 |
||
1058 |
recursiveSetCollapsed |
|
1059 |
"collapse all children and sub-children without notifications |
|
1060 |
" |
|
1061 |
isExpanded := false. |
|
1062 |
||
1063 |
children notNil ifTrue:[ |
|
1064 |
children do:[:aChild| aChild recursiveSetCollapsed ] |
|
1065 |
] |
|
1066 |
! |
|
1067 |
||
1068 |
recursiveSetExpandedAndAddToList:aList |
|
1069 |
"expand all children and sub-children without notifications; |
|
1070 |
add children to list |
|
1071 |
" |
|
1072 |
isExpanded := true. |
|
1073 |
||
1074 |
(children notNil or:[self children notNil]) ifTrue:[ |
|
1733 | 1075 |
self criticalDo:[ |
1076 |
children do:[:aChild| |
|
1077 |
aList add:aChild. |
|
1078 |
aChild recursiveSetExpandedAndAddToList:aList. |
|
1079 |
] |
|
1390 | 1080 |
] |
1081 |
] |
|
1082 |
||
1083 |
! ! |
|
1084 |
||
1085 |
!HierarchicalItem methodsFor:'protocol accessing'! |
|
1086 |
||
1087 |
children |
|
1088 |
"returns list of children |
|
1089 |
*** to optimize:redefine by subClass |
|
1090 |
" |
|
1091 |
|model| |
|
1092 |
||
1093 |
children isNil ifTrue:[ |
|
1094 |
(model := self model) notNil ifTrue:[ |
|
1486 | 1095 |
children := model childrenFor:self |
1390 | 1096 |
]. |
1097 |
]. |
|
1098 |
^ children |
|
1099 |
! |
|
1100 |
||
1101 |
icon |
|
1102 |
"returns the icon or nil; |
|
1103 |
*** to optimize:redefine by subClass |
|
1104 |
" |
|
1105 |
|model| |
|
1106 |
||
1107 |
(model := self model) notNil ifTrue:[ |
|
1108 |
^ model iconFor:self |
|
1109 |
]. |
|
1110 |
^ nil |
|
1111 |
! |
|
1112 |
||
1113 |
label |
|
1114 |
"returns the label displayed on aGC; |
|
1115 |
*** to optimize:redefine by subClass |
|
1116 |
" |
|
1117 |
|model| |
|
1118 |
||
1119 |
(model := self model) notNil ifTrue:[ |
|
1120 |
^ model labelFor:self |
|
1121 |
]. |
|
1122 |
^ nil |
|
1123 |
||
1124 |
! |
|
1125 |
||
1126 |
middleButtonMenu |
|
1127 |
"returns the middleButtonMenu or nil if no menu is defined |
|
1128 |
" |
|
1129 |
|model| |
|
1130 |
||
1131 |
(model := self model) notNil ifTrue:[ |
|
1132 |
^ model middleButtonMenuFor:self |
|
1133 |
]. |
|
1134 |
^ nil |
|
1831
8efa00e1247a
sort stuff; height fix when label changes
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
1135 |
! |
8efa00e1247a
sort stuff; height fix when label changes
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
1136 |
|
8efa00e1247a
sort stuff; height fix when label changes
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
1137 |
recursiveSortChildren:aSortBlock |
8efa00e1247a
sort stuff; height fix when label changes
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
1138 |
|
8efa00e1247a
sort stuff; height fix when label changes
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
1139 |
|children| |
8efa00e1247a
sort stuff; height fix when label changes
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
1140 |
|
8efa00e1247a
sort stuff; height fix when label changes
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
1141 |
(children := self children) notNil ifTrue:[ |
8efa00e1247a
sort stuff; height fix when label changes
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
1142 |
self criticalDo:[ |
8efa00e1247a
sort stuff; height fix when label changes
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
1143 |
children sort:aSortBlock. |
8efa00e1247a
sort stuff; height fix when label changes
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
1144 |
children do:[:aChild| aChild recursiveSortChildren:aSortBlock ] |
8efa00e1247a
sort stuff; height fix when label changes
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
1145 |
] |
8efa00e1247a
sort stuff; height fix when label changes
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
1146 |
]. |
8efa00e1247a
sort stuff; height fix when label changes
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
1147 |
! |
8efa00e1247a
sort stuff; height fix when label changes
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
1148 |
|
8efa00e1247a
sort stuff; height fix when label changes
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
1149 |
sortChildren:aSortBlock |
8efa00e1247a
sort stuff; height fix when label changes
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
1150 |
|children| |
8efa00e1247a
sort stuff; height fix when label changes
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
1151 |
|
8efa00e1247a
sort stuff; height fix when label changes
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
1152 |
(children := self children) notNil ifTrue:[ |
8efa00e1247a
sort stuff; height fix when label changes
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
1153 |
self criticalDo:[ |
8efa00e1247a
sort stuff; height fix when label changes
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
1154 |
children sort:aSortBlock |
8efa00e1247a
sort stuff; height fix when label changes
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
1155 |
] |
8efa00e1247a
sort stuff; height fix when label changes
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
1156 |
]. |
1390 | 1157 |
! ! |
1158 |
||
1159 |
!HierarchicalItem methodsFor:'protocol displaying'! |
|
1160 |
||
1532
56e0fafc4349
change display protocol for item
Claus Gittinger <cg@exept.de>
parents:
1489
diff
changeset
|
1161 |
displayOn:aGC x:x y:y h:h |
1390 | 1162 |
"draw the receiver in the graphicsContext, aGC. |
1163 |
" |
|
1164 |
|label |
|
1398 | 1165 |
x0 "{ Class:SmallInteger }" |
1390 | 1166 |
| |
1540
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1167 |
(label := self label) isNil ifTrue:[^ self]. |
1398 | 1168 |
|
1169 |
(label isSequenceable and:[label isString not]) ifFalse:[ |
|
1606 | 1170 |
^ self displayLabel:label h:(self heightOn:aGC) on:aGC x:x y:y h:h |
1398 | 1171 |
]. |
1172 |
||
1540
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1173 |
x0 := x. |
1398 | 1174 |
label do:[:el| |
1175 |
el notNil ifTrue:[ |
|
1606 | 1176 |
self displayLabel:el h:(self heightOf:el on:aGC) on:aGC x:x0 y:y h:h. |
1398 | 1177 |
x0 := x0 + 5 + (el widthOn:aGC). |
1540
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1178 |
]. |
1390 | 1179 |
] |
1180 |
! |
|
1181 |
||
1182 |
heightOn:aGC |
|
1183 |
"return the width of the receiver, if it is to be displayed on aGC |
|
1184 |
" |
|
1606 | 1185 |
height isNil ifTrue:[ |
1186 |
height := self heightOf:(self label) on:aGC |
|
1187 |
]. |
|
1188 |
^ height |
|
1390 | 1189 |
! |
1190 |
||
1191 |
widthOn:aGC |
|
1192 |
"return the width of the receiver, if it is to be displayed on aGC |
|
1193 |
" |
|
1606 | 1194 |
width isNil ifTrue:[ |
1195 |
width := self widthOf:(self label) on:aGC |
|
1196 |
]. |
|
1197 |
^ width |
|
1198 |
||
1390 | 1199 |
! ! |
1200 |
||
1201 |
!HierarchicalItem methodsFor:'protocol monitoring'! |
|
1202 |
||
1203 |
monitoringCycle |
|
1204 |
"called all 'n' seconds by the model, if the monitoring |
|
1205 |
cycle is enabled. The item can perform some checks, .. |
|
1206 |
**** can be redefined by subclass to perform some actions |
|
1207 |
" |
|
1208 |
! ! |
|
1209 |
||
1210 |
!HierarchicalItem methodsFor:'protocol queries'! |
|
1211 |
||
1571 | 1212 |
drawHorizontalLineUpToText |
1213 |
"draw the horizizontal line for the selected item up to the text |
|
1214 |
or on default to the start of the the vertical line; only used by |
|
1215 |
the hierarchical view |
|
1216 |
" |
|
1217 |
^ false |
|
1218 |
! |
|
1219 |
||
1390 | 1220 |
hasChildren |
1221 |
"checks whether the item has a list of children; the list must not |
|
1222 |
be loaded yet( ex. FileDirectory ). |
|
1223 |
*** to optimize:redefine by subClass |
|
1224 |
" |
|
1225 |
^ children notNil ifTrue:[children notEmpty] |
|
1226 |
ifFalse:[self children size ~~ 0] |
|
1227 |
! |
|
1228 |
||
1229 |
string |
|
1230 |
"access the printable string used for steping through a list |
|
1231 |
searching for an entry starting with a character. |
|
1232 |
*** to optimize:redefine by subClass |
|
1233 |
" |
|
1398 | 1234 |
|label| |
1235 |
||
1236 |
(label := self label) notNil ifTrue:[ |
|
1237 |
label isString ifTrue:[ ^ label string ]. |
|
1238 |
label isImageOrForm ifTrue:[ ^ nil ]. |
|
1239 |
||
1240 |
label isSequenceable ifFalse:[ |
|
1241 |
^ label perform:#string ifNotUnderstood:nil |
|
1242 |
]. |
|
1243 |
||
1244 |
label do:[:el||s| |
|
1245 |
(el notNil and:[el isImageOrForm not]) ifTrue:[ |
|
1246 |
s := el perform:#string ifNotUnderstood:nil. |
|
1247 |
s notNil ifTrue:[^ s]. |
|
1248 |
] |
|
1249 |
] |
|
1250 |
]. |
|
1251 |
^ nil |
|
1252 |
||
1390 | 1253 |
|
1254 |
! ! |
|
1255 |
||
1256 |
!HierarchicalItem methodsFor:'queries'! |
|
1257 |
||
1258 |
canCollapse |
|
1259 |
"called before collapsing the item |
|
1260 |
" |
|
1598
33202082065d
care for uninitialized isExpanded
Claus Gittinger <cg@exept.de>
parents:
1571
diff
changeset
|
1261 |
^ (isExpanded == true) |
1390 | 1262 |
! |
1263 |
||
1264 |
canExpand |
|
1265 |
"called before expanding the item |
|
1266 |
" |
|
1598
33202082065d
care for uninitialized isExpanded
Claus Gittinger <cg@exept.de>
parents:
1571
diff
changeset
|
1267 |
^ (isExpanded == true) not and:[self hasChildren] |
1390 | 1268 |
! |
1269 |
||
1804 | 1270 |
isChildOf:anItem |
1271 |
"returns true if the item is a child of anItem |
|
1272 |
" |
|
1273 |
|item| |
|
1274 |
||
1275 |
item := self. |
|
1276 |
||
1277 |
[anItem ~~ item] whileTrue:[ |
|
1278 |
((item := item parent) notNil and:[item isHierarchicalItem]) ifFalse:[ |
|
1279 |
^ false |
|
1280 |
] |
|
1281 |
]. |
|
1282 |
^ true |
|
1283 |
||
1284 |
! |
|
1285 |
||
1390 | 1286 |
isExpanded |
1287 |
"return true if item is expanded |
|
1288 |
" |
|
1598
33202082065d
care for uninitialized isExpanded
Claus Gittinger <cg@exept.de>
parents:
1571
diff
changeset
|
1289 |
^ (isExpanded == true) |
1390 | 1290 |
! |
1291 |
||
1292 |
isHierarchicalItem |
|
1293 |
"used to decide if the parent is a hierarchical item |
|
1294 |
or the model |
|
1295 |
" |
|
1296 |
^ true |
|
1297 |
! |
|
1298 |
||
1650 | 1299 |
isSelectable |
1300 |
"returns true if the item is selectable otherwise false |
|
1301 |
" |
|
1302 |
^ true |
|
1303 |
! |
|
1304 |
||
1390 | 1305 |
size |
1306 |
"return the number of children |
|
1307 |
" |
|
1308 |
^ children notNil ifTrue:[children size] |
|
1309 |
ifFalse:[self children size] |
|
1310 |
! ! |
|
1311 |
||
1312 |
!HierarchicalItem methodsFor:'searching'! |
|
1313 |
||
1314 |
detect:aOneArgBlock |
|
1315 |
"find the first child, for which evaluation of the block returns |
|
1316 |
true; if none does so, report an error |
|
1317 |
" |
|
1318 |
^ self detect:aOneArgBlock ifNone:[self errorNotFound] |
|
1319 |
||
1320 |
! |
|
1321 |
||
1322 |
detect:aOneArgBlock ifNone:anExceptionBlock |
|
1323 |
"find the first child, for which evaluation of the block returns |
|
1324 |
true; if none does so, return the evaluation of anExceptionBlock |
|
1325 |
" |
|
1804 | 1326 |
|item| |
1733 | 1327 |
|
1328 |
self children size ~~ 0 ifTrue:[ |
|
1329 |
self criticalDo:[ |
|
1804 | 1330 |
item := children detect:aOneArgBlock ifNone:nil |
1733 | 1331 |
]. |
1804 | 1332 |
item notNil ifTrue:[ |
1333 |
^ item |
|
1334 |
] |
|
1335 |
]. |
|
1336 |
^ anExceptionBlock value |
|
1337 |
||
1338 |
||
1339 |
! |
|
1340 |
||
1341 |
detectLast:aOneArgBlock |
|
1342 |
"find the last child, for which evaluation of the block returns |
|
1343 |
true; if none does so, an exception is raised |
|
1344 |
" |
|
1345 |
^ self detectLast:aOneArgBlock ifNone:[self errorNotFound] |
|
1346 |
||
1347 |
! |
|
1348 |
||
1349 |
detectLast:aOneArgBlock ifNone:anExceptionBlock |
|
1350 |
"find the last child, for which evaluation of the block returns |
|
1351 |
true; if none does so, return the evaluation of anExceptionBlock |
|
1352 |
" |
|
1353 |
|item| |
|
1354 |
||
1355 |
self children size ~~ 0 ifTrue:[ |
|
1356 |
self criticalDo:[ |
|
1357 |
item := children detectLast:aOneArgBlock ifNone:nil |
|
1358 |
]. |
|
1359 |
item notNil ifTrue:[ |
|
1360 |
^ item |
|
1361 |
] |
|
1390 | 1362 |
]. |
1363 |
^ anExceptionBlock value |
|
1364 |
||
1365 |
||
1366 |
! |
|
1367 |
||
1368 |
identityIndexOf:aChild |
|
1369 |
"return the index of aChild or 0 if not found. Compare using == |
|
1370 |
" |
|
1733 | 1371 |
^ self identityIndexOf:aChild startingAt:1 |
1390 | 1372 |
! |
1373 |
||
1374 |
identityIndexOf:aChild startingAt:startIndex |
|
1375 |
"return the index of aChild, starting search at startIndex. |
|
1376 |
Compare using ==; return 0 if not found |
|
1377 |
" |
|
1733 | 1378 |
|index| |
1379 |
||
1380 |
index := 0. |
|
1381 |
||
1382 |
self children size ~~ 0 ifTrue:[ |
|
1383 |
self criticalDo:[ |
|
1384 |
index := children identityIndexOf:aChild startingAt:startIndex |
|
1385 |
] |
|
1390 | 1386 |
]. |
1733 | 1387 |
^ index |
1489 | 1388 |
! |
1389 |
||
1390 |
recursiveDetect:aOneArgBlock |
|
1391 |
"recursive find the first child, for which evaluation |
|
1392 |
of the block returns true; if none nil is returned |
|
1393 |
" |
|
1804 | 1394 |
self recursiveDo:[:aChild| |
1395 |
(aOneArgBlock value:aChild) ifTrue:[^ aChild] |
|
1396 |
]. |
|
1397 |
^ nil |
|
1398 |
! |
|
1489 | 1399 |
|
1804 | 1400 |
recursiveDetectLast:aBlock |
1401 |
"find the last child, for which evaluation of the block returns |
|
1402 |
true; if none does so, nil id returned |
|
1403 |
" |
|
1404 |
self recursiveReverseDo:[:aChild| |
|
1405 |
(aBlock value:aChild) ifTrue:[^ aChild]. |
|
1489 | 1406 |
]. |
1407 |
^ nil |
|
1390 | 1408 |
! ! |
1409 |
||
1410 |
!HierarchicalItem::Example class methodsFor:'instance creation'! |
|
1411 |
||
1412 |
labeled:aLabel |
|
1413 |
^ self new setLabel:aLabel |
|
1414 |
||
1415 |
||
1416 |
! |
|
1417 |
||
1418 |
labeled:aLabel icon:anIcon |
|
1419 |
^ self new setLabel:aLabel icon:anIcon |
|
1420 |
||
1421 |
||
1422 |
! ! |
|
1423 |
||
1424 |
!HierarchicalItem::Example class methodsFor:'resources'! |
|
1425 |
||
1426 |
iconForLevel:aLevel |
|
1427 |
"returns an icon |
|
1428 |
" |
|
1429 |
aLevel == 2 ifTrue:[ ^ ResourceSelectionBrowser iconPrivateClass ]. |
|
1430 |
aLevel == 3 ifTrue:[ ^ ResourceSelectionBrowser iconClass ]. |
|
1431 |
aLevel == 4 ifTrue:[ ^ ResourceSelectionBrowser iconCategory ]. |
|
1432 |
||
1433 |
^ nil |
|
1434 |
||
1435 |
! |
|
1436 |
||
1437 |
penguinIcon |
|
1438 |
PenguinIcon isNil ifTrue:[ |
|
1794 | 1439 |
PenguinIcon := Smalltalk imageFromFileNamed:'xpmBitmaps/misc_logos/linux_penguin.xpm' |
1440 |
inPackage:'stx:goodies' |
|
1390 | 1441 |
]. |
1442 |
^ PenguinIcon |
|
1443 |
! ! |
|
1444 |
||
1445 |
!HierarchicalItem::Example methodsFor:'accessing'! |
|
1446 |
||
1447 |
children |
|
1540
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1448 |
|lvl lbl txt image img icon tmp| |
1390 | 1449 |
|
1450 |
children notNil ifTrue:[ |
|
1451 |
^ children |
|
1452 |
]. |
|
1453 |
||
1454 |
(lvl := self level) == 5 ifTrue:[ |
|
1455 |
children := #(). |
|
1456 |
^ children |
|
1457 |
]. |
|
1458 |
icon := self class iconForLevel:(lvl + 1). |
|
1459 |
children := OrderedCollection new. |
|
1460 |
||
1461 |
lvl < 4 ifTrue:[ |
|
1462 |
txt := (lvl + 1) printString, ' ['. |
|
1463 |
img := NewLauncher saveImageIcon. |
|
1464 |
||
1465 |
1 to:5 do:[:i| |
|
1466 |
(i == 2 or:[i == 3]) ifTrue:[ |
|
1467 |
lbl := img |
|
1468 |
] ifFalse:[ |
|
1469 |
i == 4 ifTrue:[ |
|
1540
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1470 |
lbl := Array with:(self class penguinIcon) |
1733 | 1471 |
with:('penguin#and#text' replaceAll:$# with:(Character cr)). |
1390 | 1472 |
] ifFalse:[ |
1473 |
lbl := txt, (i printString), ']' |
|
1474 |
] |
|
1475 |
]. |
|
1476 |
children add:(self class labeled:lbl icon:icon) |
|
1477 |
]. |
|
1478 |
] ifFalse:[ |
|
1479 |
image := ResourceSelectionBrowser iconPrivateClass. |
|
1480 |
txt := LabelAndIcon icon:image string:'Text'. |
|
1481 |
img := Icon copyIcon. |
|
1482 |
||
1483 |
1 to:5 do:[:i| |
|
1484 |
lbl := i odd ifTrue:[txt] ifFalse:[img]. |
|
1398 | 1485 |
lbl := Array with:lbl with:'test' with:img. |
1390 | 1486 |
children add:(self class labeled:lbl icon:icon). |
1487 |
] |
|
1488 |
]. |
|
1489 |
||
1490 |
children do:[:aChild| aChild parent:self ]. |
|
1491 |
^ children |
|
1492 |
! |
|
1493 |
||
1494 |
icon |
|
1495 |
"returns the icon |
|
1496 |
" |
|
1497 |
^ icon |
|
1498 |
! |
|
1499 |
||
1500 |
icon:anIcon |
|
1501 |
"set the icon; if icon changed, a notification |
|
1502 |
is raised. |
|
1503 |
" |
|
1504 |
icon ~= anIcon ifTrue:[ |
|
1505 |
icon := anIcon. |
|
1506 |
self iconChanged |
|
1507 |
] |
|
1508 |
! |
|
1509 |
||
1510 |
label |
|
1511 |
"returns the label |
|
1512 |
" |
|
1513 |
^ label |
|
1514 |
||
1515 |
! |
|
1516 |
||
1517 |
label:aLabel |
|
1518 |
"set the label; if label changed, a notification |
|
1519 |
is raised. |
|
1520 |
" |
|
1521 |
label ~= aLabel ifTrue:[ |
|
1522 |
label := aLabel. |
|
1523 |
self changed. |
|
1524 |
] |
|
1525 |
||
1526 |
! |
|
1527 |
||
1528 |
setIcon:anIcon |
|
1529 |
"set the icon without any change notification |
|
1530 |
" |
|
1531 |
icon := anIcon |
|
1532 |
! |
|
1533 |
||
1534 |
setLabel:aLabel |
|
1535 |
"set the label without any change notification |
|
1536 |
" |
|
1537 |
label := aLabel |
|
1538 |
! |
|
1539 |
||
1540 |
setLabel:aLabel icon:anIcon |
|
1541 |
"set the label and icon without any change notification |
|
1542 |
" |
|
1543 |
label := aLabel. |
|
1544 |
icon := anIcon. |
|
1545 |
! ! |
|
1546 |
||
1547 |
!HierarchicalItem class methodsFor:'documentation'! |
|
1548 |
||
1549 |
version |
|
1831
8efa00e1247a
sort stuff; height fix when label changes
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
1550 |
^ '$Header: /cvs/stx/stx/libwidg2/HierarchicalItem.st,v 1.24 2000-09-06 12:41:59 cg Exp $' |
1390 | 1551 |
! ! |