Wt examples
3.3.0
Main Page
Modules
Namespaces
Classes
Files
File List
File Members
build
buildd
witty-3.3.0
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
}
Generated on Fri May 31 2013 for
the C++ Web Toolkit (Wt)
by
1.8.3.1