]> git.saurik.com Git - wxWidgets.git/commitdiff
wxMenuBarManager::InstallMenuBarForWindow no longer looks for a menubar
authorDavid Elliott <dfe@tgwbd.org>
Thu, 6 Nov 2003 19:25:06 +0000 (19:25 +0000)
committerDavid Elliott <dfe@tgwbd.org>
Thu, 6 Nov 2003 19:25:06 +0000 (19:25 +0000)
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

include/wx/cocoa/frame.h
include/wx/cocoa/toplevel.h
src/cocoa/frame.mm
src/cocoa/mbarman.mm
src/cocoa/toplevel.mm

index 0cea7dbac31e0fda19dfcb2e70c95b745f9cc542..9d0fcc3a419a70a8b32c67fdc40d22978ddd6584 100644 (file)
@@ -51,7 +51,7 @@ protected:
 // Cocoa specifics
 // ------------------------------------------------------------------------
 public:
-    virtual wxMenuBar* GetAppMenuBar() { return GetMenuBar(); }
+    virtual wxMenuBar* GetAppMenuBar();
     // Returns the NSView for non-client drawing
     virtual WX_NSView GetNonClientNSView();
 protected:
index e09873628d4a01e8dbb606c6bccfae0d16bcc062..8e5f44bd97b666d6fd2c36ef1c7e34ac436f1135 100644 (file)
@@ -67,7 +67,7 @@ public:
     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;
index f74bbf4a0a25279e26a0724d796c4a2e5af28762..e7ed47ceef0e93d11877d990df5274d266554206 100644 (file)
@@ -81,6 +81,13 @@ void wxFrame::SetMenuBar(wxMenuBar *menubar)
     wxMenuBarManager::GetInstance()->UpdateWindowMenuBar(this);
 }
 
+wxMenuBar* wxFrame::GetAppMenuBar()
+{
+    if(GetMenuBar())
+        return GetMenuBar();
+    return wxFrameBase::GetAppMenuBar();
+}
+
 wxPoint wxFrame::GetClientAreaOrigin() const
 {
     return wxPoint(0,0);
index 829bdffebbd6db8e751d122368856c52d39469ec..63bbdd4e915961f318f96f89830878bbea9c9337 100644 (file)
@@ -188,19 +188,15 @@ void wxMenuBarManager::WindowDidResignMain(wxTopLevelWindowNative *win)
 
 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
index 453ad124a36492674b46bf598604d5491fab5e50..5bcd9a84d8f821893ff4ed58324bd4917a8027f5 100644 (file)
@@ -134,6 +134,14 @@ wxTopLevelWindowCocoa::~wxTopLevelWindowCocoa()
 // 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;