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
ConstructorDescriptionCheckboxWidget
(String title, int x, int y, int width, int height, Consumer<Boolean> onCheckAction) Constructs a newWidget
with the specified position and size. -
Method Summary
Modifier and TypeMethodDescriptionfinal int
Returns the size of the checkbox.final NanoColor
Returns the color of the checkbox icon when checked.final String
Returns the icon used to represent a checked state.final String
Returns the font name used for the title text.final int
Returns the font size used for the title text.final String
Returns the font name used for the checkbox icon.final NanoColor
Returns the color of the title text.final int
Returns the offset between the checkbox and the title text.final String
Returns the title text for the checkbox.final boolean
Returns whether the checkbox is currently checked.final boolean
isEnable()
Returns whether the checkbox is enabled.void
onLeftMouseUp
(int x, int y) Handles the left mouse button release event to toggle the checkbox state.void
render()
Renders theWidget
final void
setCheckBoxSize
(int checkBoxSize) Sets the size of the checkbox.final void
setCheckColor
(NanoColor checkColor) Sets the color of the checkbox icon when checked.final void
setChecked
(boolean checked) Sets whether the checkbox is currently checked.final void
setCheckIcon
(String checkIcon) Sets the icon used to represent a checked state.final void
setEnable
(boolean enable) Sets whether the checkbox is enabled.final void
setFontName
(String fontName) Sets the font name used for the title text.final void
setFontSize
(int fontSize) Sets the font size used for the title text.final void
setIconFontName
(String iconFontName) Sets the font name used for the checkbox icon.void
setOnCheckAction
(Consumer<Boolean> onCheckAction) Sets the action to perform when the checkbox is checked or unchecked.final void
setTitleColor
(NanoColor titleColor) Sets the color of the title text.final void
setTitleOffset
(int titleOffset) Sets the offset between the checkbox and the title text.final void
setTitleText
(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:
onLeftMouseUp
in 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:
true
if the checkbox is checked,false
otherwise
-
setChecked
public final void setChecked(boolean checked) Sets whether the checkbox is currently checked.- Parameters:
checked
-true
to check the checkbox,false
to uncheck it
-
isEnable
public final boolean isEnable()Returns whether the checkbox is enabled.- Returns:
true
if the checkbox is enabled,false
otherwise
-
setEnable
public final void setEnable(boolean enable) Sets whether the checkbox is enabled.- Parameters:
enable
-true
to enable the checkbox,false
to 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
-