]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/_timer.i
reSWIGged
[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
44 // if you don't call SetOwner() or provide an owner in the contstructor
45 // then you must override Notify() inorder to receive the timer
46 // notification. If the owner is set then it will get the timer
47 // notifications which can be handled with EVT_TIMER.
48 wxPyTimer(wxEvtHandler *owner=NULL, int id = -1);
49 virtual ~wxPyTimer();
50
51 // Set the owner instance that will receive the EVT_TIMER events using the
52 // given id.
53 void SetOwner(wxEvtHandler *owner, int id = -1);
54
55
56 // start the timer: if milliseconds == -1, use the same value as for the
57 // last Start()
58 //
59 // it is now valid to call Start() multiple times: this just restarts the
60 // timer if it is already running
61 virtual bool Start(int milliseconds = -1, bool oneShot = False);
62
63 // stop the timer
64 virtual void Stop();
65
66 // override this in your wxTimer-derived class if you want to process timer
67 // messages in it, use non default ctor or SetOwner() otherwise
68 virtual void Notify();
69
70 // return True if the timer is running
71 virtual bool IsRunning() const;
72
73 // get the (last) timer interval in the milliseconds
74 int GetInterval() const;
75
76 // return True if the timer is one shot
77 bool IsOneShot() const;
78 };
79
80
81 %pythoncode {
82 %# For backwards compatibility with 2.4
83 class PyTimer(Timer):
84 def __init__(self, notify):
85 Timer.__init__(self)
86 self.notify = notify
87
88 def Notify(self):
89 if self.notify:
90 self.notify()
91
92
93 EVT_TIMER = wx.PyEventBinder( wxEVT_TIMER, 1 )
94
95 };
96
97
98
99 class wxTimerEvent : public wxEvent
100 {
101 public:
102 wxTimerEvent(int timerid = 0, int interval = 0);
103 int GetInterval() const;
104 };
105
106
107
108 // wxTimerRunner: starts the timer in its ctor, stops in the dtor
109 class wxTimerRunner
110 {
111 public:
112 %nokwargs wxTimerRunner;
113 wxTimerRunner(wxTimer& timer);
114 wxTimerRunner(wxTimer& timer, int milli, bool oneShot = False);
115 ~wxTimerRunner();
116
117 void Start(int milli, bool oneShot = False);
118 };
119
120
121 //---------------------------------------------------------------------------