]>
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 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
15 #include "wx/window.h"
16 #include "wx/os2/private.h"
31 #include <sys/types.h>
33 #include <sys/timeb.h>
35 // ----------------------------------------------------------------------------
37 // ----------------------------------------------------------------------------
39 wxList
wxTimerList(wxKEY_INTEGER
);
40 UINT
wxTimerProc(HWND hwnd
, WORD
, int idTimer
, DWORD
);
42 // ----------------------------------------------------------------------------
44 // ----------------------------------------------------------------------------
46 #if !USE_SHARED_LIBRARY
47 IMPLEMENT_ABSTRACT_CLASS(wxTimer
, wxObject
)
61 wxTimerList
.DeleteObject(this);
64 bool wxTimer::Start(int milliseconds
,bool mode
)
68 milliseconds
= lastMilli
;
70 wxCHECK_MSG( milliseconds
> 0, FALSE
, wxT("invalid value for timer timeour") );
72 lastMilli
= milli
= milliseconds
;
74 wxTimerList
.DeleteObject(this);
77 TIMERPROC wxTimerProcInst = (TIMERPROC)
78 MakeProcInstance((FARPROC)wxTimerProc, wxGetInstance());
80 id = SetTimer(NULL, (UINT)(id ? id : 1),
81 (UINT)milliseconds, wxTimerProcInst);
85 wxTimerList
.Append(id
, this);
91 wxLogSysError(_("Couldn't create a timer"));
101 // KillTimer(NULL, (UINT)id);
102 wxTimerList
.DeleteObject(this);
108 // ----------------------------------------------------------------------------
110 // ----------------------------------------------------------------------------
112 void wxProcessTimer(wxTimer
& timer
)
114 // Avoid to process spurious timer events
124 UINT
wxTimerProc(HWND
WXUNUSED(hwnd
), WORD
, int idTimer
, DWORD
)
126 wxNode
*node
= wxTimerList
.Find((long)idTimer
);
128 wxCHECK_MSG( node
, 0, wxT("bogus timer id in wxTimerProc") );
130 wxProcessTimer(*(wxTimer
*)node
->Data());