com.threerings.opengl.gui
Class ToggleButton

java.lang.Object
  extended by com.threerings.opengl.gui.Component
      extended by com.threerings.opengl.gui.TextComponent
          extended by com.threerings.opengl.gui.Label
              extended by com.threerings.opengl.gui.Button
                  extended by com.threerings.opengl.gui.ToggleButton
All Implemented Interfaces:
ConfigUpdateListener<ManagedConfig>, UIConstants
Direct Known Subclasses:
CheckBox

public class ToggleButton
extends Button

Like a Button except that it toggles between two states (selected and normal) when clicked.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.threerings.opengl.gui.Label
Label.Fit
 
Field Summary
protected  boolean _selected
          Used to track whether we are selected or not.
static int DISSELECTED
          Indicates that this button is in the selected state and is disabled.
static int HOVER_SELECTED
          Indicates that this button is in the selected state and hovered.
static int SELECTED
          Indicates that this button is in the selected state.
protected static int STATE_COUNT
           
protected static String[] STATE_PCLASSES
           
 
Fields inherited from class com.threerings.opengl.gui.Button
_action, _argument, _feedbackSounds, _pressed, _releasedWhen, DOWN
 
Fields inherited from class com.threerings.opengl.gui.Label
_label
 
Fields inherited from class com.threerings.opengl.gui.TextComponent
_effcols, _effsizes, _haligns, _lineSpacings, _teffects, _textfacts, _valigns
 
Fields inherited from class com.threerings.opengl.gui.Component
_alpha, _backgrounds, _borders, _colors, _ctx, _cursor, _enabled, _height, _hover, _hoverable, _insets, _listeners, _parent, _preferredSize, _properties, _rect, _styleConfigs, _tipmouse, _tiptext, _tooltipStyle, _transferHandler, _valid, _visible, _width, _x, _y, DEFAULT, DISABLED, HOVER
 
Fields inherited from interface com.threerings.opengl.gui.UIConstants
BOTTOM, CENTER, DEFAULT_SIZE, DEFAULT_SPACING, GLOW, HORIZONTAL, LEFT, NORMAL, OUTLINE, OVERLAPPING, PLAIN, RIGHT, SHADOW, TOP, VERTICAL
 
Constructor Summary
ToggleButton(GlContext ctx, Icon icon, String action)
          Creates a button with the specified icon and action.
ToggleButton(GlContext ctx, String text)
          Creates a button with the specified textual label.
ToggleButton(GlContext ctx, String text, String action)
          Creates a button with the specified label and action.
 
Method Summary
protected  void fireAction(long when, int modifiers)
          Called when the button is "clicked" which may due to the mouse being pressed and released while over the button or due to keyboard manipulation while the button has focus.
protected  int getFallbackState(int state)
          Returns the fallback to use for the specified state if no explicit style was given.
 int getState()
          Returns the state of this component, either Component.DEFAULT or Component.DISABLED.
protected  int getStateCount()
          Returns the number of different states that this component can take.
protected  String getStatePseudoClass(int state)
          Returns the pseudoclass identifier for the specified component state.
 boolean isSelected()
          Returns whether or not this button is in the selected state.
 void setSelected(boolean selected)
          Configures the selected state of this button.
 
Methods inherited from class com.threerings.opengl.gui.Button
dispatchEvent, doClick, getAction, getArgument, getDefaultStyleConfig, getFeedbackSound, playFeedbackSound, setAction, setArgument, updateFromStyleConfig
 
Methods inherited from class com.threerings.opengl.gui.Label
computePreferredSize, getFit, getIcon, getIconTextGap, getLabelRenderer, getText, layout, renderComponent, setFit, setIcon, setIconTextGap, setOrientation, setPreferredWidth, setText, setTextRotation
 
Methods inherited from class com.threerings.opengl.gui.TextComponent
getEffectColor, getEffectSize, getHorizontalAlignment, getLabelRendererConfig, getLineSpacing, getTextEffect, getTextFactory, getTextFactory, getVerticalAlignment
 
