25#include <wx/stockitem.h>
26#include <wx/richmsgdlg.h>
28#include <wx/choicdlg.h>
44 wxRichMessageDialog dlg( aParent, aMessage,
_(
"File Open Warning" ),
45 wxYES_NO | wxICON_WARNING | wxCENTER );
46 dlg.SetExtendedMessage(
_(
"Interleaved saves may produce very unexpected results." )
48 dlg.SetYesNoLabels(
_(
"&Cancel" ),
_(
"&Open Anyway" ) );
51 wxYES_NO | wxICON_ERROR | wxCENTER );
52 dlg.SetExtendedMessage(
_(
"Interleaved saves may produce very unexpected results." ) );
53 dlg.SetYesNoLabels(
_(
"&Cancel" ),
_(
"&Open Anyway" ) );
56 return dlg.ShowModal() == wxID_NO;
62 static bool s_apply_to_all =
false;
66 wxYES_DEFAULT | wxICON_WARNING | wxCENTER );
67 dlg.SetExtendedMessage(
_(
"If you don't save, all your changes will be permanently lost." )
69 dlg.SetYesNoLabels(
_(
"&Save" ),
_(
"&Discard Changes" ) );
72 dlg.ShowCheckBox(
_(
"&Apply to all" ), s_apply_to_all );
74 int ret = dlg.ShowModal();
78 *aApplyToAll = dlg.IsCheckBoxChecked();
79 s_apply_to_all = dlg.IsCheckBoxChecked();
94 int ret = wxID_CANCEL;
104 wxWindowDisabler disable(
true );
108 wxYES_NO | wxCANCEL | wxYES_DEFAULT | wxICON_WARNING | wxCENTER );
109 dlg.SetExtendedMessage(
_(
"If you don't save, all your changes will be permanently lost." ) );
110 dlg.SetYesNoLabels(
_(
"&Save" ),
_(
"&Discard Changes" ) );
113 ret = dlg.ShowModal();
136 wxOK | wxCANCEL | wxOK_DEFAULT | wxICON_WARNING | wxCENTER );
137 dlg.SetExtendedMessage(
_(
"Your current changes will be permanently lost." ) );
138 dlg.SetOKCancelLabels(
_(
"&Revert" ),
_(
"&Cancel" ) );
140 return dlg.ShowModal() == wxID_OK;
147 const std::function<
bool()>& aSaveFunction )
152 case wxID_YES:
return aSaveFunction();
153 case wxID_NO:
return true;
155 case wxID_CANCEL:
return false;
165int OKOrCancelDialog( wxWindow* aParent,
const wxString& aWarning,
const wxString& aMessage,
166 const wxString& aDetailedMessage,
const wxString& aOKLabel,
167 const wxString& aCancelLabel,
bool* aApplyToAll )
170 wxOK | wxCANCEL | wxOK_DEFAULT | wxICON_WARNING | wxCENTER );
172 dlg.SetOKCancelLabels( ( aOKLabel.IsEmpty() ) ?
_(
"&OK" ) : aOKLabel,
173 ( aCancelLabel.IsEmpty() ) ?
_(
"&Cancel" ) : aCancelLabel );
175 if( !aDetailedMessage.IsEmpty() )
176 dlg.SetExtendedMessage( aDetailedMessage );
179 dlg.ShowCheckBox(
_(
"&Apply to all" ),
true );
181 int ret = dlg.ShowModal();
184 *aApplyToAll = dlg.IsCheckBoxChecked();
194 if( !wxTheApp || !wxTheApp->IsMainLoopRunning() )
196 wxLogError(
"%s", aText );
200 if( !wxTheApp->IsGUI() )
202 wxFprintf( stderr, aText );
209 wxOK | wxCENTRE | wxRESIZE_BORDER |
210 wxICON_ERROR | wxSTAY_ON_TOP );
219 if( !wxTheApp || !wxTheApp->IsMainLoopRunning() )
221 wxLogError(
"%s %s", aText, aExtraInfo );
225 if( !wxTheApp->IsGUI() )
227 wxFprintf( stderr, aText );
234 wxOK | wxCENTRE | wxRESIZE_BORDER |
235 wxICON_ERROR | wxSTAY_ON_TOP );
237 if( !aExtraInfo.IsEmpty() )
238 dlg->SetExtendedMessage( aExtraInfo );
247 if( !wxTheApp || !wxTheApp->GetTopWindow() )
249 wxLogTrace(
traceConfirm, wxS(
"%s %s" ), aMessage, aExtraInfo );
253 if( !wxTheApp->IsGUI() )
255 wxFprintf( stdout,
"%s %s", aMessage, aExtraInfo );
260 int icon = wxICON_INFORMATION;
263 wxOK | wxCENTRE | wxRESIZE_BORDER |
264 icon | wxSTAY_ON_TOP );
266 if( !aExtraInfo.IsEmpty() )
267 dlg->SetExtendedMessage( aExtraInfo );
274bool IsOK( wxWindow* aParent,
const wxString& aMessage )
284 int icon = wxICON_WARNING;
286 int icon = wxICON_QUESTION;
290 wxOK | wxCANCEL | wxOK_DEFAULT |
291 wxCENTRE | icon | wxSTAY_ON_TOP );
293 dlg.SetOKCancelLabels(
_(
"&Yes" ),
_(
"&No" ) );
295 return dlg.ShowModal() == wxID_OK;
300 const wxString& aMessage,
const wxArrayString& aOptions )
302 wxSingleChoiceDialog dlg( aParent, aMessage, aTitle, aOptions );
304 if( dlg.ShowModal() != wxID_OK )
307 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 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.
static int g_lastUnsavedChangesResult
int GetLastUnsavedChangesResponse()
Return the result code from the last call to HandleUnsavedChanges(): wxID_YES, wxID_NO or wxID_CANCEL...
void DisplayError(wxWindow *aParent, const wxString &aText)
Display an error or warning message box with aMessage.
This file is part of the common library.
#define KICAD_RICH_MESSAGE_DIALOG_BASE
#define KICAD_MESSAGE_DIALOG
#define KICAD_MESSAGE_DIALOG_BASE
static const wxChar traceConfirm[]
Flag to enable confirmation dialog debugging output.