Added support for off-axis justification.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@151 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: GroupLayout.java,v 1.1 2000/12/07 05:41:07 mdb Exp $
|
// $Id: GroupLayout.java,v 1.2 2001/06/07 08:39:10 mdb Exp $
|
||||||
|
|
||||||
package com.samskivert.swing;
|
package com.samskivert.swing;
|
||||||
|
|
||||||
@@ -118,6 +118,16 @@ public abstract class GroupLayout
|
|||||||
return _justification;
|
return _justification;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setOffAxisJustification (int justification)
|
||||||
|
{
|
||||||
|
_offjust = justification;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getOffAxisJustification ()
|
||||||
|
{
|
||||||
|
return _offjust;
|
||||||
|
}
|
||||||
|
|
||||||
public void addLayoutComponent (String name, Component comp)
|
public void addLayoutComponent (String name, Component comp)
|
||||||
{
|
{
|
||||||
// nothing to do here
|
// nothing to do here
|
||||||
@@ -272,6 +282,7 @@ public abstract class GroupLayout
|
|||||||
protected int _offpolicy = NONE;
|
protected int _offpolicy = NONE;
|
||||||
protected int _gap = 5;
|
protected int _gap = 5;
|
||||||
protected int _justification = CENTER;
|
protected int _justification = CENTER;
|
||||||
|
protected int _offjust = CENTER;
|
||||||
|
|
||||||
protected HashMap _constraints;
|
protected HashMap _constraints;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: HGroupLayout.java,v 1.4 2001/05/28 18:26:27 mdb Exp $
|
// $Id: HGroupLayout.java,v 1.5 2001/06/07 08:39:10 mdb Exp $
|
||||||
|
|
||||||
package com.samskivert.swing;
|
package com.samskivert.swing;
|
||||||
|
|
||||||
@@ -113,7 +113,6 @@ public class HGroupLayout extends GroupLayout
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case EQUALIZE:
|
case EQUALIZE:
|
||||||
sy = insets.top + (b.height - info.maxhei)/2;
|
|
||||||
defhei = info.maxhei;
|
defhei = info.maxhei;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -129,7 +128,7 @@ public class HGroupLayout extends GroupLayout
|
|||||||
break;
|
break;
|
||||||
case RIGHT:
|
case RIGHT:
|
||||||
case BOTTOM:
|
case BOTTOM:
|
||||||
sx += b.width - totwid;
|
sx += b.width - totwid - insets.right;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -150,7 +149,24 @@ public class HGroupLayout extends GroupLayout
|
|||||||
|
|
||||||
if (_offpolicy == NONE) {
|
if (_offpolicy == NONE) {
|
||||||
newhei = info.dimens[i].height;
|
newhei = info.dimens[i].height;
|
||||||
|
}
|
||||||
|
|
||||||
|
// determine our off-axis position
|
||||||
|
switch (_offjust) {
|
||||||
|
case LEFT:
|
||||||
|
case TOP:
|
||||||
|
sy = insets.top;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RIGHT:
|
||||||
|
case BOTTOM:
|
||||||
|
sy = b.height - newhei - insets.bottom;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
case CENTER:
|
||||||
sy = insets.top + (b.height - newhei)/2;
|
sy = insets.top + (b.height - newhei)/2;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
child.setBounds(sx, sy, newwid, newhei);
|
child.setBounds(sx, sy, newwid, newhei);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: VGroupLayout.java,v 1.4 2001/05/28 18:26:27 mdb Exp $
|
// $Id: VGroupLayout.java,v 1.5 2001/06/07 08:39:10 mdb Exp $
|
||||||
|
|
||||||
package com.samskivert.swing;
|
package com.samskivert.swing;
|
||||||
|
|
||||||
@@ -113,7 +113,6 @@ public class VGroupLayout extends GroupLayout
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case EQUALIZE:
|
case EQUALIZE:
|
||||||
sx = insets.left + (b.width - info.maxwid)/2;
|
|
||||||
defwid = info.maxwid;
|
defwid = info.maxwid;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -129,7 +128,7 @@ public class VGroupLayout extends GroupLayout
|
|||||||
break;
|
break;
|
||||||
case RIGHT:
|
case RIGHT:
|
||||||
case BOTTOM:
|
case BOTTOM:
|
||||||
sy += b.height - tothei;
|
sy += b.height - tothei - insets.bottom;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -150,7 +149,24 @@ public class VGroupLayout extends GroupLayout
|
|||||||
|
|
||||||
if (_offpolicy == NONE) {
|
if (_offpolicy == NONE) {
|
||||||
newwid = info.dimens[i].width;
|
newwid = info.dimens[i].width;
|
||||||
|
}
|
||||||
|
|
||||||
|
// determine our off-axis position
|
||||||
|
switch (_offjust) {
|
||||||
|
case LEFT:
|
||||||
|
case TOP:
|
||||||
|
sx = insets.left;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RIGHT:
|
||||||
|
case BOTTOM:
|
||||||
|
sx = b.width - newwid - insets.right;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
case CENTER:
|
||||||
sx = insets.left + (b.width - newwid)/2;
|
sx = insets.left + (b.width - newwid)/2;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
child.setBounds(sx, sy, newwid, newhei);
|
child.setBounds(sx, sy, newwid, newhei);
|
||||||
|
|||||||
Reference in New Issue
Block a user