author | convert-repo |
Sat, 11 Feb 2017 04:41:47 +0000 | |
changeset 3880 | c4269847c0fe |
parent 2663 | baea7b430705 |
child 3855 | 1db7742d33ad |
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 |
" |
|
1789 | 12 |
"{ Package: 'stx:libview2' }" |
13 |
||
281 | 14 |
Wrapper subclass:#TranslatingWrapper |
15 |
instanceVariableNames:'origin' |
|
16 |
classVariableNames:'' |
|
17 |
poolDictionaries:'' |
|
1789 | 18 |
category:'Compatibility-ST80-Graphics-Display Objects' |
281 | 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. |
|
1220
39e5e28042da
protocol fixes to make examples work again
Claus Gittinger <cg@exept.de>
parents:
406
diff
changeset
|
80 |
component foregroundColor:Color black. |
281 | 81 |
v addComponent:component. |
82 |
||
83 |
e := Arrow from:100@100 to:150@250. |
|
84 |
component := StrokingWrapper on:e. |
|
85 |
component lineWidth:2. |
|
86 |
v addComponent:component. |
|
87 |
||
88 |
t open |
|
89 |
[exEnd] |
|
90 |
the same components WITH translatingWrappers |
|
91 |
[exBegin] |
|
92 |
|t s v e component| |
|
93 |
||
94 |
t := StandardSystemView extent:250@200. |
|
95 |
s := HVScrollableView for:View miniScroller:true in:t. |
|
96 |
s origin:0.0@0.0 corner:1.0@1.0. |
|
97 |
v := s scrolledView. |
|
98 |
||
99 |
e := Rectangle origin:0@0 corner:80@80. |
|
100 |
component := FillingWrapper on:e. |
|
101 |
component foregroundColor:Color red. |
|
102 |
v addComponent:(TranslatingWrapper on:component at:10@10). |
|
103 |
||
104 |
e := EllipticalArc boundingBox:(0@0 corner:80@80) |
|
105 |
startAngle:0 sweepAngle:360. |
|
106 |
component := StrokingWrapper on:e. |
|
107 |
component lineWidth:5. |
|
108 |
v addComponent:(TranslatingWrapper on:component at:10@10). |
|
109 |
||
110 |
e := Arrow from:0@0 to:50@150. |
|
111 |
component := StrokingWrapper on:e. |
|
112 |
component lineWidth:2. |
|
113 |
v addComponent:(TranslatingWrapper on:component at:100@100). |
|
114 |
||
115 |
v addComponent:(TranslatingWrapper on:(Image fromFile:'SBrowser.xbm') at:0@100). |
|
116 |
||
117 |
t open |
|
118 |
[exEnd] |
|
283 | 119 |
overlapping |
281 | 120 |
[exBegin] |
121 |
|t s v e component| |
|
122 |
||
123 |
t := StandardSystemView extent:250@200. |
|
124 |
s := HVScrollableView for:View miniScroller:true in:t. |
|
125 |
s origin:0.0@0.0 corner:1.0@1.0. |
|
126 |
v := s scrolledView. |
|
127 |
||
283 | 128 |
e := Rectangle origin:0@0 corner:80@80. |
129 |
component := FillingWrapper on:e. |
|
130 |
component foregroundColor:Color red. |
|
131 |
v addComponent:(TranslatingWrapper on:component at:10@10). |
|
132 |
||
133 |
e := EllipticalArc boundingBox:(0@0 corner:80@80) |
|
134 |
startAngle:0 sweepAngle:360. |
|
135 |
component := StrokingWrapper on:e. |
|
136 |
component lineWidth:5. |
|
137 |
v addComponent:(TranslatingWrapper on:component at:50@50). |
|
138 |
||
139 |
e := Arrow from:0@0 to:50@150. |
|
140 |
component := StrokingWrapper on:e. |
|
141 |
component lineWidth:2. |
|
142 |
v addComponent:(TranslatingWrapper on:component at:100@100). |
|
143 |
||
144 |
e := Image fromFile:'SBrowser.xbm'. |
|
145 |
component := FillingWrapper on:e. |
|
146 |
component foregroundColor:Color red; backgroundColor:Color yellow. |
|
147 |
||
148 |
v addComponent:(TranslatingWrapper on:component at:50@150). |
|
149 |
||
150 |
component := StrokingWrapper on:e. |
|
151 |
component foregroundColor:Color blue. |
|
152 |
||
153 |
v addComponent:(TranslatingWrapper on:component at:50@100). |
|
281 | 154 |
|
155 |
t open |
|
156 |
[exEnd] |
|
157 |
" |
|
158 |
! ! |
|
159 |
||
160 |
!TranslatingWrapper class methodsFor:'instance creation'! |
|
161 |
||
162 |
on:aComponent at:originPoint |
|
163 |
"create and return a translatingWrapper, which positions |
|
164 |
aComponent at some originPoint" |
|
165 |
||
166 |
^ (self on:aComponent) translation:originPoint |
|
167 |
||
168 |
"Created: 26.5.1996 / 16:07:29 / cg" |
|
169 |
"Modified: 26.5.1996 / 16:12:28 / cg" |
|
170 |
! ! |
|
171 |
||
172 |
!TranslatingWrapper methodsFor:'accessing'! |
|
173 |
||
174 |
translation |
|
175 |
"return the origin offset" |
|
176 |
||
177 |
^ origin |
|
178 |
||
179 |
"Modified: 26.5.1996 / 16:06:32 / cg" |
|
180 |
! |
|
181 |
||
182 |
translation:originPoint |
|
183 |
"set the origin offset" |
|
184 |
||
292
60fbf13dfc8c
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
185 |
|delta| |
281 | 186 |
|
292
60fbf13dfc8c
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
187 |
delta := originPoint - origin. |
60fbf13dfc8c
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
188 |
origin := originPoint. |
2663 | 189 |
frame := frame origin + origin extent:frame extent. |
292
60fbf13dfc8c
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
190 |
component bounds:(component bounds + delta). |
60fbf13dfc8c
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
191 |
|
281 | 192 |
"Created: 26.5.1996 / 16:07:47 / cg" |
292
60fbf13dfc8c
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
193 |
"Modified: 5.6.1996 / 02:37:27 / cg" |
281 | 194 |
! ! |
195 |
||
196 |
!TranslatingWrapper methodsFor:'accessing - bounds'! |
|
197 |
||
198 |
bounds:newBounds |
|
2663 | 199 |
frame := newBounds. |
292
60fbf13dfc8c
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
200 |
origin = 0 ifTrue:[ |
60fbf13dfc8c
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
201 |
component bounds:newBounds |
60fbf13dfc8c
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
202 |
] ifFalse:[ |
60fbf13dfc8c
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
203 |
component bounds:(newBounds origin - origin extent:(newBounds extent)). |
60fbf13dfc8c
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
204 |
] |
281 | 205 |
|
206 |
"Created: 26.5.1996 / 16:44:16 / cg" |
|
292
60fbf13dfc8c
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
207 |
"Modified: 5.6.1996 / 00:51:10 / cg" |
281 | 208 |
! |
209 |
||
210 |
preferredBounds |
|
211 |
^ component preferredBounds + origin |
|
212 |
||
213 |
"Modified: 26.5.1996 / 16:44:26 / cg" |
|
214 |
"Created: 26.5.1996 / 16:44:53 / cg" |
|
215 |
! ! |
|
216 |
||
217 |
!TranslatingWrapper methodsFor:'displaying'! |
|
218 |
||
219 |
displayOn:aGC |
|
406 | 220 |
|oldTranslation| |
281 | 221 |
|
222 |
oldTranslation := aGC translation. |
|
406 | 223 |
aGC translateBy:origin. |
281 | 224 |
component displayOn:aGC. |
225 |
aGC translation:oldTranslation. |
|
226 |
||
227 |
"Created: 26.5.1996 / 15:27:54 / cg" |
|
406 | 228 |
"Modified: 10.2.1997 / 19:29:21 / cg" |
281 | 229 |
! ! |
230 |
||
292
60fbf13dfc8c
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
231 |
!TranslatingWrapper methodsFor:'initialization'! |
60fbf13dfc8c
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
232 |
|
60fbf13dfc8c
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
233 |
initialize |
60fbf13dfc8c
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
234 |
super initialize. |
60fbf13dfc8c
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
235 |
origin := 0@0 |
60fbf13dfc8c
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
236 |
|
60fbf13dfc8c
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
237 |
"Modified: 4.6.1996 / 21:43:44 / cg" |
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 |
|
281 | 240 |
!TranslatingWrapper methodsFor:'testing'! |
241 |
||
242 |
containsPoint:aPoint |
|
243 |
^ component containsPoint:(aPoint - origin) |
|
244 |
||
245 |
"Created: 26.5.1996 / 16:48:14 / cg" |
|
246 |
! |
|
247 |
||
248 |
intersects:aRectangle |
|
249 |
^ component intersects:(aRectangle - origin) |
|
250 |
||
251 |
"Created: 26.5.1996 / 16:48:33 / cg" |
|
252 |
! ! |
|
253 |
||
254 |
!TranslatingWrapper class methodsFor:'documentation'! |
|
255 |
||
256 |
version |
|
2663 | 257 |
^ '$Header: /cvs/stx/stx/libview2/TranslatingWrapper.st,v 1.8 2009-05-08 11:55:06 cg Exp $' |
281 | 258 |
! ! |