]> git.saurik.com Git - wxWidgets.git/commitdiff
* Add public wxApp::sm_isEmbedded flag like on wxMac. Default initialization
authorDavid Elliott <dfe@tgwbd.org>
Fri, 18 May 2007 19:52:14 +0000 (19:52 +0000)
committerDavid Elliott <dfe@tgwbd.org>
Fri, 18 May 2007 19:52:14 +0000 (19:52 +0000)
  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.
* Fix call to [NSNotificationCenter removeObserver:] to use the correct object.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@46116 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/cocoa/app.h
src/cocoa/app.mm

index 4c44be6a8e43e04f9f39792ce5096580359ba71d..326b317d02382250b1d6a4348651ec6388d66b06 100644 (file)
@@ -74,6 +74,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;
index 00ca9fb6dc30b231144a61107530db13d6564b78..f1d604d3791e577b924f41370bb1229334212f1d 100644 (file)
@@ -34,6 +34,8 @@
 #import <Foundation/NSNotification.h>
 #import <AppKit/NSCell.h>
 
+bool      wxApp::sm_isEmbedded = false; // Normally we're not a plugin
+
 // wxNSApplicationObserver singleton.
 static wxObjcAutoRefFromAlloc<wxNSApplicationObserver*> sg_cocoaAppObserver = [[wxNSApplicationObserver alloc] init];
 
@@ -135,10 +137,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();
 }
@@ -186,9 +191,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
@@ -216,7 +224,8 @@ bool wxApp::OnInitGui()
         selector:@selector(controlTintChanged:)
         name:NSControlTintDidChangeNotification object:nil];
 
-    wxMenuBarManager::CreateInstance();
+    if(!sm_isEmbedded)
+        wxMenuBarManager::CreateInstance();
 
     wxDC::CocoaInitializeTextSystem();
     return true;