]> git.saurik.com Git - wxWidgets.git/blobdiff - src/cocoa/frame.mm
mention ShouldInheritColours() change
[wxWidgets.git] / src / cocoa / frame.mm
index d4b5fbfa8387d24585dddf996e47557f3fb0647b..f74bbf4a0a25279e26a0724d796c4a2e5af28762 100644 (file)
@@ -19,9 +19,8 @@
     #include "wx/statusbr.h"
 #endif // WX_PRECOMP
 
-#include "wx/menuitem.h"
-
 #include "wx/cocoa/autorelease.h"
+#include "wx/cocoa/mbarman.h"
 
 #import <AppKit/NSWindow.h>
 #import <AppKit/NSApplication.h>
@@ -57,37 +56,29 @@ wxFrame::~wxFrame()
     [m_frameNSView release];
 }
 
-void wxFrame::Cocoa_wxMenuItemAction(wxMenuItem& item)
-{
-    Command(item.GetId());
-}
-
 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
@@ -106,6 +97,13 @@ void wxFrame::CocoaSetWxWindowSize(int width, int height)
     wxTopLevelWindow::CocoaSetWxWindowSize(width,height);
 }
 
+WX_NSView wxFrame::GetNonClientNSView()
+{
+    if(m_frameNSView)
+        return m_frameNSView;
+    return GetNSViewForSuperview();
+}
+
 void wxFrame::CocoaReplaceView(WX_NSView oldView, WX_NSView newView)
 {
     // If we have the additional toolbar/statbar view, then the