#BUGFIX by cg
class: Label
changed: #drawWith:and:clearInside:etchedFg:
fixed drawing of a string-label with newlines
in adjust=center mode.
class: Label class
comment/format in: #examples
--- a/Label.st Fri Jul 07 12:51:47 2017 +0200
+++ b/Label.st Tue Jul 11 14:36:37 2017 +0200
@@ -178,6 +178,17 @@
top open
[exEnd]
+ [exBegin]
+ |top l|
+
+ top := StandardSystemView new.
+ top extent:(200 @ 200).
+
+ l := Label in:top.
+ l label:'hello\world' withCRs.
+
+ top open
+ [exEnd]
simple with emphasis:
@@ -1959,7 +1970,7 @@
(especially Button) to redraw the logo in different colors."
|x y scaleH scaleV nW nH hSep vSep m2 ascent currentTransformation
- logoWidth logoHeight|
+ logoWidth logoHeight lines logoDrawn|
doClear ifTrue:[self clearInsideWith:bg].
@@ -1996,6 +2007,14 @@
"/ self background:bg.
self drawImageLogo:logo x:x y:y opaque:doClear.
] ifFalse:[
+ "/ convert to a line-collection if required;
+ "/ otherwise, adjust may get it wrong...
+ logoDrawn := logo.
+ (logoDrawn isString and:[(lines := logoDrawn asStringCollection) size > 1])
+ ifTrue:[
+ logoDrawn := lines.
+ ].
+
x := x + hSpace.
y := y + vSpace.
@@ -2004,7 +2023,7 @@
y := y + 1
].
- ascent := logo ascentOn:self.
+ ascent := logoDrawn ascentOn:self.
y := y + ascent.
adjust == #fit ifTrue:[
@@ -2035,21 +2054,21 @@
].
].
- logo isString ifTrue:[
+ logoDrawn isString ifTrue:[
"/ doClear ifTrue:[
-"/ self displayOpaqueString:logo x:x y:y
+"/ self displayOpaqueString:logoDrawn x:x y:y
"/ ] ifFalse:[
-"/ self displayString:logo x:x y:y
+"/ self displayString:logoDrawn x:x y:y
"/ ]
etchedFg notNil ifTrue:[
gc paint:etchedFg.
- self drawStringLogo:logo x:x+1 y:y+1.
+ self drawStringLogo:logoDrawn x:x+1 y:y+1.
gc paint:fg.
].
- self drawStringLogo:logo x:x y:y
+ self drawStringLogo:logoDrawn x:x y:y
] ifFalse:[
- (logo isStringCollection) ifTrue:[
- logo do:[ :line |
+ (logoDrawn isStringCollection) ifTrue:[
+ logoDrawn do:[ :line |
|wThis str|
adjust == #centerEach ifTrue:[
@@ -2072,7 +2091,7 @@
]
] ifFalse:[
"/ anything
- self drawOtherLogo:logo x:x y:y opaque:doClear
+ self drawOtherLogo:logoDrawn x:x y:y opaque:doClear
]
].
].
@@ -2082,7 +2101,7 @@
].
]
- "Modified: / 6.9.1998 / 22:35:53 / cg"
+ "Modified: / 11-07-2017 / 14:35:40 / cg"
!
redraw