Fixed `PopUpList` widget to display correctly non-string objects jv
authorJan Vrany <jan.vrany@fit.cvut.cz>
Fri, 26 Jan 2018 11:43:24 +0000
branchjv
changeset 6279 232954e959f7
parent 6215 c6976b98f3c3
child 6348 bbae86d44915
Fixed `PopUpList` widget to display correctly non-string objects ...using their `#displayOn:x:y:` / or `#displayString`. The popup menu shown the `#displayString` correctly however the "button" stubbornly used object's `#printString`, making the widget largely unusable with anything but strings. This commit removes this limitation.
PopUpList.st
--- a/PopUpList.st	Wed Oct 11 23:37:38 2017 +0100
+++ b/PopUpList.st	Fri Jan 26 11:43:24 2018 +0000
@@ -568,7 +568,7 @@
     index == 0 ifTrue:[
         newLabel := defaultLabel
     ] ifFalse:[
-        newLabel := (menuLabels at:index) printString
+        newLabel := (menuLabels at:index) 
     ].
 
     "kludge: don't want label to resize ..."
@@ -596,7 +596,8 @@
      p open
     "
 
-    "Modified: / 29.10.1997 / 15:50:12 / cg"
+    "Modified: / 29-10-1997 / 15:50:12 / cg"
+    "Modified: / 26-01-2018 / 10:10:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 values:aList
@@ -1010,7 +1011,7 @@
 rawLabelSizeOf:aLogo
     "compute the extent needed to hold the label plus the mark"
 
-    |ext mmH mmV longest longestWidth labels deviceFont|
+    |ext mmH mmV longest longestWidth labels|
 
     ext := super rawLabelSizeOf:aLogo.
 
@@ -1019,26 +1020,25 @@
     and:[adjust ~~ #center]]) ifTrue:[
         "compute length of longest menu entry"
 
-        deviceFont := gc deviceFont.
         longest := logo.
         logo isNil ifTrue:[
             longestWidth := 0
         ] ifFalse:[
-            longestWidth := deviceFont widthOf:logo.
+            longestWidth := super rawLabelSizeOf: logo.
         ].
         labels := menu value labels.
         labels notNil ifTrue:[
             labels do:[:entry |
                 |this|
 
-                this := deviceFont widthOf:entry printString.
+                this := super rawLabelSizeOf: entry.
                 this > longestWidth ifTrue:[
                     longest := entry.
                     longestWidth := this
                 ].
             ].
         ].
-        ext := ext max:(super rawLabelSizeOf:(longest printString))
+        ext := ext max:(super rawLabelSizeOf:(longest displayString))
     ].
 
     showHandle ifTrue:[
@@ -1050,7 +1050,8 @@
     ].
     ^ ext
 
-    "Modified: / 6.3.1999 / 21:51:14 / cg"
+    "Modified: / 06-03-1999 / 21:51:14 / cg"
+    "Modified: / 26-01-2018 / 10:11:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !PopUpList methodsFor:'private-controller access'!
@@ -1112,7 +1113,7 @@
 
         "/ self sizeFixed:true.
         label := menuLabels at:anIndex.
-        super label:label printString suppressResize:true.
+        super label:label suppressResize:true.
 "/    ].
 
     (model notNil and:[changeMsg notNil]) ifTrue:[
@@ -1147,7 +1148,8 @@
         menuAction value:value.
     ].
 
-    "Modified: / 29.10.1997 / 21:08:50 / cg"
+    "Modified: / 29-10-1997 / 21:08:50 / cg"
+    "Modified: / 26-01-2018 / 10:10:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !PopUpList class methodsFor:'documentation'!
@@ -1158,5 +1160,10 @@
 
 version_CVS
     ^ '$Header$'
+!
+
+version_HG
+
+    ^ '$Changeset: <not expanded> $'
 ! !