org.xith3d.ui.hud.base
Class Window

java.lang.Object
  extended by org.xith3d.ui.hud.base.Widget
      extended by org.xith3d.ui.hud.base.Window
All Implemented Interfaces:
org.jagatoo.datatypes.NamableObject, org.jagatoo.datatypes.NamedObject, org.openmali.types.twodee.Positioned2f, org.openmali.types.twodee.Positioned2fRO, org.openmali.types.twodee.Sized2f, org.openmali.types.twodee.Sized2fRO
Direct Known Subclasses:
Frame

public abstract class Window
extends Widget

This class represents a simple Window above the HUD.


Nested Class Summary
static class Window.CloseOperation
          This enum can be used for the setCloseOperation() method of a Window.
 
Nested classes/interfaces inherited from class org.xith3d.ui.hud.base.Widget
Widget.DescriptionBase
 
Field Summary
 
Fields inherited from class org.xith3d.ui.hud.base.Widget
transformHeight_Pixels2HUD, transformWidth_Pixels2HUD
 
Constructor Summary
protected Window(float width, float height, boolean keepContentPaneSize, WidgetContainer contentPane, WindowHeaderWidget.Description headerDesc, java.lang.String title)
          Creates a new Window.
protected Window(float width, float height, boolean keepContentPaneSize, WidgetContainer contentPane, WindowHeaderWidget headerWidget)
          Creates a new Window.
  Window(WidgetContainer contentPane)
          Creates a new undecorated Window.
  Window(WidgetContainer contentPane, java.lang.String title)
          Creates a new Window.
  Window(WidgetContainer contentPane, WindowHeaderWidget.Description headerDesc, java.lang.String title)
          Creates a new Window.
  Window(WidgetContainer contentPane, WindowHeaderWidget headerWidget)
          Creates a new Window.
 
Method Summary
 void addWindowListener(WindowListener l)
          Adds a new WindowListener.
protected  boolean checkDragStartCondition(float postionOnWindowX, float postionOnWindowY)
           
protected abstract  WidgetContainer createContentPane(float width, float height)
           
protected abstract  WindowHeaderWidget createHeaderWidget(WindowHeaderWidget.Description headerDesc, java.lang.String title)
          Creates the header Widget for this decorated Window.
 void detach()
          Removes the Widget from its Container.
 void drawAndUpdateWidget(Texture2DCanvas texCanvas, int offsetX, int offsetY, int width, int height, boolean drawsSelf)
          
protected  void drawBorder(Border border, Texture2DCanvas texCanvas, int offsetX, int offsetY, int width, int height)
          
protected  void drawWidget(Texture2DCanvas texCanvas, int offsetX, int offsetY, int width, int height, boolean drawsSelf)
          
protected  int getContentHeightPX()
          Gets the height of the widget's content area (minus border and padding) (in pixels).
 WidgetContainer getContentPane()
          
protected  int getContentWidthPX()
          Gets the width of the widget's content area (minus border and padding) (in pixels).
 Window.CloseOperation getDefaultCloseOperation()
           
 float getHeaderHeight()
          Gets the height of the title-bar.
protected  WindowHeaderWidget getHeaderWidget()
           
 float getResX()
           
 float getResY()
           
 java.lang.String getTitle()
          Gets the Window's title.
protected  void init()
          This method is called when the WidgetContainer is set.
 boolean isCloseButtonVisible()
           
 boolean isDecorated()
           
 boolean isPaneDraggingEnabled()
           
protected  void onCloseButtonClicked()
          This event is fired, if the close button on the Header-Widget was clicked.
protected  void onDetachedFromHUD(HUD hud)
          This event is fired, when this Widget is removed from the HUD live Widget hierarchy.
protected  void onFocusLost()
          This event is fired, when the focus is lost by a Widget.
protected  void onKeyPressed(org.jagatoo.input.devices.components.Key key, int modifierMask, long when)
          This event is fired, when a key is pressed on a focused Widget.
protected  void onKeyReleased(org.jagatoo.input.devices.components.Key key, int modifierMask, long when)
          This event is fired, when a key is released on a focused Widget.
protected  void onKeyTyped(char ch, int modifierMask, long when)
          This event is fired when a key is typed on the keyboard.
