]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/_timer.i
Use default window IDs
[wxWidgets.git] / wxPython / src / _timer.i
CommitLineData
d14a1e28
RD
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
19enum {
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;
66065839 29
d14a1e28
RD
30
31//---------------------------------------------------------------------------
32
33
34%{
66065839
RD
35//IMP_PYCALLBACK__(wxPyTimer, wxTimer, Notify);
36
37void wxPyTimer::Notify() {
38 bool found;
da32eb53 39 bool blocked = wxPyBeginBlockThreads();
66065839
RD
40 if ((found = wxPyCBH_findCallback(m_myInst, "Notify")))
41 wxPyCBH_callCallback(m_myInst, Py_BuildValue("()"));
da32eb53 42 wxPyEndBlockThreads(blocked);
66065839
RD
43 if (! found)
44 wxTimer::Notify();
45}
46void wxPyTimer::base_Notify() {
47 wxTimer::Notify();
48}
49
d14a1e28
RD
50%}
51
52
53
54%name(Timer) class wxPyTimer : public wxEvtHandler
55{
56public:
66065839
RD
57 %pythonAppend wxPyTimer "self._setCallbackInfo(self, Timer, 0)"
58
d14a1e28
RD
59
60 // if you don't call SetOwner() or provide an owner in the contstructor
61 // then you must override Notify() inorder 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 = -1);
65 virtual ~wxPyTimer();
66
66065839 67 void _setCallbackInfo(PyObject* self, PyObject* _class, int incref=1);
7722248d 68
d14a1e28
RD
69 // Set the owner instance that will receive the EVT_TIMER events using the
70 // given id.
71 void SetOwner(wxEvtHandler *owner, int id = -1);
72
73
74 // start the timer: if milliseconds == -1, use the same value as for the
75 // last Start()
76 //
77 // it is now valid to call Start() multiple times: this just restarts the
78 // timer if it is already running
dd9f7fea 79 virtual bool Start(int milliseconds = -1, bool oneShot = False);
d14a1e28
RD
80
81 // stop the timer
82 virtual void Stop();
83
84 // override this in your wxTimer-derived class if you want to process timer
85 // messages in it, use non default ctor or SetOwner() otherwise
7722248d 86 //virtual void Notify();
d14a1e28 87
dd9f7fea 88 // return True if the timer is running
d14a1e28
RD
89 virtual bool IsRunning() const;
90
91 // get the (last) timer interval in the milliseconds
92 int GetInterval() const;
93
dd9f7fea 94 // return True if the timer is one shot
d14a1e28 95 bool IsOneShot() const;
0bdc5dd6
RD
96
97 // return the timer ID
98 int GetId() const;
66065839 99
d14a1e28
RD
100};
101
102
66065839 103%pythoncode {
d14a1e28
RD
104%# For backwards compatibility with 2.4
105class PyTimer(Timer):
106 def __init__(self, notify):
107 Timer.__init__(self)
108 self.notify = notify
109
110 def Notify(self):
111 if self.notify:
112 self.notify()
113
114
115EVT_TIMER = wx.PyEventBinder( wxEVT_TIMER, 1 )
66065839 116
d14a1e28
RD
117};
118
119
120
121class wxTimerEvent : public wxEvent
122{
123public:
124 wxTimerEvent(int timerid = 0, int interval = 0);
125 int GetInterval() const;
126};
127
128
129
130// wxTimerRunner: starts the timer in its ctor, stops in the dtor
131class wxTimerRunner
132{
133public:
134 %nokwargs wxTimerRunner;
135 wxTimerRunner(wxTimer& timer);
dd9f7fea 136 wxTimerRunner(wxTimer& timer, int milli, bool oneShot = False);
d14a1e28
RD
137 ~wxTimerRunner();
138
dd9f7fea 139 void Start(int milli, bool oneShot = False);
d14a1e28
RD
140};
141
142
143//---------------------------------------------------------------------------