author | Claus Gittinger <cg@exept.de> |
Tue, 14 Jan 1997 18:02:37 +0100 | |
changeset 365 | 47e0d48fd769 |
parent 323 | ee2f4da361a6 |
child 406 | 16d990bcde6e |
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 |
||
365 | 22 |
!VisualComponent class methodsFor:'documentation'! |
245 | 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 |
|
365 | 49 |
from alpha testers, from reading PD programs and |
50 |
from the Hopkins/Horan book. |
|
265 | 51 |
- it may not be complete or compatible to the corresponding ST-80 class. |
52 |
If you encounter any incompatibilities, please forward a note |
|
53 |
describing the incompatibility verbal (i.e. no code) to the ST/X team. |
|
54 |
This is still being constructed - not yet finished. |
|
245 | 55 |
|
56 |
[author:] |
|
57 |
Claus Gittinger |
|
265 | 58 |
|
59 |
[see also:] |
|
60 |
GeometricWrapper |
|
245 | 61 |
" |
62 |
||
63 |
! ! |
|
64 |
||
365 | 65 |
!VisualComponent class methodsFor:'instance creation'! |
245 | 66 |
|
67 |
new |
|
68 |
^ self basicNew initialize |
|
69 |
! ! |
|
70 |
||
71 |
!VisualComponent methodsFor:'accessing'! |
|
72 |
||
274 | 73 |
container:someContainer |
74 |
"ignored here" |
|
75 |
||
76 |
"Created: 9.5.1996 / 00:48:54 / cg" |
|
77 |
! |
|
78 |
||
79 |
setParentViewIn:aView |
|
80 |
"ignored here - for now" |
|
81 |
||
82 |
"Created: 9.5.1996 / 00:19:39 / cg" |
|
83 |
! ! |
|
84 |
||
85 |
!VisualComponent methodsFor:'accessing - dimensions'! |
|
86 |
||
87 |
bottom |
|
88 |
"return my bottom y coordinate" |
|
89 |
||
90 |
^ self bounds bottom |
|
91 |
||
92 |
"Modified: 9.5.1996 / 00:13:12 / cg" |
|
93 |
"Created: 26.5.1996 / 12:56:12 / cg" |
|
94 |
! |
|
95 |
||
245 | 96 |
bounds |
246 | 97 |
"return my bounds" |
98 |
||
245 | 99 |
^ bounds |
100 |
||
101 |
"Created: 8.5.1996 / 23:35:19 / cg" |
|
246 | 102 |
"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
|
103 |
! ! |
785a5faf3320
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
290
diff
changeset
|
104 |
|
785a5faf3320
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
290
diff
changeset
|
105 |
!VisualComponent ignoredMethodsFor:'accessing - dimensions'! |
245 | 106 |
|
246 | 107 |
bounds:aRectangle |
108 |
"set my bounds" |
|
109 |
||
110 |
bounds := aRectangle |
|
245 | 111 |
|
112 |
"Created: 8.5.1996 / 23:36:07 / cg" |
|
246 | 113 |
"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
|
114 |
! ! |
785a5faf3320
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
290
diff
changeset
|
115 |
|
785a5faf3320
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
290
diff
changeset
|
116 |
!VisualComponent methodsFor:'accessing - dimensions'! |
245 | 117 |
|
274 | 118 |
left |
119 |
"return my left x coordinate" |
|
250 | 120 |
|
274 | 121 |
^ self bounds left |
122 |
||
123 |
"Created: 8.5.1996 / 23:36:07 / cg" |
|
124 |
"Modified: 26.5.1996 / 12:56:22 / cg" |
|
250 | 125 |
! |
126 |
||
245 | 127 |
preferredBounds |
246 | 128 |
"return my preferredBounds" |
129 |
||
323 | 130 |
^ 0@0 extent:100@100 |
245 | 131 |
|
132 |
"Created: 8.5.1996 / 23:36:29 / cg" |
|
323 | 133 |
"Modified: 19.7.1996 / 20:06:28 / cg" |
134 |
! |
|
135 |
||
136 |
preferredExtent |
|
137 |
^ self preferredBounds extent |
|
138 |
||
246 | 139 |
"Modified: 9.5.1996 / 00:13:22 / cg" |
323 | 140 |
"Created: 19.7.1996 / 20:06:19 / cg" |
247 | 141 |
! |
142 |
||
274 | 143 |
right |
144 |
"return my right x coordinate" |
|
145 |
||
146 |
^ self bounds right |
|
247 | 147 |
|
274 | 148 |
"Modified: 9.5.1996 / 00:13:12 / cg" |
149 |
"Created: 26.5.1996 / 12:56:25 / cg" |
|
150 |
! |
|
151 |
||
152 |
top |
|
153 |
"return my top y coordinate" |
|
154 |
||
155 |
^ self bounds top |
|
156 |
||
157 |
"Modified: 9.5.1996 / 00:13:12 / cg" |
|
158 |
"Created: 26.5.1996 / 12:56:15 / cg" |
|
321 | 159 |
! |
160 |
||
161 |
viewRectangle |
|
162 |
^ self bounds |
|
163 |
||
164 |
"Created: 19.7.1996 / 17:24:58 / cg" |
|
245 | 165 |
! ! |
166 |
||
167 |
!VisualComponent methodsFor:'accessing - look'! |
|
168 |
||
169 |
backgroundColor:aColor |
|
246 | 170 |
"set my backgroundColor" |
171 |
||
245 | 172 |
bgColor := aColor |
173 |
||
174 |
"Created: 8.5.1996 / 23:47:11 / cg" |
|
246 | 175 |
"Modified: 9.5.1996 / 00:13:33 / cg" |
245 | 176 |
! |
177 |
||
178 |
foregroundColor:aColor |
|
246 | 179 |
"set my foregroundColor" |
180 |
||
245 | 181 |
fgColor := aColor |
182 |
||
183 |
"Created: 8.5.1996 / 23:47:05 / cg" |
|
246 | 184 |
"Modified: 9.5.1996 / 00:13:39 / cg" |
245 | 185 |
! ! |
186 |
||
293
d10ad10d23fa
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
187 |
!VisualComponent methodsFor:'accessing-mvc'! |
d10ad10d23fa
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
188 |
|
d10ad10d23fa
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
189 |
model |
d10ad10d23fa
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
190 |
"return nil - generic components have no model" |
d10ad10d23fa
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
191 |
|
d10ad10d23fa
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
192 |
^ nil |
d10ad10d23fa
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
193 |
|
d10ad10d23fa
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
194 |
"Created: 5.6.1996 / 14:18:16 / cg" |
d10ad10d23fa
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
195 |
! ! |
d10ad10d23fa
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
196 |
|
265 | 197 |
!VisualComponent methodsFor:'displaying'! |
198 |
||
199 |
displayOn:aGC x:x y:y |
|
200 |
|oldTranslation| |
|
201 |
||
202 |
oldTranslation := aGC translation. |
|
203 |
aGC translation:(x @ y). |
|
204 |
||
205 |
self displayOn:aGC. |
|
206 |
||
207 |
aGC translation:oldTranslation |
|
208 |
||
209 |
"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
|
210 |
"Modified: 13.5.1996 / 11:18:24 / cg" |
265 | 211 |
! ! |
212 |
||
245 | 213 |
!VisualComponent methodsFor:'event handling'! |
214 |
||
215 |
buttonPress:button x:x y:y |
|
246 | 216 |
"button was pressed over me - ignored here" |
245 | 217 |
|
246 | 218 |
"Modified: 9.5.1996 / 00:14:08 / cg" |
245 | 219 |
! |
220 |
||
221 |
buttonRelease:button x:x y:y |
|
246 | 222 |
"button was released over me - ignored here" |
245 | 223 |
|
224 |
"Created: 8.5.1996 / 23:38:30 / cg" |
|
246 | 225 |
"Modified: 9.5.1996 / 00:14:04 / cg" |
245 | 226 |
! |
227 |
||
321 | 228 |
containerChangedSize |
229 |
||
230 |
"Created: 19.7.1996 / 17:32:19 / cg" |
|
231 |
! |
|
232 |
||
233 |
containerMapped |
|
234 |
||
235 |
"Created: 19.7.1996 / 17:39:27 / cg" |
|
236 |
! |
|
237 |
||
238 |
containerUnmapped |
|
239 |
||
240 |
"Created: 19.7.1996 / 17:44:52 / cg" |
|
241 |
! |
|
242 |
||
243 |
destroy |
|
244 |
||
245 |
"Created: 19.7.1996 / 17:25:46 / cg" |
|
246 |
! |
|
247 |
||
245 | 248 |
keyPress:key x:x y:y |
246 | 249 |
"key was pressed over me - ignored here" |
245 | 250 |
|
251 |
"Created: 8.5.1996 / 23:46:03 / cg" |
|
246 | 252 |
"Modified: 9.5.1996 / 00:14:14 / cg" |
245 | 253 |
! |
254 |
||
255 |
keyRelease:key x:x y:y |
|
246 | 256 |
"key was released over me - ignored here" |
245 | 257 |
|
258 |
"Created: 8.5.1996 / 23:46:07 / cg" |
|
246 | 259 |
"Modified: 9.5.1996 / 00:14:19 / cg" |
245 | 260 |
! ! |
261 |
||
262 |
!VisualComponent methodsFor:'initialization'! |
|
263 |
||
264 |
initialize |
|
265 |
fgColor := Color black. |
|
266 |
bgColor := Color white. |
|
267 |
||
268 |
"Created: 8.5.1996 / 23:49:54 / cg" |
|
269 |
! ! |
|
270 |
||
265 | 271 |
!VisualComponent methodsFor:'queries'! |
272 |
||
273 |
heightOn:aGC |
|
274 |
"return my height, if displayed on aGC; |
|
275 |
I assume that my height is independent of the device, and return |
|
276 |
the bounds height" |
|
277 |
||
278 |
^ self bounds height |
|
279 |
||
280 |
"Modified: 13.5.1996 / 10:15:13 / cg" |
|
281 |
! |
|
282 |
||
290
d26dc55ac7e4
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
283 |
isBorderedWrapper |
d26dc55ac7e4
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
284 |
^ false |
d26dc55ac7e4
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
285 |
|
d26dc55ac7e4
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
286 |
"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
|
287 |
! |
d26dc55ac7e4
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
288 |
|
321 | 289 |
isLayoutWrapper |
290 |
^ false |
|
291 |
||
292 |
"Created: 19.7.1996 / 17:50:59 / cg" |
|
293 |
! |
|
294 |
||
290
d26dc55ac7e4
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
295 |
isWrapper |
d26dc55ac7e4
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
296 |
^ false |
d26dc55ac7e4
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
297 |
|
d26dc55ac7e4
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
298 |
"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
|
299 |
! |
d26dc55ac7e4
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
300 |
|
265 | 301 |
widthOn:aGC |
302 |
"return my width, if displayed on aGC; |
|
303 |
I assume that my width is independent of the device, and return |
|
304 |
the bounds width" |
|
305 |
||
306 |
^ self bounds width |
|
307 |
||
308 |
"Created: 13.5.1996 / 10:14:44 / cg" |
|
309 |
"Modified: 13.5.1996 / 10:15:17 / cg" |
|
310 |
! ! |
|
311 |
||
247 | 312 |
!VisualComponent methodsFor:'testing'! |
313 |
||
314 |
containsPoint:aPoint |
|
315 |
"return true, if the receiver contains aPoint" |
|
316 |
||
317 |
^ self bounds containsPoint:aPoint |
|
318 |
||
319 |
"Created: 9.5.1996 / 00:21:44 / cg" |
|
320 |
"Modified: 9.5.1996 / 00:22:00 / cg" |
|
321 |
! |
|
322 |
||
323 |
hasBorder |
|
324 |
"return true, if the receiver shows a border" |
|
325 |
||
326 |
^ false |
|
327 |
||
328 |
"Modified: 9.5.1996 / 00:21:29 / cg" |
|
329 |
! |
|
330 |
||
331 |
intersects:aRectangle |
|
332 |
"return true, if the receivers bounds intersects aRectangle" |
|
333 |
||
334 |
^ self bounds intersects:aRectangle |
|
335 |
||
336 |
"Created: 9.5.1996 / 00:21:18 / cg" |
|
337 |
"Modified: 9.5.1996 / 00:22:04 / cg" |
|
338 |
! ! |
|
339 |
||
365 | 340 |
!VisualComponent class methodsFor:'documentation'! |
245 | 341 |
|
342 |
version |
|
365 | 343 |
^ '$Header: /cvs/stx/stx/libview2/Attic/VComponent.st,v 1.13 1997-01-14 17:02:37 cg Exp $' |
245 | 344 |
! ! |