class: ProgressIndicator
changed: #redraw
do not draw percentage, if font is larger than my view
--- a/ProgressIndicator.st Fri Feb 13 11:58:45 2015 +0100
+++ b/ProgressIndicator.st Fri Feb 13 16:06:02 2015 +0100
@@ -11,6 +11,8 @@
"
"{ Package: 'stx:libwidg2' }"
+"{ NameSpace: Smalltalk }"
+
View subclass:#ProgressIndicator
instanceVariableNames:'percentage showPercentage fgColor bgColor connectedTop
connectedLabel collector finishAction closeTopWhenDone showBusy
@@ -1054,7 +1056,7 @@
redraw
"redraw the percentage bar and optional percentage string"
- |s lx rx sx sy sw m2 m w h doBusy oldClip currentDeviceFont|
+ |s lx rx sx sy sw m2 m w h doBusy oldClip currentDeviceFont reallyShowPercentage|
self shown ifFalse:[^self].
@@ -1093,23 +1095,27 @@
self paint:bgColor.
self fillRectangleX:m+rx y:m width:w-rx height:h.
- showPercentage ifTrue:[
+ (reallyShowPercentage := showPercentage) ifTrue:[
s := percentage printString , ' %'.
+
currentDeviceFont := gc createFontOnDevice.
- sw := currentDeviceFont widthOf:s .
- sx := (width - sw) // 2.
- sy := height // 2 + currentDeviceFont descent + 2.
+ reallyShowPercentage := self height >= (currentDeviceFont heightOf:s).
+ reallyShowPercentage ifTrue:[
+ sw := currentDeviceFont widthOf:s .
+ sx := (width - sw) // 2.
+ sy := height // 2 + currentDeviceFont descent + 2.
- rx <= (sx+sw) ifTrue:[
- self paint:Color black.
- self displayString:s x:sx y:sy.
+ rx <= (sx+sw) ifTrue:[
+ self paint:Color black.
+ self displayString:s x:sx y:sy.
+ ]
]
].
self paint:fgColor.
self fillRectangleX:m y:m width:rx height:h.
- showPercentage ifTrue:[
+ reallyShowPercentage ifTrue:[
rx >= sx ifTrue:[
oldClip := self clippingRectangleOrNil.
self clippingRectangle:(m@m corner:rx+1 @ h).
@@ -1723,10 +1729,10 @@
!ProgressIndicator class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg2/ProgressIndicator.st,v 1.77 2014-02-18 15:06:59 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg2/ProgressIndicator.st,v 1.78 2015-02-13 15:06:02 cg Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libwidg2/ProgressIndicator.st,v 1.77 2014-02-18 15:06:59 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg2/ProgressIndicator.st,v 1.78 2015-02-13 15:06:02 cg Exp $'
! !