X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c0badb709a86b91a203416784b649e3d00c699c7..74a8f67d96591cec101def2a7d47c64072aff7fd:/src/cocoa/timer.mm diff --git a/src/cocoa/timer.mm b/src/cocoa/timer.mm index 4815472d7b..259011013d 100644 --- a/src/cocoa/timer.mm +++ b/src/cocoa/timer.mm @@ -22,34 +22,27 @@ #if wxUSE_TIMER -#include "wx/timer.h" - -#ifndef WX_PRECOMP -#endif - +#include "wx/cocoa/private/timer.h" #include "wx/cocoa/autorelease.h" -#import +#include "wx/cocoa/objc/objc_uniquifying.h" -// ============================================================================ -// implementation -// ============================================================================ - -IMPLEMENT_CLASS(wxTimer, wxTimerBase) +#import // ======================================================================== // wxNSTimerData // ======================================================================== @interface wxNSTimerData : NSObject { - wxTimer* m_timer; + wxCocoaTimerImpl* m_timer; } - (id)init; -- (id)initWithWxTimer:(wxTimer*)theTimer; -- (wxTimer*)timer; +- (id)initWithWxTimer:(wxCocoaTimerImpl*)theTimer; +- (wxCocoaTimerImpl*)timer; - (void)onNotify:(NSTimer *)theTimer; @end // interface wxNSTimerData : NSObject +WX_DECLARE_GET_OBJC_CLASS(wxNSTimerData,NSObject) @implementation wxNSTimerData : NSObject - (id)init @@ -60,7 +53,7 @@ IMPLEMENT_CLASS(wxTimer, wxTimerBase) return self; } -- (id)initWithWxTimer:(wxTimer*)theTimer; +- (id)initWithWxTimer:(wxCocoaTimerImpl*)theTimer; { if(!(self = [super init])) return nil; @@ -68,38 +61,39 @@ IMPLEMENT_CLASS(wxTimer, wxTimerBase) return self; } -- (wxTimer*)timer +- (wxCocoaTimerImpl*)timer { return m_timer; } - (void)onNotify:(NSTimer *)theTimer { - m_timer->Notify(); //wxTimerBase method + m_timer->Notify(); } @end +WX_IMPLEMENT_GET_OBJC_CLASS(wxNSTimerData,NSObject) // ---------------------------------------------------------------------------- -// wxTimer +// wxCocoaTimerImpl // ---------------------------------------------------------------------------- -wxTimer::~wxTimer() +wxCocoaTimerImpl::~wxCocoaTimerImpl() { Stop(); } -void wxTimer::Init() +void wxCocoaTimerImpl::Init() { m_cocoaNSTimer = NULL; } -bool wxTimer::Start(int millisecs, bool oneShot) +bool wxCocoaTimerImpl::Start(int millisecs, bool oneShot) { Stop(); wxAutoNSAutoreleasePool thePool; - wxNSTimerData *timerData = [[wxNSTimerData alloc] initWithWxTimer:this]; + wxNSTimerData *timerData = [[WX_GET_OBJC_CLASS(wxNSTimerData) alloc] initWithWxTimer:this]; m_cocoaNSTimer = [[NSTimer scheduledTimerWithTimeInterval: millisecs / 1000.0 //seconds target: timerData @@ -111,7 +105,7 @@ bool wxTimer::Start(int millisecs, bool oneShot) return IsRunning(); } -void wxTimer::Stop() +void wxCocoaTimerImpl::Stop() { if (m_cocoaNSTimer) { @@ -122,7 +116,7 @@ void wxTimer::Stop() } } -bool wxTimer::IsRunning() const +bool wxCocoaTimerImpl::IsRunning() const { return m_cocoaNSTimer != NULL && [m_cocoaNSTimer isValid]; }