KiCad PCB EDA Suite
confirm.cpp File Reference
#include <wx/stockitem.h>
#include <wx/richmsgdlg.h>
#include <confirm.h>
#include <bitmaps.h>
#include <html_messagebox.h>
#include <functional>
#include <unordered_map>

Go to the source code of this file.

Functions

int UnsavedChangesDialog (wxWindow *parent, wxString aMessage, bool *aApplyToAll)
 A specialized version of HandleUnsavedChanges which handles an apply-to-all checkbox. More...
 
int UnsavedChangesDialog (wxWindow *parent, const wxString &aMessage)
 
bool ConfirmRevertDialog (wxWindow *parent, const wxString &aMessage)
 Display a confirmation dialog for a revert action. More...
 
bool HandleUnsavedChanges (wxWindow *aParent, const wxString &aMessage, const std::function< bool()> &aSaveFunction)
 Display a dialog with Save, Cancel and Discard Changes buttons. More...
 
int OKOrCancelDialog (wxWindow *aParent, const wxString &aWarning, const wxString &aMessage, const wxString &aOKLabel, const wxString &aCancelLabel, bool *aApplyToAll)
 Displays a warning dialog with aMessage and returns the user response. More...
 
void DisplayError (wxWindow *aParent, const wxString &aText, int aDisplayTime)
 Display an error or warning message box with aMessage. More...
 
