--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/VPanelV.st Fri Jul 16 11:44:44 1993 +0200
@@ -0,0 +1,129 @@
+"
+ COPYRIGHT (c) 1989-92 by Claus Gittinger
+ All Rights Reserved
+
+ This software is furnished under a license and may be used
+ only in accordance with the terms of that license and with the
+ inclusion of the above copyright notice. This software may not
+ be provided or otherwise made available to, or used by, any
+ other person. No title to or ownership of the software is
+ hereby transferred.
+"
+
+PanelView subclass:#VerticalPanelView
+ instanceVariableNames:''
+ classVariableNames:''
+ poolDictionaries:''
+ category:'Views-Layout'
+!
+
+VerticalPanelView comment:'
+
+COPYRIGHT (c) 1989-92 by Claus Gittinger
+ All Rights Reserved
+
+a View for childViews oriented vertical
+all real work is done in PanelView - just redefine layout
+
+%W% %E%
+
+written spring/summer 89 by claus
+'!
+
+!VerticalPanelView methodsFor:'queries'!
+
+preferedExtent
+ "return a good extent, one that makes subviews fit"
+
+ |sumOfHeights maxWidth|
+
+ subViews isNil ifTrue:[^ horizontalSpace @ verticalSpace].
+
+ "compute net height needed"
+
+ sumOfHeights := 0.
+ maxWidth := 0.
+
+ subViews do:[:child |
+ sumOfHeights := sumOfHeights + child heightIncludingBorder.
+ maxWidth := maxWidth max:(child widthIncludingBorder)
+ ].
+ borderWidth ~~ 0 ifTrue:[
+ sumOfHeights := sumOfHeights + (horizontalSpace * 2).
+ maxWidth := maxWidth + (horizontalSpace * 2).
+ ].
+ sumOfHeights := sumOfHeights + ((subViews size - 1) * verticalSpace).
+
+ ^ maxWidth @ sumOfHeights
+! !
+
+!VerticalPanelView methodsFor:'layout'!
+
+setChildPositions
+ "(re)compute position of every child"
+
+ |xpos ypos space sumOfHeights numChilds l|
+
+ subViews isNil ifTrue:[^ self].
+
+ space := verticalSpace.
+
+ "compute net height needed"
+
+ sumOfHeights := 0.
+ numChilds := subViews size.
+
+ subViews do:[:child |
+ sumOfHeights := sumOfHeights + child heightIncludingBorder.
+ ].
+
+ l := layout.
+ ((l == #center) and:[numChilds == 1]) ifTrue:[
+ l := #spread
+ ].
+
+ "compute position of topmost subview and space between them;
+ if they do hardly fit, leave no space between them "
+
+ (sumOfHeights >= height) ifTrue:[
+ ypos := 0.
+ space := 0
+ ] ifFalse:[
+ (l == #bottom) ifTrue:[
+ ypos := height - (horizontalSpace * numChilds)
+ - sumOfHeights.
+ borderWidth == 0 ifTrue:[
+ ypos := ypos + horizontalSpace
+ ].
+ ] ifFalse: [
+ (l == #spread) ifTrue:[
+ space := (height - sumOfHeights) // (numChilds + 1).
+ ypos := space.
+ (space == 0) ifTrue:[
+ ypos := (height - sumOfHeights) // 2
+ ]
+ ] ifFalse: [
+ (l == #center) ifTrue:[
+ ypos := (height - (sumOfHeights
+ + ((numChilds - 1) * space))) // 2
+ ] ifFalse:[
+ borderWidth == 0 ifTrue:[
+ ypos := 0
+ ] ifFalse:[
+ ypos := verticalSpace
+ ]
+ ]
+ ]
+ ]
+ ].
+
+ "now set positions"
+
+ subViews do:[:childView |
+ xpos := (width - childView widthIncludingBorder) // 2.
+ (xpos < 0) ifTrue:[ xpos := 0 ].
+
+ childView origin:(xpos@ypos).
+ ypos := ypos + (childView heightIncludingBorder) + space
+ ]
+! !