]> git.saurik.com Git - wxWidgets.git/blame - src/motif/timer.cpp
VTK wrapper of vtkRenderWindow for wxPython. Tested on MSW so far.
[wxWidgets.git] / src / motif / timer.cpp
CommitLineData
4bb6408c
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"
0d57be45
JS
17#include "wx/app.h"
18#include "wx/list.h"
19
20#include <Xm/Xm.h>
21
22#include "wx/motif/private.h"
4bb6408c
JS
23
24#if !USE_SHARED_LIBRARY
25IMPLEMENT_ABSTRACT_CLASS(wxTimer, wxObject)
26#endif
27
0d57be45
JS
28static wxList wxTimerList(wxKEY_INTEGER);
29
30void wxTimerCallback (wxTimer * timer)
31{
32 // Check to see if it's still on
33 if (!wxTimerList.Find((long)timer))
34 return;
35
36 if (timer->m_id == 0)
37 return; // Avoid to process spurious timer events
38
39 if (!timer->m_oneShot)
0470b1e6
VZ
40 timer->m_id = XtAppAddTimeOut((XtAppContext) wxTheApp->GetAppContext(),
41 timer->m_milli,
42 (XtTimerCallbackProc) wxTimerCallback,
43 (XtPointer) timer);
0d57be45
JS
44 else
45 timer->m_id = 0;
0470b1e6
VZ
46
47 timer->Notify();
0d57be45
JS
48}
49
4bb6408c
JS
50wxTimer::wxTimer()
51{
0d57be45 52 m_id = 0;
4bb6408c
JS
53}
54
55wxTimer::~wxTimer()
56{
0470b1e6 57 wxTimer::Stop();
1a3ac83f 58 wxTimerList.DeleteObject(this);
4bb6408c
JS
59}
60
0d57be45 61bool wxTimer::Start(int milliseconds, bool mode)
4bb6408c 62{
0d57be45
JS
63 Stop();
64
0470b1e6 65 (void)wxTimerBase::Start(milliseconds, mode);
0d57be45
JS
66
67 if (!wxTimerList.Find((long)this))
68 wxTimerList.Append((long)this, this);
4bb6408c 69
0470b1e6
VZ
70 m_id = XtAppAddTimeOut((XtAppContext) wxTheApp->GetAppContext(),
71 m_milli,
72 (XtTimerCallbackProc) wxTimerCallback,
73 (XtPointer) this);
0d57be45 74 return TRUE;
4bb6408c
JS
75}
76
77void wxTimer::Stop()
78{
0d57be45
JS
79 if (m_id > 0)
80 {
81 XtRemoveTimeOut (m_id);
82 m_id = 0;
83 }
4bb6408c
JS
84 m_milli = 0 ;
85}
86
87