0
|
1 |
"
|
5
|
2 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
59
|
3 |
All Rights Reserved
|
0
|
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 |
"
|
|
12 |
|
|
13 |
PanelView subclass:#VerticalPanelView
|
|
14 |
instanceVariableNames:''
|
|
15 |
classVariableNames:''
|
|
16 |
poolDictionaries:''
|
|
17 |
category:'Views-Layout'
|
|
18 |
!
|
|
19 |
|
|
20 |
VerticalPanelView comment:'
|
5
|
21 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
59
|
22 |
All Rights Reserved
|
0
|
23 |
|
77
|
24 |
$Header: /cvs/stx/stx/libwidg/VerticalPanelView.st,v 1.8 1995-02-06 00:53:30 claus Exp $
|
38
|
25 |
'!
|
|
26 |
|
|
27 |
!VerticalPanelView class methodsFor:'documentation'!
|
|
28 |
|
|
29 |
copyright
|
|
30 |
"
|
|
31 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
59
|
32 |
All Rights Reserved
|
38
|
33 |
|
|
34 |
This software is furnished under a license and may be used
|
|
35 |
only in accordance with the terms of that license and with the
|
|
36 |
inclusion of the above copyright notice. This software may not
|
|
37 |
be provided or otherwise made available to, or used by, any
|
|
38 |
other person. No title to or ownership of the software is
|
|
39 |
hereby transferred.
|
|
40 |
"
|
|
41 |
!
|
|
42 |
|
|
43 |
version
|
|
44 |
"
|
77
|
45 |
$Header: /cvs/stx/stx/libwidg/VerticalPanelView.st,v 1.8 1995-02-06 00:53:30 claus Exp $
|
38
|
46 |
"
|
|
47 |
!
|
|
48 |
|
|
49 |
documentation
|
|
50 |
"
|
|
51 |
a View which arranges its child-views in a vertical column.
|
63
|
52 |
All real work is done in PanelView - except the layout computation is
|
38
|
53 |
redefined here.
|
|
54 |
|
77
|
55 |
The layout is controlled the instance variables:
|
|
56 |
horizontalLayout and verticalLayout
|
|
57 |
in addition to horizontalSpace and verticalSpace.
|
|
58 |
|
63
|
59 |
The vertical layout can be any of:
|
|
60 |
|
|
61 |
#top arrange elements at the top
|
|
62 |
#topSpace arrange elements at the top, start with spacing
|
|
63 |
#bottom arrange elements at the bottom
|
|
64 |
#bottomSpace arrange elements at the bottom, start with spacing
|
|
65 |
#center arrange elements in the center
|
|
66 |
#spread spread elements evenly
|
77
|
67 |
#spreadSpace spread elements evenly with spacing at ends
|
63
|
68 |
#fit like spread, but resize elements for tight packing
|
77
|
69 |
#fitSpace like fit, with spacing
|
63
|
70 |
|
|
71 |
the horizontal layout can be:
|
|
72 |
|
|
73 |
#left place element at the left
|
|
74 |
#leftSpace place element at the left, offset by horizontalSpace
|
|
75 |
#center place it horizontally centered
|
|
76 |
#right place it at the right
|
|
77 |
#rightSpace place it at the right, offset by horizontalSpace
|
|
78 |
#fit resize elements horizontally to fit this panel
|
77
|
79 |
#fitSpace like fit, but add spacing
|
63
|
80 |
|
77
|
81 |
The defaults is #center for both directions.
|
63
|
82 |
The layout is changed by the messages #verticalLayout: and #horizontalLayout:.
|
|
83 |
For backward compatibility (to times, where only vLayout existed), the simple
|
|
84 |
#layout: does the same as #verticalLayout:. Do not use this old method.
|
77
|
85 |
|
|
86 |
If none of these layout/space combinations is exactly what you need in
|
|
87 |
your application, create a subclass, and redefine the setChildPositions method.
|
63
|
88 |
"
|
|
89 |
!
|
|
90 |
|
|
91 |
examples
|
|
92 |
"
|
77
|
93 |
These examples demonstrate the effect of different layout
|
|
94 |
settings.
|
|
95 |
You should try more examples, combining spacing and different
|
|
96 |
verticalLayout:/horizontalLayout: combinations.
|
|
97 |
|
|
98 |
|
38
|
99 |
example: default layout (centered)
|
|
100 |
|
59
|
101 |
|v p b1 b2 b3|
|
38
|
102 |
|
59
|
103 |
v := StandardSystemView new.
|
|
104 |
p := VerticalPanelView in:v.
|
|
105 |
p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
|
|
106 |
b1 := Button label:'button1' in:p.
|
|
107 |
b2 := Button label:'button2' in:p.
|
|
108 |
b3 := Button label:'button3' in:p.
|
|
109 |
v extent:100 @ 300.
|
|
110 |
v open
|
38
|
111 |
|
0
|
112 |
|
63
|
113 |
example: top-layout
|
38
|
114 |
|
59
|
115 |
|v p b1 b2 b3|
|
38
|
116 |
|
59
|
117 |
v := StandardSystemView new.
|
|
118 |
p := VerticalPanelView in:v.
|
63
|
119 |
p verticalLayout:#top.
|
59
|
120 |
p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
|
|
121 |
b1 := Button label:'button1' in:p.
|
|
122 |
b2 := Button label:'button2' in:p.
|
|
123 |
b3 := Button label:'button3' in:p.
|
|
124 |
v extent:100 @ 300.
|
|
125 |
v open
|
38
|
126 |
|
|
127 |
|
77
|
128 |
example: top-layout; horizontal fit
|
|
129 |
|
|
130 |
|v p b1 b2 b3|
|
|
131 |
|
|
132 |
v := StandardSystemView new.
|
|
133 |
p := VerticalPanelView in:v.
|
|
134 |
p verticalLayout:#top.
|
|
135 |
p horizontalLayout:#fit.
|
|
136 |
p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
|
|
137 |
b1 := Button label:'button1' in:p.
|
|
138 |
b2 := Button label:'button2' in:p.
|
|
139 |
b3 := Button label:'button3' in:p.
|
|
140 |
v extent:100 @ 300.
|
|
141 |
v open
|
|
142 |
|
|
143 |
|
|
144 |
example: top-layout; horizontal fit with space
|
|
145 |
|
|
146 |
|v p b1 b2 b3|
|
|
147 |
|
|
148 |
v := StandardSystemView new.
|
|
149 |
p := VerticalPanelView in:v.
|
|
150 |
p verticalLayout:#top.
|
|
151 |
p horizontalLayout:#fitSpace.
|
|
152 |
p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
|
|
153 |
b1 := Button label:'button1' in:p.
|
|
154 |
b2 := Button label:'button2' in:p.
|
|
155 |
b3 := Button label:'button3' in:p.
|
|
156 |
v extent:100 @ 300.
|
|
157 |
v open
|
|
158 |
|
|
159 |
|
|
160 |
example: topSpace-layout
|
|
161 |
|
|
162 |
|v p b1 b2 b3|
|
|
163 |
|
|
164 |
v := StandardSystemView new.
|
|
165 |
p := VerticalPanelView in:v.
|
|
166 |
p verticalLayout:#topSpace.
|
|
167 |
p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
|
|
168 |
b1 := Button label:'button1' in:p.
|
|
169 |
b2 := Button label:'button2' in:p.
|
|
170 |
b3 := Button label:'button3' in:p.
|
|
171 |
v extent:100 @ 300.
|
|
172 |
v open
|
|
173 |
|
|
174 |
|
63
|
175 |
example: bottom-layout
|
38
|
176 |
|
59
|
177 |
|v p b1 b2 b3|
|
0
|
178 |
|
59
|
179 |
v := StandardSystemView new.
|
|
180 |
p := VerticalPanelView in:v.
|
63
|
181 |
p verticalLayout:#bottom.
|
59
|
182 |
p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
|
|
183 |
b1 := Button label:'button1' in:p.
|
|
184 |
b2 := Button label:'button2' in:p.
|
|
185 |
b3 := Button label:'button3' in:p.
|
|
186 |
v extent:100 @ 300.
|
|
187 |
v open
|
38
|
188 |
|
|
189 |
|
77
|
190 |
example: bottomSpace-layout
|
|
191 |
|
|
192 |
|v p b1 b2 b3|
|
|
193 |
|
|
194 |
v := StandardSystemView new.
|
|
195 |
p := VerticalPanelView in:v.
|
|
196 |
p verticalLayout:#bottomSpace.
|
|
197 |
p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
|
|
198 |
b1 := Button label:'button1' in:p.
|
|
199 |
b2 := Button label:'button2' in:p.
|
|
200 |
b3 := Button label:'button3' in:p.
|
|
201 |
v extent:100 @ 300.
|
|
202 |
v open
|
|
203 |
|
|
204 |
|
38
|
205 |
example: spread-layout
|
|
206 |
|
59
|
207 |
|v p b1 b2 b3|
|
38
|
208 |
|
59
|
209 |
v := StandardSystemView new.
|
|
210 |
p := VerticalPanelView in:v.
|
63
|
211 |
p verticalLayout:#spread.
|
|
212 |
p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
|
|
213 |
b1 := Button label:'button1' in:p.
|
|
214 |
b2 := Button label:'button2' in:p.
|
|
215 |
b3 := Button label:'button3' in:p.
|
|
216 |
v extent:100 @ 300.
|
|
217 |
v open
|
|
218 |
|
77
|
219 |
|
|
220 |
example: spreadSpace-layout
|
|
221 |
|
|
222 |
|v p b1 b2 b3|
|
|
223 |
|
|
224 |
v := StandardSystemView new.
|
|
225 |
p := VerticalPanelView in:v.
|
|
226 |
p verticalLayout:#spreadSpace.
|
|
227 |
p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
|
|
228 |
b1 := Button label:'button1' in:p.
|
|
229 |
b2 := Button label:'button2' in:p.
|
|
230 |
b3 := Button label:'button3' in:p.
|
|
231 |
v extent:100 @ 300.
|
|
232 |
v open
|
|
233 |
|
|
234 |
|
|
235 |
example: fit-layout
|
|
236 |
|
|
237 |
|v p b1 b2 b3|
|
|
238 |
|
|
239 |
v := StandardSystemView new.
|
|
240 |
p := VerticalPanelView in:v.
|
|
241 |
p verticalLayout:#fit.
|
|
242 |
p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
|
|
243 |
b1 := Button label:'button1' in:p.
|
|
244 |
b2 := Button label:'button2' in:p.
|
|
245 |
b3 := Button label:'button3' in:p.
|
|
246 |
v extent:100 @ 300.
|
|
247 |
v open
|
|
248 |
|
|
249 |
|
|
250 |
example: fitSpace-layout
|
|
251 |
|
|
252 |
|v p b1 b2 b3|
|
|
253 |
|
|
254 |
v := StandardSystemView new.
|
|
255 |
p := VerticalPanelView in:v.
|
|
256 |
p verticalLayout:#fitSpace.
|
|
257 |
p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
|
|
258 |
b1 := Button label:'button1' in:p.
|
|
259 |
b2 := Button label:'button2' in:p.
|
|
260 |
b3 := Button label:'button3' in:p.
|
|
261 |
v extent:100 @ 300.
|
|
262 |
v open
|
|
263 |
|
|
264 |
|
|
265 |
example: fully fitSpace
|
|
266 |
|
|
267 |
|v p b1 b2 b3|
|
|
268 |
|
|
269 |
v := StandardSystemView new.
|
|
270 |
p := VerticalPanelView in:v.
|
|
271 |
p verticalLayout:#fitSpace.
|
|
272 |
p horizontalLayout:#fitSpace.
|
|
273 |
p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
|
|
274 |
b1 := Button label:'button1' in:p.
|
|
275 |
b2 := Button label:'button2' in:p.
|
|
276 |
b3 := Button label:'button3' in:p.
|
|
277 |
v extent:100 @ 300.
|
|
278 |
v open
|
|
279 |
|
|
280 |
|
63
|
281 |
example: from top, each at left:
|
|
282 |
|
|
283 |
|v p b1 b2 b3|
|
|
284 |
|
|
285 |
v := StandardSystemView new.
|
|
286 |
p := VerticalPanelView in:v.
|
|
287 |
p verticalLayout:#top.
|
|
288 |
p horizontalLayout:#left.
|
|
289 |
p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
|
|
290 |
b1 := Button label:'button1' in:p.
|
|
291 |
b2 := Button label:'button2' in:p.
|
|
292 |
b3 := Button label:'button3' in:p.
|
|
293 |
v extent:100 @ 300.
|
|
294 |
v open
|
|
295 |
|
77
|
296 |
|
63
|
297 |
example: centered, right:
|
|
298 |
|
|
299 |
|v p b1 b2 b3|
|
|
300 |
|
|
301 |
v := StandardSystemView new.
|
|
302 |
p := VerticalPanelView in:v.
|
|
303 |
p verticalLayout:#centered.
|
|
304 |
p horizontalLayout:#right.
|
59
|
305 |
p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
|
|
306 |
b1 := Button label:'button1' in:p.
|
|
307 |
b2 := Button label:'button2' in:p.
|
|
308 |
b3 := Button label:'button3' in:p.
|
|
309 |
v extent:100 @ 300.
|
|
310 |
v open
|
63
|
311 |
|
77
|
312 |
|
|
313 |
example: a panel in a panel
|
|
314 |
|
|
315 |
|v hp p b1 b2 b3|
|
|
316 |
|
|
317 |
v := StandardSystemView new.
|
|
318 |
|
|
319 |
hp := HorizontalPanelView in:v.
|
|
320 |
hp verticalLayout:#fit.
|
|
321 |
hp horizontalLayout:#fitSpace.
|
|
322 |
hp origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
|
|
323 |
|
|
324 |
1 to:3 do:[:i |
|
|
325 |
p := VerticalPanelView in:hp.
|
|
326 |
p borderWidth:0.
|
|
327 |
p verticalLayout:#fitSpace.
|
|
328 |
p horizontalLayout:#fit.
|
|
329 |
b1 := Button label:'button1' in:p.
|
|
330 |
b2 := Button label:'button2' in:p.
|
|
331 |
b3 := Button label:'button3' in:p.
|
|
332 |
].
|
|
333 |
|
|
334 |
v extent:300 @ 100.
|
|
335 |
v open
|
38
|
336 |
"
|
|
337 |
! !
|
0
|
338 |
|
63
|
339 |
!VerticalPanelView methodsFor:'accessing'!
|
|
340 |
|
|
341 |
horizontalLayout
|
|
342 |
"return the horizontal layout as symbol.
|
|
343 |
the returned value is one of
|
|
344 |
#left
|
|
345 |
#leftSpace
|
|
346 |
#center
|
|
347 |
#right
|
|
348 |
#rightSpace
|
|
349 |
#fit
|
|
350 |
the default is #centered
|
|
351 |
"
|
|
352 |
|
|
353 |
^ hLayout
|
|
354 |
!
|
|
355 |
|
|
356 |
verticalLayout
|
|
357 |
"return the vertical layout as a symbol.
|
|
358 |
the returned value is one of
|
|
359 |
#top
|
|
360 |
#topSpace
|
|
361 |
#spread
|
|
362 |
#fit
|
|
363 |
#center
|
|
364 |
#bottom
|
|
365 |
#bottomSpace
|
|
366 |
the default is #centered
|
|
367 |
"
|
|
368 |
|
|
369 |
^ vLayout
|
|
370 |
!
|
|
371 |
|
|
372 |
horizontalLayout:aSymbol
|
|
373 |
"change the horizontal layout as symbol.
|
|
374 |
The argument, aSymbol must be one of:
|
|
375 |
#left
|
|
376 |
#leftSpace
|
|
377 |
#center
|
|
378 |
#right
|
|
379 |
#rightSpace
|
|
380 |
#fit
|
|
381 |
the default (if never changed) is #centered
|
|
382 |
"
|
|
383 |
|
|
384 |
(hLayout ~~ aSymbol) ifTrue:[
|
|
385 |
hLayout := aSymbol.
|
|
386 |
self layoutChanged
|
|
387 |
]
|
|
388 |
!
|
|
389 |
|
|
390 |
verticalLayout:aSymbol
|
|
391 |
"change the vertical layout as a symbol.
|
|
392 |
The argument, aSymbol must be one of:
|
|
393 |
#top
|
|
394 |
#topSpace
|
|
395 |
#spread
|
|
396 |
#fit
|
|
397 |
#center
|
|
398 |
#bottom
|
|
399 |
#bottomSpace
|
|
400 |
the default (if never changed) is #centered
|
|
401 |
"
|
|
402 |
|
|
403 |
(vLayout ~~ aSymbol) ifTrue:[
|
|
404 |
vLayout := aSymbol.
|
|
405 |
self layoutChanged
|
|
406 |
]
|
|
407 |
!
|
|
408 |
|
|
409 |
layout
|
|
410 |
"leftover for historic reasons - do not use any more"
|
|
411 |
|
|
412 |
self verticalLayout
|
|
413 |
!
|
|
414 |
|
|
415 |
layout:aSymbol
|
|
416 |
"leftover for historic reasons - do not use any more"
|
|
417 |
|
|
418 |
self verticalLayout:aSymbol
|
|
419 |
! !
|
|
420 |
|
|
421 |
|
0
|
422 |
!VerticalPanelView methodsFor:'queries'!
|
|
423 |
|
|
424 |
preferedExtent
|
|
425 |
"return a good extent, one that makes subviews fit"
|
|
426 |
|
59
|
427 |
|sumOfHeights maxWidth maxHeight|
|
0
|
428 |
|
|
429 |
subViews isNil ifTrue:[^ horizontalSpace @ verticalSpace].
|
|
430 |
|
|
431 |
"compute net height needed"
|
|
432 |
|
|
433 |
sumOfHeights := 0.
|
|
434 |
maxWidth := 0.
|
65
|
435 |
maxHeight := 0.
|
0
|
436 |
|
|
437 |
subViews do:[:child |
|
63
|
438 |
|childsPreference|
|
|
439 |
|
|
440 |
childsPreference := child preferedExtent.
|
|
441 |
sumOfHeights := sumOfHeights + childsPreference y.
|
|
442 |
maxHeight := maxHeight max:childsPreference y.
|
|
443 |
maxWidth := maxWidth max:childsPreference x.
|
|
444 |
|
|
445 |
"/ sumOfHeights := sumOfHeights + child heightIncludingBorder.
|
|
446 |
"/ maxWidth := maxWidth max:(child widthIncludingBorder).
|
|
447 |
"/ maxHeight := maxHeight max:(child heightIncludingBorder).
|
0
|
448 |
].
|
|
449 |
borderWidth ~~ 0 ifTrue:[
|
59
|
450 |
sumOfHeights := sumOfHeights + (horizontalSpace * 2).
|
|
451 |
maxWidth := maxWidth + (horizontalSpace * 2).
|
0
|
452 |
].
|
77
|
453 |
(vLayout == #fit or:[vLayout == #fitSpace]) ifTrue:[
|
65
|
454 |
sumOfHeights := maxHeight * subViews size.
|
|
455 |
borderWidth ~~ 0 ifTrue:[
|
|
456 |
sumOfHeights := sumOfHeights + (verticalSpace * 2).
|
|
457 |
]
|
|
458 |
] ifFalse:[
|
|
459 |
sumOfHeights := sumOfHeights + ((subViews size - 1) * verticalSpace).
|
|
460 |
].
|
0
|
461 |
|
65
|
462 |
((hLayout == #leftSpace) or:[hLayout == #rightSpace]) ifTrue:[
|
|
463 |
maxWidth := maxWidth + horizontalSpace
|
|
464 |
] ifFalse:[
|
77
|
465 |
((hLayout == #fitSpace) or:[hLayout == #center]) ifTrue:[
|
65
|
466 |
maxWidth := maxWidth + (horizontalSpace * 2)
|
|
467 |
]
|
|
468 |
].
|
0
|
469 |
^ maxWidth @ sumOfHeights
|
|
470 |
! !
|
|
471 |
|
|
472 |
!VerticalPanelView methodsFor:'layout'!
|
|
473 |
|
|
474 |
setChildPositions
|
|
475 |
"(re)compute position of every child"
|
|
476 |
|
77
|
477 |
|ypos space sumOfHeights numChilds l hEach hInside|
|
0
|
478 |
|
|
479 |
subViews isNil ifTrue:[^ self].
|
|
480 |
|
|
481 |
space := verticalSpace.
|
63
|
482 |
numChilds := subViews size.
|
77
|
483 |
hInside := height - (margin * 2) + (borderWidth*2) - subViews last borderWidth.
|
0
|
484 |
|
77
|
485 |
vLayout == #fitSpace ifTrue:[
|
59
|
486 |
"
|
|
487 |
adjust childs extents and set origins.
|
|
488 |
Be careful to avoid accumulation of rounding errors
|
|
489 |
"
|
77
|
490 |
hEach := (hInside - (numChilds + 1 * space)) / numChilds.
|
59
|
491 |
ypos := space + margin - borderWidth.
|
63
|
492 |
] ifFalse:[
|
77
|
493 |
vLayout == #fit ifTrue:[
|
63
|
494 |
"
|
77
|
495 |
adjust childs extents and set origins.
|
|
496 |
Be careful to avoid accumulation of rounding errors
|
63
|
497 |
"
|
77
|
498 |
hEach := (hInside - (numChilds - 1 * space)) / numChilds.
|
|
499 |
ypos := margin - borderWidth.
|
63
|
500 |
] ifFalse:[
|
77
|
501 |
"
|
|
502 |
compute net height needed
|
|
503 |
"
|
|
504 |
sumOfHeights := subViews inject:0 into:[:sumSoFar :child | sumSoFar + child heightIncludingBorder].
|
|
505 |
|
|
506 |
l := vLayout.
|
|
507 |
((l == #center) and:[numChilds == 1]) ifTrue:[
|
|
508 |
l := #spread
|
|
509 |
].
|
|
510 |
(l == #spread and:[numChilds == 1]) ifTrue:[
|
|
511 |
l := #spreadSpace
|
|
512 |
].
|
59
|
513 |
|
77
|
514 |
"
|
|
515 |
compute position of topmost subview and space between them;
|
|
516 |
if they do hardly fit, leave no space between them
|
|
517 |
"
|
|
518 |
(sumOfHeights >= (height - (margin * 2))) ifTrue:[
|
|
519 |
"
|
|
520 |
if we have not enough space for all the elements,
|
|
521 |
fill them tight, and show what can be shown (at least)
|
|
522 |
"
|
|
523 |
ypos := 0.
|
|
524 |
space := 0
|
|
525 |
] ifFalse:[
|
|
526 |
((l == #bottom) or:[l == #bottomSpace]) ifTrue:[
|
|
527 |
ypos := height - (space * (numChilds - 1)) - sumOfHeights.
|
|
528 |
"
|
|
529 |
borderWidth == 0 ifTrue:[
|
|
530 |
ypos := ypos + space
|
|
531 |
].
|
|
532 |
"
|
|
533 |
l == #bottomSpace ifTrue:[
|
|
534 |
ypos >= space ifTrue:[
|
|
535 |
ypos := ypos - space
|
|
536 |
]
|
|
537 |
].
|
|
538 |
|
|
539 |
ypos < 0 ifTrue:[
|
|
540 |
space := space min:(height - sumOfHeights) // (numChilds + 1).
|
|
541 |
ypos := height - (space * numChilds) - sumOfHeights.
|
63
|
542 |
]
|
|
543 |
] ifFalse: [
|
77
|
544 |
(l == #spread) ifTrue:[
|
|
545 |
space := (height - sumOfHeights) // (numChilds - 1).
|
|
546 |
ypos := 0.
|
|
547 |
(space == 0) ifTrue:[
|
|
548 |
ypos := (height - sumOfHeights) // 2
|
|
549 |
]
|
|
550 |
] ifFalse: [
|
|
551 |
(l == #spreadSpace) ifTrue:[
|
|
552 |
space := (height - sumOfHeights) // (numChilds + 1).
|
|
553 |
ypos := space.
|
|
554 |
(space == 0) ifTrue:[
|
|
555 |
ypos := (height - sumOfHeights) // 2
|
|
556 |
]
|
|
557 |
] ifFalse: [
|
|
558 |
((l == #top) or:[l == #topSpace]) ifTrue:[
|
|
559 |
space := space min:(height - sumOfHeights) // (numChilds + 1).
|
|
560 |
l == #topSpace ifTrue:[
|
|
561 |
ypos := space.
|
|
562 |
] ifFalse:[
|
|
563 |
ypos := 0
|
|
564 |
]
|
63
|
565 |
] ifFalse:[
|
77
|
566 |
"center"
|
|
567 |
ypos := (height - (sumOfHeights
|
|
568 |
+ ((numChilds - 1) * space))) // 2.
|
|
569 |
ypos < 0 ifTrue:[
|
|
570 |
space := (height - sumOfHeights) // (numChilds + 1).
|
|
571 |
ypos := (height - (sumOfHeights
|
|
572 |
+ ((numChilds - 1) * space))) // 2.
|
|
573 |
]
|
63
|
574 |
]
|
77
|
575 |
]
|
63
|
576 |
]
|
|
577 |
]
|
77
|
578 |
].
|
63
|
579 |
].
|
|
580 |
].
|
|
581 |
|
|
582 |
"
|
|
583 |
now set positions
|
|
584 |
"
|
|
585 |
subViews do:[:child |
|
|
586 |
|xpos|
|
|
587 |
|
|
588 |
hLayout == #left ifTrue:[
|
|
589 |
xpos := 0
|
|
590 |
] ifFalse:[
|
|
591 |
hLayout == #leftSpace ifTrue:[
|
|
592 |
xpos := horizontalSpace
|
|
593 |
] ifFalse:[
|
|
594 |
hLayout == #right ifTrue:[
|
|
595 |
xpos := width - child widthIncludingBorder
|
|
596 |
] ifFalse:[
|
|
597 |
hLayout == #rightSpace ifTrue:[
|
|
598 |
xpos := width - horizontalSpace - child widthIncludingBorder.
|
|
599 |
] ifFalse:[
|
77
|
600 |
hLayout == #fitSpace ifTrue:[
|
63
|
601 |
xpos := horizontalSpace.
|
|
602 |
child width:(width - (horizontalSpace + child borderWidth * 2))
|
|
603 |
] ifFalse:[
|
77
|
604 |
hLayout == #fit ifTrue:[
|
|
605 |
xpos := 0.
|
|
606 |
child width:(width - (child borderWidth * 2))
|
|
607 |
] ifFalse:[
|
|
608 |
"centered"
|
|
609 |
xpos := (width - child widthIncludingBorder) // 2.
|
|
610 |
]
|
63
|
611 |
]
|
|
612 |
]
|
|
613 |
]
|
|
614 |
]
|
|
615 |
].
|
|
616 |
(xpos < 0) ifTrue:[ xpos := 0 ].
|
|
617 |
|
77
|
618 |
(vLayout == #fit or:[vLayout == #fitSpace]) ifTrue:[
|
59
|
619 |
child origin:(xpos @ ypos rounded)
|
|
620 |
corner:(xpos + (child width))
|
|
621 |
@ (ypos + hEach - (child borderWidth)) rounded.
|
77
|
622 |
ypos := ypos + hEach + space
|
63
|
623 |
] ifFalse:[
|
|
624 |
child origin:(xpos@ypos).
|
|
625 |
ypos := ypos + (child heightIncludingBorder) + space
|
59
|
626 |
]
|
0
|
627 |
]
|
|
628 |
! !
|