5374
|
1 |
"
|
|
2 |
COPYRIGHT (c) 1997 by eXept Software AG
|
|
3 |
COPYRIGHT (c) 2009 by eXept Software AG
|
5407
|
4 |
All Rights Reserved
|
5374
|
5 |
|
|
6 |
This software is furnished under a license and may be used
|
|
7 |
only in accordance with the terms of that license and with the
|
|
8 |
inclusion of the above copyright notice. This software may not
|
|
9 |
be provided or otherwise made available to, or used by, any
|
|
10 |
other person. No title to or ownership of the software is
|
|
11 |
hereby transferred.
|
|
12 |
"
|
|
13 |
"{ Package: 'stx:libview' }"
|
|
14 |
|
6713
|
15 |
"{ NameSpace: Smalltalk }"
|
|
16 |
|
5374
|
17 |
Object subclass:#AbstractBorder
|
5407
|
18 |
instanceVariableNames:'width'
|
5374
|
19 |
classVariableNames:''
|
|
20 |
poolDictionaries:''
|
5392
|
21 |
category:'Graphics-Support'
|
5374
|
22 |
!
|
|
23 |
|
|
24 |
!AbstractBorder class methodsFor:'documentation'!
|
|
25 |
|
|
26 |
copyright
|
|
27 |
"
|
|
28 |
COPYRIGHT (c) 1997 by eXept Software AG
|
|
29 |
COPYRIGHT (c) 2009 by eXept Software AG
|
5407
|
30 |
All Rights Reserved
|
5374
|
31 |
|
|
32 |
This software is furnished under a license and may be used
|
|
33 |
only in accordance with the terms of that license and with the
|
|
34 |
inclusion of the above copyright notice. This software may not
|
|
35 |
be provided or otherwise made available to, or used by, any
|
|
36 |
other person. No title to or ownership of the software is
|
|
37 |
hereby transferred.
|
|
38 |
"
|
|
39 |
!
|
|
40 |
|
|
41 |
documentation
|
|
42 |
"
|
5392
|
43 |
Extracted from Border.
|
|
44 |
Common superclass for border-painters.
|
|
45 |
This will replace the mixture of window-system supported borders and manually
|
|
46 |
drawn 3D levels (which is ugly, but served me well for almost 20years now).
|
5374
|
47 |
|
|
48 |
[author:]
|
5407
|
49 |
Claus Gittinger
|
5374
|
50 |
"
|
|
51 |
! !
|
|
52 |
|
|
53 |
!AbstractBorder class methodsFor:'instance creation'!
|
|
54 |
|
6939
|
55 |
color:aColor
|
|
56 |
"create a new instance of the receiver with a border of the given color."
|
|
57 |
|
|
58 |
^ self width:1 color:aColor
|
|
59 |
!
|
|
60 |
|
6717
|
61 |
new
|
|
62 |
"return an initialized instance"
|
|
63 |
|
|
64 |
^ self basicNew initialize.
|
|
65 |
!
|
|
66 |
|
5374
|
67 |
width:borderWidth
|
5407
|
68 |
"create a new instance of the receiver with a border of the given width
|
5374
|
69 |
(and default color)."
|
|
70 |
|
|
71 |
^ self new width:borderWidth color:(Color black)
|
|
72 |
|
|
73 |
"Modified: 10.2.1997 / 15:19:57 / cg"
|
|
74 |
!
|
|
75 |
|
|
76 |
width:borderWidth color:aColor
|
5407
|
77 |
"create a new instance of the receiver with a border of the given width
|
5374
|
78 |
and color."
|
|
79 |
|
5407
|
80 |
^ self new width:borderWidth color:aColor
|
5374
|
81 |
|
|
82 |
"Modified: 10.2.1997 / 15:20:32 / cg"
|
|
83 |
! !
|
|
84 |
|
|
85 |
!AbstractBorder methodsFor:'accessing'!
|
|
86 |
|
7383
|
87 |
color
|
|
88 |
"get the color; nil if there is no single color"
|
|
89 |
|
|
90 |
^ nil
|
|
91 |
!
|
|
92 |
|
5407
|
93 |
color:aColor
|
6713
|
94 |
"set the color"
|
5407
|
95 |
|
|
96 |
"/ self subclassResponsibility
|
|
97 |
!
|
|
98 |
|
|
99 |
level
|
|
100 |
"get the 3D level"
|
|
101 |
|
|
102 |
^ 0
|
|
103 |
!
|
|
104 |
|
|
105 |
width
|
|
106 |
"get the width"
|
|
107 |
|
6713
|
108 |
^ width ? 1
|
5407
|
109 |
!
|
|
110 |
|
|
111 |
width:aNumber
|
|
112 |
"set the width"
|
|
113 |
|
|
114 |
width := aNumber
|
|
115 |
!
|
|
116 |
|
|
117 |
width:aWidth color:aColor
|
|
118 |
self width:aWidth.
|
|
119 |
self color:aColor
|
5374
|
120 |
|
|
121 |
"Created: 10.2.1997 / 15:21:27 / cg"
|
|
122 |
! !
|
|
123 |
|
|
124 |
!AbstractBorder methodsFor:'displaying'!
|
|
125 |
|
|
126 |
displayOn:aGC forDisplayBox:aRectangle
|
|
127 |
"display the borders represented by the receiver in the specified rectangle.
|
|
128 |
The gc is restored after the draw."
|
|
129 |
|
5407
|
130 |
"/ self subclassResponsibility
|
5374
|
131 |
! !
|
|
132 |
|
6717
|
133 |
!AbstractBorder methodsFor:'initialization'!
|
|
134 |
|
|
135 |
initialize
|
|
136 |
width := 1.
|
|
137 |
! !
|
|
138 |
|
5407
|
139 |
!AbstractBorder methodsFor:'queries'!
|
5374
|
140 |
|
5407
|
141 |
allSidesEqual:aSmallInteger
|
|
142 |
"true if all four sides have the same border width;
|
|
143 |
always true here - provided for compatibility"
|
5374
|
144 |
|
5407
|
145 |
^ true
|
|
146 |
|
|
147 |
"Created: 10.2.1997 / 14:53:13 / cg"
|
5374
|
148 |
!
|
|
149 |
|
7012
|
150 |
bottomMargin
|
|
151 |
"return the bottom inset.
|
|
152 |
That is the number of pixels that an instance of me requires at the bottom,
|
|
153 |
eg. the inset of the view's contents"
|
|
154 |
|
|
155 |
^ width
|
|
156 |
!
|
|
157 |
|
5407
|
158 |
displayBoxFor:aRectangle
|
|
159 |
"return a rectangle representing the overall display box of a component
|
|
160 |
bordered by the receiver, which has bounds of aRectangle.
|
7236
|
161 |
That is, the argument outset by the receiver's borders."
|
5407
|
162 |
|
|
163 |
|insetRectangle|
|
|
164 |
|
|
165 |
insetRectangle := aRectangle copy.
|
|
166 |
insetRectangle left:(insetRectangle left - width).
|
|
167 |
insetRectangle right:(insetRectangle right + width).
|
|
168 |
insetRectangle top:(insetRectangle top - width).
|
|
169 |
insetRectangle bottom:(insetRectangle bottom + width).
|
|
170 |
^ insetRectangle
|
5374
|
171 |
|
5407
|
172 |
"Created: 10.2.1997 / 15:43:00 / cg"
|
|
173 |
!
|
|
174 |
|
|
175 |
insetDisplayBoxFor:aRectangle
|
|
176 |
"return a rectangle representing the display box of a component
|
|
177 |
bordered by the receiver in the outer bounds, aRectangle.
|
6713
|
178 |
That is, the argument inset by the receiver's borders."
|
5407
|
179 |
|
|
180 |
|insetRectangle|
|
|
181 |
|
|
182 |
insetRectangle := aRectangle copy.
|
|
183 |
insetRectangle left:(insetRectangle left + width).
|
|
184 |
insetRectangle right:(insetRectangle right - width).
|
|
185 |
insetRectangle top:(insetRectangle top + width).
|
|
186 |
insetRectangle bottom:(insetRectangle bottom - width).
|
|
187 |
^ insetRectangle
|
|
188 |
|
|
189 |
"Created: 10.2.1997 / 15:42:06 / cg"
|
7012
|
190 |
!
|
|
191 |
|
|
192 |
leftMargin
|
|
193 |
"return the left inset.
|
|
194 |
That is the number of pixels that an instance of me requires at the left,
|
|
195 |
eg. the inset of the view's contents"
|
|
196 |
|
|
197 |
^ width
|
|
198 |
!
|
|
199 |
|
|
200 |
rightMargin
|
|
201 |
"return the right inset.
|
|
202 |
That is the number of pixels that an instance of me requires at the right,
|
|
203 |
eg. the inset of the view's contents"
|
|
204 |
|
|
205 |
^ width
|
|
206 |
!
|
|
207 |
|
|
208 |
topMargin
|
|
209 |
"return the top inset.
|
|
210 |
That is the number of pixels that an instance of me requires at the top,
|
|
211 |
eg. the inset of the view's contents"
|
|
212 |
|
|
213 |
^ width
|
5374
|
214 |
! !
|
|
215 |
|
|
216 |
!AbstractBorder class methodsFor:'documentation'!
|
|
217 |
|
6717
|
218 |
version
|
6939
|
219 |
^ '$Header$'
|
6717
|
220 |
!
|
|
221 |
|
5374
|
222 |
version_CVS
|
6939
|
223 |
^ '$Header$'
|
5374
|
224 |
! !
|
6713
|
225 |
|