X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/78e87bf7b8fb25529f77881834c75ae1614e6552..cb8ae61385f1c65552585cb55d8f7bd9f1f690b4:/interface/wx/timer.h diff --git a/interface/wx/timer.h b/interface/wx/timer.h index 6d11c2484c..054e890057 100644 --- a/interface/wx/timer.h +++ b/interface/wx/timer.h @@ -3,9 +3,18 @@ // 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 @@ -74,7 +83,7 @@ public: If non-@NULL this is the event handler which will receive the timer events (see wxTimerEvent) when the timer is running. */ - wxEvtHandler GetOwner() const; + wxEvtHandler* GetOwner() const; /** Returns @true if the timer is one shot, i.e. if it will stop after firing @@ -92,6 +101,10 @@ public: used and SetOwner() wasn't called. Perform whatever action which is to be taken periodically here. + + Notice that throwing exceptions from this method is currently not + supported, use event-based timer handling approach if an exception can + be thrown while handling timer notifications. */ virtual void Notify(); @@ -127,11 +140,25 @@ 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 - wxTimerEvent object is passed to the event handler of timer events. + wxTimerEvent object is passed to the event handler of timer events + (see wxTimer::SetOwner). For example: @@ -144,11 +171,12 @@ public: private: wxTimer m_timer; + wxDECLARE_EVENT_TABLE(); }; - BEGIN_EVENT_TABLE(MyFrame, wxFrame) + wxBEGIN_EVENT_TABLE(MyFrame, wxFrame) EVT_TIMER(TIMER_ID, MyFrame::OnTimer) - END_EVENT_TABLE() + wxEND_EVENT_TABLE() MyFrame::MyFrame() : m_timer(this, TIMER_ID) @@ -170,6 +198,9 @@ public: class wxTimerEvent : public wxEvent { public: + wxTimerEvent(); + wxTimerEvent(wxTimer& timer); + /** Returns the interval of the timer which generated this event. */ @@ -178,6 +209,6 @@ public: /** Returns the timer object which generated this event. */ - wxTimer GetTimer() const; + wxTimer& GetTimer() const; };