Wt examples
3.3.6
build
witty-8LS0oe
witty-3.3.6+dfsg
examples
mission
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
12
CountDownWidget::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
20
current_
=
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
30
void
CountDownWidget::cancel
()
31
{
32
timer_
->stop();
33
}
34
35
void
CountDownWidget::timerTick
()
36
{
37
setText(boost::lexical_cast<std::string>(--
current_
));
38
39
if
(
current_
<=
stop_
) {
40
timer_
->stop();
41
done_
.emit();
42
}
43
}
CountDownWidget::cancel
void cancel()
Cancel the count down.
Definition:
CountDownWidget.C:30
CountDownWidget::timer_
WTimer * timer_
Definition:
CountDownWidget.h:51
CountDownWidget::stop_
int stop_
Definition:
CountDownWidget.h:47
CountDownWidget::start_
int start_
Definition:
CountDownWidget.h:46
CountDownWidget::timerTick
void timerTick()
Process one timer tick.
Definition:
CountDownWidget.C:35
CountDownWidget.h
CountDownWidget::done_
Wt::Signal< void > done_
Definition:
CountDownWidget.h:45
CountDownWidget::CountDownWidget
CountDownWidget(int start, int stop, unsigned msec, WContainerWidget *parent=0)
Create a new CountDownWidget.
Definition:
CountDownWidget.C:12
CountDownWidget::current_
int current_
Definition:
CountDownWidget.h:49
Generated on Thu Jan 12 2017 for
the C++ Web Toolkit (Wt)
by
1.8.12