]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/_timer.i
New SWIG runtime and commandline param
[wxWidgets.git] / wxPython / src / _timer.i
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: _timer.i
3 // Purpose: SWIG interface definitions wxTimer
4 //
5 // Author: Robin Dunn
6 //
7 // Created: 18-June-1999
8 // RCS-ID: $Id$
9 // Copyright: (c) 2003 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
12
13 // Not a %module
14
15
16 //---------------------------------------------------------------------------
17 %newgroup
18
19 enum {
20 // generate notifications periodically until the timer is stopped (default)
21 wxTIMER_CONTINUOUS,
22
23 // only send the notification once and then stop the timer
24 wxTIMER_ONE_SHOT,
25 };
26
27 // Timer event type
28 %constant wxEventType wxEVT_TIMER;
29
30
31 //---------------------------------------------------------------------------
32
33
34 %{
35 IMP_PYCALLBACK__(wxPyTimer, wxTimer, Notify);
36 %}
37
38
39
40 %name(Timer) class wxPyTimer : public wxEvtHandler
41 {
42 public:
43 %addtofunc wxPyTimer "self._setCallbackInfo(self, Timer)"
44
45 // if you don't call SetOwner() or provide an owner in the contstructor
46 // then you must override Notify() inorder to receive the timer
47 // notification. If the owner is set then it will get the timer
48 // notifications which can be handled with EVT_TIMER.
49 wxPyTimer(wxEvtHandler *owner=NULL, int id = -1);
50 virtual ~wxPyTimer();
51
52 void _setCallbackInfo(PyObject* self, PyObject* _class);
53
54 // Set the owner instance that will receive the EVT_TIMER events using the
55 // given id.
56 void SetOwner(wxEvtHandler *owner, int id = -1);
57
58
59 // start the timer: if milliseconds == -1, use the same value as for the
60 // last Start()
61 //
62 // it is now valid to call Start() multiple times: this just restarts the
63 // timer if it is already running
64 virtual bool Start(int milliseconds = -1, bool oneShot = False);
65
66 // stop the timer
67 virtual void Stop();
68
69 // override this in your wxTimer-derived class if you want to process timer
70 // messages in it, use non default ctor or SetOwner() otherwise
71 //virtual void Notify();
72
73 // return True if the timer is running
74 virtual bool IsRunning() const;
75
76 // get the (last) timer interval in the milliseconds
77 int GetInterval() const;
78
79 // return True if the timer is one shot
80 bool IsOneShot() const;
81 };
82
83
84 %pythoncode {
85 %# For backwards compatibility with 2.4
86 class PyTimer(Timer):
87 def __init__(self, notify):
88 Timer.__init__(self)
89 self.notify = notify
90
91 def Notify(self):
92 if self.notify:
93 self.notify()
94
95
96 EVT_TIMER = wx.PyEventBinder( wxEVT_TIMER, 1 )
97
98 };
99
100
101
102 class wxTimerEvent : public wxEvent
103 {
104 public:
105 wxTimerEvent(int timerid = 0, int interval = 0);
106 int GetInterval() const;
107 };
108
109
110
111 // wxTimerRunner: starts the timer in its ctor, stops in the dtor
112 class wxTimerRunner
113 {
114 public:
115 %nokwargs wxTimerRunner;
116 wxTimerRunner(wxTimer& timer);
117 wxTimerRunner(wxTimer& timer, int milli, bool oneShot = False);
118 ~wxTimerRunner();
119
120 void Start(int milli, bool oneShot = False);
121 };
122
123
124 //---------------------------------------------------------------------------