Class WIconPair
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
An enumeration describing a type of icon.Nested classes/interfaces inherited from class eu.webtoolkit.jwt.WObject
WObject.FormData
-
Constructor Summary
ConstructorsConstructorDescriptionConstruct an icon pair from the two icons.Construct an icon pair from the two icons.WIconPair
(String icon1Str, String icon2Str, boolean clickIsSwitch, WContainerWidget parentContainer) Construct an icon pair from the two icons. -
Method Summary
Modifier and TypeMethodDescriptiongetIcon1()
getIcon2()
eu.webtoolkit.jwt.WIcon
Returns the first icon as WIcon.eu.webtoolkit.jwt.WIcon
Returns the second icon as WIcon.int
getState()
Returns the current state.Returns the first icon asWImage
.Returns the second icon asWImage
.Signal emitted when clicked while in state 0 (icon 1 is shown).Signal emitted when clicked while in state 1 (icon 2 is shown).void
Sets the IconType of the first icon.void
Sets the IconType of the second icon.void
Sets the IconType of the both icons.void
setState
(int num) Sets the state, which determines the visible icon.void
Sets the state to 0 (show icon 1).void
Sets the state to 1 (show icon 2).Methods inherited from class eu.webtoolkit.jwt.WCompositeWidget
addStyleClass, boxBorder, boxPadding, callJavaScriptMember, doJavaScript, enableAjax, find, findById, getAttributeValue, getBaseZIndex, getChildren, getClearSides, getDecorationStyle, getFloatSide, getHeight, getId, getImplementation, getJavaScriptMember, getLineHeight, getMargin, getMaximumHeight, getMaximumWidth, getMinimumHeight, getMinimumWidth, getObjectName, getOffset, getPositionScheme, getScrollVisibilityMargin, getStyleClass, getTabIndex, getTakeImplementation, getToolTip, getVerticalAlignment, getVerticalAlignmentLength, getWidth, hasFocus, hasStyleClass, isCanReceiveFocus, isDisabled, isEnabled, isHidden, isHiddenKeepsGeometry, isInline, isLoaded, isPopup, isScrollVisibilityEnabled, isScrollVisible, isSetFirstFocus, isThemeStyleEnabled, isVisible, load, propagateSetEnabled, propagateSetVisible, refresh, remove, removeStyleClass, removeWidget, render, resize, scrollVisibilityChanged, setAttributeValue, setCanReceiveFocus, setClearSides, setDecorationStyle, setDeferredToolTip, setDisabled, setFloatSide, setFocus, setHidden, setHiddenKeepsGeometry, setId, setImplementation, setInline, setJavaScriptMember, setLineHeight, setMargin, setMaximumSize, setMinimumSize, setObjectName, setOffsets, setPopup, setPositionScheme, setScrollVisibilityEnabled, setScrollVisibilityMargin, setSelectable, setStyleClass, setTabIndex, setThemeStyleEnabled, setToolTip, setVerticalAlignment
Methods inherited from class eu.webtoolkit.jwt.WWidget
acceptDrops, acceptDrops, addCssRule, addCssRule, addJSignal, addStyleClass, animateHide, animateShow, createJavaScript, disable, dropEvent, enable, getDropTouch, getJsRef, getParent, hide, htmlText, isExposed, isGlobalWidget, isLayoutSizeAware, isRendered, layoutSizeChanged, needsRerender, positionAt, positionAt, removeFromParent, removeStyleClass, render, resize, scheduleRender, scheduleRender, scheduleRender, setClearSides, setDeferredToolTip, setFocus, 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
setFormData
-
Constructor Details
-
WIconPair
public WIconPair(String icon1Str, String icon2Str, boolean clickIsSwitch, WContainerWidget parentContainer) Construct an icon pair from the two icons.The constructor takes the URL or the Font Awesome name of the two icons. When
clickIsSwitch
is settrue
, clicking on the icon will switch state.Note: The Font Aweswome name can be followed by sizing information separated by a space if the Font Aweswome version used allows it. A valid icon can look like this for example:
"fa-solid fa-camera fa-1x"
, or"fa-solid fa-camera fa-sm"
(valid for version v6.7.2). More sizing information can be found on https://docs.fontawesome.com/web/style/size.Warning: By default, the strings are considered to represent the URIs of the icons. Use
setIcon1Type()
andsetIcon2Type()
to change the IconType accordingly if it is not what the string represents. Both can be set at once using setIconTypes(). -
WIconPair
Construct an icon pair from the two icons.Calls
this(icon1Str, icon2Str, true, (WContainerWidget)null)
-
WIconPair
Construct an icon pair from the two icons.Calls
this(icon1Str, icon2Str, clickIsSwitch, (WContainerWidget)null)
-
-
Method Details
-
setIcon1Type
Sets the IconType of the first icon.- See Also:
-
setIcon2Type
Sets the IconType of the second icon.- See Also:
-
setIconsType
-
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
public int getState()Returns the current state.- See Also:
-
getIcon1
-
getIcon2
-
getUriIcon1
Returns the first icon asWImage
.If first icon type is
URI
returns the first icon asWImage
, otherwise returns nullptr.- See Also:
-
getUriIcon2
Returns the second icon asWImage
.If second icon type is
URI
returns the second icon asWImage
, otherwise returns nullptr.- See Also:
-
getIconNameIcon1
public eu.webtoolkit.jwt.WIcon getIconNameIcon1()Returns the first icon as WIcon.If first icon type is
IconName
returns the first icon as WIcon, otherwise returns nullptr.- See Also:
-
getIconNameIcon2
public eu.webtoolkit.jwt.WIcon getIconNameIcon2()Returns the second icon as WIcon.If second icon type is
IconName
returns the second icon as WIcon, otherwise returns nullptr.- See Also:
-
showIcon1
public void showIcon1()Sets the state to 0 (show icon 1).- See Also:
-
showIcon2
public void showIcon2()Sets the state to 1 (show icon 2).- See Also:
-
icon1Clicked
Signal emitted when clicked while in state 0 (icon 1 is shown).Equivalent to:
icon1().clicked()
-
icon2Clicked
Signal emitted when clicked while in state 1 (icon 2 is shown).Equivalent to:
icon2().clicked()
-