author | Claus Gittinger <cg@exept.de> |
Fri, 08 May 2009 13:48:00 +0200 | |
changeset 2660 | 87d554e2590f |
parent 2376 | bd1615a0d2af |
child 2665 | 2e57436c3213 |
permissions | -rw-r--r-- |
2376 | 1 |
" |
2 |
COPYRIGHT (c) 2002 by eXept Software AG |
|
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 |
" |
|
1789 | 12 |
"{ Package: 'stx:libview2' }" |
13 |
||
249 | 14 |
VisualComponent subclass:#VisualPart |
15 |
instanceVariableNames:'container' |
|
16 |
classVariableNames:'' |
|
17 |
poolDictionaries:'' |
|
1789 | 18 |
category:'Compatibility-ST80-Graphics-Display Objects' |
249 | 19 |
! |
20 |
||
365 | 21 |
!VisualPart class methodsFor:'documentation'! |
265 | 22 |
|
2376 | 23 |
copyright |
24 |
" |
|
25 |
COPYRIGHT (c) 2002 by eXept Software AG |
|
26 |
All Rights Reserved |
|
27 |
||
28 |
This software is furnished under a license and may be used |
|
29 |
only in accordance with the terms of that license and with the |
|
30 |
inclusion of the above copyright notice. This software may not |
|
31 |
be provided or otherwise made available to, or used by, any |
|
32 |
other person. No title to or ownership of the software is |
|
33 |
hereby transferred. |
|
34 |
" |
|
35 |
! |
|
36 |
||
265 | 37 |
documentation |
38 |
" |
|
39 |
abstract superclass for all kinds of visual components, which |
|
40 |
are containers for some other component. |
|
41 |
This class and its subclasses (currently) exist mostly for |
|
42 |
ST-80 compatibility - to provide a home for ported PD classes, |
|
43 |
which depend on the VisualPart hierarchy. |
|
44 |
||
45 |
Notice: |
|
46 |
this class was implemented using protocol information |
|
365 | 47 |
from alpha testers, from reading PD programs and |
48 |
from the Hopkins/Horan book. |
|
265 | 49 |
- it may not be complete or compatible to the corresponding ST-80 class. |
50 |
If you encounter any incompatibilities, please forward a note |
|
51 |
describing the incompatibility verbal (i.e. no code) to the ST/X team. |
|
52 |
This is still being constructed - not yet finished. |
|
53 |
||
54 |
[author:] |
|
55 |
Claus Gittinger |
|
56 |
||
57 |
[see also:] |
|
58 |
GeometricWrapper |
|
59 |
" |
|
60 |
||
61 |
||
62 |
! ! |
|
249 | 63 |
|
64 |
!VisualPart methodsFor:'accessing'! |
|
65 |
||
962
e6ccfc7fb22e
added more dummy methods to allow visualComponents to be
Claus Gittinger <cg@exept.de>
parents:
365
diff
changeset
|
66 |
backgroundColor |
e6ccfc7fb22e
added more dummy methods to allow visualComponents to be
Claus Gittinger <cg@exept.de>
parents:
365
diff
changeset
|
67 |
^ container backgroundColor |
e6ccfc7fb22e
added more dummy methods to allow visualComponents to be
Claus Gittinger <cg@exept.de>
parents:
365
diff
changeset
|
68 |
|
e6ccfc7fb22e
added more dummy methods to allow visualComponents to be
Claus Gittinger <cg@exept.de>
parents:
365
diff
changeset
|
69 |
"Created: / 18.6.1998 / 15:58:34 / cg" |
e6ccfc7fb22e
added more dummy methods to allow visualComponents to be
Claus Gittinger <cg@exept.de>
parents:
365
diff
changeset
|
70 |
! |
e6ccfc7fb22e
added more dummy methods to allow visualComponents to be
Claus Gittinger <cg@exept.de>
parents:
365
diff
changeset
|
71 |
|
249 | 72 |
container |
289
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
73 |
"return my container" |
249 | 74 |
|
75 |
^ container |
|
76 |
||
77 |
"Created: 9.5.1996 / 00:31:41 / cg" |
|
289
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
78 |
"Modified: 5.6.1996 / 01:08:26 / cg" |
249 | 79 |
! |
80 |
||
81 |
container:something |
|
82 |
"set container" |
|
83 |
||
84 |
container := something. |
|
85 |
||
86 |
"Created: 9.5.1996 / 00:31:41 / cg" |
|
87 |
! |
|
88 |
||
89 |
graphicsContext |
|
90 |
"return the graphicsContext" |
|
91 |
||
254 | 92 |
^ container graphicsContext |
249 | 93 |
|
94 |
"Created: 9.5.1996 / 00:32:12 / cg" |
|
254 | 95 |
"Modified: 9.5.1996 / 01:37:10 / cg" |
96 |
! |
|
97 |
||
98 |
graphicsDevice |
|
99 |
"return the graphicsContext" |
|
100 |
||
101 |
^ container graphicsDevice |
|
102 |
||
103 |
"Created: 9.5.1996 / 00:32:12 / cg" |
|
104 |
"Modified: 9.5.1996 / 01:37:03 / cg" |
|
105 |
! |
|
106 |
||
107 |
topComponent |
|
108 |
"return the top component - typically the topView" |
|
109 |
||
110 |
^ container topComponent |
|
111 |
||
112 |
"Modified: 9.5.1996 / 01:37:10 / cg" |
|
113 |
"Created: 9.5.1996 / 01:39:15 / cg" |
|
289
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
114 |
! |
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
115 |
|
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
116 |
view |
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
117 |
"return my view" |
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
118 |
|
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
119 |
container isNil ifTrue:[^ nil]. |
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
120 |
^ container view |
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
121 |
|
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
122 |
"Created: 4.6.1996 / 21:32:34 / cg" |
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
123 |
"Modified: 5.6.1996 / 01:20:13 / cg" |
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
124 |
! ! |
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
125 |
|
294 | 126 |
!VisualPart methodsFor:'view protocol mimicri'! |
289
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
127 |
|
2660 | 128 |
bottomInset |
129 |
^ 0 |
|
130 |
! |
|
131 |
||
132 |
computeExtent |
|
133 |
^ self extent |
|
134 |
! |
|
135 |
||
136 |
computeOrigin |
|
137 |
^ self origin |
|
138 |
! |
|
139 |
||
289
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
140 |
containerChangedSize |
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
141 |
"my container changed its size. |
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
142 |
The default here is to ignore this, but some wrappers like |
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
143 |
to resize when this happens." |
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
144 |
|
323 | 145 |
"/Transcript show:'container '; show:container; show:' of '; show:self; |
146 |
"/ show:' changed size to '; showCR:container viewRectangle. |
|
147 |
||
2660 | 148 |
self bounds:container viewRectangle. |
149 |
self invalidate. |
|
289
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
150 |
|
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
151 |
"Created: 4.6.1996 / 21:27:58 / cg" |
323 | 152 |
"Modified: 19.7.1996 / 21:20:58 / cg" |
962
e6ccfc7fb22e
added more dummy methods to allow visualComponents to be
Claus Gittinger <cg@exept.de>
parents:
365
diff
changeset
|
153 |
! |
289
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
154 |
|
2660 | 155 |
cornerRule |
156 |
^ nil |
|
157 |
! |
|
158 |
||
289
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
159 |
create |
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
160 |
"want myself to be created." |
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
161 |
|
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
162 |
container create |
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
163 |
|
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
164 |
"Created: 4.6.1996 / 21:30:25 / cg" |
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
165 |
! |
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
166 |
|
2660 | 167 |
destroy |
168 |
|c| |
|
169 |
||
170 |
(c := container) notNil ifTrue:[ |
|
171 |
container := nil. |
|
172 |
c invalidate:self bounds. |
|
173 |
c removeComponent:self. |
|
174 |
]. |
|
175 |
! |
|
176 |
||
177 |
device |
|
178 |
^ container device |
|
179 |
! |
|
180 |
||
181 |
extentRule |
|
182 |
^ nil |
|
183 |
! |
|
184 |
||
962
e6ccfc7fb22e
added more dummy methods to allow visualComponents to be
Claus Gittinger <cg@exept.de>
parents:
365
diff
changeset
|
185 |
invalidate |
e6ccfc7fb22e
added more dummy methods to allow visualComponents to be
Claus Gittinger <cg@exept.de>
parents:
365
diff
changeset
|
186 |
container notNil ifTrue:[ |
e6ccfc7fb22e
added more dummy methods to allow visualComponents to be
Claus Gittinger <cg@exept.de>
parents:
365
diff
changeset
|
187 |
container invalidate:self bounds |
e6ccfc7fb22e
added more dummy methods to allow visualComponents to be
Claus Gittinger <cg@exept.de>
parents:
365
diff
changeset
|
188 |
] |
e6ccfc7fb22e
added more dummy methods to allow visualComponents to be
Claus Gittinger <cg@exept.de>
parents:
365
diff
changeset
|
189 |
|
e6ccfc7fb22e
added more dummy methods to allow visualComponents to be
Claus Gittinger <cg@exept.de>
parents:
365
diff
changeset
|
190 |
"Modified: / 18.6.1998 / 16:12:15 / cg" |
e6ccfc7fb22e
added more dummy methods to allow visualComponents to be
Claus Gittinger <cg@exept.de>
parents:
365
diff
changeset
|
191 |
! |
e6ccfc7fb22e
added more dummy methods to allow visualComponents to be
Claus Gittinger <cg@exept.de>
parents:
365
diff
changeset
|
192 |
|
2660 | 193 |
isComponentOf:aViewOrComponent |
194 |
"return true, if I am a (direct or indirect) component of aViewOrComponent" |
|
195 |
||
196 |
|sview| |
|
197 |
||
198 |
sview := self. |
|
199 |
||
200 |
[ (sview := sview container) notNil ] whileTrue:[ |
|
201 |
sview == aViewOrComponent ifTrue:[^ true]. |
|
202 |
]. |
|
203 |
^ false |
|
204 |
! |
|
205 |
||
206 |
leftInset |
|
207 |
^ 0 |
|
208 |
! |
|
209 |
||
210 |
originRelativeTo:aContainer |
|
211 |
"return the origin (in pixels) relative to a superView, |
|
212 |
or relative to the rootView (if the aView argument is nil). |
|
213 |
If the receiver is nonNil and not a subview of aView, return nil." |
|
214 |
||
215 |
|currentPart |
|
216 |
bw "{ Class: SmallInteger }" |
|
217 |
sumX "{ Class: SmallInteger }" |
|
218 |
sumY "{ Class: SmallInteger }"| |
|
219 |
||
220 |
currentPart := self. |
|
221 |
sumX := 0. |
|
222 |
sumY := 0. |
|
223 |
[currentPart notNil] whileTrue:[ |
|
224 |
(currentPart == aContainer) ifTrue:[ |
|
225 |
^ (sumX @ sumY) |
|
226 |
]. |
|
227 |
bw := currentPart borderWidth. |
|
228 |
sumX := sumX + (currentPart left) + bw. |
|
229 |
sumY := sumY + (currentPart top) + bw. |
|
230 |
currentPart := currentPart superView |
|
231 |
]. |
|
232 |
||
233 |
(aContainer isNil or:[aContainer == self graphicsDevice rootView]) ifTrue:[ |
|
234 |
"return relative to screen ..." |
|
235 |
^ (sumX @ sumY) |
|
236 |
]. |
|
237 |
^ nil |
|
238 |
! |
|
239 |
||
240 |
originRule |
|
241 |
^ nil |
|
242 |
! |
|
243 |
||
289
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
244 |
realize |
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
245 |
"my container realized itself. |
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
246 |
The default here is to ignore this, but some wrappers like |
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
247 |
to do something when this happens." |
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
248 |
|
998 | 249 |
self realizeAllSubViews |
250 |
||
251 |
"Created: / 4.6.1996 / 21:28:31 / cg" |
|
252 |
"Modified: / 6.7.1998 / 18:38:28 / cg" |
|
253 |
! |
|
254 |
||
255 |
realizeAllSubViews |
|
256 |
"realize all my subviews - but not myself." |
|
257 |
||
289
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
258 |
^ self |
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
259 |
|
998 | 260 |
"Created: / 6.7.1998 / 18:37:08 / cg" |
962
e6ccfc7fb22e
added more dummy methods to allow visualComponents to be
Claus Gittinger <cg@exept.de>
parents:
365
diff
changeset
|
261 |
! |
289
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
262 |
|
2660 | 263 |
relativeCorner |
264 |
^ nil |
|
265 |
! |
|
266 |
||
267 |
relativeExtent |
|
268 |
^ nil |
|
269 |
! |
|
270 |
||
271 |
relativeOrigin |
|
272 |
^ nil |
|
273 |
! |
|
274 |
||
275 |
rightInset |
|
276 |
^ 0 |
|
277 |
! |
|
278 |
||
1220
39e5e28042da
protocol fixes to make examples work again
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
279 |
shown |
39e5e28042da
protocol fixes to make examples work again
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
280 |
container isNil ifTrue:[^ false]. |
39e5e28042da
protocol fixes to make examples work again
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
281 |
^ container shown |
39e5e28042da
protocol fixes to make examples work again
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
282 |
|
39e5e28042da
protocol fixes to make examples work again
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
283 |
|
39e5e28042da
protocol fixes to make examples work again
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
284 |
! |
39e5e28042da
protocol fixes to make examples work again
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
285 |
|
289
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
286 |
subViewChangedSize |
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
287 |
^ self |
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
288 |
|
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
289 |
"Created: 4.6.1996 / 21:35:57 / cg" |
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
290 |
! |
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
291 |
|
2660 | 292 |
topInset |
293 |
^ 0 |
|
294 |
! |
|
295 |
||
296 |
topView |
|
297 |
^ container topView |
|
298 |
! |
|
299 |
||
289
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
300 |
windowGroup |
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
301 |
^ container windowGroup |
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
302 |
|
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
303 |
"Created: 5.6.1996 / 00:49:19 / cg" |
1220
39e5e28042da
protocol fixes to make examples work again
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
304 |
! |
39e5e28042da
protocol fixes to make examples work again
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
305 |
|
39e5e28042da
protocol fixes to make examples work again
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
306 |
withAllSubViewsDo:aBlock |
39e5e28042da
protocol fixes to make examples work again
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
307 |
aBlock value:self |
249 | 308 |
! ! |
309 |
||
365 | 310 |
!VisualPart class methodsFor:'documentation'! |
249 | 311 |
|
312 |
version |
|
2660 | 313 |
^ '$Header: /cvs/stx/stx/libview2/VisualPart.st,v 1.13 2009-05-08 11:48:00 cg Exp $' |
249 | 314 |
! ! |