fix MDI child sizing, which was working more or less by accident before I broke it in rev 46223

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@47360 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Paul Cornett
2007-07-12 07:01:54 +00:00
parent f24fc8367d
commit 1d66b09982
4 changed files with 31 additions and 22 deletions

View File

@@ -58,7 +58,7 @@ public:
long style = wxST_SIZEGRIP|wxFULL_REPAINT_ON_RESIZE, long style = wxST_SIZEGRIP|wxFULL_REPAINT_ON_RESIZE,
wxWindowID id = 0, wxWindowID id = 0,
const wxString& name = wxStatusLineNameStr); const wxString& name = wxStatusLineNameStr);
void SetStatusBar(wxStatusBar *statbar); void SetStatusBar(wxStatusBar *statbar);
#endif // wxUSE_STATUSBAR #endif // wxUSE_STATUSBAR
@@ -68,7 +68,7 @@ public:
const wxString& name = wxToolBarNameStr); const wxString& name = wxToolBarNameStr);
void SetToolBar(wxToolBar *toolbar); void SetToolBar(wxToolBar *toolbar);
#endif // wxUSE_TOOLBAR #endif // wxUSE_TOOLBAR
virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL); virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL);
wxPoint GetClientAreaOrigin() const { return wxPoint(0, 0); } wxPoint GetClientAreaOrigin() const { return wxPoint(0, 0); }
@@ -95,14 +95,15 @@ protected:
virtual void DoGetClientSize( int *width, int *height ) const; virtual void DoGetClientSize( int *width, int *height ) const;
#if wxUSE_MENUS_NATIVE #if wxUSE_MENUS_NATIVE
virtual void DetachMenuBar(); virtual void DetachMenuBar();
virtual void AttachMenuBar(wxMenuBar *menubar); virtual void AttachMenuBar(wxMenuBar *menubar);
// Whether frame has a menubar showing
// (needed to deal with perverted MDI menubar handling)
virtual bool HasVisibleMenubar() const;
public: public:
// Menu size is dynamic now, call this whenever it might change. // Menu size is dynamic now, call this whenever it might change.
void UpdateMenuBarSize(); void UpdateMenuBarSize();
#endif // wxUSE_MENUS_NATIVE #endif // wxUSE_MENUS_NATIVE
private: private:

View File

@@ -63,6 +63,7 @@ public:
protected: protected:
void Init(); void Init();
virtual bool HasVisibleMenubar() const;
private: private:
friend class wxMDIChildFrame; friend class wxMDIChildFrame;

View File

@@ -202,8 +202,7 @@ void wxFrame::DoGetClientSize( int *width, int *height ) const
{ {
#if wxUSE_MENUS_NATIVE #if wxUSE_MENUS_NATIVE
// menu bar // menu bar
if (m_frameMenuBar && if (HasVisibleMenubar() && !m_menuBarDetached)
GTK_WIDGET_VISIBLE(m_frameMenuBar->m_widget) && !m_menuBarDetached)
{ {
*height -= m_menuBarHeight; *height -= m_menuBarHeight;
} }
@@ -319,24 +318,25 @@ void wxFrame::GtkOnSize()
// m_mainWidget holds the menubar, the toolbar and the client // m_mainWidget holds the menubar, the toolbar and the client
// area, which is represented by m_wxwindow. // area, which is represented by m_wxwindow.
int menubarHeight = 0;
#if wxUSE_MENUS_NATIVE #if wxUSE_MENUS_NATIVE
if (m_frameMenuBar && m_frameMenuBar->IsShown()) if (HasVisibleMenubar())
{ {
int xx = m_miniEdge; int xx = m_miniEdge;
int yy = m_miniEdge + m_miniTitle; int yy = m_miniEdge + m_miniTitle;
int ww = m_width - 2*m_miniEdge; int ww = m_width - 2*m_miniEdge;
if (ww < 0) if (ww < 0)
ww = 0; ww = 0;
int hh = m_menuBarHeight; menubarHeight = m_menuBarHeight;
if (m_menuBarDetached) hh = wxPLACE_HOLDER; if (m_menuBarDetached) menubarHeight = wxPLACE_HOLDER;
m_frameMenuBar->m_x = xx; m_frameMenuBar->m_x = xx;
m_frameMenuBar->m_y = yy; m_frameMenuBar->m_y = yy;
m_frameMenuBar->m_width = ww; m_frameMenuBar->m_width = ww;
m_frameMenuBar->m_height = hh; m_frameMenuBar->m_height = menubarHeight;
gtk_pizza_set_size( GTK_PIZZA(m_mainWidget), gtk_pizza_set_size( GTK_PIZZA(m_mainWidget),
m_frameMenuBar->m_widget, m_frameMenuBar->m_widget,
xx, yy, ww, hh ); xx, yy, ww, menubarHeight);
client_area_y_offset += hh; client_area_y_offset += menubarHeight;
} }
#endif // wxUSE_MENUS_NATIVE #endif // wxUSE_MENUS_NATIVE
@@ -345,16 +345,7 @@ void wxFrame::GtkOnSize()
(m_frameToolBar->m_widget->parent == m_mainWidget)) (m_frameToolBar->m_widget->parent == m_mainWidget))
{ {
int xx = m_miniEdge; int xx = m_miniEdge;
int yy = m_miniEdge + m_miniTitle; int yy = m_miniEdge + m_miniTitle + menubarHeight;
#if wxUSE_MENUS_NATIVE
if (m_frameMenuBar)
{
if (!m_menuBarDetached)
yy += m_menuBarHeight;
else
yy += wxPLACE_HOLDER;
}
#endif // wxUSE_MENUS_NATIVE
m_frameToolBar->m_x = xx; m_frameToolBar->m_x = xx;
m_frameToolBar->m_y = yy; m_frameToolBar->m_y = yy;
@@ -589,6 +580,10 @@ void wxFrame::UpdateMenuBarSize()
GtkUpdateSize(); GtkUpdateSize();
} }
bool wxFrame::HasVisibleMenubar() const
{
return m_frameMenuBar && m_frameMenuBar->IsShown();
}
#endif // wxUSE_MENUS_NATIVE #endif // wxUSE_MENUS_NATIVE
#if wxUSE_TOOLBAR #if wxUSE_TOOLBAR

View File

@@ -292,6 +292,18 @@ void wxMDIParentFrame::ActivatePrevious()
gtk_notebook_prev_page( GTK_NOTEBOOK(m_clientWindow->m_widget) ); 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 // wxMDIChildFrame
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------