diff --git a/include/wx/toplevel.h b/include/wx/toplevel.h index 9927d67db1..0089481189 100644 --- a/include/wx/toplevel.h +++ b/include/wx/toplevel.h @@ -276,9 +276,13 @@ public: virtual bool IsTopNavigationDomain(NavigationKind kind) const wxOVERRIDE; virtual bool IsVisible() const { return IsShown(); } + // override to do TLW-specific layout: we resize our unique child to fill + // the entire client area + virtual bool Layout() wxOVERRIDE; + // event handlers void OnCloseWindow(wxCloseEvent& event); - void OnSize(wxSizeEvent& WXUNUSED(event)) { DoLayout(); } + void OnSize(wxSizeEvent& WXUNUSED(event)) { Layout(); } // Get rect to be used to center top-level children virtual void GetRectForTopLevelChildren(int *x, int *y, int *w, int *h); @@ -326,9 +330,8 @@ protected: // send the iconize event, return true if processed bool SendIconizeEvent(bool iconized = true); - // do TLW-specific layout: we resize our unique child to fill the entire - // client area - void DoLayout(); + // this method is only kept for compatibility, call Layout() instead. + void DoLayout() { Layout(); } static int WidthDefault(int w) { return w == wxDefaultCoord ? GetDefaultSize().x : w; } static int HeightDefault(int h) { return h == wxDefaultCoord ? GetDefaultSize().y : h; } diff --git a/src/common/toplvcmn.cpp b/src/common/toplvcmn.cpp index 7619328a18..01211ce7c0 100644 --- a/src/common/toplvcmn.cpp +++ b/src/common/toplvcmn.cpp @@ -411,20 +411,20 @@ bool wxTopLevelWindowBase::IsTopNavigationDomain(NavigationKind kind) const // default resizing behaviour - if only ONE subwindow, resize to fill the // whole client area -void wxTopLevelWindowBase::DoLayout() +bool wxTopLevelWindowBase::Layout() { // We are called during the window destruction several times, e.g. as // wxFrame tries to adjust to its tool/status bars disappearing. But // actually doing the layout is pretty useless in this case as the window // will disappear anyhow -- so just don't bother. if ( IsBeingDeleted() ) - return; + return false; // if we're using constraints or sizers - do use them if ( GetAutoLayout() ) { - Layout(); + return wxNonOwnedWindow::Layout(); } else { @@ -443,7 +443,7 @@ void wxTopLevelWindowBase::DoLayout() { if ( child ) { - return; // it's our second subwindow - nothing to do + return false; // it's our second subwindow - nothing to do } child = win; @@ -458,8 +458,12 @@ void wxTopLevelWindowBase::DoLayout() DoGetClientSize(&clientW, &clientH); child->SetSize(0, 0, clientW, clientH); + + return true; } } + + return false; } // The default implementation for the close window event.