5460
|
1 |
"
|
7948
|
2 |
COPYRIGHT (c) 2009 by Claus Gittinger / eXept Software AG
|
5460
|
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 |
"
|
5394
|
12 |
"{ Package: 'stx:libview' }"
|
|
13 |
|
6718
|
14 |
"{ NameSpace: Smalltalk }"
|
|
15 |
|
5438
|
16 |
AbstractBorder subclass:#BeveledBorder
|
7382
|
17 |
instanceVariableNames:'color shadowColor lightColor level'
|
5394
|
18 |
classVariableNames:'RaisedBorder2 InsetBorder2 RaisedBorder1 InsetBorder1'
|
|
19 |
poolDictionaries:''
|
|
20 |
category:'Graphics-Support'
|
|
21 |
!
|
|
22 |
|
|
23 |
!BeveledBorder class methodsFor:'documentation'!
|
|
24 |
|
5460
|
25 |
copyright
|
|
26 |
"
|
7948
|
27 |
COPYRIGHT (c) 2009 by Claus Gittinger / eXept Software AG
|
5460
|
28 |
All Rights Reserved
|
|
29 |
|
|
30 |
This software is furnished under a license and may be used
|
|
31 |
only in accordance with the terms of that license and with the
|
|
32 |
inclusion of the above copyright notice. This software may not
|
|
33 |
be provided or otherwise made available to, or used by, any
|
|
34 |
other person. No title to or ownership of the software is
|
|
35 |
hereby transferred.
|
|
36 |
"
|
|
37 |
!
|
|
38 |
|
6829
|
39 |
documentation
|
|
40 |
"
|
|
41 |
This will replace the mixture of window-system supported borders and manually
|
|
42 |
drawn 3D levels (which is ugly, but served me well for almost 20years now).
|
|
43 |
|
|
44 |
[author:]
|
|
45 |
Claus Gittinger
|
|
46 |
"
|
|
47 |
!
|
|
48 |
|
5394
|
49 |
examples
|
|
50 |
"
|
6718
|
51 |
[exBegin]
|
|
52 |
|top v b|
|
5394
|
53 |
|
6718
|
54 |
|
|
55 |
top := StandardSystemView extent:100@100.
|
|
56 |
v := View origin:10@10 corner:90@30 in:top.
|
|
57 |
top openAndWait.
|
5394
|
58 |
|
6718
|
59 |
b := BeveledBorder raised1.
|
|
60 |
v border:b.
|
|
61 |
Delay waitForSeconds:1.
|
|
62 |
v border:(BeveledBorder level:2).
|
|
63 |
Delay waitForSeconds:1.
|
|
64 |
v border:(BeveledBorder level:3).
|
|
65 |
Delay waitForSeconds:1.
|
|
66 |
v border:(BeveledBorder level:-3).
|
|
67 |
Delay waitForSeconds:1.
|
|
68 |
v border:(BeveledBorder level:-2).
|
|
69 |
Delay waitForSeconds:1.
|
|
70 |
v border:(BeveledBorder level:-1).
|
|
71 |
Delay waitForSeconds:1.
|
|
72 |
v border:(BeveledBorder level:0).
|
|
73 |
[exEnd]
|
5394
|
74 |
|
6718
|
75 |
[exBegin]
|
|
76 |
|top v b|
|
5394
|
77 |
|
6718
|
78 |
top := StandardSystemView extent:100@100.
|
|
79 |
v := View origin:10@10 corner:90@30 in:top.
|
|
80 |
top openAndWait.
|
5394
|
81 |
|
|
82 |
b := BeveledBorder inset1.
|
6718
|
83 |
v border:b.
|
|
84 |
[exEnd]
|
5394
|
85 |
"
|
|
86 |
! !
|
|
87 |
|
5409
|
88 |
!BeveledBorder class methodsFor:'instance creation'!
|
|
89 |
|
|
90 |
level:aNumber
|
|
91 |
aNumber == 1 ifTrue:[^ self raised1].
|
|
92 |
aNumber == -11 ifTrue:[^ self inset1].
|
|
93 |
^ self new level:aNumber
|
5438
|
94 |
!
|
|
95 |
|
|
96 |
level:aNumber color:aColor
|
|
97 |
aNumber == 1 ifTrue:[^ self raised1].
|
|
98 |
aNumber == -11 ifTrue:[^ self inset1].
|
|
99 |
^ self new level:aNumber color:aColor
|
5409
|
100 |
! !
|
|
101 |
|
5394
|
102 |
!BeveledBorder class methodsFor:'constants'!
|
|
103 |
|
|
104 |
inset
|
|
105 |
"Answer the default beveled border with inset edges."
|
|
106 |
|
|
107 |
InsetBorder2 isNil ifTrue:[
|
|
108 |
InsetBorder2 := self new level:-2
|
|
109 |
].
|
|
110 |
^ InsetBorder2
|
|
111 |
|
|
112 |
"
|
|
113 |
self inset
|
|
114 |
"
|
|
115 |
!
|
|
116 |
|
|
117 |
inset1
|
|
118 |
"Answer the default beveled border with inset edges of thickness 1."
|
|
119 |
|
|
120 |
InsetBorder1 isNil ifTrue:[
|
|
121 |
InsetBorder1 := self new level:-1
|
|
122 |
].
|
|
123 |
^ InsetBorder1
|
|
124 |
!
|
|
125 |
|
|
126 |
raised
|
|
127 |
"Answer the default beveled border with raised edges."
|
|
128 |
|
|
129 |
RaisedBorder2 isNil ifTrue:[
|
|
130 |
"/ RaisedBorder := self new setBorderWidth: 2.
|
|
131 |
RaisedBorder2 := self new level:2
|
|
132 |
].
|
|
133 |
^ RaisedBorder2
|
|
134 |
!
|
|
135 |
|
|
136 |
raised1
|
|
137 |
"Answer the default beveled border with raised edges of thickness 1."
|
|
138 |
|
|
139 |
RaisedBorder1 isNil ifTrue:[
|
|
140 |
"/ RaisedBorder := self new setBorderWidth: 1.
|
|
141 |
RaisedBorder1 := self new level:1
|
|
142 |
].
|
|
143 |
^ RaisedBorder1
|
|
144 |
! !
|
|
145 |
|
|
146 |
!BeveledBorder methodsFor:'accessing'!
|
|
147 |
|
7382
|
148 |
color
|
|
149 |
^ color.
|
|
150 |
!
|
|
151 |
|
5438
|
152 |
color:aColor
|
7382
|
153 |
color := aColor.
|
5438
|
154 |
shadowColor := aColor slightlyDarkened.
|
|
155 |
lightColor := aColor slightlyLightened.
|
|
156 |
!
|
|
157 |
|
5394
|
158 |
level
|
|
159 |
^ level
|
|
160 |
|
|
161 |
"Created: / 6.7.1998 / 17:36:59 / cg"
|
|
162 |
!
|
|
163 |
|
|
164 |
level:anInteger
|
|
165 |
level := anInteger.
|
5409
|
166 |
width := level abs.
|
5394
|
167 |
|
|
168 |
"Created: / 6.7.1998 / 13:42:09 / cg"
|
|
169 |
"Modified: / 6.7.1998 / 17:37:17 / cg"
|
5438
|
170 |
!
|
|
171 |
|
|
172 |
level:aNumber color:aColor
|
|
173 |
self level:aNumber.
|
|
174 |
self color:aColor.
|
|
175 |
! !
|
|
176 |
|
|
177 |
!BeveledBorder methodsFor:'displaying'!
|
|
178 |
|
|
179 |
displayOn:aGC forDisplayBox:aRectangle
|
|
180 |
|oldPaint boxLeft boxTop boxWidth boxHeight light shadow|
|
|
181 |
|
|
182 |
oldPaint := aGC paint.
|
|
183 |
|
|
184 |
boxLeft := aRectangle left.
|
|
185 |
boxTop := aRectangle top.
|
|
186 |
boxWidth := aRectangle width.
|
|
187 |
boxHeight := aRectangle height.
|
|
188 |
|
|
189 |
(lightColor notNil and:[shadowColor notNil]) ifTrue:[
|
|
190 |
light := lightColor.
|
|
191 |
shadow := shadowColor.
|
|
192 |
] ifFalse:[
|
|
193 |
light := aGC lightColor.
|
|
194 |
shadow := aGC shadowColor.
|
|
195 |
].
|
|
196 |
|
|
197 |
aGC
|
|
198 |
drawEdgesForX:boxLeft y:boxTop width:boxWidth height:boxHeight level:(level ? width)
|
|
199 |
shadow:shadow light:light
|
|
200 |
halfShadow:nil halfLight:nil
|
|
201 |
style:nil.
|
|
202 |
|
|
203 |
aGC paint:oldPaint.
|
|
204 |
|
|
205 |
"
|
|
206 |
View new
|
|
207 |
border:(BeveledBorder level:2 color:Color red);
|
|
208 |
open.
|
|
209 |
"
|
|
210 |
"
|
|
211 |
View new
|
|
212 |
border:(BeveledBorder level:4 color:Color red);
|
|
213 |
open.
|
|
214 |
"
|
|
215 |
|
|
216 |
"
|
|
217 |
StandardSystemView new
|
|
218 |
extent:200@200;
|
|
219 |
add:(View new
|
|
220 |
origin:(10@10) corner:0.9@0.9;
|
|
221 |
border:(BeveledBorder width:4 color:Color red));
|
|
222 |
open.
|
|
223 |
"
|
5394
|
224 |
! !
|
|
225 |
|
|
226 |
!BeveledBorder class methodsFor:'documentation'!
|
|
227 |
|
|
228 |
version_CVS
|
7382
|
229 |
^ '$Header$'
|
5394
|
230 |
! !
|
6718
|
231 |
|