CountDownWidget Class Reference
[Timer example]

A widget which displays a decrementing number. More...

#include <CountDownWidget.h>

Inheritance diagram for CountDownWidget:

Inheritance graph
[legend]

List of all members.

Public Slots

void cancel ()
 Cancel the count down.

Public Member Functions

 CountDownWidget (int start, int stop, unsigned msec, WContainerWidget *parent=0)
 Create a new CountDownWidget.

Public Attributes

Wt::Signal< void > done
 Signal emitted when the countdown reached stop.

Private Slots

void timerTick ()
 Process one timer tick.

Private Attributes

int start_
int stop_
unsigned msec_
int current_
WTimertimer_


Detailed Description

A widget which displays a decrementing number.

Definition at line 25 of file CountDownWidget.h.


Constructor & Destructor Documentation

CountDownWidget::CountDownWidget ( int  start,
int  stop,
unsigned  msec,
WContainerWidget parent = 0 
)

Create a new CountDownWidget.

The widget will count down from start to stop, decrementing the number every msec milliseconds.

Definition at line 12 of file CountDownWidget.C.

00014   : WText(parent),
00015     start_(start),
00016     stop_(stop)
00017 {
00018   stop_ = std::min(start_ - 1, stop_);  // stop must be smaller than start
00019   current_ = start_;
00020 
00021   timer_ = new WTimer(this);
00022   timer_->setInterval(msec);
00023   timer_->timeout.connect(SLOT(this, CountDownWidget::timerTick));
00024   timer_->start();
00025 
00026   setText(boost::lexical_cast<std::wstring>(current_));
00027 }


Member Function Documentation

void CountDownWidget::cancel (  )  [slot]

Cancel the count down.

Definition at line 29 of file CountDownWidget.C.

00030 {
00031   timer_->stop();
00032 }

void CountDownWidget::timerTick (  )  [private, slot]

Process one timer tick.

Definition at line 34 of file CountDownWidget.C.

00035 {
00036   setText(boost::lexical_cast<std::wstring>(--current_));
00037 
00038   if (current_ <= stop_) {
00039     timer_->stop();
00040     done.emit();
00041   }
00042 }


Member Data Documentation

Signal emitted when the countdown reached stop.

Definition at line 38 of file CountDownWidget.h.

int CountDownWidget::start_ [private]

Definition at line 51 of file CountDownWidget.h.

int CountDownWidget::stop_ [private]

Definition at line 52 of file CountDownWidget.h.

unsigned CountDownWidget::msec_ [private]

Definition at line 53 of file CountDownWidget.h.

Definition at line 55 of file CountDownWidget.h.

Definition at line 57 of file CountDownWidget.h.


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

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