author | Claus Gittinger <cg@exept.de> |
Thu, 06 Mar 1997 15:16:03 +0100 | |
changeset 494 | ce8c074d5e6b |
parent 406 | 16d990bcde6e |
child 962 | e6ccfc7fb22e |
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 |
|
406 | 16 |
instanceVariableNames:'bounds' |
245 | 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 |
||
293
d10ad10d23fa
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
167 |
!VisualComponent methodsFor:'accessing-mvc'! |
d10ad10d23fa
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
168 |
|
d10ad10d23fa
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
169 |
model |
d10ad10d23fa
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
170 |
"return nil - generic components have no model" |
d10ad10d23fa
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
171 |
|
d10ad10d23fa
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
172 |
^ nil |
d10ad10d23fa
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
173 |
|
d10ad10d23fa
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
174 |
"Created: 5.6.1996 / 14:18:16 / cg" |
d10ad10d23fa
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
175 |
! ! |
d10ad10d23fa
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
176 |
|
265 | 177 |
!VisualComponent methodsFor:'displaying'! |
178 |
||
406 | 179 |
displayOn:aGC |
180 |
"display the receiver on some graphicsContext. |
|
181 |
The sender is repsonsible for restoring the GC's state |
|
182 |
(i.e. it may be left in any undefined state)" |
|
183 |
||
184 |
self subclassResponsibility |
|
185 |
||
186 |
"Modified: 10.2.1997 / 13:53:03 / cg" |
|
187 |
! |
|
188 |
||
189 |
displayOn:aGC at:aPoint |
|
190 |
"display the receiver translated by some amount on some graphicsContext" |
|
191 |
||
265 | 192 |
|oldTranslation| |
193 |
||
194 |
oldTranslation := aGC translation. |
|
406 | 195 |
aGC translateBy:aPoint. |
265 | 196 |
self displayOn:aGC. |
197 |
aGC translation:oldTranslation |
|
198 |
||
406 | 199 |
"Created: 10.2.1997 / 13:47:18 / cg" |
200 |
"Modified: 10.2.1997 / 13:52:53 / cg" |
|
201 |
! |
|
202 |
||
203 |
displayOn:aGC x:x y:y |
|
204 |
"display the receiver translated by some amount on some graphicsContext" |
|
205 |
||
206 |
^ self displayOn:aGC at:(x @ y). |
|
207 |
||
208 |
"Modified: 10.2.1997 / 13:52:57 / cg" |
|
265 | 209 |
! ! |
210 |
||
245 | 211 |
!VisualComponent methodsFor:'event handling'! |
212 |
||
213 |
buttonPress:button x:x y:y |
|
246 | 214 |
"button was pressed over me - ignored here" |
245 | 215 |
|
246 | 216 |
"Modified: 9.5.1996 / 00:14:08 / cg" |
245 | 217 |
! |
218 |
||
219 |
buttonRelease:button x:x y:y |
|
246 | 220 |
"button was released over me - ignored here" |
245 | 221 |
|
222 |
"Created: 8.5.1996 / 23:38:30 / cg" |
|
246 | 223 |
"Modified: 9.5.1996 / 00:14:04 / cg" |
245 | 224 |
! |
225 |
||
321 | 226 |
containerChangedSize |
227 |
||
228 |
"Created: 19.7.1996 / 17:32:19 / cg" |
|
229 |
! |
|
230 |
||
231 |
containerMapped |
|
232 |
||
233 |
"Created: 19.7.1996 / 17:39:27 / cg" |
|
234 |
! |
|
235 |
||
236 |
containerUnmapped |
|
237 |
||
238 |
"Created: 19.7.1996 / 17:44:52 / cg" |
|
239 |
! |
|
240 |
||
241 |
destroy |
|
242 |
||
243 |
"Created: 19.7.1996 / 17:25:46 / cg" |
|
244 |
! |
|
245 |
||
245 | 246 |
keyPress:key x:x y:y |
246 | 247 |
"key was pressed over me - ignored here" |
245 | 248 |
|
249 |
"Created: 8.5.1996 / 23:46:03 / cg" |
|
246 | 250 |
"Modified: 9.5.1996 / 00:14:14 / cg" |
245 | 251 |
! |
252 |
||
253 |
keyRelease:key x:x y:y |
|
246 | 254 |
"key was released over me - ignored here" |
245 | 255 |
|
256 |
"Created: 8.5.1996 / 23:46:07 / cg" |
|
246 | 257 |
"Modified: 9.5.1996 / 00:14:19 / cg" |
245 | 258 |
! ! |
259 |
||
260 |
!VisualComponent methodsFor:'initialization'! |
|
261 |
||
262 |
initialize |
|
263 |
||
406 | 264 |
"Modified: 10.2.1997 / 19:28:11 / cg" |
245 | 265 |
! ! |
266 |
||
265 | 267 |
!VisualComponent methodsFor:'queries'! |
268 |
||
269 |
heightOn:aGC |
|
270 |
"return my height, if displayed on aGC; |
|
271 |
I assume that my height is independent of the device, and return |
|
272 |
the bounds height" |
|
273 |
||
274 |
^ self bounds height |
|
275 |
||
276 |
"Modified: 13.5.1996 / 10:15:13 / cg" |
|
277 |
! |
|
278 |
||
290
d26dc55ac7e4
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
279 |
isBorderedWrapper |
d26dc55ac7e4
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
280 |
^ false |
d26dc55ac7e4
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
281 |
|
d26dc55ac7e4
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
282 |
"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
|
283 |
! |
d26dc55ac7e4
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
284 |
|
321 | 285 |
isLayoutWrapper |
286 |
^ false |
|
287 |
||
288 |
"Created: 19.7.1996 / 17:50:59 / cg" |
|
289 |
! |
|
290 |
||
290
d26dc55ac7e4
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
291 |
isWrapper |
d26dc55ac7e4
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
292 |
^ false |
d26dc55ac7e4
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
293 |
|
d26dc55ac7e4
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
294 |
"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
|
295 |
! |
d26dc55ac7e4
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
296 |
|
265 | 297 |
widthOn:aGC |
298 |
"return my width, if displayed on aGC; |
|
299 |
I assume that my width is independent of the device, and return |
|
300 |
the bounds width" |
|
301 |
||
302 |
^ self bounds width |
|
303 |
||
304 |
"Created: 13.5.1996 / 10:14:44 / cg" |
|
305 |
"Modified: 13.5.1996 / 10:15:17 / cg" |
|
306 |
! ! |
|
307 |
||
247 | 308 |
!VisualComponent methodsFor:'testing'! |
309 |
||
310 |
containsPoint:aPoint |
|
311 |
"return true, if the receiver contains aPoint" |
|
312 |
||
313 |
^ self bounds containsPoint:aPoint |
|
314 |
||
315 |
"Created: 9.5.1996 / 00:21:44 / cg" |
|
316 |
"Modified: 9.5.1996 / 00:22:00 / cg" |
|
317 |
! |
|
318 |
||
319 |
hasBorder |
|
320 |
"return true, if the receiver shows a border" |
|
321 |
||
322 |
^ false |
|
323 |
||
324 |
"Modified: 9.5.1996 / 00:21:29 / cg" |
|
325 |
! |
|
326 |
||
327 |
intersects:aRectangle |
|
328 |
"return true, if the receivers bounds intersects aRectangle" |
|
329 |
||
330 |
^ self bounds intersects:aRectangle |
|
331 |
||
332 |
"Created: 9.5.1996 / 00:21:18 / cg" |
|
333 |
"Modified: 9.5.1996 / 00:22:04 / cg" |
|
334 |
! ! |
|
335 |
||
365 | 336 |
!VisualComponent class methodsFor:'documentation'! |
245 | 337 |
|
338 |
version |
|
406 | 339 |
^ '$Header: /cvs/stx/stx/libview2/VisualComponent.st,v 1.14 1997-02-10 18:28:29 cg Exp $' |
245 | 340 |
! ! |