always right-align a right-aligned field
authorClaus Gittinger <cg@exept.de>
Wed, 13 Oct 1999 23:28:05 +0200
changeset 1586 c87e9c9b298f
parent 1585 b4f60b1a025b
child 1587 c82f9a0f73e4
always right-align a right-aligned field (even if string is longer than field)
DataSetColumn.st
--- a/DataSetColumn.st	Wed Oct 13 23:27:11 1999 +0200
+++ b/DataSetColumn.st	Wed Oct 13 23:28:05 1999 +0200
@@ -321,7 +321,7 @@
 drawLabel:aLabel atX:xLeft y:yTop
     "redraw label
     "
-    |x space|
+    |x space prevClip mustUndoClip|
 
     space := dataSet horizontalSpacing.
 
@@ -332,15 +332,31 @@
 
         columnAlignment == #right ifTrue:[x := x - space]
                                  ifFalse:[x := x // 2].
-        x := xLeft + (x max:0).
+
+"/ cg: old code (did not right-align if string is larger than width
+"/        x := xLeft + (x max:0).
+
+"/ new code: always right-align.
+        x < 0 ifTrue:[
+            "/ must clip ...
+            prevClip := dataSet clippingRectangleOrNil.
+            mustUndoClip := true.
+            dataSet clipRect:(Rectangle 
+                                left:xLeft top:yTop 
+                                width:width height:(aLabel heightOn:dataSet)).
+        ].
+        x := xLeft + x.
     ].
 
     aLabel isImageOrForm ifTrue:[
         aLabel displayOn:dataSet x:x y:yTop.
-      ^ self
+    ] ifFalse:[
+        aLabel displayOn:dataSet x:x y:(yTop + dataSet rowFontAscent)
     ].
 
-    aLabel displayOn:dataSet x:x y:(yTop + dataSet rowFontAscent)
+    mustUndoClip == true ifTrue:[
+        dataSet clippingRectangle:prevClip    
+    ].
 !
 
 drawLabelsAtX:xLeft y:yTop h:h from:start to:stop
@@ -964,5 +980,5 @@
 !DataSetColumn class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg2/DataSetColumn.st,v 1.54 1999-09-28 17:00:58 ca Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/DataSetColumn.st,v 1.55 1999-10-13 21:28:05 cg Exp $'
 ! !