LayoutFrame.st
changeset 77 e846c6f3ac50
child 83 97fd04d167c8
equal deleted inserted replaced
76:e4458543dda2 77:e846c6f3ac50
       
     1 'From Smalltalk/X, Version:2.10.5 on 15-apr-1995 at 12:14:46 pm'!
       
     2 
       
     3 LayoutOrigin subclass:#LayoutFrame
       
     4 	 instanceVariableNames:'rightFraction bottomFraction
       
     5 		rightOffset bottomOffset'
       
     6 	 classVariableNames:''
       
     7 	 poolDictionaries:''
       
     8 	 category:'Graphics-Support-ST80 compatibility'
       
     9 !
       
    10 
       
    11 !LayoutFrame methodsFor:'accessing'!
       
    12 
       
    13 rightFraction:something
       
    14     "set rightFraction"
       
    15 
       
    16     rightFraction := something.
       
    17 !
       
    18 
       
    19 rightFraction
       
    20     "return rightFraction"
       
    21 
       
    22     ^ rightFraction
       
    23 !
       
    24 
       
    25 rightOffset:something
       
    26     "set rightOffset"
       
    27 
       
    28     rightOffset := something.
       
    29 !
       
    30 
       
    31 rightOffset
       
    32     "return rightOffset"
       
    33 
       
    34     ^ rightOffset
       
    35 !
       
    36 
       
    37 rightFraction:something offset:o
       
    38     "set rightFraction and offset"
       
    39 
       
    40     rightFraction := something.
       
    41     rightOffset := o
       
    42 !
       
    43 
       
    44 bottomFraction:something
       
    45     "set bottomFraction"
       
    46 
       
    47     bottomFraction := something.
       
    48 !
       
    49 
       
    50 bottomFraction
       
    51     "return bottomFraction"
       
    52 
       
    53     ^ bottomFraction
       
    54 !
       
    55 
       
    56 bottomOffset:something
       
    57     "set bottomOffset"
       
    58 
       
    59     bottomOffset := something.
       
    60 !
       
    61 
       
    62 bottomOffset
       
    63     "return bottomOffset"
       
    64 
       
    65     ^ bottomOffset
       
    66 !
       
    67 
       
    68 bottomFraction:something offset:o
       
    69     "set bottomFraction and offset"
       
    70 
       
    71     bottomFraction := something.
       
    72     bottomOffset := o
       
    73 ! !
       
    74 
       
    75 
       
    76 !LayoutFrame methodsFor:'queries'!
       
    77 
       
    78 rectangleRelativeTo:superRectangle preferred:prefRect
       
    79     |x1 y1 x2 y2|
       
    80 
       
    81     leftOffset isNil ifTrue:[
       
    82 	x1 := 0
       
    83     ] ifFalse:[
       
    84 	x1 := leftOffset
       
    85     ].
       
    86     topOffset isNil ifTrue:[
       
    87 	y1 := 0
       
    88     ] ifFalse:[
       
    89 	y1 := topOffset
       
    90     ].
       
    91     rightOffset isNil ifTrue:[
       
    92 	x2 := 0
       
    93     ] ifFalse:[
       
    94 	x2 := rightOffset
       
    95     ].
       
    96     bottomOffset isNil ifTrue:[
       
    97 	y2 := 0
       
    98     ] ifFalse:[
       
    99 	y2 := bottomOffset
       
   100     ].
       
   101     leftFraction notNil ifTrue:[
       
   102 	x1 := x1 + (prefRect width * leftFraction)
       
   103     ].
       
   104     topFraction notNil ifTrue:[
       
   105 	y1 := y1 + (prefRect height * topFraction)
       
   106     ].
       
   107     rightFraction notNil ifTrue:[
       
   108 	x2 := x2 + (prefRect width * rightFraction)
       
   109     ].
       
   110     bottomFraction notNil ifTrue:[
       
   111 	y2 := y2 + (prefRect height * bottomFraction)
       
   112     ].
       
   113     ^ Rectangle origin:x1@y1 corner:x2@y2 
       
   114 !
       
   115 
       
   116 corner
       
   117     ^ rightFraction asFloat @ bottomFraction asFloat
       
   118 ! !
       
   119 
       
   120 !LayoutFrame methodsFor:'initialization'!
       
   121 
       
   122 initialize
       
   123     leftOffset := rightOffset := bottomOffset := topOffset := 0.
       
   124     leftFraction := topFraction := 0.
       
   125     bottomFraction := rightFraction := 1.
       
   126 ! !