Package app.ui.widgets
Class Widget
java.lang.Object
app.ui.widgets.Widget
- All Implemented Interfaces:
IDrawable
- Direct Known Subclasses:
WidgetButton,WidgetLabel,WidgetPageSelection,WidgetTextBox,WidgetToggle
Abstract class for all widgets in the UI package.
This class provides basic properties and functionalities
common to all widgets, such as position, text, and visibility.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract voiddraw(char[][] buffer, com.googlecode.lanterna.TextColor[][] printColor, com.googlecode.lanterna.TextColor[][] backColor) Abstract method to draw the widget.voiddrawText(char[][] buffer) Draws the text of the widget onto a buffer.intgetLen()Returns the length of the widget.booleanChecks if the widget is selected.booleanChecks if the widget's selection is skipped.getText()Returns the text of the widget.intReturns the widget ID.intgetX()Returns the x-coordinate of the widget.intgetY()Returns the y-coordinate of the widget.booleanisHide()Checks if the widget is hidden.voidsetHide(boolean ifHide) Sets the visibility of the widget.voidsetSkipSelection(boolean skipSelection) Sets whether the widget's selection should be skipped.voidSets the text of the widget.voidsetWidgetID(int id) Sets the widget ID.
-
Field Details
-
x
protected int x -
y
protected int y -
len
protected int len -
selected
protected boolean selected -
text
-
hide
protected boolean hide
-
-
Constructor Details
-
Widget
Constructor for Widget.- Parameters:
x- x coordinate of the widget.y- y coordinate of the widget.len- length of the widget.text- text of the widget.
-
-
Method Details
-
isHide
public boolean isHide()Checks if the widget is hidden.- Returns:
- true if the widget is hidden, false otherwise.
-
getSkipSelection
public boolean getSkipSelection()Checks if the widget's selection is skipped.- Returns:
- true if the widget's selection is skipped, false otherwise.
-
setSkipSelection
public void setSkipSelection(boolean skipSelection) Sets whether the widget's selection should be skipped.- Parameters:
skipSelection- true to skip the selection, false otherwise.
-
setHide
public void setHide(boolean ifHide) Sets the visibility of the widget.- Parameters:
ifHide- true to hide the widget, false to show it.
-
getLen
public int getLen()Returns the length of the widget.- Returns:
- The length of the widget.
-
getText
Returns the text of the widget.- Returns:
- The text of the widget.
-
setText
Sets the text of the widget.- Parameters:
text- The text to set for the widget.
-
getSelected
public boolean getSelected()Checks if the widget is selected.- Returns:
- true if the widget is selected, false otherwise.
-
getX
public int getX()Returns the x-coordinate of the widget.- Returns:
- The x-coordinate of the widget.
-
getY
public int getY()Returns the y-coordinate of the widget.- Returns:
- The y-coordinate of the widget.
-
drawText
public void drawText(char[][] buffer) Draws the text of the widget onto a buffer. -
setWidgetID
public void setWidgetID(int id) Sets the widget ID.- Parameters:
id- The new ID for the widget.
-
getWidgetID
public int getWidgetID()Returns the widget ID.- Returns:
- The ID of the widget.
-
draw
public abstract void draw(char[][] buffer, com.googlecode.lanterna.TextColor[][] printColor, com.googlecode.lanterna.TextColor[][] backColor) Abstract method to draw the widget. This method should be implemented by subclasses.
-