$szTitle = "wxtimer"; include "./_header.inc"; ?>
the wxtimer class allows you to execute code at specified intervals. its precision is platform-dependent, but in general will not be better than 1ms nor worse than 1s.
there are three different ways to use this class:
in any case, you must start the timer with start after constructing it before it actually starts sending notifications. it can be stopped later with stop.
note: a timer can only be used from the main thread.
derived from
include files
<wx/timer.h>
see also
::wxstarttimer, ::wxgetelapsedtime, wxstopwatch
members
wxtimer::wxtimer
wxtimer::~wxtimer
wxtimer::getinterval
wxtimer::isoneshot
wxtimer::isrunning
wxtimer::notify
wxtimer::setowner
wxtimer::start
wxtimer::stop
wxtimer()
default constructor. if you use it to construct the object and don't call setowner later, you must override notify method to process the notifications.
wxtimer(wxevthandler *owner, int id = -1)
creates a timer and associates it with owner. please see setowner for the description of parameters.
~wxtimer()
destructor. stops the timer if it is running.
int getinterval() const
returns the current interval for the timer (in milliseconds).
bool isoneshot() const
returns true if the timer is one shot, i.e. if it will stop after firing the first notification automatically.
bool isrunning() const
returns true if the timer is running, false if it is stopped.
void notify()
this member should be overridden by the user if the default constructor was used and setowner wasn't called.
perform whatever action which is to be taken periodically here.
void setowner(wxevthandler *owner, int id = -1)
associates the timer with the given owner object. when the timer is running, the owner will receive timer events with id equal to id specified here.
bool start(int milliseconds = -1, bool oneshot = false)
(re)starts the timer. if milliseconds parameter is -1 (value by default), the previous value is used. returns false if the timer could not be started, true otherwise (in ms windows timers are a limited resource).
if oneshot is false (the default), the notify function will be called repeatedly until the timer is stopped. if true, it will be called only once and the timer will stop automatically. to make your code more readable you may also use the following symbolic constants:
wxtimer_continuous | start a normal, continuously running, timer |
wxtimer_one_shot | start a one shot timer |
if the timer was already running, it will be stopped by this method before restarting it.
void stop()
stops the timer.
include "./_footer.inc"; ?>