author | Claus Gittinger <cg@exept.de> |
Sun, 25 Oct 2009 02:21:08 +0200 | |
changeset 2777 | 4cdef981fdb3 |
parent 2765 | 827160ff9feb |
child 2839 | 8fd092da727e |
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 |
||
2762
80249bee736b
added: #fractions:offsets: for squeak compatibility
Claus Gittinger <cg@exept.de>
parents:
2618
diff
changeset
|
133 |
fractions:fractionRectangle offsets:offsetRectangle |
80249bee736b
added: #fractions:offsets: for squeak compatibility
Claus Gittinger <cg@exept.de>
parents:
2618
diff
changeset
|
134 |
"create a new layoutFrame" |
80249bee736b
added: #fractions:offsets: for squeak compatibility
Claus Gittinger <cg@exept.de>
parents:
2618
diff
changeset
|
135 |
|
80249bee736b
added: #fractions:offsets: for squeak compatibility
Claus Gittinger <cg@exept.de>
parents:
2618
diff
changeset
|
136 |
^ self new |
80249bee736b
added: #fractions:offsets: for squeak compatibility
Claus Gittinger <cg@exept.de>
parents:
2618
diff
changeset
|
137 |
fractions:fractionRectangle offsets:offsetRectangle |
80249bee736b
added: #fractions:offsets: for squeak compatibility
Claus Gittinger <cg@exept.de>
parents:
2618
diff
changeset
|
138 |
|
80249bee736b
added: #fractions:offsets: for squeak compatibility
Claus Gittinger <cg@exept.de>
parents:
2618
diff
changeset
|
139 |
" |
80249bee736b
added: #fractions:offsets: for squeak compatibility
Claus Gittinger <cg@exept.de>
parents:
2618
diff
changeset
|
140 |
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
|
141 |
" |
80249bee736b
added: #fractions:offsets: for squeak compatibility
Claus Gittinger <cg@exept.de>
parents:
2618
diff
changeset
|
142 |
! |
80249bee736b
added: #fractions:offsets: for squeak compatibility
Claus Gittinger <cg@exept.de>
parents:
2618
diff
changeset
|
143 |
|
2221 | 144 |
inset:pixels |
145 |
"create a new layoutFrame which insets the child by some pixels" |
|
146 |
||
147 |
^ self |
|
148 |
leftFraction:0 offset:pixels |
|
149 |
rightFraction:1 offset:pixels negated |
|
150 |
topFraction:0 offset:pixels |
|
151 |
bottomFraction:1 offset:pixels negated |
|
152 |
! |
|
153 |
||
426 | 154 |
leftFraction:lF offset:lO rightFraction:rF offset:rO topFraction:tF offset:tO bottomFraction:bF offset:bO |
155 |
"create a new layoutFrame" |
|
156 |
||
157 |
^ self new |
|
158 |
leftFraction:lF offset:lO |
|
159 |
rightFraction:rF offset:rO |
|
160 |
topFraction:tF offset:tO |
|
161 |
bottomFraction:bF offset:bO |
|
162 |
||
163 |
||
164 |
||
545
0b9d704baeae
more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents:
498
diff
changeset
|
165 |
! |
0b9d704baeae
more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents:
498
diff
changeset
|
166 |
|
2765
827160ff9feb
added: #leftFraction:rightFraction:topFraction:bottomFraction:
Claus Gittinger <cg@exept.de>
parents:
2763
diff
changeset
|
167 |
leftFraction:lF rightFraction:rF topFraction:tF bottomFraction:bF |
827160ff9feb
added: #leftFraction:rightFraction:topFraction:bottomFraction:
Claus Gittinger <cg@exept.de>
parents:
2763
diff
changeset
|
168 |
"create a new layoutFrame" |
827160ff9feb
added: #leftFraction:rightFraction:topFraction:bottomFraction:
Claus Gittinger <cg@exept.de>
parents:
2763
diff
changeset
|
169 |
|
827160ff9feb
added: #leftFraction:rightFraction:topFraction:bottomFraction:
Claus Gittinger <cg@exept.de>
parents:
2763
diff
changeset
|
170 |
^ self new |
827160ff9feb
added: #leftFraction:rightFraction:topFraction:bottomFraction:
Claus Gittinger <cg@exept.de>
parents:
2763
diff
changeset
|
171 |
leftFraction:lF offset:0 |
827160ff9feb
added: #leftFraction:rightFraction:topFraction:bottomFraction:
Claus Gittinger <cg@exept.de>
parents:
2763
diff
changeset
|
172 |
rightFraction:rF offset:0 |
827160ff9feb
added: #leftFraction:rightFraction:topFraction:bottomFraction:
Claus Gittinger <cg@exept.de>
parents:
2763
diff
changeset
|
173 |
topFraction:tF offset:0 |
827160ff9feb
added: #leftFraction:rightFraction:topFraction:bottomFraction:
Claus Gittinger <cg@exept.de>
parents:
2763
diff
changeset
|
174 |
bottomFraction:bF offset:0 |
827160ff9feb
added: #leftFraction:rightFraction:topFraction:bottomFraction:
Claus Gittinger <cg@exept.de>
parents:
2763
diff
changeset
|
175 |
! |
827160ff9feb
added: #leftFraction:rightFraction:topFraction:bottomFraction:
Claus Gittinger <cg@exept.de>
parents:
2763
diff
changeset
|
176 |
|
545
0b9d704baeae
more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents:
498
diff
changeset
|
177 |
leftOffset:lO rightOffset:rO topOffset:tO bottomOffset:bO |
0b9d704baeae
more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents:
498
diff
changeset
|
178 |
"create a new layoutFrame" |
0b9d704baeae
more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents:
498
diff
changeset
|
179 |
|
0b9d704baeae
more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents:
498
diff
changeset
|
180 |
^ self new |
0b9d704baeae
more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents:
498
diff
changeset
|
181 |
leftOffset:lO |
0b9d704baeae
more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents:
498
diff
changeset
|
182 |
rightOffset:rO |
0b9d704baeae
more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents:
498
diff
changeset
|
183 |
topOffset:tO |
0b9d704baeae
more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents:
498
diff
changeset
|
184 |
bottomOffset:bO |
0b9d704baeae
more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents:
498
diff
changeset
|
185 |
|
0b9d704baeae
more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents:
498
diff
changeset
|
186 |
"Created: 18.4.1997 / 20:14:44 / cg" |
0b9d704baeae
more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents:
498
diff
changeset
|
187 |
! |
0b9d704baeae
more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents:
498
diff
changeset
|
188 |
|
0b9d704baeae
more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents:
498
diff
changeset
|
189 |
leftOffset:lO topOffset:tO rightOffset:rO 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 leftOffset:lO rightOffset:rO topOffset:tO bottomOffset:bO |
0b9d704baeae
more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents:
498
diff
changeset
|
193 |
|
0b9d704baeae
more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents:
498
diff
changeset
|
194 |
"Modified: 18.4.1997 / 20:15:23 / cg" |
1795 | 195 |
! |
196 |
||
197 |
origin:origin corner:corner |
|
198 |
"create a new layoutFrame from an oldStyle origin-corner rectangle. |
|
199 |
Added to make migration from Rectangles to LayoutFrames easier." |
|
200 |
||
201 |
|leftFraction leftOffset rightFraction rightOffset |
|
202 |
topFraction topOffset bottomFraction bottomOffset |
|
203 |
orgX orgY cornerX cornerY| |
|
204 |
||
205 |
orgX := origin x. |
|
206 |
orgY := origin y. |
|
207 |
cornerX := corner x. |
|
208 |
cornerY := corner y. |
|
209 |
leftFraction := leftOffset := 0. |
|
210 |
orgX isInteger ifTrue:[ |
|
211 |
leftOffset := orgX |
|
212 |
] ifFalse:[ |
|
213 |
leftFraction := orgX. |
|
214 |
]. |
|
215 |
orgY isInteger ifTrue:[ |
|
216 |
topOffset := orgY |
|
217 |
] ifFalse:[ |
|
218 |
topFraction := orgY. |
|
219 |
]. |
|
220 |
cornerX isInteger ifTrue:[ |
|
221 |
rightOffset := cornerX |
|
222 |
] ifFalse:[ |
|
223 |
rightFraction := cornerX. |
|
224 |
]. |
|
225 |
cornerY isInteger ifTrue:[ |
|
226 |
bottomOffset := cornerY |
|
227 |
] ifFalse:[ |
|
228 |
bottomFraction := cornerY. |
|
229 |
]. |
|
230 |
^ self |
|
231 |
leftFraction:leftFraction offset:leftOffset |
|
232 |
rightFraction:rightFraction offset:rightOffset |
|
233 |
topFraction:topFraction offset:rightOffset |
|
234 |
bottomFraction:bottomFraction offset:bottomOffset |
|
426 | 235 |
! ! |
236 |
||
77 | 237 |
!LayoutFrame methodsFor:'accessing'! |
238 |
||
126 | 239 |
bottomFraction |
2123 | 240 |
"Return the y-coordinate of the bottom of the relative rectangle as a percentage of the height of the reference rectangle." |
126 | 241 |
|
242 |
^ bottomFraction |
|
243 |
! |
|
244 |
||
245 |
bottomFraction:something |
|
2123 | 246 |
"Set the y-coordinate of the bottom of the relative rectangle to be a fraction of the height of the reference rectangle." |
126 | 247 |
|
248 |
bottomFraction := something. |
|
249 |
! |
|
250 |
||
251 |
bottomFraction:something offset:o |
|
2123 | 252 |
"set both bottomFraction and offset" |
77 | 253 |
|
126 | 254 |
bottomFraction := something. |
255 |
bottomOffset := o |
|
256 |
! |
|
257 |
||
275 | 258 |
bottomInset:pixels |
259 |
"set bottomOffset for an inset at the bottom" |
|
260 |
||
261 |
bottomOffset := pixels negated. |
|
262 |
||
263 |
"Created: 26.5.1996 / 17:38:30 / cg" |
|
264 |
! |
|
265 |
||
126 | 266 |
bottomOffset |
267 |
"return bottomOffset" |
|
268 |
||
269 |
^ bottomOffset |
|
270 |
! |
|
271 |
||
272 |
bottomOffset:something |
|
273 |
"set bottomOffset" |
|
274 |
||
275 |
bottomOffset := something. |
|
77 | 276 |
! |
277 |
||
2762
80249bee736b
added: #fractions:offsets: for squeak compatibility
Claus Gittinger <cg@exept.de>
parents:
2618
diff
changeset
|
278 |
fractions:fractionRectangle offsets:offsetRectangle |
80249bee736b
added: #fractions:offsets: for squeak compatibility
Claus Gittinger <cg@exept.de>
parents:
2618
diff
changeset
|
279 |
"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
|
280 |
|
80249bee736b
added: #fractions:offsets: for squeak compatibility
Claus Gittinger <cg@exept.de>
parents:
2618
diff
changeset
|
281 |
self |
2765
827160ff9feb
added: #leftFraction:rightFraction:topFraction:bottomFraction:
Claus Gittinger <cg@exept.de>
parents:
2763
diff
changeset
|
282 |
leftFraction:(fractionRectangle left) offset:(offsetRectangle left) |
827160ff9feb
added: #leftFraction:rightFraction:topFraction:bottomFraction:
Claus Gittinger <cg@exept.de>
parents:
2763
diff
changeset
|
283 |
rightFraction:(fractionRectangle right) offset:(offsetRectangle right) |
827160ff9feb
added: #leftFraction:rightFraction:topFraction:bottomFraction:
Claus Gittinger <cg@exept.de>
parents:
2763
diff
changeset
|
284 |
topFraction:(fractionRectangle top) offset:(offsetRectangle top) |
827160ff9feb
added: #leftFraction:rightFraction:topFraction:bottomFraction:
Claus Gittinger <cg@exept.de>
parents:
2763
diff
changeset
|
285 |
bottomFraction:(fractionRectangle bottom) offset:(offsetRectangle bottom) |
2762
80249bee736b
added: #fractions:offsets: for squeak compatibility
Claus Gittinger <cg@exept.de>
parents:
2618
diff
changeset
|
286 |
! |
80249bee736b
added: #fractions:offsets: for squeak compatibility
Claus Gittinger <cg@exept.de>
parents:
2618
diff
changeset
|
287 |
|
275 | 288 |
horizontalInset:aNumber |
2123 | 289 |
"setup the offsets for insetting horizontally the frame aNumber pixels at all sides" |
275 | 290 |
|
291 |
leftOffset := aNumber. |
|
292 |
rightOffset := aNumber negated. |
|
293 |
||
294 |
"Created: 26.5.1996 / 17:39:35 / cg" |
|
295 |
! |
|
296 |
||
297 |
inset:aNumber |
|
2123 | 298 |
"setup the offsets for insetting the frame aNumber pixels at all sides" |
275 | 299 |
|
300 |
topOffset := leftOffset := aNumber. |
|
301 |
rightOffset := bottomOffset := aNumber negated. |
|
302 |
||
303 |
"Created: 26.5.1996 / 17:36:49 / cg" |
|
304 |
! |
|
305 |
||
425 | 306 |
leftFraction:lF offset:lO rightFraction:rF offset:rO topFraction:tF offset:tO bottomFraction:bF offset:bO |
307 |
"set all fields" |
|
308 |
||
309 |
leftFraction := lF. |
|
310 |
rightFraction := rF. |
|
311 |
topFraction := tF. |
|
312 |
bottomFraction := bF. |
|
313 |
leftOffset := lO. |
|
314 |
rightOffset := rO. |
|
315 |
topOffset := tO. |
|
316 |
bottomOffset := bO. |
|
317 |
||
318 |
! |
|
319 |
||
1597 | 320 |
leftOffset:lO rightOffset:rO |
321 |
"set the horizontal offset fields" |
|
322 |
||
323 |
leftOffset := lO. |
|
324 |
rightOffset := rO. |
|
325 |
! |
|
326 |
||
545
0b9d704baeae
more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents:
498
diff
changeset
|
327 |
leftOffset:lO rightOffset:rO topOffset:tO bottomOffset:bO |
0b9d704baeae
more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents:
498
diff
changeset
|
328 |
"set all offset fields" |
0b9d704baeae
more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents:
498
diff
changeset
|
329 |
|
0b9d704baeae
more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents:
498
diff
changeset
|
330 |
leftOffset := lO. |
0b9d704baeae
more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents:
498
diff
changeset
|
331 |
rightOffset := rO. |
0b9d704baeae
more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents:
498
diff
changeset
|
332 |
topOffset := tO. |
0b9d704baeae
more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents:
498
diff
changeset
|
333 |
bottomOffset := bO. |
0b9d704baeae
more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents:
498
diff
changeset
|
334 |
|
0b9d704baeae
more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents:
498
diff
changeset
|
335 |
"Created: 18.4.1997 / 20:16:08 / cg" |
0b9d704baeae
more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents:
498
diff
changeset
|
336 |
! |
0b9d704baeae
more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents:
498
diff
changeset
|
337 |
|
77 | 338 |
rightFraction |
339 |
"return rightFraction" |
|
340 |
||
341 |
^ rightFraction |
|
342 |
! |
|
343 |
||
126 | 344 |
rightFraction:something |
345 |
"set rightFraction" |
|
77 | 346 |
|
126 | 347 |
rightFraction := something. |
77 | 348 |
! |
349 |
||
350 |
rightFraction:something offset:o |
|
351 |
"set rightFraction and offset" |
|
352 |
||
353 |
rightFraction := something. |
|
354 |
rightOffset := o |
|
355 |
! |
|
356 |
||
275 | 357 |
rightInset:pixels |
358 |
"set rightOffset for an inset at the right" |
|
359 |
||
360 |
rightOffset := pixels negated. |
|
361 |
||
362 |
"Created: 26.5.1996 / 17:38:38 / cg" |
|
363 |
! |
|
364 |
||
126 | 365 |
rightOffset |
366 |
"return rightOffset" |
|
77 | 367 |
|
126 | 368 |
^ rightOffset |
77 | 369 |
! |
370 |
||
126 | 371 |
rightOffset:something |
372 |
"set rightOffset" |
|
373 |
||
374 |
rightOffset := something. |
|
275 | 375 |
! |
376 |
||
1594 | 377 |
topOffset:newTopOffset bottomOffset:newBottomOffset |
378 |
topOffset := newTopOffset. |
|
379 |
bottomOffset := newBottomOffset. |
|
380 |
! |
|
381 |
||
275 | 382 |
verticalInset:aNumber |
383 |
"setup the offsets for insetting vertically the frame aNumber pixels |
|
384 |
at all sides" |
|
385 |
||
386 |
topOffset := aNumber. |
|
387 |
bottomOffset := aNumber negated. |
|
388 |
||
389 |
"Created: 26.5.1996 / 17:39:50 / cg" |
|
126 | 390 |
! ! |
391 |
||
392 |
!LayoutFrame methodsFor:'converting'! |
|
393 |
||
394 |
fromLiteralArrayEncoding:encoding |
|
395 |
"read my values from an encoding. |
|
396 |
The encoding is supposed to be of the form: |
|
397 |
(LayoutFrame orgOffsX relOrgX orgOffsY relOrgY cornOffsX relCornX cornOffsY relCornY) |
|
398 |
This is the reverse to literalArrayEncoding." |
|
77 | 399 |
|
126 | 400 |
leftOffset := encoding at:2. |
401 |
leftFraction := encoding at:3. |
|
402 |
topOffset := encoding at:4. |
|
403 |
topFraction := encoding at:5. |
|
404 |
rightOffset := encoding at:6. |
|
405 |
rightFraction := encoding at:7. |
|
406 |
bottomOffset := encoding at:8. |
|
407 |
bottomFraction := encoding at:9. |
|
408 |
||
409 |
" |
|
410 |
LayoutFrame new fromLiteralArrayEncoding:#(#LayoutFrame 70 0 2 0 0 1 25 0 ) |
|
411 |
#(#LayoutFrame 70 0 2 0 0 1 25 0 ) decodeAsLiteralArray |
|
412 |
" |
|
77 | 413 |
! |
414 |
||
126 | 415 |
literalArrayEncoding |
191 | 416 |
"encode myself as an array, from which a copy of the receiver |
417 |
can be reconstructed with #decodeAsLiteralArray. |
|
126 | 418 |
The encoding is: |
191 | 419 |
(#LayoutOrigin orgOffsX relOrgX orgOffsY relOrgY cornOffsX relCornX cornOffsY relCornY)" |
77 | 420 |
|
126 | 421 |
^ super literalArrayEncoding |
422 |
, (Array |
|
2618
fb52a0f3e1e8
Fix preferred and dynamic preferred sizes
Stefan Vogel <sv@exept.de>
parents:
2221
diff
changeset
|
423 |
with:rightOffset value "take care of blocks (dynamic preferred extent)" |
191 | 424 |
with:rightFraction |
2618
fb52a0f3e1e8
Fix preferred and dynamic preferred sizes
Stefan Vogel <sv@exept.de>
parents:
2221
diff
changeset
|
425 |
with:bottomOffset value |
fb52a0f3e1e8
Fix preferred and dynamic preferred sizes
Stefan Vogel <sv@exept.de>
parents:
2221
diff
changeset
|
426 |
with:bottomFraction) "take care of blocks (dynamic preferred extent)" |
77 | 427 |
|
126 | 428 |
"Modified: 1.9.1995 / 02:43:35 / claus" |
191 | 429 |
"Modified: 22.4.1996 / 13:00:17 / cg" |
77 | 430 |
! ! |
431 |
||
126 | 432 |
!LayoutFrame methodsFor:'initialization'! |
433 |
||
434 |
initialize |
|
435 |
leftOffset := rightOffset := bottomOffset := topOffset := 0. |
|
436 |
leftFraction := topFraction := 0. |
|
468 | 437 |
"/ bottomFraction := rightFraction := 1. |
438 |
bottomFraction := rightFraction := 0. |
|
439 |
||
440 |
"Modified: 1.3.1997 / 16:12:50 / cg" |
|
126 | 441 |
! ! |
77 | 442 |
|
83 | 443 |
!LayoutFrame methodsFor:'printing & storing'! |
444 |
||
445 |
displayString |
|
700 | 446 |
"return a printed representation of the receiver for displaying" |
447 |
||
83 | 448 |
^ (self class name) , '(' |
700 | 449 |
, 'l: ' , leftFraction displayString |
450 |
, '+' , leftOffset displayString |
|
451 |
, ' t: ' , topFraction displayString |
|
452 |
, '+' , topOffset displayString |
|
453 |
, ' r: ' , rightFraction displayString |
|
454 |
, '+' , rightOffset displayString |
|
455 |
, ' b: ' , bottomFraction displayString |
|
456 |
, '+' , bottomOffset displayString |
|
457 |
, ')' |
|
458 |
||
459 |
"Modified: 20.9.1997 / 11:40:14 / cg" |
|
83 | 460 |
! ! |
461 |
||
77 | 462 |
!LayoutFrame methodsFor:'queries'! |
463 |
||
126 | 464 |
corner |
465 |
^ rightFraction asFloat @ bottomFraction asFloat |
|
466 |
! |
|
467 |
||
416 | 468 |
isLayoutFrame |
469 |
"return true, if this is a layoutFrame" |
|
470 |
||
471 |
^ true |
|
472 |
||
473 |
||
474 |
! |
|
475 |
||
949
0eb888b21192
prefRect may now be a valueHolder or block
Claus Gittinger <cg@exept.de>
parents:
700
diff
changeset
|
476 |
rectangleRelativeTo:superRectangle preferred:prefRectHolder |
229 | 477 |
"compute the rectangle represented by the receiver, |
478 |
given the superViews rectangle and the views preferredExtent." |
|
479 |
||
498 | 480 |
|x1 y1 x2 y2 superWidth superHeight| |
77 | 481 |
|
1039 | 482 |
x1 := x2 := superRectangle left. |
483 |
y1 := y2 := superRectangle top. |
|
484 |
||
485 |
leftOffset notNil ifTrue:[ |
|
486 |
x1 := x1 + leftOffset value |
|
77 | 487 |
]. |
1039 | 488 |
topOffset notNil ifTrue:[ |
489 |
y1 := y1 + topOffset value |
|
77 | 490 |
]. |
1039 | 491 |
rightOffset notNil ifTrue:[ |
492 |
x2 := x2 + rightOffset value |
|
493 |
]. |
|
494 |
bottomOffset notNil ifTrue:[ |
|
495 |
y2 := y2 + bottomOffset value |
|
77 | 496 |
]. |
498 | 497 |
|
77 | 498 |
leftFraction notNil ifTrue:[ |
498 | 499 |
superWidth := superRectangle width. |
1601 | 500 |
x1 := x1 + (superWidth * leftFraction value) |
77 | 501 |
]. |
502 |
topFraction notNil ifTrue:[ |
|
498 | 503 |
superHeight := superRectangle height. |
1601 | 504 |
y1 := y1 + (superHeight * topFraction value) |
77 | 505 |
]. |
506 |
rightFraction notNil ifTrue:[ |
|
498 | 507 |
superWidth isNil ifTrue:[superWidth := superRectangle width]. |
1601 | 508 |
x2 := x2 + (superWidth * rightFraction value) |
77 | 509 |
]. |
510 |
bottomFraction notNil ifTrue:[ |
|
498 | 511 |
superHeight isNil ifTrue:[superHeight := superRectangle height]. |
1601 | 512 |
y2 := y2 + (superHeight * bottomFraction value) |
77 | 513 |
]. |
242 | 514 |
^ Rectangle left:x1 top:y1 right:x2 bottom:y2 |
83 | 515 |
|
516 |
" |
|
517 |
|superRect lF| |
|
518 |
||
498 | 519 |
superRect := 0@0 corner:99@99. |
83 | 520 |
lF := (LayoutFrame new). |
521 |
lF leftFraction:0.25; |
|
229 | 522 |
topFraction:0.25; |
523 |
rightFraction:0.75; |
|
524 |
bottomFraction:0.75. |
|
83 | 525 |
lF rectangleRelativeTo:superRect preferred:(0@0 corner:30@30) |
526 |
" |
|
229 | 527 |
|
949
0eb888b21192
prefRect may now be a valueHolder or block
Claus Gittinger <cg@exept.de>
parents:
700
diff
changeset
|
528 |
"Created: / 6.3.1997 / 21:07:51 / cg" |
1039 | 529 |
"Modified: / 13.8.1998 / 18:33:59 / cg" |
77 | 530 |
! ! |
100 | 531 |
|
126 | 532 |
!LayoutFrame class methodsFor:'documentation'! |
100 | 533 |
|
126 | 534 |
version |
2765
827160ff9feb
added: #leftFraction:rightFraction:topFraction:bottomFraction:
Claus Gittinger <cg@exept.de>
parents:
2763
diff
changeset
|
535 |
^ '$Header: /cvs/stx/stx/libview2/LayoutFrame.st,v 1.36 2009-10-19 09:28:12 cg Exp $' |
2762
80249bee736b
added: #fractions:offsets: for squeak compatibility
Claus Gittinger <cg@exept.de>
parents:
2618
diff
changeset
|
536 |
! |
80249bee736b
added: #fractions:offsets: for squeak compatibility
Claus Gittinger <cg@exept.de>
parents:
2618
diff
changeset
|
537 |
|
80249bee736b
added: #fractions:offsets: for squeak compatibility
Claus Gittinger <cg@exept.de>
parents:
2618
diff
changeset
|
538 |
version_CVS |
2765
827160ff9feb
added: #leftFraction:rightFraction:topFraction:bottomFraction:
Claus Gittinger <cg@exept.de>
parents:
2763
diff
changeset
|
539 |
^ '$Header: /cvs/stx/stx/libview2/LayoutFrame.st,v 1.36 2009-10-19 09:28:12 cg Exp $' |
100 | 540 |
! ! |