/[classpath]/classpath/java/awt/GridBagLayout.java
ViewVC logotype

Diff of /classpath/java/awt/GridBagLayout.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.7 by mkoch, Sun Jun 29 14:58:34 2003 UTC revision 1.8 by mkoch, Tue Jul 1 08:33:16 2003 UTC
# Line 55  public class GridBagLayout Line 55  public class GridBagLayout
55    
56    protected Hashtable comptable;    protected Hashtable comptable;
57    protected GridBagLayoutInfo layoutInfo;    protected GridBagLayoutInfo layoutInfo;
58    protected GridBagConstraints defaultConstraints = new GridBagConstraints();    protected GridBagConstraints defaultConstraints;
59    
60    public double[] colWeights;    public double[] colWeights;
61    public int[] colWidths;    public int[] colWidths;
# Line 64  public class GridBagLayout Line 64  public class GridBagLayout
64    
65    public GridBagLayout ()    public GridBagLayout ()
66    {    {
67      // Do nothing here.      this.comptable = new Hashtable();
68        this.defaultConstraints= new GridBagConstraints();
69    }    }
70    
71    /**    /**
# Line 105  public class GridBagLayout Line 106  public class GridBagLayout
106    
107    public void addLayoutComponent (Component component, Object constraints)    public void addLayoutComponent (Component component, Object constraints)
108    {    {
109        if (constraints == null)
110          return;
111    
112      if (!(constraints instanceof GridBagConstraints))      if (!(constraints instanceof GridBagConstraints))
113        throw new IllegalArgumentException();        throw new IllegalArgumentException();
114    
# Line 157  public class GridBagLayout Line 161  public class GridBagLayout
161    public void setConstraints (Component component,    public void setConstraints (Component component,
162                                GridBagConstraints constraints)                                GridBagConstraints constraints)
163    {    {
164      comptable.put (component, constraints);      GridBagConstraints clone = (GridBagConstraints) constraints.clone();
165    
166        if (clone.gridx < 0)
167          clone.gridx = GridBagConstraints.RELATIVE;
168        
169        if (clone.gridy < 0)
170          clone.gridy = GridBagConstraints.RELATIVE;
171    
172        if (clone.gridwidth == 0)
173          clone.gridwidth = GridBagConstraints.REMAINDER;
174        else if (clone.gridwidth < 0
175                 && clone.gridwidth != GridBagConstraints.REMAINDER
176                 && clone.gridwidth != GridBagConstraints.RELATIVE)
177          clone.gridwidth = 1;
178        
179        if (clone.gridheight == 0)
180          clone.gridheight = GridBagConstraints.REMAINDER;
181        else if (clone.gridheight < 0
182                 && clone.gridheight != GridBagConstraints.REMAINDER
183                 && clone.gridheight != GridBagConstraints.RELATIVE)
184          clone.gridheight = 1;
185        
186        comptable.put (component, clone);
187    }    }
188    
189    public GridBagConstraints getConstraints (Component component)    public GridBagConstraints getConstraints (Component component)
190    {    {
191      GridBagConstraints constraints = lookupConstraints (component);      return (GridBagConstraints) (lookupConstraints (component).clone());
   
     if (constraints == null)  
       return null;  
   
     return (GridBagConstraints) constraints.clone();  
192    }    }
193    
194    protected GridBagConstraints lookupConstraints (Component component)    protected GridBagConstraints lookupConstraints (Component component)
# Line 191  public class GridBagLayout Line 212  public class GridBagLayout
212      if (layoutInfo == null)      if (layoutInfo == null)
213        return new Point (0, 0);        return new Point (0, 0);
214            
215      return new Point (layoutInfo.x, layoutInfo.y);      return new Point (layoutInfo.pos_x, layoutInfo.pos_y);
216    }    }
217    
218    /**    /**
# Line 233  public class GridBagLayout Line 254  public class GridBagLayout
254    
255      int col;      int col;
256      int row;      int row;
257      int pixel_x = layoutInfo.x;      int pixel_x = layoutInfo.pos_x;
258      int pixel_y = layoutInfo.y;      int pixel_y = layoutInfo.pos_y;
259    
260      for (col = 0; col < layoutInfo.cols; col++)      for (col = 0; col < layoutInfo.cols; col++)
261        {        {
# Line 367  public class GridBagLayout Line 388  public class GridBagLayout
388      if (sizeflag != MINSIZE && sizeflag != PREFERREDSIZE)      if (sizeflag != MINSIZE && sizeflag != PREFERREDSIZE)
389        throw new IllegalArgumentException();        throw new IllegalArgumentException();
390    
391      GridBagLayoutInfo info = new GridBagLayoutInfo (MAXGRIDSIZE, MAXGRIDSIZE);      GridBagLayoutInfo info = new GridBagLayoutInfo (0, 0);
     Dimension dimension = sizeflag == MINSIZE ? parent.getMinimumSize()  
                                               : parent.getPreferredSize();  
392            
393        Component[] components = parent.getComponents();
394        for (int i = 0; i < components.length; i++)
395          {
396            Component component = components [i];
397            
398            // If component is not visible we dont have to care about it.
399            if (!component.isVisible())
400              continue;
401    
402            GridBagConstraints constraints = lookupConstraints (component);
403            
404            int max_x = 1;
405            int max_y = 1;
406            int cur_x = 0;
407    
408            
409            
410            // FIXME
411          }
412    
413      // FIXME      // FIXME
414        
415        // DEBUG
416        dumpLayoutInfo (info);
417    
418      return info;      return info;
419    }    }

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26