Wt examples  3.3.8
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
IconPair Class Reference

An icon pair (identical to WIconPair) More...

#include <IconPair.h>

Inheritance diagram for IconPair:
Inheritance graph
[legend]

Public Member Functions

 IconPair (const std::string icon1URI, const std::string icon2URI, bool clickIsSwitch=true, Wt::WContainerWidget *parent=0)
 Construct a two-state icon widget. More...
 
void setState (int num)
 Set which icon should be visible. More...
 
int state () const
 Get the current state. More...
 
Wt::WImageicon1 () const
 Get the first icon image. More...
 
Wt::WImageicon2 () const
 Get the second icon image. More...
 
void showIcon1 ()
 Set state to 0 (show icon 1). More...
 
void showIcon2 ()
 Set state to 1 (show icon 2). More...
 
- Public Member Functions inherited from Wt::WCompositeWidget
 WCompositeWidget (WContainerWidget *parent=0)
 
 WCompositeWidget (WWidget *implementation, WContainerWidget *parent)
 
virtual void setObjectName (const std::string &name)
 
virtual std::string objectName () const
 
virtual const std::string id () const
 
virtual void setPositionScheme (PositionScheme scheme)
 
virtual PositionScheme positionScheme () const
 
virtual void setOffsets (const WLength &offset, WFlags< Side > sides=All)
 
virtual WLength offset (Side s) const
 
virtual void resize (const WLength &width, const WLength &height)
 
virtual WLength width () const
 
virtual WLength height () const
 
virtual void setMinimumSize (const WLength &width, const WLength &height)
 
virtual WLength minimumWidth () const
 
virtual WLength minimumHeight () const
 
virtual void setMaximumSize (const WLength &width, const WLength &height)
 
virtual WLength maximumWidth () const
 
virtual WLength maximumHeight () const
 
virtual void setLineHeight (const WLength &height)
 
virtual WLength lineHeight () const
 
virtual void setFloatSide (Side s)
 
virtual Side floatSide () const
 
virtual void setClearSides (WFlags< Side > sides)
 
virtual WFlags< SideclearSides () const
 
virtual void setMargin (const WLength &margin, WFlags< Side > sides=All)
 
virtual WLength margin (Side side) const
 
virtual void setHiddenKeepsGeometry (bool enabled)
 
virtual bool hiddenKeepsGeometry () const
 
virtual void setHidden (bool hidden, const WAnimation &animation=WAnimation())
 
virtual bool isHidden () const
 
virtual bool isVisible () const
 
virtual void setDisabled (bool disabled)
 
virtual bool isDisabled () const
 
virtual bool isEnabled () const
 
virtual void setPopup (bool popup)
 
virtual bool isPopup () const
 
virtual void setInline (bool isInline)
 
virtual bool isInline () const
 
virtual void setDecorationStyle (const WCssDecorationStyle &style)
 
virtual WCssDecorationStyledecorationStyle ()
 
virtual void setStyleClass (const WString &styleClass)
 
virtual WString styleClass () const
 
virtual void addStyleClass (const WString &styleClass, bool force=false)
 
virtual void removeStyleClass (const WString &styleClass, bool force=false)
 
virtual bool hasStyleClass (const WString &styleClass) const
 
virtual void setVerticalAlignment (AlignmentFlag alignment, const WLength &length=WLength::Auto)
 
virtual AlignmentFlag verticalAlignment () const
 
virtual WLength verticalAlignmentLength () const
 
virtual void setToolTip (const WString &text, TextFormat textFormat=PlainText)
 
virtual WString toolTip () const
 
virtual void setDeferredToolTip (bool enable, TextFormat textFormat=PlainText)
 
virtual void refresh ()
 
virtual void setAttributeValue (const std::string &name, const WString &value)
 
virtual WString attributeValue (const std::string &name) const
 
virtual void setJavaScriptMember (const std::string &name, const std::string &value)
 
