]>
Commit | Line | Data |
---|---|---|
83df96d6 JS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: timer.cpp | |
3 | // Purpose: wxTimer implementation | |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 17/09/98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Julian Smart | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifdef __GNUG__ | |
13 | #pragma implementation "timer.h" | |
14 | #endif | |
15 | ||
16 | #include "wx/timer.h" | |
17 | #include "wx/app.h" | |
18 | #include "wx/list.h" | |
19 | ||
20 | #ifdef __VMS__ | |
21 | #pragma message disable nosimpint | |
22 | #endif | |
bc797f4c | 23 | |
83df96d6 JS |
24 | #ifdef __VMS__ |
25 | #pragma message enable nosimpint | |
26 | #endif | |
27 | ||
bc797f4c | 28 | #include "wx/x11/private.h" |
83df96d6 JS |
29 | |
30 | IMPLEMENT_ABSTRACT_CLASS(wxTimer, wxObject) | |
31 | ||
32 | static wxList wxTimerList(wxKEY_INTEGER); | |
33 | ||
34 | void wxTimerCallback (wxTimer * timer) | |
35 | { | |
36 | // Check to see if it's still on | |
37 | if (!wxTimerList.Find((long)timer)) | |
38 | return; | |
39 | ||
40 | if (timer->m_id == 0) | |
41 | return; // Avoid to process spurious timer events | |
42 | ||
7266b672 JS |
43 | // TODO |
44 | #if 0 | |
83df96d6 JS |
45 | if (!timer->m_oneShot) |
46 | timer->m_id = XtAppAddTimeOut((XtAppContext) wxTheApp->GetAppContext(), | |
47 | timer->m_milli, | |
48 | (XtTimerCallbackProc) wxTimerCallback, | |
49 | (XtPointer) timer); | |
50 | else | |
7266b672 JS |
51 | #endif |
52 | timer->m_id = 0; | |
83df96d6 JS |
53 | |
54 | timer->Notify(); | |
55 | } | |
56 | ||
57 | void wxTimer::Init() | |
58 | { | |
59 | m_id = 0; | |
60 | m_milli = 1000; | |
61 | } | |
62 | ||
63 | wxTimer::~wxTimer() | |
64 | { | |
65 | wxTimer::Stop(); | |
66 | wxTimerList.DeleteObject(this); | |
67 | } | |
68 | ||
69 | bool wxTimer::Start(int milliseconds, bool mode) | |
70 | { | |
71 | Stop(); | |
72 | ||
73 | (void)wxTimerBase::Start(milliseconds, mode); | |
74 | ||
75 | if (!wxTimerList.Find((long)this)) | |
76 | wxTimerList.Append((long)this, this); | |
7266b672 JS |
77 | // TODO |
78 | #if 0 | |
83df96d6 JS |
79 | m_id = XtAppAddTimeOut((XtAppContext) wxTheApp->GetAppContext(), |
80 | m_milli, | |
81 | (XtTimerCallbackProc) wxTimerCallback, | |
82 | (XtPointer) this); | |
7266b672 | 83 | #endif |
83df96d6 JS |
84 | return TRUE; |
85 | } | |
86 | ||
87 | void wxTimer::Stop() | |
88 | { | |
89 | if (m_id > 0) | |
90 | { | |
7266b672 JS |
91 | // TODO |
92 | #if 0 | |
83df96d6 | 93 | XtRemoveTimeOut (m_id); |
7266b672 | 94 | #endif |
83df96d6 JS |
95 | m_id = 0; |
96 | } | |
97 | m_milli = 0 ; | |
98 | } | |
99 | ||
100 |