PAGED_DIALOG: make sure the dialog is big enough to contain page.

This commit is contained in:
Alex Shvartzkop 2023-06-16 17:56:01 +03:00
parent f5da58e17d
commit 6ace80700e
1 changed files with 18 additions and 1 deletions

View File

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