virtual std::string javaScriptMember (const std::string &name) const
 
virtual void callJavaScriptMember (const std::string &name, const std::string &args)
 
virtual void load ()
 
virtual bool loaded () const
 
virtual void setCanReceiveFocus (bool enabled)
 
virtual bool canReceiveFocus () const
 
virtual void setFocus (bool focus)
 
virtual bool setFirstFocus ()
 
virtual bool hasFocus () const
 
virtual void setTabIndex (int index)
 
virtual int tabIndex () const
 
virtual void setId (const std::string &id)
 
virtual WWidgetfind (const std::string &name)
 
virtual WWidgetfindById (const std::string &name)
 
virtual void setSelectable (bool selectable)
 
virtual void doJavaScript (const std::string &js)
 
virtual void propagateSetEnabled (bool enabled)
 
virtual bool scrollVisibilityEnabled () const WT_CXX11ONLY(finaloverride)
 
virtual void setScrollVisibilityEnabled (bool enabled) WT_CXX11ONLY(finaloverride)
 
virtual int scrollVisibilityMargin () const WT_CXX11ONLY(finaloverride)
 
virtual void setScrollVisibilityMargin (int margin) WT_CXX11ONLY(finaloverride)
 
virtual Signal< bool > & scrollVisibilityChanged () WT_CXX11ONLY(finaloverride)
 
virtual bool isScrollVisible () const WT_CXX11ONLY(finaloverride)
 
virtual void setThemeStyleEnabled (bool enabled)
 
virtual bool isThemeStyleEnabled () const
 
- Public Member Functions inherited from Wt::WWidget
virtual ~WWidget ()
 
WWidgetparent () const
 
virtual void removeChild (WObject *child)
 
void setWidth (const WLength &width)
 
void setHeight (const WLength &height)
 
virtual void positionAt (const WWidget *widget, Orientation orientation=Vertical)
 
virtual void toggleStyleClass (const WString &styleClass, bool add, bool force=false)
 
std::string jsRef () const
 
void setFocus ()
 
virtual void acceptDrops (const std::string &mimeType, const WString &hoverStyleClass=WString())
 
virtual void stopAcceptDrops (const std::string &mimeType)
 
virtual void htmlText (std::ostream &out)
 
bool isRendered () const
 
void hide ()
 
void animateHide (const WAnimation &animation)
 
void show ()
 
void animateShow (const WAnimation &animation)
 
void enable ()
 
void disable ()
 
bool layoutSizeAware () const
 
- Public Member Functions inherited from Wt::WObject
 WObject (WObject *parent=0)
 
virtual ~WObject ()
 
void resetLearnedSlots ()
 
void resetLearnedSlot (void(T::*method)())
 
WStatelessSlot * implementStateless (void(T::*method)())
 
WStatelessSlot * implementStateless (void(T::*method)(), void(T::*undoMethod)())
 
void isNotStateless ()
 
WStatelessSlot * implementJavaScript (void(T::*method)(), const std::string &jsCode)
 
void addChild (WObject *child)
 
const std::vector< WObject * > & children () const
 
WObjectparent () const
 

Public Attributes

Wt::EventSignal< Wt::WMouseEvent > & icon1Clicked
 Signal emitted when clicked while in state 0 (icon 1 is shown). More...
 
Wt::EventSignal< Wt::WMouseEvent > & icon2Clicked
 Signal emitted when clicked while in state 1 (icon 2 is shown). More...
 

Private Member Functions

void undoShowIcon1 ()
 Undo function for prelearning showIcon1() More...
 
void undoShowIcon2 ()
 Undo function for prelearning showIcon2() More...
 

Private Attributes

Wt::WContainerWidgetimpl_
 
Wt::WImageicon1_
 First icon. More...
 
Wt::WImageicon2_
 Second icon. More...
 
int previousState_
 Undo state for prelearning stateless showIcon1() and showIcon2() slots. More...
 

