29#include <wx/stockitem.h>
30#include <wx/richmsgdlg.h>
32#include <wx/choicdlg.h>
50 wxRichMessageDialog dlg( aParent, aMessage,
_(
"File Open Warning" ),
51 wxYES_NO | wxICON_WARNING | wxCENTER );
52 dlg.SetExtendedMessage(
_(
"Interleaved saves may produce very unexpected results." )
54 dlg.SetYesNoLabels(
_(
"&Cancel" ),
_(
"&Open Anyway" ) );
56 wxMessageDialog dlg( aParent, aMessage,
_(
"File Open Warning" ),
57 wxYES_NO | wxICON_ERROR | wxCENTER );
58 dlg.SetExtendedMessage(
_(
"Interleaved saves may produce very unexpected results." ) );
59 dlg.SetYesNoLabels(
_(
"&Cancel" ),
_(
"&Open Anyway" ) );
62 return dlg.ShowModal() == wxID_NO;
68 static bool s_apply_to_all =
false;
70 wxRichMessageDialog dlg( parent, aMessage,
_(
"Save Changes?" ),
71 wxYES_NO | wxCANCEL | wxYES_DEFAULT | wxICON_WARNING | wxCENTER );
72 dlg.SetExtendedMessage(
_(
"If you don't save, all your changes will be permanently lost." )
74 dlg.SetYesNoLabels(
_(
"&Save" ),
_(
"&Discard Changes" ) );
77 dlg.ShowCheckBox(
_(
"&Apply to all" ), s_apply_to_all );
79 int ret = dlg.ShowModal();
83 *aApplyToAll = dlg.IsCheckBoxChecked();
84 s_apply_to_all = dlg.IsCheckBoxChecked();
105 wxWindowDisabler disable(
true );
108 wxMessageDialog dlg( parent, aMessage,
_(
"Save Changes?" ),
109 wxYES_NO | wxCANCEL | wxYES_DEFAULT | wxICON_WARNING | wxCENTER );
110 dlg.SetExtendedMessage(
_(
"If you don't save, all your changes will be permanently lost." ) );
111 dlg.SetYesNoLabels(
_(
"&Save" ),
_(
"&Discard Changes" ) );
114 return dlg.ShowModal();
121 wxMessageDialog dlg( parent, aMessage, wxEmptyString,
122 wxOK | wxCANCEL | wxOK_DEFAULT | wxICON_WARNING | wxCENTER );
123 dlg.SetExtendedMessage(
_(
"Your current changes will be permanently lost." ) );
124 dlg.SetOKCancelLabels(
_(
"&Revert" ),
_(
"&Cancel" ) );
126 return dlg.ShowModal() == wxID_OK;
131 const std::function<
bool()>& aSaveFunction )
135 case wxID_YES:
return aSaveFunction();
136 case wxID_NO:
return true;
138 case wxID_CANCEL:
return false;
143int OKOrCancelDialog( wxWindow* aParent,
const wxString& aWarning,
const wxString& aMessage,
144 const wxString& aDetailedMessage,
const wxString& aOKLabel,
145 const wxString& aCancelLabel,
bool* aApplyToAll )
147 wxRichMessageDialog dlg( aParent, aMessage, aWarning,
148 wxOK | wxCANCEL | wxOK_DEFAULT | wxICON_WARNING | wxCENTER );
150 dlg.SetOKCancelLabels( ( aOKLabel.IsEmpty() ) ?
_(
"&OK" ) : aOKLabel,
151 ( aCancelLabel.IsEmpty() ) ?
_(
"&Cancel" ) : aCancelLabel );
153 if( !aDetailedMessage.IsEmpty() )
154 dlg.SetExtendedMessage( aDetailedMessage );
157 dlg.ShowCheckBox(
_(
"&Apply to all" ),
true );
159 int ret = dlg.ShowModal();
162 *aApplyToAll = dlg.IsCheckBoxChecked();
170void DisplayError( wxWindow* aParent,
const wxString& aText,
int aDisplayTime )
172 if( !wxTheApp || !wxTheApp->IsMainLoopRunning() )
174 wxLogError(
"%s", aText );
178 if( !wxTheApp->IsGUI() )
180 wxFprintf( stderr, aText );
184 wxMessageDialog* dlg;
185 int icon = aDisplayTime > 0 ? wxICON_INFORMATION : wxICON_ERROR;
187 dlg =
new wxMessageDialog( aParent, aText,
_(
"Warning" ),
188 wxOK | wxCENTRE | wxRESIZE_BORDER | icon | wxSTAY_ON_TOP );
197 if( !wxTheApp || !wxTheApp->IsMainLoopRunning() )
199 wxLogError(
"%s %s", aText, aExtraInfo );
203 if( !wxTheApp->IsGUI() )
205 wxFprintf( stderr, aText );
209 wxMessageDialog* dlg;
211 dlg =
new wxMessageDialog( aParent, aText,
_(
"Error" ),
212 wxOK | wxCENTRE | wxRESIZE_BORDER | wxICON_ERROR | wxSTAY_ON_TOP );
214 if( !aExtraInfo.IsEmpty() )
215 dlg->SetExtendedMessage( aExtraInfo );
224 if( !wxTheApp || !wxTheApp->GetTopWindow() )
226 wxLogTrace(
traceConfirm, wxS(
"%s %s" ), aMessage, aExtraInfo );
230 if( !wxTheApp->IsGUI() )
232 wxFprintf( stdout,
"%s %s", aMessage, aExtraInfo );
236 wxMessageDialog* dlg;
237 int icon = wxICON_INFORMATION;
239 dlg =
new wxMessageDialog( aParent, aMessage,
_(
"Information" ),
240 wxOK | wxCENTRE | wxRESIZE_BORDER | icon | wxSTAY_ON_TOP );
242 if( !aExtraInfo.IsEmpty() )
243 dlg->SetExtendedMessage( aExtraInfo );
250bool IsOK( wxWindow* aParent,
const wxString& aMessage )
260 int icon = wxICON_WARNING;
262 int icon = wxICON_QUESTION;
265#if !defined( __WXGTK__ )
266 wxRichMessageDialog dlg( aParent, aMessage,
_(
"Confirmation" ),
267 wxOK | wxCANCEL | wxOK_DEFAULT | wxCENTRE | icon | wxSTAY_ON_TOP );
269 wxMessageDialog dlg( aParent, aMessage,
_(
"Confirmation" ),
270 wxOK | wxCANCEL | wxOK_DEFAULT | wxCENTRE | icon | wxSTAY_ON_TOP );
273 dlg.SetOKCancelLabels(
_(
"&Yes" ),
_(
"&No" ) );
275 return dlg.ShowModal() == wxID_OK;
280 const wxString& aMessage,
const wxArrayString& aOptions )
282 wxSingleChoiceDialog dlg( aParent, aMessage, aTitle, aOptions );
284 if( dlg.ShowModal() != wxID_OK )
287 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.
static const wxChar traceConfirm[]
Flag to enable confirmation dialog debugging output.