GridBagLayoutView.st
changeset 5303 dc0252c294f5
parent 3673 31a56ced44b6
child 5634 9fb149cbc61e
equal deleted inserted replaced
5301:9826c3fef3a0 5303:dc0252c294f5
     8  be provided or otherwise made available to, or used by, any
     8  be provided or otherwise made available to, or used by, any
     9  other person.  No title to or ownership of the software is
     9  other person.  No title to or ownership of the software is
    10  hereby transferred.
    10  hereby transferred.
    11 "
    11 "
    12 "{ Package: 'stx:libwidg2' }"
    12 "{ Package: 'stx:libwidg2' }"
       
    13 
       
    14 "{ NameSpace: Smalltalk }"
    13 
    15 
    14 PanelView subclass:#GridBagLayoutView
    16 PanelView subclass:#GridBagLayoutView
    15 	instanceVariableNames:'columnWidths rowHeights columnWeights rowWeights layoutInfo'
    17 	instanceVariableNames:'columnWidths rowHeights columnWeights rowWeights layoutInfo'
    16 	classVariableNames:''
    18 	classVariableNames:''
    17 	poolDictionaries:''
    19 	poolDictionaries:''
   224 
   226 
   225 !GridBagLayoutView methodsFor:'private'!
   227 !GridBagLayoutView methodsFor:'private'!
   226 
   228 
   227 adjustForGravity:c in:r
   229 adjustForGravity:c in:r
   228 
   230 
   229     | diffx diffy add |
   231     |insets fill anchor diffx diffy add |
   230 
   232 
   231     r setLeft: ((r left)   + (c insets left)).
   233     insets := c insets.
   232     r width:   ((r width)  - ((c insets left) + (c insets right))).
   234     fill := c fill.
   233     r setTop:  ((r top)    + (c insets top)).
   235     anchor := c anchor.
   234     r height:  ((r height) - ((c insets top) + (c insets bottom))).
   236     
       
   237     r setLeft: ((r left)   + (insets left)).
       
   238     r width:   ((r width)  - ((insets left) + (insets right))).
       
   239     r setTop:  ((r top)    + (insets top)).
       
   240     r height:  ((r height) - ((insets top) + (insets bottom))).
   235 
   241 
   236     diffx := 0.
   242     diffx := 0.
   237     (((c fill) ~~ #HORIZONTAL and:[(c fill) ~~ #BOTH]) and:[(r width) > (add := (c minWidth) + (c ipadX))]) ifTrue:[
   243     (fill ~~ #HORIZONTAL and:[(fill ~~ #BOTH) and:[(r width) > (add := (c minWidth) + (c ipadX))]]) ifTrue:[
   238 	diffx := (r width) - add.
   244         diffx := (r width) - add.
   239 	r width:add.
   245         r width:add.
   240     ].
   246     ].
   241 
   247 
   242     diffy := 0.
   248     diffy := 0.
   243     (((c fill) ~~ #VERTICAL and:[(c fill) ~~ #BOTH]) and:[(r height) > (add := (c minHeight) + (c ipadY))]) ifTrue:[
   249     (fill ~~ #VERTICAL and:[(fill ~~ #BOTH) and:[(r height) > (add := (c minHeight) + (c ipadY))]]) ifTrue:[
   244 	diffy := (r height) - add.
   250         diffy := (r height) - add.
   245 	r height:add.
   251         r height:add.
   246     ].
   252     ].
   247 
   253 
   248     ((c anchor) == #CENTER) ifTrue:[
   254     (anchor == #CENTER) ifTrue:[
   249 	r setLeft:((r left) + (diffx / 2)).
   255         r setLeft:((r left) + (diffx / 2)).
   250 	r setTop:((r top) + (diffy / 2)).
   256         r setTop:((r top) + (diffy / 2)).
   251     ].
   257     ].
   252     ((c anchor) == #NORTH) ifTrue:[
   258     (anchor == #NORTH) ifTrue:[
   253 	r setLeft:((r left) + (diffx / 2)).
   259         r setLeft:((r left) + (diffx / 2)).
   254     ].
   260     ].
   255     ((c anchor) == #NORTHEAST) ifTrue:[
   261     (anchor == #NORTHEAST) ifTrue:[
   256 	r setLeft:((r left) + diffx).
   262         r setLeft:((r left) + diffx).
   257     ].
   263     ].
   258     ((c anchor) == #EAST) ifTrue:[
   264     (anchor == #EAST) ifTrue:[
   259 	r setLeft:((r left) + diffx).
   265         r setLeft:((r left) + diffx).
   260 	r setTop:((r top) + (diffy / 2)).
   266         r setTop:((r top) + (diffy / 2)).
   261     ].
   267     ].
   262     ((c anchor) == #SOUTHEAST) ifTrue:[
   268     (anchor == #SOUTHEAST) ifTrue:[
   263 	r setLeft:((r left) + diffx).
   269         r setLeft:((r left) + diffx).
   264 	r setTop:((r top) + diffy).
   270         r setTop:((r top) + diffy).
   265     ].
   271     ].
   266     ((c anchor) == #SOUTH) ifTrue:[
   272     (anchor == #SOUTH) ifTrue:[
   267 	r setLeft:((r left) + (diffx / 2)).
   273         r setLeft:((r left) + (diffx / 2)).
   268 	r setTop:((r top) + diffy).
   274         r setTop:((r top) + diffy).
   269     ].
   275     ].
   270     ((c anchor) == #SOUTHWEST) ifTrue:[
   276     (anchor == #SOUTHWEST) ifTrue:[
   271 	r setTop:((r top) + diffy).
   277         r setTop:((r top) + diffy).
   272     ].
   278     ].
   273     ((c anchor) == #WEST) ifTrue:[
   279     (anchor == #WEST) ifTrue:[
   274 	r setTop:((r top) + (diffy / 2)).
   280         r setTop:((r top) + (diffy / 2)).
   275     ].
   281     ].
   276     ((c anchor) == #NORTHWEST) ifTrue:[
   282     (anchor == #NORTHWEST) ifTrue:[
   277     ].
   283     ].
   278 
   284 
   279     r setLeft: ((r left)   asInteger).
   285     r setLeft: ((r left)   asInteger).
   280     r setTop:  ((r top)    asInteger).
   286     r setTop:  ((r top)    asInteger).
   281     r width:   ((r width)  asInteger).
   287     r width:   ((r width)  asInteger).
   853 ! !
   859 ! !
   854 
   860 
   855 !GridBagLayoutView class methodsFor:'documentation'!
   861 !GridBagLayoutView class methodsFor:'documentation'!
   856 
   862 
   857 version
   863 version
   858     ^ '$Header: /cvs/stx/stx/libwidg2/GridBagLayoutView.st,v 1.10 2009-03-24 15:35:15 stefan Exp $'
   864     ^ '$Header$'
   859 ! !
   865 ! !
       
   866