wxtimerthe 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::wxtimerwxtimer() 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::~wxtimer~wxtimer() destructor. stops the timer if it is running.
wxtimer::getintervalint getinterval() const returns the current interval for the timer (in milliseconds).
wxtimer::isoneshotbool isoneshot() const returns true if the timer is one shot, i.e. if it will stop after firing the first notification automatically.
wxtimer::isrunningbool isrunning() const returns true if the timer is running, false if it is stopped.
wxtimer::notifyvoid 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.
wxtimer::setownervoid 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.
wxtimer::startbool 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:
if the timer was already running, it will be stopped by this method before restarting it.
wxtimer::stopvoid stop() stops the timer.
|