Package com.avrix.ui.widgets
Class CheckboxWidget
java.lang.Object
com.avrix.ui.widgets.Widget
com.avrix.ui.widgets.CheckboxWidget
A
Widget that represents a checkbox with a title and an icon.
The checkbox can be checked or unchecked, and the title text can be truncated with an ellipsis if it exceeds the maximum width.-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionCheckboxWidget(String title, int x, int y, int width, int height, Consumer<Boolean> onCheckAction) Constructs a newWidgetwith the specified position and size. -
Method Summary
Modifier and TypeMethodDescriptionfinal intReturns the size of the checkbox.final NanoColorReturns the color of the checkbox icon when checked.final StringReturns the icon used to represent a checked state.final StringReturns the font name used for the title text.final intReturns the font size used for the title text.final StringReturns the font name used for the checkbox icon.final NanoColorReturns the color of the title text.final intReturns the offset between the checkbox and the title text.final StringReturns the title text for the checkbox.final booleanReturns whether the checkbox is currently checked.final booleanisEnable()Returns whether the checkbox is enabled.voidonLeftMouseUp(int x, int y) Handles the left mouse button release event to toggle the checkbox state.voidrender()Renders theWidgetfinal voidsetCheckBoxSize(int checkBoxSize) Sets the size of the checkbox.final voidsetCheckColor(NanoColor checkColor) Sets the color of the checkbox icon when checked.final voidsetChecked(boolean checked) Sets whether the checkbox is currently checked.final voidsetCheckIcon(String checkIcon) Sets the icon used to represent a checked state.final voidsetEnable(boolean enable) Sets whether the checkbox is enabled.final voidsetFontName(String fontName) Sets the font name used for the title text.final voidsetFontSize(int fontSize) Sets the font size used for the title text.final voidsetIconFontName(String iconFontName) Sets the font name used for the checkbox icon.voidsetOnCheckAction(Consumer<Boolean> onCheckAction) Sets the action to perform when the checkbox is checked or unchecked.final voidsetTitleColor(NanoColor titleColor) Sets the color of the title text.final voidsetTitleOffset(int titleOffset) Sets the offset between the checkbox and the title text.final voidsetTitleText(String titleText) Sets the title text for the checkbox.Methods inherited from class com.avrix.ui.widgets.Widget
addChild, addToScreen, bringToTop, drawArc, drawArc, drawCircle, drawEllipse, drawImage, drawLine, drawRect, drawRectOutline, drawRoundedRect, drawRoundedRectOutline, drawText, getAbsoluteParent, getChildren, getHeight, getMaxScrollX, getMaxScrollY, getParent, getScrollSpeed, getScrollX, getScrollY, getWidth, getX, getXA, getY, getYA, intersectScissor, isAlwaysOnTop, isHovered, isPointOver, isScrollable, isScrollLock, isVisible, isVisibleWithinParent, isVisibleWithinWindow, onInitialize, onKeyPress, onKeyRelease, onKeyRepeat, onLeftMouseDown, onLeftMouseDownOutside, onLeftMouseUpOutside, onMouseEnter, onMouseExit, onMouseMove, onMouseMoveOutside, onMouseWheel, onRightMouseDown, onRightMouseDownOutside, onRightMouseUp, onRightMouseUpOutside, postRender, preRender, removeChild, removeFromScreen, renderChildren, setAlwaysOnTop, setHeight, setMaxScrollX, setMaxScrollY, setScrollable, setScrollLock, setScrollSpeed, setScrollX, setScrollY, setVisible, setWidth, setX, setXA, setY, setYA, update
-
Constructor Details
-
Method Details
-
onLeftMouseUp
public void onLeftMouseUp(int x, int y) Handles the left mouse button release event to toggle the checkbox state.- Overrides:
onLeftMouseUpin classWidget- Parameters:
x- the x-coordinate of the mouse eventy- the y-coordinate of the mouse event
-
getTitleText
Returns the title text for the checkbox.- Returns:
- the title text
-
setTitleText
Sets the title text for the checkbox.- Parameters:
titleText- the title text to set
-
getFontName
Returns the font name used for the title text.- Returns:
- the font name
-
setFontName
Sets the font name used for the title text.- Parameters:
fontName- the font name to set
-
getCheckIcon
Returns the icon used to represent a checked state.- Returns:
- the check icon
-
setCheckIcon
Sets the icon used to represent a checked state.- Parameters:
checkIcon- the check icon to set
-
getIconFontName
Returns the font name used for the checkbox icon.- Returns:
- the icon font name
-
setIconFontName
Sets the font name used for the checkbox icon.- Parameters:
iconFontName- the icon font name to set
-
getCheckBoxSize
public final int getCheckBoxSize()Returns the size of the checkbox.- Returns:
- the checkbox size
-
setCheckBoxSize
public final void setCheckBoxSize(int checkBoxSize) Sets the size of the checkbox.- Parameters:
checkBoxSize- the checkbox size to set
-
getFontSize
public final int getFontSize()Returns the font size used for the title text.- Returns:
- the font size
-
setFontSize
public final void setFontSize(int fontSize) Sets the font size used for the title text.- Parameters:
fontSize- the font size to set
-
getTitleOffset
public final int getTitleOffset()Returns the offset between the checkbox and the title text.- Returns:
- the title offset
-
setTitleOffset
public final void setTitleOffset(int titleOffset) Sets the offset between the checkbox and the title text.- Parameters:
titleOffset- the title offset to set
-
isChecked
public final boolean isChecked()Returns whether the checkbox is currently checked.- Returns:
trueif the checkbox is checked,falseotherwise
-
setChecked
public final void setChecked(boolean checked) Sets whether the checkbox is currently checked.- Parameters:
checked-trueto check the checkbox,falseto uncheck it
-
isEnable
public final boolean isEnable()Returns whether the checkbox is enabled.- Returns:
trueif the checkbox is enabled,falseotherwise
-
setEnable
public final void setEnable(boolean enable) Sets whether the checkbox is enabled.- Parameters:
enable-trueto enable the checkbox,falseto disable it
-
getTitleColor
Returns the color of the title text.- Returns:
- the title color
-
setTitleColor
Sets the color of the title text.- Parameters:
titleColor- the title color to set
-
getCheckColor
Returns the color of the checkbox icon when checked.- Returns:
- the check color
-
setCheckColor
Sets the color of the checkbox icon when checked.- Parameters:
checkColor- the check color to set
-
setOnCheckAction
Sets the action to perform when the checkbox is checked or unchecked.- Parameters:
onCheckAction- the action to perform
-
render
public void render()Renders theWidget
-