de.matthiasmann.twl
Class TextWidget

java.lang.Object
  extended by de.matthiasmann.twl.Widget
      extended by de.matthiasmann.twl.TextWidget
Direct Known Subclasses:
Button, EditField.TextRenderer, Label, ListBox.ListBoxLabel, ProgressBar, TableBase.StringCellRenderer

public class TextWidget
extends Widget

Generic text display widget. Supports caching of text for faster rendering.


Nested Class Summary
 
Nested classes/interfaces inherited from class de.matthiasmann.twl.Widget
Widget.OffscreenMouseAdjustments, Widget.RenderOffscreen
 
Field Summary
static AnimationState.StateKey STATE_HOVER
           
static AnimationState.StateKey STATE_TEXT_CHANGED
           
static AnimationState.StateKey STATE_TEXT_SELECTION
           
 
Fields inherited from class de.matthiasmann.twl.Widget
STATE_DISABLED, STATE_HAS_FOCUSED_CHILD, STATE_HAS_OPEN_POPUPS, STATE_KEYBOARD_FOCUS
 
Constructor Summary
TextWidget()
           
TextWidget(AnimationState animState)
          Creates a TextWidget with a shared animation state
TextWidget(AnimationState animState, boolean inherit)
          Creates a TextWidget with a shared or inherited animation state
 
Method Summary
protected  void applyTheme(ThemeInfo themeInfo)
          Apply the given theme.
protected  void applyThemeTextWidget(ThemeInfo themeInfo)
           
 int computeRelativeCursorPositionX(int charIndex)
           
 int computeRelativeCursorPositionX(int startIndex, int charIndex)
           
 int computeTextHeight()
           
 int computeTextWidth()
           
protected  int computeTextX()
           
protected  int computeTextY()
           
 void destroy()
          Clean up GL resources.
 Alignment getAlignment()
           
protected  java.lang.CharSequence getCharSequence()
           
 Font getFont()
           
 int getNumTextLines()
           
 int getPreferredInnerHeight()
          Computes the preferred inner height (the size of the widget without the border) The default implementation uses the current position of the children.
 int getPreferredInnerWidth()
          Computes the preferred inner width (the size of the widget without the border) The default implementation uses the current position of the children.
protected  void handleMouseHover(Event evt)
           
 boolean hasText()
           
 boolean isCache()
           
 boolean isMultilineText()
           
protected  void paintLabelText(AnimationState animState)
           
protected  void paintTextAt(AnimationState animState, int x, int y)
           
protected  void paintWidget(GUI gui)
          Called by Widget.paint(de.matthiasmann.twl.GUI) after painting the background and before painting all children.
protected  void paintWithSelection(AnimationState animState, int start, int end)
           
protected  void paintWithSelection(AnimationState animState, int start, int end, int lineStart, int lineEnd, int y)
           
 void setAlignment(Alignment alignment)
           
 void setCache(boolean cache)
           
protected  void setCharSequence(java.lang.CharSequence text)
          Sets a new text to be displayed.
 void setFont(Font font)
           
 
Methods inherited from class de.matthiasmann.twl.Widget
add, addActionMapping, addPropertyChangeListener, addPropertyChangeListener, adjustSize, afterAddToGUI, allChildrenRemoved, applyThemeBackground, applyThemeBorder, applyThemeInputMap, applyThemeMaxSize, applyThemeMinSize, applyThemeMouseCursor, applyThemeOffscreenExtra, applyThemeOverlay, applyThemeTooltip, beforeRemoveFromGUI, borderChanged, canAcceptKeyboardFocus, childAdded, childInvalidateLayout, childRemoved, childVisibilityChanged, computeSize, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, focusFirstChild, focusLastChild, focusNextChild, focusPrevChild, getActionMap, getAnimationState, getBackground, getBorderBottom, getBorderHorizontal, getBorderLeft, getBorderRight, getBorderTop, getBorderVertical, getBottom, getChild, getChildAt, getChildIndex, getGUI, getHeight, getInnerBottom, getInnerHeight, getInnerRight, getInnerWidth, getInnerX, getInnerY, getInputMap, getKeyboardFocusOrder, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getMouseCursor, getMouseCursor, getNumChildren, getOffscreenExtraBottom, getOffscreenExtraLeft, getOffscreenExtraRight, getOffscreenExtraTop, getOrCreateActionMap, getOverlay, getParent, getPreferredHeight, getPreferredWidth, getRenderOffscreen, getRight, getRootWidget, getTheme, getThemePath, getThemeTooltipContent, getTintAnimator, getTooltipContent, getTooltipContentAt, getWidgetAt, getWidth, getX, getY, giveupKeyboardFocus, handleEvent, handleKeyStrokeAction, hasKeyboardFocus, hasOpenPopups, hasSharedAnimationState, insertChild, invalidateLayout, invalidateLayoutLocally, isAbsoluteTheme, isClip, isDepthFocusTraversal, isEnabled, isFocusKeyEnabled, isInside, isLocallyEnabled, isMouseInside, isVisible, keyboardFocusChildChanged, keyboardFocusGained, keyboardFocusGained, keyboardFocusLost, layout, layoutChildFullInnerArea, layoutChildrenFullInnerArea, moveChild, paint, paintBackground, paintChild, paintChildren, paintDragOverlay, paintOverlay, positionChanged, reapplyTheme, removeAllChildren, removeChild, removeChild, removePropertyChangeListener, removePropertyChangeListener, requestKeyboardFocus, requestKeyboardFocus, resetTooltip, setActionMap, setBackground, setBorderSize, setBorderSize, setBorderSize, setBorderSize, setCanAcceptKeyboardFocus, setClip, setDepthFocusTraversal, setEnabled, setFocusKeyEnabled, setInnerSize, setInputMap, setMaxSize, setMinSize, setMouseCursor, setOffscreenExtra, setOffscreenExtra, setOverlay, setPosition, setRenderOffscreen, setSize, setTheme, setTintAnimator, setTooltipContent, setVisible, sizeChanged, updateTintAnimation, updateTooltip, validateLayout, widgetDisabled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STATE_HOVER

