author | Stefan Vogel <sv@exept.de> |
Fri, 03 Aug 2012 17:53:57 +0200 | |
changeset 3018 | e7f336370c9f |
parent 2839 | 8fd092da727e |
child 3329 | d885d47a0693 |
permissions | -rw-r--r-- |
88 | 1 |
" |
2 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
93 | 3 |
All Rights Reserved |
88 | 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 |
" |
|
1594 | 12 |
"{ Package: 'stx:libview2' }" |
13 |
||
77 | 14 |
LayoutOrigin subclass:#LayoutFrame |
191 | 15 |
instanceVariableNames:'rightFraction bottomFraction rightOffset bottomOffset' |
16 |
classVariableNames:'' |
|
17 |
poolDictionaries:'' |
|
18 |
category:'Graphics-Geometry' |
|
77 | 19 |
! |
20 |
||
88 | 21 |
!LayoutFrame class methodsFor:'documentation'! |
22 |
||
23 |
copyright |
|
24 |
" |
|
25 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
93 | 26 |
All Rights Reserved |
88 | 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 |
||
93 | 37 |
documentation |
38 |
" |
|
2763 | 39 |
This class is provided to make porting of existing ST-80/Squeak applications |
93 | 40 |
easier. Instances can be used to control the geometry of a subview, within |
41 |
its superview. Like a layoutOrigin, it controls the origin of a component |
|
42 |
by given fraction and offset dimensions; in addition, the bottom-right |
|
43 |
corner is also controlled by corresponding values. Therefore, the components |
|
44 |
preferredExtent is ignored. |
|
45 |
||
46 |
See also: |
|
219 | 47 |
LayoutOrigin AlignmentOrigin Layout |
93 | 48 |
|
229 | 49 |
Notice: |
50 |
this class was implemented using protocol information |
|
51 |
from alpha testers - it may not be complete or compatible to |
|
52 |
the corresponding ST-80 class. |
|
53 |
If you encounter any incompatibilities, please forward a note |
|
54 |
describing the incompatibility verbal (i.e. no code) to the ST/X team. |
|
219 | 55 |
|
56 |
[author:] |
|
57 |
Claus Gittinger |
|
229 | 58 |
|
59 |
[see also:] |
|
60 |
View |
|
61 |
LayoutOrigin AlignmentOrigin Layout |
|
62 |
Rectangle Point |
|
94 | 63 |
" |
93 | 64 |
! |
65 |
||
66 |
examples |
|
67 |
" |
|
229 | 68 |
Although the examples below use a button as component, |
69 |
they work of course with any type of subview .... |
|
70 |
||
93 | 71 |
|
229 | 72 |
arrange for the button to be in 0.25 @ 0.25 -> 0.75 @ 0.75. |
73 |
This is the same as with relative origin/corner. |
|
74 |
[exBegin] |
|
75 |
|top button| |
|
93 | 76 |
|
229 | 77 |
top := StandardSystemView new. |
78 |
top extent:300@300. |
|
93 | 79 |
|
229 | 80 |
button := Button label:'component'. |
81 |
top add:button in:(LayoutFrame new |
|
82 |
leftFraction:0.25; |
|
83 |
topFraction:0.25; |
|
84 |
rightFraction:0.75; |
|
85 |
bottomFraction:0.75). |
|
86 |
||
87 |
top open |
|
88 |
[exEnd] |
|
93 | 89 |
|
90 |
||
91 |
like above, but adds additional offset to the origin: |
|
229 | 92 |
This is the same as with relative origin/corner |
93 |
and setting left & right insets. |
|
94 |
[exBegin] |
|
95 |
|top button| |
|
93 | 96 |
|
229 | 97 |
top := StandardSystemView new. |
98 |
top extent:300@300. |
|
93 | 99 |
|
229 | 100 |
button := Button label:'component'. |
101 |
top add:button in:(LayoutFrame new |
|
102 |
leftFraction:0.25; leftOffset:10; |
|
103 |
topFraction:0.25; topOffset:-20; |
|
104 |
rightFraction:0.75; |
|
105 |
bottomFraction:0.75). |
|
93 | 106 |
|
229 | 107 |
top open |
108 |
[exEnd] |
|
93 | 109 |
|
110 |
||
229 | 111 |
like above, with offsets on all edges, |
112 |
actually simulating a constant inset on all four edges: |
|
113 |
[exBegin] |
|
114 |
|top button| |
|
93 | 115 |
|
229 | 116 |
top := StandardSystemView new. |
117 |
top extent:300@300. |
|
93 | 118 |
|
229 | 119 |
button := Button label:'component'. |
120 |
top add:button in:(LayoutFrame new |
|
121 |
leftFraction:0.0; leftOffset:10; |
|
122 |
topFraction:0.0; topOffset:10; |
|
123 |
rightFraction:1.0; rightOffset:-10; |
|
124 |
bottomFraction:1.0; bottomOffset:-10). |
|
93 | 125 |
|
229 | 126 |
top open |
127 |
[exEnd] |
|
93 | 128 |
" |
88 | 129 |
! ! |
130 |
||
426 | 131 |
!LayoutFrame class methodsFor:'instance creation'! |
132 |
||
2839 | 133 |
bottomInset:pixels |
134 |
"create a new layoutFrame which insets the child at the bottom by some pixels" |
|
135 |
||
136 |
^ self |
|
137 |
leftFraction:0 offset:0 |
|
138 |
rightFraction:1 offset:0 |
|
139 |
topFraction:0 offset:0 |
|
140 |
bottomFraction:1 offset:pixels negated |
|
141 |
||
142 |
"Created: / 26-04-2010 / 15:07:50 / cg" |
|
143 |
! |
|
144 |
||
2762
80249bee736b
added: #fractions:offsets: for squeak compatibility
Claus Gittinger <cg@exept.de>
parents:
2618
diff
changeset
|
145 |
fractions:fractionRectangle offsets:offsetRectangle |
80249bee736b
added: #fractions:offsets: for squeak compatibility
Claus Gittinger <cg@exept.de>
parents:
2618
diff
changeset
|
146 |
"create a new layoutFrame" |
80249bee736b
added: #fractions:offsets: for squeak compatibility
Claus Gittinger <cg@exept.de>
parents:
2618
diff
changeset
|
147 |
|
80249bee736b
added: #fractions:offsets: for squeak compatibility
Claus Gittinger <cg@exept.de>
parents:
2618
diff
changeset
|
148 |
^ self new |
80249bee736b
added: #fractions:offsets: for squeak compatibility
Claus Gittinger <cg@exept.de>
parents:
2618
diff
changeset
|
149 |
fractions:fractionRectangle offsets:offsetRectangle |
80249bee736b
added: #fractions:offsets: for squeak compatibility
Claus Gittinger <cg@exept.de>
parents:
2618
diff
changeset
|
150 |
|
80249bee736b
added: #fractions:offsets: for squeak compatibility
Claus Gittinger <cg@exept.de>
parents:
2618
diff
changeset
|
151 |
" |
80249bee736b
added: #fractions:offsets: for squeak compatibility
Claus Gittinger <cg@exept.de>
parents:
2618
diff
changeset
|
152 |
LayoutFrame fractions:(0 @ 0 corner:1.0 @ 1.0) offsets:(0 @ 0 corner:0 @ 0) |
80249bee736b
added: #fractions:offsets: for squeak compatibility
Claus Gittinger <cg@exept.de>
parents:
2618
diff
changeset
|
153 |
" |
80249bee736b
added: #fractions:offsets: for squeak compatibility
Claus Gittinger <cg@exept.de>
parents:
2618
diff
changeset
|
154 |
! |
80249bee736b
added: #fractions:offsets: for squeak compatibility
Claus Gittinger <cg@exept.de>
parents:
2618
diff
changeset
|
155 |
|
2221 | 156 |
inset:pixels |
157 |
"create a new layoutFrame which insets the child by some pixels" |
|
158 |
||
159 |
^ self |
|
160 |
leftFraction:0 offset:pixels |
|
161 |
rightFraction:1 offset:pixels negated |
|
162 |
topFraction:0 offset:pixels |
|
163 |
bottomFraction:1 offset:pixels negated |
|
164 |
! |
|
165 |
||
426 | 166 |
leftFraction:lF offset:lO rightFraction:rF offset:rO topFraction:tF offset:tO bottomFraction:bF offset:bO |
167 |
"create a new layoutFrame" |
|
168 |
||
169 |
^ self new |
|
170 |
leftFraction:lF offset:lO |
|
171 |
rightFraction:rF offset:rO |
|
172 |
topFraction:tF offset:tO |
|
173 |
bottomFraction:bF offset:bO |
|
174 |
||
175 |
||
176 |
||
545
0b9d704baeae
more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents:
498
diff
changeset
|
177 |
! |
0b9d704baeae
more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents:
498
diff
changeset
|
178 |
|
2765
827160ff9feb
added: #leftFraction:rightFraction:topFraction:bottomFraction:
Claus Gittinger <cg@exept.de>
parents:
2763
diff
changeset
|
179 |
leftFraction:lF rightFraction:rF topFraction:tF bottomFraction:bF |
827160ff9feb
added: #leftFraction:rightFraction:topFraction:bottomFraction:
Claus Gittinger <cg@exept.de>
parents:
2763
diff
changeset
|
180 |
"create a new layoutFrame" |
827160ff9feb
added: #leftFraction:rightFraction:topFraction:bottomFraction:
Claus Gittinger <cg@exept.de>
parents:
2763
diff
changeset
|
181 |
|
827160ff9feb
added: #leftFraction:rightFraction:topFraction:bottomFraction:
Claus Gittinger <cg@exept.de>
parents:
2763
diff
changeset
|
182 |
^ self new |
827160ff9feb
added: #leftFraction:rightFraction:topFraction:bottomFraction:
Claus Gittinger <cg@exept.de>
parents:
2763
diff
changeset
|
183 |
leftFraction:lF offset:0 |
827160ff9feb
added: #leftFraction:rightFraction:topFraction:bottomFraction:
Claus Gittinger <cg@exept.de>
parents:
2763
diff
changeset
|
184 |
rightFraction:rF offset:0 |
827160ff9feb
added: #leftFraction:rightFraction:topFraction:bottomFraction:
Claus Gittinger <cg@exept.de>
parents:
2763
diff
changeset
|
185 |
topFraction:tF offset:0 |
827160ff9feb
added: #leftFraction:rightFraction:topFraction:bottomFraction:
Claus Gittinger <cg@exept.de>
parents:
2763
diff
changeset
|
186 |
bottomFraction:bF offset:0 |
827160ff9feb
added: #leftFraction:rightFraction:topFraction:bottomFraction:
Claus Gittinger <cg@exept.de>
parents:
2763
diff
changeset
|
187 |
! |
827160ff9feb
added: #leftFraction:rightFraction:topFraction:bottomFraction:
Claus Gittinger <cg@exept.de>
parents:
2763
diff
changeset
|
188 |
|
545
0b9d704baeae
more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents:
498
diff
changeset
|
189 |
leftOffset:lO rightOffset:rO topOffset:tO bottomOffset:bO |
0b9d704baeae
more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents:
498
diff
changeset
|
190 |
"create a new layoutFrame" |
0b9d704baeae
more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents:
498
diff
changeset
|
191 |
|
0b9d704baeae
more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents:
498
diff
changeset
|
192 |
^ self new |
0b9d704baeae
more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents:
498
diff
changeset
|
193 |
leftOffset:lO |
0b9d704baeae
more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents:
498
diff
changeset
|
194 |
rightOffset:rO |
0b9d704baeae
more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents:
498
diff
changeset
|
195 |
topOffset:tO |
0b9d704baeae
more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents:
498
diff
changeset
|
196 |
bottomOffset:bO |
0b9d704baeae
more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents:
498
diff
changeset
|
197 |
|
0b9d704baeae
more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents:
498
diff
changeset
|
198 |
"Created: 18.4.1997 / 20:14:44 / cg" |
0b9d704baeae
more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents:
498
diff
changeset
|
199 |
! |
0b9d704baeae
more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents:
498
diff
changeset
|
200 |
|
0b9d704baeae
more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents:
498
diff
changeset
|
201 |
leftOffset:lO topOffset:tO rightOffset:rO bottomOffset:bO |
0b9d704baeae
more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents:
498
diff
changeset
|
202 |
"create a new layoutFrame" |
0b9d704baeae
more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents:
498
diff
changeset
|
203 |
|
0b9d704baeae
more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents:
498
diff
changeset
|
204 |
^ self leftOffset:lO rightOffset:rO topOffset:tO bottomOffset:bO |
0b9d704baeae
more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents:
498
diff
changeset
|
205 |
|
0b9d704baeae
more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents:
498
diff
changeset
|
206 |
"Modified: 18.4.1997 / 20:15:23 / cg" |
1795 | 207 |
! |
208 |
||
209 |
origin:origin corner:corner |
|
210 |
"create a new layoutFrame from an oldStyle origin-corner rectangle. |
|
211 |
Added to make migration from Rectangles to LayoutFrames easier." |
|
212 |
||
213 |
|leftFraction leftOffset rightFraction rightOffset |
|
214 |
topFraction topOffset bottomFraction bottomOffset |
|
215 |
orgX orgY cornerX cornerY| |
|
216 |
||
217 |
orgX := origin x. |
|
218 |
orgY := origin y. |
|
219 |
cornerX := corner x. |
|
220 |
cornerY := corner y. |
|
221 |
leftFraction := leftOffset := 0. |
|
222 |
orgX isInteger ifTrue:[ |
|
223 |
leftOffset := orgX |
|
224 |
] ifFalse:[ |
|
225 |
leftFraction := orgX. |
|
226 |
]. |
|
227 |
orgY isInteger ifTrue:[ |
|
228 |
topOffset := orgY |
|
229 |
] ifFalse:[ |
|
230 |
topFraction := orgY. |
|
231 |
]. |
|
232 |
cornerX isInteger ifTrue:[ |
|
233 |
rightOffset := cornerX |
|
234 |
] ifFalse:[ |
|
235 |
rightFraction := cornerX. |
|
236 |
]. |
|
237 |
cornerY isInteger ifTrue:[ |
|
238 |
bottomOffset := cornerY |
|
239 |
] ifFalse:[ |
|
240 |
bottomFraction := cornerY. |
|
241 |
]. |
|
242 |
^ self |
|
243 |
leftFraction:leftFraction offset:leftOffset |
|
244 |
rightFraction:rightFraction offset:rightOffset |
|
245 |
topFraction:topFraction offset:rightOffset |
|
246 |
bottomFraction:bottomFraction offset:bottomOffset |
|
426 | 247 |
! ! |
248 |
||
77 | 249 |
!LayoutFrame methodsFor:'accessing'! |
250 |
||
126 | 251 |
bottomFraction |
2123 | 252 |
"Return the y-coordinate of the bottom of the relative rectangle as a percentage of the height of the reference rectangle." |
126 | 253 |
|
254 |
^ bottomFraction |
|
255 |
! |
|
256 |
||
257 |
bottomFraction:something |
|
2123 | 258 |
"Set the y-coordinate of the bottom of the relative rectangle to be a fraction of the height of the reference rectangle." |
126 | 259 |
|
260 |
bottomFraction := something. |
|
261 |
! |
|
262 |
||
263 |
bottomFraction:something offset:o |
|
2123 | 264 |
"set both bottomFraction and offset" |
77 | 265 |
|
126 | 266 |
bottomFraction := something. |
267 |
bottomOffset := o |
|
268 |
! |
|
269 |
||
275 | 270 |
bottomInset:pixels |
271 |
"set bottomOffset for an inset at the bottom" |
|
272 |
||
273 |
bottomOffset := pixels negated. |
|
274 |
||
275 |
"Created: 26.5.1996 / 17:38:30 / cg" |
|
276 |
! |
|
277 |
||
126 | 278 |
bottomOffset |
279 |
"return bottomOffset" |
|
280 |
||
281 |
^ bottomOffset |
|
282 |
! |
|
283 |
||
284 |
bottomOffset:something |
|
285 |
"set bottomOffset" |
|
286 |
||
287 |
bottomOffset := something. |
|
77 | 288 |
! |
289 |
||
2762
80249bee736b
added: #fractions:offsets: for squeak compatibility
Claus Gittinger <cg@exept.de>
parents:
2618
diff
changeset
|
290 |
fractions:fractionRectangle offsets:offsetRectangle |
80249bee736b
added: #fractions:offsets: for squeak compatibility
Claus Gittinger <cg@exept.de>
parents:
2618
diff
changeset
|
291 |
"LayoutFrame fractions:(0 @ 0 corner:1.0 @ 1.0) offsets:(0 @ 0 corner:0 @ 0)" |
80249bee736b
added: #fractions:offsets: for squeak compatibility
Claus Gittinger <cg@exept.de>
parents:
2618
diff
changeset
|
292 |
|
80249bee736b
added: #fractions:offsets: for squeak compatibility
Claus Gittinger <cg@exept.de>
parents:
2618
diff
changeset
|
293 |
self |
2765
827160ff9feb
added: #leftFraction:rightFraction:topFraction:bottomFraction:
Claus Gittinger <cg@exept.de>
parents:
2763
diff
changeset
|
294 |
leftFraction:(fractionRectangle left) offset:(offsetRectangle left) |
827160ff9feb
added: #leftFraction:rightFraction:topFraction:bottomFraction:
Claus Gittinger <cg@exept.de>
parents:
2763
diff
changeset
|
295 |
rightFraction:(fractionRectangle right) offset:(offsetRectangle right) |
827160ff9feb
added: #leftFraction:rightFraction:topFraction:bottomFraction:
Claus Gittinger <cg@exept.de>
parents:
2763
diff
changeset
|
296 |
topFraction:(fractionRectangle top) offset:(offsetRectangle top) |
827160ff9feb
added: #leftFraction:rightFraction:topFraction:bottomFraction:
Claus Gittinger <cg@exept.de>
parents:
2763
diff
changeset
|
297 |
bottomFraction:(fractionRectangle bottom) offset:(offsetRectangle bottom) |
2762
80249bee736b
added: #fractions:offsets: for squeak compatibility
Claus Gittinger <cg@exept.de>
parents:
2618
diff
changeset
|
298 |
! |
80249bee736b
added: #fractions:offsets: for squeak compatibility
Claus Gittinger <cg@exept.de>
parents:
2618
diff
changeset
|
299 |
|
275 | 300 |
horizontalInset:aNumber |
2123 | 301 |
"setup the offsets for insetting horizontally the frame aNumber pixels at all sides" |
275 | 302 |
|
303 |
leftOffset := aNumber. |
|
304 |
rightOffset := aNumber negated. |
|
305 |
||
306 |
"Created: 26.5.1996 / 17:39:35 / cg" |
|
307 |
! |
|
308 |
||
309 |
inset:aNumber |
|
2123 | 310 |
"setup the offsets for insetting the frame aNumber pixels at all sides" |
275 | 311 |
|
312 |
topOffset := leftOffset := aNumber. |
|
313 |
rightOffset := bottomOffset := aNumber negated. |
|
314 |
||
315 |
"Created: 26.5.1996 / 17:36:49 / cg" |
|
316 |
! |
|
317 |
||
425 | 318 |
leftFraction:lF offset:lO rightFraction:rF offset:rO topFraction:tF offset:tO bottomFraction:bF offset:bO |
319 |
"set all fields" |
|
320 |
||
321 |
leftFraction := lF. |
|
322 |
rightFraction := rF. |
|
323 |
topFraction := tF. |
|
324 |
bottomFraction := bF. |
|
325 |
leftOffset := lO. |
|
326 |
rightOffset := rO. |
|
327 |
topOffset := tO. |
|
328 |
bottomOffset := bO. |
|
329 |
||
330 |
! |
|
331 |
||
1597 | 332 |
leftOffset:lO rightOffset:rO |
333 |
"set the horizontal offset fields" |
|
334 |
||
335 |
leftOffset := lO. |
|
336 |
rightOffset := rO. |
|
337 |
! |
|
338 |
||
545
0b9d704baeae
more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents:
498
diff
changeset
|
339 |
leftOffset:lO rightOffset:rO topOffset:tO bottomOffset:bO |
0b9d704baeae
more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents:
498
diff
changeset
|
340 |
"set all offset fields" |
0b9d704baeae
more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents:
498
diff
changeset
|
341 |
|
0b9d704baeae
more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents:
498
diff
changeset
|
342 |
leftOffset := lO. |
0b9d704baeae
more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents:
498
diff
changeset
|
343 |
rightOffset := rO. |
0b9d704baeae
more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents:
498
diff
changeset
|
344 |
topOffset := tO. |
0b9d704baeae
more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents:
498
diff
changeset
|
345 |
bottomOffset := bO. |
0b9d704baeae
more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents:
498
diff
changeset
|
346 |
|
0b9d704baeae
more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents:
498
diff
changeset
|
347 |
"Created: 18.4.1997 / 20:16:08 / cg" |
0b9d704baeae
more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents:
498
diff
changeset
|
348 |
! |
0b9d704baeae
more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents:
498
diff
changeset
|
349 |
|
77 | 350 |
rightFraction |
351 |
"return rightFraction" |
|
352 |
||
353 |
^ rightFraction |
|
354 |
! |
|
355 |
||
126 | 356 |
rightFraction:something |
357 |
"set rightFraction" |
|
77 | 358 |
|
126 | 359 |
rightFraction := something. |
77 | 360 |
! |
361 |
||
362 |
rightFraction:something offset:o |
|
363 |
"set rightFraction and offset" |
|
364 |
||
365 |
rightFraction := something. |
|
366 |
rightOffset := o |
|
367 |
! |
|
368 |
||
275 | 369 |
rightInset:pixels |
370 |
"set rightOffset for an inset at the right" |
|
371 |
||
372 |
rightOffset := pixels negated. |
|
373 |
||
374 |
"Created: 26.5.1996 / 17:38:38 / cg" |
|
375 |
! |
|
376 |
||
126 | 377 |
rightOffset |
378 |
"return rightOffset" |
|
77 | 379 |
|
126 | 380 |
^ rightOffset |
77 | 381 |
! |
382 |
||
126 | 383 |
rightOffset:something |
384 |
"set rightOffset" |
|
385 |
||
386 |
rightOffset := something. |
|
275 | 387 |
! |
388 |
||
1594 | 389 |
topOffset:newTopOffset bottomOffset:newBottomOffset |
390 |
topOffset := newTopOffset. |
|
391 |
bottomOffset := newBottomOffset. |
|
392 |
! |
|
393 |
||
275 | 394 |
verticalInset:aNumber |
395 |
"setup the offsets for insetting vertically the frame aNumber pixels |
|
396 |
at all sides" |
|
397 |
||
398 |
topOffset := aNumber. |
|
399 |
bottomOffset := aNumber negated. |
|
400 |
||
401 |
"Created: 26.5.1996 / 17:39:50 / cg" |
|
126 | 402 |
! ! |
403 |
||
404 |
!LayoutFrame methodsFor:'converting'! |
|
405 |
||
406 |
fromLiteralArrayEncoding:encoding |
|
407 |
"read my values from an encoding. |
|
408 |
The encoding is supposed to be of the form: |
|
409 |
(LayoutFrame orgOffsX relOrgX orgOffsY relOrgY cornOffsX relCornX cornOffsY relCornY) |
|
410 |
This is the reverse to literalArrayEncoding." |
|
77 | 411 |
|
126 | 412 |
leftOffset := encoding at:2. |
413 |
leftFraction := encoding at:3. |
|
414 |
topOffset := encoding at:4. |
|
415 |
topFraction := encoding at:5. |
|
416 |
rightOffset := encoding at:6. |
|
417 |
rightFraction := encoding at:7. |
|
418 |
bottomOffset := encoding at:8. |
|
419 |
bottomFraction := encoding at:9. |
|
420 |
||
421 |
" |
|
422 |
LayoutFrame new fromLiteralArrayEncoding:#(#LayoutFrame 70 0 2 0 0 1 25 0 ) |
|
423 |
#(#LayoutFrame 70 0 2 0 0 1 25 0 ) decodeAsLiteralArray |
|
424 |
" |
|
77 | 425 |
! |
426 |
||
126 | 427 |
literalArrayEncoding |
191 | 428 |
"encode myself as an array, from which a copy of the receiver |
429 |
can be reconstructed with #decodeAsLiteralArray. |
|
126 | 430 |
The encoding is: |
191 | 431 |
(#LayoutOrigin orgOffsX relOrgX orgOffsY relOrgY cornOffsX relCornX cornOffsY relCornY)" |
77 | 432 |
|
126 | 433 |
^ super literalArrayEncoding |
434 |
, (Array |
|
2618
fb52a0f3e1e8
Fix preferred and dynamic preferred sizes
Stefan Vogel <sv@exept.de>
parents:
2221
diff
changeset
|
435 |
with:rightOffset value "take care of blocks (dynamic preferred extent)" |
191 | 436 |
with:rightFraction |
2618
fb52a0f3e1e8
Fix preferred and dynamic preferred sizes
Stefan Vogel <sv@exept.de>
parents:
2221
diff
changeset
|
437 |
with:bottomOffset value |
fb52a0f3e1e8
Fix preferred and dynamic preferred sizes
Stefan Vogel <sv@exept.de>
parents:
2221
diff
changeset
|
438 |
with:bottomFraction) "take care of blocks (dynamic preferred extent)" |
77 | 439 |
|
126 | 440 |
"Modified: 1.9.1995 / 02:43:35 / claus" |
191 | 441 |
"Modified: 22.4.1996 / 13:00:17 / cg" |
77 | 442 |
! ! |
443 |
||
126 | 444 |
!LayoutFrame methodsFor:'initialization'! |
445 |
||
446 |
initialize |
|
447 |
leftOffset := rightOffset := bottomOffset := topOffset := 0. |
|
448 |
leftFraction := topFraction := 0. |
|
468 | 449 |
"/ bottomFraction := rightFraction := 1. |
450 |
bottomFraction := rightFraction := 0. |
|
451 |
||
452 |
"Modified: 1.3.1997 / 16:12:50 / cg" |
|
126 | 453 |
! ! |
77 | 454 |
|
83 | 455 |
!LayoutFrame methodsFor:'printing & storing'! |
456 |
||
3018
e7f336370c9f
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2839
diff
changeset
|
457 |
displayOn:aGCOrStream |
700 | 458 |
"return a printed representation of the receiver for displaying" |
459 |
||
3018
e7f336370c9f
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2839
diff
changeset
|
460 |
"/ what a kludge - Dolphin and Squeak mean: printOn: a stream; |
e7f336370c9f
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2839
diff
changeset
|
461 |
"/ ST/X (and some old ST80's) mean: draw-yourself on a GC. |
e7f336370c9f
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2839
diff
changeset
|
462 |
(aGCOrStream isStream) ifFalse:[ |
e7f336370c9f
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2839
diff
changeset
|
463 |
^ super displayOn:aGCOrStream |
e7f336370c9f
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2839
diff
changeset
|
464 |
]. |
e7f336370c9f
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2839
diff
changeset
|
465 |
|
e7f336370c9f
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2839
diff
changeset
|
466 |
aGCOrStream |
e7f336370c9f
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2839
diff
changeset
|
467 |
nextPutAll:self class name; |
e7f336370c9f
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2839
diff
changeset
|
468 |
nextPutAll:'(l: '. |
e7f336370c9f
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2839
diff
changeset
|
469 |
|
e7f336370c9f
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2839
diff
changeset
|
470 |
leftFraction displayOn:aGCOrStream. |
e7f336370c9f
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2839
diff
changeset
|
471 |
aGCOrStream nextPut:$+. |
e7f336370c9f
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2839
diff
changeset
|
472 |
leftOffset displayOn:aGCOrStream. |
e7f336370c9f
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2839
diff
changeset
|
473 |
aGCOrStream nextPutAll:' t: '. |
e7f336370c9f
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2839
diff
changeset
|
474 |
topFraction displayOn:aGCOrStream. |
e7f336370c9f
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2839
diff
changeset
|
475 |
aGCOrStream nextPut:$+. |
e7f336370c9f
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2839
diff
changeset
|
476 |
topOffset displayOn:aGCOrStream. |
e7f336370c9f
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2839
diff
changeset
|
477 |
aGCOrStream nextPutAll:' r: '. |
e7f336370c9f
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2839
diff
changeset
|
478 |
rightFraction displayOn:aGCOrStream. |
e7f336370c9f
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2839
diff
changeset
|
479 |
aGCOrStream nextPut:$+. |
e7f336370c9f
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2839
diff
changeset
|
480 |
rightOffset displayOn:aGCOrStream. |
e7f336370c9f
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2839
diff
changeset
|
481 |
aGCOrStream nextPutAll:' b: '. |
e7f336370c9f
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2839
diff
changeset
|
482 |
bottomFraction displayOn:aGCOrStream. |
e7f336370c9f
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2839
diff
changeset
|
483 |
aGCOrStream nextPut:$+. |
e7f336370c9f
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2839
diff
changeset
|
484 |
bottomOffset displayOn:aGCOrStream. |
e7f336370c9f
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2839
diff
changeset
|
485 |
aGCOrStream nextPut:$). |
700 | 486 |
|
487 |
"Modified: 20.9.1997 / 11:40:14 / cg" |
|
83 | 488 |
! ! |
489 |
||
77 | 490 |
!LayoutFrame methodsFor:'queries'! |
491 |
||
126 | 492 |
corner |
493 |
^ rightFraction asFloat @ bottomFraction asFloat |
|
494 |
! |
|
495 |
||
416 | 496 |
isLayoutFrame |
497 |
"return true, if this is a layoutFrame" |
|
498 |
||
499 |
^ true |
|
500 |
||
501 |
||
502 |
! |
|
503 |
||
949
0eb888b21192
prefRect may now be a valueHolder or block
Claus Gittinger <cg@exept.de>
parents:
700
diff
changeset
|
504 |
rectangleRelativeTo:superRectangle preferred:prefRectHolder |
229 | 505 |
"compute the rectangle represented by the receiver, |
506 |
given the superViews rectangle and the views preferredExtent." |
|
507 |
||
498 | 508 |
|x1 y1 x2 y2 superWidth superHeight| |
77 | 509 |
|
1039 | 510 |
x1 := x2 := superRectangle left. |
511 |
y1 := y2 := superRectangle top. |
|
512 |
||
513 |
leftOffset notNil ifTrue:[ |
|
514 |
x1 := x1 + leftOffset value |
|
77 | 515 |
]. |
1039 | 516 |
topOffset notNil ifTrue:[ |
517 |
y1 := y1 + topOffset value |
|
77 | 518 |
]. |
1039 | 519 |
rightOffset notNil ifTrue:[ |
520 |
x2 := x2 + rightOffset value |
|
521 |
]. |
|
522 |
bottomOffset notNil ifTrue:[ |
|
523 |
y2 := y2 + bottomOffset value |
|
77 | 524 |
]. |
498 | 525 |
|
77 | 526 |
leftFraction notNil ifTrue:[ |
498 | 527 |
superWidth := superRectangle width. |
1601 | 528 |
x1 := x1 + (superWidth * leftFraction value) |
77 | 529 |
]. |
530 |
topFraction notNil ifTrue:[ |
|
498 | 531 |
superHeight := superRectangle height. |
1601 | 532 |
y1 := y1 + (superHeight * topFraction value) |
77 | 533 |
]. |
534 |
rightFraction notNil ifTrue:[ |
|
498 | 535 |
superWidth isNil ifTrue:[superWidth := superRectangle width]. |
1601 | 536 |
x2 := x2 + (superWidth * rightFraction value) |
77 | 537 |
]. |
538 |
bottomFraction notNil ifTrue:[ |
|
498 | 539 |
superHeight isNil ifTrue:[superHeight := superRectangle height]. |
1601 | 540 |
y2 := y2 + (superHeight * bottomFraction value) |
77 | 541 |
]. |
242 | 542 |
^ Rectangle left:x1 top:y1 right:x2 bottom:y2 |
83 | 543 |
|
544 |
" |
|
545 |
|superRect lF| |
|
546 |
||
498 | 547 |
superRect := 0@0 corner:99@99. |
83 | 548 |
lF := (LayoutFrame new). |
549 |
lF leftFraction:0.25; |
|
229 | 550 |
topFraction:0.25; |
551 |
rightFraction:0.75; |
|
552 |
bottomFraction:0.75. |
|
83 | 553 |
lF rectangleRelativeTo:superRect preferred:(0@0 corner:30@30) |
554 |
" |
|
229 | 555 |
|
949
0eb888b21192
prefRect may now be a valueHolder or block
Claus Gittinger <cg@exept.de>
parents:
700
diff
changeset
|
556 |
"Created: / 6.3.1997 / 21:07:51 / cg" |
1039 | 557 |
"Modified: / 13.8.1998 / 18:33:59 / cg" |
77 | 558 |
! ! |
100 | 559 |
|
126 | 560 |
!LayoutFrame class methodsFor:'documentation'! |
100 | 561 |
|
126 | 562 |
version |
3018
e7f336370c9f
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2839
diff
changeset
|
563 |
^ '$Header: /cvs/stx/stx/libview2/LayoutFrame.st,v 1.38 2012-08-03 15:53:57 stefan Exp $' |
2762
80249bee736b
added: #fractions:offsets: for squeak compatibility
Claus Gittinger <cg@exept.de>
parents:
2618
diff
changeset
|
564 |
! |
80249bee736b
added: #fractions:offsets: for squeak compatibility
Claus Gittinger <cg@exept.de>
parents:
2618
diff
changeset
|
565 |
|
80249bee736b
added: #fractions:offsets: for squeak compatibility
Claus Gittinger <cg@exept.de>
parents:
2618
diff
changeset
|
566 |
version_CVS |
3018
e7f336370c9f
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2839
diff
changeset
|
567 |
^ '$Header: /cvs/stx/stx/libview2/LayoutFrame.st,v 1.38 2012-08-03 15:53:57 stefan Exp $' |
100 | 568 |
! ! |