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