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