attached to the parent of a window without one. Instead, it is now up to
the GetAppMenuBar() function to do so. The new implementation in
wxTopLevelWindow does just that. The wxFrame implementation now calls
the base class version if it does not have a menubar. Also, it is now
invalid to call the function with a NULL window (it is internal anyway).
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@24424
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
// Cocoa specifics
// ------------------------------------------------------------------------
public:
- virtual wxMenuBar* GetAppMenuBar() { return GetMenuBar(); }
+ virtual wxMenuBar* GetAppMenuBar();
// Returns the NSView for non-client drawing
virtual WX_NSView GetNonClientNSView();
protected:
virtual void CocoaDelegate_windowDidResignKey(void);
virtual void CocoaDelegate_windowDidBecomeMain(void);
virtual void CocoaDelegate_windowDidResignMain(void);
- virtual wxMenuBar* GetAppMenuBar() { return NULL; }
+ virtual wxMenuBar* GetAppMenuBar();
protected:
void SetNSWindow(WX_NSWindow cocoaNSWindow);
WX_NSWindow m_cocoaNSWindow;
wxMenuBarManager::GetInstance()->UpdateWindowMenuBar(this);
}
+wxMenuBar* wxFrame::GetAppMenuBar()
+{
+ if(GetMenuBar())
+ return GetMenuBar();
+ return wxFrameBase::GetAppMenuBar();
+}
+
wxPoint wxFrame::GetClientAreaOrigin() const
{
return wxPoint(0,0);
void wxMenuBarManager::InstallMenuBarForWindow(wxTopLevelWindowNative *win)
{
- wxMenuBar *menubar = NULL;
- for(wxTopLevelWindowNative *destwin = win;
- !menubar && destwin;
- destwin = wxDynamicCast(destwin->GetParent(), wxTopLevelWindow))
- {
- menubar = destwin->GetAppMenuBar();
- }
+ wxASSERT(win);
+ wxMenuBar *menubar = win->GetAppMenuBar();
SetMenuBar(menubar);
}
void wxMenuBarManager::UpdateWindowMenuBar(wxTopLevelWindowNative *win)
{
- InstallMenuBarForWindow(m_windowKey);
+ if(m_windowKey)
+ InstallMenuBarForWindow(m_windowKey);
}
#endif // wxUSE_MENUS
// wxTopLevelWindowCocoa Cocoa Specifics
// ----------------------------------------------------------------------------
+wxMenuBar* wxTopLevelWindowCocoa::GetAppMenuBar()
+{
+ wxTopLevelWindowCocoa *parent = wxDynamicCast(GetParent(),wxTopLevelWindow);
+ if(parent)
+ return parent->GetAppMenuBar();
+ return NULL;
+}
+
void wxTopLevelWindowCocoa::SetNSWindow(WX_NSWindow cocoaNSWindow)
{
bool need_debug = cocoaNSWindow || m_cocoaNSWindow;