cocoa wxTimer
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31752 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
		
							
								
								
									
										40
									
								
								Makefile.in
									
									
									
									
									
								
							
							
						
						
									
										40
									
								
								Makefile.in
									
									
									
									
									
								
							| @@ -3207,6 +3207,7 @@ COND_TOOLKIT_COCOA___GUI_SRC_OBJECTS =  \ | ||||
| 	monodll_statline2.o \
 | ||||
| 	monodll_stattext.o \
 | ||||
| 	monodll_textctrl.o \
 | ||||
| 	monodll_timer.o \
 | ||||
| 	monodll_toolbar.o \
 | ||||
| 	monodll_tooltip.o \
 | ||||
| 	monodll_toplevel.o \
 | ||||
| @@ -3225,8 +3226,7 @@ COND_TOOLKIT_COCOA___GUI_SRC_OBJECTS =  \ | ||||
| 	monodll_paletteg.o \
 | ||||
| 	monodll_regiong.o \
 | ||||
| 	monodll_statusbr.o \
 | ||||
| 	monodll_tabg.o \
 | ||||
| 	monodll_timer.o | ||||
| 	monodll_tabg.o | ||||
| @COND_TOOLKIT_COCOA@__GUI_SRC_OBJECTS = $(COND_TOOLKIT_COCOA___GUI_SRC_OBJECTS) | ||||
| COND_TOOLKIT_GTK___GUI_SRC_OBJECTS =  \
 | ||||
| 	monodll_accel.o \
 | ||||
| @@ -4649,6 +4649,7 @@ COND_TOOLKIT_COCOA___GUI_SRC_OBJECTS_1 =  \ | ||||
| 	monolib_statline2.o \
 | ||||
| 	monolib_stattext.o \
 | ||||
| 	monolib_textctrl.o \
 | ||||
| 	monolib_timer.o \
 | ||||
| 	monolib_toolbar.o \
 | ||||
| 	monolib_tooltip.o \
 | ||||
| 	monolib_toplevel.o \
 | ||||
| @@ -4667,8 +4668,7 @@ COND_TOOLKIT_COCOA___GUI_SRC_OBJECTS_1 =  \ | ||||
| 	monolib_paletteg.o \
 | ||||
| 	monolib_regiong.o \
 | ||||
| 	monolib_statusbr.o \
 | ||||
| 	monolib_tabg.o \
 | ||||
| 	monolib_timer.o | ||||
| 	monolib_tabg.o | ||||
| @COND_TOOLKIT_COCOA@__GUI_SRC_OBJECTS_1 = $(COND_TOOLKIT_COCOA___GUI_SRC_OBJECTS_1) | ||||
| COND_TOOLKIT_GTK___GUI_SRC_OBJECTS_1 =  \
 | ||||
| 	monolib_accel.o \
 | ||||
| @@ -6281,6 +6281,7 @@ COND_TOOLKIT_COCOA___GUI_SRC_OBJECTS_2 =  \ | ||||
| 	coredll_statline2.o \
 | ||||
| 	coredll_stattext.o \
 | ||||
| 	coredll_textctrl.o \
 | ||||
| 	coredll_timer.o \
 | ||||
| 	coredll_toolbar.o \
 | ||||
| 	coredll_tooltip.o \
 | ||||
| 	coredll_toplevel.o \
 | ||||
| @@ -6299,8 +6300,7 @@ COND_TOOLKIT_COCOA___GUI_SRC_OBJECTS_2 =  \ | ||||
| 	coredll_paletteg.o \
 | ||||
| 	coredll_regiong.o \
 | ||||
| 	coredll_statusbr.o \
 | ||||
| 	coredll_tabg.o \
 | ||||
| 	coredll_timer.o | ||||
| 	coredll_tabg.o | ||||
| @COND_TOOLKIT_COCOA@__GUI_SRC_OBJECTS_2 = $(COND_TOOLKIT_COCOA___GUI_SRC_OBJECTS_2) | ||||
| COND_TOOLKIT_GTK___GUI_SRC_OBJECTS_2 =  \
 | ||||
| 	coredll_accel.o \
 | ||||
| @@ -7472,6 +7472,7 @@ COND_TOOLKIT_COCOA___GUI_SRC_OBJECTS_3 =  \ | ||||
| 	corelib_statline2.o \
 | ||||
| 	corelib_stattext.o \
 | ||||
| 	corelib_textctrl.o \
 | ||||
| 	corelib_timer.o \
 | ||||
