author | Claus Gittinger <cg@exept.de> |
Mon, 27 Jul 1998 12:15:11 +0200 | |
changeset 2187 | 995bb5c1f6d2 |
parent 1727 | c2140507ab19 |
child 2188 | 6b013c605bc9 |
permissions | -rw-r--r-- |
0 | 1 |
" |
6 | 2 |
COPYRIGHT (c) 1991 by Claus Gittinger |
72 | 3 |
All Rights Reserved |
0 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
135 | 13 |
SimpleView subclass:#ShadowView |
616 | 14 |
instanceVariableNames:'myView shadowLength shadowClr imageUnderShadow' |
15 |
classVariableNames:'' |
|
16 |
poolDictionaries:'' |
|
626 | 17 |
category:'Views-Special' |
0 | 18 |
! |
19 |
||
1292 | 20 |
!ShadowView class methodsFor:'documentation'! |
46 | 21 |
|
22 |
copyright |
|
23 |
" |
|
24 |
COPYRIGHT (c) 1991 by Claus Gittinger |
|
72 | 25 |
All Rights Reserved |
0 | 26 |
|
46 | 27 |
This software is furnished under a license and may be used |
28 |
only in accordance with the terms of that license and with the |
|
29 |
inclusion of the above copyright notice. This software may not |
|
30 |
be provided or otherwise made available to, or used by, any |
|
31 |
other person. No title to or ownership of the software is |
|
32 |
hereby transferred. |
|
33 |
" |
|
34 |
! |
|
0 | 35 |
|
46 | 36 |
documentation |
37 |
" |
|
676 | 38 |
ShadowView exists just to give PopUps and ModalBoxes a shadow. |
39 |
||
72 | 40 |
If shadowClr is nil, the shadowView reads the screen-contents under |
41 |
itself before realization, and uses a greyed version of these pixels |
|
42 |
for its background. If shadowClr is non-nil, that color is used |
|
43 |
as shadow (can be used for solid-black shadows). |
|
44 |
||
45 |
The instance variable myView is the view, for which the shadow is for. |
|
616 | 46 |
|
47 |
[author:] |
|
48 |
Claus Gittinger |
|
46 | 49 |
" |
50 |
! ! |
|
0 | 51 |
|
269 | 52 |
!ShadowView methodsFor:'accessing'! |
53 |
||
54 |
for:aView |
|
676 | 55 |
"set the view I am a shadow for" |
269 | 56 |
|
57 |
myView := aView |
|
676 | 58 |
|
59 |
"Modified: 12.5.1996 / 21:59:17 / cg" |
|
269 | 60 |
! |
61 |
||
62 |
isPopUpView |
|
676 | 63 |
"return true, since I want to come up without decoration" |
64 |
||
269 | 65 |
^ true |
676 | 66 |
|
67 |
"Modified: 12.5.1996 / 21:57:23 / cg" |
|
269 | 68 |
! |
69 |
||
70 |
shadowColor:aColor |
|
676 | 71 |
"set the shadow color" |
269 | 72 |
|
73 |
shadowClr := aColor |
|
676 | 74 |
|
75 |
"Modified: 12.5.1996 / 21:59:25 / cg" |
|
269 | 76 |
! ! |
77 |
||
78 |
!ShadowView methodsFor:'event handling'! |
|
79 |
||
80 |
redraw |
|
676 | 81 |
"if I have a shadowColor, fill all of myself with it; |
82 |
otherwise, draw the saved image under myself." |
|
269 | 83 |
|
84 |
|ws hs| |
|
85 |
||
274 | 86 |
ws := shadowLength x. |
87 |
hs := shadowLength y. |
|
269 | 88 |
shadowClr isNil ifTrue:[ |
676 | 89 |
imageUnderShadow isNil ifTrue:[^ self]. |
269 | 90 |
|
676 | 91 |
self copyFrom:imageUnderShadow x:(width - ws) y:0 |
92 |
toX:(width - ws) y:0 |
|
93 |
width:ws height:height. |
|
94 |
self copyFrom:imageUnderShadow x:0 y:(height - hs) |
|
95 |
toX:0 y:(height - hs) |
|
96 |
width:width height:hs. |
|
269 | 97 |
|
98 |
] ifFalse:[ |
|
676 | 99 |
self paint:shadowClr. |
100 |
self fillRectangleX:(width - ws) y:0 width:ws height:height |
|
269 | 101 |
] |
676 | 102 |
|
103 |
"Modified: 12.5.1996 / 22:00:05 / cg" |
|
269 | 104 |
! ! |
105 |
||
0 | 106 |
!ShadowView methodsFor:'initialization'! |
107 |
||
269 | 108 |
create |
676 | 109 |
"enable saveUnder of the covered view(s). |
110 |
This may not be supported by all devices - these have to redraw then" |
|
111 |
||
269 | 112 |
super create. |
113 |
self backingStore:false. |
|
114 |
self saveUnder:true |
|
676 | 115 |
|
116 |
"Modified: 12.5.1996 / 22:00:47 / cg" |
|
269 | 117 |
! |
118 |
||
2187
995bb5c1f6d2
no need to initStyle in shadowViews.
Claus Gittinger <cg@exept.de>
parents:
1727
diff
changeset
|
119 |
initStyle |
995bb5c1f6d2
no need to initStyle in shadowViews.
Claus Gittinger <cg@exept.de>
parents:
1727
diff
changeset
|
120 |
^ self |
995bb5c1f6d2
no need to initStyle in shadowViews.
Claus Gittinger <cg@exept.de>
parents:
1727
diff
changeset
|
121 |
|
995bb5c1f6d2
no need to initStyle in shadowViews.
Claus Gittinger <cg@exept.de>
parents:
1727
diff
changeset
|
122 |
"Created: / 27.7.1998 / 11:40:27 / cg" |
995bb5c1f6d2
no need to initStyle in shadowViews.
Claus Gittinger <cg@exept.de>
parents:
1727
diff
changeset
|
123 |
! |
995bb5c1f6d2
no need to initStyle in shadowViews.
Claus Gittinger <cg@exept.de>
parents:
1727
diff
changeset
|
124 |
|
0 | 125 |
initialize |
126 |
super initialize. |
|
127 |
borderWidth := 0. |
|
72 | 128 |
|
274 | 129 |
shadowClr := StyleSheet at:#popUpShadowColor. |
0 | 130 |
|
131 |
"the length of the shadow from myView" |
|
132 |
shadowLength := (device pixelPerMillimeter * 1.0) rounded |
|
133 |
! |
|
134 |
||
135 |
realize |
|
54 | 136 |
"realize the shadowView some distance away from myView, |
137 |
get the pixels under the shadow from the screen" |
|
0 | 138 |
|
72 | 139 |
|root shW shH right bot kludge clr1 clr0 org blackIs0| |
0 | 140 |
|
141 |
myView notNil ifTrue:[ |
|
743 | 142 |
self origin:(myView origin + (myView borderWidth * 2) + shadowLength) |
143 |
extent:(myView extent). |
|
0 | 144 |
|
743 | 145 |
shadowClr isNil ifTrue:[ |
146 |
" |
|
147 |
get the pixels under the shadow |
|
148 |
(copy from root-view into the 'imageUnderShadow'-form) |
|
149 |
" |
|
150 |
imageUnderShadow := Form width:width height:height depth:device depth on:device. |
|
1727
c2140507ab19
oops - X needs clippedByChildren:false.
Claus Gittinger <cg@exept.de>
parents:
1722
diff
changeset
|
151 |
imageUnderShadow clippedByChildren:false. |
0 | 152 |
|
743 | 153 |
shW := shadowLength x. |
154 |
shH := shadowLength y. |
|
155 |
right := width - shW. |
|
156 |
bot := height - shH. |
|
54 | 157 |
|
743 | 158 |
root := device rootView. |
159 |
||
160 |
clr0 := Color colorId:0. |
|
161 |
clr1 := Color colorId:1. |
|
2 | 162 |
|
743 | 163 |
kludge := device depth == 1. |
164 |
blackIs0 := (device blackpixel == 0). |
|
165 |
(kludge and:[blackIs0]) ifTrue:[ |
|
1727
c2140507ab19
oops - X needs clippedByChildren:false.
Claus Gittinger <cg@exept.de>
parents:
1722
diff
changeset
|
166 |
imageUnderShadow foreground:clr0 background:clr1. |
743 | 167 |
]. |
2 | 168 |
|
743 | 169 |
org := self origin. |
0 | 170 |
|
743 | 171 |
imageUnderShadow copyFrom:root x:(org x + right) y:org y |
172 |
toX:right y:0 width:shW height:height. |
|
0 | 173 |
|
743 | 174 |
imageUnderShadow copyFrom:root x:org x y:(org y + bot) |
175 |
toX:0 y:bot width:width height:shH. |
|
72 | 176 |
|
743 | 177 |
" |
178 |
grey out the image (by oring-in a grey pattern) |
|
179 |
(sometimes we are lucky, and can do it with one raster-op) |
|
180 |
" |
|
181 |
(kludge and:[blackIs0]) ifFalse:[ |
|
182 |
imageUnderShadow foreground:clr0 background:(Color colorId:-1). |
|
183 |
imageUnderShadow mask:(Form mediumGreyFormOn:device). |
|
184 |
imageUnderShadow function:#and. |
|
185 |
imageUnderShadow fillRectangleX:right y:0 width:shW height:height. |
|
186 |
imageUnderShadow fillRectangleX:0 y:bot width:width height:shH. |
|
0 | 187 |
|
743 | 188 |
blackIs0 ifFalse:[ |
189 |
imageUnderShadow foreground:(Color black on:device) background:clr0. |
|
190 |
imageUnderShadow function:#or. |
|
191 |
imageUnderShadow fillRectangleX:right y:0 width:shW height:height. |
|
192 |
imageUnderShadow fillRectangleX:0 y:bot width:width height:shH. |
|
193 |
] |
|
194 |
] ifTrue:[ |
|
195 |
imageUnderShadow foreground:clr1 background:clr0. |
|
196 |
imageUnderShadow mask:(Form mediumGreyFormOn:device). |
|
197 |
imageUnderShadow function:#or. |
|
198 |
imageUnderShadow fillRectangleX:right y:0 width:shW height:height. |
|
199 |
imageUnderShadow fillRectangleX:0 y:bot width:width height:shH. |
|
200 |
]. |
|
201 |
]. |
|
202 |
super realize. |
|
203 |
self raise |
|
0 | 204 |
] |
743 | 205 |
|
1727
c2140507ab19
oops - X needs clippedByChildren:false.
Claus Gittinger <cg@exept.de>
parents:
1722
diff
changeset
|
206 |
"Modified: 12.5.1997 / 21:38:04 / cg" |
0 | 207 |
! |
208 |
||
12 | 209 |
recreate |
72 | 210 |
shadowClr notNil ifTrue:[ |
211 |
shadowClr := shadowClr on:device |
|
212 |
]. |
|
12 | 213 |
|
214 |
"the length of the shadow from myView" |
|
215 |
shadowLength := (device pixelPerMillimeter * 1.0) rounded. |
|
216 |
||
217 |
super recreate. |
|
218 |
self backingStore:false. |
|
219 |
self saveUnder:true |
|
269 | 220 |
! |
221 |
||
642 | 222 |
unmap |
676 | 223 |
"relase the saved image of the covered view" |
224 |
||
269 | 225 |
imageUnderShadow := nil. |
642 | 226 |
super unmap. |
227 |
||
228 |
"Modified: 3.5.1996 / 23:45:23 / stefan" |
|
676 | 229 |
"Modified: 12.5.1996 / 22:01:17 / cg" |
0 | 230 |
! ! |
231 |
||
1292 | 232 |
!ShadowView class methodsFor:'documentation'! |
0 | 233 |
|
269 | 234 |
version |
2187
995bb5c1f6d2
no need to initStyle in shadowViews.
Claus Gittinger <cg@exept.de>
parents:
1727
diff
changeset
|
235 |
^ '$Header: /cvs/stx/stx/libview/ShadowView.st,v 1.26 1998-07-27 10:15:11 cg Exp $' |
0 | 236 |
! ! |