Module com.googlecode.lanterna
Package com.googlecode.lanterna.gui2
Class TextBox.DefaultTextBoxRenderer
java.lang.Object
com.googlecode.lanterna.gui2.TextBox.DefaultTextBoxRenderer
- All Implemented Interfaces:
ComponentRenderer<TextBox>
,InteractableRenderer<TextBox>
,TextBox.TextBoxRenderer
- Enclosing class:
TextBox
public static class TextBox.DefaultTextBoxRenderer
extends Object
implements TextBox.TextBoxRenderer
This is the default text box renderer that is used if you don't override anything. With this renderer, the text
box is filled with a solid background color and the text is drawn on top of it. Scrollbars are added for
multi-line text whenever the text inside the
TextBox
does not fit in the available area.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
private final ScrollBar
private Character
private final ScrollBar
private TerminalPosition
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
drawComponent
(TextGUIGraphics graphics, TextBox component) Using the supplied graphics object, draws the component passed in.private void
drawTextArea
(TextGUIGraphics graphics, TextBox component) getCursorLocation
(TextBox component) getPreferredSize
(TextBox component) Given the supplied component, how large does this renderer want the component to be? Notice that this is the responsibility of the renderer and not the component itself, since the component has no idea what its visual representation looks like.void
setHideScrollBars
(boolean hideScrollBars) Controls whether scrollbars should be visible or not when a multi-lineTextBox
has more content than it can draw in the area it was assigned (default: false)void
setUnusedSpaceCharacter
(char unusedSpaceCharacter) Sets the character to represent an empty untyped space in the text box.void
setViewTopLeft
(TerminalPosition position)
-
Field Details
-
viewTopLeft
-
verticalScrollBar
-
horizontalScrollBar
-
hideScrollBars
private boolean hideScrollBars -
unusedSpaceCharacter
-
-
Constructor Details
-
DefaultTextBoxRenderer
public DefaultTextBoxRenderer()Default constructor
-
-
Method Details
-
setUnusedSpaceCharacter
public void setUnusedSpaceCharacter(char unusedSpaceCharacter) Sets the character to represent an empty untyped space in the text box. This will be an empty space by default but you can override it to anything that isn't double-width.- Parameters:
unusedSpaceCharacter
- Character to draw in unused space of theTextBox
- Throws:
IllegalArgumentException
- If unusedSpaceCharacter is a double-width character
-
getViewTopLeft
- Specified by:
getViewTopLeft
in interfaceTextBox.TextBoxRenderer
-
setViewTopLeft
- Specified by:
setViewTopLeft
in interfaceTextBox.TextBoxRenderer
-
getCursorLocation
- Specified by:
getCursorLocation
in interfaceInteractableRenderer<TextBox>
-
getPreferredSize
Description copied from interface:ComponentRenderer
Given the supplied component, how large does this renderer want the component to be? Notice that this is the responsibility of the renderer and not the component itself, since the component has no idea what its visual representation looks like.- Specified by:
getPreferredSize
in interfaceComponentRenderer<TextBox>
- Parameters:
component
- Component to calculate the preferred size of- Returns:
- The size this renderer would like the component to take up
-
setHideScrollBars
public void setHideScrollBars(boolean hideScrollBars) Controls whether scrollbars should be visible or not when a multi-lineTextBox
has more content than it can draw in the area it was assigned (default: false)- Parameters:
hideScrollBars
- Iftrue
, don't show scrollbars if the multi-line content is bigger than the area
-
drawComponent
Description copied from interface:ComponentRenderer
Using the supplied graphics object, draws the component passed in.- Specified by:
drawComponent
in interfaceComponentRenderer<TextBox>
- Parameters:
graphics
- Graphics object to use for drawingcomponent
- Component to draw
-
drawTextArea
-