code compactified (slightly)
authorClaus Gittinger <cg@exept.de>
Fri, 27 Jun 1997 11:56:45 +0200
changeset 1254 c9e604f03e6a
parent 1253 385bb80488f5
child 1255 c1bf6a3dbb78
code compactified (slightly)
HPanelV.st
HorizontalPanelView.st
VPanelV.st
VerticalPanelView.st
--- a/HPanelV.st	Fri Jun 20 14:45:27 1997 +0200
+++ b/HPanelV.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/Attic/HPanelV.st,v 1.31 1997-03-29 10:57:46 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/Attic/HPanelV.st,v 1.32 1997-06-27 09:56:45 cg Exp $'
 ! !
--- 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 $'
 ! !
--- a/VPanelV.st	Fri Jun 20 14:45:27 1997 +0200
+++ b/VPanelV.st	Fri Jun 27 11:56:45 1997 +0200
@@ -652,7 +652,7 @@
     "(re)compute position of every child"
 
     |ypos space sumOfHeights numChilds l hEach hInside 
-     maxWidth resizeToMax hL m2 subViews ext|
+     maxWidth resizeToMax hL m2 subViews ext restHeight|
 
     subViews := self subViews.
     subViews size == 0 ifTrue:[^ self].
@@ -688,6 +688,7 @@
              compute net height needed
             "
             sumOfHeights := subViews inject:0 into:[:sumSoFar :child | sumSoFar + child heightIncludingBorder].