| 	corelib_toolbar.o \
 | ||||
| 	corelib_tooltip.o \
 | ||||
| 	corelib_toplevel.o \
 | ||||
| @@ -7490,8 +7491,7 @@ COND_TOOLKIT_COCOA___GUI_SRC_OBJECTS_3 =  \ | ||||
| 	corelib_paletteg.o \
 | ||||
| 	corelib_regiong.o \
 | ||||
| 	corelib_statusbr.o \
 | ||||
| 	corelib_tabg.o \
 | ||||
| 	corelib_timer.o | ||||
| 	corelib_tabg.o | ||||
| @COND_TOOLKIT_COCOA@__GUI_SRC_OBJECTS_3 = $(COND_TOOLKIT_COCOA___GUI_SRC_OBJECTS_3) | ||||
| COND_TOOLKIT_GTK___GUI_SRC_OBJECTS_3 =  \
 | ||||
| 	corelib_accel.o \
 | ||||
| @@ -11337,9 +11337,6 @@ monodll_gprint.o: $(srcdir)/src/gtk/gnome/gprint.cpp $(MONODLL_ODEP) | ||||
| @COND_TOOLKIT_WINCE_USE_GUI_1@monodll_timer.o: $(srcdir)/src/msw/timer.cpp $(MONODLL_ODEP) | ||||
| @COND_TOOLKIT_WINCE_USE_GUI_1@	$(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/msw/timer.cpp | ||||
| 
 | ||||
| @COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@monodll_timer.o: $(srcdir)/src/generic/timer.cpp $(MONODLL_ODEP) | ||||
| @COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@	$(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/generic/timer.cpp | ||||
| 
 | ||||
| @COND_TOOLKIT_X11_USE_GUI_1@monodll_timer.o: $(srcdir)/src/generic/timer.cpp $(MONODLL_ODEP) | ||||
| @COND_TOOLKIT_X11_USE_GUI_1@	$(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/generic/timer.cpp | ||||
| 
 | ||||
| @@ -11352,6 +11349,9 @@ monodll_gprint.o: $(srcdir)/src/gtk/gnome/gprint.cpp $(MONODLL_ODEP) | ||||
| @COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@monodll_timer.o: $(srcdir)/src/mac/carbon/timer.cpp $(MONODLL_ODEP) | ||||
| @COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@	$(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/mac/carbon/timer.cpp | ||||
| 
 | ||||
| @COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@monodll_timer.o: $(srcdir)/src/cocoa/timer.mm $(MONODLL_ODEP) | ||||
| @COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@	$(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/cocoa/timer.mm | ||||
| 
 | ||||
| @COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@monodll_timer.o: $(srcdir)/src/os2/timer.cpp $(MONODLL_ODEP) | ||||
| @COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@	$(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/os2/timer.cpp | ||||
| 
 | ||||
| @@ -14721,9 +14721,6 @@ monolib_gprint.o: $(srcdir)/src/gtk/gnome/gprint.cpp $(MONOLIB_ODEP) | ||||
| @COND_TOOLKIT_WINCE_USE_GUI_1@monolib_timer.o: $(srcdir)/src/msw/timer.cpp $(MONOLIB_ODEP) | ||||
| @COND_TOOLKIT_WINCE_USE_GUI_1@	$(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/msw/timer.cpp | ||||
| 
 | ||||
| @COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@monolib_timer.o: $(srcdir)/src/generic/timer.cpp $(MONOLIB_ODEP) | ||||
| @COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@	$(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/generic/timer.cpp | ||||
| 
 | ||||
| @COND_TOOLKIT_X11_USE_GUI_1@monolib_timer.o: $(srcdir)/src/generic/timer.cpp $(MONOLIB_ODEP) | ||||
| @COND_TOOLKIT_X11_USE_GUI_1@	$(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/generic/timer.cpp | ||||
| 
 | ||||
| @@ -14736,6 +14733,9 @@ monolib_gprint.o: $(srcdir)/src/gtk/gnome/gprint.cpp $(MONOLIB_ODEP) | ||||
| @COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@monolib_timer.o: $(srcdir)/src/mac/carbon/timer.cpp $(MONOLIB_ODEP) | ||||
| @COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@	$(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/mac/carbon/timer.cpp | ||||
| 
 | ||||
| @COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@monolib_timer.o: $(srcdir)/src/cocoa/timer.mm $(MONOLIB_ODEP) | ||||
| @COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@	$(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/cocoa/timer.mm | ||||
| 
 | ||||
| @COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@monolib_timer.o: $(srcdir)/src/os2/timer.cpp $(MONOLIB_ODEP) | ||||
| @COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@	$(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/os2/timer.cpp | ||||
| 
 | ||||
| @@ -18507,9 +18507,6 @@ coredll_win32.o: $(srcdir)/src/univ/themes/win32.cpp $(COREDLL_ODEP) | ||||
| @COND_TOOLKIT_WINCE_USE_GUI_1@coredll_timer.o: $(srcdir)/src/msw/timer.cpp $(COREDLL_ODEP) | ||||
| @COND_TOOLKIT_WINCE_USE_GUI_1@	$(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/msw/timer.cpp | ||||
| 
 | ||||
| @COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@coredll_timer.o: $(srcdir)/src/generic/timer.cpp $(COREDLL_ODEP) | ||||
| @COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@	$(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/generic/timer.cpp | ||||
| 
 | ||||
| @COND_TOOLKIT_X11_USE_GUI_1@coredll_timer.o: $(srcdir)/src/generic/timer.cpp $(COREDLL_ODEP) | ||||
| @COND_TOOLKIT_X11_USE_GUI_1@	$(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/generic/timer.cpp | ||||
| 
 | ||||
| @@ -18522,6 +18519,9 @@ coredll_win32.o: $(srcdir)/src/univ/themes/win32.cpp $(COREDLL_ODEP) | ||||
| @COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@coredll_timer.o: $(srcdir)/src/mac/carbon/timer.cpp $(COREDLL_ODEP) | ||||
| @COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@	$(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/mac/carbon/timer.cpp | ||||
| 
 | ||||
| @COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@coredll_timer.o: $(srcdir)/src/cocoa/timer.mm $(COREDLL_ODEP) | ||||
| @COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@	$(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/cocoa/timer.mm | ||||
| 
 | ||||
| @COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@coredll_timer.o: $(srcdir)/src/os2/timer.cpp $(COREDLL_ODEP) | ||||
| @COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@	$(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/os2/timer.cpp | ||||
| 
 | ||||
| @@ -21000,9 +21000,6 @@ corelib_win32.o: $(srcdir)/src/univ/themes/win32.cpp $(CORELIB_ODEP) | ||||
| @COND_TOOLKIT_WINCE_USE_GUI_1@corelib_timer.o: $(srcdir)/src/msw/timer.cpp $(CORELIB_ODEP) | ||||
| @COND_TOOLKIT_WINCE_USE_GUI_1@	$(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/msw/timer.cpp | ||||
| 
 | ||||
| @COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@corelib_timer.o: $(srcdir)/src/generic/timer.cpp $(CORELIB_ODEP) | ||||
| @COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@	$(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/generic/timer.cpp | ||||
| 
 | ||||
| @COND_TOOLKIT_X11_USE_GUI_1@corelib_timer.o: $(srcdir)/src/generic/timer.cpp $(CORELIB_ODEP) | ||||
| @COND_TOOLKIT_X11_USE_GUI_1@	$(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/generic/timer.cpp | ||||
| 
 | ||||
| @@ -21015,6 +21012,9 @@ corelib_win32.o: $(srcdir)/src/univ/themes/win32.cpp $(CORELIB_ODEP) | ||||
| @COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@corelib_timer.o: $(srcdir)/src/mac/carbon/timer.cpp $(CORELIB_ODEP) | ||||
| @COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@	$(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/mac/carbon/timer.cpp | ||||
| 
 | ||||
| @COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@corelib_timer.o: $(srcdir)/src/cocoa/timer.mm $(CORELIB_ODEP) | ||||
| @COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@	$(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/cocoa/timer.mm | ||||
| 
 | ||||
| @COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@corelib_timer.o: $(srcdir)/src/os2/timer.cpp $(CORELIB_ODEP) | ||||
| @COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@	$(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/os2/timer.cpp | ||||
| 
 | ||||
|   | ||||
| @@ -2038,6 +2038,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file! | ||||
|     src/cocoa/statline2.mm | ||||
|     src/cocoa/stattext.mm | ||||
|     src/cocoa/textctrl.mm | ||||
|     src/cocoa/timer.mm | ||||
|     src/cocoa/toolbar.mm | ||||
|     src/cocoa/tooltip.mm | ||||
|     src/cocoa/toplevel.mm | ||||
| @@ -2058,7 +2059,6 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file! | ||||
|     src/generic/regiong.cpp | ||||
|     src/generic/statusbr.cpp | ||||
|     src/generic/tabg.cpp | ||||
|     src/generic/timer.cpp | ||||
| </set> | ||||
| <set var="COCOA_HDR" hints="files"> | ||||
|     wx/cocoa/NSApplication.h | ||||
| @@ -2128,6 +2128,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file! | ||||
|     wx/cocoa/statline.h | ||||
|     wx/cocoa/stattext.h | ||||
|     wx/cocoa/textctrl.h | ||||
|     wx/cocoa/timer.h | ||||
|     wx/cocoa/toolbar.h | ||||
|     wx/cocoa/toplevel.h | ||||
|     wx/cocoa/window.h | ||||
|   | ||||
							
								
								
									
										52
									
								
								include/wx/cocoa/timer.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										52
									
								
								include/wx/cocoa/timer.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,52 @@ | ||||
| ///////////////////////////////////////////////////////////////////////////// | ||||
| // Name:        timer.h | ||||
| // Purpose:     Cocoa wxTimer class | ||||
| // Author:      Ryan Norton | ||||
| // Id:          $Id$ | ||||
| // Copyright:   (c) Ryan Norton | ||||
| // Licence:     wxWindows licence | ||||
| ///////////////////////////////////////////////////////////////////////////// | ||||
|  | ||||
|  | ||||
| #ifndef __WX_TIMER_H__ | ||||
| #define __WX_TIMER_H__ | ||||
|  | ||||
| #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) | ||||
|     #pragma interface "timer.h" | ||||
| #endif | ||||
|  | ||||
| #include "wx/cocoa/ObjcRef.h" | ||||
|  | ||||
| //----------------------------------------------------------------------------- | ||||
| // wxTimer | ||||
| //----------------------------------------------------------------------------- | ||||
|  | ||||
| DECLARE_WXCOCOA_OBJC_CLASS(NSTimer); | ||||
|  | ||||
| class WXDLLEXPORT wxTimer : public wxTimerBase | ||||
| { | ||||
| public: | ||||
|     wxTimer() { Init(); } | ||||
|     wxTimer(wxEvtHandler *owner, int timerid = -1) : wxTimerBase(owner, timerid) | ||||
|         { Init(); } | ||||
|     ~wxTimer(); | ||||
|  | ||||
|     virtual bool Start(int millisecs = -1, bool oneShot = false); | ||||
|     virtual void Stop(); | ||||
|  | ||||
|     virtual bool IsRunning() const; | ||||
|  | ||||
|     inline WX_NSTimer GetNSTimer() | ||||
|     {   return m_cocoaNSTimer; } | ||||
|  | ||||
| protected: | ||||
|     void Init(); | ||||
|  | ||||
| private: | ||||
|     WX_NSTimer m_cocoaNSTimer; | ||||
|     static const wxObjcAutoRefFromAlloc<struct objc_object *> sm_cocoaDelegate; | ||||
|  | ||||
|     DECLARE_ABSTRACT_CLASS(wxTimer) | ||||
| }; | ||||
|  | ||||
| #endif // __WX_TIMER_H__ | ||||
| @@ -118,8 +118,10 @@ protected: | ||||
|     #include "wx/motif/timer.h" | ||||
| #elif defined(__WXGTK__) | ||||
|     #include "wx/gtk/timer.h" | ||||
| #elif defined(__WXX11__) || defined(__WXMGL__) || defined(__WXCOCOA__) | ||||
| #elif defined(__WXX11__) || defined(__WXMGL__) | ||||
|     #include "wx/generic/timer.h" | ||||
| #elif defined (__WXCOCOA__) | ||||
|     #include "wx/cocoa/timer.h" | ||||
| #elif defined(__WXMAC__) | ||||
|     #include "wx/mac/timer.h" | ||||
| #elif defined(__WXPM__) | ||||
|   | ||||
							
								
								
									
										123
									
								
								src/cocoa/timer.mm
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										123
									
								
								src/cocoa/timer.mm
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,123 @@ | ||||
| ///////////////////////////////////////////////////////////////////////////// | ||||
| // Name:        src/cocoa/timer.mm | ||||
| // Purpose:     wxTimer for wxCocoa | ||||
| // Author:      Ryan Norton | ||||
| // Modified by: | ||||
| // Created:     2005-02-04 | ||||
| // RCS-ID:      $Id$ | ||||
| // Copyright:   (c) Ryan Norton | ||||
| // Licence:     wxWindows licence | ||||
| ///////////////////////////////////////////////////////////////////////////// | ||||
|  | ||||
| // ============================================================================ | ||||
| // declarations | ||||
| // ============================================================================ | ||||
|  | ||||
| // ---------------------------------------------------------------------------- | ||||
| // headers | ||||
| // ---------------------------------------------------------------------------- | ||||
|  | ||||
| // For compilers that support precompilation, includes "wx.h". | ||||
| #include "wx/wxprec.h" | ||||
|  | ||||
| #if wxUSE_TIMER | ||||
|  | ||||
| #ifndef WX_PRECOMP | ||||
|     #include "wx/timer.h" | ||||
| #endif | ||||
|  | ||||
| #import <Foundation/NSTimer.h> | ||||
|  | ||||
| // ============================================================================ | ||||
| // implementation | ||||
| // ============================================================================ | ||||
|  | ||||
| IMPLEMENT_CLASS(wxTimer, wxTimerBase) | ||||
|  | ||||
| // ======================================================================== | ||||
| // wxNSTimerDelegate | ||||
| // ======================================================================== | ||||
| @interface wxNSTimerDelegate : NSObject | ||||
| { | ||||
| } | ||||
|  | ||||
| - (void)onNotify:(NSTimer *)theTimer; | ||||
| @end // interface wxNSTimerDelegate : NSObject | ||||
|  | ||||
| // ======================================================================== | ||||
| // wxNSTimerData | ||||
| // ======================================================================== | ||||
| @interface wxNSTimerData : NSObject | ||||
| { | ||||
|     wxTimer* m_timer; | ||||
| } | ||||
|  | ||||
| - (id)setTimer:(wxTimer*)theTimer; | ||||
| - (wxTimer*)timer; | ||||
| @end // interface wxNSTimerData : NSObject | ||||
|  | ||||
| @implementation wxNSTimerData : NSObject | ||||
| - (id)setTimer:(wxTimer*)theTimer; | ||||
| { | ||||
|     m_timer = theTimer; | ||||
|     return self; | ||||
| } | ||||
| - (wxTimer*)timer | ||||
| { | ||||
|     return m_timer; | ||||
| } | ||||
| @end  | ||||
|  | ||||
| @implementation wxNSTimerDelegate : NSObject | ||||
| - (void)onNotify:(NSTimer *)theTimer | ||||
| { | ||||
|     wxNSTimerData* theData = [theTimer userInfo]; | ||||
|     [theData timer]->Notify(); //wxTimerBase method | ||||
| } | ||||
| @end  | ||||
|  | ||||
| // ---------------------------------------------------------------------------- | ||||
| // wxTimer | ||||
| // ---------------------------------------------------------------------------- | ||||
|  | ||||
| const wxObjcAutoRefFromAlloc<struct objc_object*> wxTimer::sm_cocoaDelegate = [[wxNSTimerDelegate alloc] init]; | ||||
|  | ||||
| wxTimer::~wxTimer() | ||||
| { | ||||
|     Stop(); | ||||
| } | ||||
|  | ||||
| void wxTimer::Init() | ||||
| { | ||||
|     m_cocoaNSTimer = NULL; | ||||
| } | ||||
|  | ||||
| bool wxTimer::Start(int millisecs, bool oneShot) | ||||
| { | ||||
|     m_cocoaNSTimer =     [[NSTimer  | ||||
|             scheduledTimerWithTimeInterval: millisecs / 1000.0 //seconds | ||||
|             target:		wxTimer::sm_cocoaDelegate | ||||
|             selector:	@selector(onNotify:)  | ||||
|             userInfo:	[[wxNSTimerData alloc] setTimer:this] | ||||
|             repeats:	oneShot == false] retain]; | ||||
|                         | ||||
|     return IsRunning(); | ||||
| } | ||||
|  | ||||
| void wxTimer::Stop() | ||||
| { | ||||
|     if (m_cocoaNSTimer) | ||||
|     { | ||||
|         [m_cocoaNSTimer invalidate]; | ||||
|         [[m_cocoaNSTimer userInfo] release]; | ||||
|         [m_cocoaNSTimer release]; | ||||
|     } | ||||
| } | ||||
|  | ||||
| bool wxTimer::IsRunning() const | ||||
| { | ||||
|     return m_cocoaNSTimer != NULL && [m_cocoaNSTimer isValid]; | ||||
| } | ||||
|  | ||||
| #endif // wxUSE_TIMER | ||||
|  | ||||
		Reference in New Issue
	
	Block a user