LayoutManager2.java: Merged with Classpath.
* java/awt/LayoutManager2.java: Merged with Classpath. * java/awt/LayoutManager.java: Merged with Classpath. * java/awt/GridLayout.java: Updated copyright and javadoc. (getSize): Use `parent.ncomponents'. Handle insets. (layoutContainer): Use `parent.ncomponents'. Handle case where there are fewer children than columns. Correctly compute size of each cell in the grid. Handle case where there isn't enough space. * java/awt/CardLayout.java (tab): Renamed from `map'. Updated all users. (gotoComponent): Use parent.ncomponents. Ensure child exists before calling setVisible() on it. Last item is `num - 1', not `num'. (layoutContainer): Hoist invariants out of loop. From-SVN: r48898
This commit is contained in:
parent
3bd483f2a1
commit
0e1c7a5f36
5 changed files with 360 additions and 91 deletions
|
@ -1,5 +1,20 @@
|
|||
2002-01-15 Tom Tromey <tromey@redhat.com>
|
||||
|
||||
* java/awt/LayoutManager2.java: Merged with Classpath.
|
||||
* java/awt/LayoutManager.java: Merged with Classpath.
|
||||
* java/awt/GridLayout.java: Updated copyright and javadoc.
|
||||
(getSize): Use `parent.ncomponents'. Handle insets.
|
||||
(layoutContainer): Use `parent.ncomponents'. Handle case where
|
||||
there are fewer children than columns. Correctly compute size of
|
||||
each cell in the grid. Handle case where there isn't enough
|
||||
space.
|
||||
* java/awt/CardLayout.java (tab): Renamed from `map'. Updated
|
||||
all users.
|
||||
(gotoComponent): Use parent.ncomponents. Ensure child exists
|
||||
before calling setVisible() on it. Last item is `num - 1', not
|
||||
`num'.
|
||||
(layoutContainer): Hoist invariants out of loop.
|
||||
|
||||
Start of AWT merge with Classpath:
|
||||
* Makefile.in: Rebuilt.
|
||||
* Makefile.am (awt_java_source_files): Reference files in
|
||||
|
|
|
@ -1,12 +1,30 @@
|
|||
// CardLayout.java - Card-based layout engine
|
||||
|
||||
/* Copyright (C) 2000, 2002 Free Software Foundation
|
||||
/* Copyright (C) 1999, 2000, 2002 Free Software Foundation
|
||||
|
||||
This file is part of libgcj.
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
02111-1307 USA.
|
||||
|
||||
As a special exception, if you link this library with other files to
|
||||
produce an executable, this library does not by itself cause the
|
||||
resulting executable to be covered by the GNU General Public License.
|
||||
This exception does not however invalidate any other reasons why the
|
||||
executable file might be covered by the GNU General Public License. */
|
||||
|
||||
This software is copyrighted work licensed under the terms of the
|
||||
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
|
||||
details. */
|
||||
|
||||
package java.awt;
|
||||
|
||||
|
@ -19,20 +37,23 @@ import java.io.Serializable;
|
|||
* time. This class includes methods for changing which card is
|
||||
* shown.
|
||||
*
|
||||
* @version 0.0
|
||||
* @author Tom Tromey <tromey@redhat.com>
|
||||
* @date December 2, 2000
|
||||
* @author Aaron M. Renn (arenn@urbanophile.com)
|
||||
*/
|
||||
public class CardLayout implements LayoutManager2, Serializable
|
||||
{
|
||||
/** Create a new CardLayout object with both gaps zero. */
|
||||
/**
|
||||
* Initializes a new instance of <code>CardLayout</code> with horizontal
|
||||
* and vertical gaps of 0.
|
||||
*/
|
||||
public CardLayout ()
|
||||
{
|
||||
this (0, 0);
|
||||
}
|
||||
|
||||
/** Create a new CardLayout object with the specified horizontal and
|
||||
* vertical gaps.
|
||||
/**
|
||||
* Create a new <code>CardLayout</code> object with the specified
|
||||
* horizontal and vertical gaps.
|
||||
* @param hgap The horizontal gap
|
||||
* @param vgap The vertical gap
|
||||
*/
|
||||
|
@ -40,7 +61,7 @@ public class CardLayout implements LayoutManager2, Serializable
|
|||
{
|
||||
this.hgap = hgap;
|
||||
this.vgap = vgap;
|
||||
this.map = new Hashtable ();
|
||||
this.tab = new Hashtable ();
|
||||
}
|
||||
|
||||
/** Add a new component to the layout. The constraint must be a
|
||||
|
@ -48,21 +69,23 @@ public class CardLayout implements LayoutManager2, Serializable
|
|||
* later be used to refer to the particular component.
|
||||
* @param comp The component to add
|
||||
* @param constraints The name by which the component can later be called
|
||||
* @exception IllegalArgumentException If `constraints' is not a string
|
||||
* @exception IllegalArgumentException If `constraints' is not a
|
||||
* <code>String</code>
|
||||
*/
|
||||
public void addLayoutComponent (Component comp, Object constraints)
|
||||
{
|
||||
if (! (constraints instanceof String))
|
||||
throw new IllegalArgumentException ("Object " + constraints
|
||||
+ " is not a string");
|
||||
map.put (constraints, comp);
|
||||
tab.put (constraints, comp);
|
||||
}
|
||||
|
||||
/** Add a new component to the layout. The name can be used later
|
||||
* to refer to the component.
|
||||
* @param name The name by which the component can later be called
|
||||
* @param comp The component to add
|
||||
* @deprecated
|
||||
* @deprecated This method is deprecated in favor of
|
||||
* <code>addLayoutComponent(Component, Object)</code>.
|
||||
*/
|
||||
public void addLayoutComponent (String name, Component comp)
|
||||
{
|
||||
|
@ -121,10 +144,12 @@ public class CardLayout implements LayoutManager2, Serializable
|
|||
gotoComponent (parent, LAST, null);
|
||||
}
|
||||
|
||||
/** Lay out the container's components based on the current
|
||||
* settings.
|
||||
* @param parent The parent container
|
||||
*/
|
||||
/**
|
||||
* Lays out the container. This is done by resizing the child components
|
||||
* to be the same size as the parent, less insets and gaps.
|
||||
*
|
||||
* @param parent The parent container.
|
||||
*/
|
||||
public void layoutContainer (Container parent)
|
||||
{
|
||||
int width = parent.width;
|
||||
|
@ -135,12 +160,13 @@ public class CardLayout implements LayoutManager2, Serializable
|
|||
int num = parent.ncomponents;
|
||||
Component[] comps = parent.component;
|
||||
|
||||
int x = ins.left + hgap;
|
||||
int y = ins.top + vgap;
|
||||
width = width - 2 * hgap - ins.left - ins.right;
|
||||
height = height - 2 * vgap - ins.top - ins.bottom;
|
||||
|
||||
for (int i = 0; i < num; ++i)
|
||||
{
|
||||
comps[i].setBounds (hgap + ins.left, vgap + ins.top,
|
||||
width - 2 * hgap - ins.left - ins.right,
|
||||
height - 2 * vgap - ins.top - ins.bottom);
|
||||
}
|
||||
comps[i].setBounds (x, y, width, height);
|
||||
}
|
||||
|
||||
/** Get the maximum layout size of the container.
|
||||
|
@ -161,7 +187,9 @@ public class CardLayout implements LayoutManager2, Serializable
|
|||
return getSize (target, MIN);
|
||||
}
|
||||
|
||||
/** Cause the next component in the container to be displayed.
|
||||
/** Cause the next component in the container to be displayed. If
|
||||
* this current card is the last one in the deck, the first
|
||||
* component is displayed.
|
||||
* @param parent The parent container
|
||||
*/
|
||||
public void next (Container parent)
|
||||
|
@ -178,6 +206,8 @@ public class CardLayout implements LayoutManager2, Serializable
|
|||
}
|
||||
|
||||
/** Cause the previous component in the container to be displayed.
|
||||
* If this current card is the first one in the deck, the last
|
||||
* component is displayed.
|
||||
* @param parent The parent container
|
||||
*/
|
||||
public void previous (Container parent)
|
||||
|
@ -190,13 +220,13 @@ public class CardLayout implements LayoutManager2, Serializable
|
|||
*/
|
||||
public void removeLayoutComponent (Component comp)
|
||||
{
|
||||
Enumeration e = map.keys ();
|
||||
Enumeration e = tab.keys ();
|
||||
while (e.hasMoreElements ())
|
||||
{
|
||||
Object key = e.nextElement ();
|
||||
if (map.get (key) == comp)
|
||||
if (tab.get (key) == comp)
|
||||
{
|
||||
map.remove (key);
|
||||
tab.remove (key);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -225,11 +255,16 @@ public class CardLayout implements LayoutManager2, Serializable
|
|||
*/
|
||||
public void show (Container parent, String name)
|
||||
{
|
||||
Object target = map.get (name);
|
||||
Object target = tab.get (name);
|
||||
if (target != null)
|
||||
gotoComponent (parent, NONE, (Component) target);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this layout manager.
|
||||
*
|
||||
* @return A string representation of this object.
|
||||
*/
|
||||
public String toString ()
|
||||
{
|
||||
return getClass ().getName () + "[" + hgap + "," + vgap + "]";
|
||||
|
@ -239,7 +274,7 @@ public class CardLayout implements LayoutManager2, Serializable
|
|||
private void gotoComponent (Container parent, int what,
|
||||
Component target)
|
||||
{
|
||||
int num = parent.getComponentCount ();
|
||||
int num = parent.ncomponents;
|
||||
// This is more efficient than calling getComponents().
|
||||
Component[] comps = parent.component;
|
||||
int choice = -1;
|
||||
|
@ -247,7 +282,7 @@ public class CardLayout implements LayoutManager2, Serializable
|
|||
if (what == FIRST)
|
||||
choice = 0;
|
||||
else if (what == LAST)
|
||||
choice = num;
|
||||
choice = num - 1;
|
||||
else if (what >= 0)
|
||||
choice = what;
|
||||
|
||||
|
@ -275,12 +310,11 @@ public class CardLayout implements LayoutManager2, Serializable
|
|||
if (choice < 0)
|
||||
choice = num - 1;
|
||||
}
|
||||
else
|
||||
else if (choice == i)
|
||||
{
|
||||
// Do nothing if we're already looking at the right
|
||||
// component.
|
||||
if (choice == i)
|
||||
return;
|
||||
return;
|
||||
}
|
||||
comps[i].setVisible (false);
|
||||
|
||||
|
@ -289,7 +323,8 @@ public class CardLayout implements LayoutManager2, Serializable
|
|||
}
|
||||
}
|
||||
|
||||
comps[choice].setVisible (true);
|
||||
if (choice >= 0 && choice < num)
|
||||
comps[choice].setVisible (true);
|
||||
}
|
||||
|
||||
// Compute the size according to WHAT.
|
||||
|
@ -326,12 +361,20 @@ public class CardLayout implements LayoutManager2, Serializable
|
|||
return new Dimension (w, h);
|
||||
}
|
||||
|
||||
// The gaps.
|
||||
/**
|
||||
* @serial Horizontal gap value.
|
||||
*/
|
||||
private int hgap;
|
||||
|
||||
/**
|
||||
* @serial Vertical gap value.
|
||||
*/
|
||||
private int vgap;
|
||||
|
||||
// This hashtable maps a name to a component.
|
||||
private Hashtable map;
|
||||
/**
|
||||
* @serial Table of named components.
|
||||
*/
|
||||
private Hashtable tab;
|
||||
|
||||
// These constants are used by the private gotoComponent method.
|
||||
private int FIRST = 0;
|
||||
|
|
|
@ -1,12 +1,30 @@
|
|||
// GridLayout.java - Grid-based layout engine
|
||||
|
||||
/* Copyright (C) 2000 Free Software Foundation
|
||||
/* Copyright (C) 1999, 2000, 2002 Free Software Foundation
|
||||
|
||||
This file is part of libgcj.
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
02111-1307 USA.
|
||||
|
||||
As a special exception, if you link this library with other files to
|
||||
produce an executable, this library does not by itself cause the
|
||||
resulting executable to be covered by the GNU General Public License.
|
||||
This exception does not however invalidate any other reasons why the
|
||||
executable file might be covered by the GNU General Public License. */
|
||||
|
||||
This software is copyrighted work licensed under the terms of the
|
||||
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
|
||||
details. */
|
||||
|
||||
package java.awt;
|
||||
|
||||
|
@ -15,16 +33,24 @@ import java.io.Serializable;
|
|||
/** This class implements a grid-based layout scheme. Components are
|
||||
* all given the same size and are laid out from left to right and top
|
||||
* to bottom. A GridLayout is configured with a number of rows and a
|
||||
* number of columns. If either is zero then that dimension is
|
||||
* computed based on the actual size of the container. An exception
|
||||
* is thrown if an attempt is made to set both the number of rows and
|
||||
* the number of columns to 0. This class also support horizontal and
|
||||
* vertical gaps; these are used as spacing between cells.
|
||||
* number of columns. If both are specified, then the number of
|
||||
* columns is ignored and is derived from the number of rows and the
|
||||
* total number of components. If either is zero then that dimension
|
||||
* is computed based on the actual size of the container. An
|
||||
* exception is thrown if an attempt is made to set both the number of
|
||||
* rows and the number of columns to 0. This class also supports
|
||||
* horizontal and vertical gaps; these are used as spacing between
|
||||
* cells.
|
||||
*
|
||||
* @author Tom Tromey <tromey@redhat.com>
|
||||
* @author Aaron M. Renn (arenn@urbanophile.com)
|
||||
*/
|
||||
public class GridLayout implements LayoutManager, Serializable
|
||||
{
|
||||
/** Add a new component to the layout. This particular implementation
|
||||
* does nothing.
|
||||
* @param name The name of the component to add.
|
||||
* @param component The component to add.
|
||||
*/
|
||||
public void addLayoutComponent (String name, Component comp)
|
||||
{
|
||||
|
@ -55,16 +81,18 @@ public class GridLayout implements LayoutManager, Serializable
|
|||
return vgap;
|
||||
}
|
||||
|
||||
/** Create a new GridLayout with one row and any number of columns.
|
||||
* Both gaps are set to 0.
|
||||
/** Create a new <code>GridLayout</code> with one row and any number
|
||||
* of columns. Both gaps are set to 0.
|
||||
*/
|
||||
public GridLayout ()
|
||||
{
|
||||
this (1, 0, 0, 0);
|
||||
}
|
||||
|
||||
/** Create a new GridLayout with the specified number of rows and
|
||||
* columns. Both gaps are set to 0.
|
||||
/** Create a new <code>GridLayout</code> with the specified number
|
||||
* of rows and columns. Both gaps are set to 0. Note that the row
|
||||
* and column settings cannot both be zero. If both the row and
|
||||
* column values are non-zero, the rows value takes precedence.
|
||||
* @param rows Number of rows
|
||||
* @param cols Number of columns
|
||||
* @exception IllegalArgumentException If rows and columns are both
|
||||
|
@ -77,6 +105,9 @@ public class GridLayout implements LayoutManager, Serializable
|
|||
|
||||
/** Create a new GridLayout with the specified number of rows and
|
||||
* columns and the specified gaps.
|
||||
* Note that the row and column settings cannot both be
|
||||
* zero. If both the row and column values are non-zero, the rows value
|
||||
* takes precedence.
|
||||
* @param rows Number of rows
|
||||
* @param cols Number of columns
|
||||
* @param hgap The horizontal gap
|
||||
|
@ -103,11 +134,13 @@ public class GridLayout implements LayoutManager, Serializable
|
|||
}
|
||||
|
||||
/** Lay out the container's components based on current settings.
|
||||
* @param parent The parent container
|
||||
* The free space in the container is divided evenly into the specified
|
||||
* number of rows and columns in this object.
|
||||
* @param parent The container to lay out
|
||||
*/
|
||||
public void layoutContainer (Container parent)
|
||||
{
|
||||
int num = parent.getComponentCount ();
|
||||
int num = parent.ncomponents;
|
||||
// This is more efficient than calling getComponents().
|
||||
Component[] comps = parent.component;
|
||||
|
||||
|
@ -118,14 +151,25 @@ public class GridLayout implements LayoutManager, Serializable
|
|||
else
|
||||
real_cols = (num + real_rows - 1) / real_rows;
|
||||
|
||||
// We might have less than a single row. In this case we expand
|
||||
// to fill.
|
||||
if (num < real_cols)
|
||||
real_cols = num;
|
||||
|
||||
Dimension d = parent.getSize ();
|
||||
Insets ins = parent.getInsets ();
|
||||
|
||||
// Compute width and height of each cell in the grid.
|
||||
int tw = d.width - ins.left - ins.right;
|
||||
tw = (tw - (real_rows - 1) * hgap) / real_rows;
|
||||
int th = d.height - ins.top - ins.bottom;
|
||||
th = (th - (real_cols - 1) * vgap) / real_cols;
|
||||
|
||||
int w = (tw - (real_rows - 1) * hgap) / real_rows;
|
||||
int h = (th - (real_cols - 1) * vgap) / real_cols;
|
||||
// If the cells are too small, still try to do something.
|
||||
if (tw < 0)
|
||||
tw = 1;
|
||||
if (th < 0)
|
||||
th = 1;
|
||||
|
||||
int x = ins.left;
|
||||
int y = ins.top;
|
||||
|
@ -191,6 +235,7 @@ public class GridLayout implements LayoutManager, Serializable
|
|||
|
||||
/** Set the horizontal gap
|
||||
* @param hgap The horizontal gap
|
||||
* @exception IllegalArgumentException If the hgap value is less than zero.
|
||||
*/
|
||||
public void setHgap (int hgap)
|
||||
{
|
||||
|
@ -216,6 +261,7 @@ public class GridLayout implements LayoutManager, Serializable
|
|||
|
||||
/** Set the vertical gap.
|
||||
* @param vgap The vertical gap
|
||||
* @exception IllegalArgumentException If the vgap value is less than zero.
|
||||
*/
|
||||
public void setVgap (int vgap)
|
||||
{
|
||||
|
@ -236,14 +282,12 @@ public class GridLayout implements LayoutManager, Serializable
|
|||
// This method is used to compute the various sizes.
|
||||
private Dimension getSize (Container parent, boolean is_min)
|
||||
{
|
||||
int w = 0, h = 0, num = parent.getComponentCount ();
|
||||
int w = 0, h = 0, num = parent.ncomponents;
|
||||
// This is more efficient than calling getComponents().
|
||||
Component[] comps = parent.component;
|
||||
|
||||
for (int i = 0; i < num; ++i)
|
||||
{
|
||||
// FIXME: can we just directly read the fields in Component?
|
||||
// Or will that not work with subclassing?
|
||||
Dimension d;
|
||||
|
||||
if (is_min)
|
||||
|
@ -262,16 +306,31 @@ public class GridLayout implements LayoutManager, Serializable
|
|||
else
|
||||
real_cols = (num + real_rows - 1) / real_rows;
|
||||
|
||||
Insets ins = parent.getInsets ();
|
||||
// We subtract out an extra gap here because the gaps are only
|
||||
// between cells.
|
||||
return new Dimension (real_rows * (w + hgap) - hgap,
|
||||
real_cols * (h + vgap) - vgap);
|
||||
w = ins.left + ins.right + real_rows * (w + hgap) - hgap;
|
||||
h = ins.top + ins.bottom + real_cols * (h + vgap) - vgap;
|
||||
return new Dimension (w, h);
|
||||
}
|
||||
|
||||
// The gaps.
|
||||
private int hgap;
|
||||
private int vgap;
|
||||
// Number of rows and columns.
|
||||
private int rows;
|
||||
/**
|
||||
* @serial The number of columns in the grid.
|
||||
*/
|
||||
private int cols;
|
||||
|
||||
/**
|
||||
* @serial The number of rows in the grid.
|
||||
*/
|
||||
private int rows;
|
||||
|
||||
/**
|
||||
* @serial The horizontal gap between columns
|
||||
*/
|
||||
private int hgap;
|
||||
|
||||
/**
|
||||
* @serial The vertical gap between rows
|
||||
*/
|
||||
private int vgap;
|
||||
}
|
||||
|
|
|
@ -1,20 +1,95 @@
|
|||
/* Copyright (C) 1999 Free Software Foundation
|
||||
/* LayoutManager.java -- Layout containers in a Window
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of libjava.
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
02111-1307 USA.
|
||||
|
||||
As a special exception, if you link this library with other files to
|
||||
produce an executable, this library does not by itself cause the
|
||||
resulting executable to be covered by the GNU General Public License.
|
||||
This exception does not however invalidate any other reasons why the
|
||||
executable file might be covered by the GNU General Public License. */
|
||||
|
||||
This software is copyrighted work licensed under the terms of the
|
||||
Libjava License. Please consult the file "LIBJAVA_LICENSE" for
|
||||
details. */
|
||||
|
||||
package java.awt;
|
||||
|
||||
/* Status: Believed complete and correct. */
|
||||
|
||||
/**
|
||||
* This interface is for laying out containers.
|
||||
*
|
||||
* @author Aaron M. Renn (arenn@urbanophile.com)
|
||||
*/
|
||||
public interface LayoutManager
|
||||
{
|
||||
public void addLayoutComponent (String name, Component comp);
|
||||
public void layoutContainer (Container parent);
|
||||
public Dimension minimumLayoutSize (Container parent);
|
||||
public Dimension preferredLayoutSize (Container parent);
|
||||
public void removeLayoutComponent (Component comp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the specified component to the layout group.
|
||||
*
|
||||
* @param name The name of the component to add.
|
||||
* @param component The component to add.
|
||||
*/
|
||||
public abstract void
|
||||
addLayoutComponent(String name, Component component);
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* Removes the specified component from the layout group.
|
||||
*
|
||||
* @param component The component to remove.
|
||||
*/
|
||||
public abstract void
|
||||
removeLayoutComponent(Component component);
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* Calculates the preferred size for this container, taking into account
|
||||
* the components in the specified parent container.
|
||||
*
|
||||
* @param parent The parent container.
|
||||
*
|
||||
* @return The preferred dimensions of this container.
|
||||
*/
|
||||
public abstract Dimension
|
||||
preferredLayoutSize(Container parent);
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* Calculates the minimum size for this container, taking into account
|
||||
* the components in the specified parent container.
|
||||
*
|
||||
* @param parent The parent container.
|
||||
*
|
||||
* @return The minimum dimensions of this container.
|
||||
*/
|
||||
public abstract Dimension
|
||||
minimumLayoutSize(Container parent);
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* Lays out the components in this container on the specified parent
|
||||
* container.
|
||||
*
|
||||
* @param parent The parent container.
|
||||
*/
|
||||
public abstract void
|
||||
layoutContainer(Container parent);
|
||||
|
||||
} // interface LayoutManager
|
||||
|
||||
|
|
|
@ -1,20 +1,97 @@
|
|||
/* Copyright (C) 1999 Free Software Foundation
|
||||
/* LayoutManager2.java -- Enhanced layout manager.
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of libjava.
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
02111-1307 USA.
|
||||
|
||||
As a special exception, if you link this library with other files to
|
||||
produce an executable, this library does not by itself cause the
|
||||
resulting executable to be covered by the GNU General Public License.
|
||||
This exception does not however invalidate any other reasons why the
|
||||
executable file might be covered by the GNU General Public License. */
|
||||
|
||||
This software is copyrighted work licensed under the terms of the
|
||||
Libjava License. Please consult the file "LIBJAVA_LICENSE" for
|
||||
details. */
|
||||
|
||||
package java.awt;
|
||||
|
||||
/* Status: Believed complete and correct. */
|
||||
|
||||
/**
|
||||
* Layout manager for laying out containers based on contraints.
|
||||
*
|
||||
* @author Aaron M. Renn (arenn@urbanophile.com)
|
||||
*/
|
||||
public interface LayoutManager2 extends LayoutManager
|
||||
{
|
||||
public void addLayoutComponent (Component comp, Object constraints);
|
||||
public float getLayoutAlignmentX (Container target);
|
||||
public float getLayoutAlignmentY (Container target);
|
||||
public void invalidateLayout (Container target);
|
||||
public Dimension maximumLayoutSize (Container target);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the specified component to the layout, with the specified
|
||||
* constraint object.
|
||||
*
|
||||
* @param component The component to add.
|
||||
* @param constraint The constraint object.
|
||||
*/
|
||||
public abstract void
|
||||
addLayoutComponent(Component component, Object contraint);
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* Determines the minimum size of the specified target container.
|
||||
*
|
||||
* @param target The target container.
|
||||
*/
|
||||
public abstract Dimension
|
||||
maximumLayoutSize(Container target);
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* Returns the preferred X axis alignment for the specified target
|
||||
* container. This value will range from 0 to 1 where 0 is alignment
|
||||
* closest to the origin, 0.5 is centered, and 1 is aligned furthest
|
||||
* from the origin.
|
||||
*
|
||||
* @param target The target container.
|
||||
*/
|
||||
public abstract float
|
||||
getLayoutAlignmentX(Container target);
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* Returns the preferred Y axis alignment for the specified target
|
||||
* container. This value will range from 0 to 1 where 0 is alignment
|
||||
* closest to the origin, 0.5 is centered, and 1 is aligned furthest
|
||||
* from the origin.
|
||||
*
|
||||
* @param target The target container.
|
||||
*/
|
||||
public abstract float
|
||||
getLayoutAlignmentY(Container target);
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* Forces the layout manager to purge any cached information about
|
||||
* the layout of the target container. This will force it to be
|
||||
* recalculated.
|
||||
*
|
||||
* @param target The target container.
|
||||
*/
|
||||
public abstract void
|
||||
invalidateLayout(Container target);
|
||||
|
||||
} // interface LayoutManager2
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue