author | Claus Gittinger <cg@exept.de> |
Thu, 18 Dec 2008 11:33:20 +0100 | |
changeset 3613 | 440f0aa671ce |
parent 3562 | 188996f5b78b |
child 3615 | b2e2242fd240 |
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 |
" |
|
1794 | 12 |
"{ Package: 'stx:libwidg2' }" |
13 |
||
1390 | 14 |
Object subclass:#HierarchicalItem |
1606 | 15 |
instanceVariableNames:'parent children isExpanded height width' |
1390 | 16 |
classVariableNames:'' |
17 |
poolDictionaries:'' |
|
1430 | 18 |
category:'Views-Support' |
1390 | 19 |
! |
20 |
||
21 |
HierarchicalItem subclass:#Example |
|
22 |
instanceVariableNames:'label icon' |
|
23 |
classVariableNames:'PenguinIcon' |
|
24 |
poolDictionaries:'' |
|
25 |
privateIn:HierarchicalItem |
|
26 |
! |
|
27 |
||
28 |
!HierarchicalItem class methodsFor:'documentation'! |
|
29 |
||
1431 | 30 |
copyright |
31 |
" |
|
32 |
COPYRIGHT (c) 1999 by eXept Software AG |
|
33 |
All Rights Reserved |
|
34 |
||
35 |
This software is furnished under a license and may be used |
|
36 |
only in accordance with the terms of that license and with the |
|
37 |
inclusion of the above copyright notice. This software may not |
|
38 |
be provided or otherwise made available to, or used by, any |
|
39 |
other person. No title to or ownership of the software is |
|
40 |
hereby transferred. |
|
41 |
" |
|
42 |
||
43 |
! |
|
44 |
||
1390 | 45 |
documentation |
46 |
" |
|
47 |
Hierarchical Items are mostly like Models, but the list of |
|
48 |
dependencies are kept by its HierarchicalList. |
|
49 |
The class is used to build up hierarchical trees. |
|
50 |
||
51 |
[Instance variables:] |
|
52 |
parent <Item, List or nil> parent or my HierarchicalList. |
|
53 |
children <Collection or nil> list of children |
|
54 |
isExpanded <Boolean> indicates whether the item is |
|
55 |
expanded or collapsed |
|
56 |
||
57 |
[author:] |
|
58 |
Claus Atzkern |
|
59 |
||
60 |
[see also:] |
|
61 |
HierarchicalList |
|
62 |
HierarchicalListView |
|
63 |
" |
|
64 |
||
65 |
||
66 |
! ! |
|
67 |
||
68 |
!HierarchicalItem class methodsFor:'instance creation'! |
|
69 |
||
70 |
new |
|
71 |
^ (self basicNew) initialize |
|
2314 | 72 |
! |
73 |
||
74 |
parent:aParent |
|
75 |
|item| |
|
76 |
||
77 |
item := self new. |
|
78 |
item parent:aParent. |
|
79 |
^ item |
|
1390 | 80 |
! ! |
81 |
||
2081 | 82 |
!HierarchicalItem class methodsFor:'protocol'! |
83 |
||
84 |
doResetExtentOnChange |
|
85 |
"true: the extent of the item is reset if a change |
|
86 |
notification is raised from the item. the default is true |
|
87 |
" |
|
88 |
^ true |
|
89 |
! ! |
|
90 |
||
1390 | 91 |
!HierarchicalItem methodsFor:'accessing'! |
92 |
||
2081 | 93 |
getChildren |
94 |
"returns the children at it is; not going to the model ... |
|
95 |
" |
|
96 |
^ children |
|
97 |
! |
|
98 |
||
1390 | 99 |
level |
100 |
"returns the level starting with 1 |
|
101 |
" |
|
2386 | 102 |
|item level| |
103 |
||
104 |
"/ for optimization we try to suppress a block |
|
105 |
||
106 |
item := self. |
|
1390 | 107 |
|
2386 | 108 |
(item := item parentOrModel) isNil ifTrue:[^ 0]. |
109 |
(item := item parentOrModel) isNil ifTrue:[^ 1]. |
|
110 |
(item := item parentOrModel) isNil ifTrue:[^ 2]. |
|
111 |
(item := item parentOrModel) isNil ifTrue:[^ 3]. |
|
112 |
(item := item parentOrModel) isNil ifTrue:[^ 4]. |
|
113 |
(item := item parentOrModel) isNil ifTrue:[^ 5]. |
|
114 |
(item := item parentOrModel) isNil ifTrue:[^ 6]. |
|
115 |
||
116 |
level := 7. |
|
117 |
||
118 |
[(item := item parentOrModel) notNil] whileTrue:[ |
|
3090 | 119 |
level := level + 1. |
3562 | 120 |
level > 100000 ifTrue:[ |
121 |
self halt:'possibly recursive item hierarchy' |
|
122 |
]. |
|
1390 | 123 |
]. |
124 |
^ level |
|
125 |
! |
|
126 |
||
127 |
parent |
|
128 |
"returns the parent or nil |
|
129 |
" |
|
130 |
^ (parent notNil and:[parent isHierarchicalItem]) ifTrue:[parent] |
|
131 |
ifFalse:[nil] |
|
132 |
! |
|
133 |
||
134 |
parent:aParent |
|
135 |
"set the parent (or the model if the item is the root item) |
|
136 |
" |
|
137 |
parent := aParent |
|
138 |
||
1883 | 139 |
! |
140 |
||
141 |
rootItem |
|
142 |
"returns the root item |
|
143 |
" |
|
144 |
parent isHierarchicalItem ifTrue:[ |
|
145 |
^ parent rootItem |
|
146 |
]. |
|
147 |
^ self |
|
1390 | 148 |
! ! |
149 |
||
1818 | 150 |
!HierarchicalItem methodsFor:'accessing-children'! |
1390 | 151 |
|
152 |
at:anIndex |
|
1900 | 153 |
"return the child at anIndex if valid; |
2927 | 154 |
if the index is invalid, nil is returned" |
155 |
||
1900 | 156 |
^ self at:anIndex ifAbsent:nil |
157 |
! |
|
158 |
||
159 |
at:anIndex ifAbsent:exceptionBlock |
|
160 |
"return the child at anIndex if valid; if the index is |
|
2927 | 161 |
invalid, the result of evaluating the exceptionBlock is returned." |
162 |
||
1900 | 163 |
|list| |
164 |
||
165 |
(list := self children) notNil ifTrue:[ |
|
166 |
^ list at:anIndex ifAbsent:exceptionBlock |
|
167 |
]. |
|
168 |
^ exceptionBlock value |
|
1390 | 169 |
! |
170 |
||
171 |
at:anIndex put:anItem |
|
3613
440f0aa671ce
return value fixed (consistent)
Claus Gittinger <cg@exept.de>
parents:
3562
diff
changeset
|
172 |
"replace a child by a new item. return anItem (sigh)" |
2927 | 173 |
|
2340 | 174 |
|children oldItem visIndex model expFlag| |
1390 | 175 |
|
176 |
anItem isNil ifTrue:[ |
|
3613
440f0aa671ce
return value fixed (consistent)
Claus Gittinger <cg@exept.de>
parents:
3562
diff
changeset
|
177 |
self removeFromIndex:anIndex toIndex:anIndex. |
440f0aa671ce
return value fixed (consistent)
Claus Gittinger <cg@exept.de>
parents:
3562
diff
changeset
|
178 |
^ nil |
1390 | 179 |
]. |
2340 | 180 |
anItem parent:self. |
2081 | 181 |
|
2340 | 182 |
(model := self model) isNil ifTrue:[ |
3613
440f0aa671ce
return value fixed (consistent)
Claus Gittinger <cg@exept.de>
parents:
3562
diff
changeset
|
183 |
self children at:anIndex put:anItem. |
440f0aa671ce
return value fixed (consistent)
Claus Gittinger <cg@exept.de>
parents:
3562
diff
changeset
|
184 |
^ anItem |
2081 | 185 |
]. |
186 |
||
2340 | 187 |
model criticalDo:[ |
188 |
children := self children. |
|
189 |
oldItem := children at:anIndex. |
|
2081 | 190 |
|
2340 | 191 |
oldItem isExpanded ifTrue:[ |
192 |
oldItem collapse |
|
193 |
]. |
|
194 |
visIndex := model identityIndexOf:oldItem. |
|
195 |
expFlag := anItem isExpanded. |
|
196 |
anItem setExpanded:false. |
|
2081 | 197 |
|
2340 | 198 |
children at:anIndex put:anItem. |
199 |
||
200 |
visIndex ~~ 0 ifTrue:[ |
|
2343 | 201 |
model at:visIndex put:anItem. |
2081 | 202 |
]. |
2340 | 203 |
self changed:#redraw. |
204 |
expFlag ifTrue:[ anItem expand ]. |
|
1390 | 205 |
]. |
2081 | 206 |
^ anItem |
1390 | 207 |
! |
208 |
||
209 |
children:aListOfChildren |
|
2927 | 210 |
"set a new list of children" |
211 |
||
1733 | 212 |
self criticalDo:[ |
213 |
self removeAll. |
|
214 |
self addAll:aListOfChildren beforeIndex:1 |
|
215 |
]. |
|
216 |
^ aListOfChildren |
|
1390 | 217 |
! |
218 |
||
219 |
first |
|
220 |
"returns the first child |
|
221 |
" |
|
222 |
^ self at:1 |
|
223 |
! |
|
224 |
||
225 |
last |
|
226 |
"returns the last child |
|
227 |
" |
|
2081 | 228 |
^ self at:(self size) |
1900 | 229 |
! |
230 |
||
231 |
second |
|
232 |
"returns the second child |
|
233 |
" |
|
234 |
^ self at:2 |
|
1390 | 235 |
! ! |
236 |
||
1818 | 237 |
!HierarchicalItem methodsFor:'accessing-hierarchy'! |
1390 | 238 |
|
239 |
collapse |
|
2549 | 240 |
"hide all my subitems" |
241 |
||
2081 | 242 |
|visChd index| |
1390 | 243 |
|
244 |
self canCollapse ifTrue:[ |
|
245 |
isExpanded := false. |
|
246 |
||
1733 | 247 |
self criticalDo:[ |
248 |
(index := self listIndex) notNil ifTrue:[ |
|
2081 | 249 |
"/ do not call :#size: children will be autoloaded !!!! |
1733 | 250 |
(visChd := children size) ~~ 0 ifTrue:[ |
2117 | 251 |
self nonCriticalFrom:1 to:nil do:[:el| |
2081 | 252 |
visChd := visChd + el numberOfVisibleChildren |
1733 | 253 |
]. |
254 |
self model itemRemoveFromIndex:(index + 1) toIndex:(index + visChd). |
|
2201
aa74fa6137a5
make indicator dependent on hasIndicator and not hasChildren
ca
parents:
2193
diff
changeset
|
255 |
]. |
2549 | 256 |
index ~~ 0 ifTrue:[self hierarchyChanged]. |
1390 | 257 |
] |
258 |
] |
|
259 |
] |
|
260 |
! |
|
261 |
||
2476 | 262 |
enforcedExpand |
2724 | 263 |
"expand children - even if there are no children, |
2476 | 264 |
the item is initially expanded (but this might be undone later, |
265 |
when we know that no children are there" |
|
266 |
||
267 |
self expand:true |
|
268 |
! |
|
269 |
||
1390 | 270 |
expand |
2476 | 271 |
"expand children - but only if there are children |
272 |
(i.e. this cannot be used before the childInfo is valid; |
|
273 |
aka not before the updateTask came along this item)" |
|
274 |
||
275 |
self expand:false |
|
276 |
! |
|
277 |
||
278 |
expand:enforced |
|
2547 | 279 |
"expand children" |
280 |
||
2305 | 281 |
|index list| |
282 |
||
283 |
"/ test whether the item already is expanded; #canExpand could be redefined |
|
284 |
"/ without checking whether the node is expanded (happens already) !! |
|
285 |
||
2547 | 286 |
isExpanded ifTrue:[ ^ self ]. |
2724 | 287 |
(enforced not and:[self canExpand not]) ifTrue:[ ^ self ]. |
1942 | 288 |
|
2305 | 289 |
self criticalDo:[ |
290 |
(index := self listIndex) notNil ifTrue:[ |
|
291 |
"/ must set expand-flag to false, otherwise change notifications |
|
2476 | 292 |
"/ are raised during lazy auto creation (to the list). |
2305 | 293 |
isExpanded := false. |
294 |
list := self children. |
|
295 |
isExpanded := true. |
|
296 |
||
2832 | 297 |
list notEmptyOrNil ifTrue:[ |
298 |
list := OrderedCollection new:64. |
|
299 |
self addVisibleChildrenTo:list. |
|
300 |
self model itemAddAll:list beforeIndex:(index + 1). |
|
2305 | 301 |
]. |
302 |
index ~~ 0 ifTrue:[self hierarchyChanged]. |
|
303 |
] ifFalse:[ |
|
304 |
isExpanded := true |
|
1390 | 305 |
] |
2305 | 306 |
]. |
1390 | 307 |
! |
308 |
||
1409 | 309 |
makeVisible |
310 |
"expand all my parents |
|
311 |
" |
|
312 |
(parent notNil and:[parent isHierarchicalItem]) ifTrue:[ |
|
1733 | 313 |
self criticalDo:[ |
314 |
parent expand. |
|
315 |
parent makeVisible |
|
316 |
] |
|
1409 | 317 |
]. |
318 |
! |
|
319 |
||
1390 | 320 |
recursiveCollapse |
2081 | 321 |
"collapse all item and sub items |
1390 | 322 |
**** must be expanded |
323 |
" |
|
324 |
|visChd index| |
|
325 |
||
326 |
self canCollapse ifTrue:[ |
|
1733 | 327 |
self criticalDo:[ |
328 |
(index := self listIndex) notNil ifTrue:[ |
|
2081 | 329 |
"/ do not call :#size: children will be autoloaded !!!! |
1733 | 330 |
(visChd := children size) ~~ 0 ifTrue:[ |
2117 | 331 |
self nonCriticalFrom:1 to:nil do:[:el| |
2081 | 332 |
visChd := visChd + el numberOfVisibleChildren |
333 |
]. |
|
1733 | 334 |
]. |
335 |
self recursiveSetCollapsed. |
|
1390 | 336 |
|
1733 | 337 |
visChd ~~ 0 ifTrue:[ |
338 |
self model itemRemoveFromIndex:(index + 1) |
|
339 |
toIndex:(index + visChd) |
|
340 |
]. |
|
341 |
index ~~ 0 ifTrue:[ |
|
342 |
self hierarchyChanged |
|
343 |
] |
|
344 |
] ifFalse:[ |
|
345 |
self recursiveSetCollapsed |
|
1390 | 346 |
] |
347 |
] |
|
348 |
] |
|
349 |
! |
|
350 |
||
351 |
recursiveExpand |
|
352 |
"expand children and sub-children |
|
353 |
**** must be collapsed |
|
354 |
" |
|
2305 | 355 |
"/ test whether the item already is expanded; #canExpand could be redefined |
356 |
"/ without checking whether the node is expanded (happens already) !! |
|
357 |
||
2846 | 358 |
|index list| |
2547 | 359 |
isExpanded ifTrue:[ ^ self ]. |
2845
fb807c9aa195
Add recursive force expand, to force expand of children independed
ab
parents:
2832
diff
changeset
|
360 |
|
2547 | 361 |
self canExpand ifFalse:[ ^ self ]. |
2305 | 362 |
|
363 |
isExpanded := true. |
|
1390 | 364 |
|
2305 | 365 |
self criticalDo:[ |
366 |
self size ~~ 0 ifTrue:[ |
|
367 |
index := self listIndex. "/ get the visible list index |
|
1390 | 368 |
|
2305 | 369 |
index isNil ifTrue:[ "/ not visible |
370 |
self nonCriticalFrom:1 to:nil do:[:el| |
|
371 |
el setExpanded:true |
|
372 |
]. |
|
373 |
] ifFalse:[ |
|
374 |
list := OrderedCollection new:512. |
|
375 |
self recursiveSetExpandedAndAddToList:list. |
|
376 |
self model itemAddAll:list beforeIndex:(index + 1). |
|
377 |
||
378 |
index ~~ 0 ifTrue:[self hierarchyChanged] |
|
1390 | 379 |
] |
380 |
] |
|
2305 | 381 |
]. |
1390 | 382 |
! |
383 |
||
384 |
recursiveToggleExpand |
|
2081 | 385 |
"if the item is collapsed, the item and all its sub-items |
2547 | 386 |
are expanded otherwise collapsed" |
387 |
||
388 |
isExpanded ifTrue:[ |
|
1598
33202082065d
care for uninitialized isExpanded
Claus Gittinger <cg@exept.de>
parents:
1571
diff
changeset
|
389 |
self recursiveCollapse |
33202082065d
care for uninitialized isExpanded
Claus Gittinger <cg@exept.de>
parents:
1571
diff
changeset
|
390 |
] ifFalse:[ |
33202082065d
care for uninitialized isExpanded
Claus Gittinger <cg@exept.de>
parents:
1571
diff
changeset
|
391 |
self recursiveExpand |
33202082065d
care for uninitialized isExpanded
Claus Gittinger <cg@exept.de>
parents:
1571
diff
changeset
|
392 |
] |
1390 | 393 |
! |
394 |
||
395 |
toggleExpand |
|
2081 | 396 |
"if the item is collapsed, the item is expanded otherwise |
2547 | 397 |
collapsed" |
398 |
||
399 |
isExpanded ifTrue:[ |
|
2081 | 400 |
self collapse |
401 |
] ifFalse:[ |
|
402 |
self expand |
|
403 |
]. |
|
1390 | 404 |
! ! |
405 |
||
1818 | 406 |
!HierarchicalItem methodsFor:'accessing-mvc'! |
1390 | 407 |
|
408 |
application |
|
2927 | 409 |
"returns the responsible application or nil" |
410 |
||
1390 | 411 |
|model| |
412 |
||
413 |
(model := self model) notNil ifTrue:[ |
|
414 |
^ model application |
|
415 |
]. |
|
416 |
^ nil |
|
417 |
! |
|
418 |
||
419 |
applicationsDo:aOneArgBlock |
|
2927 | 420 |
"evaluate the block for each dependent application" |
421 |
||
1390 | 422 |
|model| |
423 |
||
424 |
(model := self model) notNil ifTrue:[ |
|
425 |
model applicationsDo:aOneArgBlock |
|
426 |
] |
|
427 |
! |
|
428 |
||
429 |
model |
|
430 |
"returns the hierachicalList model or nil |
|
431 |
" |
|
2386 | 432 |
|item next| |
433 |
||
2716 | 434 |
item := self. |
435 |
[ (next := item parentOrModel) notNil ] whileTrue:[ |
|
436 |
item := next. |
|
437 |
]. |
|
2386 | 438 |
|
439 |
item isHierarchicalItem ifFalse:[^ item]. |
|
440 |
^ nil |
|
1390 | 441 |
! ! |
442 |
||
443 |
!HierarchicalItem methodsFor:'adding & removing'! |
|
444 |
||
445 |
add:aChildItem |
|
2927 | 446 |
"add a child at end" |
447 |
||
1390 | 448 |
^ self add:aChildItem beforeIndex:(self children size + 1). |
449 |
! |
|
450 |
||
451 |
add:aChildItem after:aChild |
|
2927 | 452 |
"add an item after an existing item" |
453 |
||
1390 | 454 |
|index| |
455 |
||
2315 | 456 |
index := self identityIndexOf:aChild. |
2484
92f9e42980ab
correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents:
2476
diff
changeset
|
457 |
index == 0 ifTrue:[ self subscriptBoundsError:index ]. |
2315 | 458 |
|
459 |
self add:aChildItem beforeIndex:(index + 1). |
|
2927 | 460 |
^ aChildItem |
1390 | 461 |
! |
462 |
||
463 |
add:aChildItem afterIndex:anIndex |
|
2927 | 464 |
"add an item after an index" |
465 |
||
1390 | 466 |
^ self add:aChildItem beforeIndex:(anIndex + 1). |
467 |
! |
|
468 |
||
469 |
add:aChildItem before:aChild |
|
2927 | 470 |
"add an item before an existing item" |
471 |
||
1390 | 472 |
|index| |
473 |
||
2315 | 474 |
index := self identityIndexOf:aChild. |
2484
92f9e42980ab
correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents:
2476
diff
changeset
|
475 |
index == 0 ifTrue:[ self subscriptBoundsError:index ]. |
2315 | 476 |
|
477 |
self add:aChildItem beforeIndex:index. |
|
2927 | 478 |
^ aChild |
1390 | 479 |
! |
480 |
||
481 |
add:aChildItem beforeIndex:anIndex |
|
2927 | 482 |
"add an item before an index" |
483 |
||
1390 | 484 |
aChildItem notNil ifTrue:[ |
485 |
self addAll:(Array with:aChildItem) beforeIndex:anIndex |
|
486 |
]. |
|
487 |
^ aChildItem |
|
488 |
! |
|
489 |
||
1488 | 490 |
add:aChild sortBlock:aBlock |
2927 | 491 |
"add a child sorted" |
492 |
||
1733 | 493 |
self criticalDo:[ |
494 |
self basicAdd:aChild sortBlock:aBlock |
|
1488 | 495 |
]. |
1733 | 496 |
^ aChild |
1488 | 497 |
! |
498 |
||
1390 | 499 |
addAll:aList |
2927 | 500 |
"add children at the end" |
501 |
||
1390 | 502 |
^ self addAll:aList beforeIndex:(self children size + 1) |
503 |
! |
|
504 |
||
1650 | 505 |
addAll:aList before:aChild |
2927 | 506 |
"add an item before an existing item" |
507 |
||
1650 | 508 |
|index| |
509 |
||
2315 | 510 |
index := self identityIndexOf:aChild. |
2484
92f9e42980ab
correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents:
2476
diff
changeset
|
511 |
index == 0 ifTrue:[ self subscriptBoundsError:index ]. |
2315 | 512 |
|
2927 | 513 |
^ self addAll:aList beforeIndex:index |
1650 | 514 |
! |
515 |
||
1390 | 516 |
addAll:aList beforeIndex:anIndex |
2927 | 517 |
"add children before an index" |
518 |
||
1733 | 519 |
aList size ~~ 0 ifTrue:[ |
520 |
self criticalDo:[ |
|
521 |
self basicAddAll:aList beforeIndex:anIndex |
|
522 |
] |
|
523 |
]. |
|
524 |
^ aList |
|
525 |
! |
|
526 |
||
527 |
addAll:aList sortBlock:aBlock |
|
2927 | 528 |
"add children sorted" |
529 |
||
2357 | 530 |
aList size == 0 ifTrue:[ ^ aList ]. |
531 |
||
532 |
aBlock isNil ifTrue:[ |
|
533 |
self addAll:aList. |
|
534 |
] ifFalse:[ |
|
535 |
self criticalDo:[ |
|
536 |
aList do:[:el| self basicAdd:el sortBlock:aBlock ] |
|
1733 | 537 |
] |
538 |
]. |
|
539 |
^ aList |
|
540 |
! |
|
541 |
||
542 |
addAllFirst:aCollectionOfItems |
|
2927 | 543 |
"add children at the beginning" |
544 |
||
1733 | 545 |
^ self addAll:aCollectionOfItems beforeIndex:1 |
546 |
! |
|
547 |
||
548 |
addAllLast:aCollectionOfItems |
|
2927 | 549 |
"add children at the end" |
550 |
||
1733 | 551 |
^ self addAll:aCollectionOfItems |
552 |
! |
|
553 |
||
554 |
addFirst:aChildItem |
|
2927 | 555 |
"add a child at the beginning" |
556 |
||
1733 | 557 |
^ self add:aChildItem beforeIndex:1. |
558 |
! |
|
559 |
||
560 |
addLast:anItem |
|
2927 | 561 |
"add a child at the end" |
562 |
||
1733 | 563 |
^ self add:anItem |
564 |
! |
|
565 |
||
1804 | 566 |
remove |
567 |
"remove the item |
|
568 |
" |
|
569 |
parent notNil ifTrue:[ "check whether parent exists" |
|
570 |
parent isHierarchicalItem ifTrue:[parent remove:self] "parent is HierarchicalItem" |
|
571 |
ifFalse:[parent root:nil] "parent is HierarchicalList" |
|
572 |
]. |
|
573 |
^ self |
|
574 |
! |
|
575 |
||
1733 | 576 |
remove:aChild |
577 |
"remove a child |
|
578 |
" |
|
579 |
self removeIndex:(self identityIndexOf:aChild) |
|
580 |
||
581 |
! |
|
582 |
||
583 |
removeAll |
|
584 |
"remove all children |
|
585 |
" |
|
586 |
|size| |
|
587 |
||
1942 | 588 |
(size := children size) ~~ 0 ifTrue:[ |
1733 | 589 |
self removeFromIndex:1 toIndex:size |
590 |
] |
|
591 |
! |
|
592 |
||
593 |
removeAll:aList |
|
594 |
"remove all children in the collection |
|
595 |
" |
|
596 |
|index| |
|
597 |
||
598 |
aList size ~~ 0 ifTrue:[ |
|
599 |
self criticalDo:[ |
|
600 |
aList do:[:el| |
|
601 |
(index := self identityIndexOf:el) ~~ 0 ifTrue:[ |
|
602 |
self removeIndex:index |
|
603 |
] |
|
604 |
] |
|
605 |
] |
|
606 |
]. |
|
607 |
^ aList |
|
608 |
! |
|
609 |
||
1899 | 610 |
removeFromIndex:startIndex |
611 |
"remove the children from startIndex up to end of children |
|
612 |
" |
|
613 |
^ self removeFromIndex:startIndex toIndex:(children size) |
|
614 |
! |
|
615 |
||
1733 | 616 |
removeFromIndex:startIndex toIndex:stopIndex |
617 |
"remove the children from startIndex up to and including |
|
618 |
the child under stopIndex. |
|
619 |
" |
|
2853
e852742cbd10
when the last child is removed,
Claus Gittinger <cg@exept.de>
parents:
2851
diff
changeset
|
620 |
|nrOfChildren stop| |
1899 | 621 |
|
2853
e852742cbd10
when the last child is removed,
Claus Gittinger <cg@exept.de>
parents:
2851
diff
changeset
|
622 |
nrOfChildren := children size. |
1899 | 623 |
|
2853
e852742cbd10
when the last child is removed,
Claus Gittinger <cg@exept.de>
parents:
2851
diff
changeset
|
624 |
(startIndex <= stopIndex and:[startIndex <= nrOfChildren]) ifTrue:[ |
e852742cbd10
when the last child is removed,
Claus Gittinger <cg@exept.de>
parents:
2851
diff
changeset
|
625 |
stop := stopIndex min:nrOfChildren. |
1899 | 626 |
|
627 |
self criticalDo:[ |
|
628 |
self basicRemoveFromIndex:startIndex toIndex:stop |
|
629 |
] |
|
1733 | 630 |
]. |
2853
e852742cbd10
when the last child is removed,
Claus Gittinger <cg@exept.de>
parents:
2851
diff
changeset
|
631 |
|
e852742cbd10
when the last child is removed,
Claus Gittinger <cg@exept.de>
parents:
2851
diff
changeset
|
632 |
children size == 0 ifTrue:[ |
2854
20b890ba0f6c
allow subclasses to define the collapse-behavior
Claus Gittinger <cg@exept.de>
parents:
2853
diff
changeset
|
633 |
self clearExpandedWhenLastChildWasRemoved ifTrue:[ |
20b890ba0f6c
allow subclasses to define the collapse-behavior
Claus Gittinger <cg@exept.de>
parents:
2853
diff
changeset
|
634 |
isExpanded := false. |
20b890ba0f6c
allow subclasses to define the collapse-behavior
Claus Gittinger <cg@exept.de>
parents:
2853
diff
changeset
|
635 |
] |
2853
e852742cbd10
when the last child is removed,
Claus Gittinger <cg@exept.de>
parents:
2851
diff
changeset
|
636 |
]. |
1733 | 637 |
! |
638 |
||
639 |
removeIndex:anIndex |
|
640 |
"remove the child at an index |
|
641 |
" |
|
642 |
anIndex > 0 ifTrue:[ |
|
643 |
self removeFromIndex:anIndex toIndex:anIndex |
|
644 |
] |
|
645 |
! ! |
|
646 |
||
647 |
!HierarchicalItem methodsFor:'basic adding & removing'! |
|
648 |
||
649 |
basicAdd:aChild sortBlock:aBlock |
|
2927 | 650 |
"add a child sorted" |
651 |
||
2357 | 652 |
|size list| |
653 |
||
654 |
size := children size. |
|
655 |
list := Array with:aChild. |
|
656 |
||
657 |
(aBlock notNil and:[size ~~ 0]) ifTrue:[ |
|
658 |
children keysAndValuesDo:[:i :el| |
|
659 |
(aBlock value:aChild value:el) ifTrue:[ |
|
660 |
self basicAddAll:list beforeIndex:i. |
|
661 |
^ aChild |
|
1733 | 662 |
] |
663 |
] |
|
664 |
]. |
|
2357 | 665 |
self basicAddAll:list beforeIndex:(size + 1). |
666 |
^ aChild. |
|
1733 | 667 |
! |
668 |
||
669 |
basicAddAll:aList beforeIndex:anIndex |
|
2927 | 670 |
"add children before an index" |
671 |
||
1602 | 672 |
|coll model notify index size| |
1390 | 673 |
|
1942 | 674 |
size := children size. |
1390 | 675 |
|
676 |
anIndex == 1 ifTrue:[ |
|
677 |
notify := self |
|
678 |
] ifFalse:[ |
|
679 |
anIndex > size ifTrue:[ |
|
680 |
anIndex > (1 + size) ifTrue:[ |
|
2484
92f9e42980ab
correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents:
2476
diff
changeset
|
681 |
^ self subscriptBoundsError:index |
1390 | 682 |
]. |
683 |
notify := self at:size |
|
684 |
] ifFalse:[ |
|
685 |
notify := nil |
|
686 |
] |
|
687 |
]. |
|
1669 | 688 |
children isArray ifTrue:[ |
689 |
children := children asOrderedCollection |
|
690 |
]. |
|
1390 | 691 |
|
692 |
size == 0 ifTrue:[ |
|
693 |
children := OrderedCollection new |
|
694 |
]. |
|
695 |
aList do:[:anItem| anItem parent:self ]. |
|
696 |
children addAll:aList beforeIndex:anIndex. |
|
697 |
||
698 |
(model := self model) isNil ifTrue:[ |
|
699 |
^ aList |
|
700 |
]. |
|
701 |
||
2547 | 702 |
isExpanded ifFalse:[ |
1390 | 703 |
notify notNil ifTrue:[ |
704 |
notify changed |
|
705 |
]. |
|
2547 | 706 |
^ aList |
1390 | 707 |
]. |
708 |
(index := self listIndex) isNil ifTrue:[ |
|
709 |
^ aList |
|
710 |
]. |
|
711 |
||
712 |
children from:1 to:(anIndex - 1) do:[:anItem| |
|
713 |
index := 1 + index + anItem numberOfVisibleChildren |
|
714 |
]. |
|
715 |
coll := OrderedCollection new. |
|
716 |
||
717 |
aList do:[:anItem| |
|
718 |
coll add:anItem. |
|
719 |
anItem addVisibleChildrenTo:coll. |
|
720 |
]. |
|
721 |
model itemAddAll:coll beforeIndex:(index + 1). |
|
722 |
||
723 |
notify notNil ifTrue:[ |
|
724 |
notify changed |
|
725 |
]. |
|
726 |
^ aList |
|
727 |
! |
|
728 |
||
1733 | 729 |
basicRemoveFromIndex:startIndex toIndex:stopIndex |
1390 | 730 |
"remove the children from startIndex up to and including |
2927 | 731 |
the child under stopIndex." |
732 |
||
1390 | 733 |
|model notify |
734 |
index "{ Class:SmallInteger }" |
|
735 |
start "{ Class:SmallInteger }" |
|
736 |
stop "{ Class:SmallInteger }" |
|
737 |
size "{ Class:SmallInteger }" |
|
738 |
| |
|
739 |
size := self children size. |
|
740 |
stop := stopIndex. |
|
741 |
start := startIndex. |
|
742 |
||
743 |
(stop <= size and:[start between:1 and:stop]) ifFalse:[ |
|
2484
92f9e42980ab
correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents:
2476
diff
changeset
|
744 |
^ self subscriptBoundsError:index |
1390 | 745 |
]. |
746 |
start == 1 ifTrue:[ |
|
747 |
notify := self |
|
748 |
] ifFalse:[ |
|
749 |
stop == size ifTrue:[ |
|
750 |
notify := self at:(start - 1) |
|
751 |
] ifFalse:[ |
|
752 |
notify := nil |
|
753 |
] |
|
754 |
]. |
|
755 |
||
756 |
(model := self model) notNil ifTrue:[ |
|
757 |
index := model identityIndexOf:(children at:start). |
|
758 |
size := stop - start + 1. |
|
759 |
] ifFalse:[ |
|
760 |
index := 0 |
|
761 |
]. |
|
1669 | 762 |
|
1390 | 763 |
children from:start to:stop do:[:aChild| |
764 |
index ~~ 0 ifTrue:[ |
|
765 |
size := size + aChild numberOfVisibleChildren |
|
766 |
]. |
|
767 |
aChild parent:nil |
|
768 |
]. |
|
769 |
children removeFromIndex:start toIndex:stop. |
|
770 |
||
771 |
index ~~ 0 ifTrue:[ |
|
772 |
model itemRemoveFromIndex:index toIndex:(index + size - 1) |
|
773 |
]. |
|
774 |
notify notNil ifTrue:[ |
|
775 |
notify changed |
|
776 |
]. |
|
777 |
! ! |
|
778 |
||
779 |
!HierarchicalItem methodsFor:'change & update'! |
|
780 |
||
1606 | 781 |
changed:what with:anArgument |
1390 | 782 |
"the item changed; raise change notification |
2854
20b890ba0f6c
allow subclasses to define the collapse-behavior
Claus Gittinger <cg@exept.de>
parents:
2853
diff
changeset
|
783 |
#icon icon is modified; height and width are unchanged |
20b890ba0f6c
allow subclasses to define the collapse-behavior
Claus Gittinger <cg@exept.de>
parents:
2853
diff
changeset
|
784 |
#hierarchy collapsed/expanded; height and width are unchanged |
20b890ba0f6c
allow subclasses to define the collapse-behavior
Claus Gittinger <cg@exept.de>
parents:
2853
diff
changeset
|
785 |
#redraw redraw but height and width are unchanged |
20b890ba0f6c
allow subclasses to define the collapse-behavior
Claus Gittinger <cg@exept.de>
parents:
2853
diff
changeset
|
786 |
....... all others: the height and width are reset |
1390 | 787 |
" |
1974 | 788 |
|model why| |
1390 | 789 |
|
1974 | 790 |
what ~~ #redraw ifTrue:[ |
791 |
(what ~~ #hierarchy and:[what ~~ #icon]) ifTrue:[ |
|
2081 | 792 |
self class doResetExtentOnChange ifTrue:[ |
793 |
width := height := nil |
|
794 |
]. |
|
1974 | 795 |
]. |
796 |
why := what |
|
2230 | 797 |
] ifFalse:[ |
798 |
why := #redraw |
|
1606 | 799 |
]. |
800 |
(model := self model) notNil ifTrue:[ |
|
1974 | 801 |
model itemChanged:why with:anArgument from:self |
1390 | 802 |
]. |
1974 | 803 |
super changed:why with:anArgument |
1390 | 804 |
! |
805 |
||
2193
41d5d33c9f78
add method to synchronize the model with the changed children order
ca
parents:
2117
diff
changeset
|
806 |
childrenOrderChanged |
41d5d33c9f78
add method to synchronize the model with the changed children order
ca
parents:
2117
diff
changeset
|
807 |
"called if the order of the children changed by a user |
41d5d33c9f78
add method to synchronize the model with the changed children order
ca
parents:
2117
diff
changeset
|
808 |
operation. Update the model and raise a change notification for |
41d5d33c9f78
add method to synchronize the model with the changed children order
ca
parents:
2117
diff
changeset
|
809 |
each item which has changed its position |
2927 | 810 |
triggered by the user operation !!" |
811 |
||
2193
41d5d33c9f78
add method to synchronize the model with the changed children order
ca
parents:
2117
diff
changeset
|
812 |
|model visStart list| |
41d5d33c9f78
add method to synchronize the model with the changed children order
ca
parents:
2117
diff
changeset
|
813 |
|
41d5d33c9f78
add method to synchronize the model with the changed children order
ca
parents:
2117
diff
changeset
|
814 |
self isExpanded ifFalse:[ ^ self ]. "/ not expanded |
2206 | 815 |
children size > 1 ifFalse:[ ^ self ]. |
2193
41d5d33c9f78
add method to synchronize the model with the changed children order
ca
parents:
2117
diff
changeset
|
816 |
|
41d5d33c9f78
add method to synchronize the model with the changed children order
ca
parents:
2117
diff
changeset
|
817 |
model := self model. |
3166 | 818 |
model isNil ifTrue:[^ self]. "/ no model |
2193
41d5d33c9f78
add method to synchronize the model with the changed children order
ca
parents:
2117
diff
changeset
|
819 |
|
41d5d33c9f78
add method to synchronize the model with the changed children order
ca
parents:
2117
diff
changeset
|
820 |
visStart := model identityIndexOf:self. |
2260 | 821 |
visStart == 0 ifTrue:[ |
2305 | 822 |
model root ~~ self ifTrue:[ ^ self ]. |
823 |
"/ I'am the root but switched of by setting #showRoot to false |
|
2260 | 824 |
]. |
2193
41d5d33c9f78
add method to synchronize the model with the changed children order
ca
parents:
2117
diff
changeset
|
825 |
|
41d5d33c9f78
add method to synchronize the model with the changed children order
ca
parents:
2117
diff
changeset
|
826 |
self criticalDo:[ |
41d5d33c9f78
add method to synchronize the model with the changed children order
ca
parents:
2117
diff
changeset
|
827 |
list := OrderedCollection new. |
41d5d33c9f78
add method to synchronize the model with the changed children order
ca
parents:
2117
diff
changeset
|
828 |
self addVisibleChildrenTo:list. |
41d5d33c9f78
add method to synchronize the model with the changed children order
ca
parents:
2117
diff
changeset
|
829 |
|
41d5d33c9f78
add method to synchronize the model with the changed children order
ca
parents:
2117
diff
changeset
|
830 |
list do:[:el| |
41d5d33c9f78
add method to synchronize the model with the changed children order
ca
parents:
2117
diff
changeset
|
831 |
visStart := visStart + 1. |
41d5d33c9f78
add method to synchronize the model with the changed children order
ca
parents:
2117
diff
changeset
|
832 |
|
41d5d33c9f78
add method to synchronize the model with the changed children order
ca
parents:
2117
diff
changeset
|
833 |
(model at:visStart ifAbsent:el) ~~ el ifTrue:[ |
41d5d33c9f78
add method to synchronize the model with the changed children order
ca
parents:
2117
diff
changeset
|
834 |
model at:visStart put:el |
41d5d33c9f78
add method to synchronize the model with the changed children order
ca
parents:
2117
diff
changeset
|
835 |
]. |
41d5d33c9f78
add method to synchronize the model with the changed children order
ca
parents:
2117
diff
changeset
|
836 |
] |
41d5d33c9f78
add method to synchronize the model with the changed children order
ca
parents:
2117
diff
changeset
|
837 |
]. |
41d5d33c9f78
add method to synchronize the model with the changed children order
ca
parents:
2117
diff
changeset
|
838 |
! |
41d5d33c9f78
add method to synchronize the model with the changed children order
ca
parents:
2117
diff
changeset
|
839 |
|
1843 | 840 |
fontChanged |
841 |
"called if the font has changed |
|
842 |
" |
|
843 |
width := height := nil. |
|
844 |
||
845 |
children size ~~ 0 ifTrue:[ |
|
846 |
children do:[:el| el fontChanged ]. |
|
847 |
]. |
|
848 |
! |
|
849 |
||
1390 | 850 |
hierarchyChanged |
851 |
"hierarchy changed; optimize redrawing |
|
852 |
" |
|
853 |
self changed:#hierarchy with:nil |
|
854 |
! |
|
855 |
||
856 |
iconChanged |
|
857 |
"icon changed; optimize redrawing |
|
858 |
" |
|
859 |
self changed:#icon with:nil |
|
860 |
! ! |
|
861 |
||
862 |
!HierarchicalItem methodsFor:'enumerating'! |
|
863 |
||
1804 | 864 |
collect:aBlock |
865 |
"for each child in the receiver, evaluate the argument, aBlock |
|
2927 | 866 |
and return a new collection with the results" |
867 |
||
2008
916175defb9e
add none critical blocks for recursive operations (optimize)
ca
parents:
1974
diff
changeset
|
868 |
|coll| |
1804 | 869 |
|
2081 | 870 |
coll := OrderedCollection new. |
871 |
self do:[:el| coll add:(aBlock value:el) ]. |
|
2927 | 872 |
^ coll |
1804 | 873 |
! |
874 |
||
2465 | 875 |
contains:aBlock |
876 |
"return true if aBlock returns true for any of the receivers items" |
|
877 |
||
878 |
self do:[:el | (aBlock value:el) ifTrue:[^ true] ]. |
|
879 |
^ false |
|
880 |
! |
|
881 |
||
1390 | 882 |
do:aOneArgBlock |
2879 | 883 |
"evaluate a block for each child" |
884 |
||
2081 | 885 |
^ self from:1 do:aOneArgBlock |
1390 | 886 |
! |
887 |
||
888 |
from:startIndex do:aOneArgBlock |
|
889 |
"evaluate a block on each child starting with the |
|
890 |
child at startIndex to the end. |
|
891 |
" |
|
2117 | 892 |
^ self from:startIndex to:nil do:aOneArgBlock |
2081 | 893 |
! |
894 |
||
895 |
from:startIndex reverseDo:aOneArgBlock |
|
896 |
"evaluate a block on each child starting at end to the startIndex |
|
897 |
" |
|
2117 | 898 |
^ self from:startIndex to:nil reverseDo:aOneArgBlock |
1390 | 899 |
! |
900 |
||
901 |
from:startIndex to:endIndex do:aOneArgBlock |
|
902 |
"evaluate a block on each child starting with the |
|
903 |
child at startIndex to the endIndex. |
|
904 |
" |
|
2081 | 905 |
|res| |
906 |
||
907 |
self size < startIndex ifTrue:[^ nil]. |
|
908 |
res := nil. |
|
909 |
||
910 |
self criticalDo:[ |
|
2117 | 911 |
res := self nonCriticalFrom:startIndex to:endIndex do:aOneArgBlock |
2008
916175defb9e
add none critical blocks for recursive operations (optimize)
ca
parents:
1974
diff
changeset
|
912 |
]. |
2081 | 913 |
^ res |
1390 | 914 |
! |
915 |
||
916 |
from:startIndex to:endIndex reverseDo:aOneArgBlock |
|
917 |
"evaluate a block on each child starting with the |
|
918 |
child at endIndex to the startIndex. |
|
919 |
" |
|
2081 | 920 |
|res| |
921 |
||
922 |
self size < startIndex ifTrue:[^ nil]. |
|
923 |
res := nil. |
|
924 |
||
925 |
self criticalDo:[ |
|
2117 | 926 |
res := self nonCriticalFrom:startIndex to:endIndex reverseDo:aOneArgBlock |
2008
916175defb9e
add none critical blocks for recursive operations (optimize)
ca
parents:
1974
diff
changeset
|
927 |
]. |
2081 | 928 |
^ res |
1390 | 929 |
! |
930 |
||
1966 | 931 |
keysAndValuesDo:aTwoArgBlock |
932 |
"evaluate the argument, aBlock for every child, |
|
2081 | 933 |
passing both index and element as arguments. |
934 |
" |
|
935 |
|key res| |
|
1966 | 936 |
|
2081 | 937 |
key := 1. |
938 |
res := nil. |
|
939 |
||
940 |
self do:[:el| |
|
941 |
res := el value:key value:el. |
|
942 |
key := key + 1. |
|
1966 | 943 |
]. |
2081 | 944 |
^ res |
1966 | 945 |
! |
946 |
||
947 |
keysAndValuesReverseDo:aTwoArgBlock |
|
948 |
"evaluate the argument, aBlock in reverse order for every |
|
2081 | 949 |
child, passing both index and element as arguments. |
950 |
" |
|
951 |
|res| |
|
1966 | 952 |
|
2081 | 953 |
self size == 0 ifTrue:[^ nil]. |
954 |
res := nil. |
|
955 |
||
956 |
self criticalDo:[ |
|
2117 | 957 |
res := self nonCriticalKeysAndValuesReverseDo:aTwoArgBlock |
1966 | 958 |
]. |
2081 | 959 |
^ res |
1966 | 960 |
! |
961 |
||
1804 | 962 |
recursiveCollect:aBlock |
963 |
"for each child in the receiver, evaluate the argument, aBlock |
|
964 |
and return a new collection with the results |
|
965 |
" |
|
2008
916175defb9e
add none critical blocks for recursive operations (optimize)
ca
parents:
1974
diff
changeset
|
966 |
|coll| |
1804 | 967 |
|
2008
916175defb9e
add none critical blocks for recursive operations (optimize)
ca
parents:
1974
diff
changeset
|
968 |
coll := OrderedCollection new. |
916175defb9e
add none critical blocks for recursive operations (optimize)
ca
parents:
1974
diff
changeset
|
969 |
self recursiveDo:[:el| coll add:(aBlock value:el) ]. |
916175defb9e
add none critical blocks for recursive operations (optimize)
ca
parents:
1974
diff
changeset
|
970 |
^ coll |
1804 | 971 |
! |
972 |
||
1390 | 973 |
recursiveDo:aOneArgBlock |
974 |
"evaluate a block on each item and all the sub-items |
|
975 |
" |
|
976 |
self do:[:aChild| |
|
977 |
aOneArgBlock value:aChild. |
|
2117 | 978 |
aChild nonCriticalRecursiveDo:aOneArgBlock |
1390 | 979 |
]. |
980 |
! |
|
981 |
||
1804 | 982 |
recursiveReverseDo:aOneArgBlock |
983 |
"evaluate a block on each item and all the sub-items; |
|
984 |
proccesing children in reverse direction |
|
985 |
" |
|
2008
916175defb9e
add none critical blocks for recursive operations (optimize)
ca
parents:
1974
diff
changeset
|
986 |
self reverseDo:[:aChild| |
2117 | 987 |
aChild nonCriticalRecursiveReverseDo:aOneArgBlock. |
2008
916175defb9e
add none critical blocks for recursive operations (optimize)
ca
parents:
1974
diff
changeset
|
988 |
aOneArgBlock value:aChild. |
1804 | 989 |
]. |
990 |
! |
|
991 |
||
992 |
recursiveSelect:aBlock |
|
993 |
"return a new collection with all children and subChildren from the receiver, for which |
|
994 |
the argument aBlock evaluates to true. |
|
995 |
" |
|
2008
916175defb9e
add none critical blocks for recursive operations (optimize)
ca
parents:
1974
diff
changeset
|
996 |
|coll| |
1804 | 997 |
|
2008
916175defb9e
add none critical blocks for recursive operations (optimize)
ca
parents:
1974
diff
changeset
|
998 |
coll := OrderedCollection new. |
916175defb9e
add none critical blocks for recursive operations (optimize)
ca
parents:
1974
diff
changeset
|
999 |
self recursiveDo:[:el| (aBlock value:el) ifTrue:[coll add:el] ]. |
916175defb9e
add none critical blocks for recursive operations (optimize)
ca
parents:
1974
diff
changeset
|
1000 |
^ coll |
1804 | 1001 |
! |
1002 |
||
1390 | 1003 |
reverseDo:aOneArgBlock |
2081 | 1004 |
"evaluate a block on each child in reverse direction |
1390 | 1005 |
" |
2081 | 1006 |
^ self from:1 reverseDo:aOneArgBlock |
1804 | 1007 |
! |
1008 |
||
1009 |
select:aBlock |
|
2081 | 1010 |
"return a new collection with all items from the receiver, for which |
1804 | 1011 |
the argument aBlock evaluates to true. |
1012 |
" |
|
2008
916175defb9e
add none critical blocks for recursive operations (optimize)
ca
parents:
1974
diff
changeset
|
1013 |
|coll| |
1831
8efa00e1247a
sort stuff; height fix when label changes
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
1014 |
|
2081 | 1015 |
coll := OrderedCollection new. |
1016 |
self do:[:el| (aBlock value:el) ifTrue:[coll add:el] ]. |
|
1017 |
^ coll |
|
1876 | 1018 |
! |
1019 |
||
1020 |
withAllDo:aOneArgBlock |
|
2081 | 1021 |
"evaluate the block on each item and subitem including self |
1876 | 1022 |
" |
2081 | 1023 |
aOneArgBlock value:self. |
1024 |
||
1025 |
self do:[:el| |
|
1026 |
aOneArgBlock value:el. |
|
2117 | 1027 |
el nonCriticalRecursiveDo:aOneArgBlock. |
1883 | 1028 |
]. |
1029 |
! ! |
|
1804 | 1030 |
|
1031 |
!HierarchicalItem methodsFor:'enumerating parents'! |
|
1032 |
||
1033 |
parentsDetect:aBlock |
|
1034 |
"find the first parent, for which evaluation of the block returns |
|
1035 |
true; if none does so, report an error |
|
1036 |
" |
|
1037 |
^ self parentsDetect:aBlock ifNone:[self errorNotFound] |
|
1038 |
! |
|
1039 |
||
1040 |
parentsDetect:aBlock ifNone:anExceptionBlock |
|
1041 |
"find the first parent, for which evaluation of the block returns |
|
1042 |
true; if none does so, return the evaluation of anExceptionBlock |
|
1043 |
" |
|
1044 |
|prnt| |
|
1045 |
||
1046 |
prnt := self. |
|
1047 |
||
1048 |
self criticalDo:[ |
|
1049 |
[(prnt := prnt parent) notNil and:[prnt isHierarchicalItem]] whileTrue:[ |
|
1050 |
(aBlock value:prnt) ifTrue:[^ prnt] |
|
1051 |
] |
|
1052 |
]. |
|
1053 |
^ anExceptionBlock value |
|
1054 |
! |
|
1055 |
||
1056 |
parentsDo:aBlock |
|
1057 |
"evaluate a block on each parent |
|
1058 |
" |
|
1059 |
|prnt| |
|
1060 |
||
1061 |
prnt := self. |
|
1062 |
||
1063 |
self criticalDo:[ |
|
1064 |
[(prnt := prnt parent) notNil and:[prnt isHierarchicalItem]] whileTrue:[ |
|
1065 |
aBlock value:prnt |
|
1066 |
] |
|
1067 |
]. |
|
1390 | 1068 |
! ! |
1069 |
||
1070 |
!HierarchicalItem methodsFor:'initialization'! |
|
1071 |
||
1072 |
initialize |
|
1073 |
isExpanded := false |
|
1074 |
! ! |
|
1075 |
||
1076 |
!HierarchicalItem methodsFor:'private'! |
|
1077 |
||
1078 |
addVisibleChildrenTo:aList |
|
2547 | 1079 |
"add all visible children and sub-children to the list" |
1080 |
||
1081 |
isExpanded ifFalse:[^ self]. |
|
1390 | 1082 |
|
2117 | 1083 |
self nonCriticalFrom:1 to:nil do:[:el| |
2081 | 1084 |
aList add:el. |
1085 |
el addVisibleChildrenTo:aList. |
|
1086 |
]. |
|
1390 | 1087 |
! |
1088 |
||
2854
20b890ba0f6c
allow subclasses to define the collapse-behavior
Claus Gittinger <cg@exept.de>
parents:
2853
diff
changeset
|
1089 |
clearExpandedWhenLastChildWasRemoved |
20b890ba0f6c
allow subclasses to define the collapse-behavior
Claus Gittinger <cg@exept.de>
parents:
2853
diff
changeset
|
1090 |
^ true |
20b890ba0f6c
allow subclasses to define the collapse-behavior
Claus Gittinger <cg@exept.de>
parents:
2853
diff
changeset
|
1091 |
! |
20b890ba0f6c
allow subclasses to define the collapse-behavior
Claus Gittinger <cg@exept.de>
parents:
2853
diff
changeset
|
1092 |
|
1733 | 1093 |
criticalDo:aBlock |
1094 |
|model| |
|
1095 |
||
1096 |
(model := self model) notNil ifTrue:[ |
|
1097 |
model recursionLock critical:aBlock |
|
1098 |
] ifFalse:[ |
|
1099 |
aBlock value |
|
1100 |
] |
|
1101 |
! |
|
1102 |
||
1390 | 1103 |
listIndex |
1104 |
"returns the visible index or nil; for a none visible root |
|
1105 |
0 is returned |
|
1106 |
" |
|
1107 |
|index model| |
|
1108 |
||
1109 |
(model := self model) notNil ifTrue:[ |
|
1110 |
index := model identityIndexOf:self. |
|
1111 |
||
1112 |
(index ~~ 0 or:[parent == model]) ifTrue:[ |
|
1113 |
^ index |
|
1114 |
] |
|
1115 |
]. |
|
1116 |
^ nil |
|
1117 |
! |
|
1118 |
||
1119 |
numberOfVisibleChildren |
|
2547 | 1120 |
"returns number of all visible children including subchildren" |
1121 |
||
2081 | 1122 |
|size| |
1123 |
||
2547 | 1124 |
isExpanded ifFalse:[^ 0]. |
2081 | 1125 |
size := 0. |
1126 |
||
2117 | 1127 |
self nonCriticalFrom:1 to:nil do:[:el| |
2081 | 1128 |
size := 1 + size + el numberOfVisibleChildren |
1390 | 1129 |
]. |
2081 | 1130 |
^ size |
1390 | 1131 |
! |
1132 |
||
1133 |
parentOrModel |
|
1134 |
"returns the parent without checking for item or model |
|
1135 |
" |
|
1136 |
^ parent |
|
1137 |
! |
|
1138 |
||
1139 |
setExpanded:aBoolean |
|
2547 | 1140 |
"set expanded flag without any computation or notification" |
1141 |
||
1390 | 1142 |
isExpanded := aBoolean |
1143 |
! ! |
|
1144 |
||
2493 | 1145 |
!HierarchicalItem methodsFor:'private-displaying'! |
1540
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1146 |
|
1606 | 1147 |
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
|
1148 |
"display the label at x@y |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1149 |
" |
2484
92f9e42980ab
correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents:
2476
diff
changeset
|
1150 |
|y0| |
1540
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1151 |
|
1606 | 1152 |
lH ~~ 0 ifTrue:[ |
1153 |
y0 := y - (lH + 1 - h // 2). |
|
1540
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1154 |
|
2484
92f9e42980ab
correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents:
2476
diff
changeset
|
1155 |
y0 := y0 + (aLabel ascentOn:aGC). |
92f9e42980ab
correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents:
2476
diff
changeset
|
1156 |
(aLabel isString not |
92f9e42980ab
correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents:
2476
diff
changeset
|
1157 |
or:[(aLabel includes:(Character cr)) not]) ifTrue:[ |
1606 | 1158 |
^ aLabel displayOn:aGC x:x y:y0 |
1159 |
]. |
|
1540
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1160 |
|
1606 | 1161 |
aLabel asCollectionOfLines do:[:el| |
1162 |
el displayOn:aGC x:x y:y0. |
|
2484
92f9e42980ab
correct use of ascentOn: for display
Claus Gittinger <cg@exept.de>
parents:
2476
diff
changeset
|
1163 |
y0 := y0 + (el heightOn:aGC) |
1606 | 1164 |
] |
1540
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1165 |
]. |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1166 |
! |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1167 |
|
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1168 |
heightOf:aLabel on:aGC |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1169 |
"returns the height of the label or 0 |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1170 |
" |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1171 |
|h| |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1172 |
|
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1173 |
aLabel isSequenceable ifFalse:[ |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1174 |
^ aLabel notNil ifTrue:[aLabel heightOn:aGC] ifFalse:[0] |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1175 |
]. |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1176 |
|
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1177 |
aLabel isString ifFalse:[ |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1178 |
h := 0. |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1179 |
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
|
1180 |
^ h |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1181 |
]. |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1182 |
|
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1183 |
h := 1 + (aLabel occurrencesOf:(Character cr)). |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1184 |
^ h * (aGC font height) |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1185 |
! |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1186 |
|
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1187 |
widthOf:aLabel on:aGC |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1188 |
"returns the height of the label or 0 |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1189 |
" |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1190 |
|w| |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1191 |
|
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1192 |
aLabel isSequenceable ifFalse:[ |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1193 |
^ aLabel notNil ifTrue:[aLabel widthOn:aGC] ifFalse:[0] |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1194 |
]. |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1195 |
|
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1196 |
aLabel isString ifFalse:[ |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1197 |
w := -5. |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1198 |
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
|
1199 |
^ w |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1200 |
]. |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1201 |
|
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1202 |
(aLabel indexOf:(Character cr)) == 0 ifTrue:[ |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1203 |
^ aLabel widthOn:aGC |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1204 |
]. |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1205 |
|
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1206 |
w := 0. |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1207 |
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
|
1208 |
^ w |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1209 |
! ! |
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1210 |
|
2493 | 1211 |
!HierarchicalItem methodsFor:'private-enumerating'! |
2008
916175defb9e
add none critical blocks for recursive operations (optimize)
ca
parents:
1974
diff
changeset
|
1212 |
|
2117 | 1213 |
nonCriticalDo:aOneArgBlock |
1214 |
"evaluate a block noncritical on each child. |
|
1215 |
" |
|
1216 |
^ self nonCriticalFrom:1 to:nil do:aOneArgBlock |
|
1217 |
! |
|
1218 |
||
1219 |
nonCriticalFrom:startIndex to:endIndex do:aOneArgBlock |
|
1220 |
"evaluate a block noncritical on each child starting with the |
|
2081 | 1221 |
child at startIndex to the endIndex (if nil to end of list). |
1222 |
" |
|
1223 |
|list size resp| |
|
1224 |
||
1225 |
list := self children. |
|
1226 |
size := list size. |
|
1227 |
||
1228 |
startIndex > size ifTrue:[^ nil]. |
|
1229 |
resp := nil. |
|
1230 |
||
1231 |
endIndex notNil ifTrue:[ |
|
1232 |
size := size min:endIndex |
|
1233 |
]. |
|
1234 |
startIndex to:size do:[:i| |item| |
|
1235 |
item := list at:i ifAbsent:nil. |
|
1236 |
item isNil ifTrue:[^ resp]. |
|
1237 |
resp := aOneArgBlock value:item. |
|
1238 |
]. |
|
1239 |
^ resp |
|
1240 |
! |
|
1241 |
||
2117 | 1242 |
nonCriticalFrom:startIndex to:endIndex reverseDo:aOneArgBlock |
1243 |
"evaluate a block non critical on each child starting with the |
|
2081 | 1244 |
child at endIndex (if nil to end of list) to startIndex. |
1245 |
" |
|
1246 |
|list size resp| |
|
1247 |
||
1248 |
list := self children. |
|
1249 |
size := list size. |
|
1250 |
resp := nil. |
|
1251 |
||
1252 |
endIndex notNil ifTrue:[ |
|
1253 |
size := size min:endIndex |
|
1254 |
]. |
|
1255 |
size to:startIndex by:-1 do:[:i| |item| |
|
1256 |
item := list at:i ifAbsent:nil. |
|
1257 |
item isNil ifTrue:[^ resp]. |
|
1258 |
resp := aOneArgBlock value:item. |
|
1259 |
]. |
|
1260 |
^ resp |
|
1261 |
! |
|
1262 |
||
2117 | 1263 |
nonCriticalKeysAndValuesReverseDo:aOneArgBlock |
2081 | 1264 |
"evaluate the argument, aBlock in reverse order for every |
1265 |
child, passing both index and element as arguments. |
|
1266 |
" |
|
1267 |
|list size resp| |
|
1268 |
||
1269 |
list := self children. |
|
1270 |
size := list size. |
|
1271 |
resp := nil. |
|
1272 |
||
1273 |
size to:1 by:-1 do:[:i| |item| |
|
1274 |
item := list at:i ifAbsent:nil. |
|
1275 |
item isNil ifTrue:[^ resp]. |
|
1276 |
resp := aOneArgBlock value:i value:item. |
|
1277 |
]. |
|
1278 |
^ resp |
|
1279 |
! |
|
1280 |
||
2117 | 1281 |
nonCriticalRecursiveDo:anOneArgBlock |
1282 |
"evaluate the block non critical on each item and all the sub-items |
|
2008
916175defb9e
add none critical blocks for recursive operations (optimize)
ca
parents:
1974
diff
changeset
|
1283 |
" |
2117 | 1284 |
self nonCriticalFrom:1 to:nil do:[:aChild| |
2081 | 1285 |
anOneArgBlock value:aChild. |
2117 | 1286 |
aChild nonCriticalRecursiveDo:anOneArgBlock |
2008
916175defb9e
add none critical blocks for recursive operations (optimize)
ca
parents:
1974
diff
changeset
|
1287 |
]. |
916175defb9e
add none critical blocks for recursive operations (optimize)
ca
parents:
1974
diff
changeset
|
1288 |
! |
916175defb9e
add none critical blocks for recursive operations (optimize)
ca
parents:
1974
diff
changeset
|
1289 |
|
2117 | 1290 |
nonCriticalRecursiveReverseDo:anOneArgBlock |
1291 |
"evaluate the block non critical on each item and all the sub-items; |
|
2008
916175defb9e
add none critical blocks for recursive operations (optimize)
ca
parents:
1974
diff
changeset
|
1292 |
proccesing children in reverse direction |
916175defb9e
add none critical blocks for recursive operations (optimize)
ca
parents:
1974
diff
changeset
|
1293 |
" |
2117 | 1294 |
self nonCriticalFrom:1 to:nil reverseDo:[:aChild| |
1295 |
aChild nonCriticalRecursiveReverseDo:anOneArgBlock. |
|
2081 | 1296 |
anOneArgBlock value:aChild. |
2008
916175defb9e
add none critical blocks for recursive operations (optimize)
ca
parents:
1974
diff
changeset
|
1297 |
]. |
2294 | 1298 |
! |
1299 |
||
1300 |
nonCriticalRecursiveSort:aSortBlock |
|
1301 |
"evaluate a block noncritical on each child. |
|
1302 |
" |
|
1303 |
|unsorted sorted| |
|
1304 |
||
1305 |
unsorted := children. |
|
1306 |
||
1307 |
unsorted size ~~ 0 ifTrue:[ |
|
1308 |
sorted := unsorted sort:aSortBlock. |
|
1309 |
sorted do:[:el| el nonCriticalRecursiveSort:aSortBlock ]. |
|
1310 |
children := sorted. |
|
1311 |
]. |
|
2008
916175defb9e
add none critical blocks for recursive operations (optimize)
ca
parents:
1974
diff
changeset
|
1312 |
! ! |
916175defb9e
add none critical blocks for recursive operations (optimize)
ca
parents:
1974
diff
changeset
|
1313 |
|
2493 | 1314 |
!HierarchicalItem methodsFor:'private-hierarchy'! |
1390 | 1315 |
|
1316 |
recursiveSetCollapsed |
|
2547 | 1317 |
"collapse all children and sub-children without notifications" |
1318 |
||
1390 | 1319 |
isExpanded := false. |
1320 |
||
2547 | 1321 |
"/ do not call #size: children will be autoloaded !!!! |
2081 | 1322 |
children size ~~ 0 ifTrue:[ |
2547 | 1323 |
self nonCriticalFrom:1 to:nil do:[:el| el canRecursiveCollapse ifTrue:[el recursiveSetCollapsed]]. |
1390 | 1324 |
] |
1325 |
! |
|
1326 |
||
1327 |
recursiveSetExpandedAndAddToList:aList |
|
1328 |
"expand all children and sub-children without notifications; |
|
2547 | 1329 |
add children to list" |
1330 |
||
1390 | 1331 |
isExpanded := true. |
1332 |
||
2547 | 1333 |
self do:[:eachChild| |
2601 | 1334 |
aList add:eachChild. |
1335 |
||
2547 | 1336 |
eachChild canRecursiveExpand ifTrue:[ |
1337 |
eachChild recursiveSetExpandedAndAddToList:aList. |
|
1338 |
]. |
|
2081 | 1339 |
]. |
1390 | 1340 |
! ! |
1341 |
||
2851 | 1342 |
!HierarchicalItem methodsFor:'protocol-accessing'! |
1390 | 1343 |
|
1344 |
children |
|
2851 | 1345 |
"returns a list of children |
2927 | 1346 |
*** to optimize: redefine by subClass" |
1347 |
||
1390 | 1348 |
|model| |
1349 |
||
1350 |
children isNil ifTrue:[ |
|
1351 |
(model := self model) notNil ifTrue:[ |
|
1486 | 1352 |
children := model childrenFor:self |
1390 | 1353 |
]. |
1354 |
]. |
|
1355 |
^ children |
|
1356 |
! |
|
1357 |
||
1358 |
icon |
|
1359 |
"returns the icon or nil; |
|
1360 |
*** to optimize:redefine by subClass |
|
1361 |
" |
|
1362 |
|model| |
|
1363 |
||
1364 |
(model := self model) notNil ifTrue:[ |
|
1365 |
^ model iconFor:self |
|
1366 |
]. |
|
1367 |
^ nil |
|
1368 |
! |
|
1369 |
||
1370 |
label |
|
1371 |
"returns the label displayed on aGC; |
|
1372 |
*** to optimize:redefine by subClass |
|
1373 |
" |
|
1374 |
|model| |
|
1375 |
||
1376 |
(model := self model) notNil ifTrue:[ |
|
1377 |
^ model labelFor:self |
|
1378 |
]. |
|
1379 |
^ nil |
|
1380 |
||
1381 |
! |
|
1382 |
||
1383 |
middleButtonMenu |
|
2602 | 1384 |
"returns the items middleButtonMenu or nil if no menu is defined. |
1385 |
If nil is returned, the view is asked for a menu. |
|
1390 | 1386 |
" |
3337 | 1387 |
<resource: #programMenu> |
1388 |
||
1390 | 1389 |
|model| |
1390 |
||
1391 |
(model := self model) notNil ifTrue:[ |
|
1392 |
^ model middleButtonMenuFor:self |
|
1393 |
]. |
|
1394 |
^ nil |
|
1831
8efa00e1247a
sort stuff; height fix when label changes
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
1395 |
! |
8efa00e1247a
sort stuff; height fix when label changes
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
1396 |
|
8efa00e1247a
sort stuff; height fix when label changes
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
1397 |
recursiveSortChildren:aSortBlock |
8efa00e1247a
sort stuff; height fix when label changes
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
1398 |
|children| |
8efa00e1247a
sort stuff; height fix when label changes
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
1399 |
|
2832 | 1400 |
(children := self children) notEmptyOrNil ifTrue:[ |
1831
8efa00e1247a
sort stuff; height fix when label changes
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
1401 |
self criticalDo:[ |
8efa00e1247a
sort stuff; height fix when label changes
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
1402 |
children sort:aSortBlock. |
8efa00e1247a
sort stuff; height fix when label changes
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
1403 |
children do:[:aChild| aChild recursiveSortChildren:aSortBlock ] |
8efa00e1247a
sort stuff; height fix when label changes
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
1404 |
] |
8efa00e1247a
sort stuff; height fix when label changes
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
1405 |
]. |
8efa00e1247a
sort stuff; height fix when label changes
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
1406 |
! |
8efa00e1247a
sort stuff; height fix when label changes
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
1407 |
|
8efa00e1247a
sort stuff; height fix when label changes
Claus Gittinger <cg@exept.de>
parents:
1818
diff
changeset
|
1408 |
sortChildren:aSortBlock |
2708 | 1409 |
"sort the children inplace using the 2-arg block sortBlock for comparison" |
1410 |
||
1411 |
<resource: #obsolete> |
|
1412 |
self obsoleteMethodWarning:'use #sort:'. |
|
2252 | 1413 |
self sort:aSortBlock. |
1390 | 1414 |
! ! |
1415 |
||
2851 | 1416 |
!HierarchicalItem methodsFor:'protocol-displaying'! |
1390 | 1417 |
|
1532
56e0fafc4349
change display protocol for item
Claus Gittinger <cg@exept.de>
parents:
1489
diff
changeset
|
1418 |
displayOn:aGC x:x y:y h:h |
1390 | 1419 |
"draw the receiver in the graphicsContext, aGC. |
1420 |
" |
|
1421 |
|label |
|
1398 | 1422 |
x0 "{ Class:SmallInteger }" |
1390 | 1423 |
| |
1540
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1424 |
(label := self label) isNil ifTrue:[^ self]. |
1398 | 1425 |
|
1426 |
(label isSequenceable and:[label isString not]) ifFalse:[ |
|
1606 | 1427 |
^ self displayLabel:label h:(self heightOn:aGC) on:aGC x:x y:y h:h |
1398 | 1428 |
]. |
1429 |
||
1540
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1430 |
x0 := x. |
1398 | 1431 |
label do:[:el| |
1432 |
el notNil ifTrue:[ |
|
1606 | 1433 |
self displayLabel:el h:(self heightOf:el on:aGC) on:aGC x:x0 y:y h:h. |
1398 | 1434 |
x0 := x0 + 5 + (el widthOn:aGC). |
1540
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1435 |
]. |
1390 | 1436 |
] |
1437 |
! |
|
1438 |
||
1439 |
heightOn:aGC |
|
1440 |
"return the width of the receiver, if it is to be displayed on aGC |
|
1441 |
" |
|
1606 | 1442 |
height isNil ifTrue:[ |
1443 |
height := self heightOf:(self label) on:aGC |
|
1444 |
]. |
|
1445 |
^ height |
|
1390 | 1446 |
! |
1447 |
||
1448 |
widthOn:aGC |
|
1449 |
"return the width of the receiver, if it is to be displayed on aGC |
|
1450 |
" |
|
1606 | 1451 |
width isNil ifTrue:[ |
1452 |
width := self widthOf:(self label) on:aGC |
|
1453 |
]. |
|
1454 |
^ width |
|
1455 |
||
1390 | 1456 |
! ! |
1457 |
||
2851 | 1458 |
!HierarchicalItem methodsFor:'protocol-event processing'! |
2313 | 1459 |
|
1460 |
processButtonPress:button x:x y:y |
|
1461 |
"a mouse button was pressed in my label. |
|
2519 | 1462 |
Return true, if the event is eaten (ignored by the gc). |
1463 |
On default false is returned (should be handled by the gc). |
|
1464 |
" |
|
1465 |
^ false |
|
1466 |
! |
|
1467 |
||
1468 |
processButtonPress:button x:x y:y on:aGC |
|
1469 |
"a mouse button was pressed in my label. |
|
1470 |
Return true, if the event is eaten (ignored by the gc). |
|
1471 |
On default false is returned (should be handled by the gc). |
|
1472 |
" |
|
1473 |
^ self processButtonPress:button x:x y:y |
|
1474 |
! |
|
1475 |
||
1476 |
processButtonPressOnIcon:button on:aGC |
|
1477 |
"a mouse button was pressed in my icon. |
|
1478 |
Return true, if the event is eaten (ignored by the gc). |
|
1479 |
On default false is returned (should be handled by the gc). |
|
2313 | 1480 |
" |
1481 |
^ false |
|
1482 |
! ! |
|
1483 |
||
2851 | 1484 |
!HierarchicalItem methodsFor:'protocol-monitoring'! |
1390 | 1485 |
|
1486 |
monitoringCycle |
|
1487 |
"called all 'n' seconds by the model, if the monitoring |
|
1488 |
cycle is enabled. The item can perform some checks, .. |
|
1489 |
**** can be redefined by subclass to perform some actions |
|
1490 |
" |
|
1491 |
! ! |
|
1492 |
||
2851 | 1493 |
!HierarchicalItem methodsFor:'protocol-queries'! |
1390 | 1494 |
|
2305 | 1495 |
canCollapse |
1496 |
"called before collapsing the item; can be redefined |
|
2547 | 1497 |
by subclass to omit the collapse operation" |
1498 |
||
1499 |
^ isExpanded |
|
2305 | 1500 |
! |
1501 |
||
1502 |
canExpand |
|
1503 |
"called before expanding the item; can be redefined |
|
2549 | 1504 |
by subclass to omit the expand operation" |
2547 | 1505 |
|
2549 | 1506 |
^ self hasChildren |
2547 | 1507 |
! |
1508 |
||
1509 |
canRecursiveCollapse |
|
1510 |
"called before collapsing the item; can be redefined |
|
1511 |
by subclass to omit the collapse operation " |
|
1512 |
||
1513 |
^ self canCollapse |
|
1514 |
! |
|
1515 |
||
1516 |
canRecursiveExpand |
|
1517 |
"called before expanding the item; can be redefined |
|
1518 |
by subclass to omit the collapse operation" |
|
1519 |
||
1520 |
^ self canExpand |
|
2305 | 1521 |
! |
1522 |
||
1571 | 1523 |
drawHorizontalLineUpToText |
1524 |
"draw the horizizontal line for the selected item up to the text |
|
1525 |
or on default to the start of the the vertical line; only used by |
|
1526 |
the hierarchical view |
|
1527 |
" |
|
1528 |
^ false |
|
1529 |
! |
|
1530 |
||
1390 | 1531 |
hasChildren |
2851 | 1532 |
"checks whether the item has children; |
1533 |
the list needs not to be loaded yet( example. FileDirectory ). |
|
1534 |
*** to optimize: redefine in subClass |
|
1390 | 1535 |
" |
2081 | 1536 |
^ self children size ~~ 0 |
1390 | 1537 |
! |
1538 |
||
2201
aa74fa6137a5
make indicator dependent on hasIndicator and not hasChildren
ca
parents:
2193
diff
changeset
|
1539 |
hasIndicator |
aa74fa6137a5
make indicator dependent on hasIndicator and not hasChildren
ca
parents:
2193
diff
changeset
|
1540 |
"on default the indicator is drawn if the item |
aa74fa6137a5
make indicator dependent on hasIndicator and not hasChildren
ca
parents:
2193
diff
changeset
|
1541 |
has children |
aa74fa6137a5
make indicator dependent on hasIndicator and not hasChildren
ca
parents:
2193
diff
changeset
|
1542 |
" |
aa74fa6137a5
make indicator dependent on hasIndicator and not hasChildren
ca
parents:
2193
diff
changeset
|
1543 |
^ self hasChildren |
aa74fa6137a5
make indicator dependent on hasIndicator and not hasChildren
ca
parents:
2193
diff
changeset
|
1544 |
! |
aa74fa6137a5
make indicator dependent on hasIndicator and not hasChildren
ca
parents:
2193
diff
changeset
|
1545 |
|
2305 | 1546 |
isSelectable |
1547 |
"returns true if the item is selectable otherwise false |
|
1548 |
" |
|
1549 |
^ true |
|
1550 |
! |
|
1551 |
||
1390 | 1552 |
string |
1553 |
"access the printable string used for steping through a list |
|
1554 |
searching for an entry starting with a character. |
|
1555 |
*** to optimize:redefine by subClass |
|
1556 |
" |
|
1398 | 1557 |
|label| |
1558 |
||
1559 |
(label := self label) notNil ifTrue:[ |
|
1560 |
label isString ifTrue:[ ^ label string ]. |
|
1561 |
label isImageOrForm ifTrue:[ ^ nil ]. |
|
1562 |
||
1563 |
label isSequenceable ifFalse:[ |
|
1564 |
^ label perform:#string ifNotUnderstood:nil |
|
1565 |
]. |
|
1566 |
||
1567 |
label do:[:el||s| |
|
1568 |
(el notNil and:[el isImageOrForm not]) ifTrue:[ |
|
1569 |
s := el perform:#string ifNotUnderstood:nil. |
|
1570 |
s notNil ifTrue:[^ s]. |
|
1571 |
] |
|
1572 |
] |
|
1573 |
]. |
|
1574 |
^ nil |
|
1575 |
||
1390 | 1576 |
|
1577 |
! ! |
|
1578 |
||
1579 |
!HierarchicalItem methodsFor:'queries'! |
|
1580 |
||
1804 | 1581 |
isChildOf:anItem |
1582 |
"returns true if the item is a child of anItem |
|
1583 |
" |
|
1584 |
|item| |
|
1585 |
||
1586 |
item := self. |
|
1587 |
||
1588 |
[anItem ~~ item] whileTrue:[ |
|
1589 |
((item := item parent) notNil and:[item isHierarchicalItem]) ifFalse:[ |
|
1590 |
^ false |
|
1591 |
] |
|
1592 |
]. |
|
1593 |
^ true |
|
1594 |
||
1595 |
! |
|
1596 |
||
2305 | 1597 |
isCollapsed |
2547 | 1598 |
"returns true if the item is collapsed" |
1599 |
||
1600 |
^ isExpanded not |
|
2305 | 1601 |
! |
1602 |
||
3173 | 1603 |
isDirectoryItem |
1604 |
^ false |
|
1605 |
||
1606 |
"Created: / 23-06-2006 / 12:47:05 / fm" |
|
1607 |
"Modified: / 23-02-2007 / 12:04:23 / User" |
|
1608 |
! |
|
1609 |
||
1390 | 1610 |
isExpanded |
2547 | 1611 |
"returns true if the item is expanded" |
1612 |
||
1613 |
^ isExpanded |
|
1390 | 1614 |
! |
1615 |
||
1616 |
isHierarchicalItem |
|
1617 |
"used to decide if the parent is a hierarchical item |
|
1618 |
or the model |
|
1619 |
" |
|
1620 |
^ true |
|
1621 |
! |
|
1622 |
||
2033 | 1623 |
isRealChildOf:anItem |
1624 |
"returns true if the item is a child of anItem |
|
1625 |
" |
|
1626 |
|item| |
|
1627 |
item := self parent. |
|
1628 |
||
1629 |
[item notNil] whileTrue:[ |
|
1630 |
item == anItem ifTrue:[^ true]. |
|
1631 |
item := item parent. |
|
1632 |
]. |
|
1633 |
^ false |
|
1634 |
! |
|
1635 |
||
1876 | 1636 |
isRootItem |
1637 |
"returns true if the item is the root item |
|
1638 |
" |
|
1883 | 1639 |
^ parent isHierarchicalItem not |
1640 |
! |
|
1876 | 1641 |
|
1390 | 1642 |
size |
1643 |
"return the number of children |
|
1644 |
" |
|
2081 | 1645 |
^ self children size |
1390 | 1646 |
! ! |
1647 |
||
1648 |
!HierarchicalItem methodsFor:'searching'! |
|
1649 |
||
1650 |
detect:aOneArgBlock |
|
1651 |
"find the first child, for which evaluation of the block returns |
|
2927 | 1652 |
true; if none does so, report an error" |
1653 |
||
1390 | 1654 |
^ self detect:aOneArgBlock ifNone:[self errorNotFound] |
1655 |
! |
|
1656 |
||
3071 | 1657 |
detect:aOneArgBlock ifNone:exceptionBlock |
1390 | 1658 |
"find the first child, for which evaluation of the block returns |
2927 | 1659 |
true; if none does so, return the evaluation of anExceptionBlock" |
1660 |
||
3071 | 1661 |
self do:[:el| |
1662 |
(aOneArgBlock value:el) ifTrue:[^ el] |
|
1663 |
]. |
|
1664 |
^ exceptionBlock value |
|
1665 |
||
1666 |
"Modified: / 13-09-2006 / 11:17:53 / cg" |
|
1804 | 1667 |
! |
1668 |
||
1669 |
detectLast:aOneArgBlock |
|
1670 |
"find the last child, for which evaluation of the block returns |
|
2927 | 1671 |
true; if none does so, an exception is raised" |
1672 |
||
1804 | 1673 |
^ self detectLast:aOneArgBlock ifNone:[self errorNotFound] |
1674 |
! |
|
1675 |
||
2081 | 1676 |
detectLast:anOneArgBlock ifNone:anExceptionBlock |
1804 | 1677 |
"find the last child, for which evaluation of the block returns |
2927 | 1678 |
true; if none does so, return the evaluation of anExceptionBlock" |
1679 |
||
2081 | 1680 |
self reverseDo:[:el| (anOneArgBlock value:el) ifTrue:[^ el] ]. |
2927 | 1681 |
^ anExceptionBlock value |
1390 | 1682 |
! |
1683 |
||
2081 | 1684 |
findFirst:anOneArgBlock |
1966 | 1685 |
"find the first child, for which evaluation of the argument, aOneArgBlock |
1686 |
returns true; return its index or 0 if none detected. |
|
1687 |
" |
|
2081 | 1688 |
self keysAndValuesDo:[:i :el| (anOneArgBlock value:el) ifTrue:[^ i] ]. |
1689 |
^ 0 |
|
1966 | 1690 |
! |
1691 |
||
2081 | 1692 |
findLast:anOneArgBlock |
1966 | 1693 |
"find the last child, for which evaluation of the argument, aOneArgBlock |
1694 |
returns true; return its index or 0 if none detected. |
|
1695 |
" |
|
2081 | 1696 |
self keysAndValuesReverseDo:[:i :el| (anOneArgBlock value:el) ifTrue:[^ i] ]. |
1697 |
^ 0 |
|
1966 | 1698 |
! |
1699 |
||
1390 | 1700 |
identityIndexOf:aChild |
1701 |
"return the index of aChild or 0 if not found. Compare using == |
|
1702 |
" |
|
1733 | 1703 |
^ self identityIndexOf:aChild startingAt:1 |
1390 | 1704 |
! |
1705 |
||
1706 |
identityIndexOf:aChild startingAt:startIndex |
|
1707 |
"return the index of aChild, starting search at startIndex. |
|
1708 |
Compare using ==; return 0 if not found |
|
1709 |
" |
|
1733 | 1710 |
|index| |
1711 |
||
2081 | 1712 |
index := startIndex. |
1733 | 1713 |
|
2081 | 1714 |
self from:startIndex do:[:el| |
1715 |
el == aChild ifTrue:[^ index ]. |
|
1716 |
index := index + 1. |
|
1390 | 1717 |
]. |
2081 | 1718 |
^ 0 |
1489 | 1719 |
! |
1720 |
||
1721 |
recursiveDetect:aOneArgBlock |
|
1722 |
"recursive find the first child, for which evaluation |
|
1723 |
of the block returns true; if none nil is returned |
|
1724 |
" |
|
1804 | 1725 |
self recursiveDo:[:aChild| |
1726 |
(aOneArgBlock value:aChild) ifTrue:[^ aChild] |
|
1727 |
]. |
|
1728 |
^ nil |
|
1729 |
! |
|
1489 | 1730 |
|
1804 | 1731 |
recursiveDetectLast:aBlock |
1732 |
"find the last child, for which evaluation of the block returns |
|
1733 |
true; if none does so, nil id returned |
|
1734 |
" |
|
1735 |
self recursiveReverseDo:[:aChild| |
|
1736 |
(aBlock value:aChild) ifTrue:[^ aChild]. |
|
1489 | 1737 |
]. |
1738 |
^ nil |
|
1876 | 1739 |
! |
1740 |
||
1741 |
withAllDetect:aOneArgBlock |
|
1742 |
"recursive find the first item including self, for which evaluation |
|
1743 |
of the block returns true; if none nil is returned |
|
1744 |
" |
|
1745 |
(aOneArgBlock value:self) ifTrue:[^ self]. |
|
1746 |
||
1883 | 1747 |
^ self recursiveDetect:aOneArgBlock |
1748 |
! ! |
|
1390 | 1749 |
|
2486 | 1750 |
!HierarchicalItem methodsFor:'sorting & reordering'! |
2252 | 1751 |
|
2294 | 1752 |
recursiveSort:aSortBlock |
1753 |
"recursive sort the children inplace using the 2-arg block sortBlock for comparison |
|
1754 |
" |
|
1755 |
self criticalDo:[ |
|
1756 |
children size ~~ 0 ifTrue:[ |
|
1757 |
self nonCriticalRecursiveSort:aSortBlock. |
|
1758 |
self childrenOrderChanged. |
|
1759 |
] |
|
1760 |
]. |
|
1761 |
! |
|
1762 |
||
2252 | 1763 |
sort:aSortBlock |
1764 |
"sort the children inplace using the 2-arg block sortBlock for comparison |
|
1765 |
" |
|
1766 |
|unsorted| |
|
1767 |
||
1768 |
self criticalDo:[ |
|
2294 | 1769 |
unsorted := children. |
2252 | 1770 |
|
1771 |
unsorted size ~~ 0 ifTrue:[ |
|
1772 |
children := unsorted sort:aSortBlock. |
|
1773 |
self childrenOrderChanged. |
|
1774 |
] |
|
1775 |
]. |
|
1776 |
! ! |
|
1777 |
||
1390 | 1778 |
!HierarchicalItem::Example class methodsFor:'instance creation'! |
1779 |
||
1780 |
labeled:aLabel |
|
1781 |
^ self new setLabel:aLabel |
|
1782 |
||
1783 |
||
1784 |
! |
|
1785 |
||
1786 |
labeled:aLabel icon:anIcon |
|
1787 |
^ self new setLabel:aLabel icon:anIcon |
|
1788 |
||
1789 |
||
1790 |
! ! |
|
1791 |
||
1792 |
!HierarchicalItem::Example class methodsFor:'resources'! |
|
1793 |
||
1794 |
iconForLevel:aLevel |
|
1795 |
"returns an icon |
|
1796 |
" |
|
1797 |
aLevel == 2 ifTrue:[ ^ ResourceSelectionBrowser iconPrivateClass ]. |
|
1798 |
aLevel == 3 ifTrue:[ ^ ResourceSelectionBrowser iconClass ]. |
|
1799 |
aLevel == 4 ifTrue:[ ^ ResourceSelectionBrowser iconCategory ]. |
|
1800 |
||
1801 |
^ nil |
|
1802 |
! |
|
1803 |
||
1804 |
penguinIcon |
|
1805 |
PenguinIcon isNil ifTrue:[ |
|
1794 | 1806 |
PenguinIcon := Smalltalk imageFromFileNamed:'xpmBitmaps/misc_logos/linux_penguin.xpm' |
1807 |
inPackage:'stx:goodies' |
|
1390 | 1808 |
]. |
1809 |
^ PenguinIcon |
|
1810 |
! ! |
|
1811 |
||
1812 |
!HierarchicalItem::Example methodsFor:'accessing'! |
|
1813 |
||
1814 |
children |
|
2781 | 1815 |
|lvl lbl txt image img icon| |
1390 | 1816 |
|
1817 |
children notNil ifTrue:[ |
|
1818 |
^ children |
|
1819 |
]. |
|
1820 |
||
1821 |
(lvl := self level) == 5 ifTrue:[ |
|
1822 |
children := #(). |
|
1823 |
^ children |
|
1824 |
]. |
|
1825 |
icon := self class iconForLevel:(lvl + 1). |
|
1826 |
children := OrderedCollection new. |
|
1827 |
||
1828 |
lvl < 4 ifTrue:[ |
|
1829 |
txt := (lvl + 1) printString, ' ['. |
|
2781 | 1830 |
img := Icon saveIcon. |
1390 | 1831 |
|
1832 |
1 to:5 do:[:i| |
|
1833 |
(i == 2 or:[i == 3]) ifTrue:[ |
|
1834 |
lbl := img |
|
1835 |
] ifFalse:[ |
|
1836 |
i == 4 ifTrue:[ |
|
1540
3fab5658652a
support carrige return in labels
Claus Gittinger <cg@exept.de>
parents:
1539
diff
changeset
|
1837 |
lbl := Array with:(self class penguinIcon) |
1733 | 1838 |
with:('penguin#and#text' replaceAll:$# with:(Character cr)). |
1390 | 1839 |
] ifFalse:[ |
1840 |
lbl := txt, (i printString), ']' |
|
1841 |
] |
|
1842 |
]. |
|
1843 |
children add:(self class labeled:lbl icon:icon) |
|
1844 |
]. |
|
1845 |
] ifFalse:[ |
|
1846 |
image := ResourceSelectionBrowser iconPrivateClass. |
|
1847 |
txt := LabelAndIcon icon:image string:'Text'. |
|
1848 |
img := Icon copyIcon. |
|
1849 |
||
1850 |
1 to:5 do:[:i| |
|
1851 |
lbl := i odd ifTrue:[txt] ifFalse:[img]. |
|
1398 | 1852 |
lbl := Array with:lbl with:'test' with:img. |
1390 | 1853 |
children add:(self class labeled:lbl icon:icon). |
3333 | 1854 |
]. |
1855 |
children add:(self class labeled:'Edit Text'). |
|
1390 | 1856 |
]. |
1857 |
||
1858 |
children do:[:aChild| aChild parent:self ]. |
|
1859 |
^ children |
|
1860 |
! |
|
1861 |
||
1862 |
icon |
|
1863 |
"returns the icon |
|
1864 |
" |
|
1865 |
^ icon |
|
1866 |
! |
|
1867 |
||
1868 |
icon:anIcon |
|
1869 |
"set the icon; if icon changed, a notification |
|
1870 |
is raised. |
|
1871 |
" |
|
1872 |
icon ~= anIcon ifTrue:[ |
|
1873 |
icon := anIcon. |
|
1874 |
self iconChanged |
|
1875 |
] |
|
1876 |
! |
|
1877 |
||
1878 |
label |
|
1879 |
"returns the label |
|
1880 |
" |
|
1881 |
^ label |
|
1882 |
||
1883 |
! |
|
1884 |
||
1885 |
label:aLabel |
|
1886 |
"set the label; if label changed, a notification |
|
1887 |
is raised. |
|
1888 |
" |
|
1889 |
label ~= aLabel ifTrue:[ |
|
1890 |
label := aLabel. |
|
1891 |
self changed. |
|
1892 |
] |
|
1893 |
||
1894 |
! |
|
1895 |
||
1896 |
setIcon:anIcon |
|
1897 |
"set the icon without any change notification |
|
1898 |
" |
|
1899 |
icon := anIcon |
|
1900 |
! |
|
1901 |
||
1902 |
setLabel:aLabel |
|
1903 |
"set the label without any change notification |
|
1904 |
" |
|
1905 |
label := aLabel |
|
1906 |
! |
|
1907 |
||
1908 |
setLabel:aLabel icon:anIcon |
|
1909 |
"set the label and icon without any change notification |
|
1910 |
" |
|
1911 |
label := aLabel. |
|
1912 |
icon := anIcon. |
|
1913 |
! ! |
|
1914 |
||
1915 |
!HierarchicalItem class methodsFor:'documentation'! |
|
1916 |
||
1917 |
version |
|
3613
440f0aa671ce
return value fixed (consistent)
Claus Gittinger <cg@exept.de>
parents:
3562
diff
changeset
|
1918 |
^ '$Header: /cvs/stx/stx/libwidg2/HierarchicalItem.st,v 1.85 2008-12-18 10:33:20 cg Exp $' |
1390 | 1919 |
! ! |