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