KiCad PCB EDA Suite
confirm.cpp File Reference
#include <wx/app.h>
#include <wx/stockitem.h>
#include <wx/richmsgdlg.h>
#include <wx/choicdlg.h>
#include <wx/crt.h>
#include <confirm.h>
#include <dialogs/html_message_box.h>
#include <functional>
#include <unordered_map>
#include "cli/cli_names.h"

Go to the source code of this file.

Functions

bool IsGUI ()
 Determine if the application is running with a GUI. More...
 
bool OverrideLock (wxWindow *aParent, const wxString &aMessage)
 Display a dialog indicating the file is already open, with an option to reset the lock. More...
 
int UnsavedChangesDialog (wxWindow *parent, const 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 &aDetailedMessage, const wxString &aOKLabel, const wxString &aCancelLabel, bool *aApplyToAll)
 Display 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)
 Display 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 249 of file confirm.cpp.

250{
251 wxMessageDialog dlg( parent, aMessage, wxEmptyString,
252 wxOK | wxCANCEL | wxOK_DEFAULT | wxICON_WARNING | wxCENTER );
253 dlg.SetExtendedMessage( _( "Your current changes will be permanently lost." ) );
254 dlg.SetOKCancelLabels( _( "Revert" ), _( "Cancel" ) );
255
256 return dlg.ShowModal() == wxID_OK;
257}
#define _(s)

References _.

Referenced by SYMBOL_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 300 of file confirm.cpp.

301{
302 if( !wxTheApp || !wxTheApp->IsMainLoopRunning() )
303 {
304 wxLogError( "%s", aText );
305 return;
306 }
307
308 if( !IsGUI() )
309 {
310 wxFprintf( stderr, aText );
311 return;
312 }
313
314 wxMessageDialog* dlg;
315 int icon = aDisplayTime > 0 ? wxICON_INFORMATION : wxICON_ERROR;
316
317 dlg = new wxMessageDialog( aParent, aText, _( "Warning" ),
318 wxOK | wxCENTRE | wxRESIZE_BORDER | icon | wxSTAY_ON_TOP );
319
320 dlg->ShowModal();
321 dlg->Destroy();
322}
bool IsGUI()
Determine if the application is running with a GUI.
Definition: confirm.cpp:40

References _, and IsGUI().

