25 #include <wx/stockitem.h> 26 #include <wx/richmsgdlg.h> 27 #include <wx/choicdlg.h> 32 #include <unordered_map> 40 : wxRichMessageDialog( aParent, aMessage, aCaption, aStyle | wxCENTRE | wxSTAY_ON_TOP ),
42 m_cancelMeansCancel( true )
48 const wxString& aCaption )
49 : wxRichMessageDialog( aParent, aMessage, getCaption( aType, aCaption ), getStyle( aType ) ),
51 m_cancelMeansCancel( true )
58 ShowCheckBox(
_(
"Do not show again" ),
false );
88 int ret = wxRichMessageDialog::Show( aShow );
108 int ret = wxRichMessageDialog::ShowModal();
122 if( !aCaption.IsEmpty() )
128 case KD_INFO:
return _(
"Message" );
134 return wxEmptyString;
140 long style = wxOK | wxCENTRE | wxSTAY_ON_TOP;
145 case KD_INFO: style |= wxICON_INFORMATION;
break;
147 case KD_WARNING: style |= wxICON_WARNING;
break;
148 case KD_ERROR: style |= wxICON_ERROR;
break;
157 static bool s_apply_to_all =
false;
159 wxRichMessageDialog dlg( parent, aMessage, wxEmptyString,
160 wxYES_NO | wxCANCEL | wxYES_DEFAULT | wxICON_WARNING | wxCENTER );
161 dlg.SetExtendedMessage(
_(
"If you don't save, all your changes will be permanently lost." ) );
162 dlg.SetYesNoLabels(
_(
"Save" ),
_(
"Discard Changes" ) );
165 dlg.ShowCheckBox(
_(
"Apply to all" ), s_apply_to_all );
167 int ret = dlg.ShowModal();
171 *aApplyToAll = dlg.IsCheckBoxChecked();
172 s_apply_to_all = dlg.IsCheckBoxChecked();
186 wxMessageDialog dlg( parent, aMessage, wxEmptyString,
187 wxYES_NO | wxCANCEL | wxYES_DEFAULT | wxICON_WARNING | wxCENTER );
188 dlg.SetExtendedMessage(
_(
"If you don't save, all your changes will be permanently lost." ) );
189 dlg.SetYesNoLabels(
_(
"Save" ),
_(
"Discard Changes" ) );
192 return dlg.ShowModal();
199 wxMessageDialog dlg( parent, aMessage, wxEmptyString,
200 wxOK | wxCANCEL | wxOK_DEFAULT | wxICON_WARNING | wxCENTER );
201 dlg.SetExtendedMessage(
_(
"Your current changes will be permanently lost." ) );
202 dlg.SetOKCancelLabels(
_(
"Revert" ),
_(
"Cancel" ) );
204 return dlg.ShowModal() == wxID_OK;
209 const std::function<
bool()>& aSaveFunction )
213 case wxID_YES:
return aSaveFunction();
214 case wxID_NO:
return true;
216 case wxID_CANCEL:
return false;
221 int OKOrCancelDialog( wxWindow* aParent,
const wxString& aWarning,
const wxString& aMessage,
222 wxString aDetailedMessage, wxString aOKLabel, wxString aCancelLabel,
225 wxRichMessageDialog dlg( aParent, aMessage, aWarning,
226 wxOK | wxCANCEL | wxOK_DEFAULT | wxICON_WARNING | wxCENTER );
228 if( aOKLabel.IsEmpty() )
229 aOKLabel =
_(
"OK" );
231 if( aCancelLabel.IsEmpty() )
232 aCancelLabel =
_(
"Cancel" );
234 dlg.SetOKCancelLabels( aOKLabel, aCancelLabel );
236 if( !aDetailedMessage.IsEmpty() )
237 dlg.SetExtendedMessage( aDetailedMessage );
240 dlg.ShowCheckBox(
_(
"Apply to all" ),
true );
242 int ret = dlg.ShowModal();
245 *aApplyToAll = dlg.IsCheckBoxChecked();
253 void DisplayError( wxWindow* aParent,
const wxString& aText,
int aDisplayTime )
255 wxMessageDialog* dlg;
256 int icon = aDisplayTime > 0 ? wxICON_INFORMATION : wxICON_ERROR;
258 dlg =
new wxMessageDialog( aParent, aText,
_(
"Warning" ),
259 wxOK | wxCENTRE | wxRESIZE_BORDER | icon | wxSTAY_ON_TOP );
268 wxMessageDialog* dlg;
270 dlg =
new wxMessageDialog( aParent, aText,
_(
"Error" ),
271 wxOK | wxCENTRE | wxRESIZE_BORDER | wxICON_ERROR | wxSTAY_ON_TOP );
273 if( !aExtraInfo.IsEmpty() )
274 dlg->SetExtendedMessage( aExtraInfo );
283 wxRichMessageDialog* dlg;
284 int icon = wxICON_INFORMATION;
286 dlg =
new wxRichMessageDialog( aParent, aMessage,
_(
"Info" ),
287 wxOK | wxCENTRE | wxRESIZE_BORDER | icon | wxSTAY_ON_TOP );
289 if( !aExtraInfo.IsEmpty() )
290 dlg->ShowDetailedText( aExtraInfo );
297 bool IsOK( wxWindow* aParent,
const wxString& aMessage )
299 wxMessageDialog dlg( aParent, aMessage,
_(
"Confirmation" ),
300 wxYES_NO | wxCENTRE | wxICON_QUESTION | wxSTAY_ON_TOP );
301 dlg.SetEscapeId( wxID_NO );
303 return dlg.ShowModal() == wxID_YES;
308 const wxString& aMessage,
const wxArrayString& aOptions )
310 wxSingleChoiceDialog dlg( aParent, aMessage, aTitle, aOptions );
312 if( dlg.ShowModal() != wxID_OK )
315 return dlg.GetSelection();
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
bool HandleUnsavedChanges(wxWindow *aParent, const wxString &aMessage, const std::function< bool()> &aSaveFunction)
Display a dialog with Save, Cancel and Discard Changes buttons.
void DoNotShowCheckbox(wxString file, int line)
Checks the 'do not show again' setting for the dialog.
bool ConfirmRevertDialog(wxWindow *parent, const wxString &aMessage)
Display a confirmation dialog for a revert action.
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
This file is part of the common library.
KD_TYPE
< Dialog type. Selects appropriate icon and default dialog title
static std::unordered_map< unsigned long, int > doNotShowAgainDlgs
static wxString getCaption(KD_TYPE aType, const wxString &aCaption)
bool Show(bool aShow=true) override
static long getStyle(KD_TYPE aType)
int UnsavedChangesDialog(wxWindow *parent, wxString aMessage, bool *aApplyToAll)
A specialized version of HandleUnsavedChanges which handles an apply-to-all checkbox.
bool DoNotShowAgain() const
int OKOrCancelDialog(wxWindow *aParent, const wxString &aWarning, const wxString &aMessage, wxString aDetailedMessage, wxString aOKLabel, wxString aCancelLabel, bool *aApplyToAll)
Display a warning dialog with aMessage and returns the user response.
KIDIALOG(wxWindow *aParent, const wxString &aMessage, const wxString &aCaption, long aStyle=wxOK)
int SelectSingleOption(wxWindow *aParent, const wxString &aTitle, const wxString &aMessage, const wxArrayString &aOptions)
Display a dialog with radioboxes asking the user to select an option.
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Display a yes/no dialog with aMessage and returns the user response.