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)
 
  46 wxPyTimer::~wxPyTimer()
 
  48 //    printf("-=* ~wxPyTimer\n");
 
  54 MustHaveApp(wxPyTimer);
 
  56 %rename(Timer) wxPyTimer;
 
  57 class wxPyTimer : public wxEvtHandler
 
  60     // Don't let the OOR or callback info hold references to the object so
 
  61     // there won't be a reference cycle and it can clean itself up via normal
 
  63     %pythonAppend wxPyTimer
 
  64         "self._setOORInfo(self,0); self.this.own(True); " setCallbackInfo(Timer); 
 
  66     // if you don't call SetOwner() or provide an owner in the ctor
 
  67     // then you must override Notify() in order to receive the timer
 
  68     // notification.  If the owner is set then it will get the timer
 
  69     // notifications which can be handled with EVT_TIMER.
 
  70     wxPyTimer(wxEvtHandler *owner = NULL, int id = wxID_ANY);
 
  75     void _setCallbackInfo(PyObject* self, PyObject* _class, int incref = 0);
 
  77     // Set the owner instance that will receive the EVT_TIMER events
 
  78     // using the given id.
 
  79     void SetOwner(wxEvtHandler *owner, int id = wxID_ANY);
 
  80     wxEvtHandler* GetOwner();
 
  82     // start the timer: if milliseconds == -1, use the same value as for the
 
  85     // it is now valid to call Start() multiple times: this just restarts the
 
  86     // timer if it is already running
 
  87     virtual bool Start(int milliseconds = -1, bool oneShot = false);
 
  92     // override this in your wxTimer-derived class if you need to process timer
 
  93     // messages in it; otherwise, use non-default ctor or call SetOwner()
 
  94     virtual void Notify();
 
  96     // return True if the timer is running
 
  97     virtual bool IsRunning() const;
 
  99     // get the (last) timer interval in milliseconds
 
 100     int GetInterval() const;
 
 102     // return the timer ID
 
 105     // return True if the timer is one shot
 
 106     bool IsOneShot() const;
 
 110             """NO-OP: Timers must be destroyed by normal reference counting"""
 
 114     %property(Id, GetId, doc="See `GetId`");
 
 115     %property(Interval, GetInterval, doc="See `GetInterval`");
 
 116     %property(Owner, GetOwner, SetOwner, doc="See `GetOwner` and `SetOwner`");
 
 121 %# For backwards compatibility with 2.4
 
 122 class PyTimer(Timer):
 
 123     def __init__(self, notify):
 
 132 EVT_TIMER = wx.PyEventBinder( wxEVT_TIMER, 1 )
 
 138 class wxTimerEvent : public wxEvent
 
 141     wxTimerEvent(int timerid = 0, int interval = 0);
 
 142     int GetInterval() const;
 
 144     %property(Interval, GetInterval, doc="See `GetInterval`");
 
 149 // wxTimerRunner: starts the timer in its ctor, stops in the dtor
 
 150 MustHaveApp(wxTimerRunner);
 
 154     %nokwargs wxTimerRunner;
 
 155     wxTimerRunner(wxTimer& timer);
 
 156     wxTimerRunner(wxTimer& timer, int milli, bool oneShot = false);
 
 159     void Start(int milli, bool oneShot = false);
 
 163 //---------------------------------------------------------------------------
 
 165     wxPyPtrTypeMap_Add("wxTimer", "wxPyTimer");
 
 167 //---------------------------------------------------------------------------