Make wxTopLevelWindow::Layout() do the expected thing

It makes sense for explicit calls to Layout() to use the same logic as
is implicitly used when a TLW is resized, so override it to use
TLW-specific logic instead of using a separate DoLayout() for this.

Note that DoLayout() still has to be preserved because Debian code
search finds at least a couple of examples of its use outside the
library, meaning that there are probably quite a few more of them in the
wild.

Also, wxTopLevelWindow still needs its own wxEVT_SIZE handler because
the base class only calls Layout() if GetAutoLayout() is true, while we
want it to be always called. This might be worked around by just calling
SetAutoLayout(true) in wxTopLevelWindow ctor, but it seems safer, from
compatibility point of view, to keep wxTopLevelWindow::OnSize() instead.

See #18472.
This commit is contained in:
Vadim Zeitlin
2019-08-22 13:46:53 +02:00
parent 8dc3c38fad
commit 3241e7a850
2 changed files with 15 additions and 8 deletions

View File

@@ -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; }