VerticalPanelView.st
changeset 133 e58c7c979f33
parent 131 208fa92f434d
child 155 d6f3836d2b51
--- a/VerticalPanelView.st	Mon Jul 03 04:34:22 1995 +0200
+++ b/VerticalPanelView.st	Sun Jul 23 05:03:13 1995 +0200
@@ -23,7 +23,7 @@
 COPYRIGHT (c) 1989 by Claus Gittinger
 	      All Rights Reserved
 
-$Header: /cvs/stx/stx/libwidg/VerticalPanelView.st,v 1.12 1995-06-27 02:24:25 claus Exp $
+$Header: /cvs/stx/stx/libwidg/VerticalPanelView.st,v 1.13 1995-07-23 03:02:58 claus Exp $
 '!
 
 !VerticalPanelView class methodsFor:'documentation'!
@@ -44,7 +44,7 @@
 
 version
 "
-$Header: /cvs/stx/stx/libwidg/VerticalPanelView.st,v 1.12 1995-06-27 02:24:25 claus Exp $
+$Header: /cvs/stx/stx/libwidg/VerticalPanelView.st,v 1.13 1995-07-23 03:02:58 claus Exp $
 "
 !
 
@@ -68,8 +68,10 @@
 	#center         arrange elements in the center; ignore verticalSpace
 	#spread         spread elements evenly; ignore verticalSpace
 	#spreadSpace    spread elements evenly with spacing at ends; ignore verticalSpace
-	#fit            like spread, but resize elements for tight packing; ignore verticalSpace
-	#fitSpace       like fit, with spacing; ignore verticalSpace
+	#fit            like #spread, but resize elements for tight packing; ignore verticalSpace
+	#fitSpace       like #fit, with spacing; ignore verticalSpace
+	#topFit         like #top, but extend the last element to the bottom
+	#topSpaceFit    like #topSpace, but extend the last element to the bottom
 
     the horizontal layout can be:
 
@@ -79,7 +81,7 @@
 	#right          place it at the right
 	#rightSpace     place it at the right, offset by horizontalSpace
 	#fit            resize elements horizontally to fit this panel; ignore horizontalSpace
-	#fitSpace       like fit, but add spacing; ignore horizontalSpace
+	#fitSpace       like #fit, but add spacing; ignore horizontalSpace
 
 	#leftMax        like #left, but resize elements to max of them
 	#leftSpaceMax   like #leftSpace, but resize elements
@@ -327,6 +329,39 @@
 	v open
 
 
+    example: topFit-layout
+
+	|v p b1 b2 b3|
+
+	v := StandardSystemView new.
+	v label:'vL=topFit; hL=center (default)'.
+	p := VerticalPanelView in:v.
+	p verticalLayout:#topFit.
+	p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
+	b1 := Button label:'button1' in:p.
+	b2 := Button label:'butt2' in:p.
+	b3 := Button label:'button3' in:p.
+	v extent:100 @ 300.
+	v open
+
+
+    example: topSpaceFit-layout; combined with horizontal #fitSpace
+
+	|v p b1 b2 b3|
+
+	v := StandardSystemView new.
+	v label:'vL=topFit; hL=center (default)'.
+	p := VerticalPanelView in:v.
+	p verticalLayout:#topSpaceFit.
+	p horizontalLayout:#fitSpace.
+	p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
+	b1 := Button label:'button1' in:p.
+	b2 := Button label:'butt2' in:p.
+	b3 := Button label:'button3' in:p.
+	v extent:100 @ 300.
+	v open
+
+
     example: spread-layout
 
 	|v p b1 b2 b3|
@@ -549,14 +584,22 @@
 	     compute position of topmost subview and space between them;
 	     if they do hardly fit, leave no space between them 
 	    "
