]> git.saurik.com Git - wxWidgets.git/commitdiff
* Added GetAppMenuBar
authorDavid Elliott <dfe@tgwbd.org>
Fri, 5 Sep 2003 01:39:55 +0000 (01:39 +0000)
committerDavid Elliott <dfe@tgwbd.org>
Fri, 5 Sep 2003 01:39:55 +0000 (01:39 +0000)
* Removed Show
* Labeled (Attach|Detach)MenuBar as virtual
* Added SetMenuBar
* Implement (Attach|Detach)MenuBar using the wxMenuBarManager

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

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

index 041e7b399e9c348d78236b274b783782179548bd..91b212a2576ff18009ef100b43524356bbb27025 100644 (file)
@@ -50,6 +50,8 @@ protected:
 // ------------------------------------------------------------------------
 // Cocoa specifics
 // ------------------------------------------------------------------------
+public:
+    virtual wxMenuBar* GetAppMenuBar() { return GetMenuBar(); }
 protected:
     virtual void CocoaSetWxWindowSize(int width, int height);
 
@@ -63,14 +65,14 @@ protected:
 // Implementation
 // ------------------------------------------------------------------------
 public:
-    void AttachMenuBar(wxMenuBar *mbar);
-    void DetachMenuBar();
+    virtual void AttachMenuBar(wxMenuBar *mbar);
+    virtual void DetachMenuBar();
+    virtual void SetMenuBar(wxMenuBar *menubar);
 
     // implementation only from now on
     // -------------------------------
 
     // override some more virtuals
-    virtual bool Show( bool show = true );
 
     // get the origin of the client area (which may be different from (0, 0)
     // if the frame has a toolbar) in client coordinates
index 3c40bc0f6637f5e66556dde1cc13e10e828445bc..9d3ff26566940b3c68a5c17b3b3ee4aa4d50f510 100644 (file)
@@ -20,6 +20,7 @@
 #endif // WX_PRECOMP
 
 #include "wx/cocoa/autorelease.h"
+#include "wx/cocoa/mbarman.h"
 
 #import <AppKit/NSWindow.h>
 #import <AppKit/NSApplication.h>
@@ -58,29 +59,26 @@ wxFrame::~wxFrame()
 void wxFrame::AttachMenuBar(wxMenuBar *mbar)
 {
     wxFrameBase::AttachMenuBar(mbar);
-    if(m_frameMenuBar)
-    {
-        wxLogDebug("Attached menu");
-        [m_cocoaNSWindow setMenu:m_frameMenuBar->GetNSMenu()];
-    }
+    wxMenuBarManager::GetInstance()->UpdateWindowMenuBar(this);
 }
 
 void wxFrame::DetachMenuBar()
 {
-    if(m_frameMenuBar)
-    {
-        [m_cocoaNSWindow setMenu:nil];
-    }
     wxFrameBase::DetachMenuBar();
+    wxMenuBarManager::GetInstance()->UpdateWindowMenuBar(this);
 }
 
-bool wxFrame::Show(bool show)
+void wxFrame::SetMenuBar(wxMenuBar *menubar)
 {
-    wxAutoNSAutoreleasePool pool;
-    bool ret = wxFrameBase::Show(show);
-    if(show && GetMenuBar())
-        [wxTheApp->GetNSApplication() setMenu:GetMenuBar()->GetNSMenu() ];
-    return ret;
+    if ( menubar == GetMenuBar() )
+    {
+        // nothing to do
+        return;
+    }
+
+    wxFrameBase::DetachMenuBar();
+    wxFrameBase::AttachMenuBar(menubar);
+    wxMenuBarManager::GetInstance()->UpdateWindowMenuBar(this);
 }
 
 wxPoint wxFrame::GetClientAreaOrigin() const