public class FixedGrid extends Container
All the children are laid out in a grid, which has a fixed number of columns and rows.
In a grid, all children have the same width and the same height, regardless of their optimal size.
NO_CONSTRAINT
Constructor and Description |
---|
FixedGrid(int columns,
int rows)
Creates a grid specifying its number of columns and rows.
|
Modifier and Type | Method and Description |
---|---|
void |
addChild(Widget child,
int column,
int row)
Adds a widget at the specified column and row.
|
protected void |
computeContentOptimalSize(Size size)
Computes the optimal size of the widget.
|
Widget |
getCellChild(int column,
int row)
Gets the widget at the specified column and row.
|
int |
getColumns()
Gets the number of columns.
|
int |
getRows()
Gets the number of rows.
|
protected void |
layOutChildren(int contentWidth,
int contentHeight)
Lays out the children of this container.
|
void |
removeAllChildren()
Removes all the children of this container.
|
void |
removeChild(int column,
int row)
Removes the widget at the specified column and row.
|
addChild, changeChildIndex, computeChildOptimalSize, getChild, getChildIndex, getChildren, getChildrenCount, getContentBounds, getContentHeight, getContentWidth, getContentX, getContentY, getWidgetAt, insertChild, layOutAlignedChild, layOutChild, removeChild, renderChild, renderContent, replaceChild, setHiddenChild, setHiddenChildren, setShownChild, setShownChildren, updateStyle
addClassSelector, contains, containsWidget, getAbsoluteX, getAbsoluteY, getDesktop, getHeight, getParent, getStyle, getWidth, getX, getY, handleEvent, hasClassSelector, isAttached, isEnabled, isInState, isShown, isTransparent, onAttached, onDetached, onHidden, onLaidOut, onShown, removeAllClassSelectors, removeClassSelector, render, requestLayOut, requestRender, requestRender, setClassSelectors, setEnabled, setPosition, setStyle
public FixedGrid(int columns, int rows)
columns
- the number of columnsrows
- the number of rowsIllegalArgumentException
- if one of the parameters is negative or zeropublic void addChild(Widget child, int column, int row)
child
- the child to addcolumn
- the column of the widgetrow
- the row of the widgetIndexOutOfBoundsException
- if the cell referenced by the given coordinates is out of rangeprotected void computeContentOptimalSize(Size size)
Widget
This method does not consider the border, margin, padding and dimension specified in the style.
The given size is the available size for this widget in its parent. A width or a height equal to
Widget#NO_CONSTRAINT
means that there is no constraint on this dimension.
The given size is modified to set the optimal size.
computeContentOptimalSize
in class Widget
size
- the size available for the content.@Nullable public Widget getCellChild(int column, int row)
column
- the column of the widget to returnrow
- the row of the widget to returnIndexOutOfBoundsException
- if the cell referenced by the given coordinates is out of rangepublic int getColumns()
public int getRows()
protected void layOutChildren(int contentWidth, int contentHeight)
Container
The given size is the size of this container minus the border, margin and padding specified in the style.
When this method returns the children of this container have been lay out using
Container.layOutChild(Widget, int, int, int, int)
.
layOutChildren
in class Container
contentWidth
- the width available for the content.contentHeight
- the height available for the content.public void removeAllChildren()
Container
The container needs to be laid out again.
Should be called in the display thread to avoid concurrency issues.
removeAllChildren
in class Container
Widget.requestLayOut()
public void removeChild(int column, int row)
column
- the column of the widgetrow
- the row of the widgetIndexOutOfBoundsException
- if the cell referenced by the given coordinates is out of range