com.threerings.opengl.gui
Class TextEditor

java.lang.Object
  extended by com.threerings.opengl.gui.Component
      extended by com.threerings.opengl.gui.TextComponent
          extended by com.threerings.opengl.gui.EditableTextComponent
              extended by com.threerings.opengl.gui.TextEditor
All Implemented Interfaces:
ConfigUpdateListener<ManagedConfig>, Document.Listener, EditCommands

public class TextEditor
extends EditableTextComponent

A multiline text-editing widget.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.threerings.opengl.gui.EditableTextComponent
EditableTextComponent.CompoundType
 
Field Summary
protected  Point _curs
          A mutable Point containing the inset coordiantes of the cursor.
protected  Text[] _glyphs
          Our lines of text.
protected  int _lines
          The number of lines of glyphs we have, or 1.
protected  Point _sel
          A mutable Point containing the inset coordinates of the end of selection.
 
Fields inherited from class com.threerings.opengl.gui.EditableTextComponent
_cursp, _keymap, _lastCompoundType, _lastUndoId, _placeholder, _prefWidth, _selectionBackgrounds, _selp, _showCursor, _srect, _text, _undomgr
 
Fields inherited from class com.threerings.opengl.gui.TextComponent
_effcols, _effsizes, _haligns, _lineSpacings, _teffects, _textfacts, _valigns
 
Fields inherited from class com.threerings.opengl.gui.Component
_alpha, _backgrounds, _borders, _colors, _ctx, _cursor, _enabled, _height, _hover, _hoverable, _insets, _listeners, _parent, _preferredSize, _properties, _rect, _styleConfigs, _tipmouse, _tiptext, _tooltipStyle, _transferHandler, _valid, _visible, _width, _x, _y, DEFAULT, DISABLED, HOVER, STATE_COUNT, STATE_PCLASSES
 
Fields inherited from interface com.threerings.opengl.gui.text.EditCommands
ACTION, BACKSPACE, CLEAR, COPY, CURSOR_DOWN, CURSOR_LEFT, CURSOR_RIGHT, CURSOR_UP, CUT, DELETE, END_OF_LINE, PASTE, REDO, RELEASE_FOCUS, START_OF_LINE, UNDO, WORD_LEFT, WORD_RIGHT
 
Constructor Summary
TextEditor(GlContext ctx)
          Constructor.
TextEditor(GlContext ctx, String text)
          Constructor.
 
Method Summary
protected  void calculatePosition(int pos, Point loc)
          Calculate the inset coordinates of the specified position, populating the specified point.
protected  void clearGlyphs()
          Clears out our text textures and other related bits.
protected  Dimension computePreferredSize(int whint, int hhint)
          Computes and returns a preferred size for this component.
protected  void createGlyphs()
          Create the entity that we use to render our text.
protected  String getDefaultStyleConfig()
          Returns the name of the default config to be used for all instances of this component.
protected  int getPosition(int mouseX, int mouseY)
          Get the position in our document, given the mouse local mouse coordinates that have already had the insets taken into account.
protected  boolean hasGlyphs()
          Do we have glyphs computed?
protected  boolean processCommand(int cmd)
          Process the specified edit command, returning true if it was handled.
protected  void recreateGlyphs()
          Recreates the entity that we use to render our text.
protected  void renderComponent(Renderer renderer)
          Renders any custom bits for this component.
protected  void selectionWasSet()
          Update any internal positions after the selection is set.
 
Methods inherited from class com.threerings.opengl.gui.EditableTextComponent
acceptsFocus, deleteSelectedText, dispatchEvent, gainedFocus, getDisplayText, getDocument, getSelectedText, getSelectionBackground, getText, insertChar, layout, lostFocus, nextUndoId, renderCursor, replaceSelectedText, selectionContains, selectionIsEmpty, setCursorPos, setDocument, setMaxLength, setPlaceholder, setPreferredWidth, setSelection, setText, showCursor, stateDidChange, textInserted, textRemoved, updateFromStyleConfig, usePlaceholder, validatePaste, wasAdded, wasRemoved
 
Methods inherited from class com.threerings.opengl.gui.TextComponent
getEffectColor, getEffectSize, getHorizontalAlignment, getLabelRendererConfig, getLineSpacing, getTextEffect, getTextFactory, getTextFactory, getVerticalAlignment
 
