]>
Commit | Line | Data |
---|---|---|
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 | ||
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: | |
2b9048c5 | 43 | %pythonAppend wxPyTimer "self._setCallbackInfo(self, Timer)" |
d14a1e28 RD |
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 | ||
7722248d RD |
52 | void _setCallbackInfo(PyObject* self, PyObject* _class); |
53 | ||
d14a1e28 RD |
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 | |
dd9f7fea | 64 | virtual bool Start(int milliseconds = -1, bool oneShot = False); |
d14a1e28 RD |
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 | |
7722248d | 71 | //virtual void Notify(); |
d14a1e28 | 72 | |
dd9f7fea | 73 | // return True if the timer is running |
d14a1e28 RD |
74 | virtual bool IsRunning() const; |
75 | ||
76 | // get the (last) timer interval in the milliseconds | |
77 | int GetInterval() const; | |
78 | ||
dd9f7fea | 79 | // return True if the timer is one shot |
d14a1e28 | 80 | bool IsOneShot() const; |
0bdc5dd6 RD |
81 | |
82 | // return the timer ID | |
83 | int GetId() const; | |
84 | ||
d14a1e28 RD |
85 | }; |
86 | ||
87 | ||
88 | %pythoncode { | |
89 | %# For backwards compatibility with 2.4 | |
90 | class PyTimer(Timer): | |
91 | def __init__(self, notify): | |
92 | Timer.__init__(self) | |
93 | self.notify = notify | |
94 | ||
95 | def Notify(self): | |
96 | if self.notify: | |
97 | self.notify() | |
98 | ||
99 | ||
100 | EVT_TIMER = wx.PyEventBinder( wxEVT_TIMER, 1 ) | |
101 | ||
102 | }; | |
103 | ||
104 | ||
105 | ||
106 | class wxTimerEvent : public wxEvent | |
107 | { | |
108 | public: | |
109 | wxTimerEvent(int timerid = 0, int interval = 0); | |
110 | int GetInterval() const; | |
111 | }; | |
112 | ||
113 | ||
114 | ||
115 | // wxTimerRunner: starts the timer in its ctor, stops in the dtor | |
116 | class wxTimerRunner | |
117 | { | |
118 | public: | |
119 | %nokwargs wxTimerRunner; | |
120 | wxTimerRunner(wxTimer& timer); | |
dd9f7fea | 121 | wxTimerRunner(wxTimer& timer, int milli, bool oneShot = False); |
d14a1e28 RD |
122 | ~wxTimerRunner(); |
123 | ||
dd9f7fea | 124 | void Start(int milli, bool oneShot = False); |
d14a1e28 RD |
125 | }; |
126 | ||
127 | ||
128 | //--------------------------------------------------------------------------- |