Referenced by DIALOG_COPPER_ZONE::AcceptOptions(), FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB(), PCB_BASE_EDIT_FRAME::AddLibrary(), SYMBOL_EDIT_FRAME::AddLibraryFile(), PCB_CONTROL::AppendBoard(), SYMBOL_EDIT_FRAME::backupFile(), SCH_EDIT_FRAME::CheckSheetForRecursion(), FOOTPRINT_VIEWER_FRAME::ClickOnFootprintList(), SCH_EDIT_FRAME::ConvertPart(), DIALOG_GEN_FOOTPRINT_POSITION::CreateAsciiFiles(), MICROWAVE_TOOL::createFootprint(), DIALOG_GEN_FOOTPRINT_POSITION::CreateGerberFiles(), SIMULATOR::CreateInstance(), PCB_BASE_EDIT_FRAME::createNewLibrary(), SYMBOL_EDIT_FRAME::DdAddLibrary(), UNIT_BINDER::delayedFocusHandler(), FOOTPRINT_EDIT_FRAME::DeleteFootprintFromLibrary(), PANEL_SETUP_LAYERS::DenyChangeCheckBox(), FIELDS_EDITOR_GRID_TRICKS::doPopupSelection(), DIALOG_SIM_COMMAND::evaluateDCControls(), ExecuteFile(), FOOTPRINT_EDIT_FRAME::ExportFootprint(), PCB_EDIT_FRAME::ExportFootprintsToLibrary(), GBR_TO_PCB_EXPORTER::ExportPcb(), DIALOG_EXPORT_SVG::ExportSVGFile(), SYMBOL_EDIT_FRAME::ExportSymbol(), SCH_EDITOR_CONTROL::ExportSymbolsToLibrary(), PCB_EDIT_FRAME::ExportToGenCAD(), DIALOG_GENDRILL::GenDrillAndMapFiles(), PCB_EDIT_FRAME::GenFootprintsReport(), GetAssociatedDocument(), DISPLAY_FOOTPRINTS_FRAME::GetFootprint(), FOOTPRINT_EDIT_FRAME::ImportFootprint(), SCH_EDITOR_CONTROL::ImportFPAssignments(), SYMBOL_EDIT_FRAME::ImportSymbol(), DIALOG_PRINT_GENERIC::initPrintData(), SYMBOL_EDIT_FRAME::LoadSymbol(), SCH_EDIT_FRAME::NewProject(), DIALOG_SYMBOL_FIELDS_TABLE::OnAddField(), DIALOG_CONFIG_EQUFILES::OnAddFiles(), DIALOG_BOM::OnAddGenerator(), DIALOG_NET_INSPECTOR::onAddNet(), DIALOG_SYMBOL_FIELDS_TABLE::OnColumnItemToggled(), DIALOG_FOOTPRINT_PROPERTIES::OnDeleteField(), DIALOG_LABEL_PROPERTIES::OnDeleteField(), DIALOG_LIB_SYMBOL_PROPERTIES::OnDeleteField(), DIALOG_SHEET_PROPERTIES::OnDeleteField(), DIALOG_SYMBOL_PROPERTIES::OnDeleteField(), DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::OnDeleteField(), PANEL_FP_EDITOR_DEFAULTS::OnDeleteTextItem(), DIALOG_LIB_SYMBOL_PROPERTIES::OnGridCellChanging(), DIALOG_SYMBOL_PROPERTIES::OnGridCellChanging(), SCH_EDIT_FRAME::OnOpenCvpcb(), DIALOG_PRINT_GENERIC::onPrintButtonClick(), DIALOG_PRINT_GENERIC::onPrintPreview(), DIALOG_NET_INSPECTOR::onRenameNet(), DIALOG_ERC::OnSaveReport(), DIALOG_DRC::OnSaveReport(), DIALOG_SHEET_PROPERTIES::onSheetFilenameChanged(), PCB_DRAW_PANEL_GAL::OnShow(), SCH_EDIT_FRAME::OnUpdatePCB(), DIALOG_FOOTPRINT_PROPERTIES::OnUpdateUI(), DIALOG_LIB_SYMBOL_PROPERTIES::OnUpdateUI(), DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::OnUpdateUI(), OpenPDF(), SCH_EDIT_FRAME::OpenProjectFiles(), PCB_EDIT_FRAME::OpenProjectFiles(), SCH_EDITOR_CONTROL::Paste(), SYMBOL_GRID_TRICKS::paste_text(), FP_GRID_TRICKS::paste_text(), DIALOG_PLOT::Plot(), PCB_CONTROL::pruneItemLayers(), MWAVE_POLYGONAL_SHAPE_DLG::ReadDataShapeDescr(), PCB_EDIT_FRAME::RecreateBOMFileFromBoard(), PCB_EDIT_FRAME::RecreateCmpFileFromBoard(), FOOTPRINT_EDITOR_CONTROL::RenameFootprint(), KIGFX::VERTEX_MANAGER::Reserve(), FOOTPRINT_EDIT_FRAME::SaveFootprintAs(), FOOTPRINT_EDIT_FRAME::SaveFootprintInLibrary(), FOOTPRINT_EDIT_FRAME::SaveFootprintToBoard(), FOOTPRINT_EDIT_FRAME::SaveLibraryAs(), PCB_EDIT_FRAME::SavePcbCopy(), PCB_EDIT_FRAME::SavePcbFile(), SCH_EDIT_FRAME::saveSchematicFile(), SYMBOL_EDIT_FRAME::saveSymbolAs(), KIGFX::GPU_MANAGER::SetShader(), EDA_DRAW_PANEL_GAL::SwitchBackend(), PCB_EDIT_FRAME::TestStandalone(), DIALOG_EDIT_SYMBOLS_LIBID::TransferDataFromWindow(), DIALOG_FIELD_PROPERTIES::TransferDataFromWindow(), DIALOG_GLOBAL_SYM_LIB_TABLE_CONFIG::TransferDataFromWindow(), DIALOG_LABEL_PROPERTIES::TransferDataFromWindow(), DIALOG_LIB_TEXT_PROPERTIES::TransferDataFromWindow(), DIALOG_PRINT_USING_PRINTER::TransferDataFromWindow(), DIALOG_SCH_IMPORT_SETTINGS::TransferDataFromWindow(), DIALOG_SHEET_PROPERTIES::TransferDataFromWindow(), DIALOG_SIM_COMMAND::TransferDataFromWindow(), DIALOG_TEXT_PROPERTIES::TransferDataFromWindow(), DIALOG_GLOBAL_FP_LIB_TABLE_CONFIG::TransferDataFromWindow(), DIALOG_IMPORT_SETTINGS::TransferDataFromWindow(), DIALOG_NON_COPPER_ZONES_EDITOR::TransferDataFromWindow(), DIALOG_PAD_PRIMITIVES_PROPERTIES::TransferDataFromWindow(), DIALOG_RULE_AREA_PROPERTIES::TransferDataFromWindow(), DIALOG_TEXTBOX_PROPERTIES::TransferDataFromWindow(), DIALOG_TRACK_VIA_PROPERTIES::TransferDataFromWindow(), DIALOG_TRACK_VIA_SIZE::TransferDataFromWindow(), SPICE_VALIDATOR::Validate(), REGEX_VALIDATOR::Validate(), KIGFX::VERTEX_MANAGER::Vertex(), KIGFX::VERTEX_MANAGER::Vertices(), 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 325 of file confirm.cpp.

