--- a/HierarchicalItem.st Wed Oct 27 14:22:45 1999 +0200
+++ b/HierarchicalItem.st Wed Oct 27 16:27:43 1999 +0200
@@ -12,7 +12,7 @@
Object subclass:#HierarchicalItem
- instanceVariableNames:'parent children isExpanded'
+ instanceVariableNames:'parent children isExpanded height width'
classVariableNames:''
poolDictionaries:''
category:'Views-Support'
@@ -597,17 +597,19 @@
!
-changed:aParameter with:anArgument
+changed:what with:anArgument
"the item changed; raise change notification
"
|model|
- model := self model.
+ (what ~~ #hierarchy and:[what ~~ #icon]) ifTrue:[
+ width := nil
+ ].
- model notNil ifTrue:[
- model itemChanged:aParameter with:anArgument from:self
+ (model := self model) notNil ifTrue:[
+ model itemChanged:what with:anArgument from:self
].
- super changed:aParameter with:anArgument
+ super changed:what with:anArgument
!
hierarchyChanged
@@ -752,34 +754,33 @@
!HierarchicalItem methodsFor:'private displaying'!
-displayLabel:aLabel on:aGC x:x y:y h:h
+displayLabel:aLabel h:lH on:aGC x:x y:y h:h
"display the label at x@y
"
- |y0 lH hF|
+ |y0 hF|
- lH := self heightOf:aLabel on:aGC.
- lH == 0 ifTrue:[^ self].
+ lH ~~ 0 ifTrue:[
+ y0 := y - (lH + 1 - h // 2).
- y0 := y - (lH + 1 - h // 2).
-
- aLabel isImageOrForm ifTrue:[
- ^ aLabel displayOn:aGC x:x y:y0
- ].
- y0 := y0 + (aGC font ascent).
+ aLabel isImageOrForm ifTrue:[
+ ^ aLabel displayOn:aGC x:x y:y0
+ ].
+ y0 := y0 + (aGC font ascent).
- aLabel isString ifFalse:[
- ^ aLabel displayOn:aGC x:x y:y0
- ].
+ aLabel isString ifFalse:[
+ ^ aLabel displayOn:aGC x:x y:y0
+ ].
- (aLabel indexOf:(Character cr)) == 0 ifTrue:[
- ^ aLabel displayOn:aGC x:x y:y0
- ].
+ (aLabel indexOf:(Character cr)) == 0 ifTrue:[
+ ^ aLabel displayOn:aGC x:x y:y0
+ ].
- hF := aGC font height.
+ hF := aGC font height.
- aLabel asCollectionOfLines do:[:el|
- el displayOn:aGC x:x y:y0.
- y0 := y0 + hF
+ aLabel asCollectionOfLines do:[:el|
+ el displayOn:aGC x:x y:y0.
+ y0 := y0 + hF
+ ]
].
!
@@ -916,13 +917,13 @@
(label := self label) isNil ifTrue:[^ self].
(label isSequenceable and:[label isString not]) ifFalse:[
- ^ self displayLabel:label on:aGC x:x y:y h:h
+ ^ self displayLabel:label h:(self heightOn:aGC) on:aGC x:x y:y h:h
].
x0 := x.
label do:[:el|
el notNil ifTrue:[
- self displayLabel:el on:aGC x:x0 y:y h:h.
+ self displayLabel:el h:(self heightOf:el on:aGC) on:aGC x:x0 y:y h:h.
x0 := x0 + 5 + (el widthOn:aGC).
].
]
@@ -931,13 +932,24 @@
heightOn:aGC
"return the width of the receiver, if it is to be displayed on aGC
"
- ^ self heightOf:(self label) on:aGC
+ |height|
+
+ height isNil ifTrue:[
+ height := self heightOf:(self label) on:aGC
+ ].
+ ^ height
!
widthOn:aGC
"return the width of the receiver, if it is to be displayed on aGC
"
- ^ self widthOf:(self label) on:aGC
+ |width|
+
+ width isNil ifTrue:[
+ width := self widthOf:(self label) on:aGC
+ ].
+ ^ width
+
! !
!HierarchicalItem methodsFor:'protocol monitoring'!
@@ -1231,5 +1243,5 @@
!HierarchicalItem class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg2/HierarchicalItem.st,v 1.15 1999-10-22 22:59:12 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg2/HierarchicalItem.st,v 1.16 1999-10-27 14:27:43 ca Exp $'
! !