Move workaround for initial TLW size to wxGTK itself
Add wxWindow::WXSetInitialFittingClientSize() instead of handling wxGTK TLWs specially in the common wxSizer code and override it in wxGTK to remember that we need to reset the client size once the window is shown. This commit shouldn't result in any changes in the observed behaviour.
This commit is contained in:
@@ -999,31 +999,12 @@ wxSize wxSizer::ComputeFittingWindowSize(wxWindow *window)
|
||||
return window->ClientToWindowSize(ComputeFittingClientSize(window));
|
||||
}
|
||||
|
||||
#ifdef __WXGTK3__
|
||||
static void FitOnShow(wxShowEvent& event)
|
||||
{
|
||||
wxWindow* win = static_cast<wxWindow*>(event.GetEventObject());
|
||||
wxSizer* sizer = win->GetSizer();
|
||||
if (sizer)
|
||||
sizer->Fit(win);
|
||||
win->Unbind(wxEVT_SHOW, FitOnShow);
|
||||
}
|
||||
#endif
|
||||
|
||||
wxSize wxSizer::Fit( wxWindow *window )
|
||||
{
|
||||
wxCHECK_MSG( window, wxDefaultSize, "window can't be NULL" );
|
||||
|
||||
#ifdef __WXGTK3__
|
||||
// GTK3 updates cached style information before showing a TLW,
|
||||
// which may affect best size calculations, so add a handler to
|
||||
// redo the calculations at that time
|
||||
if (!window->IsShown() && window->IsTopLevel())
|
||||
window->Bind(wxEVT_SHOW, FitOnShow);
|
||||
#endif
|
||||
|
||||
// set client size
|
||||
window->SetClientSize(ComputeFittingClientSize(window));
|
||||
window->WXSetInitialFittingClientSize(wxSIZE_SET_CURRENT);
|
||||
|
||||
// return entire size
|
||||
return window->GetSize();
|
||||
@@ -1059,38 +1040,11 @@ void wxSizer::Layout()
|
||||
RepositionChildren(minSize);
|
||||
}
|
||||
|
||||
#ifdef __WXGTK3__
|
||||
static void SetSizeHintsOnShow(wxShowEvent& event)
|
||||
{
|
||||
wxWindow* win = static_cast<wxWindow*>(event.GetEventObject());
|
||||
wxSizer* sizer = win->GetSizer();
|
||||
if (sizer)
|
||||
sizer->SetSizeHints(win);
|
||||
win->Unbind(wxEVT_SHOW, SetSizeHintsOnShow);
|
||||
}
|
||||
#endif
|
||||
|
||||
void wxSizer::SetSizeHints( wxWindow *window )
|
||||
{
|
||||
// Preserve the window's max size hints, but set the
|
||||
// lower bound according to the sizer calculations.
|
||||
|
||||
// This is equivalent to calling Fit(), except that we need to set
|
||||
// the size hints _in between_ the two steps performed by Fit
|
||||
// (1. ComputeFittingClientSize, 2. SetClientSize). That's because
|
||||
// otherwise SetClientSize() could have no effect if there already are
|
||||
// size hints in effect that forbid requested client size.
|
||||
|
||||
#ifdef __WXGTK3__
|
||||
// see comment in Fit()
|
||||
if (!window->IsShown() && window->IsTopLevel())
|
||||
window->Bind(wxEVT_SHOW, SetSizeHintsOnShow);
|
||||
#endif
|
||||
|
||||
const wxSize clientSize = ComputeFittingClientSize(window);
|
||||
|
||||
window->SetMinClientSize(clientSize);
|
||||
window->SetClientSize(clientSize);
|
||||
window->WXSetInitialFittingClientSize(wxSIZE_SET_CURRENT | wxSIZE_SET_MIN);
|
||||
}
|
||||
|
||||
#if WXWIN_COMPATIBILITY_2_8
|
||||
|
Reference in New Issue
Block a user