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 booleanprivate final ScrollBarprivate Characterprivate final ScrollBarprivate TerminalPosition -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddrawComponent(TextGUIGraphics graphics, TextBox component) Using the supplied graphics object, draws the component passed in.private voiddrawTextArea(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.voidsetHideScrollBars(boolean hideScrollBars) Controls whether scrollbars should be visible or not when a multi-lineTextBoxhas more content than it can draw in the area it was assigned (default: false)voidsetUnusedSpaceCharacter(char unusedSpaceCharacter) Sets the character to represent an empty untyped space in the text box.voidsetViewTopLeft(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:
getViewTopLeftin interfaceTextBox.TextBoxRenderer
-
setViewTopLeft
- Specified by:
setViewTopLeftin interfaceTextBox.TextBoxRenderer
-
getCursorLocation
- Specified by:
getCursorLocationin interfaceInteractableRenderer<TextBox>
-
getPreferredSize
Description copied from interface:ComponentRendererGiven 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:
getPreferredSizein 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-lineTextBoxhas 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:ComponentRendererUsing the supplied graphics object, draws the component passed in.- Specified by:
drawComponentin interfaceComponentRenderer<TextBox>- Parameters:
graphics- Graphics object to use for drawingcomponent- Component to draw
-
drawTextArea
-