protected  void onMouseButtonPressed(org.jagatoo.input.devices.components.MouseButton button, float x, float y, long when, long lastWhen, boolean isTopMost, boolean hasFocus)
          This event is fired, when a mouse button is pressed on a focused Widget.
protected  void onMouseButtonReleased(org.jagatoo.input.devices.components.MouseButton button, float x, float y, long when, long lastWhen, boolean isTopMost, boolean hasFocus)
          This event is fired, when a mouse button is released on a focused Widget.
protected  void onMouseExited(boolean isTopMost, boolean hasFocus)
          This method is called when the mouse exited the Widget area.
protected  void onMouseMoved(float x, float y, int buttonsState, long when, boolean isTopMost, boolean hasFocus)
          This event is fired, when the mouse is moved on a Widget.
protected  void onMouseWheelMoved(int delta, boolean isPageMove, float x, float y, long when, boolean isTopMost)
          This event is fired, when the mouse wheel is moved on a Widget.
protected  void onSizeChanged(float oldWidth, float oldHeight, float newWidth, float newHeight)
          
protected  void onVisibilityChanged(boolean visible)
          This method is triggered when the visibility state has eeffectively changed.
protected  HUDPickResult pick(int canvasX, int canvasY, HUDPickResult.HUDPickReason pickReason, org.jagatoo.input.devices.components.MouseButton button, long when, long meta, int flags)
          Tests whether a Widget is under the cursor and runs the approriate methods if true.
 void removeWindowListener(WindowListener l)
          Removes a WindowListener.
 void setCloseButtonVisible(boolean visible)
          Sets the close button visible of hidden.
 void setContentSize(float contentWidth, float contentHeight)
          Sets the size of the window, so that the content-pane is the given size.
 void setDefaultCloseOperation(Window.CloseOperation op)
          Sets the default (if not overridden) CloseOperation to be executed when the close Button was clicked.
protected  void setHostTextureDirty(int flags)
          
 void setPaneDraggingEnabled(boolean enabled)
          Sets pane-dragging enabled or disabled.
protected  void setTextureDirty(int flags)
          
 void setTitle(java.lang.String title)
          Sets the Window's title.
protected  void startDragging(int canvasX, int canvasY, float widgetX, float widgetY)
           
 java.lang.String toString()
          
 
Methods inherited from class org.xith3d.ui.hud.base.Widget
addContainerListener, addControllerListener, addFocusListener, addInputListener, addKeyboardListener, addLocationListener, addMouseListener, addSizeListener, addVisibilityListener, bindToGlobalMouseMovement, blocksFocusMoveDeviceComponent, calculateTransformHeight_Pixels2HUD, calculateTransformWidth_Pixels2HUD, compareAbsZIndex, createShape, drawBackground, drawWidgetAfterWidgetAssembler, drawWidgetContents, getAbsoluteLocationOnHUD_, getAspect, getAssembly, getBorder, getContainer, getContentAspect, getContentHeight, getContentLeftPX, getContentOffset, getContentTopPX, getContentWidth, getContextMenu, getCursor, getEqualHeight_, getEqualWidth_, getForcedRedrawFrequency, getHeight, getHeightPX, getHUD, getLeft, getLevel, getLocation, getLocation, getLocationHUD2Pixels_, getLocationHUD2SG_, getLocationPixels2HUD_, getLocationSG2HUD_, getMaxRedrawFrequency, getMinHeight, getMinWidth, getName, getParentWindow, getPickHeight, getPickWidth, getRelLocationHUD2Pixels_, getRootHostWidget, getShape, getSize, getSizeHUD2Pixels_, getSizeHUD2SG_, getSizeOfPixels_, getSizePixels2HUD_, getSizeSG2HUD_, getToolTip, getTop, getTransparency, getUserObject, getWidgetAssembler, getWidth, getWidthPX, getZIndex, hasDropShadow, hasFocus, hasFocus, hasToolTip, initSize, isAHostedWidgetDirty, isClickable, isDraggable, isFocussable, isHeavyWeight, isHovered, isInitialized, isInitializing, isPickable, isThisWidgetDirty, isVisible, notifyOnDragStopped, onAttachedToContainer, onAttachedToHUD, onControllerAxisChanged, onControllerButtonPressed, onControllerButtonReleased, onDetachedFromContainer, onFocusGained, onInputStateChanged, onLocationChanged, onMouseEntered, onMouseStopped, pickConditionsMatch, removeContainerListener, removeControllerListener, removeFocusListener, removeInputListener, removeKeyboardListener, removeLocationListener, removeMouseListener, removeSizeListener, removeVisibilityListener, requestFocus, resetWidgetDirty, setBorder, setBorder, setClickable, setContentClipRect, setContextMenu, setCursor, setDraggable, setFocussable, setForcedRedrawFrequency, setHasDropShadow, setHeight, setHostedWidgetDirty, setHostTextureDirty, setHostWidget, setLocation, setLocation, setLocation, setMaxRedrawFrequency, setName, setPickable, setSize, setSize, setSize, setSize, setTextureDirty, setToolTip, setTransparency, setTransparency, setUserObject, setVisible, setWidgetDirty, setWidth, setZIndex, update, updateAbsZIndex, updateSizeFactors, updateTranslation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Window

