--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/AlignmentOrigin.st Sun Jul 02 18:18:00 1995 +0200
@@ -0,0 +1,95 @@
+LayoutOrigin subclass:#AlignmentOrigin
+ instanceVariableNames:'leftAlignmentFraction topAlignmentFraction'
+ classVariableNames:''
+ poolDictionaries:''
+ category:'Graphics-Geometry'
+!
+
+!AlignmentOrigin methodsFor:'accessing'!
+
+leftAlignmentFraction:something
+ "set leftAlignmentFraction"
+
+ leftAlignmentFraction := something.
+!
+
+leftAlignmentFraction
+ "return leftAlignmentFraction"
+
+ ^ leftAlignmentFraction
+!
+
+topAlignmentFraction:something
+ "set topAlignmentFraction"
+
+ topAlignmentFraction := something.
+!
+
+topAlignmentFraction
+ "return topAlignmentFraction"
+
+ ^ topFraction
+! !
+
+!AlignmentOrigin methodsFor:'printing & storing'!
+
+displayString
+ ^ 'LayoutOrigin('
+ , 'l: ' , leftFraction displayString
+ , '+' , leftOffset displayString
+ , ' t: ' , topFraction displayString
+ , '+' , topOffset displayString
+ , ' a: ' , leftAlignmentFraction displayString
+ , '@' , topAlignmentFraction displayString
+ , ')'
+! !
+
+
+!AlignmentOrigin methodsFor:'queries'!
+
+rectangleRelativeTo:superRectangle preferred:prefRect
+ |x y|
+
+ leftOffset isNil ifTrue:[
+ x := 0
+ ] ifFalse:[
+ x := leftOffset
+ ].
+ topOffset isNil ifTrue:[
+ y := 0
+ ] ifFalse:[
+ y := topOffset
+ ].
+ leftFraction notNil ifTrue:[
+ x := x + (superRectangle width * leftFraction)
+ ].
+ topFraction notNil ifTrue:[
+ y := y + (superRectangle height * topFraction)
+ ].
+ leftAlignmentFraction ~~ 0 ifTrue:[
+ x := x - (prefRect width * leftAlignmentFraction)
+ ].
+ topAlignmentFraction ~~ 0 ifTrue:[
+ y := y - (prefRect height * topAlignmentFraction)
+ ].
+ ^ Rectangle origin:x@y extent:prefRect extent
+
+ "
+ |superRect aO|
+
+ superRect := 0@0 corner:100@100.
+ aO := (AlignmentOrigin new).
+ aO leftFraction:0.5;
+ topFraction:0.5;
+ leftAlignmentFraction:0.5;
+ topAlignmentFraction:0.5.
+ aO rectangleRelativeTo:superRect preferred:(0@0 corner:30@30)
+ "
+! !
+
+!AlignmentOrigin methodsFor:'initialization'!
+
+initialize
+ super initialize.
+ leftAlignmentFraction := topAlignmentFraction := 0.
+! !