author | Claus Gittinger <cg@exept.de> |
Mon, 11 May 2009 08:35:25 +0200 | |
changeset 2672 | 5d7fd9552774 |
parent 2671 | 3e8b7f22722e |
child 2673 | fb475750ed7a |
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 |
2666 | 15 |
instanceVariableNames:'container layout name' |
249 | 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 |
||
2666 | 107 |
name |
108 |
^ name |
|
109 |
! |
|
110 |
||
111 |
name:something |
|
112 |
name := something. |
|
113 |
! |
|
114 |
||
254 | 115 |
topComponent |
116 |
"return the top component - typically the topView" |
|
117 |
||
118 |
^ container topComponent |
|
119 |
||
120 |
"Modified: 9.5.1996 / 01:37:10 / cg" |
|
121 |
"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
|
122 |
! |
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
123 |
|
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
124 |
view |
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
125 |
"return my view" |
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
126 |
|
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
127 |
container isNil ifTrue:[^ nil]. |
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
128 |
^ container view |
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
129 |
|
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
130 |
"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
|
131 |
"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
|
132 |
! ! |
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
133 |
|
2666 | 134 |
!VisualPart methodsFor:'accessing-dimensions'! |
135 |
||
136 |
bounds:newBounds |
|
2671 | 137 |
self assert:(newBounds left isInteger). |
138 |
self assert:(newBounds width isInteger). |
|
139 |
self assert:(newBounds top isInteger). |
|
140 |
self assert:(newBounds height isInteger). |
|
141 |
||
2666 | 142 |
frame := newBounds. |
2671 | 143 |
|
2666 | 144 |
! ! |
145 |
||
294 | 146 |
!VisualPart methodsFor:'view protocol mimicri'! |
289
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
147 |
|
2660 | 148 |
bottomInset |
149 |
^ 0 |
|
150 |
! |
|
151 |
||
2671 | 152 |
computeBoundingBox |
153 |
layout notNil ifTrue:[ |
|
154 |
container notNil ifTrue:[ |
|
155 |
self bounds:(layout |
|
156 |
rectangleRelativeTo:(0@0 extent:container extent "container bounds") |
|
157 |
preferred:self preferredBounds). |
|
158 |
] |
|
159 |
] ifFalse:[ |
|
160 |
self error. |
|
161 |
]. |
|
162 |
||
163 |
^ frame |
|
164 |
! |
|
165 |
||
2666 | 166 |
computeCorner |
167 |
^ self corner |
|
168 |
! |
|
169 |
||
2660 | 170 |
computeExtent |
171 |
^ self extent |
|
172 |
! |
|
173 |
||
174 |
computeOrigin |
|
175 |
^ self origin |
|
176 |
! |
|
177 |
||
289
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
178 |
containerChangedSize |
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
179 |
"my container changed its size. |
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
180 |
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
|
181 |
to resize when this happens." |
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
182 |
|
323 | 183 |
"/Transcript show:'container '; show:container; show:' of '; show:self; |
184 |
"/ show:' changed size to '; showCR:container viewRectangle. |
|
185 |
||
2668 | 186 |
layout notNil ifTrue:[ |
187 |
self bounds:(layout |
|
2670 | 188 |
rectangleRelativeTo:(0@0 extent:container extent "container bounds") |
2666 | 189 |
preferred:self preferredBounds). |
2665 | 190 |
]. |
2666 | 191 |
"/ self invalidate. |
289
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
192 |
|
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
193 |
"Created: 4.6.1996 / 21:27:58 / cg" |
323 | 194 |
"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
|
195 |
! |
289
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
196 |
|
2660 | 197 |
cornerRule |
198 |
^ nil |
|
199 |
! |
|
200 |
||
289
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
201 |
create |
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
202 |
"want myself to be created." |
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
203 |
|
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
204 |
container create |
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
205 |
|
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
206 |
"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
|
207 |
! |
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
208 |
|
2660 | 209 |
destroy |
210 |
|c| |
|
211 |
||
212 |
(c := container) notNil ifTrue:[ |
|
213 |
container := nil. |
|
2671 | 214 |
frame notNil ifTrue:[ c invalidate:frame ]. |
2660 | 215 |
c removeComponent:self. |
216 |
]. |
|
217 |
! |
|
218 |
||
219 |
device |
|
220 |
^ container device |
|
221 |
! |
|
222 |
||
223 |
extentRule |
|
224 |
^ nil |
|
225 |
! |
|
226 |
||
2666 | 227 |
geometryLayout |
228 |
^ layout |
|
229 |
! |
|
230 |
||
231 |
geometryLayout:newLayoutOrNil |
|
2671 | 232 |
container notNil ifTrue:[ |
233 |
frame notNil ifTrue:[ |
|
234 |
container invalidate:(frame insetBy:-2). |
|
235 |
] |
|
236 |
]. |
|
237 |
||
2670 | 238 |
frame := nil. |
2666 | 239 |
layout := newLayoutOrNil. |
2671 | 240 |
|
241 |
container notNil ifTrue:[ |
|
242 |
self computeBoundingBox. |
|
243 |
frame notNil ifTrue:[ |
|
244 |
container invalidate:(frame insetBy:-2). |
|
245 |
] |
|
246 |
]. |
|
2666 | 247 |
! |
248 |
||
962
e6ccfc7fb22e
added more dummy methods to allow visualComponents to be
Claus Gittinger <cg@exept.de>
parents:
365
diff
changeset
|
249 |
invalidate |
e6ccfc7fb22e
added more dummy methods to allow visualComponents to be
Claus Gittinger <cg@exept.de>
parents:
365
diff
changeset
|
250 |
container notNil ifTrue:[ |
2672 | 251 |
(layout notNil or:[frame notNil]) ifTrue:[ |
252 |
container invalidate:self bounds |
|
253 |
] |
|
962
e6ccfc7fb22e
added more dummy methods to allow visualComponents to be
Claus Gittinger <cg@exept.de>
parents:
365
diff
changeset
|
254 |
] |
e6ccfc7fb22e
added more dummy methods to allow visualComponents to be
Claus Gittinger <cg@exept.de>
parents:
365
diff
changeset
|
255 |
|
e6ccfc7fb22e
added more dummy methods to allow visualComponents to be
Claus Gittinger <cg@exept.de>
parents:
365
diff
changeset
|
256 |
"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
|
257 |
! |
e6ccfc7fb22e
added more dummy methods to allow visualComponents to be
Claus Gittinger <cg@exept.de>
parents:
365
diff
changeset
|
258 |
|
2660 | 259 |
isComponentOf:aViewOrComponent |
260 |
"return true, if I am a (direct or indirect) component of aViewOrComponent" |
|
261 |
||
262 |
|sview| |
|
263 |
||
264 |
sview := self. |
|
265 |
||
266 |
[ (sview := sview container) notNil ] whileTrue:[ |
|
267 |
sview == aViewOrComponent ifTrue:[^ true]. |
|
268 |
]. |
|
269 |
^ false |
|
270 |
! |
|
271 |
||
272 |
leftInset |
|
273 |
^ 0 |
|
274 |
! |
|
275 |
||
276 |
originRelativeTo:aContainer |
|
277 |
"return the origin (in pixels) relative to a superView, |
|
278 |
or relative to the rootView (if the aView argument is nil). |
|
279 |
If the receiver is nonNil and not a subview of aView, return nil." |
|
280 |
||
281 |
|currentPart |
|
282 |
bw "{ Class: SmallInteger }" |
|
283 |
sumX "{ Class: SmallInteger }" |
|
284 |
sumY "{ Class: SmallInteger }"| |
|
285 |
||
286 |
currentPart := self. |
|
287 |
sumX := 0. |
|
288 |
sumY := 0. |
|
289 |
[currentPart notNil] whileTrue:[ |
|
290 |
(currentPart == aContainer) ifTrue:[ |
|
291 |
^ (sumX @ sumY) |
|
292 |
]. |
|
293 |
bw := currentPart borderWidth. |
|
294 |
sumX := sumX + (currentPart left) + bw. |
|
295 |
sumY := sumY + (currentPart top) + bw. |
|
296 |
currentPart := currentPart superView |
|
297 |
]. |
|
298 |
||
299 |
(aContainer isNil or:[aContainer == self graphicsDevice rootView]) ifTrue:[ |
|
300 |
"return relative to screen ..." |
|
301 |
^ (sumX @ sumY) |
|
302 |
]. |
|
303 |
^ nil |
|
304 |
! |
|
305 |
||
306 |
originRule |
|
307 |
^ nil |
|
308 |
! |
|
309 |
||
289
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
310 |
realize |
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
311 |
"my container realized itself. |
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
312 |
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
|
313 |
to do something when this happens." |
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
314 |
|
998 | 315 |
self realizeAllSubViews |
316 |
||
317 |
"Created: / 4.6.1996 / 21:28:31 / cg" |
|
318 |
"Modified: / 6.7.1998 / 18:38:28 / cg" |
|
319 |
! |
|
320 |
||
321 |
realizeAllSubViews |
|
322 |
"realize all my subviews - but not myself." |
|
323 |
||
289
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
324 |
^ self |
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
325 |
|
998 | 326 |
"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
|
327 |
! |
289
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
328 |
|
2660 | 329 |
relativeCorner |
330 |
^ nil |
|
331 |
! |
|
332 |
||
333 |
relativeExtent |
|
334 |
^ nil |
|
335 |
! |
|
336 |
||
337 |
relativeOrigin |
|
338 |
^ nil |
|
339 |
! |
|
340 |
||
341 |
rightInset |
|
342 |
^ 0 |
|
343 |
! |
|
344 |
||
1220
39e5e28042da
protocol fixes to make examples work again
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
345 |
shown |
39e5e28042da
protocol fixes to make examples work again
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
346 |
container isNil ifTrue:[^ false]. |
39e5e28042da
protocol fixes to make examples work again
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
347 |
^ container shown |
39e5e28042da
protocol fixes to make examples work again
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
348 |
|
39e5e28042da
protocol fixes to make examples work again
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
349 |
|
39e5e28042da
protocol fixes to make examples work again
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
350 |
! |
39e5e28042da
protocol fixes to make examples work again
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
351 |
|
289
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
352 |
subViewChangedSize |
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
353 |
^ self |
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
354 |
|
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
355 |
"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
|
356 |
! |
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
357 |
|
2668 | 358 |
subViews |
359 |
^ #() |
|
360 |
! |
|
361 |
||
2660 | 362 |
topInset |
363 |
^ 0 |
|
364 |
! |
|
365 |
||
366 |
topView |
|
367 |
^ container topView |
|
368 |
! |
|
369 |
||
289
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
370 |
windowGroup |
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
371 |
^ container windowGroup |
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
372 |
|
5620dcc0c5f6
prepare for components & non-view as superView
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
373 |
"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
|
374 |
! |
39e5e28042da
protocol fixes to make examples work again
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
375 |
|
39e5e28042da
protocol fixes to make examples work again
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
376 |
withAllSubViewsDo:aBlock |
39e5e28042da
protocol fixes to make examples work again
Claus Gittinger <cg@exept.de>
parents:
998
diff
changeset
|
377 |
aBlock value:self |
249 | 378 |
! ! |
379 |
||
365 | 380 |
!VisualPart class methodsFor:'documentation'! |
249 | 381 |
|
382 |
version |
|
2672 | 383 |
^ '$Header: /cvs/stx/stx/libview2/VisualPart.st,v 1.19 2009-05-11 06:35:25 cg Exp $' |
249 | 384 |
! ! |