no hard error, if coming up on a different depth display,
and bgColor cannot be dithered.
--- a/DisplaySurface.st Fri Jul 04 19:04:51 2003 +0200
+++ b/DisplaySurface.st Mon Jul 14 13:35:05 2003 +0200
@@ -146,112 +146,112 @@
pixmapDepth deviceDepth defBG|
drawableId notNil ifTrue:[
- viewBackground isColor ifTrue:[
- viewBackground := viewBackground onDevice:device.
- id := viewBackground colorId.
- "
- a real color (i.e. one supported by the device) ?
- "
- id notNil ifTrue:[
- device setWindowBackground:id in:drawableId.
- ^ self
- ].
- "
- no, a dithered one - must have a dither-pattern
- (which is ready for the device, since viewBackground
- is already assigned to the device)
- "
- bgPixmap := viewBackground ditherForm.
- ] ifFalse:[
- "
- assume, it can convert itself to a form
- "
- bgPixmap := viewBackground asFormOn:device
- ].
-
- "
- must now have:
- a dithered color or bitmap or pixmap
- "
- bgPixmap isNil ifTrue:[
- 'DisplaySurface [warning]: background not convertable - ignored' errorPrintCR.
- ^ self
- ].
-
- "/ if the device does not support background pixmaps,
- "/ set the backgroundColor to the default background.
- "/ this will avoid flicker in win32 systems,
- "/ since that background is drawn directly in the
- "/ devices expose event handling.
- "/ (in contrast, the pixmap filling is done by the
- "/ window itself in its expose event handler)
-
- (device supportsViewBackgroundPixmap:bgPixmap) ifFalse:[
- defBG := View defaultViewBackgroundColor.
- defBG isColor ifTrue:[
- defBG := defBG onDevice:device.
- id := defBG colorId.
- id notNil ifTrue:[
- device setWindowBackground:id in:drawableId.
- ].
- ].
- ^ self
- ].
-
- w := bgPixmap width.
- h := bgPixmap height.
-
- deviceDepth := device depth.
- pixmapDepth := bgPixmap depth.
-
- (pixmapDepth ~~ deviceDepth) ifTrue:[
- (pixmapDepth ~~ 1) ifTrue:[
- self error:'bad dither depth (must be one or devices depth)'.
- ^ self
- ].
-
- "
- convert it into a deep form
- "
- colorMap := bgPixmap colorMap.
- devBgPixmap := Form width:w height:h depth:deviceDepth on:device.
- devBgPixmap isNil ifTrue:[
- 'DisplaySurface [warning]: could not create a device form for viewBackground' infoPrintCR.
- ^ self
- ].
- devBgPixmap paint:(colorMap at:1).
- devBgPixmap fillRectangleX:0 y:0 width:w height:h.
- devBgPixmap foreground:(colorMap at:2) background:(colorMap at:1).
- devBgPixmap copyPlaneFrom:bgPixmap x:0 y:0 toX:0 y:0 width:w height:h.
- bgPixmap := devBgPixmap.
- ] ifFalse:[
- (pixmapDepth == 1) ifTrue:[
- "
- although depth matches,
- values in the dither are to be interpreted via the ditherForms
- colormap, which is not always the same as blackpixel/whitepixel ...
- "
- colorMap := bgPixmap colorMap.
- (colorMap at:1) colorId == device whitepixel ifTrue:[
- (colorMap at:2) colorId == device blackpixel ifTrue:[
- "
- ok, can use it
- "
- device setWindowBackgroundPixmap:(bgPixmap id) in:drawableId.
- ^ self
- ]
- ].
-
- "
- no, must invert it
- "
- devBgPixmap := Form width:w height:h depth:deviceDepth on:device.
- devBgPixmap paint:(colorMap at:2) on:(colorMap at:1).
- devBgPixmap copyPlaneFrom:bgPixmap x:0 y:0 toX:0 y:0 width:w height:h.
- bgPixmap := devBgPixmap.
- ]
- ].
- device setWindowBackgroundPixmap:(bgPixmap id) in:drawableId.
+ viewBackground isColor ifTrue:[
+ viewBackground := viewBackground onDevice:device.
+ id := viewBackground colorId.
+ "
+ a real color (i.e. one supported by the device) ?
+ "
+ id notNil ifTrue:[
+ device setWindowBackground:id in:drawableId.
+ ^ self
+ ].
+ "
+ no, a dithered one - must have a dither-pattern
+ (which is ready for the device, since viewBackground
+ is already assigned to the device)
+ "
+ bgPixmap := viewBackground ditherForm.
+ ] ifFalse:[
+ "
+ assume, it can convert itself to a form
+ "
+ bgPixmap := viewBackground asFormOn:device
+ ].
+
+ "
+ must now have:
+ a dithered color or bitmap or pixmap
+ "
+ bgPixmap isNil ifTrue:[
+ 'DisplaySurface [warning]: background not convertable - ignored' errorPrintCR.
+ ^ self
+ ].
+
+ "/ if the device does not support background pixmaps,
+ "/ set the backgroundColor to the default background.
+ "/ this will avoid flicker in win32 systems,
+ "/ since that background is drawn directly in the
+ "/ devices expose event handling.
+ "/ (in contrast, the pixmap filling is done by the
+ "/ window itself in its expose event handler)
+
+ (device supportsViewBackgroundPixmap:bgPixmap) ifFalse:[
+ defBG := View defaultViewBackgroundColor.
+ defBG isColor ifTrue:[
+ defBG := defBG onDevice:device.
+ id := defBG colorId.
+ id notNil ifTrue:[
+ device setWindowBackground:id in:drawableId.
+ ].
+ ].
+ ^ self
+ ].
+
+ w := bgPixmap width.
+ h := bgPixmap height.
+
+ deviceDepth := device depth.
+ pixmapDepth := bgPixmap depth.
+
+ (pixmapDepth ~~ deviceDepth) ifTrue:[
+ (pixmapDepth ~~ 1) ifTrue:[
+ 'DisplaySurface [warning]: Bad dither depth (must be one or devices depth)' errorPrintCR.
+ ^ self
+ ].
+
+ "
+ convert it into a deep form
+ "
+ colorMap := bgPixmap colorMap.
+ devBgPixmap := Form width:w height:h depth:deviceDepth on:device.
+ devBgPixmap isNil ifTrue:[
+ 'DisplaySurface [warning]: could not create a device form for viewBackground' infoPrintCR.
+ ^ self
+ ].
+ devBgPixmap paint:(colorMap at:1).
+ devBgPixmap fillRectangleX:0 y:0 width:w height:h.
+ devBgPixmap foreground:(colorMap at:2) background:(colorMap at:1).
+ devBgPixmap copyPlaneFrom:bgPixmap x:0 y:0 toX:0 y:0 width:w height:h.
+ bgPixmap := devBgPixmap.
+ ] ifFalse:[
+ (pixmapDepth == 1) ifTrue:[
+ "
+ although depth matches,
+ values in the dither are to be interpreted via the ditherForms
+ colormap, which is not always the same as blackpixel/whitepixel ...
+ "
+ colorMap := bgPixmap colorMap.
+ (colorMap at:1) colorId == device whitepixel ifTrue:[
+ (colorMap at:2) colorId == device blackpixel ifTrue:[
+ "
+ ok, can use it
+ "
+ device setWindowBackgroundPixmap:(bgPixmap id) in:drawableId.
+ ^ self
+ ]
+ ].
+
+ "
+ no, must invert it
+ "
+ devBgPixmap := Form width:w height:h depth:deviceDepth on:device.
+ devBgPixmap paint:(colorMap at:2) on:(colorMap at:1).
+ devBgPixmap copyPlaneFrom:bgPixmap x:0 y:0 toX:0 y:0 width:w height:h.
+ bgPixmap := devBgPixmap.
+ ]
+ ].
+ device setWindowBackgroundPixmap:(bgPixmap id) in:drawableId.
]
"Modified: / 4.5.1999 / 18:42:22 / cg"
@@ -2336,7 +2336,7 @@
!DisplaySurface class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libview/DisplaySurface.st,v 1.102 2003-05-07 14:59:48 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libview/DisplaySurface.st,v 1.103 2003-07-14 11:35:05 cg Exp $'
! !
DisplaySurface initialize!