X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/448cbf1d4ef247bacd87dadb38e0bce895ead4d1..b935bec2368afde72a9451fd431c8039b1194f1f:/src/cocoa/frame.mm?ds=sidebyside diff --git a/src/cocoa/frame.mm b/src/cocoa/frame.mm index 7c0387a644..f74bbf4a0a 100644 --- a/src/cocoa/frame.mm +++ b/src/cocoa/frame.mm @@ -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 #import @@ -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 @@ -91,21 +86,22 @@ wxPoint wxFrame::GetClientAreaOrigin() const return wxPoint(0,0); } -void wxFrame::DoGetClientSize(int *width, int *height) const +void wxFrame::CocoaSetWxWindowSize(int width, int height) { - wxFrameBase::DoGetClientSize(width,height); - if(height) - { - if(m_frameStatusBar && m_frameStatusBar->IsShown()) - *height -= m_frameStatusBar->GetSize().y; - } + 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); } -void wxFrame::DoSetClientSize(int width, int height) +WX_NSView wxFrame::GetNonClientNSView() { - if(m_frameStatusBar && m_frameStatusBar->IsShown()) - height += m_frameStatusBar->GetSize().y; - wxFrameBase::DoSetClientSize(width,height); + if(m_frameNSView) + return m_frameNSView; + return GetNSViewForSuperview(); } void wxFrame::CocoaReplaceView(WX_NSView oldView, WX_NSView newView) @@ -129,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(); @@ -143,6 +140,7 @@ void wxFrame::UpdateFrameNSView() [tbarNSView setAutoresizingMask: NSViewWidthSizable|NSViewMinYMargin]; tbarheight = tbarRect.size.height; } +#endif //wxUSE_TOOLBAR float sbarheight = 0.0; if(m_frameStatusBar) { @@ -176,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) @@ -202,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); } @@ -231,6 +230,7 @@ wxToolBar* wxFrame::CreateToolBar(long style, UpdateFrameNSView(); return m_frameToolBar; } +#endif // wxUSE_TOOLBAR void wxFrame::PositionStatusBar() {