Timer

A timer can repeatedly call a piece of code. The duration between calls is specified in milliseconds. Timer is defferent from other graphics controls, it has no graphics interface.There is a example for creating a timer

class wvl_test: public wvl::form
{
public:
    wvl_test()
    {
        timer_.make_event<wvl::event::tick>(wvl::bind_mem_fun(this, &wvl_test::on_tick));
        timer_.interval(2000);
        this->show();
    }
private:   
    void on_tick()
    {  wvl::message_box.show("TICK");   }
private:
    wvl::timer timer_;     
};

A timer has not a member function called create(), it will work when you install an event for the timer, and its default interval is 1000-millisecond. You can call the member function of timer named interval() to change the interval. As the above example shows, it was changed to 2-second.

Besides make_event(), there is a member function called make_tick, so you can also use make_tick to install event
timer_.make_tick(wvl::bind_mem_fun(this, &wvl_test::on_tick));

Member Function
template<typename _Event_Policy, typename _Function> void make_event(const _Function&) const Install a event and a event handler
template<typename _Function>
void make_tick(const _Function&) const
Install the tick event and a event handler
bool enabled() const Tells whether the timer is enabled 
bool enabled(bool) Enable or disable the timer
unsigned interval() const Returns the interval of the timer
unsigned interval(unsigned) Set the inerval of the timer

Return to Index