added #rightFit & #rightSpaceFit layouts
authorClaus Gittinger <cg@exept.de>
Mon, 18 Aug 1997 12:31:47 +0200
changeset 1306 bf4903012f7a
parent 1305 02af46047b4a
child 1307 f2ce08878d5e
added #rightFit & #rightSpaceFit layouts
HPanelV.st
HorizontalPanelView.st
--- a/HPanelV.st	Fri Aug 15 13:04:32 1997 +0200
+++ b/HPanelV.st	Mon Aug 18 12:31:47 1997 +0200
@@ -49,7 +49,7 @@
 
     The horizontal layout can be any of:
 
-        #left           arrange elements at the left
+        #left           arrange elements at 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
@@ -60,8 +60,10 @@
         #spreadSpace    spread elements evenly with spacing at the ends
         #fit            like #spread, but resize elements for tight packing
         #fitSpace       like #fit, with additional spacing at the far ends
-        #leftFit        like #left, but extend the last element to the right
-        #leftSpaceFit   like #leftSpace, but extend the last element to the right
+        #leftFit        like #left, but extend the last (rightMost) element to the right
+        #leftSpaceFit   like #leftSpace, but extend the last (rightMost) element to the right
+        #rightFit       like #right, but extend the first (leftMost) element to the left
+        #rightSpaceFit  like #rightSpace, but extend the first (leftMost) element to the left
 
         #leftMax        like corresponding non-Max layouts,
         #leftSpaceMax   but resize all components to width of widest components
@@ -91,11 +93,12 @@
     The layout is changed by the messages #verticalLayout: and #horizontalLayout:.
     For backward compatibility (to times, where only hLayout existed), the simple
     #layout: does the same as #horizontalLayout:. 
-    Do not use this old method; it will vanish and currently outpus a warning.
+    Do not use this old method; it will vanish and currently outputs a warning.
 
     The panel assumes, that the elements do not resize themselfes, after it
-    became visible. This is not true for all widgets (buttons or labels may
-    like to change). If you have changing elements, tell this to the panel
+    became visible. This is not true for all widgets (buttons, labels or
+    inputFields may like to change). 
+    If you have changing elements, tell this to the panel
     with 'aPanel elementsChangeSize:true'. In that case, the panel will react
     to size changes of its elements, and reorganize things.
 
@@ -110,7 +113,7 @@
 
     CAVEAT: this class started with #left and no vertical alignments;
     as time went by, more layouts were added (by users requests)
-    and noew, many layout combinations are possible.
+    and now, many layout combinations are possible.
     Reflecting this, the setup should be changed to use different selectors 
     for space-on/off, max-resize and alignment
     (i.e. having more and more layout symbols makes things a bit confusing ...)
@@ -136,11 +139,14 @@
     setting different values for the spacing.
     Try resizing the view and see how the elements get rearranged.
 
-    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.
-
+    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.
+    (The fit layouts are especially useful to be used with SelectionInListViews;
+     you can combine multiple labels & editFields with a selectionInListView, which
+     is expanded to fill the remaining area of the view)
 
     example: default layout (center)
+        centers components
                                                                         [exBegin]
         |v p b1 b2 b3|
 
@@ -260,6 +266,7 @@
 
 
     example: left-layout (vertical is default -> center)
+        fills left-to-right; no spacing before leftMost component
                                                                         [exBegin]
         |v p b1 b2 b3|
 
@@ -278,6 +285,7 @@
 
 
     example: left starting with spacing (vertical is default -> center)
+        fills left-to-right; spacing before leftMost component
                                                                         [exBegin]
         |v p b1 b2 b3|
 
@@ -296,6 +304,7 @@
 
 
     example: leftFit-layout (vertical is default -> center)
+        fills left-to-right; resizes the rightMost component to fit
                                                                         [exBegin]
         |v p b1 b2 b3|
 
@@ -314,6 +323,8 @@
 
 
     example: leftSpaceFit-layout (vertical is default -> center)
+        fills left-to-right; 
+        starts with spacing & resizes the rightMost component to fit with spacing
                                                                         [exBegin]
         |v p b1 b2 b3|
 
@@ -332,6 +343,7 @@
 
 
     example: right-layout (vertical is default -> center)
+        right-to-left
                                                                         [exBegin]
         |v p b1 b2 b3|
 
@@ -350,6 +362,7 @@
 
 
     example: right with initial spacing (vertical is default -> center)
