public class GuiTableLayout extends GuiLayout
Children are added and removed with the usual addChild(GuiElement) and removeChild(GuiElement) methods.
Removing a child has the additional effect of 'shifting' all the following children one cell to the left and from the first cell of a row to the last cell of the previous row.
The table can have 'empty cells', by adding a null child in the proper sequence.
The layout sets the font size of GuiLabel's, the border thickness and the background of GuiTextField's as well as the clickable status of all children when each child is added to the layout. These properties, as well as other visual properties, can be changed after adding the child.
The layout also sets the pivot position of each child on adding it; changing it is possible, but it is likely to disrupt the proper child placement within the layout.
The layout sets the position of each child each time the layout() is called; setting those position manually has no effect.
Important: due to the way Rising World plug-ins are loaded, this class cannot instantiated or used in any way from within the onEnable() method of a plug-in, as it is impossible to be sure that, at that moment, the RWGui plug-in has already been loaded.
The first moment one can be sure that all plug-ins have been loaded, and it is safe to use this class, is when (or after) the first player connects to the server (either dedicated or local).
Constructor and Description |
---|
GuiTableLayout(int maxNumOfCols,
int maxNumOfRows,
int flags)
Creates a new table layout with up to maxNumOfCol columns and up to
maxNumOfRows rows.
|
Modifier and Type | Method and Description |
---|---|
void |
addChild(net.risingworld.api.gui.GuiElement element,
java.lang.Integer id,
java.lang.Object data)
Overrides the corresponding method of GuiLayout to allow for null
children.
|
void |
setColFlag(int idx,
int flag)
Set the horizontal alignment flag of a column, which affects the
horizontal alignment of all the cells of the column.
|
void |
setRowFlag(int idx,
int flag)
Set the vertical alignment flag of a row, which affects the
vertical alignment of all the cells of the row.
|
addChild, addChild, addNewLayoutChild, addNewTableLayoutChild, free, getItemData, getItemId, hide, layout, removeChild, setMargin, setPadding, show
destroy, equals, getAlpha, getBorderColor, getBorderThickness, getColor, getHeight, getHoverColor, getID, getParent, getParentID, getPivot, getPositionX, getPositionY, getWidth, hashCode, isRelativeBorderThickness, isRelativePosition, isRelativeSize, isVisible, refresh, removeFromParent, setAlpha, setBorderColor, setBorderColor, setBorderThickness, setColor, setColor, setPivot, setPosition, setSize, setVisible
public GuiTableLayout(int maxNumOfCols, int maxNumOfRows, int flags)
The number of columns and of rows cannot be modified after creation.
maxNumOfCols
- the number of table columnsmaxNumOfRows
- the number of table rowsflags
- reserved for future expansions; set to 0public void setColFlag(int idx, int flag)
idx
- the index of the column (0 = leftmost column)flag
- the alignment flags: one of RWGui.LAYOUT_H_LEFT (which
is the default), RWGui.LAYOUT_H_CENTRE or
RWGui.LAYOUT_H_RIGHT.public void setRowFlag(int idx, int flag)
idx
- the index of the row (0 = topmost row)flag
- the alignment flags: one of RWGui.LAYOUT_V_TOP,
RWGui.LAYOUT_V_MIDDLE (which is the default) or
RWGui.LAYOUT_V_BOTTOM.public void addChild(net.risingworld.api.gui.GuiElement element, java.lang.Integer id, java.lang.Object data)