Add OSX layout hack to PAGED_DIALOG for preferences.

This commit is contained in:
Jeff Young 2020-04-02 13:50:58 +01:00
parent 4966ab802e
commit 811968716c
2 changed files with 34 additions and 1 deletions

View File

@ -78,6 +78,8 @@ PAGED_DIALOG::PAGED_DIALOG( wxWindow* aParent, const wxString& aTitle,
if( m_auxiliaryButton )
m_auxiliaryButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PAGED_DIALOG::OnAuxiliaryAction ), nullptr, this );
m_treebook->Connect( wxEVT_TREEBOOK_PAGE_CHANGED, wxBookCtrlEventHandler( PAGED_DIALOG::OnPageChange ), NULL, this );
Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( PAGED_DIALOG::OnUpdateUI ), nullptr, this );
}
@ -98,7 +100,10 @@ void PAGED_DIALOG::finishInitialization()
m_treebook->Fit();
m_treebook->Layout();
FinishDialogSettings();
for( int i = 0; i < m_treebook->GetPageCount(); ++i )
m_macHack.push_back( true );
FinishDialogSettings();
}
@ -133,6 +138,9 @@ PAGED_DIALOG::~PAGED_DIALOG()
if( m_auxiliaryButton )
m_auxiliaryButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PAGED_DIALOG::OnAuxiliaryAction ), nullptr, this );
m_treebook->Disconnect( wxEVT_TREEBOOK_PAGE_CHANGED, wxBookCtrlEventHandler( PAGED_DIALOG::OnPageChange ), NULL, this );
Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( PAGED_DIALOG::OnUpdateUI ), nullptr, this );
}
@ -266,3 +274,25 @@ void PAGED_DIALOG::OnUpdateUI( wxUpdateUIEvent& event )
}
}
}
void PAGED_DIALOG::OnPageChange( wxBookCtrlEvent& event )
{
#ifdef __WXMAC__
// Work around an OSX bug where the wxGrid children don't get placed correctly until
// the first resize event
int page = event.GetSelection();
if( page + 1 <= m_macHack.size() && m_macHack[ page ] )
{
wxSize pageSize = m_treebook->GetPage( page )->GetSize();
pageSize.x -= 3;
pageSize.y += 2;
m_treebook->GetPage( page )->SetSize( pageSize );
m_macHack[ page ] = false;
}
#endif
}

View File

@ -35,6 +35,8 @@ private:
int m_errorRow; // the row if m_errorCtrl is a grid
int m_errorCol; // the column if m_errorCtrl is a grid
std::vector<bool> m_macHack;
public:
PAGED_DIALOG( wxWindow* aParent, const wxString& aTitle,
const wxString& aAuxiliaryAction = wxEmptyString );
@ -55,6 +57,7 @@ protected:
virtual void OnAuxiliaryAction( wxCommandEvent& event ) { event.Skip(); }
void OnUpdateUI( wxUpdateUIEvent& event );
void OnPageChange( wxBookCtrlEvent& event );
wxTreebook* m_treebook;
wxButton* m_auxiliaryButton;