--- a/VerticalPanelView.st Sun Aug 07 15:22:53 1994 +0200
+++ b/VerticalPanelView.st Sun Aug 07 15:23:42 1994 +0200
@@ -18,17 +18,99 @@
!
VerticalPanelView comment:'
-
COPYRIGHT (c) 1989 by Claus Gittinger
All Rights Reserved
-a View for childViews oriented vertical
-all real work is done in PanelView - just redefine layout
+$Header: /cvs/stx/stx/libwidg/VerticalPanelView.st,v 1.4 1994-08-07 13:23:33 claus Exp $
+'!
+
+!VerticalPanelView class methodsFor:'documentation'!
+
+copyright
+"
+ COPYRIGHT (c) 1989 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.
+"
+!
+
+version
+"
+$Header: /cvs/stx/stx/libwidg/VerticalPanelView.st,v 1.4 1994-08-07 13:23:33 claus Exp $
+"
+!
+
+documentation
+"
+ a View which arranges its child-views in a vertical column.
+ All real work is done in PanelView - only the layout computation is
+ redefined here.
+
+ example: default layout (centered)
+
+ |v p b1 b2 b3|
+
+ v := StandardSystemView new.
+ p := VerticalPanelView in:v.
+ 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:100 @ 300.
+ v open
+
-$Header: /cvs/stx/stx/libwidg/VerticalPanelView.st,v 1.3 1993-10-13 02:49:47 claus Exp $
+ example: left-layout
+
+ |v p b1 b2 b3|
+
+ v := StandardSystemView new.
+ p := VerticalPanelView in:v.
+ p layout:#top.
+ 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:100 @ 300.
+ v open
+
+
+ example: right-layout
+
+ |v p b1 b2 b3|
-written spring/summer 89 by claus
-'!
+ v := StandardSystemView new.
+ p := VerticalPanelView in:v.
+ p layout:#bottom.
+ 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:100 @ 300.
+ v open
+
+
+ example: spread-layout
+
+ |v p b1 b2 b3|
+
+ v := StandardSystemView new.
+ p := VerticalPanelView in:v.
+ p layout:#spread.
+ 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:100 @ 300.
+ v open
+"
+! !
!VerticalPanelView methodsFor:'queries'!
@@ -70,13 +152,9 @@
"compute net height needed"
- sumOfHeights := 0.
+ sumOfHeights := subViews inject:0 into:[:sumSoFar :child | sumSoFar + child heightIncludingBorder].
numChilds := subViews size.
- subViews do:[:child |
- sumOfHeights := sumOfHeights + child heightIncludingBorder.
- ].
-
l := layout.
((l == #center) and:[numChilds == 1]) ifTrue:[
l := #spread
@@ -85,16 +163,21 @@
"compute position of topmost subview and space between them;
if they do hardly fit, leave no space between them "
- (sumOfHeights >= height) ifTrue:[
+ (sumOfHeights >= (height - (margin * 2))) ifTrue:[
ypos := 0.
space := 0
] ifFalse:[
(l == #bottom) ifTrue:[
- ypos := height - (horizontalSpace * numChilds)
- - sumOfHeights.
+ ypos := height - (space * numChilds) - sumOfHeights.
+"
borderWidth == 0 ifTrue:[
- ypos := ypos + horizontalSpace
+ ypos := ypos + space
].
+"
+ ypos < 0 ifTrue:[
+ space := space min:(height - sumOfHeights) // (numChilds + 1).
+ ypos := height - (space * numChilds) - sumOfHeights.
+ ]
] ifFalse: [
(l == #spread) ifTrue:[
space := (height - sumOfHeights) // (numChilds + 1).
@@ -105,18 +188,28 @@
] ifFalse: [
(l == #center) ifTrue:[
ypos := (height - (sumOfHeights
- + ((numChilds - 1) * space))) // 2
+ + ((numChilds - 1) * space))) // 2.
+ ypos < 0 ifTrue:[
+ space := (height - sumOfHeights) // (numChilds + 1).
+ ypos := (height - (sumOfHeights
+ + ((numChilds - 1) * space))) // 2.
+ ]
] ifFalse:[
+"
borderWidth == 0 ifTrue:[
ypos := 0
] ifFalse:[
ypos := verticalSpace
- ]
+ ].
+"
+ space := space min:(height - sumOfHeights) // (numChilds + 1).
+ ypos := space.
]
]
]
].
+
"now set positions"
subViews do:[:childView |