author | Claus Gittinger <cg@exept.de> |
Wed, 05 Jun 1996 17:22:58 +0200 | |
changeset 291 | 785a5faf3320 |
parent 290 | d26dc55ac7e4 |
child 293 | d10ad10d23fa |
permissions | -rw-r--r-- |
245 | 1 |
" |
2 |
COPYRIGHT (c) 1996 by Claus Gittinger |
|
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 |
||
13 |
||
14 |
||
15 |
Object subclass:#VisualComponent |
|
16 |
instanceVariableNames:'bounds fgColor bgColor' |
|
17 |
classVariableNames:'' |
|
18 |
poolDictionaries:'' |
|
19 |
category:'Graphics-Display Objects' |
|
20 |
! |
|
21 |
||
22 |
!VisualComponent class methodsFor:'documentation'! |
|
23 |
||
24 |
copyright |
|
25 |
" |
|
26 |
COPYRIGHT (c) 1996 by Claus Gittinger |
|
27 |
All Rights Reserved |
|
28 |
||
29 |
This software is furnished under a license and may be used |
|
30 |
only in accordance with the terms of that license and with the |
|
31 |
inclusion of the above copyright notice. This software may not |
|
32 |
be provided or otherwise made available to, or used by, any |
|
33 |
other person. No title to or ownership of the software is |
|
34 |
hereby transferred. |
|
35 |
" |
|
36 |
||
37 |
||
38 |
! |
|
39 |
||
40 |
documentation |
|
41 |
" |
|
246 | 42 |
abstract superclass for all kinds of visual components. |
265 | 43 |
This class and its subclasses (currently) exist mostly for |
44 |
ST-80 compatibility - to provide a home for ported PD classes, |
|
45 |
which depend on the VisualComponent hierarchy. |
|
46 |
||
47 |
Notice: |
|
48 |
this class was implemented using protocol information |
|
49 |
from alpha testers and from the Hopkins/Horan book. |
|
50 |
- it may not be complete or compatible to the corresponding ST-80 class. |
|
51 |
If you encounter any incompatibilities, please forward a note |
|
52 |
describing the incompatibility verbal (i.e. no code) to the ST/X team. |
|
53 |
This is still being constructed - not yet finished. |
|
245 | 54 |
|
55 |
[author:] |
|
56 |
Claus Gittinger |
|
265 | 57 |
|
58 |
[see also:] |
|
59 |
GeometricWrapper |
|
245 | 60 |
" |
61 |
||
62 |
! ! |
|
63 |
||
64 |
!VisualComponent class methodsFor:'instance creation'! |
|
65 |
||
66 |
new |
|
67 |
^ self basicNew initialize |
|
68 |
! ! |
|
69 |
||
70 |
!VisualComponent methodsFor:'accessing'! |
|
71 |
||
274 | 72 |
container:someContainer |
73 |
"ignored here" |
|
74 |
||
75 |
"Created: 9.5.1996 / 00:48:54 / cg" |
|
76 |
! |
|
77 |
||
78 |
setParentViewIn:aView |
|
79 |
"ignored here - for now" |
|
80 |
||
81 |
"Created: 9.5.1996 / 00:19:39 / cg" |
|
82 |
! ! |
|
83 |
||
84 |
!VisualComponent methodsFor:'accessing - dimensions'! |
|
85 |
||
86 |
bottom |
|
87 |
"return my bottom y coordinate" |
|
88 |
||
89 |
^ self bounds bottom |
|
90 |
||
91 |
"Modified: 9.5.1996 / 00:13:12 / cg" |
|
92 |
"Created: 26.5.1996 / 12:56:12 / cg" |
|
93 |
! |
|
94 |
||
245 | 95 |
bounds |
246 | 96 |
"return my bounds" |
97 |
||
245 | 98 |
^ bounds |
99 |
||
100 |
"Created: 8.5.1996 / 23:35:19 / cg" |
|
246 | 101 |
"Modified: 9.5.1996 / 00:12:00 / cg" |
291
785a5faf3320
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
290
diff
changeset
|
102 |
! ! |
785a5faf3320
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
290
diff
changeset
|
103 |
|
785a5faf3320
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
290
diff
changeset
|
104 |
!VisualComponent ignoredMethodsFor:'accessing - dimensions'! |
245 | 105 |
|
246 | 106 |
bounds:aRectangle |
107 |
"set my bounds" |
|
108 |
||
109 |
bounds := aRectangle |
|
245 | 110 |
|
111 |
"Created: 8.5.1996 / 23:36:07 / cg" |
|
246 | 112 |
"Modified: 9.5.1996 / 00:13:12 / cg" |
291
785a5faf3320
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
290
diff
changeset
|
113 |
! ! |
785a5faf3320
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
290
diff
changeset
|
114 |
|
785a5faf3320
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
290
diff
changeset
|
115 |
!VisualComponent methodsFor:'accessing - dimensions'! |
245 | 116 |
|
274 | 117 |
left |
118 |
"return my left x coordinate" |
|
250 | 119 |
|
274 | 120 |
^ self bounds left |
121 |
||
122 |
"Created: 8.5.1996 / 23:36:07 / cg" |
|
123 |
"Modified: 26.5.1996 / 12:56:22 / cg" |
|
250 | 124 |
! |
125 |
||
245 | 126 |
preferredBounds |
246 | 127 |
"return my preferredBounds" |
128 |
||
245 | 129 |
^ 100@100 |
130 |
||
131 |
"Created: 8.5.1996 / 23:36:29 / cg" |
|
246 | 132 |
"Modified: 9.5.1996 / 00:13:22 / cg" |
247 | 133 |
! |
134 |
||
274 | 135 |
right |
136 |
"return my right x coordinate" |
|
137 |
||
138 |
^ self bounds right |
|
247 | 139 |
|
274 | 140 |
"Modified: 9.5.1996 / 00:13:12 / cg" |
141 |
"Created: 26.5.1996 / 12:56:25 / cg" |
|
142 |
! |
|
143 |
||
144 |
top |
|
145 |
"return my top y coordinate" |
|
146 |
||
147 |
^ self bounds top |
|
148 |
||
149 |
"Modified: 9.5.1996 / 00:13:12 / cg" |
|
150 |
"Created: 26.5.1996 / 12:56:15 / cg" |
|
245 | 151 |
! ! |
152 |
||
153 |
!VisualComponent methodsFor:'accessing - look'! |
|
154 |
||
155 |
backgroundColor:aColor |
|
246 | 156 |
"set my backgroundColor" |
157 |
||
245 | 158 |
bgColor := aColor |
159 |
||
160 |
"Created: 8.5.1996 / 23:47:11 / cg" |
|
246 | 161 |
"Modified: 9.5.1996 / 00:13:33 / cg" |
245 | 162 |
! |
163 |
||
164 |
foregroundColor:aColor |
|
246 | 165 |
"set my foregroundColor" |
166 |
||
245 | 167 |
fgColor := aColor |
168 |
||
169 |
"Created: 8.5.1996 / 23:47:05 / cg" |
|
246 | 170 |
"Modified: 9.5.1996 / 00:13:39 / cg" |
245 | 171 |
! ! |
172 |
||
265 | 173 |
!VisualComponent methodsFor:'displaying'! |
174 |
||
175 |
displayOn:aGC x:x y:y |
|
176 |
|oldTranslation| |
|
177 |
||
178 |
oldTranslation := aGC translation. |
|
179 |
aGC translation:(x @ y). |
|
180 |
||
181 |
self displayOn:aGC. |
|
182 |
||
183 |
aGC translation:oldTranslation |
|
184 |
||
185 |
"Created: 13.5.1996 / 10:18:43 / cg" |
|
266
e9d35cd74f64
wrappers usable as label in Label/Button etc.
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
186 |
"Modified: 13.5.1996 / 11:18:24 / cg" |
265 | 187 |
! ! |
188 |
||
245 | 189 |
!VisualComponent methodsFor:'event handling'! |
190 |
||
191 |
buttonPress:button x:x y:y |
|
246 | 192 |
"button was pressed over me - ignored here" |
245 | 193 |
|
246 | 194 |
"Modified: 9.5.1996 / 00:14:08 / cg" |
245 | 195 |
! |
196 |
||
197 |
buttonRelease:button x:x y:y |
|
246 | 198 |
"button was released over me - ignored here" |
245 | 199 |
|
200 |
"Created: 8.5.1996 / 23:38:30 / cg" |
|
246 | 201 |
"Modified: 9.5.1996 / 00:14:04 / cg" |
245 | 202 |
! |
203 |
||
204 |
keyPress:key x:x y:y |
|
246 | 205 |
"key was pressed over me - ignored here" |
245 | 206 |
|
207 |
"Created: 8.5.1996 / 23:46:03 / cg" |
|
246 | 208 |
"Modified: 9.5.1996 / 00:14:14 / cg" |
245 | 209 |
! |
210 |
||
211 |
keyRelease:key x:x y:y |
|
246 | 212 |
"key was released over me - ignored here" |
245 | 213 |
|
214 |
"Created: 8.5.1996 / 23:46:07 / cg" |
|
246 | 215 |
"Modified: 9.5.1996 / 00:14:19 / cg" |
245 | 216 |
! ! |
217 |
||
218 |
!VisualComponent methodsFor:'initialization'! |
|
219 |
||
220 |
initialize |
|
221 |
fgColor := Color black. |
|
222 |
bgColor := Color white. |
|
223 |
||
224 |
"Created: 8.5.1996 / 23:49:54 / cg" |
|
225 |
! ! |
|
226 |
||
265 | 227 |
!VisualComponent methodsFor:'queries'! |
228 |
||
229 |
heightOn:aGC |
|
230 |
"return my height, if displayed on aGC; |
|
231 |
I assume that my height is independent of the device, and return |
|
232 |
the bounds height" |
|
233 |
||
234 |
^ self bounds height |
|
235 |
||
236 |
"Modified: 13.5.1996 / 10:15:13 / cg" |
|
237 |
! |
|
238 |
||
290
d26dc55ac7e4
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
239 |
isBorderedWrapper |
d26dc55ac7e4
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
240 |
^ false |
d26dc55ac7e4
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
241 |
|
d26dc55ac7e4
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
242 |
"Created: 5.6.1996 / 14:11:18 / cg" |
d26dc55ac7e4
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
243 |
! |
d26dc55ac7e4
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
244 |
|
d26dc55ac7e4
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
245 |
isWrapper |
d26dc55ac7e4
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
246 |
^ false |
d26dc55ac7e4
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
247 |
|
d26dc55ac7e4
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
248 |
"Created: 5.6.1996 / 01:04:40 / cg" |
d26dc55ac7e4
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
249 |
! |
d26dc55ac7e4
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
250 |
|
265 | 251 |
widthOn:aGC |
252 |
"return my width, if displayed on aGC; |
|
253 |
I assume that my width is independent of the device, and return |
|
254 |
the bounds width" |
|
255 |
||
256 |
^ self bounds width |
|
257 |
||
258 |
"Created: 13.5.1996 / 10:14:44 / cg" |
|
259 |
"Modified: 13.5.1996 / 10:15:17 / cg" |
|
260 |
! ! |
|
261 |
||
247 | 262 |
!VisualComponent methodsFor:'testing'! |
263 |
||
264 |
containsPoint:aPoint |
|
265 |
"return true, if the receiver contains aPoint" |
|
266 |
||
267 |
^ self bounds containsPoint:aPoint |
|
268 |
||
269 |
"Created: 9.5.1996 / 00:21:44 / cg" |
|
270 |
"Modified: 9.5.1996 / 00:22:00 / cg" |
|
271 |
! |
|
272 |
||
273 |
hasBorder |
|
274 |
"return true, if the receiver shows a border" |
|
275 |
||
276 |
^ false |
|
277 |
||
278 |
"Modified: 9.5.1996 / 00:21:29 / cg" |
|
279 |
! |
|
280 |
||
281 |
intersects:aRectangle |
|
282 |
"return true, if the receivers bounds intersects aRectangle" |
|
283 |
||
284 |
^ self bounds intersects:aRectangle |
|
285 |
||
286 |
"Created: 9.5.1996 / 00:21:18 / cg" |
|
287 |
"Modified: 9.5.1996 / 00:22:04 / cg" |
|
288 |
! ! |
|
289 |
||
245 | 290 |
!VisualComponent class methodsFor:'documentation'! |
291 |
||
292 |
version |
|
291
785a5faf3320
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
290
diff
changeset
|
293 |
^ '$Header: /cvs/stx/stx/libview2/VisualComponent.st,v 1.9 1996-06-05 15:22:58 cg Exp $' |
245 | 294 |
! ! |