Wt examples  3.2.0
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
IconPair Class Reference

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

#include <IconPair.h>

Inheritance diagram for IconPair:
Inheritance graph
[legend]

List of all members.

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.
void showIcon1 ()
 Set state to 0 (show icon 1).
void showIcon2 ()
 Set state to 1 (show icon 2).

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.


Member Function Documentation

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

Get the first icon image.

Definition at line 61 of file IconPair.h.

{ return icon1_; }
Wt::WImage* IconPair::icon2 ( ) const [inline]

Get the second icon image.

Definition at line 65 of file IconPair.h.

{ 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.

{
  if (num == 0) {
    icon1_->show();
    icon2_->hide();
  } else {
    icon1_->hide();
    icon2_->show();
  }
}
void IconPair::showIcon1 ( )

Set state to 0 (show icon 1).

Definition at line 57 of file IconPair.C.

{
  previousState_ = (icon1_->isHidden() ? 1 : 0);
  setState(0);
}
void IconPair::showIcon2 ( )

Set state to 1 (show icon 2).

Definition at line 63 of file IconPair.C.

{
  previousState_ = (icon1_->isHidden() ? 1 : 0);
  setState(1);
}
int IconPair::state ( ) const

Get the current state.

See also:
setState()

Definition at line 52 of file IconPair.C.

{
  return (icon1_->isHidden() ? 1 : 0);
}
void IconPair::undoShowIcon1 ( ) [private]

Undo function for prelearning showIcon1()

Definition at line 69 of file IconPair.C.

void IconPair::undoShowIcon2 ( ) [private]

Undo function for prelearning showIcon2()

Definition at line 74 of file IconPair.C.


Member Data Documentation

First icon.

Definition at line 79 of file IconPair.h.

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

Definition at line 88 of file IconPair.h.

Second icon.

Definition at line 82 of file IconPair.h.

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

Definition at line 93 of file IconPair.h.

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 Tue Nov 29 2011 for the C++ Web Toolkit (Wt) by doxygen 1.7.5.1