#19170: SetSizeHints regression
----------------------+--------------------------------
Reporter: ericj | Owner:
Type: defect | Status: confirmed
Priority: normal | Milestone: 3.1.6
Component: GUI-all | Version: dev-latest
Resolution: | Keywords: wxSizer regression
Blocked By: | Blocking:
Patch: 0 |
----------------------+--------------------------------
Comment (by vadz):
Actually I don't really understand what did I write in comment:1 any
longer, i.e. why wouldn't a patch like this be enough:
{{{
#!diff
diff --git a/include/wx/window.h b/include/wx/window.h
index 794d7a0a15..393d71ba49 100644
--- a/include/wx/window.h
+++ b/include/wx/window.h
@@ -1571,7 +1571,11 @@ class WXDLLIMPEXP_CORE wxWindowBase : public
wxEvtHandler
// that we really need to use is not known until the window is
actually
// shown, as is the case for TLWs with recent GTK versions, as it
will
// update the size again when it does become known, if necessary.
- virtual void WXSetInitialFittingClientSize(int flags);
+ //
+ // The optional sizer argument can be passed to use the given sizer
for
+ // laying out the window, which is useful if this function is called
before
+ // SetSizer(). By default the window sizer is used.
+ virtual void WXSetInitialFittingClientSize(int flags, wxSizer* sizer
= NULL);
// get the handle of the window for the underlying window system:
this
// is only used for wxWin itself or for user code which wants to
call
diff --git a/src/common/sizer.cpp b/src/common/sizer.cpp
index 755ba7fd3e..3b18ac910f 100644
--- a/src/common/sizer.cpp
+++ b/src/common/sizer.cpp
@@ -1079,7 +1079,7 @@ wxSize wxSizer::Fit( wxWindow *window )
wxCHECK_MSG( window, wxDefaultSize, "window can't be NULL" );
// set client size
- window->WXSetInitialFittingClientSize(wxSIZE_SET_CURRENT);
+ window->WXSetInitialFittingClientSize(wxSIZE_SET_CURRENT, this);
// return entire size
return window->GetSize();
@@ -1119,7 +1119,8 @@ void wxSizer::SetSizeHints( wxWindow *window )
{
// Preserve the window's max size hints, but set the
// lower bound according to the sizer calculations.
- window->WXSetInitialFittingClientSize(wxSIZE_SET_CURRENT |
wxSIZE_SET_MIN);
+ window->WXSetInitialFittingClientSize(wxSIZE_SET_CURRENT |
wxSIZE_SET_MIN,
+ this);
}
#if WXWIN_COMPATIBILITY_2_8
diff --git a/src/common/wincmn.cpp b/src/common/wincmn.cpp
index bb8127670c..a851b371ce 100644
--- a/src/common/wincmn.cpp
+++ b/src/common/wincmn.cpp
@@ -999,11 +999,17 @@ wxSize wxWindowBase::WindowToClientSize(const
wxSize& size) const
size.y == -1 ? -1 : size.y - diff.y);
}
-void wxWindowBase::WXSetInitialFittingClientSize(int flags)
+void wxWindowBase::WXSetInitialFittingClientSize(int flags, wxSizer*
sizer)
{
- wxSizer* const sizer = GetSizer();
+ // Use the window sizer by default.
if ( !sizer )
- return;
+ {
+ sizer = GetSizer();
+
+ // If there is none, we can't compute the fitting size.
+ if ( !sizer )
+ return;
+ }
const wxSize
size = sizer->ComputeFittingClientSize(static_cast<wxWindow
*>(this));
}}}
This shouldn't change anything for wxGTK and, in particular, shouldn't
break anything.
Am I missing something here?
--
Ticket URL: <
https://trac.wxwidgets.org/ticket/19170#comment:4>