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