|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.xith3d.ui.hud.base.Widget
org.xith3d.ui.hud.base.AbstractButton
org.xith3d.ui.hud.widgets.Button
public class Button
A simple button Widget. You may specify an image for each state (normal, hover, pressed). You may specify a text.
| Nested Class Summary | |
|---|---|
static class |
Button.Description
This class is used to describe a Button Widget. |
| 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 | |
|---|---|
protected static boolean |
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 | |
|---|---|
Button(boolean isHeavyWeight,
float width,
float height,
java.lang.String text)
Creates a new Button. |
|
Button(boolean isHeavyWeight,
float width,
float height,
java.lang.String text,
Button.Description desc)
Creates a new Button. |
|
Button(boolean isHeavyWeight,
float width,
float height,
java.lang.String text,
org.openmali.vecmath2.Colorf color)
Creates a new Button. |
|
Button(boolean isHeavyWeight,
float width,
float height,
java.lang.String text,
HUDFont font)
Creates a new Button. |
|
Button(boolean isHeavyWeight,
float width,
float height,
java.lang.String text,
HUDFont font,
org.openmali.vecmath2.Colorf color)
Creates a new Button. |
|
Button(boolean isHeavyWeight,
float width,
float height,
java.lang.String normalTexture,
java.lang.String hoveredTexture,
java.lang.String pressedTexture)
Creates a new Image Button (textures will simply be streched over the whole Button area). |
|
Button(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 Button (textures will simply be streched over the whole Button area). |
|
Button(boolean isHeavyWeight,
float width,
float height,
Texture2D normalTexture,
Texture2D hoveredTexture,
Texture2D pressedTexture)
Creates a new Image Button (textures will simply be streched over the whole Button area). |
|
Button(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 Button (textures will simply be streched over the whole Button area). |
|
Button(float width,
float height,
java.lang.String text)
Creates a new Button. |
|
Button(float width,
float height,
java.lang.String text,
Button.Description desc)
Creates a new Button. |
|
Button(float width,
float height,
java.lang.String text,
org.openmali.vecmath2.Colorf color)
Creates a new Button. |
|
Button(float width,
float height,
java.lang.String text,
HUDFont font)
Creates a new Button. |
|
Button(float width,
float height,
java.lang.String text,
HUDFont font,
org.openmali.vecmath2.Colorf color)
Creates a new Button. |
|
Button(float width,
float height,
java.lang.String normalTexture,
java.lang.String hoveredTexture,
java.lang.String pressedTexture)
Creates a new Image Button (textures will simply be streched over the whole Button area). |
|
Button(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 Button (textures will simply be streched over the whole Button area). |
|
Button(float width,
float height,
Texture2D normalTexture,
Texture2D hoveredTexture,
Texture2D pressedTexture)
Creates a new Image Button (textures will simply be streched over the whole Button area). |
|
Button(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 Button (textures will simply be streched over the whole Button area). |
|
| Method Summary | ||
|---|---|---|
protected Label |
createCaptionWidget(java.lang.String text,
Label.Description labelDesc)
|
|
protected static Button.Description |
createImageButtonDesc(java.lang.String normalTexture,
java.lang.String hoveredTexture,
java.lang.String pressedTexture,
HUDFont font,
org.openmali.vecmath2.Colorf color)
|
|
protected static Button.Description |
createImageButtonDesc(Texture2D normalTexture,
Texture2D hoveredTexture,
Texture2D pressedTexture,
HUDFont font,
org.openmali.vecmath2.Colorf color)
|
|
protected static Button.Description |
deriveDesc(HUDFont font,
org.openmali.vecmath2.Colorf color)
|
|
protected void |
drawWidget(Texture2DCanvas texCanvas,
int offsetX,
int offsetY,
int width,
int height,
boolean drawsSelf)
|
|
TextAlignment |
getAlignment()
|
|
protected Texture2D |
getCurrentTexture()
Gets the texture for the current buttonstate. |
|
HUDFont |
getFont()
|
|
org.openmali.vecmath2.Colorf |
getFontColor()
|
|
Texture2D |
getIcon()
Gets the icon of this Button. |
|
int |
getIconGap()
Gets the gap between the icon and the text. |
|
|
getOptimalSize(Dim2f_ buffer)
Calculates implementation dependent optimal size for this Button. |
|
java.lang.String |
getText()
|
|
Texture2D |
getTextureHovered()
|
|
Texture2D |
getTextureNormal()
|
|
Texture2D |
getTexturePressed()
|
|
boolean |
hasText()
Returns whether this Button has a text. |
|
protected void |
init()
This method is called when the WidgetContainer is set. |
|
protected void |
onFocusGained()
This event is fired, when the focus is gained to a Widget. |
|
protected void |
onFocusLost()
This event is fired, when the focus is lost by a Widget. |
|
protected void |
onSizeChanged(float oldWidth,
float oldHeight,
float newWidth,
float newHeight)
|
|
void |
setAlignment(TextAlignment align)
Sets the text alignment of the Button's text. |
|
boolean |
setButtonState(AbstractButton.ButtonState buttonState)
Sets the new AbstractButton.ButtonState for this Button. |
|
protected void |
setEnabledImpl(boolean enabled)
|
|
void |
setFont(HUDFont font)
Sets the Font of the Button's text. |
|
void |
setFontColor(org.openmali.vecmath2.Colorf color)
Sets the font-color of the Button's text. |
|
void |
setIcon(java.lang.String icon)
Sets the icon for this Button. |
|
void |
setIcon(Texture2D icon)
Sets the icon for this Button. |
|
void |
setIconGap(int gap)
Sets the gap between the icon and the text. |
|
void |
setText(java.lang.String text)
Sets this Button's text content. |
|
void |
setTextureHovered(java.lang.String resource)
Sets the Texture by resource to be used for HOVERED ButtonState. |
|
void |
setTextureHovered(Texture2D texture)
Sets the Texture to be used for HOVERED ButtonState. |
|
void |
setTextureNormal(java.lang.String resource)
Sets the Texture by resource to be used for NORMAL ButtonState. |
|
void |
setTextureNormal(Texture2D texture)
Sets the Texture to be used for NORMAL ButtonState. |
|
void |
setTexturePressed(java.lang.String resource)
Sets the Texture by resource to be used for PRESSED ButtonState. |
|
void |
setTexturePressed(Texture2D texture)
Sets the Texture to be used for PRESSED ButtonState. |
|
java.lang.String |
toString()
|
|
void |
update()
Updates the Button's images. |
|
| Methods inherited from class org.xith3d.ui.hud.base.AbstractButton |
|---|
addButtonListener, bindAccessor, fireButtonClickedEvent, getButtonState, isDefaultFocusResponsive, isEnabled, isFocusResponsive, onInputStateChanged, onMouseButtonPressed, onMouseButtonReleased, onMouseEntered, onMouseExited, removeButtonListener, setDefaultFocusResponsive, setEnabled, setFocusResponsive, unbindAccessor |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected static final boolean DEFAULT_HEAVYWEIGHT
| Constructor Detail |
|---|
public Button(boolean isHeavyWeight,
float width,
float height,
java.lang.String text,
Button.Description desc)
isHeavyWeight - width - the new width of this Widgetheight - the new height of this Widgettext - the text to display on the Buttondesc - Button.Description
public Button(boolean isHeavyWeight,
float width,
float height,
java.lang.String text)
isHeavyWeight - width - the new width of this Widgetheight - the new height of this Widgettext - the text to display on the Button
public Button(boolean isHeavyWeight,
float width,
float height,
java.lang.String text,
HUDFont font,
org.openmali.vecmath2.Colorf color)
isHeavyWeight - width - the new width of this Widgetheight - the new height of this Widgettext - the text to display on the Buttonfont - color -
public Button(boolean isHeavyWeight,
float width,
float height,
java.lang.String text,
HUDFont font)
isHeavyWeight - width - the new width of this Widgetheight - the new height of this Widgettext - the text to display on the Buttonfont -
public Button(boolean isHeavyWeight,
float width,
float height,
java.lang.String text,
org.openmali.vecmath2.Colorf color)
isHeavyWeight - width - the new width of this Widgetheight - the new height of this Widgettext - the text to display on the Buttoncolor -
public Button(float width,
float height,
java.lang.String text,
Button.Description desc)
width - the new width of this Widgetheight - the new height of this Widgettext - the text to display on the Buttondesc - Button.Description
public Button(float width,
float height,
java.lang.String text)
width - the new width of this Widgetheight - the new height of this Widgettext - the text to display on the Button
public Button(float width,
float height,
java.lang.String text,
HUDFont font,
org.openmali.vecmath2.Colorf color)
width - the new width of this Widgetheight - the new height of this Widgettext - the text to display on the Buttonfont - color -
public Button(float width,
float height,
java.lang.String text,
HUDFont font)
width - the new width of this Widgetheight - the new height of this Widgettext - the text to display on the Buttonfont -
public Button(float width,
float height,
java.lang.String text,
org.openmali.vecmath2.Colorf color)
width - the new width of this Widgetheight - the new height of this Widgettext - the text to display on the Buttoncolor -
public Button(boolean isHeavyWeight,
float width,
float height,
Texture2D normalTexture,
Texture2D hoveredTexture,
Texture2D pressedTexture,
java.lang.String text,
HUDFont font,
org.openmali.vecmath2.Colorf color)
isHeavyWeight - width - the new width of this Widgetheight - the new height of this WidgettexNormal - the texture for the normal button statetexHovered - the texture for the normal button statetexPressed - the texture for the normal button statetext - the text to display on the Buttonfont - color -
public Button(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)
isHeavyWeight - width - the new width of this Widgetheight - the new height of this WidgettexNormal - the texture for the normal button statetexHovered - the texture for the normal button statetexPressed - the texture for the normal button statetext - the text to display on the Buttonfont - color -
public Button(boolean isHeavyWeight,
float width,
float height,
Texture2D normalTexture,
Texture2D hoveredTexture,
Texture2D pressedTexture)
isHeavyWeight - width - the new width of this Widgetheight - the new height of this WidgettexNormal - the texture for the normal button statetexHovered - the texture for the normal button statetexPressed - the texture for the normal button state
public Button(boolean isHeavyWeight,
float width,
float height,
java.lang.String normalTexture,
java.lang.String hoveredTexture,
java.lang.String pressedTexture)
isHeavyWeight - width - the new width of this Widgetheight - the new height of this WidgettexNormal - the texture for the normal button statetexHovered - the texture for the normal button statetexPressed - the texture for the normal button state
public Button(float width,
float height,
Texture2D normalTexture,
Texture2D hoveredTexture,
Texture2D pressedTexture,
java.lang.String text,
HUDFont font,
org.openmali.vecmath2.Colorf color)
width - the new width of this Widgetheight - the new height of this WidgettexNormal - the texture for the normal button statetexHovered - the texture for the normal button statetexPressed - the texture for the normal button statetext - the text to display on the Buttonfont - color -
public Button(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)
width - the new width of this Widgetheight - the new height of this WidgettexNormal - the texture for the normal button statetexHovered - the texture for the normal button statetexPressed - the texture for the normal button statetext - the text to display on the Buttonfont - color -
public Button(float width,
float height,
Texture2D normalTexture,
Texture2D hoveredTexture,
Texture2D pressedTexture)
width - the new width of this Widgetheight - the new height of this WidgettexNormal - the texture for the normal button statetexHovered - the texture for the normal button statetexPressed - the texture for the normal button state
public Button(float width,
float height,
java.lang.String normalTexture,
java.lang.String hoveredTexture,
java.lang.String pressedTexture)
width - the new width of this Widgetheight - the new height of this WidgettexNormal - the texture for the normal button statetexHovered - the texture for the normal button statetexPressed - the texture for the normal button state| Method Detail |
|---|
public void setTextureNormal(Texture2D texture)
texture - the new Texture to usepublic final void setTextureNormal(java.lang.String resource)
resource - the texture resource to usepublic final Texture2D getTextureNormal()
public void setTextureHovered(Texture2D texture)
texture - the new Texture to usepublic final void setTextureHovered(java.lang.String resource)
resource - the texture resource to usepublic final Texture2D getTextureHovered()
public void setTexturePressed(Texture2D texture)
texture - the new Texture to usepublic final void setTexturePressed(java.lang.String resource)
resource - the texture resource to usepublic final Texture2D getTexturePressed()
protected Texture2D getCurrentTexture()
protected void onFocusGained()
onFocusGained in class Widgetprotected void onFocusLost()
onFocusLost in class Widgetpublic void update()
update in class Widgetpublic boolean setButtonState(AbstractButton.ButtonState buttonState)
AbstractButton.ButtonState for this Button.
setButtonState in class AbstractButton
protected void onSizeChanged(float oldWidth,
float oldHeight,
float newWidth,
float newHeight)
onSizeChanged in class Widgetpublic final boolean hasText()
public void setText(java.lang.String text)
setText in interface TextWidgettext - the new Textpublic final java.lang.String getText()
getText in interface TextWidgetpublic void setFont(HUDFont font)
setFont in interface TextWidgetfont - the new Fontpublic final HUDFont getFont()
getFont in interface TextWidgetpublic void setFontColor(org.openmali.vecmath2.Colorf color)
setFontColor in interface TextWidgetcolor - the new Fontpublic final org.openmali.vecmath2.Colorf getFontColor()
getFontColor in interface TextWidgetpublic void setAlignment(TextAlignment align)
setAlignment in interface TextWidgetalign - the new alignmentpublic final TextAlignment getAlignment()
getAlignment in interface TextWidgetpublic void setIcon(Texture2D icon)
icon - public void setIcon(java.lang.String icon)
icon - public final Texture2D getIcon()
public void setIconGap(int gap)
gap - the gap in pixelspublic final int getIconGap()
protected void setEnabledImpl(boolean enabled)
setEnabledImpl in class AbstractButton
protected void drawWidget(Texture2DCanvas texCanvas,
int offsetX,
int offsetY,
int width,
int height,
boolean drawsSelf)
drawWidget in class Widgetpublic <Dim2f_ extends org.openmali.types.twodee.Dim2f> Dim2f_ getOptimalSize(Dim2f_ buffer)
getOptimalSize in class AbstractButtonpublic java.lang.String toString()
toString in class Widgetprotected void init()
init in class Widget
protected Label createCaptionWidget(java.lang.String text,
Label.Description labelDesc)
protected static Button.Description deriveDesc(HUDFont font,
org.openmali.vecmath2.Colorf color)
protected static Button.Description createImageButtonDesc(Texture2D normalTexture,
Texture2D hoveredTexture,
Texture2D pressedTexture,
HUDFont font,
org.openmali.vecmath2.Colorf color)
protected static Button.Description createImageButtonDesc(java.lang.String normalTexture,
java.lang.String hoveredTexture,
java.lang.String pressedTexture,
HUDFont font,
org.openmali.vecmath2.Colorf color)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||