com.threerings.opengl.gui
Class TextField

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.TextField
All Implemented Interfaces:
ConfigUpdateListener<ManagedConfig>, Document.Listener, EditCommands
Direct Known Subclasses:
PasswordField

public class TextField
extends EditableTextComponent

Displays and allows for the editing of a single line of text.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.threerings.opengl.gui.EditableTextComponent
EditableTextComponent.CompoundType
 
Field Summary
protected  int _cursx
           
protected  Text _glyphs
          Our text glyphs.
protected  int _selx
           
protected  int _txoff
           
 
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
TextField(GlContext ctx)
          Creates a blank text field.
TextField(GlContext ctx, int maxLength)
          Creates a blank text field with maximum input length.
TextField(GlContext ctx, String text)
          Creates a text field with the specified starting text.
TextField(GlContext ctx, String text, int maxLength)
          Creates a text field with the specified starting text and max length.
 
Method Summary
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 renderComponent(Renderer renderer)
          Renders any custom bits for this component.
protected  void selectionWasSet()
          Update any internal positions after the selection is set.
protected  String validatePaste(String pasted)
          Validate the pasted text.
 
Methods inherited from class com.threerings.opengl.gui.EditableTextComponent
acceptsFocus, deleteSelectedText, dispatchEvent, gainedFocus, getDisplayText, getDocument, getSelectedText, getSelectionBackground, getText, insertChar, layout, lostFocus, nextUndoId, recreateGlyphs, renderCursor, replaceSelectedText, selectionContains, selectionIsEmpty, setCursorPos, setDocument, setMaxLength, setPlaceholder, setPreferredWidth, setSelection, setText, showCursor, stateDidChange, textInserted, textRemoved, updateFromStyleConfig, usePlaceholder, 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 text glyphs.


_cursx

protected int _cursx

_selx

protected int _selx

_txoff

protected int _txoff
Constructor Detail

TextField

public TextField(GlContext ctx)
Creates a blank text field.


TextField

public TextField(GlContext ctx,
                 int maxLength)
Creates a blank text field with maximum input length. The maximum input length is controlled by a LengthLimitedDocument, changing the document will remove the length control.


TextField

public TextField(GlContext ctx,
                 String text)
Creates a text field with the specified starting text.


TextField

public TextField(GlContext ctx,
                 String text,
                 int maxLength)
Creates a text field with the specified starting text and max length. The maximum input length is controlled by a LengthLimitedDocument, changing the document will remove the length control.

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

validatePaste

protected String validatePaste(String pasted)
Description copied from class: EditableTextComponent
Validate the pasted text. Return null to reject the paste event altogether, or the pasted text may be modified...

Overrides:
validatePaste 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