|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.threerings.opengl.gui.Component
com.threerings.opengl.gui.TextComponent
com.threerings.opengl.gui.EditableTextComponent
public abstract class EditableTextComponent
Extends TextComponent with mechanisms shared by editable text Components.
| Nested Class Summary | |
|---|---|
protected static class |
EditableTextComponent.CompoundType
Edits that can be compounded together. |
| Field Summary | |
|---|---|
protected int |
_cursp
|
protected KeyMap |
_keymap
|
protected EditableTextComponent.CompoundType |
_lastCompoundType
|
protected int |
_lastUndoId
|
protected String |
_placeholder
Placeholder text, shown when our regular document is empty. |
protected int |
_prefWidth
|
protected Background[] |
_selectionBackgrounds
|
protected int |
_selp
|
protected boolean |
_showCursor
|
protected Rectangle |
_srect
|
protected Document |
_text
|
protected UndoManager |
_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 | |
|---|---|
protected |
EditableTextComponent(GlContext ctx)
For subclasses. |
protected |
EditableTextComponent(GlContext ctx,
String text,
int maxLength)
For subclasses. |
| Method Summary | |
|---|---|
boolean |
acceptsFocus()
Returns whether or not this component accepts the keyboard focus. |
protected abstract void |
clearGlyphs()
Clears out our text textures and other related bits. |
protected abstract void |
createGlyphs()
Create the entity that we use to render our text. |
protected String |
deleteSelectedText()
Deletes the currently selected text. |
boolean |
dispatchEvent(Event event)
Instructs this component to process the supplied event. |
protected void |
gainedFocus()
Called when this text field has gained the focus. |
protected String |
getDisplayText()
This method allows a derived class (specifically PasswordField) to display something other than the actual
contents of the text field. |
Document |
getDocument()
Returns the underlying document used by this text field to maintain its state. |
protected abstract 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 String |
getSelectedText()
Returns the currently selected text. |
Background |
getSelectionBackground()
Returns the selection background configured for this component. |
String |
getText()
Returns the text currently being displayed by this component. |
protected abstract boolean |
hasGlyphs()
Do we have glyphs computed? |
protected char |
insertChar(char c)
Given the provided character, return the character to insert, or 0 to nix the insertion. |
protected void |
layout()
Instructs this component to lay itself out. |
protected void |
lostFocus()
Called when this text field has lost the focus. |
protected int |
nextUndoId(EditableTextComponent.CompoundType compoundType)
Returns an undo operation id. |
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 |
renderCursor(Renderer renderer,
int x,
int y,
int height)
Helper method to render the cursor. |
protected void |
replaceSelectedText(String text,
EditableTextComponent.CompoundType compoundType)
Replaces the currently selected text with the supplied text. |
protected boolean |
selectionContains(int pos)
Determines whether the selection contains the specified position. |
protected boolean |
selectionIsEmpty()
Checks whether the selection is empty. |
protected abstract void |
selectionWasSet()
Update any internal positions after the selection is set. |
protected void |
setCursorPos(int cursorPos)
Updates the cursor position, moving the visible representation as well as the insertion and deletion point. |
void |
setDocument(Document document)
Configures this text field with a custom document. |
void |
setMaxLength(int maxLength)
Configures the maximum length of this text field. |
void |
setPlaceholder(String placeholder)
Set the placeholder text; shown when the field is unfocused and empty. |
void |
setPreferredWidth(int width)
Configures the preferred width of this text field (the preferred height will be calculated from the font). |
protected void |
setSelection(int cursorPos,
int selectPos)
Updates the selection. |
void |
setText(String text)
Configures this text field with the specified text for display and editing. |
protected boolean |
showCursor()
Should we show the cursor? |
protected void |
stateDidChange()
Called when the component's state has changed. |
void |
textInserted(Document document,
int offset,
int length)
Called when text is inserted into a document. |
void |
textRemoved(Document document,
int offset,
int length)
Called when text is removed from a document. |
protected void |
updateFromStyleConfig(int state,
StyleConfig.Original config)
Updates from the resolved style config. |
protected boolean |
usePlaceholder()
Would we want to use our placeholder text if we did not have focus? |
protected String |
validatePaste(String pasted)
Validate the pasted text. |
protected void |
wasAdded()
This method is called when we are added to a hierarchy that is connected to a top-level window (at which point we can rely on having a look and feel and can set ourselves up). |
protected void |
wasRemoved()
This method is called when we are removed from a hierarchy that is connected to a top-level window. |
| Methods inherited from class com.threerings.opengl.gui.TextComponent |
|---|
getEffectColor, getEffectSize, getHorizontalAlignment, getLabelRendererConfig, getLineSpacing, getTextEffect, getTextFactory, getTextFactory, getVerticalAlignment |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected Document _text
protected KeyMap _keymap
protected String _placeholder
protected int _prefWidth
protected boolean _showCursor
protected int _cursp
protected int _selp
protected Background[] _selectionBackgrounds
protected Rectangle _srect
protected UndoManager _undomgr
protected int _lastUndoId
protected EditableTextComponent.CompoundType _lastCompoundType
| Constructor Detail |
|---|
protected EditableTextComponent(GlContext ctx)
protected EditableTextComponent(GlContext ctx,
String text,
int maxLength)
| Method Detail |
|---|
public void setPlaceholder(String placeholder)
public void setText(String text)
setText in class TextComponentpublic String getText()
TextComponent
getText in class TextComponentpublic void setMaxLength(int maxLength)
public void setDocument(Document document)
public Document getDocument()
public void setPreferredWidth(int width)
public Background getSelectionBackground()
public void textInserted(Document document,
int offset,
int length)
Document.Listener
textInserted in interface Document.Listenerdocument - the document into which text was inserted.offset - the offset into the document of the inserted text.length - the length of the inserted text.
public void textRemoved(Document document,
int offset,
int length)
Document.Listener
textRemoved in interface Document.Listenerdocument - the document from which text was removed.offset - the offset into the document of the removed text.length - the length of the removed text.public boolean acceptsFocus()
Component
acceptsFocus in class Componentpublic boolean dispatchEvent(Event event)
Componentsuper.dispatchEvent for events that they did not "consume".
dispatchEvent in class Componentprotected char insertChar(char c)
protected boolean processCommand(int cmd)
protected String validatePaste(String pasted)
protected void updateFromStyleConfig(int state,
StyleConfig.Original config)
Component
updateFromStyleConfig in class TextComponentprotected void wasAdded()
Component
wasAdded in class Componentprotected void wasRemoved()
ComponentComponent.wasAdded(), this is a fine place
to do so.
wasRemoved in class Componentprotected void layout()
Component
layout in class Componentprotected void stateDidChange()
Component
stateDidChange in class Componentprotected void gainedFocus()
protected void lostFocus()
protected boolean showCursor()
protected boolean usePlaceholder()
protected String getDisplayText()
PasswordField) to display something other than the actual
contents of the text field.
protected void renderCursor(Renderer renderer,
int x,
int y,
int height)
protected boolean selectionIsEmpty()
protected boolean selectionContains(int pos)
protected String getSelectedText()
protected String deleteSelectedText()
protected void replaceSelectedText(String text,
EditableTextComponent.CompoundType compoundType)
protected void setCursorPos(int cursorPos)
protected void setSelection(int cursorPos,
int selectPos)
protected void recreateGlyphs()
protected abstract boolean hasGlyphs()
protected abstract void clearGlyphs()
protected abstract void createGlyphs()
protected abstract int getPosition(int mouseX,
int mouseY)
protected abstract void selectionWasSet()
protected int nextUndoId(EditableTextComponent.CompoundType compoundType)
compoundType - identifies the edit type for purposes of compounding events together.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||