]>
git.saurik.com Git - wxWidgets.git/blob - src/mac/timer.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxTimer implementation
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "timer.h"
18 #if !USE_SHARED_LIBRARY
19 IMPLEMENT_ABSTRACT_CLASS(wxTimer
, wxObject
)
22 static void wxProcessTimer( unsigned long event
, void *data
) ;
24 static pascal void MacTimerProc( TMTask
* t
)
26 MacTimerInfo
* tm
= (MacTimerInfo
*) t
;
27 wxMacAddEvent( tm
->m_table
, wxProcessTimer
, 0 , (void*) tm
->m_timer
, TRUE
) ;
30 static void wxProcessTimer( unsigned long event
, void *data
)
35 wxTimer
* timer
= (wxTimer
*) data
;
36 if ( timer
->IsOneShot() )
41 if ( timer
->m_info
.m_task
.tmAddr
&& !timer
->IsOneShot() )
43 PrimeTime( (QElemPtr
) &timer
->m_info
.m_task
, timer
->GetInterval() ) ;
49 m_info
.m_task
.tmAddr
= NULL
;
50 m_info
.m_task
.tmWakeUp
= 0 ;
51 m_info
.m_task
.tmReserved
= 0 ;
52 m_info
.m_task
.qType
= 0 ;
53 m_info
.m_table
= wxMacGetNotifierTable() ;
54 m_info
.m_timer
= this ;
57 bool wxTimer::IsRunning() const
59 return ( m_info
.m_task
.qType
& kTMTaskActive
) ;
67 bool wxTimer::Start(int milliseconds
,bool mode
)
69 (void)wxTimerBase::Start(milliseconds
, mode
);
71 wxCHECK_MSG( m_milli
> 0, FALSE
, wxT("invalid value for timer timeour") );
72 wxCHECK_MSG( m_info
.m_task
.tmAddr
== NULL
, FALSE
, wxT("attempting to restart a timer") );
74 m_milli
= milliseconds
;
75 m_info
.m_task
.tmAddr
= NewTimerProc( MacTimerProc
) ;
76 m_info
.m_task
.tmWakeUp
= 0 ;
77 m_info
.m_task
.tmReserved
= 0 ;
78 InsXTime((QElemPtr
) &m_info
.m_task
) ;
79 PrimeTime( (QElemPtr
) &m_info
.m_task
, m_milli
) ;
86 if ( m_info
.m_task
.tmAddr
)
88 RmvTime( (QElemPtr
) &m_info
.m_task
) ;
89 DisposeTimerUPP(m_info
.m_task
.tmAddr
) ;
90 m_info
.m_task
.tmAddr
= NULL
;
92 wxMacRemoveAllNotifiersForData( wxMacGetNotifierTable() , this ) ;