void DisplayErrorMessage (wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
 Display an error message with aMessage. More...
 
void DisplayInfoMessage (wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
 Display an informational message box with aMessage. More...
 
bool IsOK (wxWindow *aParent, const wxString &aMessage)
 Display a yes/no dialog with aMessage and returns the user response. More...
 
int SelectSingleOption (wxWindow *aParent, const wxString &aTitle, const wxString &aMessage, const wxArrayString &aOptions)
 Displays a dialog with radioboxes asking the user to select an option. More...
 

Variables

static std::unordered_map< unsigned long, int > doNotShowAgainDlgs
 

Function Documentation

◆ ConfirmRevertDialog()

bool ConfirmRevertDialog ( wxWindow *  parent,
const wxString &  aMessage 
)

Display a confirmation dialog for a revert action.

Definition at line 190 of file confirm.cpp.

191 {
192  wxMessageDialog dlg( parent, aMessage, wxEmptyString,
193  wxOK | wxCANCEL | wxOK_DEFAULT | wxICON_WARNING | wxCENTER );
194  dlg.SetExtendedMessage( _( "Your current changes will be permanently lost." ) );
195  dlg.SetOKCancelLabels( _( "Revert" ), _( "Cancel" ) );
196 
197  return dlg.ShowModal() == wxID_OK;
198 }
#define _(s)

References _.

Referenced by LIB_EDIT_FRAME::Revert(), and FOOTPRINT_EDIT_FRAME::RevertFootprint().

◆ DisplayError()

void DisplayError ( wxWindow *  aParent,
const wxString &  aText,
int  aDisplayTime = 0 
)

Display an error or warning message box with aMessage.

Warning
Setting displaytime does not work. Do not use it.

Definition at line 236 of file confirm.cpp.

237 {
238  wxMessageDialog* dlg;
239  int icon = aDisplayTime > 0 ? wxICON_INFORMATION : wxICON_ERROR;
240 
241  dlg = new wxMessageDialog( aParent, aText, _( "Warning" ),
242  wxOK | wxCENTRE | wxRESIZE_BORDER | icon | wxSTAY_ON_TOP );
243 
244  dlg->ShowModal();
245  dlg->Destroy();
246 }
#define _(s)

References _.

Referenced by DIALOG_COPPER_ZONE::AcceptOptions(), PCB_BASE_EDIT_FRAME::AddLibrary(), LIB_EDIT_FRAME::AddLibraryFile(), NETLIST_EXPORTER::addPinToComponentPinList(), SIM_PLOT_FRAME::AddTuner(), PCBNEW_CONTROL::AppendBoard(), PCB_EDIT_FRAME::ArchiveModulesOnBoard(), LIB_EDIT_FRAME::backupFile(), SCH_EDIT_FRAME::checkSheetForRecursion(), FOOTPRINT_VIEWER_FRAME::ClickOnFootprintList(), SCH_EDIT_FRAME::ConvertPart(), PCB_EDIT_FRAME::Create_MuWaveComponent(), PCB_EDIT_FRAME::Create_MuWavePolygonShape(), DIALOG_GEN_FOOTPRINT_POSITION::CreateAsciiFiles(), PCB_EDIT_FRAME::createBackupFile(), DIALOG_GEN_FOOTPRINT_POSITION::CreateGerberFiles(), MICROWAVE_TOOL::createInductorBetween(), SPICE_SIMULATOR::CreateInstance(), PCB_BASE_EDIT_FRAME::CreateNewLibrary(), LIB_EDIT_FRAME::CreateNewPart(), SCH_EDIT_FRAME::CreateNewText(), UNIT_BINDER::delayedFocusHandler(), FOOTPRINT_EDIT_FRAME::DeleteModuleFromLibrary(), PANEL_SETUP_LAYERS::DenyChangeCheckBox(), FIELDS_EDITOR_GRID_TRICKS::doPopupSelection(), doPrintFile(), ExecuteFile(), FOOTPRINT_EDIT_FRAME::Export_Module(), LIB_EDIT_FRAME::ExportPart(), GBR_TO_PCB_EXPORTER::ExportPcb(), DIALOG_EXPORT_SVG::ExportSVGFile(), PCB_EDIT_FRAME::ExportToGenCAD(), PCB_EDIT_FRAME::FetchNetlistFromSchematic(), FootprintWriteShape(), NETLIST_EXPORTER_PSPICE::Format(), PCB_EDIT_FRAME::GenD356File(), DIALOG_GENDRILL::GenDrillAndMapFiles(), DIALOG_SPICE_MODEL::generatePowerSource(), PCB_EDIT_FRAME::GenFootprintsReport(), DISPLAY_FOOTPRINTS_FRAME::Get_Module(), GetAssociatedDocument(), FOOTPRINT_EDIT_FRAME::Import_Module(), SCH_EDIT_FRAME::importFile(), SCH_EDITOR_CONTROL::ImportFPAssignments(), LIB_EDIT_FRAME::ImportPart(), DIALOG_PRINT_GENERIC::initPrintData(), DIALOG_BOM::installGeneratorsList(), LIB_EDIT_FRAME::LoadOneSymbol(), LIB_EDIT_FRAME::LoadPart(), SIM_PLOT_FRAME::menuOpenWorkbook(), SIM_PLOT_FRAME::menuSaveWorkbook(), SCH_EDIT_FRAME::NewProject(), DIALOG_FIELDS_EDITOR_GLOBAL::OnAddField(), DIALOG_CONFIG_EQUFILES::OnAddFiles(), DIALOG_BOM::OnAddGenerator(), DIALOG_FIND::onButtonFindItemClick(), DIALOG_FIND::onButtonFindMarkerClick(), DIALOG_FIELDS_EDITOR_GLOBAL::OnColumnItemToggled(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnDeleteField(), DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnDeleteField(), DIALOG_FOOTPRINT_FP_EDITOR::OnDeleteField(), DIALOG_FOOTPRINT_BOARD_EDITOR::OnDeleteField(), SCH_EDIT_FRAME::OnOpenCvpcb(), DIALOG_PRINT_GENERIC::onPrintButtonClick(), DIALOG_PRINT_GENERIC::onPrintPreview(), SIM_PLOT_FRAME::onSettings(), PCB_DRAW_PANEL_GAL::OnShow(), DIALOG_DRC_CONTROL::OnStartdrcClick(), KICAD_MANAGER_FRAME::OnUnarchiveFiles(), SCH_EDIT_FRAME::OnUpdatePCB(), DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::OnUpdateUI(), DIALOG_FOOTPRINT_FP_EDITOR::OnUpdateUI(), DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnUpdateUI(), DIALOG_FOOTPRINT_BOARD_EDITOR::OnUpdateUI(), ROUTER_TOOL::onViaCommand(), WIZARD_3DSHAPE_LIBS_DOWNLOADER::OnWizardFinished(), OpenPDF(), SCH_EDIT_FRAME::OpenProjectFiles(), PCB_EDIT_FRAME::OpenProjectFiles(), PCB_PARSER::parseZONE_CONTAINER(), SCH_EDITOR_CONTROL::Paste(), SYMBOL_GRID_TRICKS::paste_text(), FP_GRID_TRICKS::paste_text(), DIALOG_PLOT::Plot(), ROUTER_TOOL::prepareInteractive(), NETLIST_EXPORTER_PSPICE::ProcessNetlist(), GERBVIEW_FRAME::Read_EXCELLON_File(), GERBVIEW_FRAME::Read_GERBER_File(), MWAVE_POLYGONAL_SHAPE_DLG::ReadDataShapeDescr(), PCB_EDIT_FRAME::RecreateBOMFileFromBoard(), PCB_EDIT_FRAME::RecreateCmpFileFromBoard(), KIGFX::VERTEX_MANAGER::Reserve(), MODULE::RunOnChildren(), SCH_EDIT_FRAME::SaveEEFile(), FOOTPRINT_EDIT_FRAME::SaveFootprintAs(), FOOTPRINT_EDIT_FRAME::SaveFootprintInLibrary(), FOOTPRINT_EDIT_FRAME::SaveFootprintToBoard(), LIB_EDIT_FRAME::saveLibrary(), FOOTPRINT_EDIT_FRAME::SaveLibraryAs(), LIB_EDIT_FRAME::savePartAs(), PCB_EDIT_FRAME::SavePcbCopy(), PCB_EDIT_FRAME::SavePcbFile(), SCH_EDIT_FRAME::SaveProject(), LIB_EDIT_FRAME::SelectLibraryFromList(), KIGFX::GPU_MANAGER::SetShader(), SIM_PLOT_FRAME::StartSimulation(), EDA_DRAW_PANEL_GAL::SwitchBackend(), DIALOG_GLOBAL_FP_LIB_TABLE_CONFIG::TransferDataFromWindow(), DIALOG_GLOBAL_SYM_LIB_TABLE_CONFIG::TransferDataFromWindow(), DIALOG_TRACK_VIA_PROPERTIES::TransferDataFromWindow(), DIALOG_TRACK_VIA_SIZE::TransferDataFromWindow(), DIALOG_PRINT_USING_PRINTER::TransferDataFromWindow(), DIALOG_IMPORT_SETTINGS::TransferDataFromWindow(), DIALOG_SCH_SHEET_PROPS::TransferDataFromWindow(), DIALOG_NON_COPPER_ZONES_EDITOR::TransferDataFromWindow(), DIALOG_KEEPOUT_AREA_PROPERTIES::TransferDataFromWindow(), DIALOG_EDIT_ONE_FIELD::TransferDataFromWindow(), DIALOG_TEXT_PROPERTIES::TransferDataFromWindow(), DIALOG_SIM_SETTINGS::TransferDataFromWindow(), DIALOG_LABEL_EDITOR::TransferDataFromWindow(), DIALOG_PAD_PROPERTIES::transferDataToPad(), REGEX_VALIDATOR::Validate(), SPICE_VALIDATOR::Validate(), KIGFX::VERTEX_MANAGER::Vertex(), KIGFX::VERTEX_MANAGER::Vertices(), NETLIST_EXPORTER_ORCADPCB2::WriteNetlist(), NETLIST_EXPORTER_KICAD::WriteNetlist(), NETLIST_EXPORTER_CADSTAR::WriteNetlist(), and LEGACY_RESCUER::WriteRescueLibrary().

◆ DisplayErrorMessage()

void DisplayErrorMessage ( wxWindow *  aParent,
const wxString &  aMessage,
const wxString &  aExtraInfo = wxEmptyString 
)

Display an error message with aMessage.

Parameters
aParentis the parent window
aMessageis the message text to display
aExtraInfois extra data that can be optionally displayed in a collapsible pane

Definition at line 249 of file confirm.cpp.

250 {
251  wxRichMessageDialog* dlg;
252  int icon = wxICON_ERROR;
253 
254  dlg = new wxRichMessageDialog( aParent, aText, _( "Error" ),
255  wxOK | wxCENTRE | wxRESIZE_BORDER | icon | wxSTAY_ON_TOP );
256 
257  if( !aExtraInfo.IsEmpty() )
258  dlg->ShowDetailedText( aExtraInfo );
259 
260  dlg->ShowModal();
261  dlg->Destroy();
262 }
#define _(s)

References _.

Referenced by FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB(), LIB_CONTROL::AddSymbolToSchematic(), CVPCB_ASSOCIATION_TOOL::Associate(), CVPCB_MAINFRAME::AssociateFootprint(), DIALOG_EDIT_COMPONENT_IN_LIBRARY::checkAliasName(), checkGlError(), copy_pro_file_template(), SCH_EDIT_FRAME::CreateArchiveLibrary(), MODULE_EDITOR_TOOLS::CreatePadFromShapes(), SCH_EDIT_FRAME::EditSheet(), LIB_EDIT_FRAME::ExportPart(), PCB_EDIT_FRAME::ExportSpecctraFile(), LIB_EDIT_FRAME::ImportPart(), PCB_EDIT_FRAME::ImportSpecctraSession(), FOOTPRINT_EDIT_FRAME::KiwayMailIn(), LIB_EDIT_FRAME::KiwayMailIn(), LIB_EDIT_FRAME::LoadComponentFromCurrentLib(), LIB_EDIT_FRAME::LoadOneSymbol(), SCH_EDIT_FRAME::LoadSheetFromFile(), KICAD_MANAGER_CONTROL::NewFromTemplate(), KICAD_MANAGER_CONTROL::NewProject(), DIALOG_EXPORT_STEP::onExportButton(), PCB_EDIT_FRAME::OnExportSTEP(), CV::IFACE::OnKifaceStart(), SCH::IFACE::OnKifaceStart(), PCB::IFACE::OnKifaceStart(), PANEL_SETUP_NETCLASSES::OnRemoveNetclassClick(), DIALOG_CONFIGURE_PATHS::OnUpdateUI(), PAGED_DIALOG::OnUpdateUI(), SCH_EDIT_FRAME::OpenProjectFiles(), PCB_EDIT_FRAME::OpenProjectFiles(), PROJECT::PcbFootprintLibs(), FOOTPRINT_EDIT_FRAME::SaveFootprintToBoard(), LIB_EDIT_FRAME::saveLibrary(), LIB_EDIT_FRAME::SaveOneSymbol(), KICAD_MANAGER_CONTROL::SaveProjectAs(), DIALOG_BOARD_STATISTICS::saveReportClicked(), SchGetLibAlias(), LIB_VIEW_FRAME::ShowModal(), FOOTPRINT_VIEWER_FRAME::ShowModal(), DIALOG_PNS_DIFF_PAIR_DIMENSIONS::TransferDataFromWindow(), LIB_EDIT_FRAME::UpdateAfterSymbolProperties(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::Validate(), and SYMBOL_LIB_TABLE_RESCUER::WriteRescueLibrary().

◆ DisplayInfoMessage()

void DisplayInfoMessage ( wxWindow *  parent,
const wxString &  aMessage,
const wxString &  aExtraInfo = wxEmptyString 
)

Display an informational message box with aMessage.

Parameters
aParentis the parent window
aMessageis the message text to display
aExtraInfois the extra data that can be optionally displayed in a collapsible pane

Definition at line 265 of file confirm.cpp.

266 {
267  wxRichMessageDialog* dlg;
268  int icon = wxICON_INFORMATION;
269 
270  dlg = new wxRichMessageDialog( aParent, aMessage, _( "Info" ),
271  wxOK | wxCENTRE | wxRESIZE_BORDER | icon | wxSTAY_ON_TOP );
272 
273  if( !aExtraInfo.IsEmpty() )
274  dlg->ShowDetailedText( aExtraInfo );
275 
276  dlg->ShowModal();
277  dlg->Destroy();
278 }
#define _(s)

References _.

Referenced by PCB_EDIT_FRAME::ArchiveModulesOnBoard(), DIALOG_EDIT_COMPONENT_IN_LIBRARY::checkAliasName(), SCH_EDIT_FRAME::checkForNoFullyDefinedLibIds(), EE_INSPECTION_TOOL::checkPart(), SCH_EDIT_TOOL::CleanupSheetPins(), PCB_BASE_FRAME::CreateNewModule(), FOOTPRINT_EDIT_FRAME::DeleteModuleFromLibrary(), DIALOG_SYMBOL_REMAP::DIALOG_SYMBOL_REMAP(), FOOTPRINT_EDIT_FRAME::Export_Module(), GERBVIEW_FRAME::ExportDataInPcbnewFormat(), PCB_EDIT_FRAME::Files_io_from_id(), DISPLAY_FOOTPRINTS_FRAME::Get_Module(), PGM_BASE::GetEditorName(), DIALOG_PRINT_GENERIC::getScaleValue(), SIM_PLOT_FRAME::onAddSignal(), CV::IFACE::OnKifaceStart(), EDA_DRAW_PANEL_GAL::onPaint(), DIALOG_NETLIST::OnTestFootprintsClick(), SCH_EDIT_FRAME::OpenProjectFiles(), PCB_EDIT_FRAME::OpenProjectFiles(), DIALOG_PLOT::Plot(), FOOTPRINT_EDIT_FRAME::SaveFootprint(), FOOTPRINT_EDIT_FRAME::SaveFootprintAs(), FOOTPRINT_EDIT_FRAME::SaveLibraryAs(), PCB_EDIT_FRAME::SavePcbCopy(), ROUTER_TOOL::SelectCopperLayerPair(), SIM_PLOT_FRAME::StartSimulation(), and EDA_DRAW_PANEL_GAL::SwitchBackend().

◆ HandleUnsavedChanges()

bool HandleUnsavedChanges ( wxWindow *  aParent,
const wxString &  aMessage,
const std::function< bool()> &  aSaveFunction 
)

Display a dialog with Save, Cancel and Discard Changes buttons.

Parameters
aParent= the parent window
aMessage= the main message to put in dialog
aSaveFunction= a function to save changes, if requested. Must return true if the save was successful and false otherwise (which will result in HandleUnsavedChanges() returning wxID_CANCEL).
Returns
wxID_YES, wxID_CANCEL, wxID_NO.

Definition at line 201 of file confirm.cpp.

203 {
204  switch( UnsavedChangesDialog( aParent, aMessage ) )
205  {
206  case wxID_YES: return aSaveFunction();
207  case wxID_NO: return true;
208  default:
209  case wxID_CANCEL: return false;
210  }
211 }
int UnsavedChangesDialog(wxWindow *parent, wxString aMessage, bool *aApplyToAll)
A specialized version of HandleUnsavedChanges which handles an apply-to-all checkbox.
Definition: confirm.cpp:148

References UnsavedChangesDialog().

Referenced by SCH_EDIT_FRAME::AskToSaveChanges(), FOOTPRINT_EDIT_FRAME::Clear_Pcb(), PL_EDITOR_FRAME::Files_io(), LIB_EDIT_FRAME::LoadComponentAndSelectLib(), DIALOG_LIB_EDIT_PIN_TABLE::OnClose(), DIALOG_FIELDS_EDITOR_GLOBAL::OnClose(), FOOTPRINT_EDIT_FRAME::OnCloseWindow(), PL_EDITOR_FRAME::OnCloseWindow(), CVPCB_MAINFRAME::OnCloseWindow(), SCH_EDIT_FRAME::OnCloseWindow(), PCB_EDIT_FRAME::OnCloseWindow(), PL_EDITOR_FRAME::OnFileHistory(), PCB_EDIT_FRAME::OpenProjectFiles(), and FOOTPRINT_EDIT_FRAME::Process_Special_Functions().

◆ IsOK()

bool IsOK ( wxWindow *  aParent,
const wxString &  aMessage 
)

Display a yes/no dialog with aMessage and returns the user response.

Parameters
aParentis the parent window. NULL can be used if the parent is the top level window.
aMessageis the message to display in the dialog box.
Returns
True if user selected the yes button, otherwise false.

Definition at line 281 of file confirm.cpp.

282 {
283  wxMessageDialog dlg( aParent, aMessage, _( "Confirmation" ),
284  wxYES_NO | wxCENTRE | wxICON_QUESTION | wxSTAY_ON_TOP );
285  dlg.SetEscapeId( wxID_NO );
286 
287  return dlg.ShowModal() == wxID_YES;
288 }
#define _(s)

References _.

Referenced by DIALOG_GLOBAL_DELETION::AcceptPcbDelete(), SELECTION_TOOL::CheckLock(), DIALOG_IMAGE_EDITOR::CheckValues(), SCH_EDIT_TOOL::CleanupSheetPins(), GERBVIEW_FRAME::Clear_DrawLayers(), PCB_EDIT_FRAME::Clear_Pcb(), CVPCB_ASSOCIATION_TOOL::DeleteAll(), FOOTPRINT_EDIT_FRAME::DeleteModuleFromLibrary(), LIB_EDIT_FRAME::DeletePartFromLibrary(), SCH_EDIT_FRAME::EditSheet(), GERBVIEW_FRAME::Erase_Current_DrawLayer(), PCB_EDIT_FRAME::Files_io_from_id(), PGM_BASE::InitPgm(), SCH_EDIT_FRAME::LoadSheetFromFile(), KICAD_MANAGER_CONTROL::NewProject(), SCH_EDIT_FRAME::OnAppendProject(), DIALOG_NETLIST::OnUpdatePCB(), DIALOG_PAGES_SETTINGS::OnWksFileSelection(), SCH_EDIT_FRAME::OpenProjectFiles(), PCB_EDIT_FRAME::OpenProjectFiles(), SCH_EDIT_FRAME::prepareForNetlist(), CVPCB_MAINFRAME::ReadNetListAndFpFiles(), DIALOG_LIB_EDIT_PIN::TransferDataFromWindow(), PANEL_SETUP_LAYERS::TransferDataFromWindow(), and DIALOG_EDIT_COMPONENT_IN_LIBRARY::Validate().

◆ OKOrCancelDialog()

int OKOrCancelDialog ( wxWindow *  aParent,
const wxString &  aWarning,
const wxString &  aMessage,
const wxString &  aOKLabel,
const wxString &  aCancelLabel,
bool *  aApplyToAll 
)

Displays a warning dialog with aMessage and returns the user response.

Parameters
aParentis the parent window. NULL can be used if the parent is the top level window.
aWarningis the warning to display in the top part of the dialog box using a bold font.
aMessageis the message to display in the lower part of the dialog box using the default system UI font.
aOKLabelis the text to display in the OK button.
aCancelLabelis the text to display in the cancel button.
Returns
wxID_OK or wxID_CANCEL depending on the button the user selected.

Definition at line 214 of file confirm.cpp.

216 {
217  wxRichMessageDialog dlg( aParent, aMessage, wxEmptyString,
218  wxOK | wxCANCEL | wxOK_DEFAULT | wxICON_WARNING | wxCENTER );
219  dlg.ShowDetailedText( _( "If you don't save, all your changes will be permanently lost." ) );
220  dlg.SetOKCancelLabels( aOKLabel, aCancelLabel );
221 
222  if( aApplyToAll )
223  dlg.ShowCheckBox( _( "Apply to all" ), true );
224 
225  int ret = dlg.ShowModal();
226 
227  if( aApplyToAll )
228  *aApplyToAll = dlg.IsCheckBoxChecked();
229 
230  // Returns wxID_OK or wxID_CANCEL
231  return ret;
232 }
#define _(s)

References _.

Referenced by PANEL_SYM_LIB_TABLE::browseLibrariesHandler(), and PANEL_FP_LIB_TABLE::browseLibrariesHandler().

◆ SelectSingleOption()

int SelectSingleOption ( wxWindow *  aParent,
const wxString &  aTitle,
const wxString &  aMessage,
const wxArrayString &  aOptions 
)

Displays a dialog with radioboxes asking the user to select an option.

Parameters
aParentis the parent window.
aTitleis the dialog title.
aMessageis a text label displayed in the first row of the dialog.
aOptionsis a vector of possible options.
Returns
Index of the selected option or -1 when the dialog has been canceled.

Definition at line 291 of file confirm.cpp.

293 {
294  wxSingleChoiceDialog dlg( aParent, aMessage, aTitle, aOptions );
295 
296  if( dlg.ShowModal() != wxID_OK )
297  return -1;
298 
299  return dlg.GetSelection();
300 }

Referenced by PCB_BASE_EDIT_FRAME::AddLibrary().

◆ UnsavedChangesDialog() [1/2]

int UnsavedChangesDialog ( wxWindow *  aParent,
wxString  aMessage,
bool *  aApplyToAll 
)

A specialized version of HandleUnsavedChanges which handles an apply-to-all checkbox.

Parameters
aParent= the parent window
aMessage= the main message to put in dialog
aApplyToAll= if non-null an "Apply to all" checkbox will be shown and it's value written back to the bool.
Returns
wxID_YES, wxID_CANCEL, wxID_NO.

Definition at line 148 of file confirm.cpp.

149 {
150  static bool s_apply_to_all = false;
151 
152  wxRichMessageDialog dlg( parent, aMessage, wxEmptyString,
153  wxYES_NO | wxCANCEL | wxYES_DEFAULT | wxICON_WARNING | wxCENTER );
154  dlg.SetExtendedMessage( _( "If you don't save, all your changes will be permanently lost." ) );
155  dlg.SetYesNoLabels( _( "Save" ), _( "Discard Changes" ) );
156 
157  if( aApplyToAll )
158  dlg.ShowCheckBox( _( "Apply to all" ), s_apply_to_all );
159 
160  int ret = dlg.ShowModal();
161 
162  if( aApplyToAll )
163  {
164  *aApplyToAll = dlg.IsCheckBoxChecked();
165  s_apply_to_all = dlg.IsCheckBoxChecked();
166  }
167 
168  // Returns wxID_YES, wxID_NO, or wxID_CANCEL
169  return ret;
170 }
#define _(s)

References _.

Referenced by HandleUnsavedChanges(), InvokeSchEditSymbolLibTable(), LIB_EDIT_FRAME::saveAllLibraries(), and UnsavedChangesDialog().

◆ UnsavedChangesDialog() [2/2]

int UnsavedChangesDialog ( wxWindow *  parent,
const wxString &  aMessage 
)

Definition at line 173 of file confirm.cpp.

174 {
175 #ifdef __APPLE__
176  // wxWidgets gets the button order wrong on Mac so use the other dialog.
177  return UnsavedChangesDialog( parent, aMessage, nullptr );
178 #else
179  wxMessageDialog dlg( parent, aMessage, wxEmptyString,
180  wxYES_NO | wxCANCEL | wxYES_DEFAULT | wxICON_WARNING | wxCENTER );
181  dlg.SetExtendedMessage( _( "If you don't save, all your changes will be permanently lost." ) );
182  dlg.SetYesNoLabels( _( "Save" ), _( "Discard Changes" ) );
183 
184  // Returns wxID_YES, wxID_NO, or wxID_CANCEL
185  return dlg.ShowModal();
186 #endif
187 }
int UnsavedChangesDialog(wxWindow *parent, wxString aMessage, bool *aApplyToAll)
A specialized version of HandleUnsavedChanges which handles an apply-to-all checkbox.
Definition: confirm.cpp:148
#define _(s)

References _, and UnsavedChangesDialog().

Variable Documentation

◆ doNotShowAgainDlgs

std::unordered_map<unsigned long, int> doNotShowAgainDlgs
static