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 java.lang.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 theTextBox
does not fit in the available area.
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
hideScrollBars
private ScrollBar
horizontalScrollBar
private java.lang.Character
unusedSpaceCharacter
private ScrollBar
verticalScrollBar
private TerminalPosition
viewTopLeft
-
Constructor Summary
Constructors Constructor Description DefaultTextBoxRenderer()
Default constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
drawComponent(TextGUIGraphics graphics, TextBox component)
Using the supplied graphics object, draws the component passed in.private void
drawTextArea(TextGUIGraphics graphics, TextBox component)
TerminalPosition
getCursorLocation(TextBox component)
TerminalSize
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.TerminalPosition
getViewTopLeft()
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 Detail
-
viewTopLeft
private TerminalPosition viewTopLeft
-
verticalScrollBar
private final ScrollBar verticalScrollBar
-
horizontalScrollBar
private final ScrollBar horizontalScrollBar
-
hideScrollBars
private boolean hideScrollBars
-
unusedSpaceCharacter
private java.lang.Character unusedSpaceCharacter
-
-
Method Detail
-
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:
java.lang.IllegalArgumentException
- If unusedSpaceCharacter is a double-width character
-
getViewTopLeft
public TerminalPosition getViewTopLeft()
- Specified by:
getViewTopLeft
in interfaceTextBox.TextBoxRenderer
-
setViewTopLeft
public void setViewTopLeft(TerminalPosition position)
- Specified by:
setViewTopLeft
in interfaceTextBox.TextBoxRenderer
-
getCursorLocation
public TerminalPosition getCursorLocation(TextBox component)
- Specified by:
getCursorLocation
in interfaceInteractableRenderer<TextBox>
-
getPreferredSize
public TerminalSize getPreferredSize(TextBox component)
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
public void drawComponent(TextGUIGraphics graphics, TextBox component)
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
private void drawTextArea(TextGUIGraphics graphics, TextBox component)
-
-