protected Window(float width,
                 float height,
                 boolean keepContentPaneSize,
                 WidgetContainer contentPane,
                 WindowHeaderWidget.Description headerDesc,
                 java.lang.String title)
Creates a new Window.

Parameters:
width - the width of the Window
height - the height of the Window
keepContentPaneSize -
contentPane - the Widget that visually defines the Window.
headerDesc - the description of this Window's header (or null for an undecorated Window)
title - this Window's title

Window

protected Window(float width,
                 float height,
                 boolean keepContentPaneSize,
                 WidgetContainer contentPane,
                 WindowHeaderWidget headerWidget)
Creates a new Window.

Parameters:
width - the width of the Window
height - the height of the Window
keepContentPaneSize -
contentPane - the Widget that visually defines the Window.
headerWidget - a Widget, that defines this Window's header (or null for an undecorated Window)

Window

public Window(WidgetContainer contentPane,
              WindowHeaderWidget.Description headerDesc,
              java.lang.String title)
Creates a new Window.

Parameters:
contentPane - the Widget that visually defines the Window.
headerDesc - the description of this Window's header (or null for an undecorated Window)
title - this Window's title

Window

public Window(WidgetContainer contentPane,
              WindowHeaderWidget headerWidget)
Creates a new Window.

Parameters:
contentPane - the Widget that visually defines the Window.
headerWidget - a Widget, that defines this Window's header (or null for an undecorated Window)

Window

public Window(WidgetContainer contentPane,
              java.lang.String title)
Creates a new Window.

Parameters:
contentPane - the Widget that visually defines the Window.
title - this Window's header (or null for an undecorated Window)

Window

public Window(WidgetContainer contentPane)
Creates a new undecorated Window.

Parameters:
contentPane - the Widget that visually defines the Window.
Method Detail

getHeaderWidget

protected final WindowHeaderWidget getHeaderWidget()
Returns:
the title bar's Widget

isDecorated

public final boolean isDecorated()
Returns:
true, if this Window is decorated (has a title bar).

getHeaderHeight

public float getHeaderHeight()
Gets the height of the title-bar.

Returns:
the header's height.

setTitle

public void setTitle(java.lang.String title)
Sets the Window's title.

Parameters:
title -

getTitle

public final java.lang.String getTitle()
Gets the Window's title.

Returns:
the Window's title.

getContentPane

public final WidgetContainer getContentPane()


getContentWidthPX

protected final int getContentWidthPX()
Description copied from class: Widget
Gets the width of the widget's content area (minus border and padding) (in pixels).

Overrides:
getContentWidthPX in class Widget
Returns:
the ContentPane's width.

getContentHeightPX

protected final int getContentHeightPX()
Description copied from class: Widget
Gets the height of the widget's content area (minus border and padding) (in pixels).

Overrides:
getContentHeightPX in class Widget
Returns:
the ContentPane's height.

setContentSize

public void setContentSize(float contentWidth,
                           float contentHeight)
Sets the size of the window, so that the content-pane is the given size.

Parameters:
contentWidth -
contentHeight -

getResX

public final float getResX()
Returns:
the ContentPane's x-resolution.

getResY

public final float getResY()
Returns:
the ContentPane's y-resolution.

setDefaultCloseOperation

public void setDefaultCloseOperation(Window.CloseOperation op)
Sets the default (if not overridden) CloseOperation to be executed when the close Button was clicked.

Parameters:
op - the default close operation or null for no operation

