ImageView.st
changeset 269 167651794a77
parent 257 0acd4525d53e
child 296 f1007170201e
equal deleted inserted replaced
268:978db6396b49 269:167651794a77
    49 
    49 
    50 	ImageView openOn:'bitmaps/garfield.gif'
    50 	ImageView openOn:'bitmaps/garfield.gif'
    51 	ImageView openOn:'bitmaps/SBrowser.xbm'
    51 	ImageView openOn:'bitmaps/SBrowser.xbm'
    52 
    52 
    53 	ImageView openOnImage:(Image fromFile:'bitmaps/garfield.gif')
    53 	ImageView openOnImage:(Image fromFile:'bitmaps/garfield.gif')
    54 	ImageView openOnImage:(Form fromFile:'SBrowser.xbm')
    54 	ImageView openOnImage:(Image fromFile:'bitmaps/SBrowser.xbm')
    55 "
    55 "
    56 ! !
    56 ! !
    57 
    57 
    58 !ImageView class methodsFor:'startup'!
    58 !ImageView class methodsFor:'startup'!
    59 
    59 
   153     ^ top
   153     ^ top
   154 
   154 
   155     "
   155     "
   156      ImageView openOnImage:(Image fromFile:'bitmaps/garfield.gif')
   156      ImageView openOnImage:(Image fromFile:'bitmaps/garfield.gif')
   157      ImageView openOnImage:(Image fromFile:'bitmaps/SBrowser.xbm')
   157      ImageView openOnImage:(Image fromFile:'bitmaps/SBrowser.xbm')
   158      ImageView openOnImage:(Form fromFile:'bitmaps/SBrowser.xbm')
       
   159     "
   158     "
   160 ! !
   159 ! !
   161 
   160 
   162 !ImageView methodsFor:'accessing'!
   161 !ImageView methodsFor:'accessing'!
   163 
   162 
   177 image:anImage
   176 image:anImage
   178     "set the image - show a wait cursor, since image dithering may take a while"
   177     "set the image - show a wait cursor, since image dithering may take a while"
   179 
   178 
   180     image := anImage.
   179     image := anImage.
   181     anImage notNil ifTrue:[
   180     anImage notNil ifTrue:[
   182         self cursor:Cursor wait.
   181 	self cursor:Cursor wait.
   183         shown ifTrue:[
   182 	shown ifTrue:[
   184             self invalidate
   183 	    self invalidate
   185         ].
   184 	].
   186         self contentsChanged.
   185 	self contentsChanged.
   187         self cursor:(Cursor normal).
   186 	self cursor:(Cursor normal).
   188     ].
   187     ].
   189 
   188 
   190     "
   189     "
   191      ImageView new realize image:(Image fromFile:'bitmaps/claus.gif')
   190      ImageView new realize image:(Image fromFile:'bitmaps/claus.gif')
   192 
   191 
   203 
   202 
   204 redrawX:x y:y width:w height:h
   203 redrawX:x y:y width:w height:h
   205     |xI yI depth ext|
   204     |xI yI depth ext|
   206 
   205 
   207     image notNil ifTrue:[
   206     image notNil ifTrue:[
   208         image device ~~ device ifTrue:[
   207 	image device ~~ device ifTrue:[
   209             self withWaitCursorDo:[
   208 	    self withWaitCursorDo:[
   210                 image := image on:device.
   209 		image := image on:device.
   211             ]
   210 	    ]
   212         ].
   211 	].
   213 
   212 
   214         ((depth := image depth) == 1) ifTrue:[
   213 	((depth := image depth) == 1) ifTrue:[
   215             self paint:(image colorFromValue:1)
   214 	    self paint:(image colorFromValue:1)
   216                     on:(image colorFromValue:0).
   215 		    on:(image colorFromValue:0).
   217         ].
   216 	].
   218         adjust == #center ifTrue:[
   217 	adjust == #center ifTrue:[
   219             ext := image extent.
   218 	    ext := image extent.
   220             xI := (width - (margin * 2) - (ext x)) // 2.
   219 	    xI := (width - (margin * 2) - (ext x)) // 2.
   221             yI := (height - (margin * 2) - (ext y)) // 2.
   220 	    yI := (height - (margin * 2) - (ext y)) // 2.
   222         ] ifFalse:[
   221 	] ifFalse:[
   223             xI := yI := margin
   222 	    xI := yI := margin
   224         ].
   223 	].
   225 
   224 
   226         (depth ~~ 1
   225 	(depth ~~ 1
   227         and:[image mask notNil]) ifTrue:[
   226 	and:[image mask notNil]) ifTrue:[
   228             self clearRectangleX:x y:y width:w height:h.
   227 	    self clearRectangleX:x y:y width:w height:h.
   229             self displayForm:image x:xI y:yI 
   228 	    self displayForm:image x:xI y:yI 
   230         ] ifFalse:[
   229 	] ifFalse:[
   231             self displayOpaqueForm:image x:xI y:yI 
   230 	    self displayOpaqueForm:image x:xI y:yI 
   232         ]
   231 	]
   233     ]
   232     ]
   234 
   233 
   235     "Created: 11.7.1996 / 21:02:12 / cg"
   234     "Created: 11.7.1996 / 21:02:12 / cg"
   236     "Modified: 5.9.1996 / 11:55:19 / cg"
   235     "Modified: 5.9.1996 / 11:55:19 / cg"
   237 ! !
   236 ! !
   260 ! !
   259 ! !
   261 
   260 
   262 !ImageView class methodsFor:'documentation'!
   261 !ImageView class methodsFor:'documentation'!
   263 
   262 
   264 version
   263 version
   265     ^ '$Header: /cvs/stx/stx/libwidg2/ImageView.st,v 1.24 1996-10-22 15:58:43 cg Exp $'
   264     ^ '$Header: /cvs/stx/stx/libwidg2/ImageView.st,v 1.25 1996-12-20 11:19:20 cg Exp $'
   266 ! !
   265 ! !