]>
git.saurik.com Git - wxWidgets.git/blob - src/os2/timer.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxTimer implementation
4 // Author: David Webster
8 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "timer.h"
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
19 #include "wx/window.h"
20 #include "wx/os2/private.h"
35 #include <sys/types.h>
37 #include <sys/timeb.h>
38 // ----------------------------------------------------------------------------
40 // ----------------------------------------------------------------------------
42 wxList
wxTimerList(wxKEY_INTEGER
);
43 ULONG
wxTimerProc(HWND hwnd
, ULONG
, int nIdTimer
, ULONG
);
45 // ----------------------------------------------------------------------------
47 // ----------------------------------------------------------------------------
49 IMPLEMENT_ABSTRACT_CLASS(wxTimer
, wxObject
)
60 wxTimerList
.DeleteObject(this);
63 void wxTimer::Notify()
66 // The base class version generates an event if it has owner - which it
67 // should because otherwise nobody can process timer events, but it does
68 // not use the OS's ID, which OS/2 must have to figure out which timer fired
70 wxCHECK_RET( m_owner
, _T("wxTimer::Notify() should be overridden.") );
72 wxTimerEvent
vEvent( m_idTimer
76 (void)m_owner
->ProcessEvent(vEvent
);
77 } // end of wxTimer::Notify
84 (void)wxTimerBase::Start( nMilliseconds
88 wxCHECK_MSG( m_milli
> 0L, FALSE
, wxT("invalid value for timer") );
90 wxTimerList
.DeleteObject(this);
92 wxWindow
* pWin
= NULL
;
96 pWin
= (wxWindow
*)m_owner
;
97 m_ulId
= ::WinStartTimer( m_Hab
100 ,(ULONG
)nMilliseconds
104 m_ulId
= ::WinStartTimer( m_Hab
107 ,(ULONG
)nMilliseconds
111 wxTimerList
.Append( m_ulId
118 wxLogSysError(_("Couldn't create a timer"));
130 wxWindow
* pWin
= (wxWindow
*)m_owner
;
132 ::WinStopTimer(m_Hab
, pWin
->GetHWND(), m_ulId
);
135 ::WinStopTimer(m_Hab
, NULLHANDLE
, m_ulId
);
136 wxTimerList
.DeleteObject(this);
141 // ----------------------------------------------------------------------------
143 // ----------------------------------------------------------------------------
150 // Avoid to process spurious timer events
152 if (rTimer
.m_ulId
== 0L)
155 if (rTimer
.IsOneShot())
168 wxNode
* pNode
= wxTimerList
.Find((ULONG
)nIdTimer
);
170 wxCHECK_MSG(pNode
, 0, wxT("bogus timer id in wxTimerProc") );
172 wxProcessTimer(*(wxTimer
*)pNode
->Data());