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