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