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 |
|
0
|
119 |
initialize
|
|
120 |
super initialize.
|
|
121 |
borderWidth := 0.
|
72
|
122 |
|
274
|
123 |
shadowClr := StyleSheet at:#popUpShadowColor.
|
0
|
124 |
|
|
125 |
"the length of the shadow from myView"
|
|
126 |
shadowLength := (device pixelPerMillimeter * 1.0) rounded
|
|
127 |
!
|
|
128 |
|
|
129 |
realize
|
54
|
130 |
"realize the shadowView some distance away from myView,
|
|
131 |
get the pixels under the shadow from the screen"
|
0
|
132 |
|
72
|
133 |
|root shW shH right bot kludge clr1 clr0 org blackIs0|
|
0
|
134 |
|
|
135 |
myView notNil ifTrue:[
|
743
|
136 |
self origin:(myView origin + (myView borderWidth * 2) + shadowLength)
|
|
137 |
extent:(myView extent).
|
0
|
138 |
|
743
|
139 |
shadowClr isNil ifTrue:[
|
|
140 |
"
|
|
141 |
get the pixels under the shadow
|
|
142 |
(copy from root-view into the 'imageUnderShadow'-form)
|
|
143 |
"
|
|
144 |
imageUnderShadow := Form width:width height:height depth:device depth on:device.
|
0
|
145 |
|
743
|
146 |
shW := shadowLength x.
|
|
147 |
shH := shadowLength y.
|
|
148 |
right := width - shW.
|
|
149 |
bot := height - shH.
|
54
|
150 |
|
743
|
151 |
root := device rootView.
|
|
152 |
|
|
153 |
clr0 := Color colorId:0.
|
|
154 |
clr1 := Color colorId:1.
|
2
|
155 |
|
743
|
156 |
kludge := device depth == 1.
|
|
157 |
blackIs0 := (device blackpixel == 0).
|
|
158 |
(kludge and:[blackIs0]) ifTrue:[
|
|
159 |
imageUnderShadow foreground:clr0 background:clr1.
|
|
160 |
].
|
2
|
161 |
|
743
|
162 |
org := self origin.
|
0
|
163 |
|
743
|
164 |
imageUnderShadow copyFrom:root x:(org x + right) y:org y
|
|
165 |
toX:right y:0 width:shW height:height.
|
0
|
166 |
|
743
|
167 |
imageUnderShadow copyFrom:root x:org x y:(org y + bot)
|
|
168 |
toX:0 y:bot width:width height:shH.
|
72
|
169 |
|
743
|
170 |
"
|
|
171 |
grey out the image (by oring-in a grey pattern)
|
|
172 |
(sometimes we are lucky, and can do it with one raster-op)
|
|
173 |
"
|
|
174 |
(kludge and:[blackIs0]) ifFalse:[
|
|
175 |
imageUnderShadow foreground:clr0 background:(Color colorId:-1).
|
|
176 |
imageUnderShadow mask:(Form mediumGreyFormOn:device).
|
|
177 |
imageUnderShadow function:#and.
|
|
178 |
imageUnderShadow fillRectangleX:right y:0 width:shW height:height.
|
|
179 |
imageUnderShadow fillRectangleX:0 y:bot width:width height:shH.
|
0
|
180 |
|
743
|
181 |
blackIs0 ifFalse:[
|
|
182 |
imageUnderShadow foreground:(Color black on:device) background:clr0.
|
|
183 |
imageUnderShadow function:#or.
|
|
184 |
imageUnderShadow fillRectangleX:right y:0 width:shW height:height.
|
|
185 |
imageUnderShadow fillRectangleX:0 y:bot width:width height:shH.
|
|
186 |
]
|
|
187 |
] ifTrue:[
|
|
188 |
imageUnderShadow foreground:clr1 background:clr0.
|
|
189 |
imageUnderShadow mask:(Form mediumGreyFormOn:device).
|
|
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 |
].
|
|
195 |
super realize.
|
|
196 |
self raise
|
0
|
197 |
]
|
743
|
198 |
|
1292
|
199 |
"Modified: 29.1.1997 / 13:10:32 / cg"
|
0
|
200 |
!
|
|
201 |
|
12
|
202 |
recreate
|
72
|
203 |
shadowClr notNil ifTrue:[
|
|
204 |
shadowClr := shadowClr on:device
|
|
205 |
].
|
12
|
206 |
|
|
207 |
"the length of the shadow from myView"
|
|
208 |
shadowLength := (device pixelPerMillimeter * 1.0) rounded.
|
|
209 |
|
|
210 |
super recreate.
|
|
211 |
self backingStore:false.
|
|
212 |
self saveUnder:true
|
269
|
213 |
!
|
|
214 |
|
642
|
215 |
unmap
|
676
|
216 |
"relase the saved image of the covered view"
|
|
217 |
|
269
|
218 |
imageUnderShadow := nil.
|
642
|
219 |
super unmap.
|
|
220 |
|
|
221 |
"Modified: 3.5.1996 / 23:45:23 / stefan"
|
676
|
222 |
"Modified: 12.5.1996 / 22:01:17 / cg"
|
0
|
223 |
! !
|
|
224 |
|
1292
|
225 |
!ShadowView class methodsFor:'documentation'!
|
0
|
226 |
|
269
|
227 |
version
|
1722
|
228 |
^ '$Header: /cvs/stx/stx/libview/ShadowView.st,v 1.24 1997-05-07 18:49:34 cg Exp $'
|
0
|
229 |
! !
|