--- a/HorizontalPanelView.st Sun Apr 30 15:40:03 1995 +0200
+++ b/HorizontalPanelView.st Wed May 03 02:30:14 1995 +0200
@@ -21,7 +21,7 @@
COPYRIGHT (c) 1989 by Claus Gittinger
All Rights Reserved
-$Header: /cvs/stx/stx/libwidg/HorizontalPanelView.st,v 1.8 1995-02-06 00:52:25 claus Exp $
+$Header: /cvs/stx/stx/libwidg/HorizontalPanelView.st,v 1.9 1995-05-03 00:29:39 claus Exp $
'!
!HorizontalPanelView class methodsFor:'documentation'!
@@ -42,7 +42,7 @@
version
"
-$Header: /cvs/stx/stx/libwidg/HorizontalPanelView.st,v 1.8 1995-02-06 00:52:25 claus Exp $
+$Header: /cvs/stx/stx/libwidg/HorizontalPanelView.st,v 1.9 1995-05-03 00:29:39 claus Exp $
"
!
@@ -60,6 +60,8 @@
#left arrange elements at the left
#leftSpace arrange elements at the left, start with spacing
+ #fixLeft same as #left, but do not reduce spacing in case of no fit
+ #fixLeftSpace same as #leftSpace, but do not reduce spacing in case of no fit
#right arrange elements at the right
#rightSpace arrange elements at the right, start with spacing
#center arrange elements in the center
@@ -85,8 +87,11 @@
For backward compatibility (to times, where only hLayout existed), the simple
#layout: does the same as #horizontalLayout:. Do not use this old method.
- If none of these layout/space combinations is exactly what you need in
- your application, create a subclass, and redefine the setChildPositions method.
+ By combining Horizontal- and VerticalPanels (i.e. place a hPanel into a
+ vPanel), most layouts should be implementable.
+ However, ff none of these layout/space combinations is exactly what you need
+ in your application, create a subclass, and redefine the setChildPositions
+ method there.
"
!
@@ -98,8 +103,8 @@
setting different values for the spacing.
Try resizing the view and see how the elements get rearranged.
- All of the below examples place 3 buttons onto a panel - of course,
- you can put any other view into a panel ... the last example shows this.
+ Most of the examples below place 3 buttons onto a panel; Of course,
+ you can put any other view into a panel ... the last examples show this.
example: default layout (centered)
@@ -107,7 +112,7 @@
|v p b1 b2 b3|
v := StandardSystemView new.
- v label:'default'.
+ v label:'default: center'.
p := HorizontalPanelView in:v.
p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
@@ -124,7 +129,7 @@
v := StandardSystemView new.
p := HorizontalPanelView in:v.
- v label:'hL=left'.
+ v label:'hL=left; vL=default (center)'.
p horizontalLayout:#left.
p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
@@ -141,7 +146,7 @@
v := StandardSystemView new.
p := HorizontalPanelView in:v.
- v label:'hL=leftSpace'.
+ v label:'hL=leftSpace; vL=center'.
p horizontalLayout:#leftSpace.
p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
@@ -158,7 +163,7 @@
v := StandardSystemView new.
p := HorizontalPanelView in:v.
- v label:'hL=leftFit'.
+ v label:'hL=leftFit; vL=center'.
p horizontalLayout:#leftFit.
p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
@@ -175,7 +180,7 @@
v := StandardSystemView new.
p := HorizontalPanelView in:v.
- v label:'hL=leftFit'.
+ v label:'hL=leftSpaceFit; vL=center'.
p horizontalLayout:#leftSpaceFit.
p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
@@ -192,7 +197,7 @@
v := StandardSystemView new.
p := HorizontalPanelView in:v.
- v label:'hL=right'.
+ v label:'hL=right; vL=center'.
p horizontalLayout:#right.
p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
@@ -209,7 +214,7 @@
v := StandardSystemView new.
p := HorizontalPanelView in:v.
- v label:'hL=rightSpace'.
+ v label:'hL=rightSpace; vL=center'.
p horizontalLayout:#rightSpace.
p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
@@ -227,7 +232,7 @@
v := StandardSystemView new.
p := HorizontalPanelView in:v.
p horizontalLayout:#fit.
- v label:'hL=fit'.
+ v label:'hL=fit; vL=center'.
p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
b1 := Button label:'button1' in:p.
@@ -245,7 +250,7 @@
p := HorizontalPanelView in:v.
p horizontalLayout:#fit.
p horizontalSpace:0.
- v label:'hL=fit hS=0'.
+ v label:'hL=fit hS=0; vL=center'.
p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
b1 := Button label:'button1' in:p.
@@ -261,7 +266,7 @@
v := StandardSystemView new.
p := HorizontalPanelView in:v.
- v label:'hL=fitSpace'.
+ v label:'hL=fitSpace; vL=center'.
p horizontalLayout:#fitSpace.
p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
@@ -279,7 +284,7 @@
v := StandardSystemView new.
p := HorizontalPanelView in:v.
p horizontalLayout:#spread.
- v label:'hL=spread'.
+ v label:'hL=spread; vL=center'.
p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
b1 := Button label:'button1' in:p.
@@ -295,7 +300,7 @@
v := StandardSystemView new.
p := HorizontalPanelView in:v.
- v label:'hL=spreadSpace'.
+ v label:'hL=spreadSpace; vL=center'.
p horizontalLayout:#spreadSpace.
p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
@@ -312,7 +317,7 @@
v := StandardSystemView new.
p := HorizontalPanelView in:v.
- v label:'hL=spreadSpace vL=fit'.
+ v label:'hL=spreadSpace; vL=fit'.
p horizontalLayout:#spreadSpace.
p verticalLayout:#fit.
@@ -330,7 +335,7 @@
v := StandardSystemView new.
p := HorizontalPanelView in:v.
- v label:'hL=spreadSpace vL=fitSpace'.
+ v label:'hL=spreadSpace; vL=fitSpace'.
p horizontalLayout:#spreadSpace.
p verticalLayout:#fitSpace.
@@ -348,7 +353,7 @@
v := StandardSystemView new.
p := HorizontalPanelView in:v.
- v label:'hL=fit vL=top'.
+ v label:'hL=fit; vL=top'.
p horizontalLayout:#fit.
p verticalLayout:#top.
@@ -366,7 +371,7 @@
v := StandardSystemView new.
p := HorizontalPanelView in:v.
- v label:'hL=fitSpace vL=top'.
+ v label:'hL=fitSpace; vL=top'.
p horizontalLayout:#fitSpace.
p verticalLayout:#top.
@@ -384,7 +389,7 @@
v := StandardSystemView new.
p := HorizontalPanelView in:v.
- v label:'hL=fitSpace vL=fitSpace'.
+ v label:'hL=fitSpace; vL=fitSpace'.
p horizontalLayout:#fitSpace.
p verticalLayout:#fitSpace.
@@ -402,7 +407,7 @@
v := StandardSystemView new.
p := HorizontalPanelView in:v.
- v label:'hL=fit vL=fit hS=0'.
+ v label:'hL=fit hS=0; vL=fit'.
p horizontalLayout:#fit.
p verticalLayout:#fit.
@@ -421,7 +426,7 @@
v := StandardSystemView new.
p := HorizontalPanelView in:v.
- v label:'hL=fitSpace vL=topSpace'.
+ v label:'hL=fitSpace; vL=topSpace'.
p horizontalLayout:#fitSpace.
p verticalLayout:#topSpace.
@@ -439,7 +444,7 @@
v := StandardSystemView new.
p := HorizontalPanelView in:v.
- v label:'hL=fit vL=top'.
+ v label:'hL=fit; vL=top'.
p horizontalLayout:#fit.
p verticalLayout:#top.
@@ -458,7 +463,7 @@
v := StandardSystemView new.
p := HorizontalPanelView in:v.
- v label:'hL=fitSpace vL=bottomSpace'.
+ v label:'hL=fitSpace; vL=bottomSpace'.
p horizontalLayout:#fitSpace.
p verticalLayout:#bottomSpace.
@@ -476,7 +481,7 @@
v := StandardSystemView new.
p := HorizontalPanelView in:v.
- v label:'hL=fit vL=bottomSpace'.
+ v label:'hL=fit; vL=bottomSpace'.
p horizontalLayout:#fit.
p verticalLayout:#bottomSpace.
@@ -488,6 +493,41 @@
v extent:300 @ 100.
v open
+ example: placing hPanels into a vPanel
+
+ |v vP hP1 hP2 hP3 b1 b2 b3 b4 b5 b6 b7 b8 b9|
+
+ v := StandardSystemView new.
+ vP := VerticalPanelView in:v.
+ vP origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
+ vP verticalLayout:#fit;
+ verticalSpace:0;
+ horizontalLayout:#fit.
+
+ hP1 := HorizontalPanelView in:vP.
+ hP1 horizontalLayout:#fitSpace;
+ verticalLayout:#center.
+ b1 := Button label:'button1' in:hP1.
+ b2 := Button label:'button2' in:hP1.
+ b3 := Button label:'button3' in:hP1.
+
+ hP2 := HorizontalPanelView in:vP.
+ hP2 horizontalLayout:#fitSpace;
+ verticalLayout:#center.
+ b4 := Button label:'button4' in:hP2.
+ b5 := Button label:'button5' in:hP2.
+ b6 := Button label:'button6' in:hP2.
+
+ hP3 := HorizontalPanelView in:vP.
+ hP3 horizontalLayout:#fitSpace;
+ verticalLayout:#center.
+ b7 := Button label:'button7' in:hP3.
+ b8 := Button label:'button8' in:hP3.
+ b9 := Button label:'button9' in:hP3.
+
+ v extent:300 @ 300.
+ v open
+
example: a browser like table, where the rightmost list
extends to the far right.
@@ -515,7 +555,7 @@
l3 := ScrollableView for:FileSelectionList in:p.
l3 directory:nil.
- l3 ignoreParentDirectory:true.
+ l3 ignoreParentDirectory:false.
v extent:400 @ 300.
v open
"
@@ -528,12 +568,15 @@
the returned value is one of
#left
#leftSpace
+ #leftFit
+ #leftSpaceFit
#center
#spread
#fit
#right
#rightSpace
the default is #center
+ See the class documentation for the meanings.
"
^ hLayout
@@ -547,6 +590,7 @@
#bottom / #bottomSpace
#fit
the default is #center
+ See the class documentation for the meanings.
"
^ vLayout
@@ -556,11 +600,13 @@
"change the horizontal layout as symbol.
The argument, aSymbol must be one of:
#left / #leftSpace
+ #leftFit / #leftSpaceFit
#center
- #spread / spredSpace
+ #spread / spreadSpace
#fit / fitSpace
#right / #rightSpace
- the default (if never changed) is #center
+ the default (if never changed) is #center.
+ See the class documentation for the meanings.
"
(hLayout ~~ aSymbol) ifTrue:[
@@ -577,6 +623,7 @@
#bottom / #bottomSpace
#fit
the default (if never changed) is #center
+ See the class documentation for the meanings.
"
(vLayout ~~ aSymbol) ifTrue:[
@@ -655,7 +702,7 @@
"(re)compute position of every child whenever childs are added or
my size has changed"
- |xpos space sumOfWidths numChilds l wEach wInside|
+ |xpos space sumOfWidths numChilds l wEach wInside hL vL|
subViews isNil ifTrue:[^ self].
@@ -663,7 +710,10 @@
numChilds := subViews size.
wInside := width - (margin * 2) + (borderWidth*2) - subViews last borderWidth.
- hLayout == #fitSpace ifTrue:[
+ hL := hLayout.
+ vL := vLayout.
+
+ hL == #fitSpace ifTrue:[
"
adjust childs extents and set origins.
Be careful to avoid accumulation of rounding errors
@@ -671,7 +721,7 @@
wEach := (wInside - (numChilds + 1 * space)) / numChilds.
xpos := space + margin - borderWidth.
] ifFalse:[
- hLayout == #fit ifTrue:[
+ hL == #fit ifTrue:[
"
adjust childs extents and set origins.
Be careful to avoid accumulation of rounding errors
@@ -684,7 +734,7 @@
"
sumOfWidths := subViews inject:0 into:[:sumSoFar :child | sumSoFar + child widthIncludingBorder].
- l := hLayout.
+ l := hL.
((l == #center) and:[numChilds == 1]) ifTrue:[
l := #spread
].
@@ -696,10 +746,18 @@
compute position of leftmost subview and space between them;
if they do hardly fit, leave no space between them
"
- (sumOfWidths >= (width - (margin * 2))) ifTrue:[
+ ((sumOfWidths >= (width - (margin * 2)))
+ and:[l ~~ #fixLeftSpace and:[l ~~ #fixLeft]]) ifTrue:[
xpos := 0.
space := 0
] ifFalse: [
+ l == #fixLeftSpace ifTrue:[
+ l := #leftSpace
+ ] ifFalse:[
+ l == #fixLeft ifTrue:[
+ l := #left
+ ]
+ ].
((l == #right) or:[l == #rightSpace]) ifTrue:[
xpos := width - (space * (numChilds - 1)) - sumOfWidths.
"
@@ -737,6 +795,11 @@
or:[l == #leftFit
or:[l == #leftSpaceFit]]]) ifTrue:[
space := space min:(width - sumOfWidths) // (numChilds + 1).
+ (hL == #fixLeft or:[hL == #fixLeftSpace]) ifTrue:[
+ space := space max:horizontalSpace.
+ ] ifFalse:[
+ space := space max:0.
+ ].
(l == #leftSpace
or:[l == #leftSpaceFit]) ifTrue:[
xpos := space.
@@ -770,23 +833,23 @@
subViews keysAndValuesDo:[:index :child |
|ypos advance|
- vLayout == #top ifTrue:[
+ vL == #top ifTrue:[
ypos := 0
] ifFalse:[
- vLayout == #topSpace ifTrue:[
+ vL == #topSpace ifTrue:[
ypos := verticalSpace
] ifFalse:[
- vLayout == #bottom ifTrue:[
+ vL == #bottom ifTrue:[
ypos := height - child heightIncludingBorder
] ifFalse:[
- vLayout == #bottomSpace ifTrue:[
+ vL == #bottomSpace ifTrue:[
ypos := height - verticalSpace - child heightIncludingBorder.
] ifFalse:[
- vLayout == #fitSpace ifTrue:[
+ vL == #fitSpace ifTrue:[
ypos := verticalSpace.
child height:(height - (verticalSpace + child borderWidth * 2))
] ifFalse:[
- vLayout == #fit ifTrue:[
+ vL == #fit ifTrue:[
ypos := 0.
child height:(height - (child borderWidth * 2))
] ifFalse:[
@@ -800,7 +863,7 @@
].
(ypos < 0) ifTrue:[ypos := 0].
- (hLayout == #fit or:[hLayout == #fitSpace]) ifTrue:[
+ (hL == #fit or:[hL == #fitSpace]) ifTrue:[
child origin:(xpos truncated @ ypos)
corner:(xpos + wEach - (child borderWidth)) truncated
@ (ypos + child height).
@@ -814,10 +877,10 @@
index == numChilds ifTrue:[
|x|
- hLayout == #leftFit ifTrue:[
+ hL == #leftFit ifTrue:[
x := width - margin.
].
- hLayout == #leftSpaceFit ifTrue:[
+ hL == #leftSpaceFit ifTrue:[
x := width - margin - space
].
x notNil ifTrue:[