]> git.saurik.com Git - wxWidgets.git/blobdiff - src/cocoa/frame.mm
Blind fix for library ordering.
[wxWidgets.git] / src / cocoa / frame.mm
index c9eec7426de1c288bc148bbcb6ef0670e905bb4b..f74bbf4a0a25279e26a0724d796c4a2e5af28762 100644 (file)
@@ -9,15 +9,18 @@
 // Licence:     wxWindows license
 /////////////////////////////////////////////////////////////////////////////
 
-#include "wx/frame.h"
-#include "wx/menu.h"
-#include "wx/menuitem.h"
-#include "wx/app.h"
-#include "wx/log.h"
-#include "wx/statusbr.h"
-#include "wx/toolbar.h"
+#include "wx/wxprec.h"
+#ifndef WX_PRECOMP
+    #include "wx/log.h"
+    #include "wx/app.h"
+    #include "wx/frame.h"
+    #include "wx/menu.h"
+    #include "wx/toolbar.h"
+    #include "wx/statusbr.h"
+#endif // WX_PRECOMP
 
 #include "wx/cocoa/autorelease.h"
+#include "wx/cocoa/mbarman.h"
 
 #import <AppKit/NSWindow.h>
 #import <AppKit/NSApplication.h>
@@ -53,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
@@ -95,11 +90,20 @@ void wxFrame::CocoaSetWxWindowSize(int width, int height)
 {
     if(m_frameStatusBar)
         height += m_frameStatusBar->GetSize().y;
+#if wxUSE_TOOLBAR
     if(m_frameToolBar)
         height += m_frameToolBar->GetSize().y;
+#endif //wxUSE_TOOLBAR
     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
@@ -121,6 +125,7 @@ void wxFrame::UpdateFrameNSView()
     }
     NSRect frameRect = [m_frameNSView frame];
     float tbarheight = 0.0;
+#if wxUSE_TOOLBAR
     if(m_frameToolBar)
     {
         NSView *tbarNSView = m_frameToolBar->GetNSViewForSuperview();
@@ -135,6 +140,7 @@ void wxFrame::UpdateFrameNSView()
         [tbarNSView setAutoresizingMask: NSViewWidthSizable|NSViewMinYMargin];
         tbarheight = tbarRect.size.height;
     }
+#endif //wxUSE_TOOLBAR
     float sbarheight = 0.0;
     if(m_frameStatusBar)
     {
@@ -168,9 +174,9 @@ void wxFrame::SetStatusBar(wxStatusBar *statusbar)
     if(m_frameStatusBar)
     {
         [m_frameStatusBar->GetNSViewForSuperview() removeFromSuperview];
-        [m_frameStatusBar->GetNSViewForSuperview() setAutoresizingMask: NSViewNotSizable];
+        [m_frameStatusBar->GetNSViewForSuperview() setAutoresizingMask: NSViewMinYMargin];
         if(m_frameStatusBar->GetParent())
-            m_frameStatusBar->GetParent()->CocoaAddChild(m_frameToolBar);
+            m_frameStatusBar->GetParent()->CocoaAddChild(m_frameStatusBar);
     }
     m_frameStatusBar = statusbar;
     if(m_frameStatusBar)
@@ -194,12 +200,13 @@ wxStatusBar* wxFrame::CreateStatusBar(int number,
     return m_frameStatusBar;
 }
 
+#if wxUSE_TOOLBAR
 void wxFrame::SetToolBar(wxToolBar *toolbar)
 {
     if(m_frameToolBar)
     {
         [m_frameToolBar->GetNSViewForSuperview() removeFromSuperview];
-        [m_frameToolBar->GetNSViewForSuperview() setAutoresizingMask: NSViewNotSizable];
+        [m_frameToolBar->GetNSViewForSuperview() setAutoresizingMask: NSViewMinYMargin];
         if(m_frameToolBar->GetParent())
             m_frameToolBar->GetParent()->CocoaAddChild(m_frameToolBar);
     }
@@ -223,6 +230,7 @@ wxToolBar* wxFrame::CreateToolBar(long style,
     UpdateFrameNSView();
     return m_frameToolBar;
 }
+#endif // wxUSE_TOOLBAR
 
 void wxFrame::PositionStatusBar()
 {