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