Wt examples  3.3.0
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 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

- Protected Member Functions inherited from Wt::WWidget
virtual void enableAjax ()=0
 
virtual void propagateSetEnabled (bool enabled)=0
 
virtual void render (WFlags< RenderFlag > flags)
 

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_)),
18  icon1Clicked(icon1_->clicked()),
19  icon2Clicked(icon2_->clicked())
20 {
21  setImplementation(impl_);
22 
23  implementStateless(&IconPair::showIcon1, &IconPair::undoShowIcon1);
24  implementStateless(&IconPair::showIcon2, &IconPair::undoShowIcon2);
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 } //

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* IconPair::icon2 ( ) const
inline

Get the second icon image.

Definition at line 65 of file IconPair.h.

65 { return icon2_; }
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 }
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 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 }
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 }
void IconPair::undoShowIcon1 ( )
private

Undo function for prelearning showIcon1()

Definition at line 69 of file IconPair.C.

70 {
72 }
void IconPair::undoShowIcon2 ( )
private

Undo function for prelearning showIcon2()

Definition at line 74 of file IconPair.C.

75 {
77 } //

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 Fri May 31 2013 for the C++ Web Toolkit (Wt) by doxygen 1.8.3.1