HorizontalPanelView.st
changeset 1254 c9e604f03e6a
parent 1165 16b8537595fd
child 1291 03ed7c44f194
--- a/HorizontalPanelView.st	Fri Jun 20 14:45:27 1997 +0200
+++ b/HorizontalPanelView.st	Fri Jun 27 11:56:45 1997 +0200
@@ -1047,7 +1047,8 @@
      my size has changed"
 
     |xpos space sumOfWidths numChilds l wEach wInside hL vL resizeToMaxV 
-     resizeToMaxH maxHeight maxWidth d m2 subViews ext|
+     resizeToMaxH maxHeight maxWidth d m2 subViews ext
+     restWidth|
 
     subViews := self subViews.
     subViews size == 0 ifTrue:[^ self].
@@ -1060,6 +1061,7 @@
 
     space := horizontalSpace.
     numChilds := subViews size.
+
     m2 := margin * 2.
     wInside := width - m2 + (borderWidth*2) - subViews last borderWidth.
 
@@ -1097,6 +1099,7 @@
             ] ifFalse:[
                 sumOfWidths := subViews inject:0 into:[:sumSoFar :child | sumSoFar + child widthIncludingBorder].
             ].
+            restWidth := width - sumOfWidths.
 
             l := hL.
             ((l == #center) and:[numChilds == 1]) ifTrue:[
@@ -1123,7 +1126,7 @@
                     ]
                 ].
                 ((l == #right) or:[l == #rightSpace]) ifTrue:[
-                    xpos := width - (space * (numChilds - 1)) - sumOfWidths.
+                    xpos := restWidth - (space * (numChilds - 1)).
         "
                     borderWidth == 0 ifTrue:[
                         xpos := xpos + space 
@@ -1136,29 +1139,29 @@
                     ].
 
                     xpos < 0 ifTrue:[
-                        space := space min:(width - sumOfWidths) // (numChilds + 1).
-                        xpos := width - (space * numChilds) - sumOfWidths.
+                        space := space min:(restWidth // (numChilds + 1)).
+                        xpos := restWidth - (space * numChilds).
                     ]
                 ] ifFalse:[
                     (l == #spread) ifTrue:[
-                        space := (width - m2 - sumOfWidths) // (numChilds - 1).
+                        space := (restWidth - m2) // (numChilds - 1).
                         xpos := margin.
                         (space == 0) ifTrue:[
-                            xpos := (width - sumOfWidths) // 2
+                            xpos := restWidth // 2
                         ]
                     ] ifFalse:[
                       (l == #spreadSpace) ifTrue:[
-                        space := (width - sumOfWidths) // (numChilds + 1).
+                        space := restWidth // (numChilds + 1).
                         xpos := space.
                         (space == 0) ifTrue:[
-                            xpos := (width - sumOfWidths) // 2
+                            xpos := restWidth // 2
                         ]
                       ] ifFalse:[
                         ((l == #left) 
                         or:[l == #leftSpace
                         or:[l == #leftFit
                         or:[l == #leftSpaceFit]]]) ifTrue:[
-                            space := space min:(width - sumOfWidths - m2) // (numChilds + 1).
+                            space := space min:(restWidth - m2) // (numChilds + 1).
                             (hL == #fixLeft or:[hL == #fixLeftSpace]) ifTrue:[
                                 space := space max:horizontalSpace.
                             ] ifFalse:[
@@ -1180,12 +1183,10 @@
                             ]
                         ] ifFalse:[
                             "center"
-                            xpos := (width - (sumOfWidths
-                                              + ((numChilds - 1) * space))) // 2.
+                            xpos := (restWidth - ((numChilds - 1) * space)) // 2.
                             xpos < 0 ifTrue:[
-                                space := (width - sumOfWidths) // (numChilds + 1).
-                                xpos := (width - (sumOfWidths
-                                               + ((numChilds - 1) * space))) // 2.
+                                space := restWidth // (numChilds + 1).
+                                xpos := (restWidth - ((numChilds - 1) * space)) // 2.
                             ]
                         ]
                       ]
@@ -1292,7 +1293,7 @@
     ].
 
     "Modified: 4.9.1995 / 18:43:10 / claus"
-    "Modified: 28.1.1997 / 17:50:49 / cg"
+    "Modified: 27.6.1997 / 11:50:50 / cg"
 ! !
 
 !HorizontalPanelView methodsFor:'queries'!
@@ -1376,5 +1377,5 @@
 !HorizontalPanelView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/HorizontalPanelView.st,v 1.31 1997-03-29 10:57:46 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/HorizontalPanelView.st,v 1.32 1997-06-27 09:56:45 cg Exp $'
 ! !