29#include <wx/stockitem.h>
30#include <wx/richmsgdlg.h>
32#include <wx/choicdlg.h>
48 wxRichMessageDialog dlg( aParent, aMessage,
_(
"File Open Warning" ),
49 wxYES_NO | wxICON_WARNING | wxCENTER );
50 dlg.SetExtendedMessage(
_(
"Interleaved saves may produce very unexpected results." )
52 dlg.SetYesNoLabels(
_(
"&Cancel" ),
_(
"&Open Anyway" ) );
55 wxYES_NO | wxICON_ERROR | wxCENTER );
56 dlg.SetExtendedMessage(
_(
"Interleaved saves may produce very unexpected results." ) );
57 dlg.SetYesNoLabels(
_(
"&Cancel" ),
_(
"&Open Anyway" ) );
60 return dlg.ShowModal() == wxID_NO;
66 static bool s_apply_to_all =
false;
70 wxYES_DEFAULT | wxICON_WARNING | wxCENTER );
71 dlg.SetExtendedMessage(
_(
"If you don't save, all your changes will be permanently lost." )
73 dlg.SetYesNoLabels(
_(
"&Save" ),
_(
"&Discard Changes" ) );
76 dlg.ShowCheckBox(
_(
"&Apply to all" ), s_apply_to_all );
78 int ret = dlg.ShowModal();
82 *aApplyToAll = dlg.IsCheckBoxChecked();
83 s_apply_to_all = dlg.IsCheckBoxChecked();
98 int ret = wxID_CANCEL;
108 wxWindowDisabler disable(
true );
112 wxYES_NO | wxCANCEL | wxYES_DEFAULT | wxICON_WARNING | wxCENTER );
113 dlg.SetExtendedMessage(
_(
"If you don't save, all your changes will be permanently lost." ) );
114 dlg.SetYesNoLabels(
_(
"&Save" ),
_(
"&Discard Changes" ) );
117 ret = dlg.ShowModal();
140 wxOK | wxCANCEL | wxOK_DEFAULT | wxICON_WARNING | wxCENTER );
141 dlg.SetExtendedMessage(
_(
"Your current changes will be permanently lost." ) );
142 dlg.SetOKCancelLabels(
_(
"&Revert" ),
_(
"&Cancel" ) );
144 return dlg.ShowModal() == wxID_OK;
151 const std::function<
bool()>& aSaveFunction )
156 case wxID_YES:
return aSaveFunction();
157 case wxID_NO:
return true;
159 case wxID_CANCEL:
return false;
169int OKOrCancelDialog( wxWindow* aParent,
const wxString& aWarning,
const wxString& aMessage,
170 const wxString& aDetailedMessage,
const wxString& aOKLabel,
171 const wxString& aCancelLabel,
bool* aApplyToAll )
174 wxOK | wxCANCEL | wxOK_DEFAULT | wxICON_WARNING | wxCENTER );
176 dlg.SetOKCancelLabels( ( aOKLabel.IsEmpty() ) ?
_(
"&OK" ) : aOKLabel,
177 ( aCancelLabel.IsEmpty() ) ?
_(
"&Cancel" ) : aCancelLabel );
179 if( !aDetailedMessage.IsEmpty() )
180 dlg.SetExtendedMessage( aDetailedMessage );
183 dlg.ShowCheckBox(
_(
"&Apply to all" ),
true );
185 int ret = dlg.ShowModal();
188 *aApplyToAll = dlg.IsCheckBoxChecked();
198 if( !wxTheApp || !wxTheApp->IsMainLoopRunning() )
200 wxLogError(
"%s", aText );
204 if( !wxTheApp->IsGUI() )
206 wxFprintf( stderr, aText );
213 wxOK | wxCENTRE | wxRESIZE_BORDER |
214 wxICON_ERROR | wxSTAY_ON_TOP );
223 if( !wxTheApp || !wxTheApp->IsMainLoopRunning() )
225 wxLogError(
"%s %s", aText, aExtraInfo );
229 if( !wxTheApp->IsGUI() )
231 wxFprintf( stderr, aText );
238 wxOK | wxCENTRE | wxRESIZE_BORDER |
239 wxICON_ERROR | wxSTAY_ON_TOP );
241 if( !aExtraInfo.IsEmpty() )
242 dlg->SetExtendedMessage( aExtraInfo );
251 if( !wxTheApp || !wxTheApp->GetTopWindow() )
253 wxLogTrace(
traceConfirm, wxS(
"%s %s" ), aMessage, aExtraInfo );
257 if( !wxTheApp->IsGUI() )
259 wxFprintf( stdout,
"%s %s", aMessage, aExtraInfo );
264 int icon = wxICON_INFORMATION;
267 wxOK | wxCENTRE | wxRESIZE_BORDER |
268 icon | wxSTAY_ON_TOP );
270 if( !aExtraInfo.IsEmpty() )
271 dlg->SetExtendedMessage( aExtraInfo );
278bool IsOK( wxWindow* aParent,
const wxString& aMessage )
288 int icon = wxICON_WARNING;
290 int icon = wxICON_QUESTION;
294 wxOK | wxCANCEL | wxOK_DEFAULT |
295 wxCENTRE | icon | wxSTAY_ON_TOP );
297 dlg.SetOKCancelLabels(
_(
"&Yes" ),
_(
"&No" ) );
299 return dlg.ShowModal() == wxID_OK;
304 const wxString& aMessage,
const wxArrayString& aOptions )
306 wxSingleChoiceDialog dlg( aParent, aMessage, aTitle, aOptions );
308 if( dlg.ShowModal() != wxID_OK )
311 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.