326{
327 if( !wxTheApp || !wxTheApp->IsMainLoopRunning() )
328 {
329 wxLogError( "%s %s", aText, aExtraInfo );
330 return;
331 }
332
333 if( !IsGUI() )
334 {
335 wxFprintf( stderr, aText );
336 return;
337 }
338
339 wxMessageDialog* dlg;
340
341 dlg = new wxMessageDialog( aParent, aText, _( "Error" ),
342 wxOK | wxCENTRE | wxRESIZE_BORDER | wxICON_ERROR | wxSTAY_ON_TOP );
343
344 if( !aExtraInfo.IsEmpty() )
345 dlg->SetExtendedMessage( aExtraInfo );
346
347 dlg->ShowModal();
348 dlg->Destroy();
349}

References _, and IsGUI().

Referenced by FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB(), FILENAME_RESOLVER::addPath(), SYMBOL_EDITOR_CONTROL::AddSymbolToSchematic(), SIM_PLOT_FRAME::AddTuner(), PANEL_SETUP_LAYERS::addUserDefinedLayer(), SIM_PLOT_FRAME::applyTuners(), CVPCB_ASSOCIATION_TOOL::Associate(), CVPCB_MAINFRAME::AssociateFootprint(), PANEL_FP_LIB_TABLE::browseLibrariesHandler(), checkGlError(), SIM_MODEL::Create(), SCH_EDIT_FRAME::CreateArchiveLibrary(), PROJECT_TREE_ITEM::Delete(), WIDGET_HOTKEY_LIST::editItem(), FOOTPRINT_EDIT_FRAME::ExportFootprint(), PCB_EDIT_FRAME::ExportSpecctraFile(), SYMBOL_EDIT_FRAME::ExportSymbol(), BACK_ANNOTATE::FetchNetlistFromPCB(), PCB_EDIT_FRAME::FetchNetlistFromSchematic(), PL_EDITOR_FRAME::Files_io(), EDA_BASE_FRAME::GetFileFromHistory(), SCH_EDIT_FRAME::importFile(), PCB_EDIT_FRAME::ImportSpecctraSession(), SYMBOL_EDIT_FRAME::ImportSymbol(), PGM_BASE::InitPgm(), EDA_BASE_FRAME::IsWritable(), SYMBOL_EDIT_FRAME::KiwayMailIn(), FOOTPRINT_EDIT_FRAME::KiwayMailIn(), DIALOG_SIM_MODEL< T_symbol, T_field >::loadLibrary(), SCH_EDIT_FRAME::LoadSheetFromFile(), SYMBOL_EDIT_FRAME::LoadSymbol(), SYMBOL_EDIT_FRAME::LoadSymbolFromCurrentLib(), mergeZones(), SETTINGS_MANAGER::MigrateIfNeeded(), KICAD_MANAGER_CONTROL::NewFromTemplate(), KICAD_MANAGER_CONTROL::NewProject(), DIALOG_SCHEMATIC_SETUP::onAuxiliaryAction(), DIALOG_BOARD_SETUP::onAuxiliaryAction(), PANEL_SYM_LIB_TABLE::onConvertLegacyLibraries(), DIALOG_EXPORT_STEP::onExportButton(), PCB_EDIT_FRAME::OnExportSTEP(), PCB_EDIT_FRAME::OnExportVRML(), CV::IFACE::OnKifaceStart(), SCH::IFACE::OnKifaceStart(), PCB::IFACE::OnKifaceStart(), PANEL_SETUP_NETCLASSES::OnRemoveNetclassClick(), FOOTPRINT_EDIT_FRAME::OnSaveFootprintAsPng(), SIM_PLOT_FRAME::onSettings(), DIALOG_SHEET_PROPERTIES::onSheetFilenameChanged(), SIM_PLOT_FRAME::onSimUpdate(), PANEL_SETUP_BUSES::OnUpdateUI(), DIALOG_CONFIGURE_PATHS::OnUpdateUI(), PANEL_TEXT_VARIABLES::OnUpdateUI(), SCH_EDIT_FRAME::OpenProjectFiles(), PCB_EDIT_FRAME::OpenProjectFiles(), PROJECT::PcbFootprintLibs(), KIWAY::Player(), EDA_DRAW_FRAME::PrintPage(), NETLIST_EXPORTER_SPICE::readModel(), PCB_EDIT_FRAME::ReadNetlistFromFile(), FOOTPRINT_EDITOR_CONTROL::RenameFootprint(), SYMBOL_EDITOR_CONTROL::RenameSymbol(), PCB_EDIT_FRAME::RunEeschema(), SYMBOL_EDIT_FRAME::Save(), SYMBOL_EDIT_FRAME::saveCurrentSymbol(), SYMBOL_EDIT_FRAME::saveLibrary(), KICAD_MANAGER_CONTROL::SaveProjectAs(), DIALOG_BOARD_STATISTICS::saveReportClicked(), SCH_BASE_FRAME::saveSymbolLibTables(), SchGetLibSymbol(), KIWAY::SetLanguage(), FOOTPRINT_VIEWER_FRAME::ShowModal(), SYMBOL_VIEWER_FRAME::ShowModal(), SIM_PLOT_FRAME::StartSimulation(), DIALOG_LIB_SYMBOL_PROPERTIES::TransferDataFromWindow(), DIALOG_PIN_PROPERTIES::TransferDataFromWindow(), DIALOG_PNS_DIFF_PAIR_DIMENSIONS::TransferDataFromWindow(), DIALOG_SIM_MODEL< T_symbol, T_field >::TransferDataToWindow(), SYMBOL_EDIT_FRAME::UpdateAfterSymbolProperties(), BOARD_EDITOR_CONTROL::UpdateSchematicFromPCB(), SIM_PLOT_FRAME::UpdateTunerValue(), DIALOG_SHEET_PROPERTIES::Validate(), DIALOG_SYMBOL_PROPERTIES::Validate(), IPC356D_WRITER::Write(), NETLIST_EXPORTER_SPICE::writeInclude(), 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 352 of file confirm.cpp.

