DataSetColumn.st
changeset 2221 19a1500f8113
parent 2211 f14db8e094b9
child 2222 c1349adf1329
--- a/DataSetColumn.st	Thu Sep 26 09:38:41 2002 +0200
+++ b/DataSetColumn.st	Thu Sep 26 10:42:29 2002 +0200
@@ -123,19 +123,27 @@
     "common code to shorten a string; used in both the DSV label- and column Views,  
      if the string is too long for the column"
 
-    |widthOf3Dots wRest shortenedLabel|
+    |widthOf3Dots wRest shortenedLabel lUsed lMin lMax|
 
     aString isString ifFalse:[^ aString].
     (aString widthOn:aGC) > maxWidth ifFalse:[aString].
 
     widthOf3Dots := '...' widthOn:aGC.
-    shortenedLabel := aString copyWithoutLast:1.
+
+    lMin := 1.
+    lMax := aString size.
     [ 
-        shortenedLabel size > 0
-        and:[( wRest := shortenedLabel widthOn:aGC) > (maxWidth-widthOf3Dots)] 
-    ] whileTrue:[
-        shortenedLabel := shortenedLabel copyWithoutLast:1.
-    ].
+        lUsed := (lMax + lMin) // 2.
+        wRest := aString widthFrom:1 to:lUsed on:aGC.
+        wRest > (maxWidth-widthOf3Dots) ifTrue:[
+            lMax := lUsed - 1.
+        ] ifFalse:[
+            lMin := lUsed + 1.
+        ].
+        lMin < lMax
+    ] whileTrue.
+    shortenedLabel := aString copyFrom:1 to:lUsed.
+
     shortenedLabel isEmpty ifTrue:[
         ((aString first asString , '..') widthOn:aGC) < maxWidth ifTrue:[
             "/ only two dots and the first character
@@ -163,13 +171,7 @@
     |row newRow|
 
     row := dataSet at:aRowNr.
-    newRow := self storeCol:something inRow:row.
-
-    newRow ~~ row ifTrue:[
-        dataSet listAt:aRowNr put:newRow.
-    ]
-
-    "Modified: / 7.8.1998 / 22:17:27 / cg"
+    self storeCol:something inRow:row.
 !
 
 columnAdaptor
@@ -832,9 +834,11 @@
 
     columnAdaptor notNil ifTrue:[
         numArgs == 2 ifTrue:[
-            ^ columnAdaptor perform:writeSelector with:aRow with:newValue
+            columnAdaptor perform:writeSelector with:aRow with:newValue.
+            ^ self
         ].
-        ^ columnAdaptor perform:writeSelector with:aRow with:columnNumber with:newValue
+        columnAdaptor perform:writeSelector with:aRow with:columnNumber with:newValue.
+        ^ self
     ].
 
     numArgs == 1 ifTrue:[
@@ -842,7 +846,6 @@
     ] ifFalse:[
         aRow perform:writeSelector with:columnNumber with:newValue
     ].
-    ^ aRow
 
 ! !
 
@@ -1043,5 +1046,5 @@
 !DataSetColumn class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg2/DataSetColumn.st,v 1.76 2002-09-23 09:09:43 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/DataSetColumn.st,v 1.78 2002-09-26 08:42:29 james Exp $'
 ! !