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