CountDownWidget.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * Copyright (C) 2008 Emweb bvba, Kessel-Lo, Belgium.
  3. *
  4. * See the LICENSE file for terms of use.
  5. */
  6. // This may look like C code, but it's really -*- C++ -*-
  7. #ifndef WCOUNTDOWNWIDGET_H_
  8. #define WCOUNTDOWNWIDGET_H_
  9. #include <Wt/WText>
  10. namespace Wt {
  11. class WTimer;
  12. }
  13. using namespace Wt;
  14. /**
  15. * \defgroup missionexample Timer example
  16. */
  17. /*@{*/
  18. /*!\brief A widget which displays a decrementing number.
  19. */
  20. class CountDownWidget : public WText
  21. {
  22. public:
  23. /*! \brief Create a new CountDownWidget.
  24. *
  25. * The widget will count down from start to stop, decrementing
  26. * the number every msec milliseconds.
  27. */
  28. CountDownWidget(int start, int stop, unsigned msec,
  29. WContainerWidget *parent = 0);
  30. /*! \brief Signal emitted when the countdown reached stop.
  31. */
  32. Wt::Signal<void>& done() { return done_; }
  33. /*! \brief Cancel the count down.
  34. */
  35. void cancel();
  36. private:
  37. Wt::Signal<void> done_;
  38. int start_;
  39. int stop_;
  40. int current_;
  41. WTimer *timer_;
  42. /*! \brief Process one timer tick.
  43. */
  44. void timerTick();
  45. };
  46. /*@}*/
  47. #endif // WCOUNTDOWNWIDGET_H_