Cherry-picked Ruler.st from a3177d4a9ae5: jv tip
authorJan Vrany <jan.vrany@labware.com>
Thu, 09 Feb 2023 14:03:49 +0000
branchjv
changeset 6265 09ae5bbed69e
parent 6264 c6b18763cdbf
Cherry-picked Ruler.st from a3177d4a9ae5: * b2a3ee58d40c: #UI_ENHANCEMENT by exept, Claus Gittinger <cg@exept.de>
Ruler.st
--- a/Ruler.st	Fri Jun 17 14:34:29 2022 +0200
+++ b/Ruler.st	Thu Feb 09 14:03:49 2023 +0000
@@ -215,19 +215,19 @@
     fgColor := styleSheet colorAt:#rulerForegroundColor.
     fgColor isNil ifTrue:[
         fgColor := styleSheet colorAt:#foregroundColor.
-    ].
-    fgColor isNil ifTrue:[
-        viewBackground brightness > 0.5 ifTrue:[
-            fgColor := Black.
-        ] ifFalse:[
-            fgColor := White
+        fgColor isNil ifTrue:[
+            viewBackground brightness > 0.5 ifTrue:[
+                fgColor := Color black.
+            ] ifFalse:[
+                fgColor := Color white
+            ].
         ].
     ].
     fgColor := fgColor onDevice:device.
 
     bitGravity := #NorthWest.
 
-    self height:(font height + (2 * font descent)). 
+    self height:(self font height + (2 * self font descent)). 
 
     (Smalltalk language == #english) ifTrue:[
         metric := #inch
@@ -246,19 +246,11 @@
     "
      take a smaller font
     "
-    font := (Font family:(font family)
-                    face:(font face)
-                   style:(font style)
-                    size:8) onDevice:device.
+    self font:(self font asSize:8).
 
     "
      Ruler new open
     "
-!
-
-reinitialize
-    super reinitialize.
-    font := font on:device.
 ! !
 
 !Ruler methodsFor:'metric conversions'!
@@ -301,8 +293,8 @@
     paperHeightMM := UnitConverter inchToMillimeter:paperHeight.
     pixelPerMM := (self millimeterToPixel:1) * scale.
 
-    fontHeight := font height.
-    fontAscent := font ascent.
+    fontHeight := self font height.
+    fontAscent := self font ascent.
 
     orientation == #horizontal ifTrue:[
         (xOrigin + width > paperWidthPixel) ifTrue:[
@@ -330,7 +322,7 @@
 
             pos := 5.
             showUnit ifTrue:[
-                labelRight := stringRight := marg + (font widthOf:'cm') + 3 + xOrigin.
+                labelRight := stringRight := marg + (self font widthOf:'cm') + 3 + xOrigin.
             ] ifFalse:[
                 labelRight := stringRight := xOrigin.
             ].
@@ -353,7 +345,7 @@
                                      x:(x + marg)
                                      y:charY.
                     stringRight := x + marg 
-                                    + (font widthOf:(pos // 10) printString)
+                                    + (self font widthOf:(pos // 10) printString)
                 ].
                 mod := (mod + 1) \\ 2.
                 pos := pos + 5.
@@ -370,7 +362,7 @@
             pixelPerInch := (self inchToPixel:1) * scale.
             pos := 0.25.
             showUnit ifTrue:[
-                labelRight := marg + (font widthOf:'inch') + 3 + xOrigin.
+                labelRight := marg + (self font widthOf:'inch') + 3 + xOrigin.
             ] ifFalse:[
                 labelRight := xOrigin
             ].
@@ -422,7 +414,7 @@
         self paint:fgColor.
 
         left := 0. "width - (font widthOf:'WW')"
-        longLen := font widthOf:'WW'.
+        longLen := self font widthOf:'WW'.
         shortLen := longLen // 2.
         charX := left + shortLen.
         mod := 1.
@@ -505,13 +497,11 @@
     ].
 
     self redrawEdges
-
-
 ! !
 
 !Ruler class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg2/Ruler.st,v 1.28 2002-10-31 21:49:29 cg Exp $'
+    ^ '$Header$'
 ! !