Additional Inherited Members

- Public Types inherited from Wt::WObject
typedef void(WObject::* Method) ()
 
- Static Public Member Functions inherited from Wt::WWidget
static WString tr (const char *key)
 
- Protected Member Functions inherited from Wt::WCompositeWidget
virtual void enableAjax ()
 
void setImplementation (WWidget *widget)
 
WWidgetimplementation ()
 
virtual int boxPadding (Orientation orientation) const
 
virtual int boxBorder (Orientation orientation) const
 
virtual void render (WFlags< RenderFlag > flags)
 
- Protected Member Functions inherited from Wt::WWidget
void setLayoutSizeAware (bool sizeAware)
 
virtual void layoutSizeChanged (int width, int height)
 
 WWidget (WContainerWidget *parent=0)
 
virtual void dropEvent (WDropEvent dropEvent)
 
void scheduleRender (WFlags< RepaintFlag > flags=0)
 
virtual WStatelessSlot * getStateless (Method method)
 
- Static Protected Member Functions inherited from Wt::WObject
static WObjectsender ()
 

Detailed Description

An icon pair (identical to WIconPair)

This widget manages two images, only one of which is shown at a single time.

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

This widget is part of the Wt treelist example, where it is used to represent the expand/collapse icons, and the corresponding map open/close icon.

See also
TreeNode

Definition at line 34 of file IconPair.h.

Constructor & Destructor Documentation

IconPair::IconPair ( const std::string  icon1URI,
const std::string  icon2URI,
bool  clickIsSwitch = true,
Wt::WContainerWidget parent = 0 
)

Construct a two-state icon widget.

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

Definition at line 12 of file IconPair.C.

14  : Wt::WCompositeWidget(parent),
16  icon1_(new Wt::WImage(icon1URI, impl_)),
17  icon2_(new Wt::WImage(icon2URI, impl_)),
20 {
22 
25 
26  setInline(true);
27 
28  icon2_->hide();
29 
30  if (clickIsSwitch) {
31  icon1_->clicked().connect(icon1_, &Wt::WImage::hide);
32  icon1_->clicked().connect(icon2_, &Wt::WImage::show);
33 
34  icon2_->clicked().connect(icon2_, &Wt::WImage::hide);
35  icon2_->clicked().connect(icon1_, &Wt::WImage::show); //
36 
38  }
39 } //
EventSignal< WMouseEvent > & clicked()
virtual void setInline(bool isInline)
void setCursor(Cursor c)
Wt::WContainerWidget * impl_
Definition: IconPair.h:76
void setImplementation(WWidget *widget)
WStatelessSlot * implementStateless(void(T::*method)())
Wt::EventSignal< Wt::WMouseEvent > & icon1Clicked
Signal emitted when clicked while in state 0 (icon 1 is shown).
Definition: IconPair.h:88
PointingHandCursor
void undoShowIcon2()
Undo function for prelearning showIcon2()
Definition: IconPair.C:74
Wt::EventSignal< Wt::WMouseEvent > & icon2Clicked
Signal emitted when clicked while in state 1 (icon 2 is shown).
Definition: IconPair.h:93
Wt::WImage * icon2_
Second icon.
Definition: IconPair.h:82
void showIcon2()
Set state to 1 (show icon 2).
Definition: IconPair.C:63
void undoShowIcon1()
Undo function for prelearning showIcon1()
Definition: IconPair.C:69
virtual WCssDecorationStyle & decorationStyle()
void showIcon1()
Set state to 0 (show icon 1).
Definition: IconPair.C:57
Wt::WImage * icon1_
First icon.
Definition: IconPair.h:79

Member Function Documentation

Wt::WImage* IconPair::icon1 ( ) const
inline

Get the first icon image.

Definition at line 61 of file IconPair.h.

61 { return icon1_; }
Wt::WImage * icon1_
First icon.
Definition: IconPair.h:79
Wt::WImage* IconPair::icon2 ( ) const
inline