public static final AnimationState.StateKey STATE_HOVER

STATE_TEXT_CHANGED

public static final AnimationState.StateKey STATE_TEXT_CHANGED

STATE_TEXT_SELECTION

public static final AnimationState.StateKey STATE_TEXT_SELECTION
Constructor Detail

TextWidget

public TextWidget()

TextWidget

public TextWidget(AnimationState animState)
Creates a TextWidget with a shared animation state

Parameters:
animState - the animation state to share, can be null

TextWidget

public TextWidget(AnimationState animState,
                  boolean inherit)
Creates a TextWidget with a shared or inherited animation state

Parameters:
animState - the animation state to share or inherit, can be null
inherit - true if the animation state should be inherited false for sharing
Method Detail

getFont

public Font getFont()

setFont

public void setFont(Font font)

setCharSequence

protected void setCharSequence(java.lang.CharSequence text)
Sets a new text to be displayed. If CharSequence changes it's content this function must be called again or correct rendering can't be guranteed.

Parameters:
text - The CharSequence to display

getCharSequence

protected java.lang.CharSequence getCharSequence()

hasText

public boolean hasText()

isMultilineText

public boolean isMultilineText()

getNumTextLines

public int getNumTextLines()

getAlignment

public Alignment getAlignment()

setAlignment

public void setAlignment(Alignment alignment)

isCache

public boolean isCache()

setCache

public void setCache(boolean cache)

applyThemeTextWidget

protected void applyThemeTextWidget(ThemeInfo themeInfo)

applyTheme

protected void applyTheme(ThemeInfo themeInfo)
Description copied from class: Widget
Apply the given theme. This method also calls invalidateLayout()

Overrides:
applyTheme in class Widget
Parameters:
themeInfo - The theme info for this widget

destroy

public void destroy()
Description copied from class: Widget
Clean up GL resources. When overwritten then super method must be called.

Overrides:
destroy in class Widget

computeTextX

protected int computeTextX()

computeTextY

protected int computeTextY()

paintWidget

protected void paintWidget(GUI gui)
Description copied from class: Widget
Called by Widget.paint(de.matthiasmann.twl.GUI) after painting the background and before painting all children.

This should be overwritten instead of paint if normal themeable painting is desired by the subclass.

The default implementation does nothing.

Overrides:
paintWidget in class Widget
Parameters:
gui - the GUI object - it's the same as getGUI()

paintLabelText

protected void paintLabelText(AnimationState animState)

paintTextAt

protected void paintTextAt(AnimationState animState,
                           int x,
                           int y)

paintWithSelection

protected void paintWithSelection(AnimationState animState,
                                  int start,
                                  int end)

paintWithSelection

protected void paintWithSelection(AnimationState animState,
                                  int start,
                                  int end,
                                  int lineStart,
                                  int lineEnd,
                                  int y)

getPreferredInnerWidth

public int getPreferredInnerWidth()
Description copied from class: Widget
Computes the preferred inner width (the size of the widget without the border) The default implementation uses the current position of the children. It is highly recommended to override this method as the default implementation lead to unstable layouts. The default behavior might change in the future to provide a better default behavior.

Overrides:
getPreferredInnerWidth in class Widget
Returns:
the preferred inner width

getPreferredInnerHeight

public int getPreferredInnerHeight()
Description copied from class: Widget
Computes the preferred inner height (the size of the widget without the border) The default implementation uses the current position of the children. It is highly recommended to override this method as the default implementation lead to unstable layouts. The default behavior might change in the future to provide a better default behavior.

Overrides:
getPreferredInnerHeight in class Widget
Returns:
the preferred inner height

computeRelativeCursorPositionX

public int computeRelativeCursorPositionX(int charIndex)

computeRelativeCursorPositionX

public int computeRelativeCursorPositionX(int startIndex,
                                          int charIndex)

computeTextWidth

public int computeTextWidth()

computeTextHeight

public int computeTextHeight()

handleMouseHover

protected void handleMouseHover(Event evt)