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 wxPyTimer::wxPyTimer(wxEvtHandler *owner, int id)
48 MustHaveApp(wxPyTimer);
50 %rename(Timer) wxPyTimer;
51 class wxPyTimer : public wxEvtHandler
54 // Don't let the OOR or callback info hold references to the object so
55 // there won't be a reference cycle and it can clean itself up via normal
57 %pythonAppend wxPyTimer
58 "self._setCallbackInfo(self, Timer, 0); self._setOORInfo(self, 0)"
60 // if you don't call SetOwner() or provide an owner in the ctor
61 // then you must override Notify() in order to receive the timer
62 // notification. If the owner is set then it will get the timer
63 // notifications which can be handled with EVT_TIMER.
64 wxPyTimer(wxEvtHandler *owner = NULL, int id = wxID_ANY);
69 void _setCallbackInfo(PyObject* self, PyObject* _class, int incref = 1);
71 // Set the owner instance that will receive the EVT_TIMER events
72 // using the given id.
73 void SetOwner(wxEvtHandler *owner, int id = wxID_ANY);
74 wxEvtHandler* GetOwner();
76 // start the timer: if milliseconds == -1, use the same value as for the
79 // it is now valid to call Start() multiple times: this just restarts the
80 // timer if it is already running
81 virtual bool Start(int milliseconds = -1, bool oneShot = false);
86 // override this in your wxTimer-derived class if you need to process timer
87 // messages in it; otherwise, use non-default ctor or call SetOwner()
88 virtual void Notify();
90 // return True if the timer is running
91 virtual bool IsRunning() const;
93 // get the (last) timer interval in milliseconds
94 int GetInterval() const;
96 // return the timer ID
99 // return True if the timer is one shot
100 bool IsOneShot() const;
104 """NO-OP: Timers must be destroyed by normal reference counting"""
108 %property(Id, GetId, doc="See `GetId`");
109 %property(Interval, GetInterval, doc="See `GetInterval`");
110 %property(Owner, GetOwner, SetOwner, doc="See `GetOwner` and `SetOwner`");
115 %# For backwards compatibility with 2.4
116 class PyTimer(Timer):
117 def __init__(self, notify):
126 EVT_TIMER = wx.PyEventBinder( wxEVT_TIMER, 1 )
132 class wxTimerEvent : public wxEvent
135 wxTimerEvent(int timerid = 0, int interval = 0);
136 int GetInterval() const;
138 %property(Interval, GetInterval, doc="See `GetInterval`");
143 // wxTimerRunner: starts the timer in its ctor, stops in the dtor
144 MustHaveApp(wxTimerRunner);
148 %nokwargs wxTimerRunner;
149 wxTimerRunner(wxTimer& timer);
150 wxTimerRunner(wxTimer& timer, int milli, bool oneShot = false);
153 void Start(int milli, bool oneShot = false);
157 //---------------------------------------------------------------------------
159 wxPyPtrTypeMap_Add("wxTimer", "wxPyTimer");
161 //---------------------------------------------------------------------------