29#include <wx/stockitem.h>
30#include <wx/richmsgdlg.h>
32#include <wx/choicdlg.h>
42 wxRichMessageDialog dlg( aParent, aMessage,
_(
"File Open Warning" ),
43 wxYES_NO | wxICON_WARNING | wxCENTER );
44 dlg.SetExtendedMessage(
_(
"Interleaved saves may produce very unexpected results." )
46 dlg.SetYesNoLabels(
_(
"Cancel" ),
_(
"Open Anyway" ) );
48 wxMessageDialog dlg( aParent, aMessage,
_(
"File Open Warning" ),
49 wxYES_NO | wxICON_ERROR | wxCENTER );
50 dlg.SetExtendedMessage(
_(
"Interleaved saves may produce very unexpected results." ) );
51 dlg.SetYesNoLabels(
_(
"Cancel" ),
_(
"Open Anyway" ) );
54 return dlg.ShowModal() == wxID_NO;
60 static bool s_apply_to_all =
false;
62 wxRichMessageDialog dlg( parent, aMessage,
_(
"Save Changes?" ),
63 wxYES_NO | wxCANCEL | wxYES_DEFAULT | wxICON_WARNING | wxCENTER );
64 dlg.SetExtendedMessage(
_(
"If you don't save, all your changes will be permanently lost." )
66 dlg.SetYesNoLabels(
_(
"Save" ),
_(
"Discard Changes" ) );
69 dlg.ShowCheckBox(
_(
"Apply to all" ), s_apply_to_all );
71 int ret = dlg.ShowModal();
75 *aApplyToAll = dlg.IsCheckBoxChecked();
76 s_apply_to_all = dlg.IsCheckBoxChecked();
96 wxWindowDisabler disable(
true );
99 wxMessageDialog dlg( parent, aMessage,
_(
"Save Changes?" ),
100 wxYES_NO | wxCANCEL | wxYES_DEFAULT | wxICON_WARNING | wxCENTER );
101 dlg.SetExtendedMessage(
_(
"If you don't save, all your changes will be permanently lost." ) );
102 dlg.SetYesNoLabels(
_(
"Save" ),
_(
"Discard Changes" ) );
105 return dlg.ShowModal();
112 wxMessageDialog dlg( parent, aMessage, wxEmptyString,
113 wxOK | wxCANCEL | wxOK_DEFAULT | wxICON_WARNING | wxCENTER );
114 dlg.SetExtendedMessage(
_(
"Your current changes will be permanently lost." ) );
115 dlg.SetOKCancelLabels(
_(
"Revert" ),
_(
"Cancel" ) );
117 return dlg.ShowModal() == wxID_OK;
122 const std::function<
bool()>& aSaveFunction )
126 case wxID_YES:
return aSaveFunction();
127 case wxID_NO:
return true;
129 case wxID_CANCEL:
return false;
134int OKOrCancelDialog( wxWindow* aParent,
const wxString& aWarning,
const wxString& aMessage,
135 const wxString& aDetailedMessage,
const wxString& aOKLabel,
136 const wxString& aCancelLabel,
bool* aApplyToAll )
138 wxRichMessageDialog dlg( aParent, aMessage, aWarning,
139 wxOK | wxCANCEL | wxOK_DEFAULT | wxICON_WARNING | wxCENTER );
141 dlg.SetOKCancelLabels( ( aOKLabel.IsEmpty() ) ?
_(
"OK" ) : aOKLabel,
142 ( aCancelLabel.IsEmpty() ) ?
_(
"Cancel" ) : aCancelLabel );
144 if( !aDetailedMessage.IsEmpty() )
145 dlg.SetExtendedMessage( aDetailedMessage );
148 dlg.ShowCheckBox(
_(
"Apply to all" ),
true );
150 int ret = dlg.ShowModal();
153 *aApplyToAll = dlg.IsCheckBoxChecked();
161void DisplayError( wxWindow* aParent,
const wxString& aText,
int aDisplayTime )
163 if( !wxTheApp || !wxTheApp->IsMainLoopRunning() )
165 wxLogError(
"%s", aText );
169 if( !wxTheApp->IsGUI() )
171 wxFprintf( stderr, aText );
175 wxMessageDialog* dlg;
176 int icon = aDisplayTime > 0 ? wxICON_INFORMATION : wxICON_ERROR;
178 dlg =
new wxMessageDialog( aParent, aText,
_(
"Warning" ),
179 wxOK | wxCENTRE | wxRESIZE_BORDER | icon | wxSTAY_ON_TOP );
188 if( !wxTheApp || !wxTheApp->IsMainLoopRunning() )
190 wxLogError(
"%s %s", aText, aExtraInfo );
194 if( !wxTheApp->IsGUI() )
196 wxFprintf( stderr, aText );
200 wxMessageDialog* dlg;
202 dlg =
new wxMessageDialog( aParent, aText,
_(
"Error" ),
203 wxOK | wxCENTRE | wxRESIZE_BORDER | wxICON_ERROR | wxSTAY_ON_TOP );
205 if( !aExtraInfo.IsEmpty() )
206 dlg->SetExtendedMessage( aExtraInfo );
215 if( !wxTheApp || !wxTheApp->GetTopWindow() )
217 wxLogDebug(
"%s %s", aMessage, aExtraInfo );
221 if( !wxTheApp->IsGUI() )
223 wxFprintf( stdout,
"%s %s", aMessage, aExtraInfo );
227 wxMessageDialog* dlg;
228 int icon = wxICON_INFORMATION;
230 dlg =
new wxMessageDialog( aParent, aMessage,
_(
"Information" ),
231 wxOK | wxCENTRE | wxRESIZE_BORDER | icon | wxSTAY_ON_TOP );
233 if( !aExtraInfo.IsEmpty() )
234 dlg->SetExtendedMessage( aExtraInfo );
241bool IsOK( wxWindow* aParent,
const wxString& aMessage )
251 int icon = wxICON_WARNING;
253 int icon = wxICON_QUESTION;
256#if !defined( __WXGTK__ )
257 wxRichMessageDialog dlg( aParent, aMessage,
_(
"Confirmation" ),
258 wxOK | wxCANCEL | wxOK_DEFAULT | wxCENTRE | icon | wxSTAY_ON_TOP );
260 wxMessageDialog dlg( aParent, aMessage,
_(
"Confirmation" ),
261 wxOK | wxCANCEL | wxOK_DEFAULT | wxCENTRE | icon | wxSTAY_ON_TOP );
264 dlg.SetOKCancelLabels(
_(
"Yes" ),
_(
"No" ) );
266 return dlg.ShowModal() == wxID_OK;
271 const wxString& aMessage,
const wxArrayString& aOptions )
273 wxSingleChoiceDialog dlg( aParent, aMessage, aTitle, aOptions );
275 if( dlg.ShowModal() != wxID_OK )
278 return dlg.GetSelection();
bool AskOverrideLock(wxWindow *aParent, const wxString &aMessage)
Display a dialog indicating the file is already open, with an option to reset the lock.
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.
int OKOrCancelDialog(wxWindow *aParent, const wxString &aWarning, const wxString &aMessage, const wxString &aDetailedMessage, const wxString &aOKLabel, const wxString &aCancelLabel, bool *aApplyToAll)
Display a warning dialog with aMessage and returns the user response.
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Display a yes/no dialog with aMessage and returns the user response.
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational 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 DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
int UnsavedChangesDialog(wxWindow *parent, const wxString &aMessage, bool *aApplyToAll)
A specialized version of HandleUnsavedChanges which handles an apply-to-all checkbox.
bool ConfirmRevertDialog(wxWindow *parent, const wxString &aMessage)
Display a confirmation dialog for a revert action.
This file is part of the common library.