Class TextBoxObject
java.lang.Object
com.iragui.objects.GUIObject
com.iragui.objects.TextBoxObject
- Direct Known Subclasses:
WritableTextBoxObject
A
TextBoxObject
represents a multi-line text container within the GUI.
Each line of text is internally represented as a TextObject
and stored in a TreeMap
.
The text box manages positioning, spacing between lines, and propagates updates
(such as position, limits, and layer changes) to its child TextObject
s.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected TreeMap
<Integer, TextObject> Holds the lines of text, ordered by index. -
Constructor Summary
ConstructorsConstructorDescriptionTextBoxObject
(String name, int layer, GUI gui, int x, int y, int sizeX, int sizeY, boolean nearestFilter, boolean rgba, int lineSpacing) Constructs a newTextBoxObject
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
appendLine
(String text, Font font, Color color, Color bkgColor, boolean rgba, boolean nearestFilter, boolean antiAliasing) Appends a new line of text to this text box.void
Destroys this object, releasing GPU resources and unregistering it.getLines()
int
void
sendKey
(int key, int action) Handles key input events.void
sendMouseButton
(long window, int button, int action, int mods) Handles mouse button input.void
sendMousePos
(long window, double xPos, double yPos) Handles mouse position updates.void
sendMouseScroll
(long window, double xOffset, double yOffset) Handles mouse scroll input.void
setLayer
(int layer) Sets the rendering layer and updates parent GUI ordering.void
setLimitX
(int x) void
setLimitY
(int y) void
setLineSpacing
(int space) Sets the vertical spacing between lines.void
setMinX
(int x) void
setMinY
(int y) void
setWinLimitX
(int x) void
setWinLimitY
(int y) void
setWinMinX
(int x) void
setWinMinY
(int y) void
setX
(int x) Sets the X position in pixels.void
setY
(int y) Sets the Y position in pixels.void
update
(boolean showFrame) Update logic called each frame.Methods inherited from class com.iragui.objects.GUIObject
allowReTexture, focus, getGlPixelInt, getHFlip, getLayer, getLimitX, getLimitY, getMinX, getMinY, getRotation, getScale, getSizeX, getSizeY, getTextureID, getVFlip, getVisible, getWinLimitX, getWinLimitY, getWinMinX, getWinMinY, getX, getY, hide, includesKeyCallback, includesMouseCallback, interactionInVisibleBounds, isDestroyed, isFocused, isNearestFilter, render, resetTextureID, setAll, setAll, setHFlip, setNearestFilter, setPixel, setPreserveTextureIDOverride, setRotation, setScale, setTextureID, setVFlip, setVisible, unfocus, updates
-
Field Details
-
lines
Holds the lines of text, ordered by index.
-
-
Constructor Details
-
TextBoxObject
public TextBoxObject(String name, int layer, GUI gui, int x, int y, int sizeX, int sizeY, boolean nearestFilter, boolean rgba, int lineSpacing) Constructs a newTextBoxObject
.- Parameters:
name
- the unique object namelayer
- the rendering layergui
- the parent GUIx
- the x-positiony
- the y-positionsizeX
- the width of the text boxsizeY
- the height of the text boxnearestFilter
- whether to use nearest-neighbor filteringrgba
- whether to use RGBA textureslineSpacing
- vertical spacing between lines
-
-
Method Details
-
appendLine
public void appendLine(String text, Font font, Color color, Color bkgColor, boolean rgba, boolean nearestFilter, boolean antiAliasing) Appends a new line of text to this text box.- Parameters:
text
- the string contentfont
- the font used to render the textcolor
- the text colorbkgColor
- the background colorrgba
- whether the text uses RGBAnearestFilter
- whether to use nearest-neighbor filteringantiAliasing
- whether to apply anti-aliasing
-
getLineSpacing
public int getLineSpacing()- Returns:
- the vertical spacing between lines.
-
setLineSpacing
public void setLineSpacing(int space) Sets the vertical spacing between lines.- Parameters:
space
- the line spacing in pixels
-
setLayer
-
destroyObject
public void destroyObject()Destroys this object, releasing GPU resources and unregistering it.If
preserveTextureIDOverride
is true, the OpenGL texture ID will not be deleted. SeeGUIObject.setPreserveTextureIDOverride(boolean)
.- Overrides:
destroyObject
in classGUIObject
-
setX
-
setY
-
setLimitX
-
setMinX
-
setMinY
-
setLimitY
-
setWinLimitX
public void setWinLimitX(int x) - Overrides:
setWinLimitX
in classGUIObject
-
setWinLimitY
public void setWinLimitY(int y) - Overrides:
setWinLimitY
in classGUIObject
-
setWinMinX
public void setWinMinX(int x) - Overrides:
setWinMinX
in classGUIObject
-
setWinMinY
public void setWinMinY(int y) - Overrides:
setWinMinY
in classGUIObject
-
update
-
sendKey
-
sendMousePos
public void sendMousePos(long window, double xPos, double yPos) Description copied from class:GUIObject
Handles mouse position updates.- Specified by:
sendMousePos
in classGUIObject
-
sendMouseButton
public void sendMouseButton(long window, int button, int action, int mods) Description copied from class:GUIObject
Handles mouse button input.- Specified by:
sendMouseButton
in classGUIObject
-
sendMouseScroll
public void sendMouseScroll(long window, double xOffset, double yOffset) Description copied from class:GUIObject
Handles mouse scroll input.- Specified by:
sendMouseScroll
in classGUIObject
-
getLines
- Returns:
- all text lines as a
TreeMap
.
-