#REFACTORING by stefan
authorStefan Vogel <sv@exept.de>
Thu, 14 Apr 2016 12:13:33 +0200
changeset 5020 6dd1826b889c
parent 5019 ad97e1e51ef9
child 5021 a24473f2d6ca
#REFACTORING by stefan class: LabelAndIcon changed: #displayOn:x:y:opaque:
LabelAndIcon.st
--- a/LabelAndIcon.st	Fri Apr 08 13:27:00 2016 +0200
+++ b/LabelAndIcon.st	Thu Apr 14 12:13:33 2016 +0200
@@ -377,47 +377,36 @@
 displayOn:aGC x:x y:y opaque:opaque
     "display the receiver on a GC"
 
-    |y1 x1 iconValue imageValue iconHeight imageHeight stringHeight maxHeight gapY asc device|
-
-    device := aGC device.
-    gapY := (device pixelPerMillimeter x) rounded.
-    asc  := (aGC font onDevice:device) ascent.
+    |y1 x1 iconValue imageValue stringHeight maxHeight|
 
     iconValue := icon value.
     imageValue := image value.
 
-    iconHeight   := iconValue notNil ifTrue:[iconValue height]   ifFalse:[0].
-    imageHeight  := imageValue notNil ifTrue:[imageValue height]  ifFalse:[0].
-    stringHeight := string size ~~ 0 ifTrue:[string heightOn:aGC] ifFalse:[0].
-
+    "/ gapY := (device pixelPerMillimeter x) rounded.
     "/ maxHeight := ((iconHeight max: imageHeight) + gapY) max: stringHeight.
     maxHeight := self heightOn:aGC.
 
     x1 := x + offset.
 
     iconValue notNil ifTrue:[
-        y1 := y - asc + (maxHeight - iconHeight + 1 // 2).
-
-        icon := iconValue onDevice:device.
-
+        y1 := y - aGC font ascent + ((maxHeight - iconValue height + 1) // 2).
+        icon := iconValue onDevice:aGC device.
         (opaque and:[iconValue mask isNil]) ifTrue:[aGC displayOpaqueForm:iconValue x:x1 y:y1]
                                             ifFalse:[aGC displayForm:iconValue x:x1 y:y1].
-
-        x1 := x1 + iconValue width + gap
+        x1 := x1 + iconValue width + gap.
     ].
 
     imageValue notNil ifTrue:[
-        y1 := y - asc + (maxHeight - imageHeight + 1 // 2).
-        image := imageValue onDevice:device.
-
+        y1 := y - aGC font ascent + ((maxHeight - imageValue height + 1) // 2).
+        image := imageValue onDevice:aGC device.
         (opaque and:[imageValue mask isNil]) ifTrue:[aGC displayOpaqueForm:imageValue x:x1 y:y1]
                                              ifFalse:[aGC displayForm:imageValue x:x1 y:y1].
-
-        x1 := x1 + imageValue width + gap
+        x1 := x1 + imageValue width + gap.
     ].
 
+    stringHeight := string size ~~ 0 ifTrue:[string heightOn:aGC] ifFalse:[0].
     stringHeight ~~ 0 ifTrue:[
-        y1 := y + (maxHeight - stringHeight + 1 // 2).
+        y1 := y + ((maxHeight - stringHeight + 1) // 2).
         string displayOn:aGC x:x1 y:y1 opaque:opaque
     ]