* 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
This commit is contained in:
David Elliott
2003-09-05 01:39:55 +00:00
parent af367f4640
commit 24c7767fc8
2 changed files with 18 additions and 18 deletions

View File

@@ -50,6 +50,8 @@ protected:
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
// Cocoa specifics // Cocoa specifics
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
public:
virtual wxMenuBar* GetAppMenuBar() { return GetMenuBar(); }
protected: protected:
virtual void CocoaSetWxWindowSize(int width, int height); virtual void CocoaSetWxWindowSize(int width, int height);
@@ -63,14 +65,14 @@ protected:
// Implementation // Implementation
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
public: public:
void AttachMenuBar(wxMenuBar *mbar); virtual void AttachMenuBar(wxMenuBar *mbar);
void DetachMenuBar(); virtual void DetachMenuBar();
virtual void SetMenuBar(wxMenuBar *menubar);
// implementation only from now on // implementation only from now on
// ------------------------------- // -------------------------------
// override some more virtuals // override some more virtuals
virtual bool Show( bool show = true );
// get the origin of the client area (which may be different from (0, 0) // get the origin of the client area (which may be different from (0, 0)
// if the frame has a toolbar) in client coordinates // if the frame has a toolbar) in client coordinates

View File

@@ -20,6 +20,7 @@
#endif // WX_PRECOMP #endif // WX_PRECOMP
#include "wx/cocoa/autorelease.h" #include "wx/cocoa/autorelease.h"
#include "wx/cocoa/mbarman.h"
#import <AppKit/NSWindow.h> #import <AppKit/NSWindow.h>
#import <AppKit/NSApplication.h> #import <AppKit/NSApplication.h>
@@ -58,29 +59,26 @@ wxFrame::~wxFrame()
void wxFrame::AttachMenuBar(wxMenuBar *mbar) void wxFrame::AttachMenuBar(wxMenuBar *mbar)
{ {
wxFrameBase::AttachMenuBar(mbar); wxFrameBase::AttachMenuBar(mbar);
if(m_frameMenuBar) wxMenuBarManager::GetInstance()->UpdateWindowMenuBar(this);
{
wxLogDebug("Attached menu");
[m_cocoaNSWindow setMenu:m_frameMenuBar->GetNSMenu()];
}
} }
void wxFrame::DetachMenuBar() void wxFrame::DetachMenuBar()
{ {
if(m_frameMenuBar)
{
[m_cocoaNSWindow setMenu:nil];
}
wxFrameBase::DetachMenuBar(); wxFrameBase::DetachMenuBar();
wxMenuBarManager::GetInstance()->UpdateWindowMenuBar(this);
} }
bool wxFrame::Show(bool show) void wxFrame::SetMenuBar(wxMenuBar *menubar)
{ {
wxAutoNSAutoreleasePool pool; if ( menubar == GetMenuBar() )
bool ret = wxFrameBase::Show(show); {
if(show && GetMenuBar()) // nothing to do
[wxTheApp->GetNSApplication() setMenu:GetMenuBar()->GetNSMenu() ]; return;
return ret; }
wxFrameBase::DetachMenuBar();
wxFrameBase::AttachMenuBar(menubar);
wxMenuBarManager::GetInstance()->UpdateWindowMenuBar(this);
} }
wxPoint wxFrame::GetClientAreaOrigin() const wxPoint wxFrame::GetClientAreaOrigin() const