author | Claus Gittinger <cg@exept.de> |
Fri, 10 Jan 1997 18:32:24 +0100 | |
changeset 357 | 4bcb93f5892e |
parent 323 | ee2f4da361a6 |
child 365 | 47e0d48fd769 |
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 |
||
321 | 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 |
|
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 |
||
321 | 64 |
!VisualComponent class methodsFor:'instance creation'! |
245 | 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 |
||
323 | 129 |
^ 0@0 extent:100@100 |
245 | 130 |
|
131 |
"Created: 8.5.1996 / 23:36:29 / cg" |
|
323 | 132 |
"Modified: 19.7.1996 / 20:06:28 / cg" |
133 |
! |
|
134 |
||
135 |
preferredExtent |
|
136 |
^ self preferredBounds extent |
|
137 |
||
246 | 138 |
"Modified: 9.5.1996 / 00:13:22 / cg" |
323 | 139 |
"Created: 19.7.1996 / 20:06:19 / cg" |
247 | 140 |
! |
141 |
||
274 | 142 |
right |
143 |
"return my right x coordinate" |
|
144 |
||
145 |
^ self bounds right |
|
247 | 146 |
|
274 | 147 |
"Modified: 9.5.1996 / 00:13:12 / cg" |
148 |
"Created: 26.5.1996 / 12:56:25 / cg" |
|
149 |
! |
|
150 |
||
151 |
top |
|
152 |
"return my top y coordinate" |
|
153 |
||
154 |
^ self bounds top |
|
155 |
||
156 |
"Modified: 9.5.1996 / 00:13:12 / cg" |
|
157 |
"Created: 26.5.1996 / 12:56:15 / cg" |
|
321 | 158 |
! |
159 |
||
160 |
viewRectangle |
|
161 |
^ self bounds |
|
162 |
||
163 |
"Created: 19.7.1996 / 17:24:58 / cg" |
|
245 | 164 |
! ! |
165 |
||
166 |
!VisualComponent methodsFor:'accessing - look'! |
|
167 |
||
168 |
backgroundColor:aColor |
|
246 | 169 |
"set my backgroundColor" |
170 |
||
245 | 171 |
bgColor := aColor |
172 |
||
173 |
"Created: 8.5.1996 / 23:47:11 / cg" |
|
246 | 174 |
"Modified: 9.5.1996 / 00:13:33 / cg" |
245 | 175 |
! |
176 |
||
177 |
foregroundColor:aColor |
|
246 | 178 |
"set my foregroundColor" |
179 |
||
245 | 180 |
fgColor := aColor |
181 |
||
182 |
"Created: 8.5.1996 / 23:47:05 / cg" |
|
246 | 183 |
"Modified: 9.5.1996 / 00:13:39 / cg" |
245 | 184 |
! ! |
185 |
||
293
d10ad10d23fa
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
186 |
!VisualComponent methodsFor:'accessing-mvc'! |
d10ad10d23fa
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
187 |
|
d10ad10d23fa
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
188 |
model |
d10ad10d23fa
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
189 |
"return nil - generic components have no model" |
d10ad10d23fa
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
190 |
|
d10ad10d23fa
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
191 |
^ nil |
d10ad10d23fa
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
192 |
|
d10ad10d23fa
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
193 |
"Created: 5.6.1996 / 14:18:16 / cg" |
d10ad10d23fa
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
194 |
! ! |
d10ad10d23fa
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
291
diff
changeset
|
195 |
|
265 | 196 |
!VisualComponent methodsFor:'displaying'! |
197 |
||
198 |
displayOn:aGC x:x y:y |
|
199 |
|oldTranslation| |
|
200 |
||
201 |
oldTranslation := aGC translation. |
|
202 |
aGC translation:(x @ y). |
|
203 |
||
204 |
self displayOn:aGC. |
|
205 |
||
206 |
aGC translation:oldTranslation |
|
207 |
||
208 |
"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
|
209 |
"Modified: 13.5.1996 / 11:18:24 / cg" |
265 | 210 |
! ! |
211 |
||
245 | 212 |
!VisualComponent methodsFor:'event handling'! |
213 |
||
214 |
buttonPress:button x:x y:y |
|
246 | 215 |
"button was pressed over me - ignored here" |
245 | 216 |
|
246 | 217 |
"Modified: 9.5.1996 / 00:14:08 / cg" |
245 | 218 |
! |
219 |
||
220 |
buttonRelease:button x:x y:y |
|
246 | 221 |
"button was released over me - ignored here" |
245 | 222 |
|
223 |
"Created: 8.5.1996 / 23:38:30 / cg" |
|
246 | 224 |
"Modified: 9.5.1996 / 00:14:04 / cg" |
245 | 225 |
! |
226 |
||
321 | 227 |
containerChangedSize |
228 |
||
229 |
"Created: 19.7.1996 / 17:32:19 / cg" |
|
230 |
! |
|
231 |
||
232 |
containerMapped |
|
233 |
||
234 |
"Created: 19.7.1996 / 17:39:27 / cg" |
|
235 |
! |
|
236 |
||
237 |
containerUnmapped |
|
238 |
||
239 |
"Created: 19.7.1996 / 17:44:52 / cg" |
|
240 |
! |
|
241 |
||
242 |
destroy |
|
243 |
||
244 |
"Created: 19.7.1996 / 17:25:46 / cg" |
|
245 |
! |
|
246 |
||
245 | 247 |
keyPress:key x:x y:y |
246 | 248 |
"key was pressed over me - ignored here" |
245 | 249 |
|
250 |
"Created: 8.5.1996 / 23:46:03 / cg" |
|
246 | 251 |
"Modified: 9.5.1996 / 00:14:14 / cg" |
245 | 252 |
! |
253 |
||
254 |
keyRelease:key x:x y:y |
|
246 | 255 |
"key was released over me - ignored here" |
245 | 256 |
|
257 |
"Created: 8.5.1996 / 23:46:07 / cg" |
|
246 | 258 |
"Modified: 9.5.1996 / 00:14:19 / cg" |
245 | 259 |
! ! |
260 |
||
261 |
!VisualComponent methodsFor:'initialization'! |
|
262 |
||
263 |
initialize |
|
264 |
fgColor := Color black. |
|
265 |
bgColor := Color white. |
|
266 |
||
267 |
"Created: 8.5.1996 / 23:49:54 / cg" |
|
268 |
! ! |
|
269 |
||
265 | 270 |
!VisualComponent methodsFor:'queries'! |
271 |
||
272 |
heightOn:aGC |
|
273 |
"return my height, if displayed on aGC; |
|
274 |
I assume that my height is independent of the device, and return |
|
275 |
the bounds height" |
|
276 |
||
277 |
^ self bounds height |
|
278 |
||
279 |
"Modified: 13.5.1996 / 10:15:13 / cg" |
|
280 |
! |
|
281 |
||
290
d26dc55ac7e4
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
282 |
isBorderedWrapper |
d26dc55ac7e4
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
283 |
^ false |
d26dc55ac7e4
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
284 |
|
d26dc55ac7e4
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
285 |
"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
|
286 |
! |
d26dc55ac7e4
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
287 |
|
321 | 288 |
isLayoutWrapper |
289 |
^ false |
|
290 |
||
291 |
"Created: 19.7.1996 / 17:50:59 / cg" |
|
292 |
! |
|
293 |
||
290
d26dc55ac7e4
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
294 |
isWrapper |
d26dc55ac7e4
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
295 |
^ false |
d26dc55ac7e4
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
296 |
|
d26dc55ac7e4
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
297 |
"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
|
298 |
! |
d26dc55ac7e4
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
299 |
|
265 | 300 |
widthOn:aGC |
301 |
"return my width, if displayed on aGC; |
|
302 |
I assume that my width is independent of the device, and return |
|
303 |
the bounds width" |
|
304 |
||
305 |
^ self bounds width |
|
306 |
||
307 |
"Created: 13.5.1996 / 10:14:44 / cg" |
|
308 |
"Modified: 13.5.1996 / 10:15:17 / cg" |
|
309 |
! ! |
|
310 |
||
247 | 311 |
!VisualComponent methodsFor:'testing'! |
312 |
||
313 |
containsPoint:aPoint |
|
314 |
"return true, if the receiver contains aPoint" |
|
315 |
||
316 |
^ self bounds containsPoint:aPoint |
|
317 |
||
318 |
"Created: 9.5.1996 / 00:21:44 / cg" |
|
319 |
"Modified: 9.5.1996 / 00:22:00 / cg" |
|
320 |
! |
|
321 |
||
322 |
hasBorder |
|
323 |
"return true, if the receiver shows a border" |
|
324 |
||
325 |
^ false |
|
326 |
||
327 |
"Modified: 9.5.1996 / 00:21:29 / cg" |
|
328 |
! |
|
329 |
||
330 |
intersects:aRectangle |
|
331 |
"return true, if the receivers bounds intersects aRectangle" |
|
332 |
||
333 |
^ self bounds intersects:aRectangle |
|
334 |
||
335 |
"Created: 9.5.1996 / 00:21:18 / cg" |
|
336 |
"Modified: 9.5.1996 / 00:22:04 / cg" |
|
337 |
! ! |
|
338 |
||
321 | 339 |
!VisualComponent class methodsFor:'documentation'! |
245 | 340 |
|
341 |
version |
|
323 | 342 |
^ '$Header: /cvs/stx/stx/libview2/VisualComponent.st,v 1.12 1996-07-22 09:02:58 cg Exp $' |
245 | 343 |
! ! |