1321
|
1 |
Object subclass:#Border
|
|
2 |
instanceVariableNames:'left right top bottom leftColor rightColor topColor bottomColor'
|
|
3 |
classVariableNames:''
|
|
4 |
poolDictionaries:''
|
|
5 |
category:'Interface-Support'
|
|
6 |
!
|
|
7 |
|
|
8 |
!Border class methodsFor:'documentation'!
|
|
9 |
|
|
10 |
documentation
|
|
11 |
"
|
|
12 |
a border holdes the values of a views (or components) border.
|
|
13 |
It is (currently) not used by ST/X, but provided as a comatibility hook.
|
|
14 |
(... however, ST/X is being rewritten to make use of it soon).
|
|
15 |
Notice:
|
|
16 |
this class was implemented using protocol information
|
|
17 |
from alpha testers, from reading PD programs and
|
|
18 |
from the Hopkins/Horan book.
|
|
19 |
- it may not be complete or compatible to the corresponding ST-80 class.
|
|
20 |
If you encounter any incompatibilities, please forward a note
|
|
21 |
describing the incompatibility verbal (i.e. no code) to the ST/X team.
|
|
22 |
|
|
23 |
[see also:]
|
|
24 |
Wrapper SimpleView
|
|
25 |
|
|
26 |
[author:]
|
|
27 |
Claus Gittinger
|
|
28 |
"
|
|
29 |
|
|
30 |
|
|
31 |
! !
|
|
32 |
|
|
33 |
!Border class methodsFor:'instance creation'!
|
|
34 |
|
|
35 |
width:borderWidth
|
|
36 |
"create a new instance of the receiver with a border of the given width
|
|
37 |
(and default color)."
|
|
38 |
|
|
39 |
^ self width:borderWidth color:View defaultBorderColor
|
|
40 |
|
|
41 |
"Modified: 10.2.1997 / 15:19:57 / cg"
|
|
42 |
!
|
|
43 |
|
|
44 |
width:borderWidth color:aColor
|
|
45 |
"create a new instance of the receiver with a border of the given width
|
|
46 |
and color."
|
|
47 |
|
|
48 |
^ self new
|
|
49 |
setBorderWidth:borderWidth color:aColor
|
|
50 |
|
|
51 |
"Modified: 10.2.1997 / 15:20:32 / cg"
|
|
52 |
! !
|
|
53 |
|
|
54 |
!Border methodsFor:'accessing'!
|
|
55 |
|
|
56 |
bottom
|
|
57 |
"return the bottom border width"
|
|
58 |
|
|
59 |
^ bottom
|
|
60 |
|
|
61 |
"Created: 10.2.1997 / 14:51:34 / cg"
|
|
62 |
"Modified: 10.2.1997 / 15:39:01 / cg"
|
|
63 |
!
|
|
64 |
|
|
65 |
bottomColor
|
|
66 |
"return the value of the instance variable 'bottomColor' (automatically generated)"
|
|
67 |
|
|
68 |
^ bottomColor
|
|
69 |
|
|
70 |
"Created: 10.2.1997 / 14:51:34 / cg"
|
|
71 |
!
|
|
72 |
|
|
73 |
color:newColor
|
|
74 |
"set all four colors"
|
|
75 |
|
|
76 |
leftColor := rightColor := topColor := bottomColor := newColor
|
|
77 |
|
|
78 |
"Created: 10.2.1997 / 15:27:01 / cg"
|
|
79 |
!
|
|
80 |
|
|
81 |
left
|
|
82 |
"return the left border width"
|
|
83 |
|
|
84 |
^ left
|
|
85 |
|
|
86 |
"Created: 10.2.1997 / 14:51:34 / cg"
|
|
87 |
"Modified: 10.2.1997 / 15:39:05 / cg"
|
|
88 |
!
|
|
89 |
|
|
90 |
leftColor
|
|
91 |
"return the value of the instance variable 'leftColor' (automatically generated)"
|
|
92 |
|
|
93 |
^ leftColor
|
|
94 |
|
|
95 |
"Created: 10.2.1997 / 14:51:34 / cg"
|
|
96 |
!
|
|
97 |
|
|
98 |
right
|
|
99 |
"return the right border width"
|
|
100 |
|
|
101 |
^ right
|
|
102 |
|
|
103 |
"Created: 10.2.1997 / 14:51:34 / cg"
|
|
104 |
"Modified: 10.2.1997 / 15:39:08 / cg"
|
|
105 |
!
|
|
106 |
|
|
107 |
rightColor
|
|
108 |
"return the value of the instance variable 'rightColor' (automatically generated)"
|
|
109 |
|
|
110 |
^ rightColor
|
|
111 |
|
|
112 |
"Created: 10.2.1997 / 14:51:34 / cg"
|
|
113 |
!
|
|
114 |
|
|
115 |
setBottom:aSmallInteger
|
|
116 |
"set the bottom border width"
|
|
117 |
|
|
118 |
bottom := aSmallInteger
|
|
119 |
|
|
120 |
"Created: 10.2.1997 / 15:38:50 / cg"
|
|
121 |
!
|
|
122 |
|
|
123 |
setBottomColor:aColor
|
|
124 |
"set the bottomColor"
|
|
125 |
|
|
126 |
bottomColor := aColor
|
|
127 |
|
|
128 |
"Created: 10.2.1997 / 15:37:51 / cg"
|
|
129 |
!
|
|
130 |
|
|
131 |
setLeft:aSmallInteger
|
|
132 |
"set the left border width"
|
|
133 |
|
|
134 |
left := aSmallInteger
|
|
135 |
|
|
136 |
"Created: 10.2.1997 / 15:39:33 / cg"
|
|
137 |
!
|
|
138 |
|
|
139 |
setLeftColor:aColor
|
|
140 |
"set the leftColor"
|
|
141 |
|
|
142 |
leftColor := aColor
|
|
143 |
|
|
144 |
"Created: 10.2.1997 / 15:38:02 / cg"
|
|
145 |
!
|
|
146 |
|
|
147 |
setRight:aSmallInteger
|
|
148 |
"set the right border width"
|
|
149 |
|
|
150 |
right := aSmallInteger
|
|
151 |
|
|
152 |
"Created: 10.2.1997 / 15:39:44 / cg"
|
|
153 |
!
|
|
154 |
|
|
155 |
setRightColor:aColor
|
|
156 |
"set the rightColor"
|
|
157 |
|
|
158 |
rightColor := aColor
|
|
159 |
|
|
160 |
"Created: 10.2.1997 / 15:38:08 / cg"
|
|
161 |
!
|
|
162 |
|
|
163 |
setTop:aSmallInteger
|
|
164 |
"set the top border width"
|
|
165 |
|
|
166 |
top := aSmallInteger
|
|
167 |
|
|
168 |
"Created: 10.2.1997 / 15:39:27 / cg"
|
|
169 |
!
|
|
170 |
|
|
171 |
setTopColor:aColor
|
|
172 |
"set the topColor"
|
|
173 |
|
|
174 |
topColor := aColor
|
|
175 |
|
|
176 |
"Created: 10.2.1997 / 15:38:17 / cg"
|
|
177 |
!
|
|
178 |
|
|
179 |
top
|
|
180 |
"return the top border width"
|
|
181 |
|
|
182 |
^ top
|
|
183 |
|
|
184 |
"Created: 10.2.1997 / 14:51:34 / cg"
|
|
185 |
"Modified: 10.2.1997 / 15:39:11 / cg"
|
|
186 |
!
|
|
187 |
|
|
188 |
topColor
|
|
189 |
"return the value of the instance variable 'topColor' (automatically generated)"
|
|
190 |
|
|
191 |
^ topColor
|
|
192 |
|
|
193 |
"Created: 10.2.1997 / 14:51:34 / cg"
|
|
194 |
! !
|
|
195 |
|
|
196 |
!Border methodsFor:'displaying'!
|
|
197 |
|
|
198 |
displayOn:aGC forDisplayBox:aRectangle
|
|
199 |
"display the borders represented by the receiver in the specified rectangle.
|
|
200 |
The gc is restored after the draw."
|
|
201 |
|
|
202 |
self displayOn:aGC forDisplayBox:aRectangle using:nil
|
|
203 |
|
|
204 |
"Modified: 10.2.1997 / 14:56:10 / cg"
|
|
205 |
!
|
|
206 |
|
|
207 |
displayOn:aGC forDisplayBox:aRectangle using:colorSource
|
|
208 |
"display the borders represented by the receiver borders in the given rectangle.
|
|
209 |
colorSource is ignored here, but subclasses (i.e. 3D-borders) may use
|
|
210 |
it to ask for shadow/lightColors.
|
|
211 |
The gc's state is restored after the drawing."
|
|
212 |
|
|
213 |
|clipRectangle paint oldPaint
|
|
214 |
t r l b rL rR rT rB rW rH|
|
|
215 |
|
|
216 |
"/ clipRectangle := aGC clippingBounds.
|
|
217 |
"/ ((self insetDisplayBoxFor: aRectangle) contains: clipRectangle) ifTrue: [^self].
|
|
218 |
|
|
219 |
oldPaint := aGC paint.
|
|
220 |
r := aRectangle copy.
|
|
221 |
|
|
222 |
t := self top.
|
|
223 |
l := self left.
|
|
224 |
r := self right.
|
|
225 |
b := self bottom.
|
|
226 |
|
|
227 |
rL := aRectangle left.
|
|
228 |
rT := aRectangle top.
|
|
229 |
rR := aRectangle right.
|
|
230 |
rB := aRectangle bottom.
|
|
231 |
rH := aRectangle height.
|
|
232 |
rW := aRectangle width.
|
|
233 |
|
|
234 |
(l ~~ 0 and: [(paint := self leftColor) notNil]) ifTrue:[
|
|
235 |
aGC paint:paint.
|
|
236 |
aGC displayRectangleX:rL
|
|
237 |
y:rT
|
|
238 |
width:l
|
|
239 |
height:rH + 1 - b
|
|
240 |
].
|
|
241 |
|
|
242 |
(t ~~ 0 and: [(paint := self topColor) notNil]) ifTrue:[
|
|
243 |
aGC paint:paint.
|
|
244 |
aGC displayRectangleX:(rL + l)
|
|
245 |
y:rT
|
|
246 |
width:rW - l
|
|
247 |
height:t
|
|
248 |
].
|
|
249 |
|
|
250 |
(r ~~ 0 and: [(paint := self rightColor) notNil]) ifTrue:[
|
|
251 |
aGC paint:paint.
|
|
252 |
aGC displayRectangleX:(rR - r)
|
|
253 |
y:(rT + t)
|
|
254 |
width:r
|
|
255 |
height:rH + 1 - t
|
|
256 |
].
|
|
257 |
|
|
258 |
(b ~~ 0 and: [(paint := self bottomColor) notNil]) ifTrue:[
|
|
259 |
aGC paint:paint.
|
|
260 |
aGC displayRectangleX:(rL)
|
|
261 |
y:(rB + 1 - b)
|
|
262 |
width:rW - r
|
|
263 |
height:b
|
|
264 |
].
|
|
265 |
|
|
266 |
aGC paint: oldPaint
|
|
267 |
|
|
268 |
"
|
|
269 |
|v b|
|
|
270 |
|
|
271 |
v := StandardSystemView extent:10@10.
|
|
272 |
v openAndWait.
|
|
273 |
|
|
274 |
b := Border width:2 color:Color red.
|
|
275 |
b displayOn:v forDisplayBox:(0@0 corner:9@9).
|
|
276 |
|
|
277 |
Delay waitForSeconds:1.
|
|
278 |
b leftColor:Color blue.
|
|
279 |
b displayOn:v forDisplayBox:(0@0 corner:9@9).
|
|
280 |
Delay waitForSeconds:1.
|
|
281 |
b topColor:Color green.
|
|
282 |
b displayOn:v forDisplayBox:(0@0 corner:9@9).
|
|
283 |
Delay waitForSeconds:1.
|
|
284 |
b rightColor:Color magenta.
|
|
285 |
b displayOn:v forDisplayBox:(0@0 corner:9@9).
|
|
286 |
|
|
287 |
"
|
|
288 |
|
|
289 |
"Modified: 10.2.1997 / 15:30:22 / cg"
|
|
290 |
! !
|
|
291 |
|
|
292 |
!Border methodsFor:'private accessing'!
|
|
293 |
|
|
294 |
setBorderWidth:aWidth color:aColor
|
|
295 |
left := right := top := bottom := aWidth.
|
|
296 |
leftColor := rightColor := topColor := bottomColor := aColor
|
|
297 |
|
|
298 |
"Created: 10.2.1997 / 15:21:27 / cg"
|
|
299 |
! !
|
|
300 |
|
|
301 |
!Border methodsFor:'queries'!
|
|
302 |
|
|
303 |
allSidesEqual:aSmallInteger
|
|
304 |
left ~~ aSmallInteger ifTrue:[^ false].
|
|
305 |
top ~~ aSmallInteger ifTrue:[^ false].
|
|
306 |
right ~~ aSmallInteger ifTrue:[^ false].
|
|
307 |
bottom ~~ aSmallInteger ifTrue:[^ false].
|
|
308 |
^ true
|
|
309 |
|
|
310 |
"Created: 10.2.1997 / 14:53:13 / cg"
|
|
311 |
!
|
|
312 |
|
|
313 |
displayBoxFor:aRectangle
|
|
314 |
"return a rectangle representing the overall display box of a component
|
|
315 |
bordered by the receiver, which has bounds of aRectangle.
|
|
316 |
That is, the argument outset by the receivers borders."
|
|
317 |
|
|
318 |
|insetRectangle|
|
|
319 |
|
|
320 |
insetRectangle := aRectangle copy.
|
|
321 |
insetRectangle left:(insetRectangle left - self left).
|
|
322 |
insetRectangle right:(insetRectangle right + self right).
|
|
323 |
insetRectangle top:(insetRectangle top - self top).
|
|
324 |
insetRectangle bottom:(insetRectangle bottom + self bottom).
|
|
325 |
^ insetRectangle
|
|
326 |
|
|
327 |
"Created: 10.2.1997 / 15:43:00 / cg"
|
|
328 |
!
|
|
329 |
|
|
330 |
insetDisplayBoxFor:aRectangle
|
|
331 |
"return a rectangle representing the display box of a component
|
|
332 |
bordered by the receiver in the outer bounds, aRectangle.
|
|
333 |
That is, the argument inset by the receivers borders."
|
|
334 |
|
|
335 |
|insetRectangle|
|
|
336 |
|
|
337 |
insetRectangle := aRectangle copy.
|
|
338 |
insetRectangle left:(insetRectangle left + self left).
|
|
339 |
insetRectangle right:(insetRectangle right - self right).
|
|
340 |
insetRectangle top:(insetRectangle top + self top).
|
|
341 |
insetRectangle bottom:(insetRectangle bottom - self bottom).
|
|
342 |
^ insetRectangle
|
|
343 |
|
|
344 |
"Created: 10.2.1997 / 15:42:06 / cg"
|
|
345 |
! !
|
|
346 |
|
|
347 |
!Border class methodsFor:'documentation'!
|
|
348 |
|
|
349 |
version
|
1322
|
350 |
^ '$Header: /cvs/stx/stx/libview/Border.st,v 1.2 1997-02-10 14:45:30 cg Exp $'
|
1321
|
351 |
! !
|