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();
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 return dlg.ShowModal();
121 wxOK | wxCANCEL | wxOK_DEFAULT | wxICON_WARNING | wxCENTER );
122 dlg.SetExtendedMessage(
_(
"Your current changes will be permanently lost." ) );
123 dlg.SetOKCancelLabels(
_(
"&Revert" ),
_(
"&Cancel" ) );
125 return dlg.ShowModal() == wxID_OK;
130 const std::function<
bool()>& aSaveFunction )
134 case wxID_YES:
return aSaveFunction();
135 case wxID_NO:
return true;
137 case wxID_CANCEL:
return false;
142int OKOrCancelDialog( wxWindow* aParent,
const wxString& aWarning,
const wxString& aMessage,
143 const wxString& aDetailedMessage,
const wxString& aOKLabel,
144 const wxString& aCancelLabel,
bool* aApplyToAll )
147 wxOK | wxCANCEL | wxOK_DEFAULT | wxICON_WARNING | wxCENTER );
149 dlg.SetOKCancelLabels( ( aOKLabel.IsEmpty() ) ?
_(
"&OK" ) : aOKLabel,
150 ( aCancelLabel.IsEmpty() ) ?
_(
"&Cancel" ) : aCancelLabel );
152 if( !aDetailedMessage.IsEmpty() )
153 dlg.SetExtendedMessage( aDetailedMessage );
156 dlg.ShowCheckBox(
_(
"&Apply to all" ),
true );
158 int ret = dlg.ShowModal();
161 *aApplyToAll = dlg.IsCheckBoxChecked();
171 if( !wxTheApp || !wxTheApp->IsMainLoopRunning() )
173 wxLogError(
"%s", aText );
177 if( !wxTheApp->IsGUI() )
179 wxFprintf( stderr, aText );
186 wxOK | wxCENTRE | wxRESIZE_BORDER |
187 wxICON_ERROR | wxSTAY_ON_TOP );
196 if( !wxTheApp || !wxTheApp->IsMainLoopRunning() )
198 wxLogError(
"%s %s", aText, aExtraInfo );
202 if( !wxTheApp->IsGUI() )
204 wxFprintf( stderr, aText );
211 wxOK | wxCENTRE | wxRESIZE_BORDER |
212 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 );
237 int icon = wxICON_INFORMATION;
240 wxOK | wxCENTRE | wxRESIZE_BORDER |
241 icon | wxSTAY_ON_TOP );
243 if( !aExtraInfo.IsEmpty() )
244 dlg->SetExtendedMessage( aExtraInfo );
251bool IsOK( wxWindow* aParent,
const wxString& aMessage )
261 int icon = wxICON_WARNING;
263 int icon = wxICON_QUESTION;
266#if !defined( __WXGTK__ )
268 wxOK | wxCANCEL | wxOK_DEFAULT |
269 wxCENTRE | icon | wxSTAY_ON_TOP );
271 wxMessageDialog dlg( aParent, aMessage,
_(
"Confirmation" ),
272 wxOK | wxCANCEL | wxOK_DEFAULT | wxCENTRE | icon | wxSTAY_ON_TOP );
275 dlg.SetOKCancelLabels(
_(
"&Yes" ),
_(
"&No" ) );
277 return dlg.ShowModal() == wxID_OK;
282 const wxString& aMessage,
const wxArrayString& aOptions )
284 wxSingleChoiceDialog dlg( aParent, aMessage, aTitle, aOptions );
286 if( dlg.ShowModal() != wxID_OK )
289 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.
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_BASE
static const wxChar traceConfirm[]
Flag to enable confirmation dialog debugging output.