--- a/DisplayRootView.st Sat Sep 18 16:17:46 1999 +0200
+++ b/DisplayRootView.st Mon Sep 20 08:59:09 1999 +0200
@@ -35,8 +35,9 @@
documentation
"
- this class describes Xs rootWindow (which is the background window and
- can be used for drawing outside of Views i.e. for dragging between Views).
+ this class describes the rootWindow (which is the background window or
+ desktop and can be used for drawing outside of Views
+ i.e. for dragging between Views).
For historic and compatibility reasons, there is a global variable
called 'RootView', which is bound to the default displays ('Display')
@@ -56,7 +57,9 @@
windowManager menus are drawn. If that is the case, your paining
into the rootView may not be visible, unless you set the #noClipByChildren
option (see below).
-
+ Also, it is not guaranteed, that all devices support drawing in the
+ root window - especially if the device is a simulated one, such as
+ a remote webBrowser ...
In general, you should never use the rootView for normal applications.
To draw in the (Displays) root window:
@@ -110,23 +113,25 @@
!DisplayRootView methodsFor:'accessing'!
controller
- "I have no controller"
+ "return nil - I have no controller"
^ nil
!
name
+ "return my name - always 'RootWindow'"
+
^ 'RootWindow'
!
sensor
- "I have no sensor"
+ "return nil, since I have no sensor"
^ nil
!
windowGroup
- "I have no windowGroup"
+ "return nil - I have no windowGroup"
^ nil
! !
@@ -165,8 +170,10 @@
canDrop:aCollectionOfDropObjects
"return true, if aCollectionOfDropObjects can be
- dropped in the receiver. This method should be
- redefined in views which can take objects"
+ dropped in the receiver.
+ False is returned here, since nothing can be dropped on the desktop.
+ (for now - actually some systems do allow dropping things on the desktop
+ and this query should be forwarded to my display device)"
^ false
@@ -174,7 +181,7 @@
!
isRootView
- "yes, I am a rootview"
+ "return true, since yes, I am a rootview"
^ true
@@ -189,15 +196,17 @@
|errorOccured|
+ device platformName = 'WIN32' ifTrue:[^ true].
+
errorOccured := false.
device class deviceErrorSignal handle:[:ex |
- errorOccured := true.
- ex return
+ errorOccured := true.
+ ex return
] do:[
- self enableButtonEvents.
- device flush.
+ self enableButtonEvents.
+ device flush.
].
- ^ errorOccured
+ ^ errorOccured not
"
DisplayRootView new
@@ -206,7 +215,7 @@
!
shown
- "a rootview is always assumed to be visible"
+ "return true - a rootview is always assumed to be visible"
^ true
@@ -217,6 +226,6 @@
!DisplayRootView class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libview/DisplayRootView.st,v 1.22 1999-04-23 12:42:16 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libview/DisplayRootView.st,v 1.23 1999-09-20 06:58:22 cg Exp $'
! !
DisplayRootView initialize!
--- a/Image.st Sat Sep 18 16:17:46 1999 +0200
+++ b/Image.st Mon Sep 20 08:59:09 1999 +0200
@@ -8396,6 +8396,47 @@
"Modified: 24.4.1997 / 16:18:31 / cg"
!
+applyPixelValuesTo:pixelFunctionBlock into:newImage in:aRectangle
+ "helper for withPixelFunctionAppliedToValues:
+ enumerate pixelValues and evaluate the block for each.
+ To be redefined by subclasses for better performance."
+
+ |w "{Class: SmallInteger }"
+ h "{Class: SmallInteger }"
+ x0 "{Class: SmallInteger }"
+ y0 "{Class: SmallInteger }"
+ x1 "{Class: SmallInteger }"
+ y1 "{Class: SmallInteger }"
+ y "{Class: SmallInteger }"
+ newPixel newPixelRow pixelRow|
+
+ x0 := aRectangle left.
+ y0 := aRectangle top.
+ w := aRectangle width.
+ h := aRectangle height.
+
+ newPixelRow := Array new:w.
+ pixelRow := self pixelArraySpecies new:width.
+
+ y := y0.
+ h timesRepeat:[
+ self rowAt:y into:pixelRow.
+ 1 to:w do:[:runCol |
+ newPixel := pixelFunctionBlock
+ value:self
+ value:(pixelRow at:runCol+x0)
+ value:(runCol+x0-1)
+ value:y.
+ newPixelRow at:runCol put:newPixel.
+ ].
+ pixelRow replaceFrom:x0+1 to:x0+1+w-1 with:newPixelRow startingAt:1.
+ newImage rowAt:y putAll:newPixelRow.
+ y := y + 1.
+ ].
+
+ "Modified: 24.4.1997 / 16:18:31 / cg"
+!
+
colorMapProcessing:aBlock
"a helper for all kinds of colormap manipulations.
The argument, aBlock is called for every colormap entry,
@@ -9853,7 +9894,8 @@
].
^ newImage
- "
+ "black out everything except for some rectangle:
+
|i black|
i := Image fromFile:'bitmaps/gifImages/claus.gif'.
@@ -9869,6 +9911,26 @@
]
]) inspect.
"
+ "brighten a frame:
+
+ |i black w h|
+
+ i := Image fromFile:'bitmaps/gifImages/claus.gif'.
+ i inspect.
+
+ w := i width.
+ h := i height.
+ (i withPixelFunctionApplied:[:oldImage :oldColor :x :y |
+ ((x between:0 and:10)
+ or:[(y between:0 and:10)
+ or:[(x between:w-10 and:w)
+ or:[y between:h-10 and:h]]]) ifTrue:[
+ oldColor lightened nearestIn:i colorMap
+ ] ifFalse:[
+ oldColor.
+ ]
+ ]) inspect.
+ "
"Modified: 24.4.1997 / 18:36:59 / cg"
!
@@ -10621,7 +10683,7 @@
blackComponentOfCMYK:pixel
"if the receiver is a cmyk-image:
- return the black component (0 .. 100) of a pixelValue."
+ return the black component scaled to a percentage (0 .. 100) of a pixelValue."
samplesPerPixel == 4 ifTrue:[
"/ assume that the cyan bits are the leftMost bits (cmyk)
@@ -10637,7 +10699,9 @@
blueBitsOf:pixel
"if the receiver is an rgb-image:
- return the blue bits of a pixelValue.
+ return the blue bits of a pixelValue as integer 0..maxBlueValue.
+ MaxGreenValue is of course the largest integer representable by the number
+ of blue bits i.e. (1 bitShift:bitsBlue)-1.
This has to be redefined by subclasses."
|blueBits|
@@ -10659,7 +10723,7 @@
blueComponentOf:pixel
"if the receiver is an rgb-image:
- return the blue component (0 .. 100) of a pixelValue.
+ return the blue component scaled to a percentage (0 .. 100) of a pixelValue.
This has to be redefined by subclasses."
|blueBits "{ Class: SmallInteger }"
@@ -10793,7 +10857,7 @@
cyanComponentOfCMY:pixel
"if the receiver is a cmy-image:
- return the cyan component (0 .. 100) of a pixelValue."
+ return the cyan component scaled to a percentage (0 .. 100) of a pixelValue."
samplesPerPixel == 3 ifTrue:[
"/ assume that the cyan bits are the leftMost bits (cmy)
@@ -10809,7 +10873,7 @@
cyanComponentOfCMYK:pixel
"if the receiver is a cmyk-image:
- return the cyan component (0 .. 100) of a pixelValue."
+ return the cyan component scaled to a percentage (0 .. 100) of a pixelValue."
samplesPerPixel == 4 ifTrue:[
"/ assume that the cyan bits are the leftMost bits (cmyk)
@@ -10825,7 +10889,9 @@
greenBitsOf:pixel
"if the receiver is an rgb-image:
- return the green bits of a pixelValue.
+ return the green bits of a pixelValue as integer 0..maxGreenValue.
+ MaxGreenValue is of course the largest integer representable by the number
+ of green bits i.e. (1 bitShift:bitsGreen)-1.
This has to be redefined by subclasses."
|blueBits greenBits|
@@ -10848,7 +10914,7 @@
greenComponentOf:pixel
"if the receiver is an rgb-image:
- return the green component (0..100) of a pixelValue.
+ return the green component scaled to a percentage (0..100) of a pixelValue.
This has to be redefined by subclasses."
|greenBits "{ Class: SmallInteger }"
@@ -10906,7 +10972,7 @@
magentaComponentOfCMY:pixel
"if the receiver is a cmy-image:
- return the magenta component (0 .. 100) of a pixelValue."
+ return the magenta component scaled to a percentage (0 .. 100) of a pixelValue."
samplesPerPixel == 3 ifTrue:[
"/ assume that the cyan bits are the leftMost bits (cmy)
@@ -10922,7 +10988,7 @@
magentaComponentOfCMYK:pixel
"if the receiver is a cmyk-image:
- return the magenta component (0 .. 100) of a pixelValue."
+ return the magenta component scaled to a percentage (0 .. 100) of a pixelValue."
samplesPerPixel == 4 ifTrue:[
"/ assume that the cyan bits are the leftMost bits (cmyk)
@@ -10982,7 +11048,9 @@
redBitsOf:pixel
"if the receiver is an rgb-image:
- return the red component of a pixelValue.
+ return the red component of a pixelValue as integer 0..maxRedValue.
+ MaxRedValue is of course the largest integer representable by the number
+ of red bits i.e. (1 bitShift:bitsRed)-1.
This has to be redefined by subclasses."
|redBits greenBits blueBits|
@@ -11007,7 +11075,7 @@
redComponentOf:pixel
"if the receiver is an rgb-image:
- return the red component (0..100) of a pixelValue.
+ return the red component scaled to a percentage (0..100) of a pixelValue.
This has to be redefined by subclasses."
|redBits "{ Class: SmallInteger }"
@@ -11176,6 +11244,29 @@
"Modified: / 30.9.1998 / 22:03:50 / cg"
!
+valueFromRedBits:redBits greenBits:greenBits blueBits:blueBits
+ "given a rgb bits, each in 0..maxXXXValue (i.e. according to
+ r/g/b channels number of bits, return the corresponding pixel value.
+ For now, only useful with RGB images"
+
+ |pixel numGreenBits numBlueBits|
+
+ photometric == #rgb ifTrue:[
+ samplesPerPixel >= 3 ifTrue:[
+ numGreenBits := bitsPerSample at:2.
+ numBlueBits := bitsPerSample at:3.
+
+ pixel := (((redBits bitShift:numGreenBits) + greenBits) bitShift:numBlueBits) + blueBits.
+ ^ pixel
+ ]
+ ].
+
+ ImageErrorSignal raiseErrorString:'format not supported'.
+ ^ nil
+
+ "Modified: / 30.9.1998 / 22:03:50 / cg"
+!
+
widthOn:aGC
"return my width, if displayed on aGC;
since my width is independent of the device (the number of pixels),
@@ -11189,7 +11280,7 @@
yellowComponentOfCMY:pixel
"if the receiver is a cmy-image:
- return the yellow component (0 .. 100) of a pixelValue."
+ return the yellow component scaled to a percentage (0 .. 100) of a pixelValue."
samplesPerPixel == 3 ifTrue:[
"/ assume that the cyan bits are the leftMost bits (cmy)
@@ -11206,7 +11297,7 @@
yellowComponentOfCMYK:pixel
"if the receiver is a cmyk-image:
- return the yellow component (0 .. 100) of a pixelValue."
+ return the yellow component scaled to a percentage (0 .. 100) of a pixelValue."
samplesPerPixel == 4 ifTrue:[
"/ assume that the cyan bits are the leftMost bits (cmyk)
@@ -11797,6 +11888,6 @@
!Image class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libview/Image.st,v 1.279 1999-09-18 10:13:16 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libview/Image.st,v 1.280 1999-09-20 06:59:09 cg Exp $'
! !
Image initialize!
--- a/ShadowView.st Sat Sep 18 16:17:46 1999 +0200
+++ b/ShadowView.st Mon Sep 20 08:59:09 1999 +0200
@@ -130,9 +130,10 @@
"realize the shadowView some distance away from myView,
get the pixels under the shadow from the screen"
- |root shW shH right bot kludge clr1 clr0 org blackIs0|
+ |root shW shH right bot kludge clr1 clr0 org blackIs0 img|
myView notNil ifTrue:[
+
self origin:(myView origin + (myView borderWidth * 2) + shadowLength)
extent:(myView extent).
@@ -168,29 +169,65 @@
imageUnderShadow copyFrom:root x:org x y:(org y + bot)
toX:0 y:bot width:width height:shH.
- "
- grey out the image (by oring-in a grey pattern)
- (sometimes we are lucky, and can do it with one raster-op)
- "
- (kludge and:[blackIs0]) ifFalse:[
- imageUnderShadow foreground:clr0 background:(Color colorId:-1).
- imageUnderShadow mask:(Form mediumGreyFormOn:device).
- imageUnderShadow function:#and.
- imageUnderShadow fillRectangleX:right y:0 width:shW height:height.
- imageUnderShadow fillRectangleX:0 y:bot width:width height:shH.
+ false "device visualType == #TrueColor" ifTrue:[
+ "
+ grey out the image (by darkening the pixels)
+ (thats expensive ...)
+ "
+ img := Image fromForm:imageUnderShadow.
+ 0 to:height-1-shH do:[:y |
+ right to:right+shW-1 do:[:x | |pix r g b|
+ pix := img pixelAtX:x y:y.
+ r := img redBitsOf:pix.
+ g := img greenBitsOf:pix.
+ b := img blueBitsOf:pix.
+ r := r // 2.
+ g := g // 2.
+ b := b // 2.
+ pix := img valueFromRedBits:r greenBits:g blueBits:b.
+ img pixelAtX:x y:y put:pix.
+ ].
+ ].
+ 0 to:width-1 do:[:x |
+ bot to:bot+shH-1 do:[:y | |pix r g b|
+ pix := img pixelAtX:x y:y.
+ r := img redBitsOf:pix.
+ g := img greenBitsOf:pix.
+ b := img blueBitsOf:pix.
+ r := r // 2.
+ g := g // 2.
+ b := b // 2.
+ pix := img valueFromRedBits:r greenBits:g blueBits:b.
+ img pixelAtX:x y:y put:pix.
+ ].
+ ].
+ imageUnderShadow := img asFormOn:device.
+ ] ifFalse:[
+ "
+ grey out the image (by oring-in a grey pattern)
+ (sometimes we are lucky, and can do it with one raster-op)
+ "
- blackIs0 ifFalse:[
- imageUnderShadow foreground:(Color black onDevice:device) background:clr0.
+ (kludge and:[blackIs0]) ifFalse:[
+ imageUnderShadow foreground:clr0 background:(Color colorId:-1).
+ imageUnderShadow mask:(Form mediumGreyFormOn:device).
+ imageUnderShadow function:#and.
+ imageUnderShadow fillRectangleX:right y:0 width:shW height:height.
+ imageUnderShadow fillRectangleX:0 y:bot width:width height:shH.
+
+ blackIs0 ifFalse:[
+ imageUnderShadow foreground:(Color black onDevice:device) background:clr0.
+ imageUnderShadow function:#or.
+ imageUnderShadow fillRectangleX:right y:0 width:shW height:height.
+ imageUnderShadow fillRectangleX:0 y:bot width:width height:shH.
+ ]
+ ] ifTrue:[
+ imageUnderShadow foreground:clr1 background:clr0.
+ imageUnderShadow mask:(Form mediumGreyFormOn:device).
imageUnderShadow function:#or.
imageUnderShadow fillRectangleX:right y:0 width:shW height:height.
imageUnderShadow fillRectangleX:0 y:bot width:width height:shH.
- ]
- ] ifTrue:[
- imageUnderShadow foreground:clr1 background:clr0.
- imageUnderShadow mask:(Form mediumGreyFormOn:device).
- imageUnderShadow function:#or.
- imageUnderShadow fillRectangleX:right y:0 width:shW height:height.
- imageUnderShadow fillRectangleX:0 y:bot width:width height:shH.
+ ].
].
].
super realize.
@@ -227,5 +264,5 @@
!ShadowView class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libview/ShadowView.st,v 1.29 1999-08-18 14:35:26 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libview/ShadowView.st,v 1.30 1999-09-20 06:58:54 cg Exp $'
! !