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