1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: SWIG interface definitions wxTimer
7 // Created: 18-June-1999
9 // Copyright: (c) 2003 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
16 //---------------------------------------------------------------------------
20 // generate notifications periodically until the timer is stopped (default)
23 // only send the notification once and then stop the timer
28 %constant wxEventType wxEVT_TIMER;
31 //---------------------------------------------------------------------------
35 //IMP_PYCALLBACK__(wxPyTimer, wxTimer, Notify);
37 IMPLEMENT_ABSTRACT_CLASS(wxPyTimer, wxTimer);
39 void wxPyTimer::Notify() {
41 bool blocked = wxPyBeginBlockThreads();
42 if ((found = wxPyCBH_findCallback(m_myInst, "Notify")))
43 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()"));
44 wxPyEndBlockThreads(blocked);
48 void wxPyTimer::base_Notify() {
56 MustHaveApp(wxPyTimer);
58 %name(Timer) class wxPyTimer : public wxEvtHandler
61 %pythonAppend wxPyTimer "self._setCallbackInfo(self, Timer, 0); self._setOORInfo(self)"
64 // if you don't call SetOwner() or provide an owner in the contstructor
65 // then you must override Notify() inorder to receive the timer
66 // notification. If the owner is set then it will get the timer
67 // notifications which can be handled with EVT_TIMER.
68 wxPyTimer(wxEvtHandler *owner=NULL, int id = -1);
71 void _setCallbackInfo(PyObject* self, PyObject* _class, int incref=1);
73 // Set the owner instance that will receive the EVT_TIMER events using the
75 void SetOwner(wxEvtHandler *owner, int id = -1);
76 wxEvtHandler* GetOwner();
78 // start the timer: if milliseconds == -1, use the same value as for the
81 // it is now valid to call Start() multiple times: this just restarts the
82 // timer if it is already running
83 virtual bool Start(int milliseconds = -1, bool oneShot = false);
88 // override this in your wxTimer-derived class if you want to process timer
89 // messages in it, use non default ctor or SetOwner() otherwise
90 //virtual void Notify();
92 // return True if the timer is running
93 virtual bool IsRunning() const;
95 // get the (last) timer interval in the milliseconds
96 int GetInterval() const;
98 // return True if the timer is one shot
99 bool IsOneShot() const;
101 // return the timer ID
108 %# For backwards compatibility with 2.4
109 class PyTimer(Timer):
110 def __init__(self, notify):
119 EVT_TIMER = wx.PyEventBinder( wxEVT_TIMER, 1 )
125 class wxTimerEvent : public wxEvent
128 wxTimerEvent(int timerid = 0, int interval = 0);
129 int GetInterval() const;
134 // wxTimerRunner: starts the timer in its ctor, stops in the dtor
135 MustHaveApp(wxTimerRunner);
139 %nokwargs wxTimerRunner;
140 wxTimerRunner(wxTimer& timer);
141 wxTimerRunner(wxTimer& timer, int milli, bool oneShot = false);
144 void Start(int milli, bool oneShot = false);
148 //---------------------------------------------------------------------------
150 wxPyPtrTypeMap_Add("wxTimer", "wxPyTimer");
152 //---------------------------------------------------------------------------