Wt examples 3.3.12
CountDownWidget.C
Go to the documentation of this file.
1/*
2 * Copyright (C) 2008 Emweb bvba, Kessel-Lo, Belgium.
3 *
4 * See the LICENSE file for terms of use.
5 */
6
7#include <boost/lexical_cast.hpp>
8
9#include <Wt/WTimer>
10#include "CountDownWidget.h"
11
12CountDownWidget::CountDownWidget(int start, int stop, unsigned msec,
13 WContainerWidget *parent)
14 : WText(parent),
15 done_(this),
16 start_(start),
17 stop_(stop)
18{
19 stop_ = std::min(start_ - 1, stop_); // stop must be smaller than start
21
22 timer_ = new WTimer(this);
23 timer_->setInterval(msec);
24 timer_->timeout().connect(this, &CountDownWidget::timerTick);
25 timer_->start();
26
27 setText(boost::lexical_cast<std::string>(current_));
28}
29
31{
32 timer_->stop();
33}
34
36{
37 setText(boost::lexical_cast<std::string>(--current_));
38
39 if (current_ <= stop_) {
40 timer_->stop();
41 done_.emit();
42 }
43}
void cancel()
Cancel the count down.
void timerTick()
Process one timer tick.
CountDownWidget(int start, int stop, unsigned msec, WContainerWidget *parent=0)
Create a new CountDownWidget.
Wt::Signal< void > done_
void emit(A1 a1=NoClass::none, A2 a2=NoClass::none, A3 a3=NoClass::none, A4 a4=NoClass::none, A5 a5=NoClass::none, A6 a6=NoClass::none) const
bool setText(const WString &text)
EventSignal< WMouseEvent > & timeout()
void setInterval(int msec)
void stop()
void start()

Generated on Fri May 17 2024 for the C++ Web Toolkit (Wt) by doxygen 1.9.8