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