eu.webtoolkit.jwt
Class WIconPair

java.lang.Object
  extended by eu.webtoolkit.jwt.WObject
      extended by eu.webtoolkit.jwt.WWidget
          extended by eu.webtoolkit.jwt.WCompositeWidget
              extended by eu.webtoolkit.jwt.WIconPair

public class WIconPair
extends WCompositeWidget

A widget that shows one of two icons depending on its state.

This is a utility class that simply manages two images, only one of which is shown at a single time, which reflects the current 'state'.

The widget may react to click events, by changing state.

CSS

This widget does not provide styling, and can be styled using inline or external CSS as appropriate. The image may be styled via the <img> elements.


Constructor Summary
WIconPair(java.lang.String icon1URI, java.lang.String icon2URI)
          Construct an icon pair from the two icons.
WIconPair(java.lang.String icon1URI, java.lang.String icon2URI, boolean clickIsSwitch)
          Construct an icon pair from the two icons.
WIconPair(java.lang.String icon1URI, java.lang.String icon2URI, boolean clickIsSwitch, WContainerWidget parent)
          Construct an icon pair from the two icons.
 
Method Summary
 WImage getIcon1()
          Returns the first icon image.
 WImage getIcon2()
          Returns the second icon image.
 int getState()
          Returns the current state.
 EventSignal1<WMouseEvent> icon1Clicked()
          Signal emitted when clicked while in state 0 (icon 1 is shown).
 EventSignal1<WMouseEvent> icon2Clicked()
          Signal emitted when clicked while in state 1 (icon 2 is shown).
 void setState(int num)
          Sets the state, which determines the visible icon.
 void showIcon1()
          Sets the state to 0 (show icon 1).
 void showIcon2()
          Sets the state to 1 (show icon 2).
 
Methods inherited from class eu.webtoolkit.jwt.WCompositeWidget
addStyleClass, boxBorder, boxPadding, callJavaScriptMember, doJavaScript, enableAjax, find, getAttributeValue, getClearSides, getDecorationStyle, getFloatSide, getHeight, getId, getImplementation, getJavaScriptMember, getLineHeight, getMargin, getMaximumHeight, getMaximumWidth, getMinimumHeight, getMinimumWidth, getOffset, getPositionScheme, getStyleClass, getTabIndex, getToolTip, getVerticalAlignment, getVerticalAlignmentLength, getWidth, isDisabled, isEnabled, isHidden, isHiddenKeepsGeometry, isInline, isLoaded, isPopup, isVisible, load, propagateSetEnabled, refresh, remove, removeStyleClass, resize, setAttributeValue, setClearSides, setDecorationStyle, setDisabled, setFloatSide, setHidden, setHiddenKeepsGeometry, setId, setImplementation, setInline, setJavaScriptMember, setLineHeight, setMargin, setMaximumSize, setMinimumSize, setOffsets, setPopup, setPositionScheme, setSelectable, setStyleClass, setTabIndex, setToolTip, setVerticalAlignment
 
Methods inherited from class eu.webtoolkit.jwt.WWidget
acceptDrops, acceptDrops, addCssRule, addCssRule, addStyleClass, animateHide, animateShow, containsExposed, disable, dropEvent, enable, getDrop, getJsRef, getParent, hide, htmlText, isLayoutSizeAware, isRendered, layoutSizeChanged, positionAt, positionAt, removeStyleClass, resize, setClearSides, setHeight, setHidden, setLayoutSizeAware, setMargin, setMargin, setMargin, setMargin, setMargin, setOffsets, setOffsets, setOffsets, setOffsets, setOffsets, setToolTip, setVerticalAlignment, setWidth, show, stopAcceptDrops, toggleStyleClass, toggleStyleClass, tr
 
Methods inherited from class eu.webtoolkit.jwt.WObject
addChild, getObjectName, setObjectName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WIconPair

public WIconPair(java.lang.String icon1URI,
                 java.lang.String icon2URI,
                 boolean clickIsSwitch,
                 WContainerWidget parent)
Construct an icon pair from the two icons.

The constructor takes the URL of the two icons. When clickIsSwitch is set true, clicking on the icon will switch state.


WIconPair

public WIconPair(java.lang.String icon1URI,
                 java.lang.String icon2URI)
Construct an icon pair from the two icons.

Calls this(icon1URI, icon2URI, true, (WContainerWidget)null)


WIconPair

public WIconPair(java.lang.String icon1URI,
                 java.lang.String icon2URI,
                 boolean clickIsSwitch)
Construct an icon pair from the two icons.

Calls this(icon1URI, icon2URI, clickIsSwitch, (WContainerWidget)null)

Method Detail

setState

public void setState(int num)
Sets the state, which determines the visible icon.

The first icon has number 0, and the second icon has number 1.

The default state is 0.

See Also:
getState()

getState

public int getState()
Returns the current state.

See Also:
setState(int num)

getIcon1

public WImage getIcon1()
Returns the first icon image.


getIcon2

public WImage getIcon2()
Returns the second icon image.


showIcon1

public void showIcon1()
Sets the state to 0 (show icon 1).

See Also:
setState(int num)

showIcon2

public void showIcon2()
Sets the state to 1 (show icon 2).

See Also:
setState(int num)

icon1Clicked

public EventSignal1<WMouseEvent> icon1Clicked()
Signal emitted when clicked while in state 0 (icon 1 is shown).

Equivalent to:

 icon1().clicked()
   
 


icon2Clicked

public EventSignal1<WMouseEvent> icon2Clicked()
Signal emitted when clicked while in state 1 (icon 2 is shown).

Equivalent to:

 icon2().clicked()