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:#HorizontalPanelView
|
|
14 |
instanceVariableNames:''
|
|
15 |
classVariableNames:''
|
|
16 |
poolDictionaries:''
|
|
17 |
category:'Views-Layout'
|
|
18 |
!
|
|
19 |
|
|
20 |
HorizontalPanelView comment:'
|
5
|
21 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
59
|
22 |
All Rights Reserved
|
0
|
23 |
|
155
|
24 |
$Header: /cvs/stx/stx/libwidg/HorizontalPanelView.st,v 1.15 1995-09-07 12:45:02 claus Exp $
|
38
|
25 |
'!
|
|
26 |
|
|
27 |
!HorizontalPanelView 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 |
"
|
155
|
45 |
$Header: /cvs/stx/stx/libwidg/HorizontalPanelView.st,v 1.15 1995-09-07 12:45:02 claus Exp $
|
38
|
46 |
"
|
|
47 |
!
|
|
48 |
|
|
49 |
documentation
|
|
50 |
"
|
|
51 |
a View which arranges its child-views in a horizontal row.
|
|
52 |
All real work is done in PanelView - only the layout computation is
|
|
53 |
redefined here.
|
|
54 |
|
77
|
55 |
The layout is controlled the instance variables:
|
|
56 |
horizontalLayout and verticalLayout
|
127
|
57 |
in addition to
|
|
58 |
horizontalSpace and verticalSpace.
|
77
|
59 |
|
133
|
60 |
HorizontalSpace and verticalSpace control the spacing between elements;
|
|
61 |
they default to some 1mm.
|
|
62 |
|
62
|
63 |
The horizontal layout can be any of:
|
|
64 |
|
|
65 |
#left arrange elements at the left
|
|
66 |
#leftSpace arrange elements at the left, start with spacing
|
118
|
67 |
#fixLeft same as #left, but do not reduce spacing in case of no fit
|
|
68 |
#fixLeftSpace same as #leftSpace, but do not reduce spacing in case of no fit
|
62
|
69 |
#right arrange elements at the right
|
|
70 |
#rightSpace arrange elements at the right, start with spacing
|
|
71 |
#center arrange elements in the center
|
|
72 |
#spread spread elements evenly
|
77
|
73 |
#spreadSpace spread elements evenly with spacing at the ends
|
133
|
74 |
#fit like #spread, but resize elements for tight packing
|
|
75 |
#fitSpace like #fit, with additional spacing at the far ends
|
|
76 |
#leftFit like #left, but extend the last element to the right
|
|
77 |
#leftSpaceFit like #leftSpace, but extend the last element to the right
|
|
78 |
|
|
79 |
#leftMax like corresponding non-Max layouts,
|
|
80 |
#leftSpaceMax but resize all components to width of widest components
|
|
81 |
#rightMax
|
|
82 |
#rightSpaceMax
|
|
83 |
#centerMax
|
|
84 |
#spreadMax
|
|
85 |
#spreadSpaceMax
|
62
|
86 |
|
|
87 |
the vertical layout can be:
|
|
88 |
|
|
89 |
#top place element at the top
|
|
90 |
#topSpace place element at the top, offset by verticalSpace
|
|
91 |
#center place it horizontally centered
|
|
92 |
#bottom place it at the bottom
|
|
93 |
#bottomSpace place it at the bottom, offset by verticalSpace
|
|
94 |
#fit resize elements vertically to fit this panel
|
133
|
95 |
#fitSpace like #fit, but with spacing
|
|
96 |
|
|
97 |
#topMax like #top, but resize all views vertically to max height
|
|
98 |
#topSpaceMax like #topSpace, but resize all views vertically to max height
|
|
99 |
#bottomMax like #bottom, but resize all views vertically to max height
|
|
100 |
#bottomSpaceMax like #bottomSpace, but resize all views vertically to max height
|
|
101 |
#centerMax like #center, but resize all views vertically to max height
|
62
|
102 |
|
77
|
103 |
The defaults is #center for both directions.
|
62
|
104 |
The layout is changed by the messages #verticalLayout: and #horizontalLayout:.
|
|
105 |
For backward compatibility (to times, where only hLayout existed), the simple
|
133
|
106 |
#layout: does the same as #horizontalLayout:.
|
|
107 |
Do not use this old method; it will vanish and currently outpus a warning.
|
77
|
108 |
|
127
|
109 |
The panel assumes, that the elements do not resize themselfes, after it
|
|
110 |
became visible. This is not true for all widgets (buttons or labels may
|
|
111 |
like to change). If you have changing elements, tell this to the panel
|
|
112 |
with 'aPanel elementsChangeSize:true'. In that case, the panel will react
|
133
|
113 |
to size changes of its elements, and reorganize things.
|
127
|
114 |
|
118
|
115 |
By combining Horizontal- and VerticalPanels (i.e. place a hPanel into a
|
|
116 |
vPanel), most layouts should be implementable.
|
133
|
117 |
However, iff none of these layout/space combinations is exactly what you need
|
118
|
118 |
in your application, create a subclass, and redefine the setChildPositions
|
|
119 |
method there.
|
125
|
120 |
|
|
121 |
TODO: for completeness, support #fixRight, #fixRightSpace,
|
|
122 |
#rightFit, #rightSpaceFit layouts
|
127
|
123 |
|
|
124 |
CAVEAT: this class started with #left and no vertical alignments;
|
133
|
125 |
as time went by, more layouts were added (by users requests)
|
|
126 |
and noew, many layout combinations are possible.
|
|
127 |
Reflecting this, the setup should be changed to use different selectors
|
|
128 |
for space-on/off, max-resize and alignment
|
127
|
129 |
(i.e. having more and more layout symbols makes things a bit confusing ...)
|
62
|
130 |
"
|
|
131 |
!
|
|
132 |
|
|
133 |
examples
|
|
134 |
"
|
77
|
135 |
These examples show the effect of various horizontalLayout and
|
|
136 |
verticalLayout settings. Try them all. Especially, notice the
|
|
137 |
differences between the xxx and xxxSpace layouts and the effect of
|
|
138 |
setting different values for the spacing.
|
|
139 |
Try resizing the view and see how the elements get rearranged.
|
|
140 |
|
118
|
141 |
Most of the examples below place 3 buttons onto a panel; Of course,
|
|
142 |
you can put any other view into a panel ... the last examples show this.
|
77
|
143 |
|
|
144 |
|
127
|
145 |
example: default layout (center)
|
38
|
146 |
|
59
|
147 |
|v p b1 b2 b3|
|
38
|
148 |
|
59
|
149 |
v := StandardSystemView new.
|
118
|
150 |
v label:'default: center'.
|
77
|
151 |
|
59
|
152 |
p := HorizontalPanelView in:v.
|
|
153 |
p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
|
|
154 |
b1 := Button label:'button1' in:p.
|
|
155 |
b2 := Button label:'button2' in:p.
|
|
156 |
b3 := Button label:'button3' in:p.
|
|
157 |
v extent:300 @ 100.
|
|
158 |
v open
|
38
|
159 |
|
0
|
160 |
|
133
|
161 |
example: same (default center layout) with different sized elements
|
|
162 |
|
|
163 |
|v p b1 b2 b3|
|
|
164 |
|
|
165 |
v := StandardSystemView new.
|
|
166 |
v label:'default: center'.
|
|
167 |
|
|
168 |
p := HorizontalPanelView in:v.
|
|
169 |
p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
|
|
170 |
b1 := Button label:'but1' in:p. b1 font:(b1 font size:8).
|
|
171 |
b2 := Button label:'b2' in:p. b2 font:(b1 font size:24).
|
|
172 |
b3 := Button label:'button3' in:p.
|
|
173 |
v extent:300 @ 100.
|
|
174 |
v open
|
|
175 |
|
|
176 |
|
|
177 |
example: horizontal default (center); vertical centerMax
|
|
178 |
|
|
179 |
|v p b1 b2 b3|
|
|
180 |
|
|
181 |
v := StandardSystemView new.
|
|
182 |
v label:'vL=centerMax'.
|
|
183 |
p := HorizontalPanelView in:v.
|
|
184 |
p verticalLayout:#centerMax.
|
|
185 |
p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
|
|
186 |
b1 := Button label:'but1' in:p. b1 font:(b1 font size:8).
|
|
187 |
b2 := Button label:'b2' in:p. b2 font:(b1 font size:24).
|
|
188 |
b3 := Button label:'button3' in:p.
|
|
189 |
v extent:300 @ 100.
|
|
190 |
v open
|
|
191 |
|
|
192 |
|
|
193 |
example: horizontal default (center); vertical topMax
|
|
194 |
|
|
195 |
|v p b1 b2 b3|
|
|
196 |
|
|
197 |
v := StandardSystemView new.
|
|
198 |
v label:'vL=topMax'.
|
|
199 |
p := HorizontalPanelView in:v.
|
|
200 |
p verticalLayout:#topMax.
|
|
201 |
p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
|
|
202 |
b1 := Button label:'but1' in:p. b1 font:(b1 font size:8).
|
|
203 |
b2 := Button label:'b2' in:p. b2 font:(b1 font size:24).
|
|
204 |
b3 := Button label:'button3' in:p.
|
|
205 |
v extent:300 @ 100.
|
|
206 |
v open
|
|
207 |
|
|
208 |
|
|
209 |
example: horizontal default (center); vertical topSpaceMax
|
|
210 |
|
|
211 |
|v p b1 b2 b3|
|
|
212 |
|
|
213 |
v := StandardSystemView new.
|
|
214 |
v label:'vL=topSpaceMax'.
|
|
215 |
p := HorizontalPanelView in:v.
|
|
216 |
p verticalLayout:#topSpaceMax.
|
|
217 |
p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
|
|
218 |
b1 := Button label:'but1' in:p. b1 font:(b1 font size:8).
|
|
219 |
b2 := Button label:'b2' in:p. b2 font:(b1 font size:24).
|
|
220 |
b3 := Button label:'button3' in:p.
|
|
221 |
v extent:300 @ 100.
|
|
222 |
v open
|
|
223 |
|
|
224 |
|
|
225 |
example: horizontal default (center); vertical bottomMax
|
|
226 |
|
|
227 |
|v p b1 b2 b3|
|
|
228 |
|
|
229 |
v := StandardSystemView new.
|
|
230 |
v label:'vL=bottomMax'.
|
|
231 |
p := HorizontalPanelView in:v.
|
|
232 |
p verticalLayout:#bottomMax.
|
|
233 |
p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
|
|
234 |
b1 := Button label:'but1' in:p. b1 font:(b1 font size:8).
|
|
235 |
b2 := Button label:'b2' in:p. b2 font:(b1 font size:24).
|
|
236 |
b3 := Button label:'button3' in:p.
|
|
237 |
v extent:300 @ 100.
|
|
238 |
v open
|
|
239 |
|
|
240 |
|
|
241 |
example: horizontal default (center); vertical bottomSpaceMax
|
|
242 |
|
|
243 |
|v p b1 b2 b3|
|
|
244 |
|
|
245 |
v := StandardSystemView new.
|
|
246 |
v label:'vL=bottomSpaceMax'.
|
|
247 |
p := HorizontalPanelView in:v.
|
|
248 |
p verticalLayout:#bottomSpaceMax.
|
|
249 |
p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
|
|
250 |
b1 := Button label:'but1' in:p. b1 font:(b1 font size:8).
|
|
251 |
b2 := Button label:'b2' in:p. b2 font:(b1 font size:24).
|
|
252 |
b3 := Button label:'button3' in:p.
|
|
253 |
v extent:300 @ 100.
|
|
254 |
v open
|
|
255 |
|
|
256 |
|
127
|
257 |
example: left-layout (vertical is default -> center)
|
38
|
258 |
|
59
|
259 |
|v p b1 b2 b3|
|
38
|
260 |
|
59
|
261 |
v := StandardSystemView new.
|
|
262 |
p := HorizontalPanelView in:v.
|
118
|
263 |
v label:'hL=left; vL=default (center)'.
|
77
|
264 |
|
62
|
265 |
p horizontalLayout:#left.
|
59
|
266 |
p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
|
|
267 |
b1 := Button label:'button1' in:p.
|
|
268 |
b2 := Button label:'button2' in:p.
|
|
269 |
b3 := Button label:'button3' in:p.
|
|
270 |
v extent:300 @ 100.
|
|
271 |
v open
|
38
|
272 |
|
|
273 |
|
127
|
274 |
example: left starting with spacing (vertical is default -> center)
|
77
|
275 |
|
|
276 |
|v p b1 b2 b3|
|
|
277 |
|
|
278 |
v := StandardSystemView new.
|
|
279 |
p := HorizontalPanelView in:v.
|
118
|
280 |
v label:'hL=leftSpace; vL=center'.
|
77
|
281 |
|
|
282 |
p horizontalLayout:#leftSpace.
|
|
283 |
p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
|
|
284 |
b1 := Button label:'button1' in:p.
|
|
285 |
b2 := Button label:'button2' in:p.
|
|
286 |
b3 := Button label:'button3' in:p.
|
|
287 |
v extent:300 @ 100.
|
|
288 |
v open
|
|
289 |
|
|
290 |
|
127
|
291 |
example: leftFit-layout (vertical is default -> center)
|
38
|
292 |
|
59
|
293 |
|v p b1 b2 b3|
|
0
|
294 |
|
59
|
295 |
v := StandardSystemView new.
|
|
296 |
p := HorizontalPanelView in:v.
|
118
|
297 |
v label:'hL=leftFit; vL=center'.
|
77
|
298 |
|
|
299 |
p horizontalLayout:#leftFit.
|
|
300 |
p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
|
|
301 |
b1 := Button label:'button1' in:p.
|
|
302 |
b2 := Button label:'button2' in:p.
|
|
303 |
b3 := Button label:'button3' in:p.
|
|
304 |
v extent:300 @ 100.
|
|
305 |
v open
|
|
306 |
|
|
307 |
|
127
|
308 |
example: leftSpaceFit-layout (vertical is default -> center)
|
77
|
309 |
|
|
310 |
|v p b1 b2 b3|
|
|
311 |
|
|
312 |
v := StandardSystemView new.
|
|
313 |
p := HorizontalPanelView in:v.
|
118
|
314 |
v label:'hL=leftSpaceFit; vL=center'.
|
77
|
315 |
|
|
316 |
p horizontalLayout:#leftSpaceFit.
|
|
317 |
p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
|
|
318 |
b1 := Button label:'button1' in:p.
|
|
319 |
b2 := Button label:'button2' in:p.
|
|
320 |
b3 := Button label:'button3' in:p.
|
|
321 |
v extent:300 @ 100.
|
|
322 |
v open
|
|
323 |
|
|
324 |
|
127
|
325 |
example: right-layout (vertical is default -> center)
|
77
|
326 |
|
|
327 |
|v p b1 b2 b3|
|
|
328 |
|
|
329 |
v := StandardSystemView new.
|
|
330 |
p := HorizontalPanelView in:v.
|
118
|
331 |
v label:'hL=right; vL=center'.
|
77
|
332 |
|
62
|
333 |
p horizontalLayout:#right.
|
59
|
334 |
p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
|
|
335 |
b1 := Button label:'button1' in:p.
|
|
336 |
b2 := Button label:'button2' in:p.
|
|
337 |
b3 := Button label:'button3' in:p.
|
|
338 |
v extent:300 @ 100.
|
|
339 |
v open
|
38
|
340 |
|
|
341 |
|
127
|
342 |
example: right with initial spacing (vertical is default -> center)
|
77
|
343 |
|
|
344 |
|v p b1 b2 b3|
|
|
345 |
|
|
346 |
v := StandardSystemView new.
|
|
347 |
p := HorizontalPanelView in:v.
|
118
|
348 |
v label:'hL=rightSpace; vL=center'.
|
77
|
349 |
|
|
350 |
p horizontalLayout:#rightSpace.
|
|
351 |
p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
|
|
352 |
b1 := Button label:'button1' in:p.
|
|
353 |
b2 := Button label:'button2' in:p.
|
|
354 |
b3 := Button label:'button3' in:p.
|
|
355 |
v extent:300 @ 100.
|
|
356 |
v open
|
|
357 |
|
|
358 |
|
127
|
359 |
example: fit-layout (vertical is default -> center)
|
38
|
360 |
|
59
|
361 |
|v p b1 b2 b3|
|
38
|
362 |
|
59
|
363 |
v := StandardSystemView new.
|
|
364 |
p := HorizontalPanelView in:v.
|
77
|
365 |
p horizontalLayout:#fit.
|
118
|
366 |
v label:'hL=fit; vL=center'.
|
77
|
367 |
|
|
368 |
p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
|
|
369 |
b1 := Button label:'button1' in:p.
|
|
370 |
b2 := Button label:'button2' in:p.
|
|
371 |
b3 := Button label:'button3' in:p.
|
|
372 |
v extent:300 @ 100.
|
|
373 |
v open
|
|
374 |
|
|
375 |
|
127
|
376 |
example: full fit i.e. no spacing (vertical is default -> center)
|
77
|
377 |
|
|
378 |
|v p b1 b2 b3|
|
|
379 |
|
|
380 |
v := StandardSystemView new.
|
|
381 |
p := HorizontalPanelView in:v.
|
|
382 |
p horizontalLayout:#fit.
|
|
383 |
p horizontalSpace:0.
|
118
|
384 |
v label:'hL=fit hS=0; vL=center'.
|
77
|
385 |
|
|
386 |
p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
|
|
387 |
b1 := Button label:'button1' in:p.
|
|
388 |
b2 := Button label:'button2' in:p.
|
|
389 |
b3 := Button label:'button3' in:p.
|
|
390 |
v extent:300 @ 100.
|
|
391 |
v open
|
|
392 |
|
|
393 |
|
127
|
394 |
example: fit with spacing (vertical is default -> center)
|
77
|
395 |
|
|
396 |
|v p b1 b2 b3|
|
|
397 |
|
|
398 |
v := StandardSystemView new.
|
|
399 |
p := HorizontalPanelView in:v.
|
118
|
400 |
v label:'hL=fitSpace; vL=center'.
|
77
|
401 |
|
|
402 |
p horizontalLayout:#fitSpace.
|
62
|
403 |
p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
|
|
404 |
b1 := Button label:'button1' in:p.
|
|
405 |
b2 := Button label:'button2' in:p.
|
|
406 |
b3 := Button label:'button3' in:p.
|
|
407 |
v extent:300 @ 100.
|
|
408 |
v open
|
|
409 |
|
77
|
410 |
|
127
|
411 |
example: spread-layout (vertical is default -> center)
|
77
|
412 |
|
|
413 |
|v p b1 b2 b3|
|
|
414 |
|
|
415 |
v := StandardSystemView new.
|
|
416 |
p := HorizontalPanelView in:v.
|
|
417 |
p horizontalLayout:#spread.
|
118
|
418 |
v label:'hL=spread; vL=center'.
|
77
|
419 |
|
|
420 |
p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
|
|
421 |
b1 := Button label:'button1' in:p.
|
|
422 |
b2 := Button label:'button2' in:p.
|
|
423 |
b3 := Button label:'button3' in:p.
|
|
424 |
v extent:300 @ 100.
|
|
425 |
v open
|
|
426 |
|
|
427 |
|
127
|
428 |
example: spread with spacing (vertical is default -> center)
|
77
|
429 |
|
|
430 |
|v p b1 b2 b3|
|
|
431 |
|
|
432 |
v := StandardSystemView new.
|
|
433 |
p := HorizontalPanelView in:v.
|
118
|
434 |
v label:'hL=spreadSpace; vL=center'.
|
77
|
435 |
|
|
436 |
p horizontalLayout:#spreadSpace.
|
|
437 |
p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
|
|
438 |
b1 := Button label:'button1' in:p.
|
|
439 |
b2 := Button label:'button2' in:p.
|
|
440 |
b3 := Button label:'button3' in:p.
|
|
441 |
v extent:300 @ 100.
|
|
442 |
v open
|
|
443 |
|
|
444 |
|
|
445 |
example: spread with spacing; vertical fit
|
|
446 |
|
|
447 |
|v p b1 b2 b3|
|
|
448 |
|
|
449 |
v := StandardSystemView new.
|
|
450 |
p := HorizontalPanelView in:v.
|
118
|
451 |
v label:'hL=spreadSpace; vL=fit'.
|
77
|
452 |
|
|
453 |
p horizontalLayout:#spreadSpace.
|
|
454 |
p verticalLayout:#fit.
|
|
455 |
p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
|
|
456 |
b1 := Button label:'button1' in:p.
|
|
457 |
b2 := Button label:'button2' in:p.
|
|
458 |
b3 := Button label:'button3' in:p.
|
|
459 |
v extent:300 @ 100.
|
|
460 |
v open
|
|
461 |
|
|
462 |
|
|
463 |
example: spread with spacing; vertical fit with spacing
|
|
464 |
|
|
465 |
|v p b1 b2 b3|
|
|
466 |
|
|
467 |
v := StandardSystemView new.
|
|
468 |
p := HorizontalPanelView in:v.
|
118
|
469 |
v label:'hL=spreadSpace; vL=fitSpace'.
|
77
|
470 |
|
|
471 |
p horizontalLayout:#spreadSpace.
|
|
472 |
p verticalLayout:#fitSpace.
|
|
473 |
p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
|
|
474 |
b1 := Button label:'button1' in:p.
|
|
475 |
b2 := Button label:'button2' in:p.
|
|
476 |
b3 := Button label:'button3' in:p.
|
|
477 |
v extent:300 @ 100.
|
|
478 |
v open
|
|
479 |
|
|
480 |
|
62
|
481 |
example: fit - top
|
|
482 |
|
|
483 |
|v p b1 b2 b3|
|
|
484 |
|
|
485 |
v := StandardSystemView new.
|
|
486 |
p := HorizontalPanelView in:v.
|
118
|
487 |
v label:'hL=fit; vL=top'.
|
77
|
488 |
|
62
|
489 |
p horizontalLayout:#fit.
|
|
490 |
p verticalLayout:#top.
|
|
491 |
p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
|
|
492 |
b1 := Button label:'button1' in:p.
|
|
493 |
b2 := Button label:'button2' in:p.
|
|
494 |
b3 := Button label:'button3' in:p.
|
|
495 |
v extent:300 @ 100.
|
|
496 |
v open
|
|
497 |
|
77
|
498 |
|
|
499 |
example: fit with initial spacing
|
|
500 |
|
|
501 |
|v p b1 b2 b3|
|
|
502 |
|
|
503 |
v := StandardSystemView new.
|
|
504 |
p := HorizontalPanelView in:v.
|
118
|
505 |
v label:'hL=fitSpace; vL=top'.
|
77
|
506 |
|
|
507 |
p horizontalLayout:#fitSpace.
|
|
508 |
p verticalLayout:#top.
|
|
509 |
p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
|
|
510 |
b1 := Button label:'button1' in:p.
|
|
511 |
b2 := Button label:'button2' in:p.
|
|
512 |
b3 := Button label:'button3' in:p.
|
|
513 |
v extent:300 @ 100.
|
|
514 |
v open
|
|
515 |
|
|
516 |
|
|
517 |
example: fit with initial spacing in both directions
|
|
518 |
|
|
519 |
|v p b1 b2 b3|
|
|
520 |
|
|
521 |
v := StandardSystemView new.
|
|
522 |
p := HorizontalPanelView in:v.
|
118
|
523 |
v label:'hL=fitSpace; vL=fitSpace'.
|
77
|
524 |
|
|
525 |
p horizontalLayout:#fitSpace.
|
|
526 |
p verticalLayout:#fitSpace.
|
|
527 |
p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
|
|
528 |
b1 := Button label:'button1' in:p.
|
|
529 |
b2 := Button label:'button2' in:p.
|
|
530 |
b3 := Button label:'button3' in:p.
|
|
531 |
v extent:300 @ 100.
|
|
532 |
v open
|
|
533 |
|
|
534 |
|
|
535 |
example: fit without spacing in both directions
|
|
536 |
|
|
537 |
|v p b1 b2 b3|
|
|
538 |
|
|
539 |
v := StandardSystemView new.
|
|
540 |
p := HorizontalPanelView in:v.
|
118
|
541 |
v label:'hL=fit hS=0; vL=fit'.
|
77
|
542 |
|
|
543 |
p horizontalLayout:#fit.
|
|
544 |
p verticalLayout:#fit.
|
|
545 |
p horizontalSpace:0.
|
|
546 |
p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
|
|
547 |
b1 := Button label:'button1' in:p.
|
|
548 |
b2 := Button label:'button2' in:p.
|
|
549 |
b3 := Button label:'button3' in:p.
|
|
550 |
v extent:300 @ 100.
|
|
551 |
v open
|
|
552 |
|
|
553 |
|
|
554 |
example: fit with initial spacing; top with spacing
|
|
555 |
|
|
556 |
|v p b1 b2 b3|
|
|
557 |
|
|
558 |
v := StandardSystemView new.
|
|
559 |
p := HorizontalPanelView in:v.
|
118
|
560 |
v label:'hL=fitSpace; vL=topSpace'.
|
77
|
561 |
|
|
562 |
p horizontalLayout:#fitSpace.
|
|
563 |
p verticalLayout:#topSpace.
|
|
564 |
p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
|
|
565 |
b1 := Button label:'button1' in:p.
|
|
566 |
b2 := Button label:'button2' in:p.
|
|
567 |
b3 := Button label:'button3' in:p.
|
|
568 |
v extent:300 @ 100.
|
|
569 |
v open
|
|
570 |
|
|
571 |
|
62
|
572 |
example: fit - top without spacing
|
|
573 |
|
|
574 |
|v p b1 b2 b3|
|
|
575 |
|
|
576 |
v := StandardSystemView new.
|
|
577 |
p := HorizontalPanelView in:v.
|
118
|
578 |
v label:'hL=fit; vL=top'.
|
77
|
579 |
|
62
|
580 |
p horizontalLayout:#fit.
|
|
581 |
p verticalLayout:#top.
|
|
582 |
p horizontalSpace:0.
|
|
583 |
p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
|
|
584 |
b1 := Button label:'button1' in:p.
|
|
585 |
b2 := Button label:'button2' in:p.
|
|
586 |
b3 := Button label:'button3' in:p.
|
|
587 |
v extent:300 @ 100.
|
|
588 |
v open
|
|
589 |
|
77
|
590 |
|
62
|
591 |
example: fit - bottom with spacing and bottomSpace
|
|
592 |
|
|
593 |
|v p b1 b2 b3|
|
|
594 |
|
|
595 |
v := StandardSystemView new.
|
|
596 |
p := HorizontalPanelView in:v.
|
118
|
597 |
v label:'hL=fitSpace; vL=bottomSpace'.
|
77
|
598 |
|
|
599 |
p horizontalLayout:#fitSpace.
|
62
|
600 |
p verticalLayout:#bottomSpace.
|
|
601 |
p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
|
|
602 |
b1 := Button label:'button1' in:p.
|
|
603 |
b2 := Button label:'button2' in:p.
|
|
604 |
b3 := Button label:'button3' in:p.
|
|
605 |
v extent:300 @ 100.
|
|
606 |
v open
|
|
607 |
|
77
|
608 |
|
62
|
609 |
example: fit no horizontal space - bottom with spacing and bottomSpace
|
|
610 |
|
|
611 |
|v p b1 b2 b3|
|
|
612 |
|
|
613 |
v := StandardSystemView new.
|
|
614 |
p := HorizontalPanelView in:v.
|
118
|
615 |
v label:'hL=fit; vL=bottomSpace'.
|
77
|
616 |
|
62
|
617 |
p horizontalLayout:#fit.
|
|
618 |
p verticalLayout:#bottomSpace.
|
|
619 |
p horizontalSpace:0.
|
59
|
620 |
p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
|
|
621 |
b1 := Button label:'button1' in:p.
|
|
622 |
b2 := Button label:'button2' in:p.
|
|
623 |
b3 := Button label:'button3' in:p.
|
|
624 |
v extent:300 @ 100.
|
|
625 |
v open
|
77
|
626 |
|
133
|
627 |
example: leftMax - vertical default
|
|
628 |
|
|
629 |
|v p b1 b2 b3|
|
|
630 |
|
|
631 |
v := StandardSystemView new.
|
|
632 |
p := HorizontalPanelView in:v.
|
|
633 |
v label:'hL=leftMax; vL=default'.
|
|
634 |
|
|
635 |
p horizontalLayout:#leftMax.
|
|
636 |
p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
|
|
637 |
b1 := Button label:'button1' in:p.
|
|
638 |
b2 := Button label:'b2' in:p.
|
|
639 |
b3 := Button label:'but3' in:p.
|
|
640 |
v extent:300 @ 100.
|
|
641 |
v open
|
|
642 |
|
|
643 |
|
|
644 |
example: leftSpaceMax - vertical default
|
|
645 |
|
|
646 |
|v p b1 b2 b3|
|
|
647 |
|
|
648 |
v := StandardSystemView new.
|
|
649 |
p := HorizontalPanelView in:v.
|
|
650 |
v label:'hL=leftSpaceMax; vL=default'.
|
|
651 |
|
|
652 |
p horizontalLayout:#leftSpaceMax.
|
|
653 |
p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
|
|
654 |
b1 := Button label:'button1' in:p.
|
|
655 |
b2 := Button label:'b2' in:p.
|
|
656 |
b3 := Button label:'but3' in:p.
|
|
657 |
v extent:300 @ 100.
|
|
658 |
v open
|
|
659 |
|
|
660 |
|
|
661 |
example: rightMax - vertical default
|
|
662 |
|
|
663 |
|v p b1 b2 b3|
|
|
664 |
|
|
665 |
v := StandardSystemView new.
|
|
666 |
p := HorizontalPanelView in:v.
|
|
667 |
v label:'hL=rightMax; vL=default'.
|
|
668 |
|
|
669 |
p horizontalLayout:#rightMax.
|
|
670 |
p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
|
|
671 |
b1 := Button label:'button1' in:p.
|
|
672 |
b2 := Button label:'b2' in:p.
|
|
673 |
b3 := Button label:'but3' in:p.
|
|
674 |
v extent:300 @ 100.
|
|
675 |
v open
|
|
676 |
|
|
677 |
|
|
678 |
example: rightSpaceMax - vertical default
|
|
679 |
|
|
680 |
|v p b1 b2 b3|
|
|
681 |
|
|
682 |
v := StandardSystemView new.
|
|
683 |
p := HorizontalPanelView in:v.
|
|
684 |
v label:'hL=rightSpaceMax; vL=default'.
|
|
685 |
|
|
686 |
p horizontalLayout:#rightSpaceMax.
|
|
687 |
p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
|
|
688 |
b1 := Button label:'button1' in:p.
|
|
689 |
b2 := Button label:'b2' in:p.
|
|
690 |
b3 := Button label:'but3' in:p.
|
|
691 |
v extent:300 @ 100.
|
|
692 |
v open
|
|
693 |
|
|
694 |
|
|
695 |
example: centerMax - vertical default
|
|
696 |
|
|
697 |
|v p b1 b2 b3|
|
|
698 |
|
|
699 |
v := StandardSystemView new.
|
|
700 |
p := HorizontalPanelView in:v.
|
|
701 |
v label:'hL=centerMax; vL=default'.
|
|
702 |
|
|
703 |
p horizontalLayout:#centerMax.
|
|
704 |
p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
|
|
705 |
b1 := Button label:'button1' in:p.
|
|
706 |
b2 := Button label:'b2' in:p.
|
|
707 |
b3 := Button label:'but3' in:p.
|
|
708 |
v extent:300 @ 100.
|
|
709 |
v open
|
|
710 |
|
|
711 |
|
|
712 |
example: spreadMax - vertical default
|
|
713 |
|
|
714 |
|v p b1 b2 b3|
|
|
715 |
|
|
716 |
v := StandardSystemView new.
|
|
717 |
p := HorizontalPanelView in:v.
|
|
718 |
v label:'hL=spreadMax; vL=default'.
|
|
719 |
|
|
720 |
p horizontalLayout:#spreadMax.
|
|
721 |
p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
|
|
722 |
b1 := Button label:'button1' in:p.
|
|
723 |
b2 := Button label:'b2' in:p.
|
|
724 |
b3 := Button label:'but3' in:p.
|
|
725 |
v extent:300 @ 100.
|
|
726 |
v open
|
|
727 |
|
|
728 |
|
|
729 |
example: spreadSpaceMax - vertical default
|
|
730 |
|
|
731 |
|v p b1 b2 b3|
|
|
732 |
|
|
733 |
v := StandardSystemView new.
|
|
734 |
p := HorizontalPanelView in:v.
|
|
735 |
v label:'hL=spreadSpaceMax; vL=default'.
|
|
736 |
|
|
737 |
p horizontalLayout:#spreadSpaceMax.
|
|
738 |
p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
|
|
739 |
b1 := Button label:'button1' in:p.
|
|
740 |
b2 := Button label:'b2' in:p.
|
|
741 |
b3 := Button label:'but3' in:p.
|
|
742 |
v extent:300 @ 100.
|
|
743 |
v open
|
|
744 |
|
|
745 |
|
|
746 |
example: maximize elements in both directions and center
|
|
747 |
|
|
748 |
|v p b1 b2 b3|
|
|
749 |
|
|
750 |
v := StandardSystemView new.
|
|
751 |
v label:'hL=centerMax; vL=centerMax'.
|
|
752 |
|
|
753 |
p := HorizontalPanelView in:v.
|
|
754 |
p horizontalLayout:#centerMax.
|
|
755 |
p verticalLayout:#centerMax.
|
|
756 |
p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
|
|
757 |
b1 := Button label:'but1' in:p. b1 font:(b1 font size:8).
|
|
758 |
b2 := Button label:'b2' in:p. b2 font:(b1 font size:24).
|
|
759 |
b3 := Button label:'button3' in:p.
|
|
760 |
v extent:300 @ 100.
|
|
761 |
v open
|
|
762 |
|
|
763 |
|
118
|
764 |
example: placing hPanels into a vPanel
|
|
765 |
|
|
766 |
|v vP hP1 hP2 hP3 b1 b2 b3 b4 b5 b6 b7 b8 b9|
|
|
767 |
|
|
768 |
v := StandardSystemView new.
|
|
769 |
vP := VerticalPanelView in:v.
|
|
770 |
vP origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
|
|
771 |
vP verticalLayout:#fit;
|
|
772 |
verticalSpace:0;
|
|
773 |
horizontalLayout:#fit.
|
|
774 |
|
|
775 |
hP1 := HorizontalPanelView in:vP.
|
|
776 |
hP1 horizontalLayout:#fitSpace;
|
|
777 |
verticalLayout:#center.
|
|
778 |
b1 := Button label:'button1' in:hP1.
|
|
779 |
b2 := Button label:'button2' in:hP1.
|
|
780 |
b3 := Button label:'button3' in:hP1.
|
|
781 |
|
|
782 |
hP2 := HorizontalPanelView in:vP.
|
|
783 |
hP2 horizontalLayout:#fitSpace;
|
|
784 |
verticalLayout:#center.
|
|
785 |
b4 := Button label:'button4' in:hP2.
|
|
786 |
b5 := Button label:'button5' in:hP2.
|
|
787 |
b6 := Button label:'button6' in:hP2.
|
|
788 |
|
|
789 |
hP3 := HorizontalPanelView in:vP.
|
|
790 |
hP3 horizontalLayout:#fitSpace;
|
|
791 |
verticalLayout:#center.
|
|
792 |
b7 := Button label:'button7' in:hP3.
|
|
793 |
b8 := Button label:'button8' in:hP3.
|
|
794 |
b9 := Button label:'button9' in:hP3.
|
|
795 |
|
|
796 |
v extent:300 @ 300.
|
|
797 |
v open
|
|
798 |
|
77
|
799 |
example: a browser like table, where the rightmost list
|
|
800 |
extends to the far right.
|
|
801 |
|
|
802 |
|v p l1 l2 l3|
|
|
803 |
|
|
804 |
v := StandardSystemView new.
|
|
805 |
p := HorizontalPanelView in:v.
|
125
|
806 |
v label:'hL=leftFit hS=0; vL=fit'.
|
77
|
807 |
|
|
808 |
p horizontalLayout:#leftFit.
|
125
|
809 |
p horizontalSpace:0.
|
77
|
810 |
p verticalLayout:#fit.
|
|
811 |
p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
|
|
812 |
|
|
813 |
l1 := ScrollableView for:FileSelectionList in:p.
|
|
814 |
l1 stayInDirectory:true.
|
|
815 |
l1 ignoreParentDirectory:true.
|
|
816 |
l1 directory:'/'.
|
|
817 |
l1 action:[:selection | l2 directory:(l1 selectedPathname)].
|
|
818 |
|
|
819 |
l2 := ScrollableView for:FileSelectionList in:p.
|
|
820 |
l2 stayInDirectory:true.
|
|
821 |
l2 directory:nil.
|
|
822 |
l2 ignoreParentDirectory:true.
|
|
823 |
l2 action:[:selection | l3 directory:(l2 selectedPathname)].
|
|
824 |
|
|
825 |
l3 := ScrollableView for:FileSelectionList in:p.
|
|
826 |
l3 directory:nil.
|
118
|
827 |
l3 ignoreParentDirectory:false.
|
77
|
828 |
v extent:400 @ 300.
|
|
829 |
v open
|
125
|
830 |
|
|
831 |
|
|
832 |
trouble example: self resizing elements may cause trouble
|
|
833 |
|
|
834 |
|v p l1 l2 l3|
|
|
835 |
|
|
836 |
v := StandardSystemView new.
|
|
837 |
p := HorizontalPanelView origin:(0.0 @ 0.0) corner:(1.0 @ 1.0) in:v.
|
|
838 |
|
|
839 |
l1 := (Label label:'one' in:p) level:-1.
|
|
840 |
l2 := (Label label:'two' in:p) level:-1.
|
|
841 |
l3 := (Label label:'three' in:p) level:-1.
|
|
842 |
|
|
843 |
v extent:400 @ 300.
|
|
844 |
v open.
|
|
845 |
|
|
846 |
(Delay forSeconds:5) wait.
|
|
847 |
|
|
848 |
l1 label:'oneone'.
|
|
849 |
l2 label:'twotwo'.
|
|
850 |
l3 label:'threethree'.
|
|
851 |
|
|
852 |
|
|
853 |
fixed trouble example: tell the panel that this situation may happen
|
|
854 |
|
|
855 |
|v p l1 l2 l3|
|
|
856 |
|
|
857 |
v := StandardSystemView new.
|
|
858 |
p := HorizontalPanelView origin:(0.0 @ 0.0) corner:(1.0 @ 1.0) in:v.
|
|
859 |
p elementsChangeSize:true.
|
|
860 |
|
|
861 |
l1 := (Label label:'one' in:p) level:-1.
|
|
862 |
l2 := (Label label:'two' in:p) level:-1.
|
|
863 |
l3 := (Label label:'three' in:p) level:-1.
|
|
864 |
|
|
865 |
v extent:400 @ 300.
|
|
866 |
v open.
|
|
867 |
|
|
868 |
(Delay forSeconds:5) wait.
|
|
869 |
|
|
870 |
l1 label:'oneone'.
|
|
871 |
l2 label:'twotwo'.
|
|
872 |
l3 label:'threethree'.
|
38
|
873 |
"
|
|
874 |
! !
|
0
|
875 |
|
62
|
876 |
!HorizontalPanelView methodsFor:'accessing'!
|
|
877 |
|
|
878 |
horizontalLayout
|
|
879 |
"return the horizontal layout as symbol.
|
|
880 |
the returned value is one of
|
133
|
881 |
#left arrange elements at the left
|
|
882 |
#leftSpace arrange elements at the left, start with spacing
|
|
883 |
#fixLeft same as #left, but do not reduce spacing in case of no fit
|
|
884 |
#fixLeftSpace same as #leftSpace, but do not reduce spacing in case of no fit
|
|
885 |
#right arrange elements at the right
|
|
886 |
#rightSpace arrange elements at the right, start with spacing
|
|
887 |
#center arrange elements in the center
|
|
888 |
#spread spread elements evenly
|
|
889 |
#spreadSpace spread elements evenly with spacing at the ends
|
|
890 |
#fit like #spread, but resize elements for tight packing
|
|
891 |
#fitSpace like #fit, with additional spacing at the far ends
|
|
892 |
#leftFit like #left, but extend the last element to the right
|
|
893 |
#leftSpaceFit like #leftSpace, but extend the last element to the right
|
77
|
894 |
the default is #center
|
118
|
895 |
See the class documentation for the meanings.
|
62
|
896 |
"
|
|
897 |
|
|
898 |
^ hLayout
|
|
899 |
!
|
|
900 |
|
|
901 |
verticalLayout
|
|
902 |
"return the vertical layout as a symbol.
|
|
903 |
the returned value is one of
|
133
|
904 |
#top place element at the top
|
|
905 |
#topSpace place element at the top, offset by verticalSpace
|
|
906 |
#center place it horizontally centered
|
|
907 |
#bottom place it at the bottom
|
|
908 |
#bottomSpace place it at the bottom, offset by verticalSpace
|
|
909 |
#fit resize elements vertically to fit this panel
|
|
910 |
#fitSpace like #fit, but with spacing
|
|
911 |
|
|
912 |
#topMax like #top, but resize all views vertically to max height
|
|
913 |
#topSpaceMax like #topSpace, but resize all views vertically to max height
|
|
914 |
#bottomMax like #bottom, but resize all views vertically to max height
|
|
915 |
#bottomSpaceMax like #bottomSpace, but resize all views vertically to max height
|
|
916 |
#centerMax like #center, but resize all views vertically to max height
|
77
|
917 |
the default is #center
|
118
|
918 |
See the class documentation for the meanings.
|
62
|
919 |
"
|
|
920 |
|
|
921 |
^ vLayout
|
|
922 |
!
|
|
923 |
|
|
924 |
horizontalLayout:aSymbol
|
|
925 |
"change the horizontal layout as symbol.
|
|
926 |
The argument, aSymbol must be one of:
|
133
|
927 |
#left arrange elements at the left
|
|
928 |
#leftSpace arrange elements at the left, start with spacing
|
|
929 |
#fixLeft same as #left, but do not reduce spacing in case of no fit
|
|
930 |
#fixLeftSpace same as #leftSpace, but do not reduce spacing in case of no fit
|
|
931 |
#right arrange elements at the right
|
|
932 |
#rightSpace arrange elements at the right, start with spacing
|
|
933 |
#center arrange elements in the center
|
|
934 |
#spread spread elements evenly
|
|
935 |
#spreadSpace spread elements evenly with spacing at the ends
|
|
936 |
#fit like #spread, but resize elements for tight packing
|
|
937 |
#fitSpace like #fit, with additional spacing at the far ends
|
|
938 |
#leftFit like #left, but extend the last element to the right
|
|
939 |
#leftSpaceFit like #leftSpace, but extend the last element to the right
|
118
|
940 |
the default (if never changed) is #center.
|
|
941 |
See the class documentation for the meanings.
|
62
|
942 |
"
|
|
943 |
|
|
944 |
(hLayout ~~ aSymbol) ifTrue:[
|
|
945 |
hLayout := aSymbol.
|
|
946 |
self layoutChanged
|
|
947 |
]
|
|
948 |
!
|
|
949 |
|
|
950 |
verticalLayout:aSymbol
|
|
951 |
"change the vertical layout as a symbol.
|
|
952 |
The argument, aSymbol must be one of:
|
133
|
953 |
#top place element at the top
|
|
954 |
#topSpace place element at the top, offset by verticalSpace
|
|
955 |
#center place it horizontally centered
|
|
956 |
#bottom place it at the bottom
|
|
957 |
#bottomSpace place it at the bottom, offset by verticalSpace
|
|
958 |
#fit resize elements vertically to fit this panel
|
|
959 |
#fitSpace like #fit, but with spacing
|
|
960 |
|
|
961 |
#topMax like #top, but resize all views vertically to max height
|
|
962 |
#topSpaceMax like #topSpace, but resize all views vertically to max height
|
|
963 |
#bottomMax like #bottom, but resize all views vertically to max height
|
|
964 |
#bottomSpaceMax like #bottomSpace, but resize all views vertically to max height
|
|
965 |
#centerMax like #center, but resize all views vertically to max height
|
77
|
966 |
the default (if never changed) is #center
|
118
|
967 |
See the class documentation for the meanings.
|
62
|
968 |
"
|
|
969 |
|
|
970 |
(vLayout ~~ aSymbol) ifTrue:[
|
|
971 |
vLayout := aSymbol.
|
|
972 |
self layoutChanged
|
|
973 |
]
|
|
974 |
!
|
|
975 |
|
|
976 |
layout
|
|
977 |
"leftover for historic reasons - do not use any more"
|
|
978 |
|
130
|
979 |
self obsoleteMethodWarning:'use #horizontalLayout'.
|
|
980 |
^ self horizontalLayout
|
62
|
981 |
!
|
|
982 |
|
155
|
983 |
layout:something
|
|
984 |
"OBSOLETE compatibility interface. Will vanish.
|
|
985 |
leftover for historic reasons - do not use any more.
|
|
986 |
In the meantime, try to figure out what is meant ... a kludge"
|
|
987 |
|
|
988 |
something isLayout ifTrue:[^ super layout:something].
|
62
|
989 |
|
130
|
990 |
self obsoleteMethodWarning:'use #horizontalLayout:'.
|
155
|
991 |
^ self horizontalLayout:something
|
|
992 |
|
|
993 |
"Modified: 31.8.1995 / 23:07:33 / claus"
|
62
|
994 |
! !
|
|
995 |
|
|
996 |
|
0
|
997 |
!HorizontalPanelView methodsFor:'queries'!
|
|
998 |
|
130
|
999 |
preferredExtent
|
0
|
1000 |
"return a good extent, one that makes subviews fit"
|
|
1001 |
|
59
|
1002 |
|sumOfWidths maxHeight maxWidth|
|
0
|
1003 |
|
|
1004 |
subViews isNil ifTrue:[^ horizontalSpace @ verticalSpace].
|
|
1005 |
|
|
1006 |
"compute net height needed"
|
|
1007 |
|
|
1008 |
sumOfWidths := 0.
|
|
1009 |
maxHeight := 0.
|
59
|
1010 |
maxWidth := 0.
|
0
|
1011 |
|
|
1012 |
subViews do:[:child |
|
62
|
1013 |
|childsPreference|
|
|
1014 |
|
133
|
1015 |
"/ better to use component's preferredExtent ...
|
|
1016 |
|
130
|
1017 |
childsPreference := child preferredExtent.
|
62
|
1018 |
sumOfWidths := sumOfWidths + childsPreference x.
|
|
1019 |
maxHeight := maxHeight max:childsPreference y.
|
|
1020 |
maxWidth := maxWidth max:childsPreference x.
|
|
1021 |
|
133
|
1022 |
"/ ... instead of actual extent
|
62
|
1023 |
"/ sumOfWidths := sumOfWidths + child widthIncludingBorder.
|
|
1024 |
"/ maxHeight := maxHeight max:(child heightIncludingBorder).
|
|
1025 |
"/ maxWidth := maxWidth max:(child widthIncludingBorder).
|
0
|
1026 |
].
|
|
1027 |
borderWidth ~~ 0 ifTrue:[
|
59
|
1028 |
sumOfWidths := sumOfWidths + (horizontalSpace * 2).
|
|
1029 |
maxHeight := maxHeight + (verticalSpace * 2).
|
0
|
1030 |
].
|
133
|
1031 |
(hLayout == #fit
|
|
1032 |
or:[hLayout == #fitSpace
|
|
1033 |
or:[hLayout endsWith:'Max']]) ifTrue:[
|
59
|
1034 |
sumOfWidths := maxWidth * subViews size.
|
|
1035 |
borderWidth ~~ 0 ifTrue:[
|
131
|
1036 |
sumOfWidths := sumOfWidths + (horizontalSpace * 2).
|
59
|
1037 |
]
|
|
1038 |
] ifFalse:[
|
|
1039 |
sumOfWidths := sumOfWidths + ((subViews size - 1) * horizontalSpace).
|
131
|
1040 |
hLayout == #leftSpace ifTrue:[
|
|
1041 |
sumOfWidths := sumOfWidths + horizontalSpace
|
|
1042 |
] ifFalse:[
|
|
1043 |
((hLayout == #center) or:[hLayout == #spread]) ifTrue:[
|
|
1044 |
sumOfWidths := sumOfWidths + (horizontalSpace * 2)
|
|
1045 |
]
|
|
1046 |
].
|
59
|
1047 |
].
|
0
|
1048 |
|
65
|
1049 |
((vLayout == #topSpace) or:[vLayout == #bottomSpace]) ifTrue:[
|
|
1050 |
maxHeight := maxHeight + verticalSpace
|
|
1051 |
] ifFalse:[
|
77
|
1052 |
((vLayout == #fitSpace) or:[vLayout == #center]) ifTrue:[
|
65
|
1053 |
maxHeight := maxHeight + (verticalSpace * 2)
|
|
1054 |
]
|
|
1055 |
].
|
|
1056 |
|
0
|
1057 |
^ sumOfWidths @ maxHeight
|
|
1058 |
! !
|
|
1059 |
|
|
1060 |
!HorizontalPanelView methodsFor:'layout'!
|
|
1061 |
|
|
1062 |
setChildPositions
|
|
1063 |
"(re)compute position of every child whenever childs are added or
|
|
1064 |
my size has changed"
|
|
1065 |
|
133
|
1066 |
|xpos space sumOfWidths numChilds l wEach wInside hL vL resizeToMaxV
|
|
1067 |
resizeToMaxH maxHeight maxWidth|
|
0
|
1068 |
|
|
1069 |
subViews isNil ifTrue:[^ self].
|
|
1070 |
|
|
1071 |
space := horizontalSpace.
|
59
|
1072 |
numChilds := subViews size.
|
77
|
1073 |
wInside := width - (margin * 2) + (borderWidth*2) - subViews last borderWidth.
|
59
|
1074 |
|
118
|
1075 |
hL := hLayout.
|
|
1076 |
vL := vLayout.
|
|
1077 |
|
133
|
1078 |
resizeToMaxH := false.
|
|
1079 |
(hL endsWith:'Max') ifTrue:[
|
|
1080 |
wEach := maxWidth := subViews inject:0 into:[:maxSoFar :child | maxSoFar max:child widthIncludingBorder].
|
|
1081 |
hL := (hL copyWithoutLast:3) asSymbol.
|
|
1082 |
resizeToMaxH := true.
|
|
1083 |
].
|
|
1084 |
|
118
|
1085 |
hL == #fitSpace ifTrue:[
|
59
|
1086 |
"
|
|
1087 |
adjust childs extents and set origins.
|
|
1088 |
Be careful to avoid accumulation of rounding errors
|
|
1089 |
"
|
77
|
1090 |
wEach := (wInside - (numChilds + 1 * space)) / numChilds.
|
59
|
1091 |
xpos := space + margin - borderWidth.
|
62
|
1092 |
] ifFalse:[
|
118
|
1093 |
hL == #fit ifTrue:[
|
77
|
1094 |
"
|
|
1095 |
adjust childs extents and set origins.
|
|
1096 |
Be careful to avoid accumulation of rounding errors
|
|
1097 |
"
|
|
1098 |
wEach := (wInside - (numChilds - 1 * space)) / numChilds.
|
|
1099 |
xpos := margin - borderWidth.
|
|
1100 |
] ifFalse:[
|
|
1101 |
"
|
|
1102 |
compute net width needed
|
|
1103 |
"
|
133
|
1104 |
resizeToMaxH ifTrue:[
|
|
1105 |
sumOfWidths := subViews inject:0 into:[:sumSoFar :child | sumSoFar + maxWidth + (child borderWidth*2)].
|
|
1106 |
] ifFalse:[
|
|
1107 |
sumOfWidths := subViews inject:0 into:[:sumSoFar :child | sumSoFar + child widthIncludingBorder].
|
|
1108 |
].
|
62
|
1109 |
|
118
|
1110 |
l := hL.
|
77
|
1111 |
((l == #center) and:[numChilds == 1]) ifTrue:[
|
|
1112 |
l := #spread
|
|
1113 |
].
|
|
1114 |
(l == #spread and:[numChilds == 1]) ifTrue:[
|
|
1115 |
l := #spreadSpace
|
|
1116 |
].
|
0
|
1117 |
|
77
|
1118 |
"
|
|
1119 |
compute position of leftmost subview and space between them;
|
|
1120 |
if they do hardly fit, leave no space between them
|
|
1121 |
"
|
118
|
1122 |
((sumOfWidths >= (width - (margin * 2)))
|
|
1123 |
and:[l ~~ #fixLeftSpace and:[l ~~ #fixLeft]]) ifTrue:[
|
77
|
1124 |
xpos := 0.
|
|
1125 |
space := 0
|
|
1126 |
] ifFalse: [
|
118
|
1127 |
l == #fixLeftSpace ifTrue:[
|
|
1128 |
l := #leftSpace
|
|
1129 |
] ifFalse:[
|
|
1130 |
l == #fixLeft ifTrue:[
|
|
1131 |
l := #left
|
|
1132 |
]
|
|
1133 |
].
|
77
|
1134 |
((l == #right) or:[l == #rightSpace]) ifTrue:[
|
|
1135 |
xpos := width - (space * (numChilds - 1)) - sumOfWidths.
|
62
|
1136 |
"
|
77
|
1137 |
borderWidth == 0 ifTrue:[
|
|
1138 |
xpos := xpos + space
|
|
1139 |
].
|
|
1140 |
"
|
|
1141 |
l == #rightSpace ifTrue:[
|
|
1142 |
xpos >= space ifTrue:[
|
|
1143 |
xpos := xpos - space
|
|
1144 |
]
|
|
1145 |
].
|
62
|
1146 |
|
77
|
1147 |
xpos < 0 ifTrue:[
|
|
1148 |
space := space min:(width - sumOfWidths) // (numChilds + 1).
|
|
1149 |
xpos := width - (space * numChilds) - sumOfWidths.
|
59
|
1150 |
]
|
|
1151 |
] ifFalse:[
|
77
|
1152 |
(l == #spread) ifTrue:[
|
|
1153 |
space := (width - sumOfWidths) // (numChilds - 1).
|
|
1154 |
xpos := 0.
|
|
1155 |
(space == 0) ifTrue:[
|
|
1156 |
xpos := (width - sumOfWidths) // 2
|
|
1157 |
]
|
|
1158 |
] ifFalse:[
|
|
1159 |
(l == #spreadSpace) ifTrue:[
|
|
1160 |
space := (width - sumOfWidths) // (numChilds + 1).
|
|
1161 |
xpos := space.
|
|
1162 |
(space == 0) ifTrue:[
|
|
1163 |
xpos := (width - sumOfWidths) // 2
|
62
|
1164 |
]
|
77
|
1165 |
] ifFalse:[
|
|
1166 |
((l == #left)
|
|
1167 |
or:[l == #leftSpace
|
|
1168 |
or:[l == #leftFit
|
|
1169 |
or:[l == #leftSpaceFit]]]) ifTrue:[
|
|
1170 |
space := space min:(width - sumOfWidths) // (numChilds + 1).
|
118
|
1171 |
(hL == #fixLeft or:[hL == #fixLeftSpace]) ifTrue:[
|
|
1172 |
space := space max:horizontalSpace.
|
|
1173 |
] ifFalse:[
|
|
1174 |
space := space max:0.
|
|
1175 |
].
|
77
|
1176 |
(l == #leftSpace
|
|
1177 |
or:[l == #leftSpaceFit]) ifTrue:[
|
|
1178 |
xpos := space.
|
|
1179 |
] ifFalse:[
|
|
1180 |
xpos := 0
|
|
1181 |
]
|
|
1182 |
"
|
|
1183 |
borderWidth == 0 ifTrue:[
|
|
1184 |
xpos := 0
|
|
1185 |
].
|
|
1186 |
"
|
|
1187 |
] ifFalse:[
|
|
1188 |
"center"
|
62
|
1189 |
xpos := (width - (sumOfWidths
|
77
|
1190 |
+ ((numChilds - 1) * space))) // 2.
|
|
1191 |
xpos < 0 ifTrue:[
|
|
1192 |
space := (width - sumOfWidths) // (numChilds + 1).
|
|
1193 |
xpos := (width - (sumOfWidths
|
|
1194 |
+ ((numChilds - 1) * space))) // 2.
|
|
1195 |
]
|
62
|
1196 |
]
|
77
|
1197 |
]
|
62
|
1198 |
]
|
59
|
1199 |
]
|
77
|
1200 |
].
|
62
|
1201 |
].
|
0
|
1202 |
].
|
|
1203 |
|
133
|
1204 |
vL := vLayout.
|
|
1205 |
resizeToMaxV := false.
|
|
1206 |
(vLayout endsWith:'Max') ifTrue:[
|
|
1207 |
resizeToMaxV := true.
|
|
1208 |
maxHeight := subViews inject:0 into:[:maxSoFar :child | maxSoFar max:child heightIncludingBorder].
|
|
1209 |
vL == #centerMax ifTrue:[vL := #center].
|
|
1210 |
vL == #bottomMax ifTrue:[vL := #bottom].
|
|
1211 |
vL == #bottomSpaceMax ifTrue:[vL := #bottomSpace].
|
|
1212 |
vL == #topMax ifTrue:[vL := #top].
|
|
1213 |
vL == #topSpaceMax ifTrue:[vL := #topSpace].
|
|
1214 |
].
|
|
1215 |
|
0
|
1216 |
"now set positions"
|
|
1217 |
|
77
|
1218 |
subViews keysAndValuesDo:[:index :child |
|
133
|
1219 |
|ypos advance bwChild hChild|
|
|
1220 |
|
|
1221 |
hChild := child heightIncludingBorder.
|
|
1222 |
bwChild := child borderWidth.
|
|
1223 |
|
|
1224 |
resizeToMaxV ifTrue:[
|
|
1225 |
child height:(hChild := maxHeight - (bwChild * 2)).
|
|
1226 |
].
|
62
|
1227 |
|
118
|
1228 |
vL == #top ifTrue:[
|
62
|
1229 |
ypos := 0
|
|
1230 |
] ifFalse:[
|
118
|
1231 |
vL == #topSpace ifTrue:[
|
62
|
1232 |
ypos := verticalSpace
|
|
1233 |
] ifFalse:[
|
118
|
1234 |
vL == #bottom ifTrue:[
|
62
|
1235 |
ypos := height - child heightIncludingBorder
|
|
1236 |
] ifFalse:[
|
118
|
1237 |
vL == #bottomSpace ifTrue:[
|
62
|
1238 |
ypos := height - verticalSpace - child heightIncludingBorder.
|
|
1239 |
] ifFalse:[
|
118
|
1240 |
vL == #fitSpace ifTrue:[
|
62
|
1241 |
ypos := verticalSpace.
|
133
|
1242 |
child height:(height - (verticalSpace + bwChild * 2))
|
62
|
1243 |
] ifFalse:[
|
118
|
1244 |
vL == #fit ifTrue:[
|
77
|
1245 |
ypos := 0.
|
133
|
1246 |
child height:(height - (bwChild * 2))
|
77
|
1247 |
] ifFalse:[
|
|
1248 |
"centered"
|
|
1249 |
ypos := (height - child heightIncludingBorder) // 2.
|
|
1250 |
]
|
62
|
1251 |
]
|
|
1252 |
]
|
|
1253 |
]
|
|
1254 |
]
|
|
1255 |
].
|
59
|
1256 |
(ypos < 0) ifTrue:[ypos := 0].
|
0
|
1257 |
|
133
|
1258 |
(hL == #fit
|
|
1259 |
or:[hL == #fitSpace
|
|
1260 |
or:[resizeToMaxH]]) ifTrue:[
|
77
|
1261 |
child origin:(xpos truncated @ ypos)
|
155
|
1262 |
corner:(xpos + wEach - (child borderWidth) - 1) truncated
|
|
1263 |
@ (ypos + child height - 1).
|
77
|
1264 |
advance := wEach.
|
62
|
1265 |
] ifFalse:[
|
|
1266 |
child origin:(xpos @ ypos).
|
77
|
1267 |
advance := child widthIncludingBorder
|
|
1268 |
].
|
|
1269 |
xpos := xpos + advance + space.
|
|
1270 |
|
|
1271 |
index == numChilds ifTrue:[
|
|
1272 |
|x|
|
|
1273 |
|
118
|
1274 |
hL == #leftFit ifTrue:[
|
155
|
1275 |
x := width - margin - 1.
|
77
|
1276 |
].
|
118
|
1277 |
hL == #leftSpaceFit ifTrue:[
|
155
|
1278 |
x := width - margin - 1 - space
|
77
|
1279 |
].
|
|
1280 |
x notNil ifTrue:[
|
155
|
1281 |
subViews last corner:(x @ (ypos + child height - 1))
|
77
|
1282 |
]
|
62
|
1283 |
]
|
77
|
1284 |
].
|
155
|
1285 |
|
|
1286 |
"Modified: 4.9.1995 / 18:43:10 / claus"
|
0
|
1287 |
! !
|