diff --git a/common/confirm.cpp b/common/confirm.cpp index 34753b9d0c..e3231515c8 100644 --- a/common/confirm.cpp +++ b/common/confirm.cpp @@ -283,56 +283,12 @@ int YesNoCancelDialog( wxWindow* aParent, int SelectSingleOption( wxWindow* aParent, const wxString& aTitle, const wxString& aMessage, const wxArrayString& aOptions ) { - int ret = -1; - wxDialog* dlg = new wxDialog( aParent, wxID_ANY, aTitle ); + wxSingleChoiceDialog dlg( aParent, aMessage, aTitle, aOptions ); - wxBoxSizer* boxSizer = new wxBoxSizer( wxVERTICAL ); + if( dlg.ShowModal() != wxID_OK ) + return -1; - if( !aMessage.IsEmpty() ) - boxSizer->Add( new wxStaticText( dlg, wxID_ANY, aMessage ), 0, wxEXPAND | wxALL, 5 ); - - std::vector radioButtons; - radioButtons.reserve( aOptions.Count() ); - - for( const wxString& option : aOptions ) - { - radioButtons.emplace_back( new wxRadioButton( dlg, wxID_ANY, _( option ) ) ); - boxSizer->Add( radioButtons.back(), 0, wxEXPAND | wxALL, 5 ); - } - - wxStdDialogButtonSizer* m_sdboxSizer = new wxStdDialogButtonSizer(); - wxButton* btnOk = new wxButton( dlg, wxID_OK ); - m_sdboxSizer->AddButton( btnOk ); - m_sdboxSizer->AddButton( new wxButton( dlg, wxID_CANCEL ) ); - m_sdboxSizer->Realize(); - btnOk->SetDefault(); - boxSizer->Add( m_sdboxSizer, 1, wxEXPAND | wxALL, 5 ); - - dlg->SetSizer( boxSizer ); - dlg->Layout(); - boxSizer->Fit( dlg ); - boxSizer->SetSizeHints( dlg ); - dlg->Centre( wxBOTH ); - - if( dlg->ShowModal() == wxID_OK ) - { - for( unsigned int i = 0; i < radioButtons.size(); ++i ) - { - if( radioButtons[i]->GetValue() ) - { - ret = i; - break; - } - } - } - else - { - ret = -1; - } - - dlg->Destroy(); - - return ret; + return dlg.GetSelection(); } diff --git a/include/confirm.h b/include/confirm.h index f1cbdd7a39..595f891a11 100644 --- a/include/confirm.h +++ b/include/confirm.h @@ -157,6 +157,7 @@ int YesNoCancelDialog( wxWindow* aParent, /** * Displays a dialog with radioboxes asking the user to select an option. + * * @param aParent is the parent window. * @param aTitle is the dialog title. * @param aMessage is a text label displayed in the first row of the dialog.