353{
354 if( !wxTheApp || !wxTheApp->GetTopWindow() )
355 {
356 wxLogDebug( "%s %s", aMessage, aExtraInfo );
357 return;
358 }
359
360 if( !IsGUI() )
361 {
362 wxFprintf( stdout, "%s %s", aMessage, aExtraInfo );
363 return;
364 }
365
366 wxMessageDialog* dlg;
367 int icon = wxICON_INFORMATION;
368
369 dlg = new wxMessageDialog( aParent, aMessage, _( "Information" ),
370 wxOK | wxCENTRE | wxRESIZE_BORDER | icon | wxSTAY_ON_TOP );
371
372 if( !aExtraInfo.IsEmpty() )
373 dlg->SetExtendedMessage( aExtraInfo );
374
375 dlg->ShowModal();
376 dlg->Destroy();
377}

References _, and IsGUI().

Referenced by SCH_EDIT_FRAME::checkForNoFullyDefinedLibIds(), EE_INSPECTION_TOOL::CheckSymbol(), PCB_BASE_FRAME::CreateNewFootprint(), FOOTPRINT_EDIT_FRAME::DeleteFootprintFromLibrary(), DIALOG_SYMBOL_REMAP::DIALOG_SYMBOL_REMAP(), EDA_DRAW_PANEL_GAL::DoRePaint(), FOOTPRINT_EDIT_FRAME::DuplicateFootprint(), FOOTPRINT_EDIT_FRAME::ExportFootprint(), PCB_EDIT_FRAME::ExportFootprintsToLibrary(), GERBVIEW_CONTROL::ExportToPcbnew(), PCB_EDIT_FRAME::Files_io_from_id(), DIALOG_PRINT_GENERIC::getScaleValue(), PGM_BASE::GetTextEditor(), PCB_EDIT_FRAME::inferLegacyEdgeClearance(), SIM_PLOT_FRAME::onAddSignal(), CV::IFACE::OnKifaceStart(), SCH_DRAW_PANEL::OnShow(), SCH_EDIT_FRAME::OpenProjectFiles(), DIALOG_PLOT::Plot(), BOARD_EDITOR_CONTROL::RepairBoard(), FOOTPRINT_EDITOR_CONTROL::RepairFootprint(), SCH_EDITOR_CONTROL::RepairSchematic(), FOOTPRINT_EDIT_FRAME::SaveFootprint(), FOOTPRINT_EDIT_FRAME::SaveFootprintAs(), FOOTPRINT_EDIT_FRAME::SaveLibraryAs(), PCB_EDIT_FRAME::SavePcbCopy(), ROUTER_TOOL::SelectCopperLayerPair(), KICAD_MANAGER_CONTROL::ShowPlayer(), EDA_DRAW_PANEL_GAL::SwitchBackend(), DIALOG_LABEL_PROPERTIES::TransferDataFromWindow(), and DIALOG_SCH_FIELD_PROPERTIES::UpdateField().

