From ba808e24125f0b777bff51566d55ff1c191293d3 Mon Sep 17 00:00:00 2001 From: David Elliott Date: Mon, 6 Oct 2003 17:12:43 +0000 Subject: [PATCH] Moved wxCocoa specific doIdle method to application delegate object git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@24104 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/cocoa/app.mm | 57 ++++++++++++++++++++++++------------------------ 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/src/cocoa/app.mm b/src/cocoa/app.mm index 2ee2c6bab8..54d1f42267 100644 --- a/src/cocoa/app.mm +++ b/src/cocoa/app.mm @@ -49,7 +49,6 @@ wxPoseAsInitializer *wxPoseAsInitializer::sm_first = NULL; { } -- (void)doIdle: (id)data; - (void)sendEvent: (NSEvent*)anEvent; @end // wxPoserNSApplication @@ -57,6 +56,33 @@ WX_IMPLEMENT_POSER(wxPoserNSApplication); @implementation wxPoserNSApplication : NSApplication +- (void)sendEvent: (NSEvent*)anEvent +{ + wxLogDebug("SendEvent"); + wxTheApp->CocoaInstallRequestedIdleHandler(); + [super sendEvent: anEvent]; +} + +@end // wxPoserNSApplication + +// ======================================================================== +// wxNSApplicationDelegate +// ======================================================================== +@interface wxNSApplicationDelegate : NSObject +{ +} + +- (void)doIdle: (id)data; +// Delegate methods +- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)theApplication; +- (void)applicationWillBecomeActive:(NSNotification *)notification; +- (void)applicationDidBecomeActive:(NSNotification *)notification; +- (void)applicationWillResignActive:(NSNotification *)notification; +- (void)applicationDidResignActive:(NSNotification *)notification; +@end // interface wxNSApplicationDelegate : NSObject + +@implementation wxNSApplicationDelegate : NSObject + - (void)doIdle: (id)data { wxASSERT(wxTheApp); @@ -90,31 +116,6 @@ WX_IMPLEMENT_POSER(wxPoserNSApplication); wxTheApp->CocoaRequestIdle(); } -- (void)sendEvent: (NSEvent*)anEvent -{ - wxLogDebug("SendEvent"); - wxTheApp->CocoaInstallRequestedIdleHandler(); - [super sendEvent: anEvent]; -} - -@end // wxPoserNSApplication - -// ======================================================================== -// wxNSApplicationDelegate -// ======================================================================== -@interface wxNSApplicationDelegate : NSObject -{ -} - -- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)theApplication; -- (void)applicationWillBecomeActive:(NSNotification *)notification; -- (void)applicationDidBecomeActive:(NSNotification *)notification; -- (void)applicationWillResignActive:(NSNotification *)notification; -- (void)applicationDidResignActive:(NSNotification *)notification; -@end // interface wxNSApplicationDelegate : NSObject - -@implementation wxNSApplicationDelegate : NSObject - // NOTE: Terminate means that the event loop does NOT return and thus // cleanup code doesn't properly execute. Furthermore, wxWindows has its // own exit on frame delete mechanism. @@ -237,7 +238,7 @@ void wxApp::CocoaInstallIdleHandler() m_isIdle = false; // Call doIdle for EVERYTHING dammit // We'd need Foundation/NSConnection.h for this next constant, do we need it? - [[ NSRunLoop currentRunLoop ] performSelector:@selector(doIdle:) target:m_cocoaApp argument:NULL order:0 modes:[NSArray arrayWithObjects:NSDefaultRunLoopMode, /* NSConnectionReplyRunLoopMode,*/ NSModalPanelRunLoopMode, /**/NSEventTrackingRunLoopMode,/**/ nil] ]; + [[ NSRunLoop currentRunLoop ] performSelector:@selector(doIdle:) target:m_cocoaAppDelegate argument:NULL order:0 modes:[NSArray arrayWithObjects:NSDefaultRunLoopMode, /* NSConnectionReplyRunLoopMode,*/ NSModalPanelRunLoopMode, /**/NSEventTrackingRunLoopMode,/**/ nil] ]; } void wxApp::CocoaDelegate_applicationWillBecomeActive() @@ -273,7 +274,7 @@ bool wxApp::OnInitGui() // [ m_cocoaApp setDelegate:m_cocoaApp ]; #if 0 wxLogDebug("Just for kicks"); - [ m_cocoaApp performSelector:@selector(doIdle:) withObject:NULL ]; + [ m_cocoaAppDelegate performSelector:@selector(doIdle:) withObject:NULL ]; wxLogDebug("okay.. done now"); #endif return TRUE; -- 2.45.2