org.xith3d.ui.hud.widgets
Class ToggleButton

java.lang.Object
  extended by org.xith3d.ui.hud.base.Widget
      extended by org.xith3d.ui.hud.base.AbstractButton
          extended by org.xith3d.ui.hud.widgets.Button
              extended by org.xith3d.ui.hud.widgets.ToggleButton
All Implemented Interfaces:
org.jagatoo.datatypes.Enableable, 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, TextWidget

public class ToggleButton
extends Button

A ToggleButton is a Button, that stays PRESSED until it gets clicked again.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.xith3d.ui.hud.widgets.Button
Button.Description
 
Nested classes/interfaces inherited from class org.xith3d.ui.hud.base.AbstractButton
AbstractButton.ButtonState
 
Nested classes/interfaces inherited from class org.xith3d.ui.hud.base.Widget
Widget.DescriptionBase
 
Field Summary
 
Fields inherited from class org.xith3d.ui.hud.widgets.Button
DEFAULT_HEAVYWEIGHT
 
Fields inherited from class org.xith3d.ui.hud.base.AbstractButton
buttonState, isStateChangable
 
Fields inherited from class org.xith3d.ui.hud.base.Widget
transformHeight_Pixels2HUD, transformWidth_Pixels2HUD
 
Constructor Summary
ToggleButton(boolean isHeavyWeight, float width, float height, java.lang.String text)
          Create a new ToggleButton.
ToggleButton(boolean isHeavyWeight, float width, float height, java.lang.String text, Button.Description desc)
          Create a new ToggleButton.
ToggleButton(boolean isHeavyWeight, float width, float height, java.lang.String text, org.openmali.vecmath2.Colorf color)
          Creates a new ToggleButton.
ToggleButton(boolean isHeavyWeight, float width, float height, java.lang.String text, HUDFont font)
          Creates a new ToggleButton.
ToggleButton(boolean isHeavyWeight, float width, float height, java.lang.String text, HUDFont font, org.openmali.vecmath2.Colorf color)
          Creates a new ToggleButton.
ToggleButton(boolean isHeavyWeight, float width, float height, java.lang.String normalTexture, java.lang.String hoveredTexture, java.lang.String pressedTexture)
          Creates a new Image ToggleButton (textures will simply be streched over the whole Button area).
ToggleButton(boolean isHeavyWeight, float width, float height, java.lang.String normalTexture, java.lang.String hoveredTexture, java.lang.String pressedTexture, java.lang.String text, HUDFont font, org.openmali.vecmath2.Colorf color)
          Creates a new Image ToggleButton (textures will simply be streched over the whole Button area).
ToggleButton(boolean isHeavyWeight, float width, float height, Texture2D normalTexture, Texture2D hoveredTexture, Texture2D pressedTexture)
          Creates a new Image ToggleButton (textures will simply be streched over the whole Button area).
ToggleButton(boolean isHeavyWeight, float width, float height, Texture2D normalTexture, Texture2D hoveredTexture, Texture2D pressedTexture, java.lang.String text, HUDFont font, org.openmali.vecmath2.Colorf color)
          Creates a new Image ToggleButton (textures will simply be streched over the whole Button area).
ToggleButton(float width, float height, java.lang.String text)
          Create a new ToggleButton.
ToggleButton(float width, float height, java.lang.String text, Button.Description desc)
          Create a new ToggleButton.
ToggleButton(float width, float height, java.lang.String text, org.openmali.vecmath2.Colorf color)
          Creates a new ToggleButton.
ToggleButton(float width, float height, java.lang.String text, HUDFont font)
          Creates a new ToggleButton.
ToggleButton(float width, float height, java.lang.String text, HUDFont font, org.openmali.vecmath2.Colorf color)
          Creates a new ToggleButton.
ToggleButton(float width, float height, java.lang.String normalTexture, java.lang.String hoveredTexture, java.lang.String pressedTexture)
          Creates a new Image ToggleButton (textures will simply be streched over the whole Button area).
ToggleButton(float width, float height, java.lang.String normalTexture, java.lang.String hoveredTexture, java.lang.String pressedTexture, java.lang.String text, HUDFont font, org.openmali.vecmath2.Colorf color)
          Creates a new Image ToggleButton (textures will simply be streched over the whole Button area).
ToggleButton(float width, float height, Texture2D normalTexture, Texture2D hoveredTexture, Texture2D pressedTexture)
          Creates a new Image ToggleButton (textures will simply be streched over the whole Button area).
ToggleButton(float width, float height, Texture2D normalTexture, Texture2D hoveredTexture, Texture2D pressedTexture, java.lang.String text, HUDFont font, org.openmali.vecmath2.Colorf color)
          Creates a new Image ToggleButton (textures will simply be streched over the whole Button area).
 
Method Summary
 boolean isToggled()
           
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 onMouseEntered(boolean isTopMost, boolean hasFocus)
          This method is called when the mouse entered the Widget area.
