From 3ef788632fcf85341c95d59ba0f6dea55fbf1a2b Mon Sep 17 00:00:00 2001 From: mdb Date: Thu, 16 May 2002 02:02:38 +0000 Subject: [PATCH] Modified the default off-axis policy to CONSTRAIN, a new policy type that causes widgets that are wider than the container in the off-axis to be squeezed to fit but widgets that are smaller to be left alone. It is not a valid on-axis policy. git-svn-id: https://samskivert.googlecode.com/svn/trunk@740 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- .../src/java/com/samskivert/swing/GroupLayout.java | 11 +++++++++-- .../src/java/com/samskivert/swing/HGroupLayout.java | 4 +++- .../src/java/com/samskivert/swing/VGroupLayout.java | 4 +++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/projects/samskivert/src/java/com/samskivert/swing/GroupLayout.java b/projects/samskivert/src/java/com/samskivert/swing/GroupLayout.java index 36470ef2..016137a7 100644 --- a/projects/samskivert/src/java/com/samskivert/swing/GroupLayout.java +++ b/projects/samskivert/src/java/com/samskivert/swing/GroupLayout.java @@ -1,5 +1,5 @@ // -// $Id: GroupLayout.java,v 1.4 2002/04/26 02:34:48 mdb Exp $ +// $Id: GroupLayout.java,v 1.5 2002/05/16 02:02:38 mdb Exp $ // // samskivert library - useful routines for java programs // Copyright (C) 2001 Michael Bayne @@ -98,6 +98,13 @@ public abstract class GroupLayout */ public final static int EQUALIZE = 2; + /** + * Only valid for off-axis policy, this leaves widgets alone unless + * they are larger in the off-axis direction than their container, in + * which case it constrains them to fit on the off-axis. + */ + public final static int CONSTRAIN = 3; + public void setPolicy (int policy) { _policy = policy; @@ -391,7 +398,7 @@ public abstract class GroupLayout } protected int _policy = NONE; - protected int _offpolicy = NONE; + protected int _offpolicy = CONSTRAIN; protected int _gap = DEFAULT_GAP; protected int _justification = CENTER; protected int _offjust = CENTER; diff --git a/projects/samskivert/src/java/com/samskivert/swing/HGroupLayout.java b/projects/samskivert/src/java/com/samskivert/swing/HGroupLayout.java index 14c1457f..78693d4f 100644 --- a/projects/samskivert/src/java/com/samskivert/swing/HGroupLayout.java +++ b/projects/samskivert/src/java/com/samskivert/swing/HGroupLayout.java @@ -1,5 +1,5 @@ // -// $Id: HGroupLayout.java,v 1.8 2001/10/09 19:46:31 mdb Exp $ +// $Id: HGroupLayout.java,v 1.9 2002/05/16 02:02:38 mdb Exp $ // // samskivert library - useful routines for java programs // Copyright (C) 2001 Michael Bayne @@ -179,6 +179,8 @@ public class HGroupLayout extends GroupLayout if (_offpolicy == NONE) { newhei = info.dimens[i].height; + } else if (_offpolicy == CONSTRAIN) { + newhei = Math.min(info.dimens[i].height, b.height); } else { newhei = defhei; } diff --git a/projects/samskivert/src/java/com/samskivert/swing/VGroupLayout.java b/projects/samskivert/src/java/com/samskivert/swing/VGroupLayout.java index c0d06cec..5e203f4e 100644 --- a/projects/samskivert/src/java/com/samskivert/swing/VGroupLayout.java +++ b/projects/samskivert/src/java/com/samskivert/swing/VGroupLayout.java @@ -1,5 +1,5 @@ // -// $Id: VGroupLayout.java,v 1.9 2001/10/17 17:01:02 mdb Exp $ +// $Id: VGroupLayout.java,v 1.10 2002/05/16 02:02:38 mdb Exp $ // // samskivert library - useful routines for java programs // Copyright (C) 2001 Michael Bayne @@ -179,6 +179,8 @@ public class VGroupLayout extends GroupLayout if (_offpolicy == NONE) { newwid = info.dimens[i].width; + } else if (_offpolicy == CONSTRAIN) { + newwid = Math.min(info.dimens[i].width, b.width); } else { newwid = defwid; }