de.matthiasmann.twl
Class ResizableFrame

java.lang.Object
  extended by de.matthiasmann.twl.Widget
      extended by de.matthiasmann.twl.ResizableFrame

public class ResizableFrame
extends Widget

A resizable frame.

All child widgets (which are not part of the frame itself) cover the complete inner area Widget.layoutChildFullInnerArea(de.matthiasmann.twl.Widget).

The preferred way to use the ResizableFrame is to add a single widget which will manage the layout of all it's children. DialogLayout can be used for this to avoid creating a new class.


Nested Class Summary
static class ResizableFrame.ResizableAxis
           
 
Nested classes/interfaces inherited from class de.matthiasmann.twl.Widget
Widget.OffscreenMouseAdjustments, Widget.RenderOffscreen
 
Field Summary
static AnimationState.StateKey STATE_FADE
           
 
Fields inherited from class de.matthiasmann.twl.Widget
STATE_DISABLED, STATE_HAS_FOCUSED_CHILD, STATE_HAS_OPEN_POPUPS, STATE_KEYBOARD_FOCUS
 
Constructor Summary
ResizableFrame()
           
 
Method Summary
 void addCloseCallback(java.lang.Runnable cb)
           
 void adjustSize()
          Auto adjust the size of this widget based on it's preferred size.
protected  void applyTheme(ThemeInfo themeInfo)
          Apply the given theme.
protected  void applyThemeResizableFrame(ThemeInfo themeInfo)
           
protected  void fadeTo(Color color, int duration)
           
protected  void fadeToHide(int duration)
           
 int getFadeDurationActivate()
           
 int getFadeDurationDeactivate()
           
 int getFadeDurationHide()
           
 int getFadeDurationShow()
           
 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(Event evt)
          Returns the mouse cursor which should be used for the given mouse coordinates and modifiers.
 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.
 ResizableFrame.ResizableAxis getResizableAxis()
           
 java.lang.String getTitle()
           
protected  boolean handleEvent(Event evt)
          Called when an event occurred that this widget could be interested in.
 boolean hasTitleBar()
           
 boolean isBackgroundDraggable()
           
 boolean isDraggable()
           
protected  boolean isFrameElement(Widget widget)
           
protected  void keyboardFocusGained()
          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 layoutCloseButton()
           
protected  void layoutResizeHandle()
           
protected  void layoutTitle()
           
 void removeCloseCallback(java.lang.Runnable cb)
           
 void setBackgroundDraggable(boolean backgroundDraggable)
          Controls weather the ResizableFrame can be dragged via the background (eg space not occupied by any widget or a resizable edge), default is false.
 void setDraggable(boolean movable)
          Controls weather the ResizableFrame can be dragged via the title bar or not, default is true.
 void setHardVisible(boolean visible)
          Sets the visibility without triggering a fade
 void setResizableAxis(ResizableFrame.ResizableAxis resizableAxis)
           
 void setTitle(java.lang.String title)
           
 void setVisible(boolean visible)
          Changes the visibility flag of this widget.
protected  void updateTintAnimation()
          Updates the tint animation when a fade is active.
 
Methods inherited from class de.matthiasmann.twl.Widget
add, addActionMapping, addPropertyChangeListener, addPropertyChangeListener, afterAddToGUI, allChildrenRemoved, applyThemeBackground, applyThemeBorder, applyThemeInputMap, applyThemeMaxSize, applyThemeMinSize, applyThemeMouseCursor, applyThemeOffscreenExtra, applyThemeOverlay, applyThemeTooltip, beforeRemoveFromGUI, borderChanged, canAcceptKeyboardFocus, childAdded, childInvalidateLayout, childRemoved, childVisibilityChanged, computeSize, destroy, 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, getMouseCursor, getNumChildren, getOffscreenExtraBottom, getOffscreenExtraLeft, getOffscreenExtraRight, getOffscreenExtraTop, getOrCreateActionMap, getOverlay, getParent, getPreferredHeight, getRenderOffscreen, getRight, getRootWidget, getTheme, getThemePath, getThemeTooltipContent, getTintAnimator, getTooltipContent, getTooltipContentAt, getWidgetAt, getWidth, getX, getY, giveupKeyboardFocus, handleKeyStrokeAction, hasKeyboardFocus, hasOpenPopups, hasSharedAnimationState, insertChild, invalidateLayout, invalidateLayoutLocally, isAbsoluteTheme, isClip, isDepthFocusTraversal, isEnabled, isFocusKeyEnabled, isInside, isLocallyEnabled, isMouseInside, isVisible, keyboardFocusChildChanged, keyboardFocusGained, layoutChildFullInnerArea, layoutChildrenFullInnerArea, moveChild, paint, paintBackground, paintChild, paintChildren, paintDragOverlay, paintOverlay, paintWidget, 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, sizeChanged, updateTooltip, validateLayout, widgetDisabled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STATE_FADE

public static final AnimationState.StateKey STATE_FADE
Constructor Detail

ResizableFrame

public ResizableFrame()
Method Detail

getTitle

public java.lang.String getTitle()

setTitle

public void setTitle(java.lang.String title)

getResizableAxis

public ResizableFrame.ResizableAxis getResizableAxis()

setResizableAxis

public void setResizableAxis(ResizableFrame.ResizableAxis resizableAxis)

isDraggable

public boolean isDraggable()

setDraggable

public void setDraggable(boolean movable)
Controls weather the ResizableFrame can be dragged via the title bar or not, default is true.

When set to false the resizing should also be disabled to present a consistent behavior to the user.

