AlignmentOrigin.st
changeset 4296 00f9234e8c1c
parent 4282 22f5625bfa52
child 4355 6616dc6cedd5
equal deleted inserted replaced
4295:a3333891d7f3 4296:00f9234e8c1c
   207 !
   207 !
   208 
   208 
   209 hash
   209 hash
   210     ^ super hash
   210     ^ super hash
   211       + leftAlignmentFraction hash + topAlignmentFraction hash 
   211       + leftAlignmentFraction hash + topAlignmentFraction hash 
       
   212 ! !
       
   213 
       
   214 !AlignmentOrigin methodsFor:'computing'!
       
   215 
       
   216 rectangleRelativeTo:superRectangle preferred:prefRectHolder
       
   217     "compute the rectangle represented by the receiver,
       
   218      given the superView's rectangle and the view's preferredExtent."
       
   219 
       
   220     |x y prefRect|
       
   221 
       
   222     prefRect := prefRectHolder value.
       
   223 
       
   224     x := superRectangle left.
       
   225     y := superRectangle top.
       
   226 
       
   227     leftOffset notNil ifTrue:[
       
   228         x := x + leftOffset value
       
   229     ].
       
   230     topOffset notNil ifTrue:[
       
   231         y := y + topOffset value
       
   232     ].
       
   233     leftFraction notNil ifTrue:[
       
   234         x := x + (superRectangle width * leftFraction value)
       
   235     ].
       
   236     topFraction notNil ifTrue:[
       
   237         y := y + (superRectangle height * topFraction value)
       
   238     ].
       
   239     leftAlignmentFraction ~~ 0 ifTrue:[
       
   240         x := x - (prefRect width * leftAlignmentFraction value)
       
   241     ].
       
   242     topAlignmentFraction ~~ 0 ifTrue:[
       
   243         y := y - (prefRect height * topAlignmentFraction value)
       
   244     ].
       
   245     ^ Rectangle left:x top:y extent:prefRect extent
       
   246 
       
   247     "
       
   248      |superRect aO|
       
   249 
       
   250      superRect := 0@0 corner:100@100.
       
   251      aO := (AlignmentOrigin new).
       
   252      aO leftFraction:0.5;
       
   253         topFraction:0.5;
       
   254         leftAlignmentFraction:0.5;
       
   255         topAlignmentFraction:0.5.
       
   256      aO rectangleRelativeTo:superRect preferred:(0@0 corner:30@30) 
       
   257     "
       
   258 
       
   259     "Modified: / 13-08-1998 / 18:39:26 / cg"
       
   260     "Modified (comment): / 17-07-2019 / 10:03:04 / Claus Gittinger"
   212 ! !
   261 ! !
   213 
   262 
   214 !AlignmentOrigin methodsFor:'converting'!
   263 !AlignmentOrigin methodsFor:'converting'!
   215 
   264 
   216 fromLiteralArrayEncoding:encodingArray
   265 fromLiteralArrayEncoding:encodingArray
   298     "return true, if this is an alignmentOrigin"
   347     "return true, if this is an alignmentOrigin"
   299 
   348 
   300     ^ true
   349     ^ true
   301 
   350 
   302 
   351 
   303 !
       
   304 
       
   305 rectangleRelativeTo:superRectangle preferred:prefRectHolder
       
   306     "compute the rectangle represented by the receiver,
       
   307      given the superViews rectangle and the view's preferredExtent."
       
   308 
       
   309     |x y prefRect|
       
   310 
       
   311     prefRect := prefRectHolder value.
       
   312 
       
   313     x := superRectangle left.
       
   314     y := superRectangle top.
       
   315 
       
   316     leftOffset notNil ifTrue:[
       
   317         x := x + leftOffset value
       
   318     ].
       
   319     topOffset notNil ifTrue:[
       
   320         y := y + topOffset value
       
   321     ].
       
   322     leftFraction notNil ifTrue:[
       
   323         x := x + (superRectangle width * leftFraction value)
       
   324     ].
       
   325     topFraction notNil ifTrue:[
       
   326         y := y + (superRectangle height * topFraction value)
       
   327     ].
       
   328     leftAlignmentFraction ~~ 0 ifTrue:[
       
   329         x := x - (prefRect width * leftAlignmentFraction value)
       
   330     ].
       
   331     topAlignmentFraction ~~ 0 ifTrue:[
       
   332         y := y - (prefRect height * topAlignmentFraction value)
       
   333     ].
       
   334     ^ Rectangle left:x top:y extent:prefRect extent
       
   335 
       
   336     "
       
   337      |superRect aO|
       
   338 
       
   339      superRect := 0@0 corner:100@100.
       
   340      aO := (AlignmentOrigin new).
       
   341      aO leftFraction:0.5;
       
   342         topFraction:0.5;
       
   343         leftAlignmentFraction:0.5;
       
   344         topAlignmentFraction:0.5.
       
   345      aO rectangleRelativeTo:superRect preferred:(0@0 corner:30@30) 
       
   346     "
       
   347 
       
   348     "Modified: / 13.8.1998 / 18:39:26 / cg"
       
   349 ! !
   352 ! !
   350 
   353 
   351 !AlignmentOrigin class methodsFor:'documentation'!
   354 !AlignmentOrigin class methodsFor:'documentation'!
   352 
   355 
   353 version
   356 version