DataSetColumn.st
changeset 3298 3408a7138374
parent 3264 642d79a1b0d6
child 3320 18d61818a3d1
--- a/DataSetColumn.st	Tue Dec 11 19:37:15 2007 +0100
+++ b/DataSetColumn.st	Wed Dec 12 12:51:01 2007 +0100
@@ -423,9 +423,12 @@
 drawLabel:aLabelToDraw atX:xLeft y:yTop
     "draw aLabelToDraw; handle columnAlignment"
 
-    |drawnLabel x space prevClip mustUndoClip 
+    |drawnLabel x space prevClip mustUndoClip cashedWidth
      labelWidth leftPart leftShift indexOfFirstDigit indexOfFirstNonDigit|
 
+    cashedWidth := self width.
+    cashedWidth isNil ifTrue:[ ^ self ].
+
     space := dataSet horizontalSpacing.
 
     drawnLabel := aLabelToDraw.
@@ -433,8 +436,8 @@
 
     (longStringCompression ~~ false
     and:[ drawnLabel isString 
-    and:[ labelWidth > width]]) ifTrue:[
-        drawnLabel := self class shortenedStringFor:drawnLabel on:dataSet maxWidth:width-space.
+    and:[ labelWidth > cashedWidth]]) ifTrue:[
+        drawnLabel := self class shortenedStringFor:drawnLabel on:dataSet maxWidth:cashedWidth-space.
         labelWidth := drawnLabel widthOn:dataSet.
     ].
 
@@ -456,9 +459,9 @@
                 ].
             ].
             leftShift := leftPart widthOn:dataSet.
-            x := (width // 2) - leftShift.
+            x := (cashedWidth // 2) - leftShift.
         ] ifFalse:[
-            x := width - labelWidth.
+            x := cashedWidth - labelWidth.
 
             columnAlignment == #right ifTrue:[x := x - space]
                                      ifFalse:[x := x // 2].
@@ -476,7 +479,7 @@
             mustUndoClip := true.
             dataSet clippingRectangle:(Rectangle 
                                 left:xLeft top:yTop 
-                                width:width height:(drawnLabel heightOn:dataSet)).
+                                width:cashedWidth height:(drawnLabel heightOn:dataSet)).
         ].
     ].
 
@@ -503,7 +506,10 @@
 drawLabelsAtX:xLeft y:yTop h:h from:start to:stop
     "redraw labels from start to stop
     "
-    |fg y yT x hspace lblHg bg label row isSel|
+    |fg y yT x hspace lblHg bg label row isSel cashedWidth|
+
+    cashedWidth := self width.
+    cashedWidth isNil ifTrue:[ ^ self ].
 
     yT := yTop.
     hspace := dataSet horizontalSpacing.
@@ -525,7 +531,7 @@
             fg := self selectedForegroundColorFor:row at:aRowNr.
 
             dataSet paint:bg.
-            dataSet fillRectangleX:x y:y width:width height:h.
+            dataSet fillRectangleX:x y:y width:cashedWidth height:h.
         ] ifFalse:[
             description backgroundSelector notNil ifTrue:[
                 "/ MUST REDRAW BACKGROUND
@@ -536,7 +542,7 @@
                     bg := dataSet colorOnDevice:bg
                 ].
                 dataSet paint:bg.
-                dataSet fillRectangleX:x y:y width:width height:h.
+                dataSet fillRectangleX:x y:y width:cashedWidth height:h.
             ] ifFalse:[
                 bg := backgroundColor
             ].
@@ -599,15 +605,14 @@
 drawSeparatorsAtX:xLeft y:yTop h:h from:start to:stop
     "redraw separators for cells between start and stop
     "
-    |is3D xL    "{ Class:SmallInteger }"
-     xR    "{ Class:SmallInteger }"
-     yB    "{ Class:SmallInteger }"
-     yT    "{ Class:SmallInteger }"
-     times "{ Class:SmallInteger }"
-    |
+    |cashedWidth is3D xL xR yB yT times|
+
     (showColSeparator or:[showRowSeparator]) ifFalse:[
         ^ self
     ].
+    cashedWidth := self width.
+    cashedWidth isNil ifTrue:[ ^ self ].
+
     is3D := dataSet has3Dseparators.
 
     is3D ifTrue:[dataSet paint:(dataSet separatorDarkColor)]
@@ -615,7 +620,7 @@
 
     times := stop - start + 1.
     xL    := xLeft.
-    xR    := xL - 1 + width.
+    xR    := xL - 1 + cashedWidth.
 
     showRowSeparator ifTrue:[
      "/ DRAW SEPARATORS AT BOTTOM( DARK COLOR )
@@ -703,14 +708,16 @@
 redrawX:xLeft y:yTop h:h from:start to:stop
     "redraw rows between start and stop
     "
-    |rH "{ Class:SmallInteger }"
-     y  "{ Class:SmallInteger }"
-    |
+    |rH y cashedWidth|
+
+    cashedWidth := self width.
+    cashedWidth isNil ifTrue:[ ^ self ].
+
     rH := dataSet rowHeight.
 
     description backgroundSelector isNil ifTrue:[
         dataSet paint:backgroundColor.
-        dataSet fillRectangleX:xLeft y:yTop width:width height:h
+        dataSet fillRectangleX:xLeft y:yTop width:cashedWidth height:h
     ].
 
  "/ DRAW CELLS: BACKGROUND/FOREGROUND/LABEL
@@ -724,7 +731,7 @@
         start to:stop do:[:rowNr|
             (self isRowVisible:rowNr) ifTrue:[
                 (self hasChoices:rowNr) ifTrue:[
-                    dataSet drawComboButtonAtX:xLeft y:y w:width
+                    dataSet drawComboButtonAtX:xLeft y:y w:cashedWidth
                 ].
             ].
             y := y + rH.
@@ -735,7 +742,7 @@
             start to:stop do:[:rowNr| |state|
                 state := self at:rowNr.
                 (self isRowVisible:rowNr) ifTrue:[
-                    dataSet drawCheckToggleAtX:xLeft y:y w:width state:state.
+                    dataSet drawCheckToggleAtX:xLeft y:y w:cashedWidth state:state.
                 ].
                 y := y + rH.
             ]
@@ -1216,5 +1223,5 @@
 !DataSetColumn class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg2/DataSetColumn.st,v 1.110 2007-10-29 16:05:45 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/DataSetColumn.st,v 1.111 2007-12-12 11:51:01 ab Exp $'
 ! !