+            restHeight := height - sumOfHeights.
 
             l := vLayout.
             ((l == #center) and:[numChilds == 1]) ifTrue:[
@@ -718,7 +719,7 @@
                     ]
                 ].
                 ((l == #bottom) or:[l == #bottomSpace]) ifTrue:[
-                    ypos := height - (space * (numChilds - 1)) - sumOfHeights.
+                    ypos := restHeight - (space * (numChilds - 1)).
         "
                     borderWidth == 0 ifTrue:[
                         ypos := ypos + space 
@@ -731,29 +732,29 @@
                     ].
 
                     ypos < 0 ifTrue:[
-                        space := space min:(height - sumOfHeights) // (numChilds + 1).
-                        ypos := height - (space * numChilds) - sumOfHeights.
+                        space := space min:(restHeight // (numChilds + 1)).
+                        ypos := restHeight - (space * numChilds).
                     ]
                 ] ifFalse: [
                     (l == #spread) ifTrue:[
-                        space := (height - m2 - sumOfHeights) // (numChilds - 1).
+                        space := (restHeight - m2) // (numChilds - 1).
                         ypos := margin.
                         (space == 0) ifTrue:[
-                            ypos := (height - sumOfHeights) // 2
+                            ypos := restHeight // 2
                         ]
                     ] ifFalse: [
                       (l == #spreadSpace) ifTrue:[
-                        space := (height - sumOfHeights) // (numChilds + 1).
+                        space := restHeight // (numChilds + 1).
                         ypos := space.
                         (space == 0) ifTrue:[
-                            ypos := (height - sumOfHeights) // 2
+                            ypos := restHeight // 2
                         ]
                       ] ifFalse: [
                         ((l == #top)
                         or:[l == #topSpace
                         or:[l == #topFit
                         or:[l == #topSpaceFit]]]) ifTrue:[
-                            space := space min:(height - sumOfHeights - m2) // (numChilds + 1).
+                            space := space min:(restHeight - m2) // (numChilds + 1).
                             (vLayout == #fixTop or:[vLayout == #fixTopSpace]) ifTrue:[
                                 space := space max:verticalSpace.
                             ] ifFalse:[
@@ -775,12 +776,10 @@
                             ]
                         ] ifFalse:[
                             "center"
-                            ypos := (height - (sumOfHeights
-                                                 + ((numChilds - 1) * space))) // 2.
+                            ypos := (restHeight - ((numChilds - 1) * space)) // 2.
                             ypos < 0 ifTrue:[
-                                space := (height - sumOfHeights) // (numChilds + 1).
-                                ypos := (height - (sumOfHeights
-                                               + ((numChilds - 1) * space))) // 2.
+                                space := restHeight // (numChilds + 1).
+                                ypos := (restHeight - ((numChilds - 1) * space)) // 2.
                             ]
                         ]
                       ]
@@ -886,7 +885,7 @@
     ]
 
     "Modified: 4.9.1995 / 18:43:29 / claus"
-    "Modified: 28.1.1997 / 17:57:05 / cg"
+    "Modified: 27.6.1997 / 11:50:47 / cg"
 ! !
 
 !VerticalPanelView methodsFor:'queries'!
@@ -964,5 +963,5 @@
 !VerticalPanelView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/Attic/VPanelV.st,v 1.29 1997-02-25 13:03:55 ca Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/Attic/VPanelV.st,v 1.30 1997-06-27 09:56:25 cg Exp $'
 ! !
--- a/VerticalPanelView.st	Fri Jun 20 14:45:27 1997 +0200
+++ b/VerticalPanelView.st	Fri Jun 27 11:56:45 1997 +0200
@@ -652,7 +652,7 @@
     "(re)compute position of every child"
 
     |ypos space sumOfHeights numChilds l hEach hInside 
-     maxWidth resizeToMax hL m2 subViews ext|
+     maxWidth resizeToMax hL m2 subViews ext restHeight|
 
     subViews := self subViews.
     subViews size == 0 ifTrue:[^ self].
@@ -688,6 +688,7 @@
              compute net height needed
             "
             sumOfHeights := subViews inject:0 into:[:sumSoFar :child | sumSoFar + child heightIncludingBorder].
+            restHeight := height - sumOfHeights.
 
             l := vLayout.
             ((l == #center) and:[numChilds == 1]) ifTrue:[
@@ -718,7 +719,7 @@
                     ]
                 ].
                 ((l == #bottom) or:[l == #bottomSpace]) ifTrue:[
-                    ypos := height - (space * (numChilds - 1)) - sumOfHeights.
+                    ypos := restHeight - (space * (numChilds - 1)).
         "
                     borderWidth == 0 ifTrue:[
                         ypos := ypos + space 
@@ -731,29 +732,29 @@
                     ].
 
                     ypos < 0 ifTrue:[
-                        space := space min:(height - sumOfHeights) // (numChilds + 1).
-                        ypos := height - (space * numChilds) - sumOfHeights.
+                        space := space min:(restHeight // (numChilds + 1)).
+                        ypos := restHeight - (space * numChilds).
                     ]
                 ] ifFalse: [
                     (l == #spread) ifTrue:[
-                        space := (height - m2 - sumOfHeights) // (numChilds - 1).
+                        space := (restHeight - m2) // (numChilds - 1).
                         ypos := margin.
                         (space == 0) ifTrue:[
-                            ypos := (height - sumOfHeights) // 2
+                            ypos := restHeight // 2
                         ]
                     ] ifFalse: [
                       (l == #spreadSpace) ifTrue:[
-                        space := (height - sumOfHeights) // (numChilds + 1).
+                        space := restHeight // (numChilds + 1).
                         ypos := space.
                         (space == 0) ifTrue:[
-                            ypos := (height - sumOfHeights) // 2
+                            ypos := restHeight // 2
                         ]
                       ] ifFalse: [
                         ((l == #top)
                         or:[l == #topSpace
                         or:[l == #topFit
                         or:[l == #topSpaceFit]]]) ifTrue:[
-                            space := space min:(height - sumOfHeights - m2) // (numChilds + 1).
+                            space := space min:(restHeight - m2) // (numChilds + 1).
                             (vLayout == #fixTop or:[vLayout == #fixTopSpace]) ifTrue:[
                                 space := space max:verticalSpace.
                             ] ifFalse:[
@@ -775,12 +776,10 @@
                             ]
                         ] ifFalse:[
                             "center"
-                            ypos := (height - (sumOfHeights
-                                                 + ((numChilds - 1) * space))) // 2.
+                            ypos := (restHeight - ((numChilds - 1) * space)) // 2.
                             ypos < 0 ifTrue:[
-                                space := (height - sumOfHeights) // (numChilds + 1).
-                                ypos := (height - (sumOfHeights
-                                               + ((numChilds - 1) * space))) // 2.
+                                space := restHeight // (numChilds + 1).
+                                ypos := (restHeight - ((numChilds - 1) * space)) // 2.
                             ]
                         ]
                       ]
@@ -886,7 +885,7 @@
     ]
 
     "Modified: 4.9.1995 / 18:43:29 / claus"
-    "Modified: 28.1.1997 / 17:57:05 / cg"
+    "Modified: 27.6.1997 / 11:50:47 / cg"
 ! !
 
 !VerticalPanelView methodsFor:'queries'!
@@ -964,5 +963,5 @@
 !VerticalPanelView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/VerticalPanelView.st,v 1.29 1997-02-25 13:03:55 ca Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/VerticalPanelView.st,v 1.30 1997-06-27 09:56:25 cg Exp $'
 ! !