author | Claus Gittinger <cg@exept.de> |
Tue, 14 Jan 1997 18:02:37 +0100 | |
changeset 365 | 47e0d48fd769 |
parent 292 | 60fbf13dfc8c |
child 406 | 16d990bcde6e |
permissions | -rw-r--r-- |
281 | 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 |
Wrapper subclass:#TranslatingWrapper |
|
15 |
instanceVariableNames:'origin' |
|
16 |
classVariableNames:'' |
|
17 |
poolDictionaries:'' |
|
18 |
category:'Graphics-Display Objects' |
|
19 |
! |
|
20 |
||
21 |
!TranslatingWrapper class methodsFor:'documentation'! |
|
22 |
||
23 |
copyright |
|
24 |
" |
|
25 |
COPYRIGHT (c) 1996 by Claus Gittinger |
|
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 |
! |
|
37 |
||
38 |
documentation |
|
39 |
" |
|
40 |
a wrapper which shifts the origin of its wrapped component. |
|
283 | 41 |
This allows the wrapped thingy to think & draw in its own 0@0 based |
281 | 42 |
coordinates. |
43 |
||
44 |
Notice: |
|
45 |
this class was implemented using protocol information |
|
365 | 46 |
from alpha testers, from reading PD programs and |
47 |
from the Hopkins/Horan book. |
|
281 | 48 |
- it may not be complete or compatible to the corresponding ST-80 class. |
49 |
If you encounter any incompatibilities, please forward a note |
|
50 |
describing the incompatibility verbal (i.e. no code) to the ST/X team. |
|
51 |
||
52 |
[see also:] |
|
53 |
Wrapper |
|
54 |
||
55 |
[author:] |
|
56 |
Claus Gittinger |
|
57 |
" |
|
58 |
! |
|
59 |
||
60 |
examples |
|
61 |
" |
|
62 |
some components without translatingWrapper |
|
63 |
[exBegin] |
|
64 |
|t s v e component| |
|
65 |
||
66 |
t := StandardSystemView extent:250@200. |
|
67 |
s := HVScrollableView for:View miniScroller:true in:t. |
|
68 |
s origin:0.0@0.0 corner:1.0@1.0. |
|
69 |
v := s scrolledView. |
|
70 |
||
71 |
e := Rectangle origin:10@10 corner:90@90. |
|
72 |
component := FillingWrapper on:e. |
|
73 |
component foregroundColor:Color red. |
|
74 |
v addComponent:component. |
|
75 |
||
76 |
e := EllipticalArc boundingBox:(10@10 corner:90@90) |
|
77 |
startAngle:0 sweepAngle:360. |
|
78 |
component := StrokingWrapper on:e. |
|
79 |
component lineWidth:5. |
|
80 |
v addComponent:component. |
|
81 |
||
82 |
e := Arrow from:100@100 to:150@250. |
|
83 |
component := StrokingWrapper on:e. |
|
84 |
component lineWidth:2. |
|
85 |
v addComponent:component. |
|
86 |
||
87 |
t open |
|
88 |
[exEnd] |
|
89 |
the same components WITH translatingWrappers |
|
90 |
[exBegin] |
|
91 |
|t s v e component| |
|
92 |
||
93 |
t := StandardSystemView extent:250@200. |
|
94 |
s := HVScrollableView for:View miniScroller:true in:t. |
|
95 |
s origin:0.0@0.0 corner:1.0@1.0. |
|
96 |
v := s scrolledView. |
|
97 |
||
98 |
e := Rectangle origin:0@0 corner:80@80. |
|
99 |
component := FillingWrapper on:e. |
|
100 |
component foregroundColor:Color red. |
|
101 |
v addComponent:(TranslatingWrapper on:component at:10@10). |
|
102 |
||
103 |
e := EllipticalArc boundingBox:(0@0 corner:80@80) |
|
104 |
startAngle:0 sweepAngle:360. |
|
105 |
component := StrokingWrapper on:e. |
|
106 |
component lineWidth:5. |
|
107 |
v addComponent:(TranslatingWrapper on:component at:10@10). |
|
108 |
||
109 |
e := Arrow from:0@0 to:50@150. |
|
110 |
component := StrokingWrapper on:e. |
|
111 |
component lineWidth:2. |
|
112 |
v addComponent:(TranslatingWrapper on:component at:100@100). |
|
113 |
||
114 |
v addComponent:(TranslatingWrapper on:(Image fromFile:'SBrowser.xbm') at:0@100). |
|
115 |
||
116 |
t open |
|
117 |
[exEnd] |
|
283 | 118 |
overlapping |
281 | 119 |
[exBegin] |
120 |
|t s v e component| |
|
121 |
||
122 |
t := StandardSystemView extent:250@200. |
|
123 |
s := HVScrollableView for:View miniScroller:true in:t. |
|
124 |
s origin:0.0@0.0 corner:1.0@1.0. |
|
125 |
v := s scrolledView. |
|
126 |
||
283 | 127 |
e := Rectangle origin:0@0 corner:80@80. |
128 |
component := FillingWrapper on:e. |
|
129 |
component foregroundColor:Color red. |
|
130 |
v addComponent:(TranslatingWrapper on:component at:10@10). |
|
131 |
||
132 |
e := EllipticalArc boundingBox:(0@0 corner:80@80) |
|
133 |
startAngle:0 sweepAngle:360. |
|
134 |
component := StrokingWrapper on:e. |
|
135 |
component lineWidth:5. |
|
136 |
v addComponent:(TranslatingWrapper on:component at:50@50). |
|
137 |
||
138 |
e := Arrow from:0@0 to:50@150. |
|
139 |
component := StrokingWrapper on:e. |
|
140 |
component lineWidth:2. |
|
141 |
v addComponent:(TranslatingWrapper on:component at:100@100). |
|
142 |
||
143 |
e := Image fromFile:'SBrowser.xbm'. |
|
144 |
component := FillingWrapper on:e. |
|
145 |
component foregroundColor:Color red; backgroundColor:Color yellow. |
|
146 |
||
147 |
v addComponent:(TranslatingWrapper on:component at:50@150). |
|
148 |
||
149 |
component := StrokingWrapper on:e. |
|
150 |
component foregroundColor:Color blue. |
|
151 |
||
152 |
v addComponent:(TranslatingWrapper on:component at:50@100). |
|
281 | 153 |
|
154 |
t open |
|
155 |
[exEnd] |
|
156 |
" |
|
157 |
! ! |
|
158 |
||
159 |
!TranslatingWrapper class methodsFor:'instance creation'! |
|
160 |
||
161 |
on:aComponent at:originPoint |
|
162 |
"create and return a translatingWrapper, which positions |
|
163 |
aComponent at some originPoint" |
|
164 |
||
165 |
^ (self on:aComponent) translation:originPoint |
|
166 |
||
167 |
"Created: 26.5.1996 / 16:07:29 / cg" |
|
168 |
"Modified: 26.5.1996 / 16:12:28 / cg" |
|
169 |
! ! |
|
170 |
||
171 |
!TranslatingWrapper methodsFor:'accessing'! |
|
172 |
||
173 |
translation |
|
174 |
"return the origin offset" |
|
175 |
||
176 |
^ origin |
|
177 |
||
178 |
"Modified: 26.5.1996 / 16:06:32 / cg" |
|
179 |
! |
|
180 |
||
181 |
translation:originPoint |
|
182 |
"set the origin offset" |
|
183 |
||
292
60fbf13dfc8c
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
184 |
|delta| |
281 | 185 |
|
292
60fbf13dfc8c
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
186 |
delta := originPoint - origin. |
60fbf13dfc8c
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
187 |
origin := originPoint. |
60fbf13dfc8c
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
188 |
bounds := bounds origin + origin extent:bounds extent. |
60fbf13dfc8c
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
189 |
component bounds:(component bounds + delta). |
60fbf13dfc8c
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
190 |
|
281 | 191 |
"Created: 26.5.1996 / 16:07:47 / cg" |
292
60fbf13dfc8c
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
192 |
"Modified: 5.6.1996 / 02:37:27 / cg" |
281 | 193 |
! ! |
194 |
||
195 |
!TranslatingWrapper methodsFor:'accessing - bounds'! |
|
196 |
||
197 |
bounds:newBounds |
|
292
60fbf13dfc8c
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
198 |
bounds := newBounds. |
60fbf13dfc8c
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
199 |
origin = 0 ifTrue:[ |
60fbf13dfc8c
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
200 |
component bounds:newBounds |
60fbf13dfc8c
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
201 |
] ifFalse:[ |
60fbf13dfc8c
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
202 |
component bounds:(newBounds origin - origin extent:(newBounds extent)). |
60fbf13dfc8c
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
203 |
] |
281 | 204 |
|
205 |
"Created: 26.5.1996 / 16:44:16 / cg" |
|
292
60fbf13dfc8c
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
206 |
"Modified: 5.6.1996 / 00:51:10 / cg" |
281 | 207 |
! |
208 |
||
209 |
preferredBounds |
|
210 |
^ component preferredBounds + origin |
|
211 |
||
212 |
"Modified: 26.5.1996 / 16:44:26 / cg" |
|
213 |
"Created: 26.5.1996 / 16:44:53 / cg" |
|
214 |
! ! |
|
215 |
||
216 |
!TranslatingWrapper methodsFor:'displaying'! |
|
217 |
||
218 |
displayOn:aGC |
|
219 |
|oldTranslation oldPaint oldBgPaint| |
|
220 |
||
221 |
oldTranslation := aGC translation. |
|
222 |
oldPaint := aGC paint. |
|
223 |
oldBgPaint := aGC backgroundPaint. |
|
224 |
||
225 |
aGC translation:(origin + aGC translation). |
|
226 |
aGC paint:fgColor on:bgColor. |
|
227 |
||
228 |
component displayOn:aGC. |
|
229 |
||
230 |
aGC translation:oldTranslation. |
|
231 |
aGC paint:oldPaint on:oldBgPaint. |
|
232 |
||
233 |
"Created: 26.5.1996 / 15:27:54 / cg" |
|
234 |
"Modified: 26.5.1996 / 16:13:44 / cg" |
|
235 |
! ! |
|
236 |
||
292
60fbf13dfc8c
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
237 |
!TranslatingWrapper methodsFor:'initialization'! |
60fbf13dfc8c
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
238 |
|
60fbf13dfc8c
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
239 |
initialize |
60fbf13dfc8c
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
240 |
super initialize. |
60fbf13dfc8c
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
241 |
origin := 0@0 |
60fbf13dfc8c
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
242 |
|
60fbf13dfc8c
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
243 |
"Modified: 4.6.1996 / 21:43:44 / cg" |
60fbf13dfc8c
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
244 |
! ! |
60fbf13dfc8c
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
245 |
|
281 | 246 |
!TranslatingWrapper methodsFor:'testing'! |
247 |
||
248 |
containsPoint:aPoint |
|
249 |
^ component containsPoint:(aPoint - origin) |
|
250 |
||
251 |
"Created: 26.5.1996 / 16:48:14 / cg" |
|
252 |
! |
|
253 |
||
254 |
intersects:aRectangle |
|
255 |
^ component intersects:(aRectangle - origin) |
|
256 |
||
257 |
"Created: 26.5.1996 / 16:48:33 / cg" |
|
258 |
! ! |
|
259 |
||
260 |
!TranslatingWrapper class methodsFor:'documentation'! |
|
261 |
||
262 |
version |
|
365 | 263 |
^ '$Header: /cvs/stx/stx/libview2/Attic/TranslWrpr.st,v 1.4 1997-01-14 17:00:41 cg Exp $' |
281 | 264 |
! ! |