public class GuiCheckBox extends GuiLayout
Both types can have three states: DISABLED, UNCHECKED and CHECKED. Unless they are in the DISABLED state, they generate notifications via the callback object of the GuiModalWindow they belong to.
Both also manage state changes (CHECKED to UNCHECKED and vice versa) upon click events. Radio boxes also manage unchecking other radio boxes belonging to the same immediate layout parent, when changing into CHECKED. If click event notification is required, which is usually the case, a non-null id (and optionally data) parameter in the constructor is required. Passing an id (and a data object) when adding the box to a GuiLayout, as when adding other non-layout children, has no effect.
Modifier and Type | Field and Description |
---|---|
static int |
CHECKED |
static int |
DISABLED |
static int |
UNCHECKED |
Constructor and Description |
---|
GuiCheckBox(java.lang.String text,
int initialState,
boolean radio,
java.lang.Integer id,
java.lang.Object data)
Constructs a check/radio box with text as a label, initialState as
current state and click id and data.
|
Modifier and Type | Method and Description |
---|---|
void |
addChild(net.risingworld.api.gui.GuiElement element)
Overridden, does nothing
|
void |
addChild(net.risingworld.api.gui.GuiElement element,
java.lang.Integer id)
Overridden, does nothing
|
void |
addChild(net.risingworld.api.gui.GuiElement element,
java.lang.Integer id,
java.lang.Object data)
Overridden, does nothing
|
GuiLayout |
addNewLayoutChild(int layoutType,
int layoutFlags)
Overridden, does nothing
|
GuiLayout |
addNewTableLayoutChild(int colNum,
int rowNum,
int flags)
Overridden, does nothing
|
RWGui.Pair<java.lang.Integer,java.lang.Object> |
getItemData(net.risingworld.api.gui.GuiElement element)
Returns the id and data pair associated with the GuiCheckBox if element
is any of the GuiElement making it up and the state is not DISABLED.
|
java.lang.Integer |
getItemId(net.risingworld.api.gui.GuiElement element)
Returns the id associated with the GuiCheckBox if element is any of the
GuiElement making it up and the state is not DISABLED.
|
int |
getState()
Queries the state of the box.
|
boolean |
isRadio()
Queries the type of the box.
|
void |
removeChild(net.risingworld.api.gui.GuiElement element)
Overridden, does nothing
|
void |
setState(int newState)
Sets the new state of the box.
|
free, getChildFromId, hide, layout, 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 static final int DISABLED
public static final int UNCHECKED
public static final int CHECKED
public GuiCheckBox(java.lang.String text, int initialState, boolean radio, java.lang.Integer id, java.lang.Object data)
text
- the text of the labelinitialState
- the initial state (one of DISABLED, CHECKED or UNCHECKED)radio
- if true the box is a radio box, if false it is a check boxid
- the click id notified to the callback of the
GuiModalwindow this box belongs todata
- the click data notified to the callback of the
GuiModalwindow this box belongs to (optional)public boolean isRadio()
public int getState()
public void setState(int newState)
newState
- the new state (one of DISABLED, CHECKED or UNCHECKED).public java.lang.Integer getItemId(net.risingworld.api.gui.GuiElement element)
public RWGui.Pair<java.lang.Integer,java.lang.Object> getItemData(net.risingworld.api.gui.GuiElement element)
getItemData
in class GuiLayout
element
- the GuiElement to look for.public void addChild(net.risingworld.api.gui.GuiElement element)
public void addChild(net.risingworld.api.gui.GuiElement element, java.lang.Integer id)
public void addChild(net.risingworld.api.gui.GuiElement element, java.lang.Integer id, java.lang.Object data)
public void removeChild(net.risingworld.api.gui.GuiElement element)
removeChild
in class GuiLayout
element
- The GuiElement to removepublic GuiLayout addNewLayoutChild(int layoutType, int layoutFlags)
addNewLayoutChild
in class GuiLayout
layoutType
- either RWGui.LAYOUT_HORIZ or RWGui.LAYOUT_VERT.layoutFlags
- one of the RWGui.LAYOUT_H_* flags ORed with one of
RWGui.LAYOUT_V_* flags; their meaning depends on the layout type
(RWGui.LAYOUT_HORIZ or RWGui.LAYOUT_VERT).public GuiLayout addNewTableLayoutChild(int colNum, int rowNum, int flags)
addNewTableLayoutChild
in class GuiLayout
colNum
- the number of columns the table will haverowNum
- the number of rows the table will have.flags
- currently not used, set to 0.