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
|
|
46 |
from alpha testers and from the Hopkins/Horan book.
|
|
47 |
- it may not be complete or compatible to the corresponding ST-80 class.
|
|
48 |
If you encounter any incompatibilities, please forward a note
|
|
49 |
describing the incompatibility verbal (i.e. no code) to the ST/X team.
|
|
50 |
|
|
51 |
[see also:]
|
|
52 |
Wrapper
|
|
53 |
|
|
54 |
[author:]
|
|
55 |
Claus Gittinger
|
|
56 |
"
|
|
57 |
!
|
|
58 |
|
|
59 |
examples
|
|
60 |
"
|
|
61 |
some components without translatingWrapper
|
|
62 |
[exBegin]
|
|
63 |
|t s v e component|
|
|
64 |
|
|
65 |
t := StandardSystemView extent:250@200.
|
|
66 |
s := HVScrollableView for:View miniScroller:true in:t.
|
|
67 |
s origin:0.0@0.0 corner:1.0@1.0.
|
|
68 |
v := s scrolledView.
|
|
69 |
|
|
70 |
e := Rectangle origin:10@10 corner:90@90.
|
|
71 |
component := FillingWrapper on:e.
|
|
72 |
component foregroundColor:Color red.
|
|
73 |
v addComponent:component.
|
|
74 |
|
|
75 |
e := EllipticalArc boundingBox:(10@10 corner:90@90)
|
|
76 |
startAngle:0 sweepAngle:360.
|
|
77 |
component := StrokingWrapper on:e.
|
|
78 |
component lineWidth:5.
|
|
79 |
v addComponent:component.
|
|
80 |
|
|
81 |
e := Arrow from:100@100 to:150@250.
|
|
82 |
component := StrokingWrapper on:e.
|
|
83 |
component lineWidth:2.
|
|
84 |
v addComponent:component.
|
|
85 |
|
|
86 |
t open
|
|
87 |
[exEnd]
|
|
88 |
the same components WITH translatingWrappers
|
|
89 |
[exBegin]
|
|
90 |
|t s v e component|
|
|
91 |
|
|
92 |
t := StandardSystemView extent:250@200.
|
|
93 |
s := HVScrollableView for:View miniScroller:true in:t.
|
|
94 |
s origin:0.0@0.0 corner:1.0@1.0.
|
|
95 |
v := s scrolledView.
|
|
96 |
|
|
97 |
e := Rectangle origin:0@0 corner:80@80.
|
|
98 |
component := FillingWrapper on:e.
|
|
99 |
component foregroundColor:Color red.
|
|
100 |
v addComponent:(TranslatingWrapper on:component at:10@10).
|
|
101 |
|
|
102 |
e := EllipticalArc boundingBox:(0@0 corner:80@80)
|
|
103 |
startAngle:0 sweepAngle:360.
|
|
104 |
component := StrokingWrapper on:e.
|
|
105 |
component lineWidth:5.
|
|
106 |
v addComponent:(TranslatingWrapper on:component at:10@10).
|
|
107 |
|
|
108 |
e := Arrow from:0@0 to:50@150.
|
|
109 |
component := StrokingWrapper on:e.
|
|
110 |
component lineWidth:2.
|
|
111 |
v addComponent:(TranslatingWrapper on:component at:100@100).
|
|
112 |
|
|
113 |
v addComponent:(TranslatingWrapper on:(Image fromFile:'SBrowser.xbm') at:0@100).
|
|
114 |
|
|
115 |
t open
|
|
116 |
[exEnd]
|
283
|
117 |
overlapping
|
281
|
118 |
[exBegin]
|
|
119 |
|t s v e component|
|
|
120 |
|
|
121 |
t := StandardSystemView extent:250@200.
|
|
122 |
s := HVScrollableView for:View miniScroller:true in:t.
|
|
123 |
s origin:0.0@0.0 corner:1.0@1.0.
|
|
124 |
v := s scrolledView.
|
|
125 |
|
283
|
126 |
e := Rectangle origin:0@0 corner:80@80.
|
|
127 |
component := FillingWrapper on:e.
|
|
128 |
component foregroundColor:Color red.
|
|
129 |
v addComponent:(TranslatingWrapper on:component at:10@10).
|
|
130 |
|
|
131 |
e := EllipticalArc boundingBox:(0@0 corner:80@80)
|
|
132 |
startAngle:0 sweepAngle:360.
|
|
133 |
component := StrokingWrapper on:e.
|
|
134 |
component lineWidth:5.
|
|
135 |
v addComponent:(TranslatingWrapper on:component at:50@50).
|
|
136 |
|
|
137 |
e := Arrow from:0@0 to:50@150.
|
|
138 |
component := StrokingWrapper on:e.
|
|
139 |
component lineWidth:2.
|
|
140 |
v addComponent:(TranslatingWrapper on:component at:100@100).
|
|
141 |
|
|
142 |
e := Image fromFile:'SBrowser.xbm'.
|
|
143 |
component := FillingWrapper on:e.
|
|
144 |
component foregroundColor:Color red; backgroundColor:Color yellow.
|
|
145 |
|
|
146 |
v addComponent:(TranslatingWrapper on:component at:50@150).
|
|
147 |
|
|
148 |
component := StrokingWrapper on:e.
|
|
149 |
component foregroundColor:Color blue.
|
|
150 |
|
|
151 |
v addComponent:(TranslatingWrapper on:component at:50@100).
|
281
|
152 |
|
|
153 |
t open
|
|
154 |
[exEnd]
|
|
155 |
"
|
|
156 |
! !
|
|
157 |
|
|
158 |
!TranslatingWrapper class methodsFor:'instance creation'!
|
|
159 |
|
|
160 |
on:aComponent at:originPoint
|
|
161 |
"create and return a translatingWrapper, which positions
|
|
162 |
aComponent at some originPoint"
|
|
163 |
|
|
164 |
^ (self on:aComponent) translation:originPoint
|
|
165 |
|
|
166 |
"Created: 26.5.1996 / 16:07:29 / cg"
|
|
167 |
"Modified: 26.5.1996 / 16:12:28 / cg"
|
|
168 |
! !
|
|
169 |
|
|
170 |
!TranslatingWrapper methodsFor:'accessing'!
|
|
171 |
|
|
172 |
translation
|
|
173 |
"return the origin offset"
|
|
174 |
|
|
175 |
^ origin
|
|
176 |
|
|
177 |
"Modified: 26.5.1996 / 16:06:32 / cg"
|
|
178 |
!
|
|
179 |
|
|
180 |
translation:originPoint
|
|
181 |
"set the origin offset"
|
|
182 |
|
|
183 |
origin := originPoint
|
|
184 |
|
|
185 |
"Modified: 26.5.1996 / 16:06:32 / cg"
|
|
186 |
"Created: 26.5.1996 / 16:07:47 / cg"
|
|
187 |
! !
|
|
188 |
|
|
189 |
!TranslatingWrapper methodsFor:'accessing - bounds'!
|
|
190 |
|
|
191 |
bounds
|
|
192 |
^ component bounds + origin
|
|
193 |
|
|
194 |
"Created: 26.5.1996 / 16:13:05 / cg"
|
|
195 |
"Modified: 26.5.1996 / 16:44:26 / cg"
|
|
196 |
!
|
|
197 |
|
|
198 |
bounds:newBounds
|
|
199 |
component bounds:(newBounds - origin).
|
|
200 |
|
|
201 |
"Created: 26.5.1996 / 16:44:16 / cg"
|
|
202 |
!
|
|
203 |
|
|
204 |
preferredBounds
|
|
205 |
^ component preferredBounds + origin
|
|
206 |
|
|
207 |
"Modified: 26.5.1996 / 16:44:26 / cg"
|
|
208 |
"Created: 26.5.1996 / 16:44:53 / cg"
|
|
209 |
! !
|
|
210 |
|
|
211 |
!TranslatingWrapper methodsFor:'displaying'!
|
|
212 |
|
|
213 |
displayOn:aGC
|
|
214 |
|oldTranslation oldPaint oldBgPaint|
|
|
215 |
|
|
216 |
oldTranslation := aGC translation.
|
|
217 |
oldPaint := aGC paint.
|
|
218 |
oldBgPaint := aGC backgroundPaint.
|
|
219 |
|
|
220 |
aGC translation:(origin + aGC translation).
|
|
221 |
aGC paint:fgColor on:bgColor.
|
|
222 |
|
|
223 |
component displayOn:aGC.
|
|
224 |
|
|
225 |
aGC translation:oldTranslation.
|
|
226 |
aGC paint:oldPaint on:oldBgPaint.
|
|
227 |
|
|
228 |
"Created: 26.5.1996 / 15:27:54 / cg"
|
|
229 |
"Modified: 26.5.1996 / 16:13:44 / cg"
|
|
230 |
! !
|
|
231 |
|
|
232 |
!TranslatingWrapper methodsFor:'testing'!
|
|
233 |
|
|
234 |
containsPoint:aPoint
|
|
235 |
^ component containsPoint:(aPoint - origin)
|
|
236 |
|
|
237 |
"Created: 26.5.1996 / 16:48:14 / cg"
|
|
238 |
!
|
|
239 |
|
|
240 |
intersects:aRectangle
|
|
241 |
^ component intersects:(aRectangle - origin)
|
|
242 |
|
|
243 |
"Created: 26.5.1996 / 16:48:33 / cg"
|
|
244 |
! !
|
|
245 |
|
|
246 |
!TranslatingWrapper class methodsFor:'documentation'!
|
|
247 |
|
|
248 |
version
|
283
|
249 |
^ '$Header: /cvs/stx/stx/libview2/TranslatingWrapper.st,v 1.2 1996-05-29 09:37:24 cg Exp $'
|
281
|
250 |
! !
|