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