author | Claus Gittinger <cg@exept.de> |
Wed, 29 May 1996 00:43:47 +0200 | |
changeset 279 | bf069aab8a8c |
parent 273 | f76fb9098814 |
child 280 | 39e270e5aa30 |
permissions | -rw-r--r-- |
245 | 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 |
||
279 | 14 |
Wrapper subclass:#TranslatingWrapper |
15 |
instanceVariableNames:'origin' |
|
245 | 16 |
classVariableNames:'' |
17 |
poolDictionaries:'' |
|
18 |
category:'Graphics-Display Objects' |
|
19 |
! |
|
20 |
||
279 | 21 |
!TranslatingWrapper class methodsFor:'documentation'! |
245 | 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 |
" |
|
279 | 40 |
a wrapper which shifts the origin of its wrapped component. |
41 |
This allows the wrapped thingy to think & draw in its own 0/0 based |
|
42 |
coordinates. |
|
254 | 43 |
|
265 | 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 |
||
248 | 51 |
[see also:] |
279 | 52 |
Wrapper |
248 | 53 |
|
245 | 54 |
[author:] |
55 |
Claus Gittinger |
|
56 |
" |
|
57 |
! |
|
58 |
||
59 |
examples |
|
60 |
" |
|
279 | 61 |
some components without translatingWrapper |
273 | 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 |
||
279 | 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] |
|
117 |
[exBegin] |
|
118 |
|t s v e component| |
|
119 |
||
120 |
t := StandardSystemView extent:250@200. |
|
121 |
s := HVScrollableView for:View miniScroller:true in:t. |
|
122 |
s origin:0.0@0.0 corner:1.0@1.0. |
|
123 |
v := s scrolledView. |
|
124 |
||
125 |
e := LabelAndIcon icon:(Image fromFile:'bitmaps/SBrowser.xbm') |
|
126 |
string:'hello'. |
|
127 |
v addComponent:(TranslatingWrapper on:e at:10@10). |
|
273 | 128 |
|
129 |
t open |
|
130 |
[exEnd] |
|
131 |
||
245 | 132 |
" |
133 |
! ! |
|
134 |
||
279 | 135 |
!TranslatingWrapper class methodsFor:'instance creation'! |
245 | 136 |
|
279 | 137 |
on:aComponent at:originPoint |
138 |
"create and return a translatingWrapper, which positions |
|
139 |
aComponent at some originPoint" |
|
245 | 140 |
|
279 | 141 |
^ (self on:aComponent) translation:originPoint |
262
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
142 |
|
279 | 143 |
"Created: 26.5.1996 / 16:07:29 / cg" |
144 |
"Modified: 26.5.1996 / 16:12:28 / cg" |
|
145 |
! ! |
|
262
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
146 |
|
279 | 147 |
!TranslatingWrapper methodsFor:'accessing'! |
262
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
148 |
|
279 | 149 |
translation |
150 |
"return the origin offset" |
|
262
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
151 |
|
279 | 152 |
^ origin |
262
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
153 |
|
279 | 154 |
"Modified: 26.5.1996 / 16:06:32 / cg" |
262
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
155 |
! |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
156 |
|
279 | 157 |
translation:originPoint |
158 |
"set the origin offset" |
|
262
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
159 |
|
279 | 160 |
origin := originPoint |
262
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
161 |
|
279 | 162 |
"Modified: 26.5.1996 / 16:06:32 / cg" |
163 |
"Created: 26.5.1996 / 16:07:47 / cg" |
|
164 |
! ! |
|
165 |
||
166 |
!TranslatingWrapper methodsFor:'accessing - bounds'! |
|
262
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
167 |
|
279 | 168 |
bounds |
169 |
^ component bounds + origin |
|
262
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
170 |
|
279 | 171 |
"Created: 26.5.1996 / 16:13:05 / cg" |
172 |
"Modified: 26.5.1996 / 16:44:26 / cg" |
|
262
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
173 |
! |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
174 |
|
279 | 175 |
bounds:newBounds |
176 |
component bounds:(newBounds - origin). |
|
246 | 177 |
|
279 | 178 |
"Created: 26.5.1996 / 16:44:16 / cg" |
245 | 179 |
! |
180 |
||
181 |
preferredBounds |
|
279 | 182 |
^ component preferredBounds + origin |
246 | 183 |
|
279 | 184 |
"Modified: 26.5.1996 / 16:44:26 / cg" |
185 |
"Created: 26.5.1996 / 16:44:53 / cg" |
|
245 | 186 |
! ! |
187 |
||
279 | 188 |
!TranslatingWrapper methodsFor:'displaying'! |
245 | 189 |
|
190 |
displayOn:aGC |
|
279 | 191 |
|oldTranslation oldPaint oldBgPaint| |
245 | 192 |
|
279 | 193 |
oldTranslation := aGC translation. |
194 |
oldPaint := aGC paint. |
|
195 |
oldBgPaint := aGC backgroundPaint. |
|
245 | 196 |
|
279 | 197 |
aGC translation:(origin + aGC translation). |
263 | 198 |
aGC paint:fgColor on:bgColor. |
245 | 199 |
|
279 | 200 |
component displayOn:aGC. |
245 | 201 |
|
279 | 202 |
aGC translation:oldTranslation. |
203 |
aGC paint:oldPaint on:oldBgPaint. |
|
245 | 204 |
|
279 | 205 |
"Created: 26.5.1996 / 15:27:54 / cg" |
206 |
"Modified: 26.5.1996 / 16:13:44 / cg" |
|
245 | 207 |
! ! |
208 |
||
279 | 209 |
!TranslatingWrapper methodsFor:'testing'! |
245 | 210 |
|
279 | 211 |
containsPoint:aPoint |
212 |
^ component containsPoint:(aPoint - origin) |
|
246 | 213 |
|
279 | 214 |
"Created: 26.5.1996 / 16:48:14 / cg" |
215 |
! |
|
245 | 216 |
|
279 | 217 |
intersects:aRectangle |
218 |
^ component intersects:(aRectangle - origin) |
|
219 |
||
220 |
"Created: 26.5.1996 / 16:48:33 / cg" |
|
245 | 221 |
! ! |
222 |
||
279 | 223 |
!TranslatingWrapper class methodsFor:'documentation'! |
245 | 224 |
|
225 |
version |
|
279 | 226 |
^ '$Header: /cvs/stx/stx/libview2/StrokingWrapper.st,v 1.10 1996-05-28 22:43:43 cg Exp $' |
245 | 227 |
! ! |