getDefaultCloseOperation

public final Window.CloseOperation getDefaultCloseOperation()
Returns:
the default (if not overridden) CloseOperation to be executed when the close Button was clicked.

setCloseButtonVisible

public void setCloseButtonVisible(boolean visible)
Sets the close button visible of hidden.

Parameters:
visible -
Throws:
java.lang.UnsupportedOperationException - if this is an undecorated Window

isCloseButtonVisible

public boolean isCloseButtonVisible()
Returns:
if the close button is visible of hidden.
Throws:
java.lang.UnsupportedOperationException - if this is an undecorated Window

setPaneDraggingEnabled

public void setPaneDraggingEnabled(boolean enabled)
Sets pane-dragging enabled or disabled. If pane-dragging is enabled, you can hold the mouse button on the content pane and drag the Frame.


isPaneDraggingEnabled

public final boolean isPaneDraggingEnabled()
Returns:
true, if pane-dragging is enabled. If pane-dragging is enabled, you can hold the mouse button on the content pane and drag the Frame.

checkDragStartCondition

protected boolean checkDragStartCondition(float postionOnWindowX,
                                          float postionOnWindowY)
Returns:
true, if pane-dragging is enabled. If pane-dragging is enabled, you can hold the mouse button on the content pane and drag the Frame.

startDragging

protected void startDragging(int canvasX,
                             int canvasY,
                             float widgetX,
                             float widgetY)
Overrides:
startDragging in class Widget

onMouseButtonPressed

protected void onMouseButtonPressed(org.jagatoo.input.devices.components.MouseButton button,
                                    float x,
                                    float y,
                                    long when,
                                    long lastWhen,
                                    boolean isTopMost,
                                    boolean hasFocus)
This event is fired, when a mouse button is pressed on a focused Widget.

Overrides:
onMouseButtonPressed in class Widget
Parameters:
button - the button that was pressed
x - the current mouse x position
y - the current mouse y position
isTopMost - is this Widget topMost
hasFocus - is this Widget focused
See Also:
net.jtank.input.MouseCode

onMouseButtonReleased

protected void onMouseButtonReleased(org.jagatoo.input.devices.components.MouseButton button,
                                     float x,
                                     float y,
                                     long when,
                                     long lastWhen,
                                     boolean isTopMost,
                                     boolean hasFocus)
This event is fired, when a mouse button is released on a focused Widget.

Overrides:
onMouseButtonReleased in class Widget
Parameters:
button - the button that was released
x - the current mouse x position
y - the current mouse y position
isTopMost - is this Widget topMost
hasFocus - is this Widget focused
See Also:
net.jtank.input.MouseCode

onMouseMoved

protected void onMouseMoved(float x,
                            float y,
                            int buttonsState,
                            long when,
                            boolean isTopMost,
                            boolean hasFocus)
This event is fired, when the mouse is moved on a Widget.

Overrides:
onMouseMoved in class Widget
Parameters:
x - the new X coordinate
y - the new Y coordinate
isTopMost - is this Widget topMost
hasFocus - is this Widget focused

onMouseWheelMoved

protected void onMouseWheelMoved(int delta,
                                 boolean isPageMove,
                                 float x,
                                 float y,
                                 long when,
                                 boolean isTopMost)
This event is fired, when the mouse wheel is moved on a Widget.

Overrides:
onMouseWheelMoved in class Widget
Parameters:
delta - a positive value when the wheel was moved up
x - the current mouse x position
y - the current mouse y position
isTopMost - is this Widget topMost

onFocusLost

protected void onFocusLost()
This event is fired, when the focus is lost by a Widget.

Overrides:
onFocusLost in class Widget

onMouseExited

protected void onMouseExited(boolean isTopMost,
                             boolean hasFocus)
This method is called when the mouse exited the Widget area.

Overrides:
onMouseExited in class Widget
Parameters:
isTopMost - is this Widget topMost
hasFocus - is this Widget focused

onKeyPressed

protected void onKeyPressed(org.jagatoo.input.devices.components.Key key,
                            int modifierMask,
                            long when)
This event is fired, when a key is pressed on a focused Widget.

Overrides:
onKeyPressed in class Widget
Parameters:
key - the key that was pressed
modifierMask - the mask of modifier keys
when - the keyevent's timestamp

onKeyReleased

