X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/047c1182f94ca7941b08170cddbb5880f1023055..e887bad5f3a10f5b0c1f173c34c694dda283d0cf:/src/cocoa/app.mm?ds=sidebyside diff --git a/src/cocoa/app.mm b/src/cocoa/app.mm index cbff3c9f2e..0ac5bca28e 100644 --- a/src/cocoa/app.mm +++ b/src/cocoa/app.mm @@ -22,7 +22,6 @@ #endif #include "wx/cocoa/ObjcRef.h" -#include "wx/cocoa/ObjcPose.h" #include "wx/cocoa/autorelease.h" #include "wx/cocoa/mbarman.h" #include "wx/cocoa/NSApplication.h" @@ -35,13 +34,10 @@ #import #import -// wxNSApplicationObserver singleton. -static wxObjcAutoRefFromAlloc sg_cocoaAppObserver = [[wxNSApplicationObserver alloc] init]; +bool wxApp::sm_isEmbedded = false; // Normally we're not a plugin -// ======================================================================== -// wxPoseAsInitializer -// ======================================================================== -wxPoseAsInitializer *wxPoseAsInitializer::sm_first = NULL; +// wxNSApplicationObserver singleton. +static wxObjcAutoRefFromAlloc sg_cocoaAppObserver = [[WX_GET_OBJC_CLASS(wxNSApplicationObserver) alloc] init]; // ======================================================================== // wxNSApplicationDelegate @@ -57,6 +53,7 @@ wxPoseAsInitializer *wxPoseAsInitializer::sm_first = NULL; } @end // implementation wxNSApplicationDelegate : NSObject +WX_IMPLEMENT_GET_OBJC_CLASS(wxNSApplicationDelegate,NSObject) // ======================================================================== // wxNSApplicationObserver @@ -94,6 +91,7 @@ wxPoseAsInitializer *wxPoseAsInitializer::sm_first = NULL; } @end // implementation wxNSApplicationObserver : NSObject +WX_IMPLEMENT_GET_OBJC_CLASS(wxNSApplicationObserver,NSObject) // ======================================================================== // wxApp @@ -103,11 +101,6 @@ wxPoseAsInitializer *wxPoseAsInitializer::sm_first = NULL; // wxApp Static member initialization // ---------------------------------------------------------------------------- IMPLEMENT_DYNAMIC_CLASS(wxApp, wxEvtHandler) -BEGIN_EVENT_TABLE(wxApp, wxEvtHandler) - EVT_IDLE(wxAppBase::OnIdle) -// EVT_END_SESSION(wxApp::OnEndSession) -// EVT_QUERY_END_SESSION(wxApp::OnQueryEndSession) -END_EVENT_TABLE() // ---------------------------------------------------------------------------- // wxApp initialization/cleanup @@ -131,10 +124,6 @@ bool wxApp::Initialize(int& argc, wxChar **argv) } } - // Posing must be completed before any instances of the Objective-C - // classes being posed as are created. - wxPoseAsInitializer::InitializePosers(); - return wxAppBase::Initialize(argc, argv); } @@ -145,10 +134,13 @@ void wxApp::CleanUp() wxDC::CocoaShutdownTextSystem(); wxMenuBarManager::DestroyInstance(); - [m_cocoaApp setDelegate:nil]; - [[NSNotificationCenter defaultCenter] removeObserver:m_cocoaAppDelegate]; - [m_cocoaAppDelegate release]; - m_cocoaAppDelegate = NULL; + [[NSNotificationCenter defaultCenter] removeObserver:sg_cocoaAppObserver]; + if(!sm_isEmbedded) + { + [m_cocoaApp setDelegate:nil]; + [m_cocoaAppDelegate release]; + m_cocoaAppDelegate = NULL; + } wxAppBase::CleanUp(); } @@ -196,9 +188,12 @@ bool wxApp::OnInitGui() // Create the app using the sharedApplication method m_cocoaApp = [NSApplication sharedApplication]; - // Enable response to application delegate messages - m_cocoaAppDelegate = [[wxNSApplicationDelegate alloc] init]; - [m_cocoaApp setDelegate:m_cocoaAppDelegate]; + if(!sm_isEmbedded) + { + // Enable response to application delegate messages + m_cocoaAppDelegate = [[WX_GET_OBJC_CLASS(wxNSApplicationDelegate) alloc] init]; + [m_cocoaApp setDelegate:m_cocoaAppDelegate]; + } // Enable response to "delegate" messages on the notification observer [[NSNotificationCenter defaultCenter] addObserver:sg_cocoaAppObserver @@ -226,7 +221,8 @@ bool wxApp::OnInitGui() selector:@selector(controlTintChanged:) name:NSControlTintDidChangeNotification object:nil]; - wxMenuBarManager::CreateInstance(); + if(!sm_isEmbedded) + wxMenuBarManager::CreateInstance(); wxDC::CocoaInitializeTextSystem(); return true;