IconPair Class Reference
[Treelist example]

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

#include <IconPair.h>

Inheritance diagram for IconPair:

Inheritance graph
[legend]

List of all members.

Public Slots

void showIcon1 ()
 Set state to 0 (show icon 1).
void showIcon2 ()
 Set state to 1 (show icon 2).

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.
void setState (int num)
 Set which icon should be visible.
int state () const
 Get the current state.
Wt::WImageicon1 () const
 Get the first icon image.
Wt::WImageicon2 () const
 Get the second icon image.

Public Attributes

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

Private Member Functions

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

Private Attributes

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


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.

00014   : Wt::WCompositeWidget(parent),
00015     impl_(new Wt::WContainerWidget()),
00016     icon1_(new Wt::WImage(icon1URI, impl_)),
00017     icon2_(new Wt::WImage(icon2URI, impl_)),
00018     icon1Clicked(icon1_->clicked),
00019     icon2Clicked(icon2_->clicked)
00020 {
00021   setImplementation(impl_);
00022 
00023   implementStateless(&IconPair::showIcon1, &IconPair::undoShowIcon1);
00024   implementStateless(&IconPair::showIcon2, &IconPair::undoShowIcon2);
00025 
00026   setInline(true);
00027 
00028   icon2_->hide();
00029 
00030   if (clickIsSwitch) {
00031     icon1_->clicked.connect(SLOT(icon1_, Wt::WImage::hide));
00032     icon1_->clicked.connect(SLOT(icon2_, Wt::WImage::show));
00033 
00034     icon2_->clicked.connect(SLOT(icon2_, Wt::WImage::hide));
00035     icon2_->clicked.connect(SLOT(icon1_, Wt::WImage::show)); //
00036 
00037     decorationStyle().setCursor(Wt::WCssDecorationStyle::Pointer);
00038   }
00039 } //


Member Function Documentation

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.

00042 {
00043   if (num == 0) {
00044     icon1_->show();
00045     icon2_->hide();
00046   } else {
00047     icon1_->hide();
00048     icon2_->show();
00049   }
00050 }

int IconPair::state (  )  const

Get the current state.

See also:
setState()

Definition at line 52 of file IconPair.C.

00053 {
00054   return (icon1_->isHidden() ? 1 : 0);
00055 }

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

Get the first icon image.

Definition at line 61 of file IconPair.h.

00061 { return icon1_; }

Wt::WImage* IconPair::icon2 (  )  const [inline]

Get the second icon image.

Definition at line 65 of file IconPair.h.

00065 { return icon2_; }

void IconPair::showIcon1 (  )  [slot]

Set state to 0 (show icon 1).

Definition at line 57 of file IconPair.C.

00058 {
00059   previousState_ = (icon1_->isHidden() ? 1 : 0);
00060   setState(0);
00061 }

void IconPair::showIcon2 (  )  [slot]

Set state to 1 (show icon 2).

Definition at line 63 of file IconPair.C.

00064 {
00065   previousState_ = (icon1_->isHidden() ? 1 : 0);
00066   setState(1);
00067 }

void IconPair::undoShowIcon1 (  )  [private]

Undo function for prelearning showIcon1().

Definition at line 69 of file IconPair.C.

00070 {
00071   setState(previousState_);
00072 }

void IconPair::undoShowIcon2 (  )  [private]

Undo function for prelearning showIcon2().

Definition at line 74 of file IconPair.C.

00075 {
00076   setState(previousState_);
00077 } //


Member Data Documentation

Definition at line 77 of file IconPair.h.

First icon.

Definition at line 80 of file IconPair.h.

Second icon.

Definition at line 83 of file IconPair.h.

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

Definition at line 89 of file IconPair.h.

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

Definition at line 94 of file IconPair.h.

int IconPair::previousState_ [private]

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

Definition at line 98 of file IconPair.h.


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

Generated on Mon Jan 26 14:14:22 2009 for Wt by doxygen 1.5.6