author | Claus Gittinger <cg@exept.de> |
Sat, 26 Oct 1996 19:17:33 +0200 | |
changeset 346 | 1612c23d9c5d |
parent 292 | 60fbf13dfc8c |
child 365 | 47e0d48fd769 |
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 |
|
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 |
||
292
60fbf13dfc8c
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
183 |
|delta| |
281 | 184 |
|
292
60fbf13dfc8c
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
185 |
delta := originPoint - origin. |
60fbf13dfc8c
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
186 |
origin := originPoint. |
60fbf13dfc8c
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
187 |
bounds := bounds origin + origin extent:bounds extent. |
60fbf13dfc8c
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
188 |
component bounds:(component bounds + delta). |
60fbf13dfc8c
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
189 |
|
281 | 190 |
"Created: 26.5.1996 / 16:07:47 / cg" |
292
60fbf13dfc8c
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
191 |
"Modified: 5.6.1996 / 02:37:27 / cg" |
281 | 192 |
! ! |
193 |
||
194 |
!TranslatingWrapper methodsFor:'accessing - bounds'! |
|
195 |
||
196 |
bounds:newBounds |
|
292
60fbf13dfc8c
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
197 |
bounds := newBounds. |
60fbf13dfc8c
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
198 |
origin = 0 ifTrue:[ |
60fbf13dfc8c
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
199 |
component bounds:newBounds |
60fbf13dfc8c
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
200 |
] ifFalse:[ |
60fbf13dfc8c
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
201 |
component bounds:(newBounds origin - origin extent:(newBounds extent)). |
60fbf13dfc8c
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
202 |
] |
281 | 203 |
|
204 |
"Created: 26.5.1996 / 16:44:16 / cg" |
|
292
60fbf13dfc8c
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
205 |
"Modified: 5.6.1996 / 00:51:10 / cg" |
281 | 206 |
! |
207 |
||
208 |
preferredBounds |
|
209 |
^ component preferredBounds + origin |
|
210 |
||
211 |
"Modified: 26.5.1996 / 16:44:26 / cg" |
|
212 |
"Created: 26.5.1996 / 16:44:53 / cg" |
|
213 |
! ! |
|
214 |
||
215 |
!TranslatingWrapper methodsFor:'displaying'! |
|
216 |
||
217 |
displayOn:aGC |
|
218 |
|oldTranslation oldPaint oldBgPaint| |
|
219 |
||
220 |
oldTranslation := aGC translation. |
|
221 |
oldPaint := aGC paint. |
|
222 |
oldBgPaint := aGC backgroundPaint. |
|
223 |
||
224 |
aGC translation:(origin + aGC translation). |
|
225 |
aGC paint:fgColor on:bgColor. |
|
226 |
||
227 |
component displayOn:aGC. |
|
228 |
||
229 |
aGC translation:oldTranslation. |
|
230 |
aGC paint:oldPaint on:oldBgPaint. |
|
231 |
||
232 |
"Created: 26.5.1996 / 15:27:54 / cg" |
|
233 |
"Modified: 26.5.1996 / 16:13:44 / cg" |
|
234 |
! ! |
|
235 |
||
292
60fbf13dfc8c
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
236 |
!TranslatingWrapper methodsFor:'initialization'! |
60fbf13dfc8c
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
237 |
|
60fbf13dfc8c
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
238 |
initialize |
60fbf13dfc8c
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
239 |
super initialize. |
60fbf13dfc8c
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
240 |
origin := 0@0 |
60fbf13dfc8c
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
241 |
|
60fbf13dfc8c
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
242 |
"Modified: 4.6.1996 / 21:43:44 / cg" |
60fbf13dfc8c
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
243 |
! ! |
60fbf13dfc8c
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
244 |
|
281 | 245 |
!TranslatingWrapper methodsFor:'testing'! |
246 |
||
247 |
containsPoint:aPoint |
|
248 |
^ component containsPoint:(aPoint - origin) |
|
249 |
||
250 |
"Created: 26.5.1996 / 16:48:14 / cg" |
|
251 |
! |
|
252 |
||
253 |
intersects:aRectangle |
|
254 |
^ component intersects:(aRectangle - origin) |
|
255 |
||
256 |
"Created: 26.5.1996 / 16:48:33 / cg" |
|
257 |
! ! |
|
258 |
||
259 |
!TranslatingWrapper class methodsFor:'documentation'! |
|
260 |
||
261 |
version |
|
292
60fbf13dfc8c
prepare for view-component integration
Claus Gittinger <cg@exept.de>
parents:
283
diff
changeset
|
262 |
^ '$Header: /cvs/stx/stx/libview2/TranslatingWrapper.st,v 1.3 1996-06-05 15:27:43 cg Exp $' |
281 | 263 |
! ! |