Methods inherited from class com.threerings.opengl.gui.Component
acceptsFocus, addListener, boundsToString, changeCursor, configUpdated, contains, createDefaultTooltipComponent, createDefaultTooltipComponent, createTooltipComponent, emitEvent, getAbsoluteX, getAbsoluteY, getAlpha, getBackground, getBorder, getBounds, getColor, getContext, getCursor, getFirstDescendantFocus, getFocusTarget, getHeight, getHitComponent, getInsets, getLastDescendantFocus, getNextFocus, getParent, getPreferredSize, getPreviousFocus, getProperty, getStyleConfigs, getTooltipText, getTooltipTimeout, getTooltipWindowStyle, getTransferHandler, getWidth, getWindow, getX, getY, hasFocus, intersectScissor, invalidate, isAdded, isEnabled, isHoverable, isShowing, isTooltipRelativeToMouse, isValid, isVisible, removeAllListeners, removeAllListeners, removeListener, render, renderBackground, renderBorder, requestFocus, scrollRectToVisible, scrollRectToVisible, setAlpha, setBackground, setBounds, setCursor, setEnabled, setHoverable, setLocation, setParent, setPreferredSize, setPreferredSize, setProperty, setSize, setStyleConfig, setStyleConfig, setStyleConfig, setStyleConfigs, setTooltipRelativeToMouse, setTooltipText, setTransferHandler, setVisible, stateDidChange, updateCursor, updateFromStyleConfig, validate, wasAdded, wasRemoved
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SELECTED

public static final int SELECTED
Indicates that this button is in the selected state.

See Also:
Constant Field Values

HOVER_SELECTED

public static final int HOVER_SELECTED
Indicates that this button is in the selected state and hovered.

See Also:
Constant Field Values

DISSELECTED

public static final int DISSELECTED
Indicates that this button is in the selected state and is disabled.

See Also:
Constant Field Values

_selected

protected boolean _selected
Used to track whether we are selected or not.


STATE_COUNT

protected static final int STATE_COUNT
See Also:
Constant Field Values

STATE_PCLASSES

protected static final String[] STATE_PCLASSES
Constructor Detail

ToggleButton

public ToggleButton(GlContext ctx,
                    String text)
Creates a button with the specified textual label.


ToggleButton

public ToggleButton(GlContext ctx,
                    String text,
                    String action)
Creates a button with the specified label and action. The action will be dispatched via an ActionEvent when the button changes state.


ToggleButton

public ToggleButton(GlContext ctx,
                    Icon icon,
                    String action)
Creates a button with the specified icon and action. The action will be dispatched via an ActionEvent when the button changes state.

Method Detail

isSelected

public boolean isSelected()
Returns whether or not this button is in the selected state.


setSelected

public void setSelected(boolean selected)
Configures the selected state of this button.


getState

public int getState()
Description copied from class: Component
Returns the state of this component, either Component.DEFAULT or Component.DISABLED.

Overrides:
getState in class Button

getStateCount

protected int getStateCount()
Description copied from class: Component
Returns the number of different states that this component can take. These states correspond to stylesheet pseudoclasses that allow components to customize their configuration based on whether they are enabled or disabled, or pressed if they are a button, etc.

Overrides:
getStateCount in class Button

getStatePseudoClass

protected String getStatePseudoClass(int state)
Description copied from class: Component
Returns the pseudoclass identifier for the specified component state. This string will be the way that the state is identified in the associated stylesheet. For example, the Component.DISABLED state maps to disabled and is configured like so:
 component:disabled {
    color: #CCCCCC; // etc.
 }
 

Overrides:
getStatePseudoClass in class Button

getFallbackState

protected int getFallbackState(int state)
Description copied from class: Component
Returns the fallback to use for the specified state if no explicit style was given.

Overrides:
getFallbackState in class Component

fireAction

protected void fireAction(long when,
                          int modifiers)
Description copied from class: Button
Called when the button is "clicked" which may due to the mouse being pressed and released while over the button or due to keyboard manipulation while the button has focus.

Overrides:
fireAction in class Button