Account for a container's insets when laying out it's children. Apparently
that's up to us. git-svn-id: https://samskivert.googlecode.com/svn/trunk@27 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: HGroupLayout.java,v 1.1 2000/12/07 05:41:07 mdb Exp $
|
// $Id: HGroupLayout.java,v 1.2 2000/12/07 11:09:59 mdb Exp $
|
||||||
|
|
||||||
package com.samskivert.swing;
|
package com.samskivert.swing;
|
||||||
|
|
||||||
@@ -59,6 +59,11 @@ public class HGroupLayout extends GroupLayout
|
|||||||
dims.width -= _gap;
|
dims.width -= _gap;
|
||||||
dims.height = info.maxhei;
|
dims.height = info.maxhei;
|
||||||
|
|
||||||
|
// account for the insets
|
||||||
|
Insets insets = parent.getInsets();
|
||||||
|
dims.width += insets.left + insets.right;
|
||||||
|
dims.height += insets.top + insets.bottom;
|
||||||
|
|
||||||
return dims;
|
return dims;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,8 +72,13 @@ public class HGroupLayout extends GroupLayout
|
|||||||
Rectangle b = parent.bounds();
|
Rectangle b = parent.bounds();
|
||||||
DimenInfo info = computeDimens(parent, PREFERRED);
|
DimenInfo info = computeDimens(parent, PREFERRED);
|
||||||
|
|
||||||
|
// adjust the bounds width and height to account for the insets
|
||||||
|
Insets insets = parent.getInsets();
|
||||||
|
b.width -= (insets.left + insets.right);
|
||||||
|
b.height -= (insets.top + insets.bottom);
|
||||||
|
|
||||||
int nk = parent.getComponentCount();
|
int nk = parent.getComponentCount();
|
||||||
int sx = 0, sy = 0;
|
int sx = insets.left, sy = insets.top;
|
||||||
int totwid, totgap = _gap * (info.count-1);
|
int totwid, totgap = _gap * (info.count-1);
|
||||||
int freecount = info.count - info.numfix;
|
int freecount = info.count - info.numfix;
|
||||||
|
|
||||||
@@ -115,10 +125,11 @@ public class HGroupLayout extends GroupLayout
|
|||||||
// do the justification-related calculations
|
// do the justification-related calculations
|
||||||
switch (_justification) {
|
switch (_justification) {
|
||||||
case CENTER:
|
case CENTER:
|
||||||
sx = (b.width - totwid)/2;
|
sx += (b.width - totwid)/2;
|
||||||
break;
|
break;
|
||||||
case RIGHT:
|
case RIGHT:
|
||||||
sx = b.width - totwid;
|
case BOTTOM:
|
||||||
|
sx += b.width - totwid;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: VGroupLayout.java,v 1.1 2000/12/07 05:41:07 mdb Exp $
|
// $Id: VGroupLayout.java,v 1.2 2000/12/07 11:09:59 mdb Exp $
|
||||||
|
|
||||||
package com.samskivert.swing;
|
package com.samskivert.swing;
|
||||||
|
|
||||||
@@ -59,6 +59,11 @@ public class VGroupLayout extends GroupLayout
|
|||||||
dims.height -= _gap;
|
dims.height -= _gap;
|
||||||
dims.width = info.maxwid;
|
dims.width = info.maxwid;
|
||||||
|
|
||||||
|
// account for the insets
|
||||||
|
Insets insets = parent.getInsets();
|
||||||
|
dims.width += insets.left + insets.right;
|
||||||
|
dims.height += insets.top + insets.bottom;
|
||||||
|
|
||||||
return dims;
|
return dims;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,8 +72,13 @@ public class VGroupLayout extends GroupLayout
|
|||||||
Rectangle b = parent.bounds();
|
Rectangle b = parent.bounds();
|
||||||
DimenInfo info = computeDimens(parent, PREFERRED);
|
DimenInfo info = computeDimens(parent, PREFERRED);
|
||||||
|
|
||||||
|
// adjust the bounds width and height to account for the insets
|
||||||
|
Insets insets = parent.getInsets();
|
||||||
|
b.width -= (insets.left + insets.right);
|
||||||
|
b.height -= (insets.top + insets.bottom);
|
||||||
|
|
||||||
int nk = parent.getComponentCount();
|
int nk = parent.getComponentCount();
|
||||||
int sx = 0, sy = 0;
|
int sx = insets.left, sy = insets.top;
|
||||||
int tothei, totgap = _gap * (info.count-1);
|
int tothei, totgap = _gap * (info.count-1);
|
||||||
int freecount = info.count - info.numfix;
|
int freecount = info.count - info.numfix;
|
||||||
|
|
||||||
@@ -115,10 +125,11 @@ public class VGroupLayout extends GroupLayout
|
|||||||
// do the justification-related calculations
|
// do the justification-related calculations
|
||||||
switch (_justification) {
|
switch (_justification) {
|
||||||
case CENTER:
|
case CENTER:
|
||||||
sy = (b.height - tothei)/2;
|
sy += (b.height - tothei)/2;
|
||||||
break;
|
break;
|
||||||
case RIGHT:
|
case RIGHT:
|
||||||
sy = b.height - tothei;
|
case BOTTOM:
|
||||||
|
sy += b.height - tothei;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user