From 24c7767fc8e093be0f0790c78daeb12b4e58579b Mon Sep 17 00:00:00 2001 From: David Elliott Date: Fri, 5 Sep 2003 01:39:55 +0000 Subject: [PATCH] * Added GetAppMenuBar * 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 | 8 +++++--- src/cocoa/frame.mm | 28 +++++++++++++--------------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/include/wx/cocoa/frame.h b/include/wx/cocoa/frame.h index 041e7b399e..91b212a257 100644 --- a/include/wx/cocoa/frame.h +++ b/include/wx/cocoa/frame.h @@ -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 diff --git a/src/cocoa/frame.mm b/src/cocoa/frame.mm index 3c40bc0f66..9d3ff26566 100644 --- a/src/cocoa/frame.mm +++ b/src/cocoa/frame.mm @@ -20,6 +20,7 @@ #endif // WX_PRECOMP #include "wx/cocoa/autorelease.h" +#include "wx/cocoa/mbarman.h" #import #import @@ -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 -- 2.45.2