recompute constant height if changed during drawing
authorca
Thu, 10 Oct 2002 09:00:20 +0200
changeset 2266 18974d0dc3a4
parent 2265 5304bdf0f8e2
child 2267 dad00a31733e
recompute constant height if changed during drawing
HierarchicalListView.st
--- a/HierarchicalListView.st	Thu Oct 10 07:58:47 2002 +0200
+++ b/HierarchicalListView.st	Thu Oct 10 09:00:20 2002 +0200
@@ -653,7 +653,7 @@
 drawElementsFrom:start to:stop x:xLeft y:yT w:w
     "draw the items between start to stop without clearing the background
     "
-    |item prevItem parent icon showIndc showIcon showText nxtPrnt
+    |item prevItem parent icon showIndc showIcon showText nxtPrnt iconHeight
      iconExtent
      yTop      "{ Class:SmallInteger }"
      yCtr      "{ Class:SmallInteger }"
@@ -742,24 +742,44 @@
         ].
 
         (showIcon and:[(icon := self figureFor:item) notNil]) ifTrue:[
-            iconWidth := icon width.
-            iconRgtX  := xIcon + iconWidth.
-            xDeltaIT  := xText - textStartLeft - iconRgtX.
+            iconWidth  := icon width.
+            iconHeight := icon height.
 
+            iconRgtX   := xIcon + iconWidth.
+            xDeltaIT   := xText - textStartLeft - iconRgtX.
             xDeltaIT < 0 ifTrue:[
                 alignTextRightX := alignTextRightX - xDeltaIT.
 
                 alignTextRight ifFalse:[
-                    imageWidth := iconWidth.
+                    imageWidth      := iconWidth.
                     widthOfContents := widthOfContents - xDeltaIT.
                 ] ifTrue:[
                     widthOfContents := alignTextRightX + maxWidthOfText
                 ].
+                
+                widthLvl := self xOfStringLevel:(item level).
+                xText    := item widthOn:self.
+                xText > maxWidthOfText ifTrue:[ maxWidthOfText := xText ].
+
+                widthOfContents := (widthLvl + xText) max:widthOfContents.
+
+                (constantHeight notNil and:[ iconHeight >= constantHeight ]) ifTrue:[
+                    constantHeight := iconHeight + lineSpacing.
+                    self recomputeHeightOfContents.
+                ].
                 self contentsChanged.
                 StopRedrawSignal raise
             ].
+
             iconRgtX > xL ifTrue:[
-                icon displayOn:self x:xIcon y:(yCtr - (icon height // 2))
+                (constantHeight notNil and:[ iconHeight >= constantHeight ]) ifTrue:[
+                    constantHeight := iconHeight + lineSpacing.
+
+                    self recomputeHeightOfContents.
+                    self contentsChanged.
+                    StopRedrawSignal raise
+                ].
+                icon displayOn:self x:xIcon y:(yCtr - (iconHeight // 2))
             ]
         ].
 
@@ -1416,5 +1436,5 @@
 !HierarchicalListView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg2/HierarchicalListView.st,v 1.52 2002-10-09 14:30:06 ca Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/HierarchicalListView.st,v 1.53 2002-10-10 07:00:20 ca Exp $'
 ! !