+        right-to-left with spacing after last component
                                                                         [exBegin]
         |v p b1 b2 b3|
 
@@ -367,6 +380,44 @@
                                                                         [exEnd]
 
 
+    example: rightFit-layout (vertical is default -> center)
+        right-to-left; resize the leftMost component to fit
+                                                                        [exBegin]
+        |v p b1 b2 b3|
+
+        v := StandardSystemView new.
+        p := HorizontalPanelView in:v.
+        v label:'hL=rightFit; vL=center'.
+
+        p horizontalLayout:#rightFit.
+        p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
+        b1 := Button label:'button1' in:p.
+        b2 := Button label:'button2' in:p.
+        b3 := Button label:'button3' in:p.
+        v extent:300 @ 100.
+        v open
+                                                                        [exEnd]
+
+
+    example: rightSpaceFit with initial spacing (vertical is default -> center)
+        right-to-left; start with spacing & resize the leftMost to fit
+                                                                        [exBegin]
+        |v p b1 b2 b3|
+
+        v := StandardSystemView new.
+        p := HorizontalPanelView in:v.
+        v label:'hL=rightSpaceFit; vL=center'.
+
+        p horizontalLayout:#rightSpaceFit.
+        p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
+        b1 := Button label:'button1' in:p.
+        b2 := Button label:'button2' in:p.
+        b3 := Button label:'button3' in:p.
+        v extent:300 @ 100.
+        v open
+                                                                        [exEnd]
+
+
     example: fit-layout (vertical is default -> center)
                                                                         [exBegin]
         |v p b1 b2 b3|
@@ -831,8 +882,8 @@
         v open
                                                                         [exEnd]
 
-    example: a browser like table, where the rightmost list
-             extends to the far right.
+    example: a browser like table, the two left tables have a fix width,
+             while the rightmost list extends to the far right.
                                                                         [exBegin]
         |v p l1 l2 l3|
 
@@ -865,7 +916,7 @@
                                                                         [exEnd]
 
 
-    trouble example: self resizing elements may cause trouble
+    trouble example: self-resizing elements may cause trouble
                                                                         [exBegin]
         |v p l1 l2 l3|
 
@@ -916,24 +967,28 @@
 horizontalLayout
     "return the horizontal layout as symbol.
      the returned value is one of
-	#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
-	#spread         spread elements evenly
-	#spreadSpace    spread elements evenly with spacing at the ends
-	#fit            like #spread, but resize elements for tight packing
-	#fitSpace       like #fit, with additional spacing at the far ends
-	#leftFit        like #left, but extend the last element to the right
-	#leftSpaceFit   like #leftSpace, but extend the last element to the right
+        #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
+        #spread         spread elements evenly
+        #spreadSpace    spread elements evenly with spacing at the ends
+        #fit            like #spread, but resize elements for tight packing
+        #fitSpace       like #fit, with additional spacing at the far ends
+        #leftFit        like #left, but resize the last element to fit
+        #leftSpaceFit   like #leftSpace, but resize the last element to fit
+        #rightFit       like #right, but resize the first element to fit
+        #rightSpaceFit  like #rightSpace, but resize the first element to fit
       the default is #center
       See the class documentation for  the meanings.
     "
 
     ^ hLayout
+
+    "Modified: 17.8.1997 / 15:21:26 / cg"
 !
 
 horizontalLayout:aSymbol
@@ -950,8 +1005,11 @@
         #spreadSpace    spread elements evenly with spacing at the ends
         #fit            like #spread, but resize elements for tight packing
         #fitSpace       like #fit, with additional spacing at the far ends
-        #leftFit        like #left, but extend the last element to the right
-        #leftSpaceFit   like #leftSpace, but extend the last element to the right
+        #leftFit        like #left, but resize the last element to fit
+        #leftSpaceFit   like #leftSpace, but resize the last element to fit
+        #rightFit       like #right, but resize the first element to fit
+        #rightSpaceFit  like #rightSpace, but resize the first element to fit
+
         #leftMax        like non-Max layouts, resizing components to
         #leftSpaceMax   the width of the widest component
         #rightMax
@@ -960,7 +1018,7 @@
         #spreadMax
         #spreadSpaceMax
       the default (if never changed) is #center.
-      See the class documentation for  the meanings.
+      See the class documentation for the meanings.
     "
 
     (hLayout ~~ aSymbol) ifTrue:[
@@ -968,7 +1026,7 @@
         self layoutChanged
     ]
 
