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