protected  void onMouseExited(boolean isTopMost, boolean hasFocus)
          This method is called when the mouse exited the Widget area.
 void setToggled(boolean toggled)
          Sets if the ToggleButton is currently toggled.
 
Methods inherited from class org.xith3d.ui.hud.widgets.Button
createCaptionWidget, createImageButtonDesc, createImageButtonDesc, deriveDesc, drawWidget, getAlignment, getCurrentTexture, getFont, getFontColor, getIcon, getIconGap, getOptimalSize, getText, getTextureHovered, getTextureNormal, getTexturePressed, hasText, init, onFocusGained, onFocusLost, onSizeChanged, setAlignment, setButtonState, setEnabledImpl, setFont, setFontColor, setIcon, setIcon, setIconGap, setText, setTextureHovered, setTextureHovered, setTextureNormal, setTextureNormal, setTexturePressed, setTexturePressed, toString, update
 
Methods inherited from class org.xith3d.ui.hud.base.AbstractButton
addButtonListener, bindAccessor, fireButtonClickedEvent, getButtonState, isDefaultFocusResponsive, isEnabled, isFocusResponsive, onInputStateChanged, removeButtonListener, setDefaultFocusResponsive, setEnabled, setFocusResponsive, unbindAccessor
 
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, detach, drawAndUpdateWidget, drawBackground, drawBorder, drawWidgetAfterWidgetAssembler, drawWidgetContents, getAbsoluteLocationOnHUD_, getAspect, getAssembly, getBorder, getContainer, getContentAspect, getContentHeight, getContentHeightPX, getContentLeftPX, getContentOffset, getContentTopPX, getContentWidth, getContentWidthPX, 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, onDetachedFromHUD, onKeyPressed, onKeyReleased, onKeyTyped, onLocationChanged, onMouseMoved, onMouseStopped, onMouseWheelMoved, onVisibilityChanged, pick, 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, setHostTextureDirty, setHostWidget, setLocation, setLocation, setLocation, setMaxRedrawFrequency, setName, setPickable, setSize, setSize, setSize, setSize, setTextureDirty, setTextureDirty, setToolTip, setTransparency, setTransparency, setUserObject, setVisible, setWidgetDirty, setWidth, setZIndex, startDragging, updateAbsZIndex, updateSizeFactors, updateTranslation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ToggleButton

public ToggleButton(boolean isHeavyWeight,
                    float width,
                    float height,
                    java.lang.String text,
                    Button.Description desc)
Create a new ToggleButton.

Parameters:
isHeavyWeight -
width - the new width of this Widget
height - the new height of this Widget
zIndex - the new z-index of this Widget
text - the text to display on the Button
desc - Button.Description

ToggleButton

public ToggleButton(boolean isHeavyWeight,
                    float width,
                    float height,
                    java.lang.String text)
Create a new ToggleButton.

Parameters:
isHeavyWeight -
width - the new width of this Widget
height - the new height of this Widget
zIndex - the new z-index of this Widget
text - the text to display on the Button

ToggleButton

public ToggleButton(boolean isHeavyWeight,
                    float width,
                    float height,
                    java.lang.String text,
                    HUDFont font,
                    org.openmali.vecmath2.Colorf color)
Creates a new ToggleButton.

Parameters:
isHeavyWeight -
width - the new width of this Widget
height - the new height of this Widget
text - the text to display on the Button
font -
color -

ToggleButton

public ToggleButton(boolean isHeavyWeight,
                    float width,
                    float height,
                    java.lang.String text,
                    HUDFont font)
Creates a new ToggleButton.

Parameters:
isHeavyWeight -
width - the new width of this Widget
height - the new height of this Widget
text - the text to display on the Button
font -

ToggleButton

public ToggleButton(boolean isHeavyWeight,
                    float width,
                    float height,
                    java.lang.String text,
                    org.openmali.vecmath2.Colorf color)
Creates a new ToggleButton.

Parameters:
isHeavyWeight -
width - the new width of this Widget
height - the new height of this Widget
text - the text to display on the Button
color -

ToggleButton

public ToggleButton(float width,
                    float height,
                    java.lang.String text,
                    Button.Description desc)
Create a new ToggleButton.

Parameters:
isHeavyWeight -
width - the new width of this Widget
height - the new height of this Widget
zIndex - the new z-index of this Widget
text - the text to display on the Button
desc - Button.Description

ToggleButton

public ToggleButton(float width,
                    float height,
                    java.lang.String text)
Create a new ToggleButton.

Parameters:
width - the new width of this Widget
height - the new height of this Widget
zIndex - the new z-index of this Widget
text - the text to display on the Button

ToggleButton

public ToggleButton(float width,
                    float height,
                    java.lang.String text,
                    HUDFont font,
                    org.openmali.vecmath2.Colorf color)
Creates a new ToggleButton.

Parameters:
width - the new width of this Widget
height - the new height of this Widget
text - the text to display on the Button
font -
color -

ToggleButton

public ToggleButton(float width,
                    float height,
                    java.lang.String text,
                    HUDFont font)
Creates a new ToggleButton.

