Label.st
changeset 3651 c47e8c3583cf
parent 3649 36c3b9d8bef3
child 3751 8c607457ad94
equal deleted inserted replaced
3650:f3132c5a61a3 3651:c47e8c3583cf
  1651 
  1651 
  1652 drawWith:fg and:bg clearInside:doClear etchedFg:etchedFg
  1652 drawWith:fg and:bg clearInside:doClear etchedFg:etchedFg
  1653     "redraw my label with fg/bg - this generic method is also used by subclasses
  1653     "redraw my label with fg/bg - this generic method is also used by subclasses
  1654      (especially Button) to redraw the logo in different colors."
  1654      (especially Button) to redraw the logo in different colors."
  1655 
  1655 
  1656     |x y scaleH scaleV nW nH hSep vSep m2 stringLogo|
  1656     |x y scaleH scaleV nW nH hSep vSep m2 ascent|
  1657 
  1657 
  1658     doClear ifTrue:[self clearInsideWith:bg].
  1658     doClear ifTrue:[self clearInsideWith:bg].
  1659 
  1659 
  1660     self paint:fg on:bg.
  1660     self paint:fg on:bg.
  1661     logo notNil ifTrue:[
  1661     logo notNil ifTrue:[
  1694             level < 0 ifTrue:[
  1694             level < 0 ifTrue:[
  1695                 x := x + 1.
  1695                 x := x + 1.
  1696                 y := y + 1
  1696                 y := y + 1
  1697             ].
  1697             ].
  1698 
  1698 
  1699             (logo isString
  1699             ascent := logo ascentOn:self.
  1700             or:[logo species == String
  1700             y := y + ascent.
  1701             or:[logo isStringCollection]]) ifTrue:[
  1701 
  1702                 stringLogo := true.
       
  1703                 y := y + (font ascentOn:device).
       
  1704             ] ifFalse:[
       
  1705                 stringLogo := false.
       
  1706             ].
       
  1707         
       
  1708             adjust == #fit ifTrue:[
  1702             adjust == #fit ifTrue:[
  1709                 "/
  1703                 "/
  1710                 "/ change scale to make the logo fit exactly
  1704                 "/ change scale to make the logo fit exactly
  1711                 "/
  1705                 "/
  1712                 scaleH := ((width - m2 - hSep) / (labelWidth - hSpace)) asFloat.
  1706                 scaleH := ((width - m2 - hSep) / (labelWidth - hSpace)) asFloat.
  1714                 scaleH <= 0 ifTrue:[scaleH := Float epsilon].
  1708                 scaleH <= 0 ifTrue:[scaleH := Float epsilon].
  1715                 scaleV <= 0 ifTrue:[scaleV := Float epsilon].
  1709                 scaleV <= 0 ifTrue:[scaleV := Float epsilon].
  1716 
  1710 
  1717                 self scale:(scaleH min:scaleV).
  1711                 self scale:(scaleH min:scaleV).
  1718                 x := transformation applyInverseScaleX:x.
  1712                 x := transformation applyInverseScaleX:x.
  1719                 stringLogo ifTrue:[
  1713                 ascent ~~ 0 ifTrue:[
  1720                     y := y - font ascent + (transformation applyScaleY:font ascent).
  1714                     y := y - ascent + (transformation applyScaleY:ascent).
  1721                 ].
  1715                 ].
  1722                 y := transformation applyInverseScaleY:y.
  1716                 y := transformation applyInverseScaleY:y.
  1723                 scaleH < scaleV ifTrue:[
  1717                 scaleH < scaleV ifTrue:[
  1724                     nH := labelHeight * scaleH.
  1718                     nH := labelHeight * scaleH.
  1725                     "/ now, center vertically
  1719                     "/ now, center vertically
  1846 ! !
  1840 ! !
  1847 
  1841 
  1848 !Label class methodsFor:'documentation'!
  1842 !Label class methodsFor:'documentation'!
  1849 
  1843 
  1850 version
  1844 version
  1851     ^ '$Header: /cvs/stx/stx/libwidg/Label.st,v 1.136 2008-06-24 14:48:28 cg Exp $'
  1845     ^ '$Header: /cvs/stx/stx/libwidg/Label.st,v 1.137 2008-06-28 11:44:58 stefan Exp $'
  1852 ! !
  1846 ! !