-	    (sumOfHeights >= (height - (margin * 2))) ifTrue:[
+	    ((sumOfHeights >= (height - (margin * 2)))
+	    and:[l ~~ #fixTopSpace and:[l ~~ #fixTop]])  ifTrue:[
 		"
-		 if we  have not enough space for all the elements, 
+		 if we have not enough space for all the elements, 
 		 fill them tight, and show what can be shown (at least)
 		"
 		ypos := 0.
 		space := 0
 	    ] ifFalse:[
+		l == #fixTopSpace ifTrue:[
+		    l := #topSpace
+		] ifFalse:[
+		    l == #fixTop ifTrue:[
+			l := #top 
+		    ]
+		].
 		((l == #bottom) or:[l == #bottomSpace]) ifTrue:[
 		    ypos := height - (space * (numChilds - 1)) - sumOfHeights.
 	"
@@ -589,9 +632,18 @@
 			    ypos := (height - sumOfHeights) // 2
 			]
 		      ] ifFalse: [
-			((l == #top) or:[l == #topSpace]) ifTrue:[
+			((l == #top)
+			or:[l == #topSpace
+			or:[l == #topFit
+			or:[l == #topSpaceFit]]]) ifTrue:[
 			    space := space min:(height - sumOfHeights) // (numChilds + 1).
-			    l == #topSpace ifTrue:[
+			    (vLayout == #fixTop or:[vLayout == #fixTopSpace]) ifTrue:[
+				space := space max:verticalSpace.
+			    ] ifFalse:[
+				space := space max:0.
+			    ].
+			    (l == #topSpace 
+			    or:[l == #topSpaceFit]) ifTrue:[
 				ypos := space.
 			    ] ifFalse:[
 				ypos := 0
@@ -628,7 +680,7 @@
     "
      now set positions
     "
-    subViews do:[:child |
+    subViews keysAndValuesDo:[:index :child |
 	|xpos bwChild wChild|
 
 	wChild := child widthIncludingBorder.
@@ -668,7 +720,8 @@
 	].
 	(xpos < 0) ifTrue:[ xpos := 0 ].
 
-	(vLayout == #fit or:[vLayout == #fitSpace]) ifTrue:[
+	(vLayout == #fit 
+	or:[vLayout == #fitSpace]) ifTrue:[
 	    child origin:(xpos @ ypos rounded)
 		  corner:(xpos + (child width))
 			 @ (ypos + hEach - bwChild) rounded.
@@ -676,6 +729,20 @@
 	] ifFalse:[
 	    child origin:(xpos@ypos).
 	    ypos := ypos + (child heightIncludingBorder) + space
+	].
+
+	index == numChilds ifTrue:[
+	    |y|
+
+	    vLayout == #topFit ifTrue:[
+		y := height - margin.
+	    ].
+	    vLayout == #topSpaceFit ifTrue:[
+		y := height - margin - space
+	    ].
+	    y notNil ifTrue:[
+		subViews last corner:(xpos + child width) @ y
+	    ]
 	]
     ]
 ! !
@@ -685,12 +752,19 @@
 horizontalLayout
     "return the horizontal layout as symbol.
      the returned value is one of
-	#left 
-	#leftSpace 
-	#center
-	#right 
-	#rightSpace 
-	#fit 
+	#left           place element at the left
+	#leftSpace      place element at the left, offset by horizontalSpace
+	#center         place elements horizontally centered; ignore horizontalSpace
+	#right          place it at the right
+	#rightSpace     place it at the right, offset by horizontalSpace
+	#fit            resize elements horizontally to fit this panel; ignore horizontalSpace
+	#fitSpace       like #fit, but add spacing; ignore horizontalSpace
+
+	#leftMax        like #left, but resize elements to max of them
+	#leftSpaceMax   like #leftSpace, but resize elements
+	#centerMax      like #center, but resize elements
+	#rightMax       like #right, but resize elements to max of them
+	#rightSpaceMax  like #rightSpace, but resize elements
       the default is #centered
     "
 
@@ -700,12 +774,19 @@
 horizontalLayout:aSymbol
     "change the horizontal layout as symbol.
      The argument, aSymbol must be one of:
-	#left 
-	#leftSpace 
-	#center
-	#right 
-	#rightSpace 
-	#fit 
+	#left           place element at the left
+	#leftSpace      place element at the left, offset by horizontalSpace
+	#center         place elements horizontally centered; ignore horizontalSpace
+	#right          place it at the right
+	#rightSpace     place it at the right, offset by horizontalSpace
+	#fit            resize elements horizontally to fit this panel; ignore horizontalSpace
+	#fitSpace       like #fit, but add spacing; ignore horizontalSpace
+
+	#leftMax        like #left, but resize elements to max of them
+	#leftSpaceMax   like #leftSpace, but resize elements
+	#centerMax      like #center, but resize elements
+	#rightMax       like #right, but resize elements to max of them
+	#rightSpaceMax  like #rightSpace, but resize elements
       the default (if never changed) is #centered
     "
 
@@ -718,13 +799,17 @@
 verticalLayout
     "return the vertical layout as a symbol.
      the returned value is one of
-	#top
-	#topSpace
-	#spread
-	#fit
-	#center
-	#bottom
-	#bottomSpace
+	#top            arrange elements at the top
+	#topSpace       arrange elements at the top, start with spacing
+	#bottom         arrange elements at the bottom
+	#bottomSpace    arrange elements at the bottom, start with spacing
+	#center         arrange elements in the center; ignore verticalSpace
+	#spread         spread elements evenly; ignore verticalSpace
+	#spreadSpace    spread elements evenly with spacing at ends; ignore verticalSpace
+	#fit            like #spread, but resize elements for tight packing; ignore verticalSpace
+	#fitSpace       like #fit, with spacing; ignore verticalSpace
+	#topFit         like #top, but extend the last element to the bottom
+	#topSpaceFit    like #topSpace, but extend the last element to the bottom
       the default is #centered
     "
 
@@ -734,13 +819,17 @@
 verticalLayout:aSymbol
     "change the vertical layout as a symbol.
      The argument, aSymbol must be one of:
-	#top
-	#topSpace
-	#spread
-	#fit
-	#center
-	#bottom
-	#bottomSpace
+	#top            arrange elements at the top
+	#topSpace       arrange elements at the top, start with spacing
+	#bottom         arrange elements at the bottom
+	#bottomSpace    arrange elements at the bottom, start with spacing
+	#center         arrange elements in the center; ignore verticalSpace
+	#spread         spread elements evenly; ignore verticalSpace
+	#spreadSpace    spread elements evenly with spacing at ends; ignore verticalSpace
+	#fit            like #spread, but resize elements for tight packing; ignore verticalSpace
+	#fitSpace       like #fit, with spacing; ignore verticalSpace
+	#topFit         like #top, but extend the last element to the bottom
+	#topSpaceFit    like #topSpace, but extend the last element to the bottom
       the default (if never changed) is #centered
     "