diff -r 8f73cdf66b60 -r 612861ef768a AlignmentOrigin.st --- a/AlignmentOrigin.st Sat Apr 27 16:19:26 1996 +0200 +++ b/AlignmentOrigin.st Sat Apr 27 19:51:19 1996 +0200 @@ -43,10 +43,12 @@ reference point within the component is positioned. The reference point itself is specified as fraction of the components size. - Notice: this class was implemented using protocol information - from alpha testers - it may not be complete or compatible to - the corresponding ST-80 class. If you encounter any incompatibilities, - please forward a note to the ST/X team. + Notice: + this class was implemented using protocol information + from alpha testers - it may not be complete or compatible to + the corresponding ST-80 class. + If you encounter any incompatibilities, please forward a note + describing the incompatibility verbal (i.e. no code) to the ST/X team. [author:] Claus Gittinger @@ -59,56 +61,62 @@ examples " + Although the examples below use a button as component, + they work of course with any type of subview .... + using a LayoutOrigin, to control the top-left origins position of a component (i.e. origin at:0.5@0.5): - - |top button| + [exBegin] + |top button| - top := StandardSystemView new. - top extent:300@300. + top := StandardSystemView new. + top extent:300@300. - button := Button label:'component'. - top add:button in:(LayoutOrigin new - leftFraction:0.5; - topFraction:0.5). + button := Button label:'component'. + top add:button in:(LayoutOrigin new + leftFraction:0.5; + topFraction:0.5). - top open + top open + [exEnd] using an AlignmentOrigin, to control the centers position of a component (i.e. center of component at:0.5@0.5): - - |top button| + [exBegin] + |top button| - top := StandardSystemView new. - top extent:300@300. + top := StandardSystemView new. + top extent:300@300. - button := Button label:'component'. - top add:button in:(AlignmentOrigin new - leftFraction:0.5; - topFraction:0.5; - leftAlignmentFraction:0.5; - topAlignmentFraction:0.5). + button := Button label:'component'. + top add:button in:(AlignmentOrigin new + leftFraction:0.5; + topFraction:0.5; + leftAlignmentFraction:0.5; + topAlignmentFraction:0.5). - top open + top open + [exEnd] using an AlignmentOrigin, to control the bottom-right position of a component (i.e. bottom-right of component at:0.5@0.5): - - |top button| + [exBegin] + |top button| - top := StandardSystemView new. - top extent:300@300. + top := StandardSystemView new. + top extent:300@300. - button := Button label:'component'. - top add:button in:(AlignmentOrigin new - leftFraction:0.5; - topFraction:0.5; - leftAlignmentFraction:1.0; - topAlignmentFraction:1.0). + button := Button label:'component'. + top add:button in:(AlignmentOrigin new + leftFraction:0.5; + topFraction:0.5; + leftAlignmentFraction:1.0; + topAlignmentFraction:1.0). - top open + top open + [exEnd] " ! ! @@ -198,29 +206,32 @@ !AlignmentOrigin methodsFor:'queries'! rectangleRelativeTo:superRectangle preferred:prefRect + "compute the rectangle represented by the receiver, + given the superViews rectangle and the views preferredExtent." + |x y| leftOffset isNil ifTrue:[ - x := 0 + x := 0 ] ifFalse:[ - x := leftOffset + x := leftOffset ]. topOffset isNil ifTrue:[ - y := 0 + y := 0 ] ifFalse:[ - y := topOffset + y := topOffset ]. leftFraction notNil ifTrue:[ - x := x + (superRectangle width * leftFraction) + x := x + (superRectangle width * leftFraction) ]. topFraction notNil ifTrue:[ - y := y + (superRectangle height * topFraction) + y := y + (superRectangle height * topFraction) ]. leftAlignmentFraction ~~ 0 ifTrue:[ - x := x - (prefRect width * leftAlignmentFraction) + x := x - (prefRect width * leftAlignmentFraction) ]. topAlignmentFraction ~~ 0 ifTrue:[ - y := y - (prefRect height * topAlignmentFraction) + y := y - (prefRect height * topAlignmentFraction) ]. ^ Rectangle origin:x@y extent:prefRect extent @@ -230,15 +241,17 @@ superRect := 0@0 corner:100@100. aO := (AlignmentOrigin new). aO leftFraction:0.5; - topFraction:0.5; - leftAlignmentFraction:0.5; - topAlignmentFraction:0.5. + topFraction:0.5; + leftAlignmentFraction:0.5; + topAlignmentFraction:0.5. aO rectangleRelativeTo:superRect preferred:(0@0 corner:30@30) " + + "Modified: 27.4.1996 / 14:53:56 / cg" ! ! !AlignmentOrigin class methodsFor:'documentation'! version - ^ '$Header: /cvs/stx/stx/libview2/AlignmentOrigin.st,v 1.11 1996-04-25 16:21:00 cg Exp $' + ^ '$Header: /cvs/stx/stx/libview2/AlignmentOrigin.st,v 1.12 1996-04-27 17:51:19 cg Exp $' ! !