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 Details

    • viewTopLeft

      private TerminalPosition viewTopLeft
    • verticalScrollBar

      private final ScrollBar verticalScrollBar
    • horizontalScrollBar

      private final ScrollBar horizontalScrollBar
    • hideScrollBars

      private boolean hideScrollBars
    • unusedSpaceCharacter

      private Character 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 the TextBox
      Throws:
      IllegalArgumentException - If unusedSpaceCharacter is a double-width character
    • getViewTopLeft

      public TerminalPosition getViewTopLeft()
      Specified by:
      getViewTopLeft in interface TextBox.TextBoxRenderer
    • setViewTopLeft

      public void setViewTopLeft(TerminalPosition position)
      Specified by:
      setViewTopLeft in interface TextBox.TextBoxRenderer
    • getCursorLocation

      public TerminalPosition getCursorLocation(TextBox component)
      Specified by:
      getCursorLocation in interface InteractableRenderer<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 interface ComponentRenderer<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-line TextBox has more content than it can draw in the area it was assigned (default: false)
      Parameters:
      hideScrollBars - If true, 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 interface ComponentRenderer<TextBox>
      Parameters:
      graphics - Graphics object to use for drawing
      component - Component to draw
    • drawTextArea

      private void drawTextArea(TextGUIGraphics graphics, TextBox component)