Get the second icon image.

Definition at line 65 of file IconPair.h.

65 { return icon2_; }
Wt::WImage * icon2_
Second icon.
Definition: IconPair.h:82
void IconPair::setState ( int  num)

Set which icon should be visible.

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

See also
state()

Definition at line 41 of file IconPair.C.

42 {
43  if (num == 0) {
44  icon1_->show();
45  icon2_->hide();
46  } else {
47  icon1_->hide();
48  icon2_->show();
49  }
50 }
Wt::WImage * icon2_
Second icon.
Definition: IconPair.h:82
Wt::WImage * icon1_
First icon.
Definition: IconPair.h:79
void IconPair::showIcon1 ( )

Set state to 0 (show icon 1).

Definition at line 57 of file IconPair.C.

58 {
59  previousState_ = (icon1_->isHidden() ? 1 : 0);
60  setState(0);
61 }
void setState(int num)
Set which icon should be visible.
Definition: IconPair.C:41
int previousState_
Undo state for prelearning stateless showIcon1() and showIcon2() slots.
Definition: IconPair.h:97
virtual bool isHidden() const
Wt::WImage * icon1_
First icon.
Definition: IconPair.h:79
void IconPair::showIcon2 ( )

Set state to 1 (show icon 2).

Definition at line 63 of file IconPair.C.

64 {
65  previousState_ = (icon1_->isHidden() ? 1 : 0);
66  setState(1);
67 }
void setState(int num)
Set which icon should be visible.
Definition: IconPair.C:41
int previousState_
Undo state for prelearning stateless showIcon1() and showIcon2() slots.
Definition: IconPair.h:97
virtual bool isHidden() const
Wt::WImage * icon1_
First icon.
Definition: IconPair.h:79
int IconPair::state ( ) const

Get the current state.

See also
setState()

Definition at line 52 of file IconPair.C.

53 {
54  return (icon1_->isHidden() ? 1 : 0);
55 }
virtual bool isHidden() const
Wt::WImage * icon1_
First icon.
Definition: IconPair.h:79
void IconPair::undoShowIcon1 ( )
private

Undo function for prelearning showIcon1()

Definition at line 69 of file IconPair.C.

70 {
72 }
void setState(int num)
Set which icon should be visible.
Definition: IconPair.C:41
int previousState_
Undo state for prelearning stateless showIcon1() and showIcon2() slots.
Definition: IconPair.h:97
void IconPair::undoShowIcon2 ( )
private

Undo function for prelearning showIcon2()

Definition at line 74 of file IconPair.C.

75 {
77 } //
void setState(int num)
Set which icon should be visible.
Definition: IconPair.C:41
int previousState_
Undo state for prelearning stateless showIcon1() and showIcon2() slots.
Definition: IconPair.h:97

Member Data Documentation

Wt::WImage* IconPair::icon1_
private

First icon.

Definition at line 79 of file IconPair.h.

Wt::EventSignal<Wt::WMouseEvent>& IconPair::icon1Clicked

Signal emitted when clicked while in state 0 (icon 1 is shown).

Definition at line 88 of file IconPair.h.

Wt::WImage* IconPair::icon2_
private

Second icon.

Definition at line 82 of file IconPair.h.

Wt::EventSignal<Wt::WMouseEvent>& IconPair::icon2Clicked

Signal emitted when clicked while in state 1 (icon 2 is shown).

Definition at line 93 of file IconPair.h.

Wt::WContainerWidget* IconPair::impl_
private

Definition at line 76 of file IconPair.h.

int IconPair::previousState_
private

Undo state for prelearning stateless showIcon1() and showIcon2() slots.

Definition at line 97 of file IconPair.h.


The documentation for this class was generated from the following files:

Generated on Mon Sep 4 2017 for the C++ Web Toolkit (Wt) by doxygen 1.8.11