Label.st
changeset 6177 e80cfdebfdbe
parent 6106 ea570c22a64d
child 6238 341edb64b989
equal deleted inserted replaced
6176:7b8ba07cb680 6177:e80cfdebfdbe
   173         top := StandardSystemView new.
   173         top := StandardSystemView new.
   174         top extent:(200 @ 200).
   174         top extent:(200 @ 200).
   175 
   175 
   176         l := Label in:top.
   176         l := Label in:top.
   177         l label:'hello world'.
   177         l label:'hello world'.
       
   178 
       
   179         top open
       
   180                                                                         [exEnd]
       
   181                                                                         [exBegin]
       
   182         |top l|
       
   183 
       
   184         top := StandardSystemView new.
       
   185         top extent:(200 @ 200).
       
   186 
       
   187         l := Label in:top.
       
   188         l label:'hello\world' withCRs.
   178 
   189 
   179         top open
   190         top open
   180                                                                         [exEnd]
   191                                                                         [exEnd]
   181 
   192 
   182 
   193 
  1957 drawWith:fg and:bg clearInside:doClear etchedFg:etchedFg
  1968 drawWith:fg and:bg clearInside:doClear etchedFg:etchedFg
  1958     "redraw my label with fg/bg - this generic method is also used by subclasses
  1969     "redraw my label with fg/bg - this generic method is also used by subclasses
  1959      (especially Button) to redraw the logo in different colors."
  1970      (especially Button) to redraw the logo in different colors."
  1960 
  1971 
  1961     |x y scaleH scaleV nW nH hSep vSep m2 ascent currentTransformation
  1972     |x y scaleH scaleV nW nH hSep vSep m2 ascent currentTransformation
  1962      logoWidth logoHeight|
  1973      logoWidth logoHeight lines logoDrawn|
  1963 
  1974 
  1964     doClear ifTrue:[self clearInsideWith:bg].
  1975     doClear ifTrue:[self clearInsideWith:bg].
  1965 
  1976 
  1966     gc paint:fg on:bg.
  1977     gc paint:fg on:bg.
  1967     logo notNil ifTrue:[
  1978     logo notNil ifTrue:[
  1994 
  2005 
  1995             logo := logo onDevice:device.
  2006             logo := logo onDevice:device.
  1996 "/            self background:bg.
  2007 "/            self background:bg.
  1997             self drawImageLogo:logo x:x y:y opaque:doClear.
  2008             self drawImageLogo:logo x:x y:y opaque:doClear.
  1998         ] ifFalse:[
  2009         ] ifFalse:[
       
  2010             "/ convert to a line-collection if required;
       
  2011             "/ otherwise, adjust may get it wrong...
       
  2012             logoDrawn := logo.
       
  2013             (logoDrawn isString and:[(lines := logoDrawn asStringCollection) size > 1])
       
  2014             ifTrue:[
       
  2015                 logoDrawn := lines.
       
  2016             ].
       
  2017             
  1999             x := x + hSpace.
  2018             x := x + hSpace.
  2000             y := y + vSpace.
  2019             y := y + vSpace.
  2001 
  2020 
  2002             level < 0 ifTrue:[
  2021             level < 0 ifTrue:[
  2003                 x := x + 1.
  2022                 x := x + 1.
  2004                 y := y + 1
  2023                 y := y + 1
  2005             ].
  2024             ].
  2006 
  2025 
  2007             ascent := logo ascentOn:self.
  2026             ascent := logoDrawn ascentOn:self.
  2008             y := y + ascent.
  2027             y := y + ascent.
  2009 
  2028 
  2010             adjust == #fit ifTrue:[
  2029             adjust == #fit ifTrue:[
  2011                 "/
  2030                 "/
  2012                 "/ change scale to make the logo fit exactly
  2031                 "/ change scale to make the logo fit exactly
  2033                     nW := labelWidth * scaleV.
  2052                     nW := labelWidth * scaleV.
  2034                     x := x + ((width - nW - m2 - hSep) / scaleV / 2) 
  2053                     x := x + ((width - nW - m2 - hSep) / scaleV / 2) 
  2035                 ].
  2054                 ].
  2036             ].
  2055             ].
  2037 
  2056 
  2038             logo isString ifTrue:[
  2057             logoDrawn isString ifTrue:[
  2039 "/                doClear ifTrue:[
  2058 "/                doClear ifTrue:[
  2040 "/                    self displayOpaqueString:logo x:x y:y
  2059 "/                    self displayOpaqueString:logoDrawn x:x y:y
  2041 "/                ] ifFalse:[
  2060 "/                ] ifFalse:[
  2042 "/                    self displayString:logo x:x y:y
  2061 "/                    self displayString:logoDrawn x:x y:y
  2043 "/                ]
  2062 "/                ]
  2044                 etchedFg notNil ifTrue:[
  2063                 etchedFg notNil ifTrue:[
  2045                     gc paint:etchedFg.
  2064                     gc paint:etchedFg.
  2046                     self drawStringLogo:logo x:x+1 y:y+1.
  2065                     self drawStringLogo:logoDrawn x:x+1 y:y+1.
  2047                     gc paint:fg.
  2066                     gc paint:fg.
  2048                 ].
  2067                 ].
  2049                 self drawStringLogo:logo x:x y:y
  2068                 self drawStringLogo:logoDrawn x:x y:y
  2050             ] ifFalse:[
  2069             ] ifFalse:[
  2051                 (logo isStringCollection) ifTrue:[
  2070                 (logoDrawn isStringCollection) ifTrue:[
  2052                     logo do:[ :line | 
  2071                     logoDrawn do:[ :line | 
  2053                         |wThis str|
  2072                         |wThis str|
  2054 
  2073 
  2055                         adjust == #centerEach ifTrue:[
  2074                         adjust == #centerEach ifTrue:[
  2056                             wThis := line asString widthOn:self.
  2075                             wThis := line asString widthOn:self.
  2057                             x := (width - wThis) // 2.
  2076                             x := (width - wThis) // 2.
  2070                         self drawStringLogo:str x:x y:y.
  2089                         self drawStringLogo:str x:x y:y.
  2071                         y := y + (gc font height)
  2090                         y := y + (gc font height)
  2072                     ]
  2091                     ]
  2073                 ] ifFalse:[
  2092                 ] ifFalse:[
  2074                     "/ anything
  2093                     "/ anything
  2075                     self drawOtherLogo:logo x:x y:y opaque:doClear
  2094                     self drawOtherLogo:logoDrawn x:x y:y opaque:doClear
  2076                 ]
  2095                 ]
  2077             ].
  2096             ].
  2078         ].
  2097         ].
  2079 
  2098 
  2080         adjust == #fit ifTrue:[
  2099         adjust == #fit ifTrue:[
  2081             self scale:1
  2100             self scale:1
  2082         ].
  2101         ].
  2083     ]
  2102     ]
  2084 
  2103 
  2085     "Modified: / 6.9.1998 / 22:35:53 / cg"
  2104     "Modified: / 11-07-2017 / 14:35:40 / cg"
  2086 !
  2105 !
  2087 
  2106 
  2088 redraw
  2107 redraw
  2089     "redraw my label"
  2108     "redraw my label"
  2090 
  2109