Methods inherited from class com.threerings.opengl.gui.Component
addListener, boundsToString, changeCursor, configUpdated, contains, createDefaultTooltipComponent, createDefaultTooltipComponent, createTooltipComponent, emitEvent, getAbsoluteX, getAbsoluteY, getAlpha, getBackground, getBorder, getBounds, getColor, getContext, getCursor, getFallbackState, getFirstDescendantFocus, getFocusTarget, getHeight, getHitComponent, getInsets, getLastDescendantFocus, getNextFocus, getParent, getPreferredSize, getPreviousFocus, getProperty, getState, getStateCount, getStatePseudoClass, getStyleConfigs, getTooltipText, getTooltipTimeout, getTooltipWindowStyle, getTransferHandler, getWidth, getWindow, getX, getY, hasFocus, intersectScissor, invalidate, isAdded, isEnabled, isHoverable, isShowing, isTooltipRelativeToMouse, isValid, isVisible, removeAllListeners, removeAllListeners, removeListener, render, renderBackground, renderBorder, requestFocus, scrollRectToVisible, scrollRectToVisible, setAlpha, setBackground, setBounds, setCursor, setEnabled, setHoverable, setLocation, setParent, setPreferredSize, setPreferredSize, setProperty, setSize, setStyleConfig, setStyleConfig, setStyleConfig, setStyleConfigs, setTooltipRelativeToMouse, setTooltipText, setTransferHandler, setVisible, updateCursor, updateFromStyleConfig, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_glyphs

protected Text[] _glyphs
Our lines of text.


_lines

protected int _lines
The number of lines of glyphs we have, or 1.


_curs

protected Point _curs
A mutable Point containing the inset coordiantes of the cursor.


_sel

protected Point _sel
A mutable Point containing the inset coordinates of the end of selection.

Constructor Detail

TextEditor

public TextEditor(GlContext ctx)
Constructor.


TextEditor

public TextEditor(GlContext ctx,
                  String text)
Constructor.

Method Detail

getDefaultStyleConfig

protected String getDefaultStyleConfig()
Description copied from class: Component
Returns the name of the default config to be used for all instances of this component. Derived classes will likely want to override this method and set up a default config for their type of component.

Overrides:
getDefaultStyleConfig in class Component

renderComponent

protected void renderComponent(Renderer renderer)
Description copied from class: Component
Renders any custom bits for this component. This is called with the graphics context translated to (0, 0) relative to this component.

Overrides:
renderComponent in class Component

computePreferredSize

protected Dimension computePreferredSize(int whint,
                                         int hhint)
Description copied from class: Component
Computes and returns a preferred size for this component. This method is called if no overriding preferred size has been supplied.

Overrides:
computePreferredSize in class Component
Returns:
the computed preferred size of this component in a newly created Dimension instance which will be adopted (and modified) by the caller.

processCommand

protected boolean processCommand(int cmd)
Description copied from class: EditableTextComponent
Process the specified edit command, returning true if it was handled.

Overrides:
processCommand in class EditableTextComponent

recreateGlyphs

protected void recreateGlyphs()
Description copied from class: EditableTextComponent
Recreates the entity that we use to render our text.

Overrides:
recreateGlyphs in class EditableTextComponent

hasGlyphs

protected boolean hasGlyphs()
Description copied from class: EditableTextComponent
Do we have glyphs computed?

Specified by:
hasGlyphs in class EditableTextComponent

createGlyphs

protected void createGlyphs()
Description copied from class: EditableTextComponent
Create the entity that we use to render our text.

Specified by:
createGlyphs in class EditableTextComponent

clearGlyphs

protected void clearGlyphs()
Description copied from class: EditableTextComponent
Clears out our text textures and other related bits.

Specified by:
clearGlyphs in class EditableTextComponent

getPosition

protected int getPosition(int mouseX,
                          int mouseY)
Description copied from class: EditableTextComponent
Get the position in our document, given the mouse local mouse coordinates that have already had the insets taken into account.

Specified by:
getPosition in class EditableTextComponent

selectionWasSet

protected void selectionWasSet()
Description copied from class: EditableTextComponent
Update any internal positions after the selection is set.

Specified by:
selectionWasSet in class EditableTextComponent

calculatePosition

protected void calculatePosition(int pos,
                                 Point loc)
Calculate the inset coordinates of the specified position, populating the specified point.