◆ 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 260 of file confirm.cpp.

262{
263 switch( UnsavedChangesDialog( aParent, aMessage ) )
264 {
265 case wxID_YES: return aSaveFunction();
266 case wxID_NO: return true;
267 default:
268 case wxID_CANCEL: return false;
269 }
270}
int UnsavedChangesDialog(wxWindow *parent, const wxString &aMessage, bool *aApplyToAll)
A specialized version of HandleUnsavedChanges which handles an apply-to-all checkbox.
Definition: confirm.cpp:197

References UnsavedChangesDialog().

Referenced by SCH_EDIT_FRAME::AskToSaveChanges(), FOOTPRINT_EDIT_FRAME::CanCloseFPFromBoard(), CVPCB_MAINFRAME::canCloseWindow(), SCH_EDIT_FRAME::canCloseWindow(), PL_EDITOR_FRAME::canCloseWindow(), PCB_EDIT_FRAME::canCloseWindow(), SIM_PLOT_FRAME::canCloseWindow(), FOOTPRINT_EDIT_FRAME::canCloseWindow(), FOOTPRINT_EDIT_FRAME::Clear_Pcb(), FOOTPRINT_EDITOR_CONTROL::CreateFootprint(), PL_EDITOR_FRAME::Files_io(), PCB_EDIT_FRAME::Files_io_from_id(), SYMBOL_EDIT_FRAME::LoadSymbol(), DIALOG_SYMBOL_FIELDS_TABLE::OnClose(), DIALOG_LIB_EDIT_PIN_TABLE::OnClose(), PL_EDITOR_FRAME::OnFileHistory(), and PCB_EDIT_FRAME::OpenProjectFiles().