Parameters:
width - the new width of this Widget
height - the new height of this Widget
text - the text to display on the Button
font -

ToggleButton

public ToggleButton(float width,
                    float height,
                    java.lang.String text,
                    org.openmali.vecmath2.Colorf color)
Creates a new ToggleButton.

Parameters:
width - the new width of this Widget
height - the new height of this Widget
text - the text to display on the Button
color -

ToggleButton

public ToggleButton(boolean isHeavyWeight,
                    float width,
                    float height,
                    Texture2D normalTexture,
                    Texture2D hoveredTexture,
                    Texture2D pressedTexture,
                    java.lang.String text,
                    HUDFont font,
                    org.openmali.vecmath2.Colorf color)
Creates a new Image ToggleButton (textures will simply be streched over the whole Button area).

Parameters:
isHeavyWeight -
width - the new width of this Widget
height - the new height of this Widget
texNormal - the texture for the normal button state
texHovered - the texture for the normal button state
texPressed - the texture for the normal button state
text - the text to display on the Button
font -
color -

ToggleButton

public ToggleButton(boolean isHeavyWeight,
                    float width,
                    float height,
                    java.lang.String normalTexture,
                    java.lang.String hoveredTexture,
                    java.lang.String pressedTexture,
                    java.lang.String text,
                    HUDFont font,
                    org.openmali.vecmath2.Colorf color)
Creates a new Image ToggleButton (textures will simply be streched over the whole Button area).

Parameters:
isHeavyWeight -
width - the new width of this Widget
height - the new height of this Widget
texNormal - the texture for the normal button state
texHovered - the texture for the normal button state
texPressed - the texture for the normal button state
text - the text to display on the Button
font -
color -

ToggleButton

public ToggleButton(boolean isHeavyWeight,
                    float width,
                    float height,
                    Texture2D normalTexture,
                    Texture2D hoveredTexture,
                    Texture2D pressedTexture)
Creates a new Image ToggleButton (textures will simply be streched over the whole Button area).

Parameters:
isHeavyWeight -
width - the new width of this Widget
height - the new height of this Widget
texNormal - the texture for the normal button state
texHovered - the texture for the normal button state
texPressed - the texture for the normal button state

ToggleButton

public ToggleButton(boolean isHeavyWeight,
                    float width,
                    float height,
                    java.lang.String normalTexture,
                    java.lang.String hoveredTexture,
                    java.lang.String pressedTexture)
Creates a new Image ToggleButton (textures will simply be streched over the whole Button area).

Parameters:
isHeavyWeight -
width - the new width of this Widget
height - the new height of this Widget
texNormal - the texture for the normal button state
texHovered - the texture for the normal button state
texPressed - the texture for the normal button state

ToggleButton

public ToggleButton(float width,
                    float height,
                    Texture2D normalTexture,
                    Texture2D hoveredTexture,
                    Texture2D pressedTexture,
                    java.lang.String text,
                    HUDFont font,
                    org.openmali.vecmath2.Colorf color)
Creates a new Image ToggleButton (textures will simply be streched over the whole Button area).

Parameters:
width - the new width of this Widget
height - the new height of this Widget
texNormal - the texture for the normal button state
texHovered - the texture for the normal button state
texPressed - the texture for the normal button state
text - the text to display on the Button
font -
color -

ToggleButton

public ToggleButton(float width,
                    float height,
                    java.lang.String normalTexture,
                    java.lang.String hoveredTexture,
                    java.lang.String pressedTexture,
                    java.lang.String text,
                    HUDFont font,
                    org.openmali.vecmath2.Colorf color)
Creates a new Image ToggleButton (textures will simply be streched over the whole Button area).

Parameters:
width - the new width of this Widget
height - the new height of this Widget
texNormal - the texture for the normal button state
texHovered - the texture for the normal button state
texPressed - the texture for the normal button state
text - the text to display on the Button
font -
color -

ToggleButton

public ToggleButton(float width,
                    float height,
                    Texture2D normalTexture,
                    Texture2D hoveredTexture,
                    Texture2D pressedTexture)
Creates a new Image ToggleButton (textures will simply be streched over the whole Button area).

Parameters:
width - the new width of this Widget
height - the new height of this Widget
texNormal - the texture for the normal button state
texHovered - the texture for the normal button state
texPressed - the texture for the normal button state

ToggleButton

public ToggleButton(float width,
                    float height,
                    java.lang.String normalTexture,
                    java.lang.String hoveredTexture,
                    java.lang.String pressedTexture)
Creates a new Image ToggleButton (textures will simply be streched over the whole Button area).

Parameters:
width - the new width of this Widget
height - the new height of this Widget
texNormal - the texture for the normal button state
texHovered - the texture for the normal button state
texPressed - the texture for the normal button state
Method Detail

setToggled

public void setToggled(boolean toggled)
Sets if the ToggleButton is currently toggled.


isToggled

public final boolean isToggled()
Returns:
true, if the ToggleButton is currently toggled

onMouseEntered

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

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

onMouseExited

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

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

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 AbstractButton
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 AbstractButton
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