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