protected void onKeyReleased(org.jagatoo.input.devices.components.Key key,
                             int modifierMask,
                             long when)
This event is fired, when a key is released on a focused Widget.

Overrides:
onKeyReleased in class Widget
Parameters:
key - the key that was released
modifierMask - the mask of modifier keys
when - the keyevent's timestamp

onKeyTyped

protected void onKeyTyped(char ch,
                          int modifierMask,
                          long when)
This event is fired when a key is typed on the keyboard.

Overrides:
onKeyTyped in class Widget
Parameters:
ch - the typed key's character
modifierMask - the mask of modifier keys
when - the keyevent's timestamp

addWindowListener

public void addWindowListener(WindowListener l)
Adds a new WindowListener.

Parameters:
l - the new WindowListener

removeWindowListener

public void removeWindowListener(WindowListener l)
Removes a WindowListener.

Parameters:
l - the WindowListener to remove

detach

public void detach()
Removes the Widget from its Container.

Overrides:
detach in class Widget

onCloseButtonClicked

protected void onCloseButtonClicked()
This event is fired, if the close button on the Header-Widget was clicked.
It simply calls detach() by default. Override it to change this behaviour.

See Also:
detach()

onVisibilityChanged

protected void onVisibilityChanged(boolean visible)
This method is triggered when the visibility state has eeffectively changed.

Overrides:
onVisibilityChanged in class Widget

onSizeChanged

protected void onSizeChanged(float oldWidth,
                             float oldHeight,
                             float newWidth,
                             float newHeight)

Overrides:
onSizeChanged in class Widget

pick

protected HUDPickResult pick(int canvasX,
                             int canvasY,
                             HUDPickResult.HUDPickReason pickReason,
                             org.jagatoo.input.devices.components.MouseButton button,
                             long when,
                             long meta,
                             int flags)
Tests whether a Widget is under the cursor and runs the approriate methods if true.

Overrides:
pick in class Widget
Parameters:
canvasX - the x position of the mouse on the Canvas3D
canvasY - the y position of the mouse on the Canvas3D
pickReason - the action which caused this pick operation
button - the mouse-button, that caused the picking
when - the timestamp of the picking
meta - this could be either the lastPressTime, lastReleaseTime, buttonsState mask or the page-move-boolean. (depends on the pickReason)
Returns:
an instance of HUDPickResult holding the picked Widget and absolute and relative picking positions or null.

onDetachedFromHUD

protected void onDetachedFromHUD(HUD hud)
This event is fired, when this Widget is removed from the HUD live Widget hierarchy.

Overrides:
onDetachedFromHUD in class Widget
Parameters:
hud - the HUD, the Widget is removed from

toString

public java.lang.String toString()

Overrides:
toString in class Widget

setHostTextureDirty

protected void setHostTextureDirty(int flags)

Overrides:
setHostTextureDirty in class Widget

setTextureDirty

protected void setTextureDirty(int flags)

Overrides:
setTextureDirty in class Widget

drawBorder

protected void drawBorder(Border border,
                          Texture2DCanvas texCanvas,
                          int offsetX,
                          int offsetY,
                          int width,
                          int height)

Overrides:
drawBorder in class Widget

drawWidget

protected void drawWidget(Texture2DCanvas texCanvas,
                          int offsetX,
                          int offsetY,
                          int width,
                          int height,
                          boolean drawsSelf)

Specified by:
drawWidget in class Widget

drawAndUpdateWidget

public void drawAndUpdateWidget(Texture2DCanvas texCanvas,
                                int offsetX,
                                int offsetY,
                                int width,
                                int height,
                                boolean drawsSelf)

Overrides:
drawAndUpdateWidget in class Widget

init

protected void init()
This method is called when the WidgetContainer is set.

Specified by:
init in class Widget

createHeaderWidget

protected abstract WindowHeaderWidget createHeaderWidget(WindowHeaderWidget.Description headerDesc,
                                                         java.lang.String title)
Creates the header Widget for this decorated Window. It is only called, if the Window is decorated. It MUST NOT return null. It MUST NOT add it to the WidgetAssembler.

Parameters:
headerDesc - the description for the header Widget
title - the Window's title
Returns:
the create WindowHeaderWidget instance

createContentPane

protected abstract WidgetContainer createContentPane(float width,
                                                     float height)