extra.ui
Class GridContainer

java.lang.Object
  |
  +--waba.ui.Control
        |
        +--waba.ui.Container
              |
              +--extra.ui.GridContainer

public class GridContainer
extends Container

A container that lays it's component controls out in a grid. Here's an example.

   GridContainer gc=new GridContainer(2,2);
   gc.add(new Button("One"));
   gc.add(new Button("Two"));
   gc.add(new Button("Three"));
   gc.add(new Button("Four"));
   gc.setRect(0,0,160,100);
   add(gc);
 
which should give you something like:
  _____________________
 |          |          |
 |   One    |   Two    |
 |__________|__________|
 |          |          |
 |  Three   |   Four   |
 |__________|__________|
 


Constructor Summary
GridContainer(int gridx, int gridy)
          Construct a new container with the specified grid width and height.
 
Method Summary
 void add(Control c)
          Adds a control at the grid position to the left of the last one added or (0,0) if this is the first.
 void add(Control c, int x, int y)
          Adds a control at the specified grid position
 Control get(int x, int y)
          Gets the control at the given grid position
 void layout()
          Layout all the controls in this container.
 void remove(Control c)
          Removes a control from this layout.
 void remove(int x, int y)
          Removes a control at the given grid position.
 void setGaps(int x, int y)
          Sets the gap between controls.
 void setRect(int x, int y, int width, int height)
          Sets the rect for this container.
 
Methods inherited from class waba.ui.Container
findChild, paintChildren
 
Methods inherited from class waba.ui.Control
addTimer, contains, createGraphics, getFontMetrics, getNext, getParent, getRect, onEvent, onPaint, postEvent, removeTimer, repaint
 
Methods inherited from class java.lang.Object
equals, hashCode, toString
 

Constructor Detail

GridContainer

public GridContainer(int gridx,
                     int gridy)
Construct a new container with the specified grid width and height.
Parameters:
gridx - the number of columns in the grid.
gridy - the number of rows in the grid.
Method Detail

setGaps

public void setGaps(int x,
                    int y)
Sets the gap between controls.
Parameters:
x - the x gap in pixels
y - the y gap in pixels

get

public Control get(int x,
                   int y)
Gets the control at the given grid position
Parameters:
x - the x grid coord
y - the y grid coord

add

public void add(Control c)
Adds a control at the grid position to the left of the last one added or (0,0) if this is the first. If the last added was at the maximum x position, this one is added at an x pos of 0 on the next y pos down.
Overrides:
add in class Container
Parameters:
c - the control to add

add

public void add(Control c,
                int x,
                int y)
Adds a control at the specified grid position
Parameters:
x - the x grid coord
y - the y grid coord

remove

public void remove(Control c)
Removes a control from this layout.
Overrides:
remove in class Container
Parameters:
c - the control to remove

remove

public void remove(int x,
                   int y)
Removes a control at the given grid position.
Parameters:
x - the x grid coord
y - the y grid coord

setRect

public void setRect(int x,
                    int y,
                    int width,
                    int height)
Sets the rect for this container. Redoes the layout.
Overrides:
setRect in class Control

layout

public void layout()
Layout all the controls in this container.