43 preferredExtent is ignored. |
43 preferredExtent is ignored. |
44 |
44 |
45 See also: |
45 See also: |
46 LayoutOrigin AlignmentOrigin Layout |
46 LayoutOrigin AlignmentOrigin Layout |
47 |
47 |
48 Notice: this class was implemented using protocol information |
48 Notice: |
49 from alpha testers - it may not be complete or compatible to |
49 this class was implemented using protocol information |
50 the corresponding ST-80 class. If you encounter any incompatibilities, |
50 from alpha testers - it may not be complete or compatible to |
51 please forward a note to the ST/X team. |
51 the corresponding ST-80 class. |
|
52 If you encounter any incompatibilities, please forward a note |
|
53 describing the incompatibility verbal (i.e. no code) to the ST/X team. |
52 |
54 |
53 [author:] |
55 [author:] |
54 Claus Gittinger |
56 Claus Gittinger |
|
57 |
|
58 [see also:] |
|
59 View |
|
60 LayoutOrigin AlignmentOrigin Layout |
|
61 Rectangle Point |
55 " |
62 " |
56 ! |
63 ! |
57 |
64 |
58 examples |
65 examples |
59 " |
66 " |
60 |top button| |
67 Although the examples below use a button as component, |
61 |
68 they work of course with any type of subview .... |
62 top := StandardSystemView new. |
69 |
63 top extent:300@300. |
70 |
64 |
71 arrange for the button to be in 0.25 @ 0.25 -> 0.75 @ 0.75. |
65 button := Button label:'component'. |
72 This is the same as with relative origin/corner. |
66 top add:button in:(LayoutFrame new |
73 [exBegin] |
67 leftFraction:0.25; |
74 |top button| |
68 topFraction:0.25; |
75 |
69 rightFraction:0.75; |
76 top := StandardSystemView new. |
70 bottomFraction:0.75). |
77 top extent:300@300. |
71 |
78 |
72 top open |
79 button := Button label:'component'. |
|
80 top add:button in:(LayoutFrame new |
|
81 leftFraction:0.25; |
|
82 topFraction:0.25; |
|
83 rightFraction:0.75; |
|
84 bottomFraction:0.75). |
|
85 |
|
86 top open |
|
87 [exEnd] |
73 |
88 |
74 |
89 |
75 like above, but adds additional offset to the origin: |
90 like above, but adds additional offset to the origin: |
76 |
91 This is the same as with relative origin/corner |
77 |top button| |
92 and setting left & right insets. |
78 |
93 [exBegin] |
79 top := StandardSystemView new. |
94 |top button| |
80 top extent:300@300. |
95 |
81 |
96 top := StandardSystemView new. |
82 button := Button label:'component'. |
97 top extent:300@300. |
83 top add:button in:(LayoutFrame new |
98 |
84 leftFraction:0.25; leftOffset:10; |
99 button := Button label:'component'. |
85 topFraction:0.25; topOffset:-20; |
100 top add:button in:(LayoutFrame new |
86 rightFraction:0.75; |
101 leftFraction:0.25; leftOffset:10; |
87 bottomFraction:0.75). |
102 topFraction:0.25; topOffset:-20; |
88 |
103 rightFraction:0.75; |
89 top open |
104 bottomFraction:0.75). |
90 |
105 |
91 |
106 top open |
92 like above, with offsets on all edges, actually simulating |
107 [exEnd] |
93 a constant inset on all four edges: |
108 |
94 |
109 |
95 |top button| |
110 like above, with offsets on all edges, |
96 |
111 actually simulating a constant inset on all four edges: |
97 top := StandardSystemView new. |
112 [exBegin] |
98 top extent:300@300. |
113 |top button| |
99 |
114 |
100 button := Button label:'component'. |
115 top := StandardSystemView new. |
101 top add:button in:(LayoutFrame new |
116 top extent:300@300. |
102 leftFraction:0.0; leftOffset:10; |
117 |
103 topFraction:0.0; topOffset:10; |
118 button := Button label:'component'. |
104 rightFraction:1.0; rightOffset:-10; |
119 top add:button in:(LayoutFrame new |
105 bottomFraction:1.0; bottomOffset:-10). |
120 leftFraction:0.0; leftOffset:10; |
106 |
121 topFraction:0.0; topOffset:10; |
107 top open |
122 rightFraction:1.0; rightOffset:-10; |
|
123 bottomFraction:1.0; bottomOffset:-10). |
|
124 |
|
125 top open |
|
126 [exEnd] |
108 " |
127 " |
109 ! ! |
128 ! ! |
110 |
129 |
111 !LayoutFrame methodsFor:'accessing'! |
130 !LayoutFrame methodsFor:'accessing'! |
112 |
131 |
240 corner |
259 corner |
241 ^ rightFraction asFloat @ bottomFraction asFloat |
260 ^ rightFraction asFloat @ bottomFraction asFloat |
242 ! |
261 ! |
243 |
262 |
244 rectangleRelativeTo:superRectangle preferred:prefRect |
263 rectangleRelativeTo:superRectangle preferred:prefRect |
|
264 "compute the rectangle represented by the receiver, |
|
265 given the superViews rectangle and the views preferredExtent." |
|
266 |
245 |x1 y1 x2 y2| |
267 |x1 y1 x2 y2| |
246 |
268 |
247 leftOffset isNil ifTrue:[ |
269 leftOffset isNil ifTrue:[ |
248 x1 := 0 |
270 x1 := 0 |
249 ] ifFalse:[ |
271 ] ifFalse:[ |
250 x1 := leftOffset |
272 x1 := leftOffset |
251 ]. |
273 ]. |
252 topOffset isNil ifTrue:[ |
274 topOffset isNil ifTrue:[ |
253 y1 := 0 |
275 y1 := 0 |
254 ] ifFalse:[ |
276 ] ifFalse:[ |
255 y1 := topOffset |
277 y1 := topOffset |
256 ]. |
278 ]. |
257 rightOffset isNil ifTrue:[ |
279 rightOffset isNil ifTrue:[ |
258 x2 := 0 |
280 x2 := 0 |
259 ] ifFalse:[ |
281 ] ifFalse:[ |
260 x2 := rightOffset |
282 x2 := rightOffset |
261 ]. |
283 ]. |
262 bottomOffset isNil ifTrue:[ |
284 bottomOffset isNil ifTrue:[ |
263 y2 := 0 |
285 y2 := 0 |
264 ] ifFalse:[ |
286 ] ifFalse:[ |
265 y2 := bottomOffset |
287 y2 := bottomOffset |
266 ]. |
288 ]. |
267 leftFraction notNil ifTrue:[ |
289 leftFraction notNil ifTrue:[ |
268 x1 := x1 + (superRectangle width * leftFraction) |
290 x1 := x1 + (superRectangle width * leftFraction) |
269 ]. |
291 ]. |
270 topFraction notNil ifTrue:[ |
292 topFraction notNil ifTrue:[ |
271 y1 := y1 + (superRectangle height * topFraction) |
293 y1 := y1 + (superRectangle height * topFraction) |
272 ]. |
294 ]. |
273 rightFraction notNil ifTrue:[ |
295 rightFraction notNil ifTrue:[ |
274 x2 := x2 + (superRectangle width * rightFraction) |
296 x2 := x2 + (superRectangle width * rightFraction) |
275 ]. |
297 ]. |
276 bottomFraction notNil ifTrue:[ |
298 bottomFraction notNil ifTrue:[ |
277 y2 := y2 + (superRectangle height * bottomFraction) |
299 y2 := y2 + (superRectangle height * bottomFraction) |
278 ]. |
300 ]. |
279 ^ Rectangle origin:x1@y1 corner:x2@y2 |
301 ^ Rectangle origin:x1@y1 corner:x2@y2 |
280 |
302 |
281 " |
303 " |
282 |superRect lF| |
304 |superRect lF| |
283 |
305 |
284 superRect := 0@0 corner:100@100. |
306 superRect := 0@0 corner:100@100. |
285 lF := (LayoutFrame new). |
307 lF := (LayoutFrame new). |
286 lF leftFraction:0.25; |
308 lF leftFraction:0.25; |
287 topFraction:0.25; |
309 topFraction:0.25; |
288 rightFraction:0.75; |
310 rightFraction:0.75; |
289 bottomFraction:0.75. |
311 bottomFraction:0.75. |
290 lF rectangleRelativeTo:superRect preferred:(0@0 corner:30@30) |
312 lF rectangleRelativeTo:superRect preferred:(0@0 corner:30@30) |
291 " |
313 " |
|
314 |
|
315 "Modified: 27.4.1996 / 14:54:03 / cg" |
292 ! ! |
316 ! ! |
293 |
317 |
294 !LayoutFrame class methodsFor:'documentation'! |
318 !LayoutFrame class methodsFor:'documentation'! |
295 |
319 |
296 version |
320 version |
297 ^ '$Header: /cvs/stx/stx/libview2/Attic/LayoutFrm.st,v 1.12 1996-04-25 16:20:26 cg Exp $' |
321 ^ '$Header: /cvs/stx/stx/libview2/Attic/LayoutFrm.st,v 1.13 1996-04-27 17:50:45 cg Exp $' |
298 ! ! |
322 ! ! |