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
|
72
|
14 |
instanceVariableNames:'myView shadowLength shadowClr imageUnderShadow'
|
0
|
15 |
classVariableNames:''
|
|
16 |
poolDictionaries:''
|
|
17 |
category:'Views-Basic'
|
|
18 |
!
|
|
19 |
|
|
20 |
ShadowView comment:'
|
46
|
21 |
COPYRIGHT (c) 1991 by Claus Gittinger
|
72
|
22 |
All Rights Reserved
|
54
|
23 |
|
157
|
24 |
$Header: /cvs/stx/stx/libview/ShadowView.st,v 1.11 1995-07-23 02:28:15 claus Exp $
|
46
|
25 |
'!
|
0
|
26 |
|
46
|
27 |
!ShadowView class methodsFor:'documentation'!
|
|
28 |
|
|
29 |
copyright
|
|
30 |
"
|
|
31 |
COPYRIGHT (c) 1991 by Claus Gittinger
|
72
|
32 |
All Rights Reserved
|
0
|
33 |
|
46
|
34 |
This software is furnished under a license and may be used
|
|
35 |
only in accordance with the terms of that license and with the
|
|
36 |
inclusion of the above copyright notice. This software may not
|
|
37 |
be provided or otherwise made available to, or used by, any
|
|
38 |
other person. No title to or ownership of the software is
|
|
39 |
hereby transferred.
|
|
40 |
"
|
|
41 |
!
|
0
|
42 |
|
46
|
43 |
version
|
|
44 |
"
|
157
|
45 |
$Header: /cvs/stx/stx/libview/ShadowView.st,v 1.11 1995-07-23 02:28:15 claus Exp $
|
46
|
46 |
"
|
|
47 |
!
|
|
48 |
|
|
49 |
documentation
|
|
50 |
"
|
54
|
51 |
just to give PopUps and ModalBoxes a shadow.
|
72
|
52 |
If shadowClr is nil, the shadowView reads the screen-contents under
|
|
53 |
itself before realization, and uses a greyed version of these pixels
|
|
54 |
for its background. If shadowClr is non-nil, that color is used
|
|
55 |
as shadow (can be used for solid-black shadows).
|
|
56 |
|
|
57 |
The instance variable myView is the view, for which the shadow is for.
|
46
|
58 |
"
|
|
59 |
! !
|
0
|
60 |
|
|
61 |
!ShadowView methodsFor:'initialization'!
|
|
62 |
|
|
63 |
initialize
|
|
64 |
super initialize.
|
|
65 |
borderWidth := 0.
|
72
|
66 |
|
|
67 |
shadowClr := StyleSheet at:#shadowColor.
|
0
|
68 |
|
|
69 |
"the length of the shadow from myView"
|
|
70 |
shadowLength := (device pixelPerMillimeter * 1.0) rounded
|
|
71 |
!
|
|
72 |
|
|
73 |
realize
|
54
|
74 |
"realize the shadowView some distance away from myView,
|
|
75 |
get the pixels under the shadow from the screen"
|
0
|
76 |
|
72
|
77 |
|root shW shH right bot kludge clr1 clr0 org blackIs0|
|
0
|
78 |
|
|
79 |
myView notNil ifTrue:[
|
72
|
80 |
self origin:(myView origin + (myView borderWidth * 2) + shadowLength)
|
|
81 |
extent:(myView extent).
|
0
|
82 |
|
72
|
83 |
shadowClr isNil ifTrue:[
|
|
84 |
"
|
|
85 |
get the pixels under the shadow
|
|
86 |
(copy from root-view into the 'imageUnderShadow'-form)
|
|
87 |
"
|
|
88 |
imageUnderShadow := Form width:width height:height depth:device depth on:device.
|
|
89 |
imageUnderShadow initGC.
|
|
90 |
device setClipByChildren:false in:imageUnderShadow gcId.
|
0
|
91 |
|
72
|
92 |
shW := shadowLength x.
|
|
93 |
shH := shadowLength y.
|
|
94 |
right := width - shW.
|
|
95 |
bot := height - shH.
|
54
|
96 |
|
72
|
97 |
root := DisplayRootView new.
|
2
|
98 |
|
72
|
99 |
clr0 := Color colorId:0.
|
|
100 |
clr1 := Color colorId:1.
|
2
|
101 |
|
72
|
102 |
kludge := root device depth == 1.
|
|
103 |
blackIs0 := (root device blackpixel == 0).
|
|
104 |
(kludge and:[blackIs0]) ifTrue:[
|
|
105 |
imageUnderShadow foreground:clr0 background:clr1.
|
|
106 |
].
|
0
|
107 |
|
72
|
108 |
org := self origin.
|
0
|
109 |
|
72
|
110 |
imageUnderShadow copyFrom:root x:(org x + right) y:org y
|
|
111 |
toX:right y:0 width:shW height:height.
|
|
112 |
|
|
113 |
imageUnderShadow copyFrom:root x:org x y:(org y + bot)
|
|
114 |
toX:0 y:bot width:width height:shH.
|
|
115 |
|
|
116 |
"
|
|
117 |
grey out the image (by oring-in a grey pattern)
|
|
118 |
(sometimes we are lucky, and can do it with one raster-op)
|
|
119 |
"
|
|
120 |
(kludge and:[blackIs0]) ifFalse:[
|
|
121 |
imageUnderShadow foreground:clr0 background:(Color colorId:-1).
|
|
122 |
imageUnderShadow mask:(Form mediumGreyFormOn:device).
|
|
123 |
imageUnderShadow function:#and.
|
|
124 |
imageUnderShadow fillRectangleX:right y:0 width:shW height:height.
|
|
125 |
imageUnderShadow fillRectangleX:0 y:bot width:width height:shH.
|
0
|
126 |
|
72
|
127 |
blackIs0 ifFalse:[
|
|
128 |
imageUnderShadow foreground:(Color black on:device) background:clr0.
|
|
129 |
imageUnderShadow function:#or.
|
|
130 |
imageUnderShadow fillRectangleX:right y:0 width:shW height:height.
|
|
131 |
imageUnderShadow fillRectangleX:0 y:bot width:width height:shH.
|
|
132 |
]
|
|
133 |
] ifTrue:[
|
|
134 |
imageUnderShadow foreground:clr1 background:clr0.
|
|
135 |
imageUnderShadow mask:(Form mediumGreyFormOn:device).
|
|
136 |
imageUnderShadow function:#or.
|
|
137 |
imageUnderShadow fillRectangleX:right y:0 width:shW height:height.
|
|
138 |
imageUnderShadow fillRectangleX:0 y:bot width:width height:shH.
|
|
139 |
].
|
|
140 |
].
|
|
141 |
super realize.
|
|
142 |
self raise
|
0
|
143 |
]
|
|
144 |
!
|
|
145 |
|
|
146 |
unrealize
|
|
147 |
imageUnderShadow := nil.
|
|
148 |
super unrealize.
|
|
149 |
!
|
|
150 |
|
|
151 |
create
|
|
152 |
super create.
|
|
153 |
self backingStore:false.
|
12
|
154 |
self saveUnder:true
|
|
155 |
!
|
2
|
156 |
|
12
|
157 |
recreate
|
72
|
158 |
shadowClr notNil ifTrue:[
|
|
159 |
shadowClr := shadowClr on:device
|
|
160 |
].
|
12
|
161 |
|
|
162 |
"the length of the shadow from myView"
|
|
163 |
shadowLength := (device pixelPerMillimeter * 1.0) rounded.
|
|
164 |
|
|
165 |
super recreate.
|
|
166 |
self backingStore:false.
|
|
167 |
self saveUnder:true
|
0
|
168 |
! !
|
|
169 |
|
86
|
170 |
!ShadowView methodsFor:'event handling'!
|
0
|
171 |
|
|
172 |
redraw
|
|
173 |
"fill all of myself with black"
|
|
174 |
|
72
|
175 |
|ws hs|
|
|
176 |
|
|
177 |
shadowClr isNil ifTrue:[
|
|
178 |
imageUnderShadow isNil ifTrue:[^ self].
|
2
|
179 |
|
0
|
180 |
"
|
72
|
181 |
self foreground:(Color colorId:-1) background:(Color colorId:0).
|
|
182 |
self function:#copy.
|
0
|
183 |
"
|
72
|
184 |
ws := shadowLength x.
|
|
185 |
hs := shadowLength y.
|
|
186 |
self copyFrom:imageUnderShadow x:(width - ws) y:0
|
|
187 |
toX:(width - ws) y:0
|
|
188 |
width:ws height:height.
|
|
189 |
self copyFrom:imageUnderShadow x:0 y:(height - hs)
|
|
190 |
toX:0 y:(height - hs)
|
|
191 |
width:width height:hs.
|
0
|
192 |
|
72
|
193 |
] ifFalse:[
|
|
194 |
self paint:shadowClr.
|
|
195 |
self fillRectangleX:(width - ws) y:0 width:ws height:height
|
54
|
196 |
]
|
0
|
197 |
! !
|
|
198 |
|
|
199 |
!ShadowView methodsFor:'accessing'!
|
|
200 |
|
|
201 |
shadowColor:aColor
|
|
202 |
"to set the shadow color"
|
|
203 |
|
72
|
204 |
shadowClr := aColor
|
0
|
205 |
!
|
|
206 |
|
|
207 |
for:aView
|
|
208 |
"set the view I am for"
|
|
209 |
|
|
210 |
myView := aView
|
|
211 |
!
|
|
212 |
|
157
|
213 |
isPopUpView
|
0
|
214 |
^ true
|
|
215 |
! !
|