From f9f9b40c642c8fc63214418f3d80d240ee3a8ae6 Mon Sep 17 00:00:00 2001 From: David Elliott Date: Fri, 13 Jul 2007 21:30:31 +0000 Subject: [PATCH] Merged 46116 from trunk (NOTE: CVS): * Add public wxApp::sm_isEmbedded flag like on wxMac. Default initialization to true but a plugin can set it to false to cause wxCocoa to not initialize things like the application delegate or the menubar manager. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@47443 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/cocoa/app.h | 2 ++ src/cocoa/app.mm | 23 ++++++++++++++++------- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/include/wx/cocoa/app.h b/include/wx/cocoa/app.h index 1e9d95e91b..61dd54cad5 100644 --- a/include/wx/cocoa/app.h +++ b/include/wx/cocoa/app.h @@ -76,6 +76,8 @@ public: bool IsInAssert() const { return m_isInAssert; } #endif // __WXDEBUG__ + // Set true _before_ initializing wx to force embedded mode (no app delegate, etc.) + static bool sm_isEmbedded; private: #ifdef __WXDEBUG__ bool m_isInAssert; diff --git a/src/cocoa/app.mm b/src/cocoa/app.mm index 2c3104a99f..27989725bf 100644 --- a/src/cocoa/app.mm +++ b/src/cocoa/app.mm @@ -39,6 +39,8 @@ #import #import +bool wxApp::sm_isEmbedded = false; // Normally we're not a plugin + // wxNSApplicationObserver singleton. static wxObjcAutoRefFromAlloc sg_cocoaAppObserver = [[wxNSApplicationObserver alloc] init]; @@ -154,10 +156,13 @@ void wxApp::CleanUp() wxDC::CocoaShutdownTextSystem(); wxMenuBarManager::DestroyInstance(); - [m_cocoaApp setDelegate:nil]; [[NSNotificationCenter defaultCenter] removeObserver:sg_cocoaAppObserver]; - [m_cocoaAppDelegate release]; - m_cocoaAppDelegate = NULL; + if(!sm_isEmbedded) + { + [m_cocoaApp setDelegate:nil]; + [m_cocoaAppDelegate release]; + m_cocoaAppDelegate = NULL; + } wxAppBase::CleanUp(); @@ -215,9 +220,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 = [[wxNSApplicationDelegate alloc] init]; + [m_cocoaApp setDelegate:m_cocoaAppDelegate]; + } // Enable response to "delegate" messages on the notification observer [[NSNotificationCenter defaultCenter] addObserver:sg_cocoaAppObserver @@ -245,7 +253,8 @@ bool wxApp::OnInitGui() selector:@selector(controlTintChanged:) name:NSControlTintDidChangeNotification object:nil]; - wxMenuBarManager::CreateInstance(); + if(!sm_isEmbedded) + wxMenuBarManager::CreateInstance(); wxDC::CocoaInitializeTextSystem(); return true;