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)
 
  42     if (owner == NULL) SetOwner(this);
 
  46 void wxPyTimer::Notify() {
 
  48     wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
  49     if ((found = wxPyCBH_findCallback(m_myInst, "Notify")))
 
  50         wxPyCBH_callCallback(m_myInst, Py_BuildValue("()"));
 
  51     wxPyEndBlockThreads(blocked);
 
  55 void wxPyTimer::base_Notify() {
 
  63 MustHaveApp(wxPyTimer);
 
  65 %rename(Timer) wxPyTimer;
 
  66 class wxPyTimer : public wxEvtHandler
 
  69     // Don't let the OOR or callback info hold references to the object so
 
  70     // there won't be a reference cycle and it can clean itself up via normal
 
  72     %pythonAppend wxPyTimer
 
  73         "self._setCallbackInfo(self, Timer, 0); self._setOORInfo(self, 0)"
 
  76     // if you don't call SetOwner() or provide an owner in the contstructor
 
  77     // then you must override Notify() inorder to receive the timer
 
  78     // notification.  If the owner is set then it will get the timer
 
  79     // notifications which can be handled with EVT_TIMER.
 
  80     wxPyTimer(wxEvtHandler *owner=NULL, int id = -1);
 
  85     void _setCallbackInfo(PyObject* self, PyObject* _class, int incref=1);
 
  87     // Set the owner instance that will receive the EVT_TIMER events using the
 
  89     void SetOwner(wxEvtHandler *owner, int id = -1);
 
  90     wxEvtHandler* GetOwner();
 
  92     // start the timer: if milliseconds == -1, use the same value as for the
 
  95     // it is now valid to call Start() multiple times: this just restarts the
 
  96     // timer if it is already running
 
  97     virtual bool Start(int milliseconds = -1, bool oneShot = false);
 
 102     // override this in your wxTimer-derived class if you want to process timer
 
 103     // messages in it, use non default ctor or SetOwner() otherwise
 
 104     //virtual void Notify();
 
 106     // return True if the timer is running
 
 107     virtual bool IsRunning() const;
 
 109     // get the (last) timer interval in the milliseconds
 
 110     int GetInterval() const;
 
 112     // return True if the timer is one shot
 
 113     bool IsOneShot() const;
 
 115     // return the timer ID
 
 120             """NO-OP: Timers must be destroyed by normal refrence counting"""
 
 127 %# For backwards compatibility with 2.4
 
 128 class PyTimer(Timer):
 
 129     def __init__(self, notify):
 
 138 EVT_TIMER = wx.PyEventBinder( wxEVT_TIMER, 1 )
 
 144 class wxTimerEvent : public wxEvent
 
 147     wxTimerEvent(int timerid = 0, int interval = 0);
 
 148     int GetInterval() const;
 
 153 // wxTimerRunner: starts the timer in its ctor, stops in the dtor
 
 154 MustHaveApp(wxTimerRunner);
 
 158     %nokwargs wxTimerRunner;
 
 159     wxTimerRunner(wxTimer& timer);
 
 160     wxTimerRunner(wxTimer& timer, int milli, bool oneShot = false);
 
 163     void Start(int milli, bool oneShot = false);
 
 167 //---------------------------------------------------------------------------
 
 169     wxPyPtrTypeMap_Add("wxTimer", "wxPyTimer");
 
 171 //---------------------------------------------------------------------------