|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectde.matthiasmann.twl.Widget
public class Widget
Root of the TWL class hierarchy.
When subclassing the following methods should be overridden to ensure correct layout behavior:
The following methods are events and can be overridden when needed:
afterAddToGUI(de.matthiasmann.twl.GUI)allChildrenRemoved()beforeRemoveFromGUI(de.matthiasmann.twl.GUI)borderChanged()childAdded(de.matthiasmann.twl.Widget)childHidden(de.matthiasmann.twl.Widget)childRemoved(de.matthiasmann.twl.Widget)childVisibilityChanged(de.matthiasmann.twl.Widget)keyboardFocusChildChanged(de.matthiasmann.twl.Widget)keyboardFocusGained()keyboardFocusGained(de.matthiasmann.twl.FocusGainedCause, de.matthiasmann.twl.Widget)keyboardFocusLost()positionChanged()sizeChanged()widgetDisabled()NOTE: The only thread safe methods of TWL are:
| Nested Class Summary | |
|---|---|
static interface |
Widget.OffscreenMouseAdjustments
|
static interface |
Widget.RenderOffscreen
When this interface is installed in a Widget then the widget tries to render into an offscreen surface. |
| Field Summary | |
|---|---|
static AnimationState.StateKey |
STATE_DISABLED
|
static AnimationState.StateKey |
STATE_HAS_FOCUSED_CHILD
|
static AnimationState.StateKey |
STATE_HAS_OPEN_POPUPS
|
static AnimationState.StateKey |
STATE_KEYBOARD_FOCUS
|
| Constructor Summary | |
|---|---|
Widget()
Creates a Widget with it's own animation state |
|
Widget(AnimationState animState)
Creates a Widget with a shared animation state |
|
Widget(AnimationState animState,
boolean inherit)
Creates a Widget with a shared or inherited animation state |
|
| Method Summary | |
|---|---|
void |
add(Widget child)
Adds a new child at the end of this widget. |
protected void |
addActionMapping(java.lang.String action,
java.lang.String methodName,
java.lang.Object... params)
Installs an action mapping for the given action in the current action map. |
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Add a PropertyChangeListener for all properties. |
void |
addPropertyChangeListener(java.lang.String propertyName,
java.beans.PropertyChangeListener listener)
Add a PropertyChangeListener for a specific property. |
void |
adjustSize()
Auto adjust the size of this widget based on it's preferred size. |
protected void |
afterAddToGUI(GUI gui)
Called after this widget has been added to a GUI tree. |
protected void |
allChildrenRemoved()
All children have been removed. |
protected void |
applyTheme(ThemeInfo themeInfo)
Apply the given theme. |
protected void |
applyThemeBackground(ThemeInfo themeInfo)
|
protected void |
applyThemeBorder(ThemeInfo themeInfo)
|
protected void |
applyThemeInputMap(ThemeInfo themeInfo)
|
protected void |
applyThemeMaxSize(ThemeInfo themeInfo)
|
protected void |
applyThemeMinSize(ThemeInfo themeInfo)
|
protected void |
applyThemeMouseCursor(ThemeInfo themeInfo)
|
protected void |
applyThemeOffscreenExtra(ThemeInfo themeInfo)
|
protected void |
applyThemeOverlay(ThemeInfo themeInfo)
|
protected void |
applyThemeTooltip(ThemeInfo themeInfo)
|
protected void |
beforeRemoveFromGUI(GUI gui)
Called when this widget is removed from the GUI tree. |
protected void |
borderChanged()
Called when the border size has changed. |
boolean |
canAcceptKeyboardFocus()
|
protected void |
childAdded(Widget child)
A new child has been added. |
protected void |
childInvalidateLayout(Widget child)
Called when the layout of a child has been invalidated. |
protected void |
childRemoved(Widget exChild)
A child has been removed. |
protected void |
childVisibilityChanged(Widget child)
Called when the visibility state of a child was changed. |
static int |
computeSize(int min,
int preferred,
int max)
A helper method to compute the size of a widget based on min, max and preferred size. |
void |
destroy()
Clean up GL resources. |
protected void |
firePropertyChange(java.beans.PropertyChangeEvent evt)
Fire an existing PropertyChangeEvent to any registered listeners. |
protected void |
firePropertyChange(java.lang.String propertyName,
boolean oldValue,
boolean newValue)
Report a bound property update to any registered listeners. |
protected void |
firePropertyChange(java.lang.String propertyName,
int oldValue,
int newValue)
Report a bound property update to any registered listeners. |
protected void |
firePropertyChange(java.lang.String propertyName,
java.lang.Object oldValue,
java.lang.Object newValue)
Report a bound property update to any registered listeners. |
boolean |
focusFirstChild()
|
boolean |
focusLastChild()
|
boolean |
focusNextChild()
|
boolean |
focusPrevChild()
|
ActionMap |
getActionMap()
Returns the current action map. |
AnimationState |
getAnimationState()
Returns the animation state object. |
Image |
getBackground()
Returns the current background image or null. |
short |
getBorderBottom()
|
int |
getBorderHorizontal()
|
short |
getBorderLeft()
|
short |
getBorderRight()
|
short |
getBorderTop()
|
int |
getBorderVertical()
|
int |
getBottom()
Returns the bottom Y coordinate of this widget |
Widget |
getChild(int index)
Returns the child at the given index |
protected Widget |
getChildAt(int x,
int y)
Returns the visible child widget which is at the specified coordinate. |
int |
getChildIndex(Widget child)
Returns the index of the specified child in this widget. |
GUI |
getGUI()
Returns the GUI root of this widget tree if it has one. |
int |
getHeight()
Returns the height of this widget This property can be bound and fires PropertyChangeEvent |
int |
getInnerBottom()
Returns the bottom Y coordinate while taking the bottom border into account. |
int |
getInnerHeight()
The inner height takes the top and bottom border into account. |
int |
getInnerRight()
Returns the right X coordinate while taking the right border into account. |
int |
getInnerWidth()
The inner width takes the left and right border into account. |
int |
getInnerX()
The inner X position takes the left border into account |
int |
getInnerY()
The inner Y position takes the top border into account |
InputMap |
getInputMap()
Returns the current input map. |
protected java.util.List<Widget> |
getKeyboardFocusOrder()
Returns all children of this widget in their focus travel order. |
int |
getMaxHeight()
Returns the maximum height of the widget. |
int |
getMaxWidth()
Returns the maximum width of the widget. |
int |
getMinHeight()
Returns the minimum height of the widget. |
int |
getMinWidth()
Returns the minimum width of the widget. |
MouseCursor |
getMouseCursor()
|
MouseCursor |
getMouseCursor(Event evt)
Returns the mouse cursor which should be used for the given mouse coordinates and modifiers. |
int |
getNumChildren()
Returns the number of children in this widget. |
short |
getOffscreenExtraBottom()
|
short |
getOffscreenExtraLeft()
|
short |
getOffscreenExtraRight()
|
short |
getOffscreenExtraTop()
|
ActionMap |
getOrCreateActionMap()
Returns the current action map. |
Image |
getOverlay()
Returns the current overlay image or null. |
Widget |
getParent()
Returns the parent of this widget or null if it is the tree root. |
int |
getPreferredHeight()
Returns the preferred height. |
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. |
int |
getPreferredWidth()
Returns the preferred width based on it's children and preferred inner width. |
Widget.RenderOffscreen |
getRenderOffscreen()
Returns the currently active offscreen rendering delegate or null if none was set |
int |
getRight()
Returns the right X coordinate of this widget |
Widget |
getRootWidget()
Returns the root of this widget tree. |
java.lang.String |
getTheme()
Returns the current theme name of this widget. |
java.lang.String |
getThemePath()
Returns this widget's theme path by concatenating the theme names from all parents separated by '.'. |
protected java.lang.Object |
getThemeTooltipContent()
|
TintAnimator |
getTintAnimator()
Returns the current tine animation object or null if none was set |
java.lang.Object |
getTooltipContent()
Returns the currently set tooltip content. |
protected java.lang.Object |
getTooltipContentAt(int mouseX,
int mouseY)
Automatic tooltip support. |
Widget |
getWidgetAt(int x,
int y)
Returns the visible widget at the specified location. |
int |
getWidth()
Returns the width of this widget This property can be bound and fires PropertyChangeEvent |
int |
getX()
Returns the absolute X coordinate of widget in it's tree This property can be bound and fires PropertyChangeEvent |
int |
getY()
Returns the absolute Y coordinate of widget in it's tree This property can be bound and fires PropertyChangeEvent |
void |
giveupKeyboardFocus()
If this widget currently has the keyboard focus, then the keyboard focus is removed. |
protected boolean |
handleEvent(Event evt)
Called when an event occurred that this widget could be interested in. |
protected boolean |
handleKeyStrokeAction(java.lang.String action,
Event event)
Called when a key stroke was found in the inputMap. |
boolean |
hasKeyboardFocus()
Checks if this widget has the keyboard focus |
boolean |
hasOpenPopups()
Checks whether this widget or atleast one of it's children owns an open popup. |
boolean |
hasSharedAnimationState()
Returns true if the animation state of this widget is shared with another widget. |
void |
insertChild(Widget child,
int index)
Inserts a new child into this widget. |
void |
invalidateLayout()
Called when something has changed which affected the layout of this widget. |
protected void |
invalidateLayoutLocally()
Invalidates only the layout of this widget. |
static boolean |
isAbsoluteTheme(java.lang.String theme)
Checks if the given theme name is absolute or relative to it's parent. |
boolean |
isClip()
Returns true if paint() is clipped to this widget. |
boolean |
isDepthFocusTraversal()
|
boolean |
isEnabled()
Checks if this widget and all it's parents are enabled. |
boolean |
isFocusKeyEnabled()
Returns if this widget will handle the FOCUS_KEY. |
boolean |
isInside(int x,
int y)
Checks if the given absolute (to this widget's tree) coordinates are inside this widget. |
boolean |
isLocallyEnabled()
Returns the local enabled state of this widget. |
protected boolean |
isMouseInside(Event evt)
Checks whether the mouse is inside the widget or not. |
boolean |
isVisible()
Returns the current visibility flag of this widget. |
protected void |
keyboardFocusChildChanged(Widget child)
The current keyboard focus child has changed. |
protected void |
keyboardFocusGained()
Called when this widget has gained the keyboard focus. |
protected void |
keyboardFocusGained(FocusGainedCause cause,
Widget previousWidget)
Called when this widget has gained the keyboard focus. |
protected void |
keyboardFocusLost()
Called when this widget has lost the keyboard focus. |
protected void |
layout()
Called when the layoutInvalid flag is set. |
protected void |
layoutChildFullInnerArea(Widget child)
Sets size and position of a child widget so that it consumes the complete inner area. |
protected void |
layoutChildrenFullInnerArea()
Sets size and position of all child widgets so that they all consumes the complete inner area. |
protected void |
moveChild(int from,
int to)
Moves the child at index from to index to. |
protected void |
paint(GUI gui)
Paints this widget and it's children. |
protected void |
paintBackground(GUI gui)
Paint the background image of this widget. |
protected void |
paintChild(GUI gui,
Widget child)
Paints a specified child. |
protected void |
paintChildren(GUI gui)
Paints all children in index order. |
protected void |
paintDragOverlay(GUI gui,
int mouseX,
int mouseY,
int modifier)
Called after all other widgets have been rendered when a drag operation is in progress. |
protected void |
paintOverlay(GUI gui)
Paints the overlay image of this widget. |
protected void |
paintWidget(GUI gui)
Called by paint(de.matthiasmann.twl.GUI) after painting the
background and before painting all children. |
protected void |
positionChanged()
Called when the position of this widget was changed. |
void |
reapplyTheme()
If the widget changed some internal state which may require different theme information then this function can be used to reapply the current theme. |
void |
removeAllChildren()
Removes all children of this widget. |
Widget |
removeChild(int index)
Removes the specified child from this widget. |
boolean |
removeChild(Widget child)
Removes the specified child from this widget. |
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Remove a PropertyChangeListener. |
void |
removePropertyChangeListener(java.lang.String propertyName,
java.beans.PropertyChangeListener listener)
Remove a PropertyChangeListener. |
boolean |
requestKeyboardFocus()
Requests that the keyboard focus is transfered to this widget. |
protected boolean |
requestKeyboardFocus(Widget child)
A child requests keyboard focus. |
protected void |
resetTooltip()
If this widget currently has an open tooltip then this tooltip is reset and the tooltip timer is restarted. |
void |
setActionMap(ActionMap actionMap)
Installs an action map for this widget. |
void |
setBackground(Image background)
Sets the background image that should be drawn before drawing this widget |
boolean |
setBorderSize(Border border)
Sets the border width for this widget. |
boolean |
setBorderSize(int border)
Sets a uniform border for this widget. |
boolean |
setBorderSize(int horizontal,
int vertical)
Sets a border for this widget. |
boolean |
setBorderSize(int top,
int left,
int bottom,
int right)
Sets a border for this widget. |
void |
setCanAcceptKeyboardFocus(boolean canAcceptKeyboardFocus)
|
void |
setClip(boolean clip)
Sets whether paint() must be clipped to this Widget or not. |
void |
setDepthFocusTraversal(boolean depthFocusTraversal)
|
void |
setEnabled(boolean enabled)
Sets the local enabled state of that widget. |
void |
setFocusKeyEnabled(boolean focusKeyEnabled)
Controls the handling of the FOCUS_KEY. |
boolean |
setInnerSize(int width,
int height)
Changes the inner size of this widget. |
void |
setInputMap(InputMap inputMap)
Sets the input map for key strokes. |
void |
setMaxSize(int width,
int height)
Sets the maximum size of the widget. |
void |
setMinSize(int width,
int height)
Sets the minimum size of the widget. |
void |
setMouseCursor(MouseCursor mouseCursor)
|
void |
setOffscreenExtra(Border offscreenExtra)
Sets the offscreen rendering extra area for this widget. |
void |
setOffscreenExtra(int top,
int left,
int bottom,
int right)
Sets the offscreen rendering extra area for this widget. |
void |
setOverlay(Image overlay)
Sets the overlay image that should be drawn after drawing the children |
boolean |
setPosition(int x,
int y)
Changes the position of this widget. |
void |
setRenderOffscreen(Widget.RenderOffscreen renderOffscreen)
Sets set offscreen rendering delegate. |
boolean |
setSize(int width,
int height)
Changes the size of this widget. |
void |
setTheme(java.lang.String theme)
Changes the theme name of this widget - DOES NOT call reapplyTheme() |
void |
setTintAnimator(TintAnimator tintAnimator)
Sets the tint animation object. |
void |
setTooltipContent(java.lang.Object tooltipContent)
Changes the tooltip context. |
void |
setVisible(boolean visible)
Changes the visibility flag of this widget. |
protected void |
sizeChanged()
Called when the size of this widget has changed. |
protected void |
updateTintAnimation()
Updates the tint animation when a fade is active. |
protected void |
updateTooltip()
Called by setTooltipContent and applyThemeTooltip. |
void |
validateLayout()
Calls layout() if the layout is marked invalid. |
protected void |
widgetDisabled()
This method is called when this widget has been disabled, either directly or one of it's parents. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final AnimationState.StateKey STATE_KEYBOARD_FOCUS
public static final AnimationState.StateKey STATE_HAS_OPEN_POPUPS
public static final AnimationState.StateKey STATE_HAS_FOCUSED_CHILD
public static final AnimationState.StateKey STATE_DISABLED
| Constructor Detail |
|---|
public Widget()
The initial theme name is the lower case version of the simple class name of the concrete subclass - or in pseudo code:
getClass().getSimpleName().toLowerCase()
setTheme(java.lang.String)public Widget(AnimationState animState)
The initial theme name is the lower case version of the simple class name of the concrete subclass - or in pseudo code:
getClass().getSimpleName().toLowerCase()
animState - the animation state to share, can be nullsetTheme(java.lang.String)
public Widget(AnimationState animState,
boolean inherit)
The initial theme name is the lower case version of the simple class name of the concrete subclass - or in pseudo code:
getClass().getSimpleName().toLowerCase()
animState - the animation state to share or inherit, can be nullinherit - true if the animation state should be inherited, false for sharingAnimationState.AnimationState(de.matthiasmann.twl.AnimationState),
setTheme(java.lang.String)| Method Detail |
|---|
public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
listener - The PropertyChangeListener to be addedPropertyChangeSupport.addPropertyChangeListener(java.beans.PropertyChangeListener)
public void addPropertyChangeListener(java.lang.String propertyName,
java.beans.PropertyChangeListener listener)
propertyName - The name of the property to listen onlistener - The PropertyChangeListener to be addedPropertyChangeSupport.addPropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener)public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
listener - The PropertyChangeListener to be removedPropertyChangeSupport.removePropertyChangeListener(java.beans.PropertyChangeListener)
public void removePropertyChangeListener(java.lang.String propertyName,
java.beans.PropertyChangeListener listener)
propertyName - The name of the property that was listened onlistener - The PropertyChangeListener to be removedPropertyChangeSupport.removePropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener)public boolean hasOpenPopups()
public final Widget getParent()
public final Widget getRootWidget()
public final GUI getGUI()
Once a widget is added (indirectly) to a GUI object it will be part of that GUI tree.
This method is thread safe.
Repeated calls may not return the same result. Use it like this:
GUI gui = getGUI();
if(gui != null) {
gui.invokeLater(....);
}
afterAddToGUI(de.matthiasmann.twl.GUI),
beforeRemoveFromGUI(de.matthiasmann.twl.GUI)public final boolean isVisible()
public void setVisible(boolean visible)
visible - the new visibility flagpublic final boolean isLocallyEnabled()
isEnabled(),
setEnabled(boolean)public final boolean isEnabled()
STATE_DISABLED
If a widget is disabled it will not receive keyboard or mouse events
except MOUSE_ENTERED and MOUSE_EXITED
isEnabled(),
setEnabled(boolean)public void setEnabled(boolean enabled)
STATE_DISABLED.
On disabling the keyboard focus will be removed.
If a widget is disabled it will not receive keyboard or mouse events
except MOUSE_ENTERED and MOUSE_EXITED
enabled - true if the widget should be locally enabledisEnabled(),
isLocallyEnabled()public final int getX()
addPropertyChangeListener(java.beans.PropertyChangeListener),
addPropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener)public final int getY()
addPropertyChangeListener(java.beans.PropertyChangeListener),
addPropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener)public final int getWidth()
addPropertyChangeListener(java.beans.PropertyChangeListener),
addPropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener)public final int getHeight()
addPropertyChangeListener(java.beans.PropertyChangeListener),
addPropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener)public final int getRight()
public final int getBottom()
public final int getInnerX()
public final int getInnerY()
public final int getInnerWidth()
public final int getInnerHeight()
public final int getInnerRight()
public final int getInnerBottom()
public boolean isInside(int x,
int y)
x - the X coordinate to testy - the Y coordinate to test
public boolean setPosition(int x,
int y)
When the position has changed then
positionChanged() is calledPropertyChangeEvent are fired for "x" and "y"This method should only be called from within the layout() method of the parent. Otherwise it could lead to bad interaction with theming and result in a wrong position after the theme has been applied.
NOTE: Position is absolute in the widget's tree.
x - The new x position, can be negativey - The new y position, can be negative
layout()
public boolean setSize(int width,
int height)
width - The new width (including border)height - The new height (including border)
java.lang.IllegalArgumentException - if the size is negativesizeChanged(),
layout()
public boolean setInnerSize(int width,
int height)
width - The new width (exclusive border)height - The new height (exclusive border)
setSize(int,int)public short getBorderTop()
public short getBorderLeft()
public short getBorderBottom()
public short getBorderRight()
public int getBorderHorizontal()
public int getBorderVertical()
public boolean setBorderSize(int top,
int left,
int bottom,
int right)
top - the top borderleft - the left borderbottom - the bottom borderright - the right border
java.lang.IllegalArgumentException - if any of the parameters is negative.
public boolean setBorderSize(int horizontal,
int vertical)
horizontal - the border width for left and rightvertical - the border height for top and bottom
java.lang.IllegalArgumentException - if horizontal or vertical is negative.public boolean setBorderSize(int border)
border - the border width/height on all edges
java.lang.IllegalArgumentException - if border is negative.public boolean setBorderSize(Border border)
border - the border object or null for no border
public short getOffscreenExtraTop()
public short getOffscreenExtraLeft()
public short getOffscreenExtraBottom()
public short getOffscreenExtraRight()
public void setOffscreenExtra(int top,
int left,
int bottom,
int right)
top - the extra area on topleft - the extra area on leftbottom - the extra area on bottomright - the extra area on right
java.lang.IllegalArgumentException - if any of the parameters is negative.setRenderOffscreen(de.matthiasmann.twl.Widget.RenderOffscreen)public void setOffscreenExtra(Border offscreenExtra)
offscreenExtra - the border object or null for no extra area
java.lang.IllegalArgumentException - if any of the values is negative.setRenderOffscreen(de.matthiasmann.twl.Widget.RenderOffscreen)public int getMinWidth()
public int getMinHeight()
public void setMinSize(int width,
int height)
The minimum size is set via the theme in applyThemeMinSize(de.matthiasmann.twl.ThemeInfo)
width - the minimum widthheight - the minimum height
java.lang.IllegalArgumentException - when width or height is negativegetMinWidth(),
getMinHeight()public int getPreferredInnerWidth()
public int getPreferredWidth()
getPreferredInnerWidth()public int getPreferredInnerHeight()
public int getPreferredHeight()
getPreferredInnerHeight()public int getMaxWidth()
public int getMaxHeight()
public void setMaxSize(int width,
int height)
Short.MAX_VALUE for unbounded expansion.
The maximum size is set via the theme in applyThemeMaxSize(de.matthiasmann.twl.ThemeInfo)
width - the maximum widthheight - the maximum height
java.lang.IllegalArgumentException - when width or height is negativegetMaxWidth(),
getMaxHeight()
public static int computeSize(int min,
int preferred,
int max)
min - the minimum size of the widgetpreferred - the preferred size of the widget
or the available space where the widget is fitted intomax - the maximum size of the widget
public void adjustSize()
public void invalidateLayout()
invalidateLayoutLocally(),
borderChanged()public void validateLayout()
invalidateLayout(),
layout()public java.lang.String getTheme()
public void setTheme(java.lang.String theme)
If the theme name is empty then this widget won't receive theme data and is not included in the theme path, but it's children are still themed.
A theme name must not contain spaces or '*'. A '/' is only allowed as first character to indicate an absolute theme path. A '.' is only allowed for absolute theme paths.
theme - The new theme path element
java.lang.NullPointerException - if theme is null
java.lang.IllegalArgumentException - if the theme name is invalidGUI.applyTheme(ThemeManager),
reapplyTheme(),
getThemePath(),
isAbsoluteTheme(java.lang.String)public final java.lang.String getThemePath()
public boolean isClip()
public void setClip(boolean clip)
clip - true if clipping must be used - default is falsepublic boolean isFocusKeyEnabled()
public void setFocusKeyEnabled(boolean focusKeyEnabled)
The default is true.
When enabled the focus key (TAB) will cycle through all (indirect)
children which can receive keyboard focus. The order is defined
by getKeyboardFocusOrder().
focusKeyEnabled - if true this widget will handle the focus key.public Image getBackground()
paintBackground(de.matthiasmann.twl.GUI)public void setBackground(Image background)
background - the new background image - can be nullpaintBackground(de.matthiasmann.twl.GUI)public Image getOverlay()
paintOverlay(de.matthiasmann.twl.GUI)public void setOverlay(Image overlay)
overlay - the new overlay image - can be nullpaintOverlay(de.matthiasmann.twl.GUI)public MouseCursor getMouseCursor(Event evt)
getMouseCursor()
evt - only Event.getMouseX(), Event.getMouseY() and Event.getModifiers() are valid.
public MouseCursor getMouseCursor()
public void setMouseCursor(MouseCursor mouseCursor)
public final int getNumChildren()
public final Widget getChild(int index)
throws java.lang.IndexOutOfBoundsException
index -
java.lang.IndexOutOfBoundsException - if the index is invalidpublic void add(Widget child)
insertChild(child, getNumChildren())
child - the child that should be added
java.lang.NullPointerException - if child is null
java.lang.IllegalArgumentException - if the child is already in a treeinsertChild(de.matthiasmann.twl.Widget, int),
getNumChildren()
public void insertChild(Widget child,
int index)
throws java.lang.IndexOutOfBoundsException
child - the child that should be insertedindex - the index where it should be inserted
java.lang.IndexOutOfBoundsException - if the index is invalid
java.lang.NullPointerException - if child is null
java.lang.IllegalArgumentException - if the child is already in a treepublic final int getChildIndex(Widget child)
child - the child which index should be returned
public boolean removeChild(Widget child)
child - the child that should be removed.
public Widget removeChild(int index)
throws java.lang.IndexOutOfBoundsException
index - the index of the child
java.lang.IndexOutOfBoundsException - if the index is invalidinvalidateLayout()public void removeAllChildren()
allChildrenRemoved()public void destroy()
public boolean canAcceptKeyboardFocus()
public void setCanAcceptKeyboardFocus(boolean canAcceptKeyboardFocus)
public boolean isDepthFocusTraversal()
public void setDepthFocusTraversal(boolean depthFocusTraversal)
public boolean requestKeyboardFocus()
Use with care - users don't expect focus changes while working with the UI
Focus transfer only works when the widget is added to the GUI tree.
See getGUI().
public void giveupKeyboardFocus()
public boolean hasKeyboardFocus()
public boolean focusNextChild()
public boolean focusPrevChild()
public boolean focusFirstChild()
public boolean focusLastChild()
public AnimationState getAnimationState()
public boolean hasSharedAnimationState()
Widget(de.matthiasmann.twl.AnimationState)public TintAnimator getTintAnimator()
public void setTintAnimator(TintAnimator tintAnimator)
tintAnimator - the new tint animation objectpublic Widget.RenderOffscreen getRenderOffscreen()
public void setRenderOffscreen(Widget.RenderOffscreen renderOffscreen)
renderOffscreen - the offscreen rendering delegate.public java.lang.Object getTooltipContent()
public void setTooltipContent(java.lang.Object tooltipContent)
tooltipContent - the new tooltip content.updateTooltip(),
getTooltipContent()public InputMap getInputMap()
public void setInputMap(InputMap inputMap)
inputMap - the input map or null.handleKeyStrokeAction(java.lang.String, de.matthiasmann.twl.Event)public ActionMap getActionMap()
null is returned.
public ActionMap getOrCreateActionMap()
public void setActionMap(ActionMap actionMap)
actionMap - the new action map or null.
public Widget getWidgetAt(int x,
int y)
x - the x coordinatey - the y coordinate
protected void applyTheme(ThemeInfo themeInfo)
themeInfo - The theme info for this widgetprotected void applyThemeBackground(ThemeInfo themeInfo)
protected void applyThemeOverlay(ThemeInfo themeInfo)
protected void applyThemeBorder(ThemeInfo themeInfo)
protected void applyThemeOffscreenExtra(ThemeInfo themeInfo)
protected void applyThemeMinSize(ThemeInfo themeInfo)
protected void applyThemeMaxSize(ThemeInfo themeInfo)
protected void applyThemeMouseCursor(ThemeInfo themeInfo)
protected void applyThemeInputMap(ThemeInfo themeInfo)
protected void applyThemeTooltip(ThemeInfo themeInfo)
protected java.lang.Object getThemeTooltipContent()
protected java.lang.Object getTooltipContentAt(int mouseX,
int mouseY)
getTooltipContent
if it is non null, otherwise the result from getThemeTooltipContent
is returned.
This method is not called if the tooltip is already open and the mouse is
moved but does not leave this widget. If the tooltip depends on the mouse
position then updateTooltip must be called from handleEvent.
mouseX - the mouse X coordinatemouseY - the mouse Y coordinate
updateTooltip()protected void updateTooltip()
getTooltipContent()protected void resetTooltip()
getTooltipContent()
protected void addActionMapping(java.lang.String action,
java.lang.String methodName,
java.lang.Object... params)
this widget.
This is equal to calling addActionMapping on ActionMap with
this as target and ActionMap.FLAG_ON_PRESSED as flags.
action - the action namemethodName - the method name to invoke on this widgetparams - optional parameters which can be passed to the methodgetActionMap(),
ActionMap.addMapping(java.lang.String, java.lang.Object, java.lang.reflect.Method, java.lang.Object[], int),
getInputMap()public void reapplyTheme()
protected boolean isMouseInside(Event evt)
Calls isInside(int, int) with the mouse coordinates.
evt - the mouse event
protected boolean handleEvent(Event evt)
The default implementation handles only keyboard events and delegates
them to the child widget which has keyboard focus.
If focusKey handling is enabled then this widget cycles the keyboard
focus through it's children.
If the key was not consumed by a child or focusKey and an inputMap is
specified then the event is translated by the InputMap and
handleKeyStrokeAction is called when a mapping was found.
If the widget wants to receive mouse events then it must return true for all mouse events except for MOUSE_WHEEL (which is optional) event. Otherwise the following mouse event are not send. Before mouse movement or button events are send a MOUSE_ENTERED event is send first.
evt - The event - do not store this object - it may be reused
setFocusKeyEnabled(boolean),
handleKeyStrokeAction(java.lang.String, de.matthiasmann.twl.Event),
setInputMap(de.matthiasmann.twl.InputMap)
protected boolean handleKeyStrokeAction(java.lang.String action,
Event event)
action - the action associated with the key strokeevent - the event which caused the action
setInputMap(de.matthiasmann.twl.InputMap)
protected void moveChild(int from,
int to)
from - the index of the child that should be movedto - the new index for the child at from
java.lang.IndexOutOfBoundsException - if from or to are invalidprotected boolean requestKeyboardFocus(Widget child)
child - The child that wants keyboard focus
protected void beforeRemoveFromGUI(GUI gui)
gui - the GUI object - same as getGUI()getGUI()protected void afterAddToGUI(GUI gui)
gui - the GUI object - same as getGUI()getGUI()protected void layout()
protected void positionChanged()
protected void sizeChanged()
invalidateLayoutLocally()protected void borderChanged()
invalidateLayout()protected void childInvalidateLayout(Widget child)
child - the child which was invalidatedinvalidateLayout()protected void childAdded(Widget child)
child - the new childinvalidateLayout()protected void childRemoved(Widget exChild)
exChild - the removed widget - no longer a childinvalidateLayout()protected void allChildrenRemoved()
removeAllChildren instead of childRemoved.
The default implementation calls invalidateLayout.
invalidateLayout()protected void childVisibilityChanged(Widget child)
child - the child which changed it's visibility statesetVisible(boolean)protected void keyboardFocusChildChanged(Widget child)
child - The child which has now the keyboard focus in this hierachy level or nullprotected void keyboardFocusLost()
protected void keyboardFocusGained()
keyboardFocusGained(de.matthiasmann.twl.FocusGainedCause, de.matthiasmann.twl.Widget)
protected void keyboardFocusGained(FocusGainedCause cause,
Widget previousWidget)
keyboardFocusGained()
cause - the cause for the this focus transferpreviousWidget - the widget which previously had the keyboard focus - can be null.protected void widgetDisabled()
The default implementation does nothing.
protected void paint(GUI gui)
A subclass should overwrite paintWidget() instead of this function.
The default implementation calls the following method in order:
paintBackground(de.matthiasmann.twl.GUI)paintWidget(de.matthiasmann.twl.GUI)paintChildren(de.matthiasmann.twl.GUI)paintOverlay(de.matthiasmann.twl.GUI)
gui - the GUI objectprotected void paintWidget(GUI gui)
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.
gui - the GUI object - it's the same as getGUI()protected void paintBackground(GUI gui)
gui - the GUI objectpaint(de.matthiasmann.twl.GUI)protected void paintOverlay(GUI gui)
gui - the GUI objectpaint(de.matthiasmann.twl.GUI)protected void paintChildren(GUI gui)
gui - the GUI objectpaint(de.matthiasmann.twl.GUI)
protected void paintChild(GUI gui,
Widget child)
gui - the GUI objectchild - the child Widget
protected void paintDragOverlay(GUI gui,
int mouseX,
int mouseY,
int modifier)
gui - the GUI objectmouseX - the current mouse X positionmouseY - the current mouse Y positionmodifier - the current active modifiers - see Event.getModifiers()protected final void invalidateLayoutLocally()
sizeChanged()protected void layoutChildFullInnerArea(Widget child)
child - A child widgetprotected void layoutChildrenFullInnerArea()
protected java.util.List<Widget> getKeyboardFocusOrder()
The returned list is only iterated and not stored.
The default implementation just returns an unmodifable view of the internal children list.
protected final Widget getChildAt(int x,
int y)
x - the x coordinatey - the y coordinate
getX(),
getY()protected void updateTintAnimation()
protected final void firePropertyChange(java.beans.PropertyChangeEvent evt)
evt - The PropertyChangeEvent objectPropertyChangeSupport.firePropertyChange(java.beans.PropertyChangeEvent)
protected final void firePropertyChange(java.lang.String propertyName,
boolean oldValue,
boolean newValue)
propertyName - The programmatic name of the property that was changedoldValue - The old value of the propertynewValue - The new value of the propertyPropertyChangeSupport.firePropertyChange(java.lang.String, boolean, boolean)
protected final void firePropertyChange(java.lang.String propertyName,
int oldValue,
int newValue)
propertyName - The programmatic name of the property that was changedoldValue - The old value of the propertynewValue - The new value of the propertyPropertyChangeSupport.firePropertyChange(java.lang.String, int, int)
protected final void firePropertyChange(java.lang.String propertyName,
java.lang.Object oldValue,
java.lang.Object newValue)
propertyName - The programmatic name of the property that was changedoldValue - The old value of the propertynewValue - The new value of the propertyPropertyChangeSupport.firePropertyChange(java.lang.String, java.lang.Object, java.lang.Object)public static boolean isAbsoluteTheme(java.lang.String theme)
theme - the theme name or path.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||