-    "Modified: 26.3.1997 / 15:41:16 / cg"
+    "Modified: 17.8.1997 / 15:21:16 / cg"
 !
 
 layout:something
@@ -1063,9 +1121,18 @@
 
     resizeToMaxH := false.
     (hL endsWith:'Max') ifTrue:[
+        resizeToMaxH := true.
         wEach := maxWidth := subViews inject:0 into:[:maxSoFar :child | maxSoFar max:child widthIncludingBorder].
         hL := (hL copyWithoutLast:3) asSymbol.
-        resizeToMaxH := true.
+    ].
+
+    numChilds == 1 ifTrue:[
+        (hL == #leftFit or:[hL == #rightFit]) ifTrue:[
+            hL := #fit
+        ].
+        (hL == #leftSpaceFit or:[hL == #rightSpaceFit]) ifTrue:[
+            hL := #fitSpace
+        ].
     ].
 
     hL == #fitSpace ifTrue:[
@@ -1084,6 +1151,16 @@
             wEach := (wInside - (numChilds - 1 * space)) / numChilds.
             xpos := margin - borderWidth.
         ] ifFalse:[
+            l := hL.
+
+            "/ adjust - do not include width of last(first) element if doing a fit
+            (hL == #leftFit or:[hL == #leftSpaceFit]) ifTrue:[
+                subViews last width:0.
+            ].
+            (hL == #rightFit or:[hL == #rightSpaceFit]) ifTrue:[
+                subViews first width:0.
+            ].
+
             "
              compute net width needed
             "
@@ -1092,15 +1169,11 @@
             ] ifFalse:[
                 sumOfWidths := subViews inject:0 into:[:sumSoFar :child | sumSoFar + child widthIncludingBorder].
             ].
+
             restWidth := width - sumOfWidths.
 
