// ------------------------------------------------------------------------
// Cocoa specifics
// ------------------------------------------------------------------------
+public:
+ virtual wxMenuBar* GetAppMenuBar() { return GetMenuBar(); }
protected:
virtual void CocoaSetWxWindowSize(int width, int height);
// 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
#endif // WX_PRECOMP
#include "wx/cocoa/autorelease.h"
+#include "wx/cocoa/mbarman.h"
#import <AppKit/NSWindow.h>
#import <AppKit/NSApplication.h>
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