◆ IsGUI()

bool IsGUI ( )

Determine if the application is running with a GUI.

Returns
true if there is a GUI and false otherwise

Definition at line 40 of file confirm.cpp.

41{
42 if( !wxTheApp )
43 return false;
44
45#if wxCHECK_VERSION( 3, 1, 6 )
46 return wxTheApp->IsGUI();
47#else
48 // wxWidgets older than version 3.1.6 do not have a way to know if the app
49 // has a GUI or is a console application.
50 // So the trick is to set the App class name when starting kicad-cli, and when
51 // the app class name is the kicad-cli class name the app is a console app
52 bool run_gui = wxTheApp->GetClassName() != KICAD_CLI_APP_NAME;
53 return run_gui;
54#endif
55}
#define KICAD_CLI_APP_NAME
Definition: cli_names.h:23

References KICAD_CLI_APP_NAME.

Referenced by EDA_BASE_FRAME::CheckForAutoSaveFile(), SCH_EDIT_FRAME::CheckForAutoSaveFile(), DisplayError(), DisplayErrorMessage(), DisplayInfoMessage(), and PCB_PLUGIN::FootprintSave().

◆ 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 380 of file confirm.cpp.

381{
382 // wxMessageDialog no longer responds correctly to the <ESC> key (on at least OSX and MSW)
383 // so we're now using wxRichMessageDialog.
384 //
385 // Note also that we have to repurpose an OK/Cancel version of it because otherwise wxWidgets
386 // uses "destructive" spacing for the "No" button.
387
388#ifdef __APPLE__
389 // Why is wxICON_QUESTION a light-bulb on Mac? That has more of a hint or info connotation.
390 int icon = wxICON_WARNING;
391#else
392 int icon = wxICON_QUESTION;
393#endif
394
395#if !defined( __WXGTK__ )
396 wxRichMessageDialog dlg( aParent, aMessage, _( "Confirmation" ),
397 wxOK | wxCANCEL | wxOK_DEFAULT | wxCENTRE | icon | wxSTAY_ON_TOP );
398#else
399 wxMessageDialog dlg( aParent, aMessage, _( "Confirmation" ),
400 wxOK | wxCANCEL | wxOK_DEFAULT | wxCENTRE | icon | wxSTAY_ON_TOP );
401#endif
402
403 dlg.SetOKCancelLabels( _( "Yes" ), _( "No" ) );
404
405 return dlg.ShowModal() == wxID_OK;
406}

References _.