Parameters:
movable - if dragging via the title bar is allowed - default is true.

isBackgroundDraggable

public boolean isBackgroundDraggable()

setBackgroundDraggable

public void setBackgroundDraggable(boolean backgroundDraggable)
Controls weather the ResizableFrame can be dragged via the background (eg space not occupied by any widget or a resizable edge), default is false.

This works independent of setDraggable(boolean).

Parameters:
backgroundDraggable - if dragging via the background is allowed - default is false.
See Also:
setDraggable(boolean)

hasTitleBar

public final boolean hasTitleBar()

addCloseCallback

public void addCloseCallback(java.lang.Runnable cb)

removeCloseCallback

public void removeCloseCallback(java.lang.Runnable cb)

getFadeDurationActivate

public int getFadeDurationActivate()

getFadeDurationDeactivate

public int getFadeDurationDeactivate()

getFadeDurationHide

public int getFadeDurationHide()

getFadeDurationShow

public int getFadeDurationShow()

setVisible

public void setVisible(boolean visible)
Description copied from class: Widget
Changes the visibility flag of this widget. Widgets are by default visible. Invisible widgets don't receive paint() or handleEvent() calls

Overrides:
setVisible in class Widget
Parameters:
visible - the new visibility flag

setHardVisible

public void setHardVisible(boolean visible)
Sets the visibility without triggering a fade

Parameters:
visible - the new visibility flag
See Also:
Widget.setVisible(boolean)

applyThemeResizableFrame

protected void applyThemeResizableFrame(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

updateTintAnimation

protected void updateTintAnimation()
Description copied from class: Widget
Updates the tint animation when a fade is active. Can be overridden to do additional things like hide the widget after the end of the animation.

Overrides:
updateTintAnimation in class Widget

fadeTo

protected void fadeTo(Color color,
                      int duration)

fadeToHide

protected void fadeToHide(int duration)

isFrameElement

protected boolean isFrameElement(Widget widget)

layout

protected void layout()
Description copied from class: Widget
Called when the layoutInvalid flag is set. The default implementation does nothing.

Overrides:
layout in class Widget

layoutTitle

protected void layoutTitle()

layoutCloseButton

protected void layoutCloseButton()

layoutResizeHandle

protected void layoutResizeHandle()

keyboardFocusGained

protected void keyboardFocusGained()
Description copied from class: Widget
Called when this widget has gained the keyboard focus. The default implementation does nothing.

Overrides:
keyboardFocusGained in class Widget
See Also:
Widget.keyboardFocusGained(de.matthiasmann.twl.FocusGainedCause, de.matthiasmann.twl.Widget)

keyboardFocusLost

protected void keyboardFocusLost()
Description copied from class: Widget
Called when this widget has lost the keyboard focus. The default implementation does nothing.

Overrides:
keyboardFocusLost in class Widget

getMinWidth

public int getMinWidth()
Description copied from class: Widget
Returns the minimum width of the widget. Layout manager will allocate atleast the minimum width to a widget even when the container is not big enough. The default implementation will not return values smaller then the current border width.

Overrides:
getMinWidth in class Widget
Returns:
the minimum width of the widget

getMinHeight

public int getMinHeight()
Description copied from class: Widget
Returns the minimum height of the widget. Layout manager will allocate atleast the minimum height to a widget even when the container is not big enough. The default implementation will not return values smaller then the current border width.

Overrides:
getMinHeight in class Widget
Returns:
the minimum height of the widget

getMaxWidth

public int getMaxWidth()
Description copied from class: Widget
Returns the maximum width of the widget. A maximum of 0 means that the widgets wants it's preferred size and no extra space from layout. A value > 0 is used for widgets which can expand to cover available area to that maximum.

Overrides:
getMaxWidth in class Widget
Returns:
the maximum width

getMaxHeight

public int getMaxHeight()
Description copied from class: Widget
Returns the maximum height of the widget. A maximum of 0 means that the widgets wants it's preferred size and no extra space from layout. A value > 0 is used for widgets which can expand to cover available area to that maximum.

Overrides:
getMaxHeight in class Widget
Returns:
the maximum height

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

getPreferredWidth

public int getPreferredWidth()
Description copied from class: Widget
Returns the preferred width based on it's children and preferred inner width. Subclasses can overwrite this method to compute the preferred size differently.

Overrides:
getPreferredWidth in class Widget
Returns:
the preferred width.
See Also:
Widget.getPreferredInnerWidth()

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

adjustSize

public void adjustSize()
Description copied from class: Widget
Auto adjust the size of this widget based on it's preferred size. Subclasses can provide more functionality

Overrides:
adjustSize in class Widget

handleEvent

protected boolean handleEvent(Event evt)
Description copied from class: Widget
Called when an event occurred that this widget could be interested in.

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.

Overrides:
handleEvent in class Widget
Parameters:
evt - The event - do not store this object - it may be reused
Returns:
true if the widget handled this event
See Also:
Widget.setFocusKeyEnabled(boolean), Widget.handleKeyStrokeAction(java.lang.String, de.matthiasmann.twl.Event), Widget.setInputMap(de.matthiasmann.twl.InputMap)

getMouseCursor

public MouseCursor getMouseCursor(Event evt)
Description copied from class: Widget
Returns the mouse cursor which should be used for the given mouse coordinates and modifiers. The default implementation calls Widget.getMouseCursor()

Overrides:
getMouseCursor in class Widget
Parameters:
evt - only Event.getMouseX(), Event.getMouseY() and Event.getModifiers() are valid.
Returns:
the mouse cursor or null when no mouse cursor is defined for this widget