]> git.saurik.com Git - wxWidgets.git/commitdiff
fix MDI child sizing, which was working more or less by accident before I broke it...
authorPaul Cornett <paulcor@bullseye.com>
Thu, 12 Jul 2007 07:01:54 +0000 (07:01 +0000)
committerPaul Cornett <paulcor@bullseye.com>
Thu, 12 Jul 2007 07:01:54 +0000 (07:01 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@47360 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/gtk/frame.h
include/wx/gtk/mdi.h
src/gtk/frame.cpp
src/gtk/mdi.cpp

index 70d53296cda90eca70e12718a8086b3f92e10b0e..726cce187bd9480c5e0e8bc830fd4d60a781f774 100644 (file)
@@ -58,7 +58,7 @@ public:
                                          long style = wxST_SIZEGRIP|wxFULL_REPAINT_ON_RESIZE,
                                          wxWindowID id = 0,
                                          const wxString& name = wxStatusLineNameStr);
-                                         
+
     void SetStatusBar(wxStatusBar *statbar);
 #endif // wxUSE_STATUSBAR
 
@@ -68,7 +68,7 @@ public:
                                      const wxString& name = wxToolBarNameStr);
     void SetToolBar(wxToolBar *toolbar);
 #endif // wxUSE_TOOLBAR
-    
+
     virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL);
     wxPoint GetClientAreaOrigin() const { return wxPoint(0, 0); }
 
@@ -95,14 +95,15 @@ protected:
     virtual void DoGetClientSize( int *width, int *height ) const;
 
 #if wxUSE_MENUS_NATIVE
-
     virtual void DetachMenuBar();
     virtual void AttachMenuBar(wxMenuBar *menubar);
+    // Whether frame has a menubar showing
+    //   (needed to deal with perverted MDI menubar handling)
+    virtual bool HasVisibleMenubar() const;
 
 public:
     // Menu size is dynamic now, call this whenever it might change.
     void UpdateMenuBarSize();
-
 #endif // wxUSE_MENUS_NATIVE
 
 private:
index ee20c378be3493131f6d069d4fb9b222cb6c6db5..978b1abe865a26dac7dac8e5288f34436d5085b0 100644 (file)
@@ -63,6 +63,7 @@ public:
 
 protected:
     void Init();
+    virtual bool HasVisibleMenubar() const;
 
 private:
     friend class wxMDIChildFrame;
index c89c664ade3001bc12452da25d69081799819761..0690e2602bb49b2149cb186a687d1689d5ad7f2f 100644 (file)
@@ -202,8 +202,7 @@ void wxFrame::DoGetClientSize( int *width, int *height ) const
     {
 #if wxUSE_MENUS_NATIVE
         // menu bar
-        if (m_frameMenuBar &&
-            GTK_WIDGET_VISIBLE(m_frameMenuBar->m_widget) && !m_menuBarDetached)
+        if (HasVisibleMenubar() && !m_menuBarDetached)
         {
             *height -= m_menuBarHeight;
         }
@@ -319,24 +318,25 @@ void wxFrame::GtkOnSize()
         // m_mainWidget holds the menubar, the toolbar and the client
         // area, which is represented by m_wxwindow.
 
+        int menubarHeight = 0;
 #if wxUSE_MENUS_NATIVE
-        if (m_frameMenuBar && m_frameMenuBar->IsShown())
+        if (HasVisibleMenubar())
         {
             int xx = m_miniEdge;
             int yy = m_miniEdge + m_miniTitle;
             int ww = m_width  - 2*m_miniEdge;
             if (ww < 0)
                 ww = 0;
-            int hh = m_menuBarHeight;
-            if (m_menuBarDetached) hh = wxPLACE_HOLDER;
+            menubarHeight = m_menuBarHeight;
+            if (m_menuBarDetached) menubarHeight = wxPLACE_HOLDER;
             m_frameMenuBar->m_x = xx;
             m_frameMenuBar->m_y = yy;
             m_frameMenuBar->m_width = ww;
-            m_frameMenuBar->m_height = hh;
+            m_frameMenuBar->m_height = menubarHeight;
             gtk_pizza_set_size( GTK_PIZZA(m_mainWidget),
                                   m_frameMenuBar->m_widget,
-                                  xx, yy, ww, hh );
-            client_area_y_offset += hh;
+                                  xx, yy, ww, menubarHeight);
+            client_area_y_offset += menubarHeight;
         }
 #endif // wxUSE_MENUS_NATIVE
 
@@ -345,16 +345,7 @@ void wxFrame::GtkOnSize()
             (m_frameToolBar->m_widget->parent == m_mainWidget))
         {
             int xx = m_miniEdge;
-            int yy = m_miniEdge + m_miniTitle;
-#if wxUSE_MENUS_NATIVE
-            if (m_frameMenuBar)
-            {
-                if (!m_menuBarDetached)
-                    yy += m_menuBarHeight;
-                else
-                    yy += wxPLACE_HOLDER;
-            }
-#endif // wxUSE_MENUS_NATIVE
+            int yy = m_miniEdge + m_miniTitle + menubarHeight;
 
             m_frameToolBar->m_x = xx;
             m_frameToolBar->m_y = yy;
@@ -589,6 +580,10 @@ void wxFrame::UpdateMenuBarSize()
     GtkUpdateSize();
 }
 
+bool wxFrame::HasVisibleMenubar() const
+{
+    return m_frameMenuBar && m_frameMenuBar->IsShown();
+}
 #endif // wxUSE_MENUS_NATIVE
 
 #if wxUSE_TOOLBAR
index 607dc314d73395c4e67508c2db6752d36d804002..7c384c2d54e10cbaeead5e0915181e5aed89f1ae 100644 (file)
@@ -292,6 +292,18 @@ void wxMDIParentFrame::ActivatePrevious()
       gtk_notebook_prev_page( GTK_NOTEBOOK(m_clientWindow->m_widget) );
 }
 
+bool wxMDIParentFrame::HasVisibleMenubar() const
+{
+    if (wxFrame::HasVisibleMenubar())
+        return true;
+
+    wxMDIChildFrame* active_child_frame = GetActiveChild();
+    wxMenuBar* menubar = NULL;
+    if (active_child_frame)
+        menubar = active_child_frame->m_menuBar;
+    return menubar && menubar->IsShown();
+}
+
 //-----------------------------------------------------------------------------
 // wxMDIChildFrame
 //-----------------------------------------------------------------------------