Referenced by PANEL_IMAGE_EDITOR::CheckValues(), SCH_EDIT_TOOL::CleanupSheetPins(), GERBVIEW_FRAME::Clear_DrawLayers(), PCB_EDIT_FRAME::Clear_Pcb(), CVPCB_ASSOCIATION_TOOL::DeleteAll(), FOOTPRINT_EDIT_FRAME::DeleteFootprintFromLibrary(), SYMBOL_EDIT_FRAME::DeleteSymbolFromLibrary(), DIALOG_GLOBAL_DELETION::DoGlobalDeletions(), GERBVIEW_FRAME::Erase_Current_DrawLayer(), PCB_EDIT_FRAME::ExportFootprintsToLibrary(), SCH_EDITOR_CONTROL::ExportSymbolsToLibrary(), PCB_EDIT_FRAME::Files_io_from_id(), KICAD_MANAGER_CONTROL::NewProject(), SCH_EDIT_FRAME::OnAppendProject(), DIALOG_BOARD_REANNOTATE::OnApplyClick(), PANEL_SETUP_RULES::onCharHook(), PANEL_SYM_LIB_TABLE::onConvertLegacyLibraries(), DIALOG_NET_INSPECTOR::onDeleteNet(), DIALOG_SYMBOL_FIELDS_TABLE::OnRemoveField(), DIALOG_SHEET_PROPERTIES::onSheetFilenameChanged(), SCH_EDIT_FRAME::OpenProjectFiles(), PCB_EDIT_FRAME::OpenProjectFiles(), CVPCB_MAINFRAME::readNetListAndFpFiles(), SCH_EDIT_FRAME::ReadyToNetlist(), DIALOG_BOARD_REANNOTATE::ReannotateBoard(), SCH_EDITOR_CONTROL::Revert(), SIM_PLOT_FRAME::StartSimulation(), DIALOG_PIN_PROPERTIES::TransferDataFromWindow(), PANEL_SETUP_LAYERS::TransferDataFromWindow(), and DIALOG_LIB_SYMBOL_PROPERTIES::Validate().

◆ OKOrCancelDialog()

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

Display 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.
aDetailedMessageis the message to display in the "Show detailed information" section. Passing wxEmptyString will hide this portion of the dialog.
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 273 of file confirm.cpp.

276{
277 wxRichMessageDialog dlg( aParent, aMessage, aWarning,
278 wxOK | wxCANCEL | wxOK_DEFAULT | wxICON_WARNING | wxCENTER );
279
280 dlg.SetOKCancelLabels( ( aOKLabel.IsEmpty() ) ? _( "OK" ) : aOKLabel,
281 ( aCancelLabel.IsEmpty() ) ? _( "Cancel" ) : aCancelLabel );
282
283 if( !aDetailedMessage.IsEmpty() )
284 dlg.SetExtendedMessage( aDetailedMessage );
285
286 if( aApplyToAll )
287 dlg.ShowCheckBox( _( "Apply to all" ), true );
288
289 int ret = dlg.ShowModal();
290
291 if( aApplyToAll )
292 *aApplyToAll = dlg.IsCheckBoxChecked();
293
294 // Returns wxID_OK or wxID_CANCEL
295 return ret;
296}

References _.

Referenced by PANEL_FP_LIB_TABLE::browseLibrariesHandler(), PANEL_SYM_LIB_TABLE::browseLibrariesHandler(), DIALOG_SYMBOL_FIELDS_TABLE::OnExport(), SYMBOL_EDIT_FRAME::Save(), SYMBOL_EDIT_FRAME::saveAllLibraries(), and ROUTER_TOOL::saveRouterDebugLog().

◆ OverrideLock()

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

Display a dialog indicating the file is already open, with an option to reset the lock.

Returns
true if the lock was reset.

Definition at line 175 of file confirm.cpp.

