superwaba.ext.xplat.ui
Class GridContainer
java.lang.Object
|
+--waba.ui.Control
|
+--waba.ui.Container
|
+--superwaba.ext.xplat.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(getClientRect());
add(gc);
which should give you something like:
_____________________
| | |
| One | Two |
|__________|__________|
| | |
| Three | Four |
|__________|__________|
Fields inherited from class waba.ui.Container |
BORDER_LOWERED,
BORDER_NONE,
BORDER_RAISED,
BORDER_SIMPLE,
children,
lastH,
lastW,
lastX,
lastY,
parentWindow,
tail |
Fields inherited from class waba.ui.Control |
AFTER,
appId,
asContainer,
asWindow,
backColor,
backDis,
BEFORE,
BOTTOM,
CENTER,
enabled,
FILL,
FIT,
fm,
fmH,
focusLess,
font,
foreColor,
foreDis,
height,
LEFT,
parent,
PREFERRED,
RANGE,
RIGHT,
SAME,
TOP,
visible,
width,
x,
x2,
y,
y2 |
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 |
add,
broadcastEvent,
findChild,
getChildren,
getClientRect,
onColorsChanged,
onPaint,
onStart,
paintChildren,
setBorderStyle,
setEnabled |
Methods inherited from class waba.ui.Control |
addTimer,
contains,
createGraphics,
getAbsoluteRect,
getBackColor,
getFont,
getFontMetrics,
getForeColor,
getNext,
getParent,
getParentWindow,
getPos,
getPreferredHeight,
getPreferredWidth,
getRect,
getSize,
isDisplayed,
isEnabled,
isVisible,
onBoundsChanged,
onEvent,
onFontChanged,
onWindowPaintFinished,
postEvent,
removeTimer,
repaint,
repaintNow,
requestFocus,
setBackColor,
setBackForeColors,
setFocusLess,
setFont,
setForeColor,
setRect,
setRect,
setVisible |
layout
protected Control[][] layout
- the layout of controls
xgap
protected int xgap
ygap
protected int ygap
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.
setGaps
public void setGaps(int x,
int y)
- Sets the gap between controls.
- Parameters:
x
- the x gap in pixelsy
- 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 coordy
- the y grid coord- Returns:
- a control, or null if none at that position
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
- Overrides:
- add in class Container
- Parameters:
x
- the x grid coordy
- 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 coordy
- 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.