Label.st
branchjv
changeset 5987 f9cc7367fde9
parent 5981 50c1bb3e9f98
parent 5983 1fe3da275b7f
child 6085 4ecbe3a93aec
equal deleted inserted replaced
5986:1fa5f049f917 5987:f9cc7367fde9
  1938 
  1938 
  1939 drawWith:fg and:bg clearInside:doClear etchedFg:etchedFg
  1939 drawWith:fg and:bg clearInside:doClear etchedFg:etchedFg
  1940     "redraw my label with fg/bg - this generic method is also used by subclasses
  1940     "redraw my label with fg/bg - this generic method is also used by subclasses
  1941      (especially Button) to redraw the logo in different colors."
  1941      (especially Button) to redraw the logo in different colors."
  1942 
  1942 
  1943     |x y scaleH scaleV nW nH hSep vSep m2 ascent currentTransformation|
  1943     |x y scaleH scaleV nW nH hSep vSep m2 ascent currentTransformation
       
  1944      logoWidth logoHeight|
  1944 
  1945 
  1945     doClear ifTrue:[self clearInsideWith:bg].
  1946     doClear ifTrue:[self clearInsideWith:bg].
  1946 
  1947 
  1947     self paint:fg on:bg.
  1948     self paint:fg on:bg.
  1948     logo notNil ifTrue:[
  1949     logo notNil ifTrue:[
  1952 
  1953 
  1953         x := labelOriginX.
  1954         x := labelOriginX.
  1954         y := labelOriginY.
  1955         y := labelOriginY.
  1955 
  1956 
  1956         logo isImageOrForm ifTrue:[
  1957         logo isImageOrForm ifTrue:[
       
  1958             logoWidth := logo width.
       
  1959             logoHeight := logo height.
       
  1960             ((logoWidth == 0) or:[logoHeight == 0]) ifTrue:[
       
  1961                 "/ do nothing; also avoids followup errors in the image creation and division by zero...
       
  1962                 ^ self.
       
  1963             ].    
  1957             adjust == #fit ifTrue:[
  1964             adjust == #fit ifTrue:[
  1958                 "/
  1965                 "/
  1959                 "/ change scale to make the logo fit exactly
  1966                 "/ change scale to make the logo fit exactly
  1960                 "/
  1967                 "/
  1961                 scaleH := ((width - hSep) / (logo width)) asFloat.
  1968                 scaleH := ((width - hSep) / logoWidth) asFloat.
  1962                 scaleV := ((height - vSep) / (logo height)) asFloat.
  1969                 scaleV := ((height - vSep) / logoHeight) asFloat.
  1963                 scaleH <= 0 ifTrue:[scaleH := Float epsilon].
  1970                 scaleH <= 0 ifTrue:[scaleH := Float epsilon].
  1964                 scaleV <= 0 ifTrue:[scaleV := Float epsilon].
  1971                 scaleV <= 0 ifTrue:[scaleV := Float epsilon].
  1965                 self scale:(scaleH @ scaleV).
  1972                 self scale:(scaleH @ scaleV).
  1966                 x := currentTransformation applyInverseScaleX:x.
  1973                 x := currentTransformation applyInverseScaleX:x.
  1967                 y := currentTransformation applyInverseScaleY:y.
  1974                 y := currentTransformation applyInverseScaleY:y.