176{
177#ifdef __APPLE__
178 // wxMessageDialog gets the button spacing wrong on Mac so we have to use wxRichMessageDialog.
179 // Note that its warning icon is more like wxMessageDialog's error icon, so we use it instead
180 // of wxICON_ERROR.
181 wxRichMessageDialog dlg( aParent, aMessage, _( "File Open Warning" ),
182 wxYES_NO | wxICON_WARNING | wxCENTER );
183 dlg.SetExtendedMessage( _( "Interleaved saves may produce very unexpected results." )
184 + wxS( "\n" ) );
185 dlg.SetYesNoLabels( _( "Cancel" ), _( "Open Anyway" ) );
186#else
187 wxMessageDialog dlg( aParent, aMessage, _( "File Open Warning" ),
188 wxYES_NO | wxICON_ERROR | wxCENTER );
189 dlg.SetExtendedMessage( _( "Interleaved saves may produce very unexpected results." ) );
190 dlg.SetYesNoLabels( _( "Cancel" ), _( "Open Anyway" ) );
191#endif
192
193 return dlg.ShowModal() == wxID_NO;
194}

References _.

Referenced by SCH_EDIT_FRAME::importFile(), SCH_EDIT_FRAME::OpenProjectFiles(), and PCB_EDIT_FRAME::OpenProjectFiles().

◆ SelectSingleOption()

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.

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 409 of file confirm.cpp.

411{
412 wxSingleChoiceDialog dlg( aParent, aMessage, aTitle, aOptions );
413
414 if( dlg.ShowModal() != wxID_OK )
415 return -1;
416
417 return dlg.GetSelection();
418}

◆ UnsavedChangesDialog() [1/2]

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

Definition at line 223 of file confirm.cpp.

224{
225#ifdef __APPLE__
226 // wxMessageDialog gets the button order (and spacing) wrong on Mac so we have to use
227 // wxRichMessageDialog.
228 return UnsavedChangesDialog( parent, aMessage, nullptr );
229#else
230 #ifdef _WIN32
231 // wxMessageDialog on windows invokes TaskDialogIndirect which is a native function for a dialog
232 // As a result it skips wxWidgets for modal management...and we don't parent frames properly
233 // among other things for Windows to do the right thing by default
234 // Disable all the windows manually to avoid being able to hit this dialog from the tool frame and kicad frame at the same time
235 wxWindowDisabler disable( true );
236 #endif
237
238 wxMessageDialog dlg( parent, aMessage, _( "Save Changes?" ),
239 wxYES_NO | wxCANCEL | wxYES_DEFAULT | wxICON_WARNING | wxCENTER );
240 dlg.SetExtendedMessage( _( "If you don't save, all your changes will be permanently lost." ) );
241 dlg.SetYesNoLabels( _( "Save" ), _( "Discard Changes" ) );
242
243 // Returns wxID_YES, wxID_NO, or wxID_CANCEL
244 return dlg.ShowModal();
245#endif
246}

References _, and UnsavedChangesDialog().

◆ UnsavedChangesDialog() [2/2]

int UnsavedChangesDialog ( wxWindow *  aParent,
const 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 197 of file confirm.cpp.

198{
199 static bool s_apply_to_all = false;
200
201 wxRichMessageDialog dlg( parent, aMessage, _( "Save Changes?" ),
202 wxYES_NO | wxCANCEL | wxYES_DEFAULT | wxICON_WARNING | wxCENTER );
203 dlg.SetExtendedMessage( _( "If you don't save, all your changes will be permanently lost." )
204 + wxS( "\n" ) );
205 dlg.SetYesNoLabels( _( "Save" ), _( "Discard Changes" ) );
206
207 if( aApplyToAll )
208 dlg.ShowCheckBox( _( "Apply to all" ), s_apply_to_all );
209
210 int ret = dlg.ShowModal();
211
212 if( aApplyToAll )
213 {
214 *aApplyToAll = dlg.IsCheckBoxChecked();
215 s_apply_to_all = dlg.IsCheckBoxChecked();
216 }
217
218 // Returns wxID_YES, wxID_NO, or wxID_CANCEL
219 return ret;
220}

References _.

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

Variable Documentation

◆ doNotShowAgainDlgs

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