-            l := hL.
-            ((l == #center) and:[numChilds == 1]) ifTrue:[
-                l := #spread
-            ].
-            (l == #spread and:[numChilds == 1]) ifTrue:[
-                l := #spreadSpace
-            ].
+            ((l == #center) and:[numChilds == 1]) ifTrue:[l := #spread].
+            (l == #spread and:[numChilds == 1]) ifTrue:[l := #spreadSpace].
 
             "
              compute position of leftmost subview and space between them;
@@ -1118,14 +1191,16 @@
                         l := #left
                     ]
                 ].
-                ((l == #right) or:[l == #rightSpace]) ifTrue:[
+                ((l == #right) or:[l == #rightSpace
+                or:[l == #rightFit or:[l == #rightSpaceFit]]]) ifTrue:[
                     xpos := restWidth - (space * (numChilds - 1)).
         "
                     borderWidth == 0 ifTrue:[
                         xpos := xpos + space 
                     ].
         "
-                    l == #rightSpace ifTrue:[
+                    (l == #rightSpace   
+                    or:[l == #rightSpaceFit]) ifTrue:[
                         xpos >= space ifTrue:[
                             xpos := xpos - space
                         ]
@@ -1150,18 +1225,15 @@
                             xpos := restWidth // 2
                         ]
                       ] ifFalse:[
-                        ((l == #left) 
-                        or:[l == #leftSpace
-                        or:[l == #leftFit
-                        or:[l == #leftSpaceFit]]]) ifTrue:[
+                        ((l == #left) or:[l == #leftSpace
+                        or:[l == #leftFit or:[l == #leftSpaceFit]]]) ifTrue:[
                             space := space min:(restWidth - m2) // (numChilds + 1).
                             (hL == #fixLeft or:[hL == #fixLeftSpace]) ifTrue:[
                                 space := space max:horizontalSpace.
                             ] ifFalse:[
                                 space := space max:0.
                             ].
-                            (l == #leftSpace 
-                            or:[l == #leftSpaceFit]) ifTrue:[
+                            (l == #leftSpace or:[l == #leftSpaceFit]) ifTrue:[
                                 xpos := space.
                             ] ifFalse:[
                                 "/
@@ -1189,19 +1261,16 @@
         ].
     ].
 
-    vL := vLayout.
     resizeToMaxV := false.
-    (vLayout endsWith:'Max') ifTrue:[
+    (vL endsWith:'Max') ifTrue:[
         resizeToMaxV := true.
         maxHeight := subViews inject:0 into:[:maxSoFar :child | maxSoFar max:child heightIncludingBorder].
-        vL == #centerMax ifTrue:[vL := #center].
-        vL == #bottomMax ifTrue:[vL := #bottom].
-        vL == #bottomSpaceMax ifTrue:[vL := #bottomSpace].
-        vL == #topMax ifTrue:[vL := #top].
-        vL == #topSpaceMax ifTrue:[vL := #topSpace].
+        vL := (vL copyWithoutLast:3) asSymbol.
     ].
 
-    "now set positions"
+    "
+     now set positions
+    "
 
     subViews keysAndValuesDo:[:index :child |
         |ypos advance bwChild hChild newHChild|
@@ -1268,7 +1337,6 @@
             child origin:(xpos @ ypos).
             advance := child widthIncludingBorder
         ].
-        xpos := xpos + advance + space.
 
         index == numChilds ifTrue:[
             |x|
@@ -1277,16 +1345,29 @@
                 x := width - margin - 1 - (child borderWidth * 2) + borderWidth.
                 hL == #leftSpaceFit ifTrue:[
                     x := x - space
-                ]
+                ].
+                child corner:(x @ (ypos + child height - 1))
             ].
-            x notNil ifTrue:[
-                subViews last corner:(x @ (ypos + child height - 1))
-            ]
-        ]
+        ].
+        index == 1 ifTrue:[
+            |x xR|
+
+            (hL == #rightFit or:[hL == #rightSpaceFit]) ifTrue:[
+                x := 0 + (child borderWidth * 2) - borderWidth.
+                hL == #rightSpaceFit ifTrue:[
+                    x := x + space
+                ].
+                xR := child corner x.
+                child origin:(x @ (child origin y))
+                      corner:(xR @ (child corner y))
+            ].
+        ].
+
+        xpos := xpos + advance + space.
     ].
 
     "Modified: 4.9.1995 / 18:43:10 / claus"
-    "Modified: 27.6.1997 / 11:50:50 / cg"
+    "Modified: 17.8.1997 / 16:20:37 / cg"
 ! !
 
 !HorizontalPanelView methodsFor:'queries'!
@@ -1370,5 +1451,5 @@
 !HorizontalPanelView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/Attic/HPanelV.st,v 1.33 1997-07-31 21:12:35 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/Attic/HPanelV.st,v 1.34 1997-08-18 10:31:47 cg Exp $'
 ! !
--- a/HorizontalPanelView.st	Fri Aug 15 13:04:32 1997 +0200
+++ b/HorizontalPanelView.st	Mon Aug 18 12:31:47 1997 +0200
@@ -49,7 +49,7 @@
 
     The horizontal layout can be any of:
 
-        #left           arrange elements at the left
+        #left           arrange elements at 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
@@ -60,8 +60,10 @@
         #spreadSpace    spread elements evenly with spacing at the ends
         #fit            like #spread, but resize elements for tight packing
         #fitSpace       like #fit, with additional spacing at the far ends
-        #leftFit        like #left, but extend the last element to the right
-        #leftSpaceFit   like #leftSpace, but extend the last element to the right
+        #leftFit        like #left, but extend the last (rightMost) element to the right
+        #leftSpaceFit   like #leftSpace, but extend the last (rightMost) element to the right
+        #rightFit       like #right, but extend the first (leftMost) element to the left
+        #rightSpaceFit  like #rightSpace, but extend the first (leftMost) element to the left
 
         #leftMax        like corresponding non-Max layouts,
         #leftSpaceMax   but resize all components to width of widest components
@@ -91,11 +93,12 @@
     The layout is changed by the messages #verticalLayout: and #horizontalLayout:.
     For backward compatibility (to times, where only hLayout existed), the simple
     #layout: does the same as #horizontalLayout:. 
-    Do not use this old method; it will vanish and currently outpus a warning.
+    Do not use this old method; it will vanish and currently outputs a warning.
 
     The panel assumes, that the elements do not resize themselfes, after it
-    became visible. This is not true for all widgets (buttons or labels may
-    like to change). If you have changing elements, tell this to the panel
+    became visible. This is not true for all widgets (buttons, labels or
+    inputFields may like to change). 
+    If you have changing elements, tell this to the panel
     with 'aPanel elementsChangeSize:true'. In that case, the panel will react
     to size changes of its elements, and reorganize things.
 
@@ -110,7 +113,7 @@
 
     CAVEAT: this class started with #left and no vertical alignments;
     as time went by, more layouts were added (by users requests)
-    and noew, many layout combinations are possible.
+    and now, many layout combinations are possible.
     Reflecting this, the setup should be changed to use different selectors 
     for space-on/off, max-resize and alignment
     (i.e. having more and more layout symbols makes things a bit confusing ...)
@@ -136,11 +139,14 @@
     setting different values for the spacing.
     Try resizing the view and see how the elements get rearranged.
 
-    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.
-
+    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.
+    (The fit layouts are especially useful to be used with SelectionInListViews;
+     you can combine multiple labels & editFields with a selectionInListView, which
+     is expanded to fill the remaining area of the view)
 
     example: default layout (center)
+        centers components
                                                                         [exBegin]
         |v p b1 b2 b3|
 
@@ -260,6 +266,7 @@
 
 
     example: left-layout (vertical is default -> center)
+        fills left-to-right; no spacing before leftMost component
                                                                         [exBegin]
         |v p b1 b2 b3|
 
@@ -278,6 +285,7 @@
 
 
     example: left starting with spacing (vertical is default -> center)
+        fills left-to-right; spacing before leftMost component
                                                                         [exBegin]
         |v p b1 b2 b3|
 
@@ -296,6 +304,7 @@
 
 
     example: leftFit-layout (vertical is default -> center)
+        fills left-to-right; resizes the rightMost component to fit
                                                                         [exBegin]
         |v p b1 b2 b3|
 
@@ -314,6 +323,8 @@
 
 
     example: leftSpaceFit-layout (vertical is default -> center)
+        fills left-to-right; 
+        starts with spacing & resizes the rightMost component to fit with spacing
                                                                         [exBegin]
         |v p b1 b2 b3|
 
@@ -332,6 +343,7 @@
 
 
     example: right-layout (vertical is default -> center)
+        right-to-left
                                                                         [exBegin]
         |v p b1 b2 b3|
 
@@ -350,6 +362,7 @@
 
 
     example: right with initial spacing (vertical is default -> center)
+        right-to-left with spacing after last component
                                                                         [exBegin]
         |v p b1 b2 b3|
 
@@ -367,6 +380,44 @@
                                                                         [exEnd]
 
 
+    example: rightFit-layout (vertical is default -> center)
+        right-to-left; resize the leftMost component to fit
+                                                                        [exBegin]
+        |v p b1 b2 b3|
+
+        v := StandardSystemView new.
+        p := HorizontalPanelView in:v.
+        v label:'hL=rightFit; vL=center'.
+
+        p horizontalLayout:#rightFit.
+        p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
+        b1 := Button label:'button1' in:p.
+        b2 := Button label:'button2' in:p.
+        b3 := Button label:'button3' in:p.
+        v extent:300 @ 100.
+        v open
+                                                                        [exEnd]
+
+
+    example: rightSpaceFit with initial spacing (vertical is default -> center)
+        right-to-left; start with spacing & resize the leftMost to fit
+                                                                        [exBegin]
+        |v p b1 b2 b3|
+
+        v := StandardSystemView new.
+        p := HorizontalPanelView in:v.
+        v label:'hL=rightSpaceFit; vL=center'.
+
+        p horizontalLayout:#rightSpaceFit.
+        p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
+        b1 := Button label:'button1' in:p.
+        b2 := Button label:'button2' in:p.
+        b3 := Button label:'button3' in:p.
+        v extent:300 @ 100.
+        v open
+                                                                        [exEnd]
+
+
     example: fit-layout (vertical is default -> center)
                                                                         [exBegin]
         |v p b1 b2 b3|
@@ -831,8 +882,8 @@
         v open
                                                                         [exEnd]
 
-    example: a browser like table, where the rightmost list
-             extends to the far right.
+    example: a browser like table, the two left tables have a fix width,
+             while the rightmost list extends to the far right.
                                                                         [exBegin]
         |v p l1 l2 l3|
 
@@ -865,7 +916,7 @@
                                                                         [exEnd]
 
 
-    trouble example: self resizing elements may cause trouble
+    trouble example: self-resizing elements may cause trouble
                                                                         [exBegin]
         |v p l1 l2 l3|
 
@@ -916,24 +967,28 @@
 horizontalLayout
     "return the horizontal layout as symbol.
      the returned value is one of
-	#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
-	#spread         spread elements evenly
-	#spreadSpace    spread elements evenly with spacing at the ends
-	#fit            like #spread, but resize elements for tight packing
-	#fitSpace       like #fit, with additional spacing at the far ends
-	#leftFit        like #left, but extend the last element to the right
-	#leftSpaceFit   like #leftSpace, but extend the last element to the right
+        #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
+        #spread         spread elements evenly
+        #spreadSpace    spread elements evenly with spacing at the ends
+        #fit            like #spread, but resize elements for tight packing
+        #fitSpace       like #fit, with additional spacing at the far ends
+        #leftFit        like #left, but resize the last element to fit
+        #leftSpaceFit   like #leftSpace, but resize the last element to fit
+        #rightFit       like #right, but resize the first element to fit
+        #rightSpaceFit  like #rightSpace, but resize the first element to fit
       the default is #center
       See the class documentation for  the meanings.
     "
 
     ^ hLayout
+
+    "Modified: 17.8.1997 / 15:21:26 / cg"
 !
 
 horizontalLayout:aSymbol
@@ -950,8 +1005,11 @@
         #spreadSpace    spread elements evenly with spacing at the ends
         #fit            like #spread, but resize elements for tight packing
         #fitSpace       like #fit, with additional spacing at the far ends
-        #leftFit        like #left, but extend the last element to the right
-        #leftSpaceFit   like #leftSpace, but extend the last element to the right
+        #leftFit        like #left, but resize the last element to fit
+        #leftSpaceFit   like #leftSpace, but resize the last element to fit
+        #rightFit       like #right, but resize the first element to fit
+        #rightSpaceFit  like #rightSpace, but resize the first element to fit
+
         #leftMax        like non-Max layouts, resizing components to
         #leftSpaceMax   the width of the widest component
         #rightMax
@@ -960,7 +1018,7 @@
         #spreadMax
         #spreadSpaceMax
       the default (if never changed) is #center.
-      See the class documentation for  the meanings.
+      See the class documentation for the meanings.
     "
 
     (hLayout ~~ aSymbol) ifTrue:[
@@ -968,7 +1026,7 @@
         self layoutChanged
     ]
 
-    "Modified: 26.3.1997 / 15:41:16 / cg"
+    "Modified: 17.8.1997 / 15:21:16 / cg"
 !
 
 layout:something
@@ -1063,9 +1121,18 @@
 
     resizeToMaxH := false.
     (hL endsWith:'Max') ifTrue:[
+        resizeToMaxH := true.
         wEach := maxWidth := subViews inject:0 into:[:maxSoFar :child | maxSoFar max:child widthIncludingBorder].
         hL := (hL copyWithoutLast:3) asSymbol.
-        resizeToMaxH := true.
+    ].
+
+    numChilds == 1 ifTrue:[
+        (hL == #leftFit or:[hL == #rightFit]) ifTrue:[
+            hL := #fit
+        ].
+        (hL == #leftSpaceFit or:[hL == #rightSpaceFit]) ifTrue:[
+            hL := #fitSpace
+        ].
     ].
 
     hL == #fitSpace ifTrue:[
@@ -1084,6 +1151,16 @@
             wEach := (wInside - (numChilds - 1 * space)) / numChilds.
             xpos := margin - borderWidth.
         ] ifFalse:[
+            l := hL.
+
+            "/ adjust - do not include width of last(first) element if doing a fit
+            (hL == #leftFit or:[hL == #leftSpaceFit]) ifTrue:[
+                subViews last width:0.
+            ].
+            (hL == #rightFit or:[hL == #rightSpaceFit]) ifTrue:[
+                subViews first width:0.
+            ].
+
             "
              compute net width needed
             "
@@ -1092,15 +1169,11 @@
             ] ifFalse:[
                 sumOfWidths := subViews inject:0 into:[:sumSoFar :child | sumSoFar + child widthIncludingBorder].
             ].
+
             restWidth := width - sumOfWidths.
 
-            l := hL.
-            ((l == #center) and:[numChilds == 1]) ifTrue:[
-                l := #spread
-            ].
-            (l == #spread and:[numChilds == 1]) ifTrue:[
-                l := #spreadSpace
-            ].
+            ((l == #center) and:[numChilds == 1]) ifTrue:[l := #spread].
+            (l == #spread and:[numChilds == 1]) ifTrue:[l := #spreadSpace].
 
             "
              compute position of leftmost subview and space between them;
@@ -1118,14 +1191,16 @@
                         l := #left
                     ]
                 ].
-                ((l == #right) or:[l == #rightSpace]) ifTrue:[
+                ((l == #right) or:[l == #rightSpace
+                or:[l == #rightFit or:[l == #rightSpaceFit]]]) ifTrue:[
                     xpos := restWidth - (space * (numChilds - 1)).
         "
                     borderWidth == 0 ifTrue:[
                         xpos := xpos + space 
                     ].
         "
-                    l == #rightSpace ifTrue:[
+                    (l == #rightSpace   
+                    or:[l == #rightSpaceFit]) ifTrue:[
                         xpos >= space ifTrue:[
                             xpos := xpos - space
                         ]
@@ -1150,18 +1225,15 @@
                             xpos := restWidth // 2
                         ]
                       ] ifFalse:[
-                        ((l == #left) 
-                        or:[l == #leftSpace
-                        or:[l == #leftFit
-                        or:[l == #leftSpaceFit]]]) ifTrue:[
+                        ((l == #left) or:[l == #leftSpace
+                        or:[l == #leftFit or:[l == #leftSpaceFit]]]) ifTrue:[
                             space := space min:(restWidth - m2) // (numChilds + 1).
                             (hL == #fixLeft or:[hL == #fixLeftSpace]) ifTrue:[
                                 space := space max:horizontalSpace.
                             ] ifFalse:[
                                 space := space max:0.
                             ].
-                            (l == #leftSpace 
-                            or:[l == #leftSpaceFit]) ifTrue:[
+                            (l == #leftSpace or:[l == #leftSpaceFit]) ifTrue:[
                                 xpos := space.
                             ] ifFalse:[
                                 "/
@@ -1189,19 +1261,16 @@
         ].
     ].
 
-    vL := vLayout.
     resizeToMaxV := false.
-    (vLayout endsWith:'Max') ifTrue:[
+    (vL endsWith:'Max') ifTrue:[
         resizeToMaxV := true.
         maxHeight := subViews inject:0 into:[:maxSoFar :child | maxSoFar max:child heightIncludingBorder].
-        vL == #centerMax ifTrue:[vL := #center].
-        vL == #bottomMax ifTrue:[vL := #bottom].
-        vL == #bottomSpaceMax ifTrue:[vL := #bottomSpace].
-        vL == #topMax ifTrue:[vL := #top].
-        vL == #topSpaceMax ifTrue:[vL := #topSpace].
+        vL := (vL copyWithoutLast:3) asSymbol.
     ].
 
-    "now set positions"
+    "
+     now set positions
+    "
 
     subViews keysAndValuesDo:[:index :child |
         |ypos advance bwChild hChild newHChild|
@@ -1268,7 +1337,6 @@
             child origin:(xpos @ ypos).
             advance := child widthIncludingBorder
         ].
-        xpos := xpos + advance + space.
 
         index == numChilds ifTrue:[
             |x|
@@ -1277,16 +1345,29 @@
                 x := width - margin - 1 - (child borderWidth * 2) + borderWidth.
                 hL == #leftSpaceFit ifTrue:[
                     x := x - space
-                ]
+                ].
+                child corner:(x @ (ypos + child height - 1))
             ].
-            x notNil ifTrue:[
-                subViews last corner:(x @ (ypos + child height - 1))
-            ]
-        ]
+        ].
+        index == 1 ifTrue:[
+            |x xR|
+
+            (hL == #rightFit or:[hL == #rightSpaceFit]) ifTrue:[
+                x := 0 + (child borderWidth * 2) - borderWidth.
+                hL == #rightSpaceFit ifTrue:[
+                    x := x + space
+                ].
+                xR := child corner x.
+                child origin:(x @ (child origin y))
+                      corner:(xR @ (child corner y))
+            ].
+        ].
+
+        xpos := xpos + advance + space.
     ].
 
     "Modified: 4.9.1995 / 18:43:10 / claus"
-    "Modified: 27.6.1997 / 11:50:50 / cg"
+    "Modified: 17.8.1997 / 16:20:37 / cg"
 ! !
 
 !HorizontalPanelView methodsFor:'queries'!
@@ -1370,5 +1451,5 @@
 !HorizontalPanelView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/HorizontalPanelView.st,v 1.33 1997-07-31 21:12:35 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/HorizontalPanelView.st,v 1.34 1997-08-18 10:31:47 cg Exp $'
 ! !