From bb15c56a2d471b0ffd0f62882c1b8e7ed9cd2feb Mon Sep 17 00:00:00 2001 From: Alex Shvartzkop Date: Fri, 16 Jun 2023 17:56:01 +0300 Subject: [PATCH] PAGED_DIALOG: make sure the dialog is big enough to contain page. (cherry picked from commit 6ace80700e155b9cca9432a0c12fe2ed69c30ae1) --- common/widgets/paged_dialog.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/common/widgets/paged_dialog.cpp b/common/widgets/paged_dialog.cpp index d5f3b5cf9b..cfa262b5cf 100644 --- a/common/widgets/paged_dialog.cpp +++ b/common/widgets/paged_dialog.cpp @@ -63,6 +63,7 @@ PAGED_DIALOG::PAGED_DIALOG( wxWindow* aParent, const wxString& aTitle, bool aSho m_treebook = new WX_TREEBOOK( treebookPanel, wxID_ANY ); m_treebook->SetFont( KIUI::GetControlFont( this ) ); + m_treebook->SetFitToCurrentPage( true ); long treeCtrlFlags = m_treebook->GetTreeCtrl()->GetWindowStyleFlag(); treeCtrlFlags = ( treeCtrlFlags & ~wxBORDER_MASK ) | wxBORDER_NONE; @@ -234,7 +235,7 @@ bool PAGED_DIALOG::TransferDataToWindow() } lastPageIndex = std::max( 0, lastPageIndex ); - m_treebook->ChangeSelection( lastPageIndex ); + m_treebook->SetSelection( lastPageIndex ); UpdateResetButton( lastPageIndex ); return true; @@ -407,6 +408,22 @@ void PAGED_DIALOG::onPageChanged( wxBookCtrlEvent& event ) UpdateResetButton( page ); + // Make sure the dialog size is enough to fit the page content. + m_treebook->InvalidateBestSize(); + + SetMinSize( wxDefaultSize ); + wxSize minSize = GetBestSize(); + minSize.IncTo( wxSize( 600, 500 ) ); + minSize.DecTo( wxSize( 1500, 900 ) ); // Failsafe + SetMinSize( minSize ); + + wxSize currentSize = GetSize(); + wxSize newSize = currentSize; + newSize.IncTo( minSize ); + + if( newSize != currentSize ) + SetSize( newSize ); + #ifdef __WXMAC__ // Work around an OSX wxWidgets issue where the wxGrid children don't get placed correctly // until the first resize event