X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a0e9a5dfdeebc1d5e2d7e6e2146e63a26c8645a1..9e9574fe45b176ee74bba8fad7574cf9906145d1:/interface/wx/timer.h diff --git a/interface/wx/timer.h b/interface/wx/timer.h index 12513350ae..6753e2dd12 100644 --- a/interface/wx/timer.h +++ b/interface/wx/timer.h @@ -2,10 +2,18 @@ // Name: timer.h // Purpose: interface of wxTimer // Author: wxWidgets team -// RCS-ID: $Id$ -// Licence: wxWindows license +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// +// generate notifications periodically until the timer is stopped (default) +#define wxTIMER_CONTINUOUS false + +// only send the notification once and then stop the timer +#define wxTIMER_ONE_SHOT true + +wxEventType wxEVT_TIMER; + + /** @class wxTimer @@ -77,7 +85,7 @@ public: wxEvtHandler* GetOwner() const; /** - Returns @true if the timer is one shot, i.e. if it will stop after firing + Returns @true if the timer is one shot, i.e.\ if it will stop after firing the first notification automatically. */ bool IsOneShot() const; @@ -119,10 +127,21 @@ public: 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 + Alternatively, use StartOnce(). + If the timer was already running, it will be stopped by this method before restarting it. */ - virtual bool Start(int milliseconds = -1, bool oneShot = false); + virtual bool Start(int milliseconds = -1, bool oneShot = wxTIMER_CONTINUOUS); + + /** + Starts the timer for a once-only notification. + + This is a simple wrapper for Start() with @c wxTIMER_ONE_SHOT parameter. + + @since 2.9.5 + */ + bool StartOnce(int milliseconds = -1); /** Stops the timer. @@ -131,6 +150,19 @@ public: }; +/** + @class wxTimerRunner + + Starts the timer in its ctor, stops in the dtor. +*/ +class wxTimerRunner +{ +public: + wxTimerRunner(wxTimer& timer); + wxTimerRunner(wxTimer& timer, int milli, bool oneShot = false); + void Start(int milli, bool oneShot = false); + ~wxTimerRunner(); +}; /** @class wxTimerEvent @@ -176,6 +208,9 @@ public: class wxTimerEvent : public wxEvent { public: + wxTimerEvent(); + wxTimerEvent(wxTimer& timer); + /** Returns the interval of the timer which generated this event. */