0
|
1 |
"
|
6
|
2 |
COPYRIGHT (c) 1991 by Claus Gittinger
|
0
|
3 |
All Rights Reserved
|
|
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 |
|
|
13 |
View subclass:#ShadowView
|
|
14 |
instanceVariableNames:'myView shadowLength shadow imageUnderShadow'
|
|
15 |
classVariableNames:''
|
|
16 |
poolDictionaries:''
|
|
17 |
category:'Views-Basic'
|
|
18 |
!
|
|
19 |
|
|
20 |
ShadowView comment:'
|
|
21 |
|
6
|
22 |
COPYRIGHT (c) 1991 by Claus Gittinger
|
0
|
23 |
All Rights Reserved
|
|
24 |
|
|
25 |
just to give PopUps and ModalBoxes a shadow. A ShadowView just paints black.
|
|
26 |
The instance variable myView is the view, the shadow is for.
|
|
27 |
|
6
|
28 |
$Header: /cvs/stx/stx/libview/ShadowView.st,v 1.4 1993-10-13 02:44:17 claus Exp $
|
0
|
29 |
written nov 91 by claus.
|
|
30 |
real shadow added jun-93 by claus (if shadowColor is nil)
|
|
31 |
'!
|
|
32 |
|
|
33 |
!ShadowView methodsFor:'initialization'!
|
|
34 |
|
|
35 |
initialize
|
|
36 |
super initialize.
|
|
37 |
borderWidth := 0.
|
|
38 |
shadow := Black.
|
|
39 |
|
|
40 |
"the length of the shadow from myView"
|
|
41 |
shadowLength := (device pixelPerMillimeter * 1.0) rounded
|
|
42 |
!
|
|
43 |
|
|
44 |
realize
|
|
45 |
"realize the shadowView some distance away from myView"
|
|
46 |
|
2
|
47 |
|root shW shH right bot kludge|
|
0
|
48 |
|
|
49 |
myView notNil ifTrue:[
|
|
50 |
self origin:(myView origin + (myView borderWidth * 2) + shadowLength) extent:(myView extent).
|
|
51 |
|
|
52 |
imageUnderShadow := Form width:width height:height depth:device depth on:device.
|
|
53 |
imageUnderShadow initGC.
|
|
54 |
device setClipByChildren:false in:imageUnderShadow gcId.
|
|
55 |
|
|
56 |
shW := shadowLength x.
|
|
57 |
shH := shadowLength y.
|
2
|
58 |
right := width - shW.
|
|
59 |
bot := height - shH.
|
0
|
60 |
|
|
61 |
root := DisplayRootView new.
|
2
|
62 |
|
|
63 |
kludge := root device depth == 1.
|
|
64 |
(kludge and:[root device blackpixel == 0]) ifTrue:[
|
|
65 |
imageUnderShadow foreground:(Color colorId:0)
|
|
66 |
background:(Color colorId:1).
|
|
67 |
].
|
|
68 |
|
0
|
69 |
imageUnderShadow copyFrom:root x:(self origin x + right) y:(self origin y)
|
|
70 |
toX:right y:0 width:shW height:height.
|
|
71 |
|
|
72 |
imageUnderShadow copyFrom:root x:(self origin x) y:(self origin y + bot)
|
|
73 |
toX:0 y:bot width:width height:shH.
|
|
74 |
|
|
75 |
"grey out image in area"
|
|
76 |
|
2
|
77 |
(kludge and:[root device blackpixel == 0]) ifFalse:[
|
|
78 |
imageUnderShadow foreground:(Color colorId:0) background:(Color colorId:-1).
|
|
79 |
imageUnderShadow mask:(Form mediumGreyFormOn:device).
|
|
80 |
imageUnderShadow function:#and.
|
|
81 |
imageUnderShadow fillRectangleX:0 y:0 width:width height:height.
|
0
|
82 |
|
2
|
83 |
(Color black on:device) colorId == 0 ifFalse:[
|
|
84 |
imageUnderShadow foreground:(Color black on:device) background:(Color colorId:0).
|
|
85 |
imageUnderShadow function:#or.
|
|
86 |
imageUnderShadow fillRectangleX:0 y:0 width:width height:height.
|
|
87 |
]
|
|
88 |
] ifTrue:[
|
|
89 |
imageUnderShadow foreground:(Color colorId:1) background:(Color colorId:0).
|
|
90 |
imageUnderShadow mask:(Form mediumGreyFormOn:device).
|
|
91 |
imageUnderShadow function:#or.
|
|
92 |
imageUnderShadow fillRectangleX:0 y:0 width:width height:height.
|
|
93 |
].
|
0
|
94 |
|
|
95 |
super realize.
|
|
96 |
self raise
|
|
97 |
]
|
|
98 |
!
|
|
99 |
|
|
100 |
unrealize
|
|
101 |
"realize the shadowView some distance away from myView"
|
|
102 |
|
|
103 |
imageUnderShadow := nil.
|
|
104 |
super unrealize.
|
|
105 |
!
|
|
106 |
|
|
107 |
create
|
|
108 |
super create.
|
|
109 |
self backingStore:false.
|
2
|
110 |
|
|
111 |
"X11/NeWS server is broken here ..."
|
|
112 |
(device serverVendor startsWith:'X11/NeWS') ifFalse:[
|
|
113 |
self saveUnder:true
|
|
114 |
]
|
0
|
115 |
! !
|
|
116 |
|
|
117 |
!ShadowView methodsFor:'events'!
|
|
118 |
|
|
119 |
redraw
|
|
120 |
"fill all of myself with black"
|
|
121 |
|
2
|
122 |
imageUnderShadow isNil ifTrue:[^ self].
|
|
123 |
|
0
|
124 |
"
|
|
125 |
self foreground:(Color colorId:-1) background:(Color colorId:0).
|
|
126 |
self function:#copy.
|
|
127 |
"
|
|
128 |
self copyFrom:imageUnderShadow x:(width - shadowLength x) y:0
|
|
129 |
toX:(width - shadowLength x) y:0 width:shadowLength x height:height.
|
|
130 |
self copyFrom:imageUnderShadow x:0 y:(height - shadowLength y)
|
|
131 |
toX:0 y:(height - shadowLength y) width:width height:shadowLength y.
|
|
132 |
|
|
133 |
"
|
|
134 |
self paint:shadow.
|
|
135 |
self fillRectangleX:0 y:0 width:width height:height
|
|
136 |
"
|
|
137 |
! !
|
|
138 |
|
|
139 |
!ShadowView methodsFor:'accessing'!
|
|
140 |
|
|
141 |
shadowColor:aColor
|
|
142 |
"to set the shadow color"
|
|
143 |
|
|
144 |
shadow := aColor
|
|
145 |
!
|
|
146 |
|
|
147 |
for:aView
|
|
148 |
"set the view I am for"
|
|
149 |
|
|
150 |
myView := aView
|
|
151 |
!
|
|
152 |
|
|
153 |
createOnTop
|
|
154 |
^ true
|
|
155 |
! !
|