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