cleanup - reformatting

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@37541 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
David Surovell 2006-02-12 23:37:07 +00:00
parent 6b71411ac9
commit 0ec80ebe6f

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////////
// Name: timer.cpp
// Name: sec/mac/carbon/timer.cpp
// Purpose: wxTimer implementation
// Author: Stefan Csomor
// Modified by:
@ -13,16 +13,17 @@
#include "wx/timer.h"
IMPLEMENT_ABSTRACT_CLASS(wxTimer, wxEvtHandler)
#ifdef __WXMAC__
#include "wx/mac/private.h"
#endif
#include "wx/dynarray.h"
#ifndef __DARWIN__
#include <Timer.h>
#endif
#include "wx/dynarray.h"
IMPLEMENT_ABSTRACT_CLASS(wxTimer, wxEvtHandler)
#define wxMAC_USE_CARBON_TIMER 1
@ -38,7 +39,7 @@ struct MacTimerInfo
static pascal void wxProcessTimer( EventLoopTimerRef theTimer, void *data );
static pascal void wxProcessTimer( EventLoopTimerRef theTimer, void *data )
{
if ( !data )
if ( data == NULL )
return;
wxTimer* timer = (wxTimer*)data;
@ -65,7 +66,8 @@ bool wxTimer::IsRunning() const
wxTimer::~wxTimer()
{
Stop();
if (m_info != NULL) {
if (m_info != NULL)
{
delete m_info;
m_info = NULL;
}
@ -80,13 +82,16 @@ bool wxTimer::Start(int milliseconds,bool mode)
m_info->m_timer = this;
m_info->m_proc = NewEventLoopTimerUPP( &wxProcessTimer );
verify_noerr( InstallEventLoopTimer (
OSStatus err = InstallEventLoopTimer(
GetMainEventLoop(),
m_milli*kEventDurationMillisecond,
IsOneShot() ? 0 : m_milli * kEventDurationMillisecond,
m_info->m_proc,
this,
&m_info->m_timerRef) ) ;
&m_info->m_timerRef );
verify_noerr( err );
return true;
}
@ -96,6 +101,7 @@ void wxTimer::Stop()
RemoveEventLoopTimer( m_info->m_timerRef );
if (m_info->m_proc)
DisposeEventLoopTimerUPP( m_info->m_proc );
m_info->m_proc = NULL;
m_info->m_timerRef = kInvalidID;
}
@ -114,7 +120,7 @@ static void wxProcessTimer( unsigned long event , void *data ) ;
static pascal void MacTimerProc( TMTask * t )
{
MacTimerInfo * tm = (MacTimerInfo*) t;
wxMacAddEvent( tm->m_table , wxProcessTimer, 0 , (void*) tm->m_timer , TRUE ) ;
wxMacAddEvent( tm->m_table, wxProcessTimer, 0, (void*) tm->m_timer, true );
}
// we need this array to track timers that are being deleted within the Notify procedure
@ -125,30 +131,24 @@ wxArrayPtrVoid gTimersInProcess ;
static void wxProcessTimer( unsigned long event, void *data )
{
if ( !data )
if ( data == NULL )
return;
wxTimer* timer = (wxTimer*) data;
if ( timer->IsOneShot() )
timer->Stop();
gTimersInProcess.Add( timer );
timer->Notify();
int index = gTimersInProcess.Index( timer );
if ( index != wxNOT_FOUND )
{
gTimersInProcess.RemoveAt( index );
if ( !timer->IsOneShot() && timer->m_info->m_task.tmAddr )
{
PrimeTime( (QElemPtr) &timer->m_info->m_task, timer->GetInterval() );
}
}
}
void wxTimer::Init()
@ -172,10 +172,12 @@ bool wxTimer::IsRunning() const
wxTimer::~wxTimer()
{
Stop();
if (m_info != NULL) {
if (m_info != NULL)
{
delete m_info;
m_info = NULL;
}
int index = gTimersInProcess.Index( this );
if ( index != wxNOT_FOUND )
gTimersInProcess.RemoveAt( index );
@ -195,6 +197,7 @@ bool wxTimer::Start(int milliseconds,bool mode)
m_info->m_timer = this;
InsXTime( (QElemPtr) &m_info->m_task );
PrimeTime( (QElemPtr) &m_info->m_task, m_milli );
return true;
}
@ -206,9 +209,8 @@ void wxTimer::Stop()
DisposeTimerUPP( m_info->m_task.tmAddr );
m_info->m_task.tmAddr = NULL;
}
wxMacRemoveAllNotifiersForData( wxMacGetNotifierTable(), this );
}
#endif