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