]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/motif/timer.cpp
VTK wrapper of vtkRenderWindow for wxPython. Tested on MSW so far.
[wxWidgets.git] / src / motif / timer.cpp
... / ...
CommitLineData
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#include <Xm/Xm.h>
21
22#include "wx/motif/private.h"
23
24#if !USE_SHARED_LIBRARY
25IMPLEMENT_ABSTRACT_CLASS(wxTimer, wxObject)
26#endif
27
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)
40 timer->m_id = XtAppAddTimeOut((XtAppContext) wxTheApp->GetAppContext(),
41 timer->m_milli,
42 (XtTimerCallbackProc) wxTimerCallback,
43 (XtPointer) timer);
44 else
45 timer->m_id = 0;
46
47 timer->Notify();
48}
49
50wxTimer::wxTimer()
51{
52 m_id = 0;
53}
54
55wxTimer::~wxTimer()
56{
57 wxTimer::Stop();
58 wxTimerList.DeleteObject(this);
59}
60
61bool wxTimer::Start(int milliseconds, bool mode)
62{
63 Stop();
64
65 (void)wxTimerBase::Start(milliseconds, mode);
66
67 if (!wxTimerList.Find((long)this))
68 wxTimerList.Append((long)this, this);
69
70 m_id = XtAppAddTimeOut((XtAppContext) wxTheApp->GetAppContext(),
71 m_milli,
72 (XtTimerCallbackProc) wxTimerCallback,
73 (XtPointer) this);
74 return TRUE;
75}
76
77void wxTimer::Stop()
78{
79 if (m_id > 0)
80 {
81 XtRemoveTimeOut (m_id);
82 m_id = 0;
83 }
84 m_milli = 0 ;
85}
86
87