5353
|
1 |
"
|
7947
|
2 |
COPYRIGHT (c) 1997 by Claus Gittinger / eXept Software AG
|
|
3 |
All Rights Reserved
|
5353
|
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 |
"{ Package: 'stx:libview' }"
|
|
13 |
|
6714
|
14 |
"{ NameSpace: Smalltalk }"
|
|
15 |
|
5373
|
16 |
AbstractBorder subclass:#Border
|
7013
|
17 |
instanceVariableNames:'leftColor leftWidth rightColor rightWidth topColor topWidth
|
|
18 |
bottomColor bottomWidth'
|
1321
|
19 |
classVariableNames:''
|
|
20 |
poolDictionaries:''
|
5391
|
21 |
category:'Graphics-Support'
|
1321
|
22 |
!
|
|
23 |
|
|
24 |
!Border class methodsFor:'documentation'!
|
|
25 |
|
5353
|
26 |
copyright
|
|
27 |
"
|
7947
|
28 |
COPYRIGHT (c) 1997 by Claus Gittinger / eXept Software AG
|
|
29 |
All Rights Reserved
|
5353
|
30 |
|
|
31 |
This software is furnished under a license and may be used
|
|
32 |
only in accordance with the terms of that license and with the
|
|
33 |
inclusion of the above copyright notice. This software may not
|
|
34 |
be provided or otherwise made available to, or used by, any
|
|
35 |
other person. No title to or ownership of the software is
|
|
36 |
hereby transferred.
|
|
37 |
"
|
|
38 |
!
|
|
39 |
|
1321
|
40 |
documentation
|
|
41 |
"
|
5373
|
42 |
a border holds the values of a view's (or component's) border.
|
5457
|
43 |
We have only recently started to change the system to use borders instead of separate
|
|
44 |
borderWidth, borderColor, level, shadow- and lightColors.
|
|
45 |
Expect more changes here in the near future..
|
1321
|
46 |
|
|
47 |
[see also:]
|
5457
|
48 |
SimpleView
|
1321
|
49 |
|
|
50 |
[author:]
|
5457
|
51 |
Claus Gittinger
|
1321
|
52 |
"
|
1324
|
53 |
!
|
|
54 |
|
|
55 |
examples
|
|
56 |
"
|
6714
|
57 |
[exBegin]
|
1324
|
58 |
|v b|
|
|
59 |
|
|
60 |
v := StandardSystemView extent:100@100.
|
|
61 |
v openAndWait.
|
|
62 |
|
7013
|
63 |
b := Border width:1 color:Color red.
|
|
64 |
v border:b
|
|
65 |
[exEnd]
|
|
66 |
|
|
67 |
[exBegin]
|
|
68 |
|v b|
|
|
69 |
|
|
70 |
v := StandardSystemView extent:100@100.
|
|
71 |
v openAndWait.
|
|
72 |
|
6714
|
73 |
b := Border width:10 color:Color red.
|
|
74 |
b displayOn:v forDisplayBox:(0@0 corner:90@90).
|
1324
|
75 |
|
|
76 |
Delay waitForSeconds:1.
|
6714
|
77 |
b leftColor:Color blue.
|
|
78 |
b displayOn:v forDisplayBox:(0@0 corner:90@90).
|
|
79 |
Delay waitForSeconds:1.
|
|
80 |
b topColor:Color green.
|
|
81 |
b displayOn:v forDisplayBox:(0@0 corner:90@90).
|
1324
|
82 |
Delay waitForSeconds:1.
|
6714
|
83 |
b rightColor:Color yellow.
|
|
84 |
b displayOn:v forDisplayBox:(0@0 corner:90@90).
|
|
85 |
[exEnd]
|
|
86 |
|
|
87 |
[exBegin]
|
|
88 |
|v b|
|
1321
|
89 |
|
6714
|
90 |
v := StandardSystemView extent:100@100.
|
|
91 |
v openAndWait.
|
|
92 |
|
|
93 |
b := Border width:10 color:Color red.
|
7013
|
94 |
b topColor:Color red.
|
|
95 |
b leftColor:Color blue.
|
|
96 |
b topColor:Color green.
|
|
97 |
b rightColor:Color yellow.
|
|
98 |
b leftWidth:10 rightWidth:20 topWidth:5 bottomWidth:15.
|
|
99 |
|
|
100 |
b displayOn:v forDisplayBox:(0@0 corner:90@90).
|
6714
|
101 |
[exEnd]
|
|
102 |
|
|
103 |
[exBegin]
|
5373
|
104 |
|v sub1 sub2 sub3|
|
1321
|
105 |
|
5373
|
106 |
v := StandardSystemView extent:200@200.
|
|
107 |
v openAndWait.
|
1321
|
108 |
|
5373
|
109 |
sub1 := (View in:v) origin:10@10; corner:90@90.
|
6714
|
110 |
sub1 border:(SimpleBorder width:10 color:Color red ).
|
|
111 |
sub1 realize.
|
5373
|
112 |
sub2 := (View in:v) origin:110@10; corner:190@90.
|
6714
|
113 |
sub2 border:(Border new width:10; color:Color blue; leftColor:Color red; rightColor:Color red ).
|
|
114 |
sub2 realize.
|
5373
|
115 |
sub3 := (View in:v) origin:110@110; corner:190@190.
|
6714
|
116 |
sub3 border:(SimpleBorder width:10 color:Color green ).
|
|
117 |
sub3 realize.
|
1321
|
118 |
|
6714
|
119 |
Delay waitForSeconds:1.
|
|
120 |
sub3 border:(Border new width:10; color:Color yellow; leftColor:Color red; rightColor:Color red ).
|
|
121 |
|
|
122 |
[exEnd]
|
5373
|
123 |
"
|
1321
|
124 |
! !
|
|
125 |
|
|
126 |
!Border methodsFor:'accessing'!
|
|
127 |
|
|
128 |
bottomColor
|
|
129 |
"return the value of the instance variable 'bottomColor' (automatically generated)"
|
|
130 |
|
|
131 |
^ bottomColor
|
|
132 |
|
|
133 |
"Created: 10.2.1997 / 14:51:34 / cg"
|
|
134 |
!
|
|
135 |
|
5408
|
136 |
bottomColor:aColor
|
|
137 |
"set the bottomColor"
|
|
138 |
|
|
139 |
bottomColor := aColor
|
|
140 |
|
|
141 |
"Created: 10.2.1997 / 15:37:51 / cg"
|
|
142 |
!
|
|
143 |
|
7013
|
144 |
bottomWidth
|
|
145 |
^ bottomWidth
|
|
146 |
!
|
|
147 |
|
|
148 |
bottomWidth:something
|
|
149 |
bottomWidth := something.
|
|
150 |
!
|
|
151 |
|
1321
|
152 |
color:newColor
|
|
153 |
"set all four colors"
|
|
154 |
|
5408
|
155 |
leftColor := rightColor := topColor := bottomColor := newColor
|
1321
|
156 |
|
|
157 |
"Created: 10.2.1997 / 15:27:01 / cg"
|
|
158 |
!
|
|
159 |
|
|
160 |
leftColor
|
|
161 |
"return the value of the instance variable 'leftColor' (automatically generated)"
|
|
162 |
|
|
163 |
^ leftColor
|
|
164 |
|
|
165 |
"Created: 10.2.1997 / 14:51:34 / cg"
|
|
166 |
!
|
|
167 |
|
5408
|
168 |
leftColor:aColor
|
|
169 |
"set the leftColor"
|
1321
|
170 |
|
5408
|
171 |
leftColor := aColor
|
1321
|
172 |
|
5408
|
173 |
"Created: 10.2.1997 / 15:38:02 / cg"
|
1321
|
174 |
!
|
|
175 |
|
7013
|
176 |
leftWidth
|
|
177 |
^ leftWidth
|
|
178 |
!
|
|
179 |
|
|
180 |
leftWidth:something
|
|
181 |
leftWidth := something.
|
|
182 |
!
|
|
183 |
|
|
184 |
leftWidth:leftWidthArg rightWidth:rightWidthArg topWidth:topWidthArg bottomWidth:bottomWidthArg
|
|
185 |
leftWidth := leftWidthArg.
|
|
186 |
rightWidth := rightWidthArg.
|
|
187 |
topWidth := topWidthArg.
|
|
188 |
bottomWidth := bottomWidthArg.
|
|
189 |
!
|
|
190 |
|
1321
|
191 |
rightColor
|
|
192 |
"return the value of the instance variable 'rightColor' (automatically generated)"
|
|
193 |
|
|
194 |
^ rightColor
|
|
195 |
|
|
196 |
"Created: 10.2.1997 / 14:51:34 / cg"
|
|
197 |
!
|
|
198 |
|
5408
|
199 |
rightColor:aColor
|
1321
|
200 |
"set the rightColor"
|
|
201 |
|
|
202 |
rightColor := aColor
|
|
203 |
|
|
204 |
"Created: 10.2.1997 / 15:38:08 / cg"
|
|
205 |
!
|
|
206 |
|
7013
|
207 |
rightWidth
|
|
208 |
^ rightWidth
|
|
209 |
!
|
|
210 |
|
|
211 |
rightWidth:something
|
|
212 |
rightWidth := something.
|
|
213 |
!
|
|
214 |
|
1321
|
215 |
topColor
|
|
216 |
"return the value of the instance variable 'topColor' (automatically generated)"
|
|
217 |
|
|
218 |
^ topColor
|
|
219 |
|
|
220 |
"Created: 10.2.1997 / 14:51:34 / cg"
|
5373
|
221 |
!
|
|
222 |
|
5408
|
223 |
topColor:aColor
|
|
224 |
"set the topColor"
|
5373
|
225 |
|
5408
|
226 |
topColor := aColor
|
|
227 |
|
|
228 |
"Created: 10.2.1997 / 15:38:17 / cg"
|
7013
|
229 |
!
|
|
230 |
|
|
231 |
topWidth
|
|
232 |
^ topWidth
|
|
233 |
!
|
|
234 |
|
|
235 |
topWidth:something
|
|
236 |
topWidth := something.
|
|
237 |
!
|
|
238 |
|
|
239 |
width:w
|
|
240 |
leftWidth := rightWidth := topWidth := bottomWidth := width := w.
|
1321
|
241 |
! !
|
|
242 |
|
|
243 |
!Border methodsFor:'displaying'!
|
|
244 |
|
5408
|
245 |
displayOn:aGC forDisplayBox:aRectangle
|
5373
|
246 |
"display the border represented by the receiver in the given rectangle.
|
1321
|
247 |
The gc's state is restored after the drawing."
|
|
248 |
|
6714
|
249 |
|oldPaint rL rR rT rB rW rH|
|
1321
|
250 |
|
5408
|
251 |
width == 0 ifTrue:[ ^ self ].
|
1321
|
252 |
|
|
253 |
oldPaint := aGC paint.
|
|
254 |
|
|
255 |
rL := aRectangle left.
|
|
256 |
rT := aRectangle top.
|
|
257 |
rR := aRectangle right.
|
|
258 |
rB := aRectangle bottom.
|
|
259 |
rH := aRectangle height.
|
|
260 |
rW := aRectangle width.
|
|
261 |
|
5408
|
262 |
leftColor notNil ifTrue:[
|
|
263 |
aGC paint:leftColor.
|
7013
|
264 |
leftWidth == 1 ifTrue:[
|
6714
|
265 |
aGC displayLineFromX:rL y:rT toX:rL y:rB-1.
|
|
266 |
] ifFalse:[
|
7013
|
267 |
aGC fillRectangleX:rL y:rT width:leftWidth height:rH
|
6714
|
268 |
].
|
1321
|
269 |
].
|
|
270 |
|
5408
|
271 |
topColor notNil ifTrue:[
|
|
272 |
aGC paint:topColor.
|
7013
|
273 |
topWidth == 1 ifTrue:[
|
6714
|
274 |
aGC displayLineFromX:rL+1 y:rT toX:rR-1 y:rT.
|
|
275 |
] ifFalse:[
|
7013
|
276 |
aGC fillRectangleX:(rL + leftWidth) y:rT width:rW - leftWidth - rightWidth height:topWidth
|
6714
|
277 |
].
|
1321
|
278 |
].
|
|
279 |
|
5408
|
280 |
rightColor notNil ifTrue:[
|
|
281 |
aGC paint:rightColor.
|
7013
|
282 |
rightWidth == 1 ifTrue:[
|
6714
|
283 |
aGC displayLineFromX:rR-1 y:rT toX:rR-1 y:rB-1.
|
|
284 |
] ifFalse:[
|
7013
|
285 |
aGC fillRectangleX:(rR - rightWidth) y:rT width:rightWidth height:rH
|
6714
|
286 |
].
|
1321
|
287 |
].
|
|
288 |
|
5408
|
289 |
bottomColor notNil ifTrue:[
|
6714
|
290 |
aGC paint:bottomColor.
|
7013
|
291 |
bottomWidth == 1 ifTrue:[
|
|
292 |
aGC displayLineFromX:rL+1 y:rB-1 toX:rR-2 y:rB-1.
|
6714
|
293 |
] ifFalse:[
|
7013
|
294 |
aGC fillRectangleX:rL+leftWidth y:(rB-bottomWidth) width:rW - leftWidth - rightWidth height:bottomWidth
|
6714
|
295 |
].
|
1321
|
296 |
].
|
|
297 |
|
|
298 |
aGC paint: oldPaint
|
|
299 |
|
1324
|
300 |
"Modified: 10.2.1997 / 15:55:04 / cg"
|
1321
|
301 |
! !
|
|
302 |
|
7013
|
303 |
!Border methodsFor:'initialization'!
|
|
304 |
|
|
305 |
initialize
|
|
306 |
width := 1.
|
|
307 |
leftWidth := rightWidth := topWidth := bottomWidth := 1.
|
|
308 |
! !
|
|
309 |
|
|
310 |
!Border methodsFor:'queries'!
|
|
311 |
|
|
312 |
bottomMargin
|
|
313 |
^ bottomWidth
|
|
314 |
!
|
|
315 |
|
|
316 |
leftMargin
|
|
317 |
^ leftWidth
|
|
318 |
!
|
|
319 |
|
|
320 |
rightMargin
|
|
321 |
^ rightWidth
|
|
322 |
!
|
|
323 |
|
|
324 |
topMargin
|
|
325 |
^ topWidth
|
|
326 |
! !
|
|
327 |
|
1321
|
328 |
!Border class methodsFor:'documentation'!
|
|
329 |
|
|
330 |
version
|
7013
|
331 |
^ '$Header$'
|
5353
|
332 |
!
|
|
333 |
|
|
334 |
version_CVS
|
7013
|
335 |
^ '$Header$'
|
1321
|
336 |
! !
|
6714
|
337 |
|