2013-10-18 13:32:22 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2007 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2017-07-20 13:03:33 +00:00
|
|
|
* Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
|
2013-10-18 13:32:22 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2013-04-06 12:01:53 +00:00
|
|
|
/**
|
2011-11-08 16:37:25 +00:00
|
|
|
* @file confirm.cpp
|
2013-04-06 12:01:53 +00:00
|
|
|
* @brief utilities to display some error, warning and info short messges
|
2011-11-08 16:37:25 +00:00
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2013-10-18 13:32:22 +00:00
|
|
|
#include <wx/stockitem.h>
|
2017-07-20 13:03:33 +00:00
|
|
|
#include <wx/richmsgdlg.h>
|
2016-01-18 05:17:56 +00:00
|
|
|
|
2017-09-23 09:20:10 +00:00
|
|
|
#include <confirm.h>
|
2016-01-18 05:17:56 +00:00
|
|
|
#include <bitmaps.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <html_messagebox.h>
|
2012-03-08 17:47:23 +00:00
|
|
|
#include <dialog_exit_base.h>
|
2016-01-18 05:17:56 +00:00
|
|
|
|
2017-11-06 08:35:05 +00:00
|
|
|
#include <functional>
|
2018-02-21 17:26:45 +00:00
|
|
|
#include <unordered_map>
|
|
|
|
|
|
|
|
// Set of dialogs that have been chosen not to be shown again
|
|
|
|
static std::unordered_map<unsigned long, int> doNotShowAgainDlgs;
|
|
|
|
|
|
|
|
|
2018-03-02 15:52:45 +00:00
|
|
|
KIDIALOG::KIDIALOG( wxWindow* aParent, const wxString& aMessage,
|
|
|
|
const wxString& aCaption, long aStyle )
|
|
|
|
: wxRichMessageDialog( aParent, aMessage, aCaption, aStyle | wxCENTRE )
|
2018-02-21 17:26:45 +00:00
|
|
|
{
|
2018-03-02 15:52:45 +00:00
|
|
|
setHash();
|
2018-02-21 17:26:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-03-02 15:52:45 +00:00
|
|
|
KIDIALOG::KIDIALOG( wxWindow* aParent, const wxString& aMessage,
|
|
|
|
KD_TYPE aType, const wxString& aCaption )
|
|
|
|
: wxRichMessageDialog( aParent, aMessage, getCaption( aType, aCaption ), getStyle( aType ) )
|
2018-02-21 17:26:45 +00:00
|
|
|
{
|
2018-03-02 15:52:45 +00:00
|
|
|
setHash();
|
2018-02-21 17:26:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-03-02 15:52:45 +00:00
|
|
|
bool KIDIALOG::DoNotShowAgain() const
|
2018-02-21 17:26:45 +00:00
|
|
|
{
|
2018-03-02 15:52:45 +00:00
|
|
|
return doNotShowAgainDlgs.count( m_hash ) > 0;
|
2018-02-21 17:26:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-03-02 15:52:45 +00:00
|
|
|
void KIDIALOG::ForceShowAgain()
|
2018-02-21 17:26:45 +00:00
|
|
|
{
|
2018-03-02 15:52:45 +00:00
|
|
|
doNotShowAgainDlgs.erase( m_hash );
|
2018-02-21 17:26:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-03-02 15:52:45 +00:00
|
|
|
bool KIDIALOG::Show( bool aShow )
|
2018-02-21 17:26:45 +00:00
|
|
|
{
|
2018-07-25 09:45:20 +00:00
|
|
|
// We should check the do-not-show-again setting only when the dialog is displayed
|
|
|
|
if( aShow )
|
|
|
|
{
|
|
|
|
// Check if this dialog should be shown to the user
|
|
|
|
auto it = doNotShowAgainDlgs.find( m_hash );
|
2018-02-21 17:26:45 +00:00
|
|
|
|
2018-07-25 09:45:20 +00:00
|
|
|
if( it != doNotShowAgainDlgs.end() )
|
|
|
|
return it->second;
|
|
|
|
}
|
2018-02-21 17:26:45 +00:00
|
|
|
|
2018-07-25 09:45:20 +00:00
|
|
|
bool ret = wxRichMessageDialog::Show( aShow );
|
2018-02-21 17:26:45 +00:00
|
|
|
|
2018-03-02 15:52:45 +00:00
|
|
|
// Has the user asked not to show the dialog again
|
|
|
|
if( IsCheckBoxChecked() )
|
|
|
|
doNotShowAgainDlgs[m_hash] = ret;
|
2018-02-21 17:26:45 +00:00
|
|
|
|
2018-03-02 15:52:45 +00:00
|
|
|
return ret;
|
2018-02-21 17:26:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-03-02 10:57:03 +00:00
|
|
|
int KIDIALOG::ShowModal()
|
2018-02-21 17:26:45 +00:00
|
|
|
{
|
|
|
|
// Check if this dialog should be shown to the user
|
2018-03-02 15:52:45 +00:00
|
|
|
auto it = doNotShowAgainDlgs.find( m_hash );
|
2018-02-21 17:26:45 +00:00
|
|
|
|
|
|
|
if( it != doNotShowAgainDlgs.end() )
|
|
|
|
return it->second;
|
|
|
|
|
2018-03-02 15:52:45 +00:00
|
|
|
int ret = wxRichMessageDialog::ShowModal();
|
2018-02-21 17:26:45 +00:00
|
|
|
|
|
|
|
// Has the user asked not to show the dialog again
|
2018-03-02 15:52:45 +00:00
|
|
|
if( IsCheckBoxChecked() )
|
|
|
|
doNotShowAgainDlgs[m_hash] = ret;
|
2018-02-21 17:26:45 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-03-02 15:52:45 +00:00
|
|
|
void KIDIALOG::setHash()
|
|
|
|
{
|
|
|
|
std::size_t h1 = std::hash<wxString>{}( GetMessage() );
|
|
|
|
std::size_t h2 = std::hash<wxString>{}( GetTitle() );
|
|
|
|
m_hash = h1 ^ ( h2 << 1 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxString KIDIALOG::getCaption( KD_TYPE aType, const wxString& aCaption )
|
2018-02-21 17:26:45 +00:00
|
|
|
{
|
2018-03-02 15:52:45 +00:00
|
|
|
if( !aCaption.IsEmpty() )
|
|
|
|
return aCaption;
|
|
|
|
|
|
|
|
switch( aType )
|
|
|
|
{
|
|
|
|
case KD_NONE: /* fall through */
|
|
|
|
case KD_INFO: return _( "Message" );
|
|
|
|
case KD_QUESTION: return _( "Question" );
|
|
|
|
case KD_WARNING: return _( "Warning" );
|
|
|
|
case KD_ERROR: return _( "Error" );
|
|
|
|
}
|
|
|
|
|
|
|
|
return wxEmptyString;
|
2018-02-21 17:26:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-03-02 15:52:45 +00:00
|
|
|
long KIDIALOG::getStyle( KD_TYPE aType )
|
2018-02-21 17:26:45 +00:00
|
|
|
{
|
2018-03-02 15:52:45 +00:00
|
|
|
long style = wxOK | wxCENTRE;
|
|
|
|
|
|
|
|
switch( aType )
|
|
|
|
{
|
|
|
|
case KD_NONE: break;
|
|
|
|
case KD_INFO: style |= wxICON_INFORMATION; break;
|
|
|
|
case KD_QUESTION: style |= wxICON_QUESTION; break;
|
|
|
|
case KD_WARNING: style |= wxICON_WARNING; break;
|
|
|
|
case KD_ERROR: style |= wxICON_ERROR; break;
|
|
|
|
}
|
2018-02-21 17:26:45 +00:00
|
|
|
|
2018-03-02 15:52:45 +00:00
|
|
|
return style;
|
2018-02-21 17:26:45 +00:00
|
|
|
}
|
2017-11-06 08:35:05 +00:00
|
|
|
|
2007-12-05 20:54:11 +00:00
|
|
|
|
2012-03-08 17:47:23 +00:00
|
|
|
class DIALOG_EXIT: public DIALOG_EXIT_BASE
|
|
|
|
{
|
|
|
|
public:
|
2013-10-18 13:32:22 +00:00
|
|
|
DIALOG_EXIT( wxWindow *aParent, const wxString& aMessage ) :
|
|
|
|
DIALOG_EXIT_BASE( aParent )
|
2012-03-08 17:47:23 +00:00
|
|
|
{
|
2012-03-09 18:58:58 +00:00
|
|
|
m_bitmap->SetBitmap( KiBitmap( dialog_warning_xpm ) );
|
2013-10-18 13:32:22 +00:00
|
|
|
|
|
|
|
if( !aMessage.IsEmpty() )
|
2012-03-08 17:47:23 +00:00
|
|
|
m_TextInfo->SetLabel( aMessage );
|
2013-10-18 13:32:22 +00:00
|
|
|
|
2012-03-08 17:47:23 +00:00
|
|
|
GetSizer()->Fit( this );
|
|
|
|
GetSizer()->SetSizeHints( this );
|
|
|
|
};
|
|
|
|
|
|
|
|
private:
|
2016-09-24 18:53:15 +00:00
|
|
|
void OnSaveAndExit( wxCommandEvent& event ) override { EndModal( wxID_YES ); }
|
|
|
|
void OnExitNoSave( wxCommandEvent& event ) override { EndModal( wxID_NO ); }
|
2012-03-08 17:47:23 +00:00
|
|
|
};
|
|
|
|
|
2013-10-18 13:32:22 +00:00
|
|
|
|
2012-03-08 17:47:23 +00:00
|
|
|
int DisplayExitDialog( wxWindow* parent, const wxString& aMessage )
|
|
|
|
{
|
|
|
|
DIALOG_EXIT dlg( parent, aMessage );
|
|
|
|
|
|
|
|
int ret = dlg.ShowModal();
|
2016-05-06 15:15:30 +00:00
|
|
|
|
|
|
|
// Returns wxID_YES, wxID_NO, or wxID_CANCEL
|
2012-03-08 17:47:23 +00:00
|
|
|
return ret;
|
|
|
|
}
|
2011-11-08 16:37:25 +00:00
|
|
|
|
2013-10-18 13:32:22 +00:00
|
|
|
|
2017-07-20 14:06:41 +00:00
|
|
|
// DisplayError should be deprecated, use DisplayErrorMessage instead
|
2009-11-23 15:16:50 +00:00
|
|
|
void DisplayError( wxWindow* parent, const wxString& text, int displaytime )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-12-05 20:54:11 +00:00
|
|
|
wxMessageDialog* dialog;
|
|
|
|
|
2017-07-20 13:03:33 +00:00
|
|
|
int icon = displaytime > 0 ? wxICON_INFORMATION : wxICON_ERROR;
|
|
|
|
|
|
|
|
dialog = new wxMessageDialog( parent, text, _( "Warning" ),
|
|
|
|
wxOK | wxCENTRE | wxRESIZE_BORDER | icon );
|
2007-12-05 20:54:11 +00:00
|
|
|
|
|
|
|
dialog->ShowModal();
|
|
|
|
dialog->Destroy();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-12-05 20:54:11 +00:00
|
|
|
|
2017-09-23 09:20:10 +00:00
|
|
|
void DisplayErrorMessage( wxWindow* aParent, const wxString& aText, const wxString& aExtraInfo )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2017-07-20 13:03:33 +00:00
|
|
|
wxRichMessageDialog* dlg;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2017-07-20 13:03:33 +00:00
|
|
|
dlg = new wxRichMessageDialog( aParent, aText, _( "Error" ),
|
|
|
|
wxOK | wxCENTRE | wxRESIZE_BORDER | wxICON_ERROR );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2017-07-20 13:03:33 +00:00
|
|
|
if( !aExtraInfo.IsEmpty() )
|
|
|
|
{
|
|
|
|
dlg->ShowDetailedText( aExtraInfo );
|
|
|
|
}
|
|
|
|
|
|
|
|
dlg->ShowModal();
|
|
|
|
dlg->Destroy();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-09-23 09:20:10 +00:00
|
|
|
void DisplayInfoMessage( wxWindow* aParent, const wxString& aMessage, const wxString& aExtraInfo )
|
2017-07-20 13:03:33 +00:00
|
|
|
{
|
|
|
|
wxRichMessageDialog* dlg;
|
|
|
|
|
|
|
|
dlg = new wxRichMessageDialog( aParent, aMessage, _( "Info" ),
|
|
|
|
wxOK | wxCENTRE | wxRESIZE_BORDER | wxICON_INFORMATION );
|
|
|
|
|
|
|
|
if( !aExtraInfo.IsEmpty() )
|
|
|
|
{
|
|
|
|
dlg->ShowDetailedText( aExtraInfo );
|
|
|
|
}
|
|
|
|
|
|
|
|
dlg->ShowModal();
|
|
|
|
dlg->Destroy();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-10-18 13:32:22 +00:00
|
|
|
bool IsOK( wxWindow* aParent, const wxString& aMessage )
|
|
|
|
{
|
|
|
|
wxMessageDialog dlg( aParent, aMessage, _( "Confirmation" ),
|
2018-09-09 03:16:07 +00:00
|
|
|
wxYES_NO | wxCENTRE | wxICON_QUESTION | wxSTAY_ON_TOP );
|
2013-10-18 13:32:22 +00:00
|
|
|
|
2013-10-19 13:22:24 +00:00
|
|
|
return dlg.ShowModal() == wxID_YES;
|
2013-10-18 13:32:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class DIALOG_YES_NO_CANCEL : public DIALOG_EXIT
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2013-10-18 13:32:22 +00:00
|
|
|
public:
|
|
|
|
DIALOG_YES_NO_CANCEL( wxWindow *aParent,
|
|
|
|
const wxString& aPrimaryMessage,
|
|
|
|
const wxString& aSecondaryMessage = wxEmptyString,
|
|
|
|
const wxString& aYesButtonText = wxEmptyString,
|
|
|
|
const wxString& aNoButtonText = wxEmptyString,
|
|
|
|
const wxString& aCancelButtonText = wxEmptyString ) :
|
2018-05-02 20:12:11 +00:00
|
|
|
DIALOG_EXIT( aParent, aPrimaryMessage )
|
2013-10-18 13:32:22 +00:00
|
|
|
{
|
|
|
|
if( aSecondaryMessage.IsEmpty() )
|
|
|
|
m_staticText2->Hide();
|
2018-05-02 20:12:11 +00:00
|
|
|
else
|
|
|
|
m_staticText2->SetLabel( aSecondaryMessage );
|
2013-10-18 13:32:22 +00:00
|
|
|
|
|
|
|
m_buttonSaveAndExit->SetLabel( aYesButtonText.IsEmpty() ? wxGetStockLabel( wxID_YES ) :
|
|
|
|
aYesButtonText );
|
|
|
|
m_buttonExitNoSave->SetLabel( aNoButtonText.IsEmpty() ? wxGetStockLabel( wxID_NO ) :
|
|
|
|
aNoButtonText );
|
|
|
|
m_buttonCancel->SetLabel( aCancelButtonText.IsEmpty() ? wxGetStockLabel( wxID_CANCEL ) :
|
|
|
|
aCancelButtonText );
|
|
|
|
GetSizer()->Fit( this );
|
|
|
|
GetSizer()->SetSizeHints( this );
|
|
|
|
};
|
|
|
|
};
|
2007-12-05 20:54:11 +00:00
|
|
|
|
2011-11-08 16:37:25 +00:00
|
|
|
|
2013-10-18 13:32:22 +00:00
|
|
|
int YesNoCancelDialog( wxWindow* aParent,
|
|
|
|
const wxString& aPrimaryMessage,
|
|
|
|
const wxString& aSecondaryMessage,
|
|
|
|
const wxString& aYesButtonText,
|
|
|
|
const wxString& aNoButtonText,
|
|
|
|
const wxString& aCancelButtonText )
|
|
|
|
{
|
|
|
|
DIALOG_YES_NO_CANCEL dlg( aParent, aPrimaryMessage, aSecondaryMessage,
|
|
|
|
aYesButtonText, aNoButtonText, aCancelButtonText );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2013-10-18 13:32:22 +00:00
|
|
|
return dlg.ShowModal();
|
2011-11-08 16:37:25 +00:00
|
|
|
}
|
2017-11-06 08:35:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
int SelectSingleOption( wxWindow* aParent, const wxString& aTitle, const wxString& aMessage, const wxArrayString& aOptions )
|
|
|
|
{
|
2018-03-02 16:30:10 +00:00
|
|
|
wxSingleChoiceDialog dlg( aParent, aMessage, aTitle, aOptions );
|
2017-11-06 08:35:05 +00:00
|
|
|
|
2018-03-02 16:30:10 +00:00
|
|
|
if( dlg.ShowModal() != wxID_OK )
|
|
|
|
return -1;
|
2017-11-06 08:35:05 +00:00
|
|
|
|
2018-03-02 16:30:10 +00:00
|
|
|
return dlg.GetSelection();
|
2017-11-06 08:35:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-03-02 16:54:03 +00:00
|
|
|
class DIALOG_MULTI_OPTIONS : public wxMultiChoiceDialog
|
2017-11-06 08:35:05 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
DIALOG_MULTI_OPTIONS( wxWindow* aParent, const wxString& aTitle, const wxString& aMessage,
|
|
|
|
const wxArrayString& aOptions )
|
2018-03-02 16:54:03 +00:00
|
|
|
: wxMultiChoiceDialog( aParent, aMessage, aTitle, aOptions ),
|
|
|
|
m_optionsCount( aOptions.GetCount() )
|
2017-11-06 08:35:05 +00:00
|
|
|
{
|
|
|
|
wxBoxSizer* btnSizer = new wxBoxSizer( wxHORIZONTAL );
|
2017-11-21 17:17:30 +00:00
|
|
|
wxButton* selectAll = new wxButton( this, wxID_ANY, _( "Select All" ) );
|
2017-11-21 22:01:00 +00:00
|
|
|
btnSizer->Add( selectAll, 1, wxEXPAND | wxALL, 5 );
|
2017-11-21 17:17:30 +00:00
|
|
|
wxButton* unselectAll = new wxButton( this, wxID_ANY, _( "Unselect All" ) );
|
2017-11-21 22:01:00 +00:00
|
|
|
btnSizer->Add( unselectAll, 1, wxEXPAND | wxALL, 5 );
|
2018-03-02 16:54:03 +00:00
|
|
|
auto sizer = GetSizer();
|
|
|
|
sizer->Insert( sizer->GetItemCount() - 1, btnSizer, 0, wxEXPAND | wxALL, 0 );
|
2017-11-06 08:35:05 +00:00
|
|
|
|
|
|
|
Layout();
|
2018-03-02 16:54:03 +00:00
|
|
|
sizer->Fit( this );
|
|
|
|
sizer->SetSizeHints( this );
|
2017-11-06 08:35:05 +00:00
|
|
|
Centre( wxBOTH );
|
|
|
|
|
|
|
|
selectAll->Bind( wxEVT_COMMAND_BUTTON_CLICKED, &DIALOG_MULTI_OPTIONS::selectAll, this );
|
|
|
|
unselectAll->Bind( wxEVT_COMMAND_BUTTON_CLICKED, &DIALOG_MULTI_OPTIONS::unselectAll, this );
|
|
|
|
}
|
|
|
|
|
2018-03-02 16:54:03 +00:00
|
|
|
void SetCheckboxes( bool aValue )
|
2017-11-06 08:35:05 +00:00
|
|
|
{
|
2018-03-02 16:54:03 +00:00
|
|
|
wxArrayInt selIdxs;
|
2017-11-06 08:35:05 +00:00
|
|
|
|
2018-03-02 16:54:03 +00:00
|
|
|
if( aValue ) // select all indices
|
2017-11-06 08:35:05 +00:00
|
|
|
{
|
2018-03-03 01:07:20 +00:00
|
|
|
for( int i = 0; i < m_optionsCount; ++i )
|
2018-03-02 16:54:03 +00:00
|
|
|
selIdxs.Add( i );
|
2017-11-06 08:35:05 +00:00
|
|
|
}
|
|
|
|
|
2018-03-02 16:54:03 +00:00
|
|
|
SetSelections( selIdxs );
|
2017-11-06 08:35:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
2018-03-02 16:54:03 +00:00
|
|
|
///> Number of displayed options
|
|
|
|
int m_optionsCount;
|
2017-11-06 08:35:05 +00:00
|
|
|
|
|
|
|
void selectAll( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
SetCheckboxes( true );
|
|
|
|
}
|
|
|
|
|
|
|
|
void unselectAll( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
SetCheckboxes( false );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2018-03-02 16:54:03 +00:00
|
|
|
std::pair<bool, wxArrayInt> SelectMultipleOptions( wxWindow* aParent, const wxString& aTitle,
|
2017-11-06 08:35:05 +00:00
|
|
|
const wxString& aMessage, const wxArrayString& aOptions, bool aDefaultState )
|
|
|
|
{
|
|
|
|
DIALOG_MULTI_OPTIONS dlg( aParent, aTitle, aMessage, aOptions );
|
2018-03-02 16:54:03 +00:00
|
|
|
dlg.Layout();
|
2017-11-06 08:35:05 +00:00
|
|
|
dlg.SetCheckboxes( aDefaultState );
|
|
|
|
|
2018-03-02 16:54:03 +00:00
|
|
|
wxArrayInt ret;
|
|
|
|
bool clickedOk = ( dlg.ShowModal() == wxID_OK );
|
|
|
|
|
|
|
|
if( clickedOk )
|
|
|
|
ret = dlg.GetSelections();
|
2017-11-06 08:35:05 +00:00
|
|
|
|
|
|
|
return std::make_pair( clickedOk, ret );
|
|
|
|
}
|
2017-11-21 17:17:30 +00:00
|
|
|
|
|
|
|
|
2018-03-02 16:54:03 +00:00
|
|
|
std::pair<bool, wxArrayInt> SelectMultipleOptions( wxWindow* aParent, const wxString& aTitle,
|
2017-11-21 17:17:30 +00:00
|
|
|
const wxString& aMessage, const std::vector<std::string>& aOptions, bool aDefaultState )
|
|
|
|
{
|
|
|
|
wxArrayString array;
|
|
|
|
|
|
|
|
for( const auto& option : aOptions )
|
|
|
|
array.Add( option );
|
|
|
|
|
|
|
|
return SelectMultipleOptions( aParent, aTitle, aMessage, array, aDefaultState );
|
|
|
|
}
|