From 314735e2fc0746a7235f97bc7e10ee120f705849 Mon Sep 17 00:00:00 2001 From: Mark Roszko Date: Sun, 25 Jan 2026 12:34:55 -0500 Subject: [PATCH] Move message dialogs to KICAD_MESSAGE_DIALOG define Fixes https://gitlab.com/kicad/code/kicad/-/issues/22830 --- bitmap2component/bitmap2cmp_panel.cpp | 3 +- common/common.cpp | 9 +++-- common/confirm.cpp | 11 ++--- .../dialog_design_block_properties.cpp | 3 +- common/dialogs/git/dialog_git_repository.cpp | 4 +- common/eda_base_frame.cpp | 8 ++-- common/lib_table_grid_tricks.cpp | 4 +- common/local_history.cpp | 7 ++-- common/tool/common_control.cpp | 11 ++--- common/widgets/widget_hotkey_list.cpp | 2 +- eeschema/dialogs/dialog_erc.cpp | 5 ++- eeschema/dialogs/dialog_rescue_each.cpp | 13 +++--- eeschema/dialogs/dialog_sheet_properties.cpp | 9 +++-- eeschema/dialogs/dialog_symbol_remap.cpp | 18 ++++----- .../dialogs/panel_template_fieldnames.cpp | 7 ++-- eeschema/files-io.cpp | 21 +++++----- eeschema/project_rescue.cpp | 8 ++-- eeschema/sheet.cpp | 40 +++++++++---------- eeschema/symbol_editor/symbol_edit_frame.cpp | 16 ++++---- eeschema/symbol_editor/symbol_editor.cpp | 2 +- .../dialog_map_gerber_layers_to_pcb.cpp | 10 ++--- include/confirm.h | 5 +++ kicad/import_project.cpp | 4 +- kicad/project_tree_item.cpp | 10 ++--- .../python/scripting/pcb_scripting_tool.cpp | 3 +- 25 files changed, 121 insertions(+), 112 deletions(-) diff --git a/bitmap2component/bitmap2cmp_panel.cpp b/bitmap2component/bitmap2cmp_panel.cpp index 761f2b3f2b..272152eee6 100644 --- a/bitmap2component/bitmap2cmp_panel.cpp +++ b/bitmap2component/bitmap2cmp_panel.cpp @@ -39,6 +39,7 @@ #include #include #include +#include #define DEFAULT_DPI 300 // the image DPI used in formats that do not define a DPI @@ -586,7 +587,7 @@ bool DROP_FILE::OnDropFiles( wxCoord x, wxCoord y, const wxArrayString& filename { wxString cap = _( "Replace Loaded File?" ); wxString msg = _( "There is already a file loaded. Do you want to replace it?" ); - wxMessageDialog acceptFileDlg( m_panel, msg, cap, wxYES_NO | wxICON_QUESTION | wxYES_DEFAULT ); + KICAD_MESSAGE_DIALOG acceptFileDlg( m_panel, msg, cap, wxYES_NO | wxICON_QUESTION | wxYES_DEFAULT ); int replace = acceptFileDlg.ShowModal(); if( replace == wxID_NO ) diff --git a/common/common.cpp b/common/common.cpp index 0fddb56540..8bea9e08f2 100644 --- a/common/common.cpp +++ b/common/common.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -783,10 +784,10 @@ bool WarnUserIfOperatingSystemUnsupported() if( !KIPLATFORM::APP::IsOperatingSystemUnsupported() ) return false; - wxMessageDialog dialog( nullptr, - _( "This operating system is not supported " - "by KiCad and its dependencies." ), - _( "Unsupported Operating System" ), wxOK | wxICON_EXCLAMATION ); + KICAD_MESSAGE_DIALOG dialog( nullptr, + _( "This operating system is not supported " + "by KiCad and its dependencies." ), + _( "Unsupported Operating System" ), wxOK | wxICON_EXCLAMATION ); dialog.SetExtendedMessage( _( "Any issues with KiCad on this system cannot " "be reported to the official bugtracker." ) ); diff --git a/common/confirm.cpp b/common/confirm.cpp index fbd21d01f5..710aaa6942 100644 --- a/common/confirm.cpp +++ b/common/confirm.cpp @@ -271,14 +271,9 @@ bool IsOK( wxWindow* aParent, const wxString& aMessage ) int icon = wxICON_QUESTION; #endif -#if !defined( __WXGTK__ ) - KICAD_RICH_MESSAGE_DIALOG_BASE dlg( aParent, aMessage, _( "Confirmation" ), - wxOK | wxCANCEL | wxOK_DEFAULT | - wxCENTRE | icon | wxSTAY_ON_TOP ); -#else - wxMessageDialog dlg( aParent, aMessage, _( "Confirmation" ), - wxOK | wxCANCEL | wxOK_DEFAULT | wxCENTRE | icon | wxSTAY_ON_TOP ); -#endif + KICAD_MESSAGE_DIALOG dlg( aParent, aMessage, _( "Confirmation" ), + wxOK | wxCANCEL | wxOK_DEFAULT | + wxCENTRE | icon | wxSTAY_ON_TOP ); dlg.SetOKCancelLabels( _( "&Yes" ), _( "&No" ) ); diff --git a/common/dialogs/dialog_design_block_properties.cpp b/common/dialogs/dialog_design_block_properties.cpp index 72bd36e942..8b6422d21e 100644 --- a/common/dialogs/dialog_design_block_properties.cpp +++ b/common/dialogs/dialog_design_block_properties.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include @@ -102,7 +103,7 @@ bool DIALOG_DESIGN_BLOCK_PROPERTIES::TransferDataFromWindow() illegalCh, m_textName->GetValue() ); - wxMessageDialog errdlg( this, msg, _( "Error" ) ); + KICAD_MESSAGE_DIALOG errdlg( this, msg, _( "Error" ) ); errdlg.ShowModal(); return false; } diff --git a/common/dialogs/git/dialog_git_repository.cpp b/common/dialogs/git/dialog_git_repository.cpp index 336702bd6e..605011cd3d 100644 --- a/common/dialogs/git/dialog_git_repository.cpp +++ b/common/dialogs/git/dialog_git_repository.cpp @@ -307,8 +307,8 @@ void DIALOG_GIT_REPOSITORY::OnTestClick( wxCommandEvent& event ) git_remote_disconnect( remote ); - auto dlg = wxMessageDialog( this, wxEmptyString, _( "Test Connection" ), - wxOK | wxICON_INFORMATION ); + auto dlg = KICAD_MESSAGE_DIALOG( this, wxEmptyString, _( "Test Connection" ), + wxOK | wxICON_INFORMATION ); if( success ) { diff --git a/common/eda_base_frame.cpp b/common/eda_base_frame.cpp index a24c7bf585..5935682b9e 100644 --- a/common/eda_base_frame.cpp +++ b/common/eda_base_frame.cpp @@ -1276,12 +1276,12 @@ wxString EDA_BASE_FRAME::GetFileFromHistory( int cmdId, const wxString& type, FI if( !wxFileName::FileExists( fn ) ) { - wxMessageDialog dlg( this, wxString::Format( _( "File '%s' was not found.\n" ), fn ), _( "Error" ), - wxYES_NO | wxYES_DEFAULT | wxICON_ERROR | wxCENTER ); + KICAD_MESSAGE_DIALOG dlg( this, wxString::Format( _( "File '%s' was not found.\n" ), fn ), _( "Error" ), + wxYES_NO | wxYES_DEFAULT | wxICON_ERROR | wxCENTER ); dlg.SetExtendedMessage( _( "Do you want to remove it from list of recently opened files?" ) ); - dlg.SetYesNoLabels( wxMessageDialog::ButtonLabel( _( "Remove" ) ), - wxMessageDialog::ButtonLabel( _( "Keep" ) ) ); + dlg.SetYesNoLabels( KICAD_MESSAGE_DIALOG::ButtonLabel( _( "Remove" ) ), + KICAD_MESSAGE_DIALOG::ButtonLabel( _( "Keep" ) ) ); if( dlg.ShowModal() == wxID_YES ) aFileHistory->RemoveFileFromHistory( i ); diff --git a/common/lib_table_grid_tricks.cpp b/common/lib_table_grid_tricks.cpp index 04026fb2bc..bb1ddecb5e 100644 --- a/common/lib_table_grid_tricks.cpp +++ b/common/lib_table_grid_tricks.cpp @@ -483,7 +483,7 @@ bool LIB_TABLE_GRID_TRICKS::VerifyTable( WX_GRID* aGrid, std::function #include #include +#include #include #include @@ -468,7 +469,7 @@ static bool commitSnapshotWithLock( git_repository* repo, git_index* index, else if( rc != 0 ) { wxLogTrace( traceAutoSave, wxS( "File %s status error %d " ), relPath, rc ); - filesArrStr.emplace_back( relPathStr ); // Add anyway even if the file is untracked. + filesArrStr.emplace_back( relPathStr ); // Add anyway even if the file is untracked. } } @@ -1501,8 +1502,8 @@ bool confirmFileDeletion( wxWindow* aParent, const std::vector& aFiles aFilesToDelete.size() - displayCount ); } - wxMessageDialog dlg( aParent, message, _( "Delete Files during Restore" ), - wxYES_NO | wxCANCEL | wxICON_QUESTION ); + KICAD_MESSAGE_DIALOG dlg( aParent, message, _( "Delete Files during Restore" ), + wxYES_NO | wxCANCEL | wxICON_QUESTION ); dlg.SetYesNoCancelLabels( _( "Proceed" ), _( "Keep All Files" ), _( "Abort" ) ); dlg.SetExtendedMessage( _( "Choosing 'Keep All Files' will restore the selected commit but retain any existing " diff --git a/common/tool/common_control.cpp b/common/tool/common_control.cpp index dc14e67495..e343c7afdc 100644 --- a/common/tool/common_control.cpp +++ b/common/tool/common_control.cpp @@ -45,6 +45,7 @@ #include #include #include +#include #define URL_GET_INVOLVED wxS( "https://go.kicad.org/contribute/" ) #define URL_DONATE wxS( "https://go.kicad.org/app-donate" ) @@ -280,7 +281,7 @@ int COMMON_CONTROL::ShowProjectManager( const TOOL_EVENT& aEvent ) if( top && top->GetFrameType() == KICAD_MAIN_FRAME_T ) showFrame( top ); else - wxMessageDialog( m_frame, _( "Can not switch to project manager in stand-alone mode." ) ); + KICAD_MESSAGE_DIALOG( m_frame, _( "Can not switch to project manager in stand-alone mode." ) ); return 0; } @@ -324,8 +325,8 @@ int COMMON_CONTROL::ShowHelp( const TOOL_EVENT& aEvent ) msg = wxString::Format( _( "Help file '%s' or\n'%s' could not be found.\n" "Do you want to access the KiCad online help?" ), names[0], names[1] ); - wxMessageDialog dlg( nullptr, msg, _( "File Not Found" ), - wxYES_NO | wxNO_DEFAULT | wxCANCEL ); + KICAD_MESSAGE_DIALOG dlg( nullptr, msg, _( "File Not Found" ), + wxYES_NO | wxNO_DEFAULT | wxCANCEL ); if( dlg.ShowModal() != wxID_YES ) return -1; @@ -344,8 +345,8 @@ int COMMON_CONTROL::ShowHelp( const TOOL_EVENT& aEvent ) msg = wxString::Format( _( "Help file '%s' could not be found.\n" "Do you want to access the KiCad online help?" ), base_name ); - wxMessageDialog dlg( nullptr, msg, _( "File Not Found" ), - wxYES_NO | wxNO_DEFAULT | wxCANCEL ); + KICAD_MESSAGE_DIALOG dlg( nullptr, msg, _( "File Not Found" ), + wxYES_NO | wxNO_DEFAULT | wxCANCEL ); if( dlg.ShowModal() != wxID_YES ) return -1; diff --git a/common/widgets/widget_hotkey_list.cpp b/common/widgets/widget_hotkey_list.cpp index 18841f79e5..7baa87bb3e 100644 --- a/common/widgets/widget_hotkey_list.cpp +++ b/common/widgets/widget_hotkey_list.cpp @@ -513,7 +513,7 @@ bool WIDGET_HOTKEY_LIST::resolveKeyConflicts( TOOL_ACTION* aAction, long aKey ) conflictingAction->GetFriendlyName(), HOTKEY_STORE::GetSectionName( conflictingAction ) ); - wxMessageDialog dlg( GetParent(), msg, _( "Confirm change" ), wxYES_NO | wxNO_DEFAULT ); + KICAD_MESSAGE_DIALOG dlg( GetParent(), msg, _( "Confirm change" ), wxYES_NO | wxNO_DEFAULT ); if( dlg.ShowModal() == wxID_YES ) { diff --git a/eeschema/dialogs/dialog_erc.cpp b/eeschema/dialogs/dialog_erc.cpp index 251cec57e0..a6a1507336 100644 --- a/eeschema/dialogs/dialog_erc.cpp +++ b/eeschema/dialogs/dialog_erc.cpp @@ -46,6 +46,7 @@ #include #include #include +#include #include #include @@ -410,8 +411,8 @@ void DIALOG_ERC::OnDeleteAllClick( wxCommandEvent& event ) if( numExcluded > 0 ) { - wxMessageDialog dlg( this, _( "Delete exclusions too?" ), _( "Delete All Markers" ), - wxYES_NO | wxCANCEL | wxCENTER | wxICON_QUESTION ); + KICAD_MESSAGE_DIALOG dlg( this, _( "Delete exclusions too?" ), _( "Delete All Markers" ), + wxYES_NO | wxCANCEL | wxCENTER | wxICON_QUESTION ); dlg.SetYesNoLabels( _( "Errors and Warnings Only" ), _( "Errors, Warnings and Exclusions" ) ); diff --git a/eeschema/dialogs/dialog_rescue_each.cpp b/eeschema/dialogs/dialog_rescue_each.cpp index d24ab54214..64b5266d32 100644 --- a/eeschema/dialogs/dialog_rescue_each.cpp +++ b/eeschema/dialogs/dialog_rescue_each.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -279,12 +280,12 @@ bool DIALOG_RESCUE_EACH::TransferDataFromWindow() void DIALOG_RESCUE_EACH::OnNeverShowClick( wxCommandEvent& aEvent ) { - wxMessageDialog dlg( GetParent(), - _( "Stop showing this tool?\n" - "No changes will be made.\n\n" - "This setting can be changed from the \"Preferences\" dialog,\n" - "and the tool can be activated manually from the \"Tools\" menu." ), - _( "Rescue Symbols" ), wxYES_NO | wxNO_DEFAULT | wxICON_QUESTION ); + KICAD_MESSAGE_DIALOG dlg( GetParent(), + _( "Stop showing this tool?\n" + "No changes will be made.\n\n" + "This setting can be changed from the \"Preferences\" dialog,\n" + "and the tool can be activated manually from the \"Tools\" menu." ), + _( "Rescue Symbols" ), wxYES_NO | wxNO_DEFAULT | wxICON_QUESTION ); int resp = dlg.ShowModal (); if( resp == wxID_YES ) diff --git a/eeschema/dialogs/dialog_sheet_properties.cpp b/eeschema/dialogs/dialog_sheet_properties.cpp index c1e976b53f..e2615eaec1 100644 --- a/eeschema/dialogs/dialog_sheet_properties.cpp +++ b/eeschema/dialogs/dialog_sheet_properties.cpp @@ -307,14 +307,15 @@ bool DIALOG_SHEET_PROPERTIES::TransferDataFromWindow() if( fn.IsAbsolute() && fn.MakeRelativeTo( screenFileName.GetPath() ) ) { - wxMessageDialog makeRelDlg( this, _( "Use relative path for sheet file?" ), _( "Sheet File Path" ), - wxYES_NO | wxYES_DEFAULT | wxICON_QUESTION | wxCENTER ); + KICAD_MESSAGE_DIALOG makeRelDlg( this, _( "Use relative path for sheet file?" ), + _( "Sheet File Path" ), + wxYES_NO | wxYES_DEFAULT | wxICON_QUESTION | wxCENTER ); makeRelDlg.SetExtendedMessage( _( "Using relative hierarchical sheet file name paths improves " "schematic portability across systems and platforms. Using " "absolute paths can result in portability issues." ) ); - makeRelDlg.SetYesNoLabels( wxMessageDialog::ButtonLabel( _( "Use Relative Path" ) ), - wxMessageDialog::ButtonLabel( _( "Use Absolute Path" ) ) ); + makeRelDlg.SetYesNoLabels( KICAD_MESSAGE_DIALOG::ButtonLabel( _( "Use Relative Path" ) ), + KICAD_MESSAGE_DIALOG::ButtonLabel( _( "Use Absolute Path" ) ) ); if( makeRelDlg.ShowModal() == wxID_YES ) { diff --git a/eeschema/dialogs/dialog_symbol_remap.cpp b/eeschema/dialogs/dialog_symbol_remap.cpp index ed553abd5d..3c8886302b 100644 --- a/eeschema/dialogs/dialog_symbol_remap.cpp +++ b/eeschema/dialogs/dialog_symbol_remap.cpp @@ -353,10 +353,10 @@ bool DIALOG_SYMBOL_REMAP::backupProject( REPORTER& aReporter ) errorMsg.Printf( _( "Cannot create project remap back up folder '%s'." ), destFileName.GetPath() ); - wxMessageDialog dlg( this, errorMsg, _( "Backup Error" ), - wxYES_NO | wxCENTRE | wxRESIZE_BORDER | wxICON_QUESTION ); - dlg.SetYesNoLabels( wxMessageDialog::ButtonLabel( _( "Continue with Rescue" ) ), - wxMessageDialog::ButtonLabel( _( "Abort Rescue" ) ) ); + KICAD_MESSAGE_DIALOG dlg( this, errorMsg, _( "Backup Error" ), + wxYES_NO | wxCENTRE | wxRESIZE_BORDER | wxICON_QUESTION ); + dlg.SetYesNoLabels( KICAD_MESSAGE_DIALOG::ButtonLabel( _( "Continue with Rescue" ) ), + KICAD_MESSAGE_DIALOG::ButtonLabel( _( "Abort Rescue" ) ) ); if( dlg.ShowModal() == wxID_NO ) return false; @@ -525,13 +525,13 @@ bool DIALOG_SYMBOL_REMAP::backupProject( REPORTER& aReporter ) if( !errorMsg.IsEmpty() ) { - wxMessageDialog dlg( this, _( "Some of the project files could not be backed up." ), - _( "Backup Error" ), - wxYES_NO | wxCENTRE | wxRESIZE_BORDER | wxICON_QUESTION ); + KICAD_MESSAGE_DIALOG dlg( this, _( "Some of the project files could not be backed up." ), + _( "Backup Error" ), + wxYES_NO | wxCENTRE | wxRESIZE_BORDER | wxICON_QUESTION ); errorMsg.Trim(); dlg.SetExtendedMessage( errorMsg ); - dlg.SetYesNoLabels( wxMessageDialog::ButtonLabel( _( "Continue with Rescue" ) ), - wxMessageDialog::ButtonLabel( _( "Abort Rescue" ) ) ); + dlg.SetYesNoLabels( KICAD_MESSAGE_DIALOG::ButtonLabel( _( "Continue with Rescue" ) ), + KICAD_MESSAGE_DIALOG::ButtonLabel( _( "Abort Rescue" ) ) ); if( dlg.ShowModal() == wxID_NO ) return false; diff --git a/eeschema/dialogs/panel_template_fieldnames.cpp b/eeschema/dialogs/panel_template_fieldnames.cpp index 726688fa3c..7254a03968 100644 --- a/eeschema/dialogs/panel_template_fieldnames.cpp +++ b/eeschema/dialogs/panel_template_fieldnames.cpp @@ -35,6 +35,7 @@ #include #include #include +#include PANEL_TEMPLATE_FIELDNAMES::PANEL_TEMPLATE_FIELDNAMES( wxWindow* aWindow, TEMPLATES* aProjectTemplateMgr ) : @@ -213,7 +214,7 @@ bool PANEL_TEMPLATE_FIELDNAMES::TransferDataFromWindow() msg.Printf( _( "The field name '%s' contains trailing and/or leading white space." ), field.m_Name ); - wxMessageDialog dlg( this, msg, _( "Warning" ), wxOK|wxCANCEL|wxCENTER|wxICON_WARNING ); + KICAD_MESSAGE_DIALOG dlg( this, msg, _( "Warning" ), wxOK | wxCANCEL | wxCENTER | wxICON_WARNING ); dlg.SetExtendedMessage( _( "This may result in what appears to be duplicate field " "names but are actually unique names differing only by " @@ -221,8 +222,8 @@ bool PANEL_TEMPLATE_FIELDNAMES::TransferDataFromWindow() "characters will have no effect on existing symbol " "field names." ) ); - dlg.SetOKCancelLabels( wxMessageDialog::ButtonLabel( _( "Remove White Space" ) ), - wxMessageDialog::ButtonLabel( _( "Keep White Space" ) ) ); + dlg.SetOKCancelLabels( KICAD_MESSAGE_DIALOG::ButtonLabel( _( "Remove White Space" ) ), + KICAD_MESSAGE_DIALOG::ButtonLabel( _( "Keep White Space" ) ) ); if( dlg.ShowModal() == wxID_OK ) field.m_Name = trimmedName; diff --git a/eeschema/files-io.cpp b/eeschema/files-io.cpp index 359453ba9f..491c9240a3 100644 --- a/eeschema/files-io.cpp +++ b/eeschema/files-io.cpp @@ -633,12 +633,11 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector& aFileSet, in "the schematic or recovery of the symbol cache library file and " "reloading the schematic is required." ); - wxMessageDialog dlgMissingCache( this, msg, _( "Warning" ), - wxOK | wxCANCEL | wxICON_EXCLAMATION | wxCENTER ); + KICAD_MESSAGE_DIALOG dlgMissingCache( this, msg, _( "Warning" ), + wxOK | wxCANCEL | wxICON_EXCLAMATION | wxCENTER ); dlgMissingCache.SetExtendedMessage( extMsg ); - dlgMissingCache.SetOKCancelLabels( - wxMessageDialog::ButtonLabel( _( "Load Without Cache File" ) ), - wxMessageDialog::ButtonLabel( _( "Abort" ) ) ); + dlgMissingCache.SetOKCancelLabels( KICAD_MESSAGE_DIALOG::ButtonLabel( _( "Load Without Cache File" ) ), + KICAD_MESSAGE_DIALOG::ButtonLabel( _( "Abort" ) ) ); if( dlgMissingCache.ShowModal() == wxID_CANCEL ) { @@ -1196,8 +1195,8 @@ bool SCH_EDIT_FRAME::SaveProject( bool aSaveAs ) "Make sure you have write permissions and try again." ), newFileName.GetPath() ); - wxMessageDialog dlgBadPath( this, msg, _( "Error" ), - wxOK | wxICON_EXCLAMATION | wxCENTER ); + KICAD_MESSAGE_DIALOG dlgBadPath( this, msg, _( "Error" ), + wxOK | wxICON_EXCLAMATION | wxCENTER ); dlgBadPath.ShowModal(); return false; @@ -1224,8 +1223,8 @@ bool SCH_EDIT_FRAME::SaveProject( bool aSaveAs ) if( !PrepareSaveAsFiles( Schematic(), screens, fn, newFileName, saveCopy, copySubsheets, includeExternSheets, filenameMap, msg ) ) { - wxMessageDialog dlgBadFilePath( this, msg, _( "Error" ), - wxOK | wxICON_EXCLAMATION | wxCENTER ); + KICAD_MESSAGE_DIALOG dlgBadFilePath( this, msg, _( "Error" ), + wxOK | wxICON_EXCLAMATION | wxCENTER ); dlgBadFilePath.ShowModal(); return false; @@ -1314,8 +1313,8 @@ bool SCH_EDIT_FRAME::SaveProject( bool aSaveAs ) wxOK | wxCANCEL | wxCANCEL_DEFAULT | wxCENTER | wxICON_EXCLAMATION ); dlg.ShowDetailedText( _( "The following files will be overwritten:\n\n" ) + msg ); - dlg.SetOKCancelLabels( wxMessageDialog::ButtonLabel( _( "Overwrite Files" ) ), - wxMessageDialog::ButtonLabel( _( "Abort Project Save" ) ) ); + dlg.SetOKCancelLabels( KICAD_MESSAGE_DIALOG::ButtonLabel( _( "Overwrite Files" ) ), + KICAD_MESSAGE_DIALOG::ButtonLabel( _( "Abort Project Save" ) ) ); if( dlg.ShowModal() == wxID_CANCEL ) return false; diff --git a/eeschema/project_rescue.cpp b/eeschema/project_rescue.cpp index 79b860a57c..e7f544fcff 100644 --- a/eeschema/project_rescue.cpp +++ b/eeschema/project_rescue.cpp @@ -549,8 +549,8 @@ bool RESCUER::RescueProject( wxWindow* aParent, RESCUER& aRescuer, bool aRunning { if( aRunningOnDemand ) { - wxMessageDialog dlg( aParent, _( "This project has nothing to rescue." ), - _( "Project Rescue Helper" ) ); + KICAD_MESSAGE_DIALOG dlg( aParent, _( "This project has nothing to rescue." ), + _( "Project Rescue Helper" ) ); dlg.ShowModal(); } @@ -564,8 +564,8 @@ bool RESCUER::RescueProject( wxWindow* aParent, RESCUER& aRescuer, bool aRunning // have clicked cancel by mistake, and should have some indication of that. if( !aRescuer.GetChosenCandidateCount() ) { - wxMessageDialog dlg( aParent, _( "No symbols were rescued." ), - _( "Project Rescue Helper" ) ); + KICAD_MESSAGE_DIALOG dlg( aParent, _( "No symbols were rescued." ), + _( "Project Rescue Helper" ) ); dlg.ShowModal(); // Set the modified flag even on Cancel. Many users seem to instinctively want to Save at diff --git a/eeschema/sheet.cpp b/eeschema/sheet.cpp index 52a98d9b6f..83a545cd1f 100644 --- a/eeschema/sheet.cpp +++ b/eeschema/sheet.cpp @@ -218,9 +218,9 @@ bool SCH_EDIT_FRAME::LoadSheetFromFile( SCH_SHEET* aSheet, SCH_SHEET_PATH* aCurr msg = _( "The entire schematic could not be loaded. Errors occurred attempting " "to load hierarchical sheet schematics." ); - wxMessageDialog msgDlg1( this, msg, _( "Schematic Load Error" ), - wxOK | wxCANCEL | wxCANCEL_DEFAULT | - wxCENTER | wxICON_QUESTION ); + KICAD_MESSAGE_DIALOG msgDlg1( this, msg, _( "Schematic Load Error" ), + wxOK | wxCANCEL | wxCANCEL_DEFAULT | + wxCENTER | wxICON_QUESTION ); msgDlg1.SetOKLabel( wxMessageDialog::ButtonLabel( _( "Use partial schematic" ) ) ); msgDlg1.SetExtendedMessage( pi->GetError() ); @@ -307,8 +307,8 @@ bool SCH_EDIT_FRAME::LoadSheetFromFile( SCH_SHEET* aSheet, SCH_SHEET_PATH* aCurr newScreens.GetLibNicknames( names ); - wxMessageDialog::ButtonLabel okButtonLabel( _( "Continue Load" ) ); - wxMessageDialog::ButtonLabel cancelButtonLabel( _( "Cancel Load" ) ); + KICAD_MESSAGE_DIALOG::ButtonLabel okButtonLabel( _( "Continue Load" ) ); + KICAD_MESSAGE_DIALOG::ButtonLabel cancelButtonLabel( _( "Cancel Load" ) ); // Prior to schematic file format 20221002, all symbol instance data was saved in the root // sheet so loading a hierarchical sheet that is not the root sheet will have no symbol @@ -324,8 +324,8 @@ bool SCH_EDIT_FRAME::LoadSheetFromFile( SCH_SHEET* aSheet, SCH_SHEET_PATH* aCurr "Loading the project that uses this schematic file and saving to the " "latest file version will resolve this issue.\n\n" "Do you wish to continue?" ); - wxMessageDialog msgDlg7( this, msg, _( "Continue Load Schematic" ), - wxOK | wxCANCEL | wxCANCEL_DEFAULT | wxCENTER | wxICON_QUESTION ); + KICAD_MESSAGE_DIALOG msgDlg7( this, msg, _( "Continue Load Schematic" ), + wxOK | wxCANCEL | wxCANCEL_DEFAULT | wxCENTER | wxICON_QUESTION ); msgDlg7.SetOKCancelLabels( okButtonLabel, cancelButtonLabel ); if( msgDlg7.ShowModal() == wxID_CANCEL ) @@ -352,9 +352,9 @@ bool SCH_EDIT_FRAME::LoadSheetFromFile( SCH_SHEET* aSheet, SCH_SHEET_PATH* aCurr "from the current project library table. This may result in broken " "symbol library references for the loaded schematic.\n\n" "Do you wish to continue?" ); - wxMessageDialog msgDlg3( this, msg, _( "Continue Load Schematic" ), - wxOK | wxCANCEL | wxCANCEL_DEFAULT | - wxCENTER | wxICON_QUESTION ); + KICAD_MESSAGE_DIALOG msgDlg3( this, msg, _( "Continue Load Schematic" ), + wxOK | wxCANCEL | wxCANCEL_DEFAULT | + wxCENTER | wxICON_QUESTION ); msgDlg3.SetOKCancelLabels( okButtonLabel, cancelButtonLabel ); if( msgDlg3.ShowModal() == wxID_CANCEL ) @@ -392,8 +392,8 @@ bool SCH_EDIT_FRAME::LoadSheetFromFile( SCH_SHEET* aSheet, SCH_SHEET_PATH* aCurr "Linking the file to this project may result in missing or " "incorrect symbol library references.\n\n" "Do you wish to continue?" ); - wxMessageDialog msgDlg4( this, msg, _( "Continue Load Schematic" ), - wxOK | wxCANCEL | wxCANCEL_DEFAULT | wxCENTER + KICAD_MESSAGE_DIALOG msgDlg4( this, msg, _( "Continue Load Schematic" ), + wxOK | wxCANCEL | wxCANCEL_DEFAULT | wxCENTER | wxICON_QUESTION ); msgDlg4.SetOKCancelLabels( okButtonLabel, cancelButtonLabel ); @@ -437,9 +437,9 @@ bool SCH_EDIT_FRAME::LoadSheetFromFile( SCH_SHEET* aSheet, SCH_SHEET_PATH* aCurr "are missing from the selected schematic project library table. " "This may result in broken symbol library references.\n\n" "Do you wish to continue?" ); - wxMessageDialog msgDlg5( this, msg, _( "Continue Load Schematic" ), - wxOK | wxCANCEL | wxCANCEL_DEFAULT | - wxCENTER | wxICON_QUESTION ); + KICAD_MESSAGE_DIALOG msgDlg5( this, msg, _( "Continue Load Schematic" ), + wxOK | wxCANCEL | wxCANCEL_DEFAULT | + wxCENTER | wxICON_QUESTION ); msgDlg5.SetOKCancelLabels( okButtonLabel, cancelButtonLabel ); if( msgDlg5.ShowModal() == wxID_CANCEL ) @@ -498,9 +498,9 @@ bool SCH_EDIT_FRAME::LoadSheetFromFile( SCH_SHEET* aSheet, SCH_SHEET_PATH* aCurr "in the current library table. This conflict cannot be resolved and " "may result in broken symbol library references.\n\n" "Do you wish to continue?" ); - wxMessageDialog msgDlg6( this, msg, _( "Continue Load Schematic" ), - wxOK | wxCANCEL | wxCANCEL_DEFAULT | - wxCENTER | wxICON_QUESTION ); + KICAD_MESSAGE_DIALOG msgDlg6( this, msg, _( "Continue Load Schematic" ), + wxOK | wxCANCEL | wxCANCEL_DEFAULT | + wxCENTER | wxICON_QUESTION ); msgDlg6.SetOKCancelLabels( okButtonLabel, cancelButtonLabel ); if( msgDlg6.ShowModal() == wxID_CANCEL ) @@ -565,8 +565,8 @@ bool SCH_EDIT_FRAME::LoadSheetFromFile( SCH_SHEET* aSheet, SCH_SHEET_PATH* aCurr projectTable->Save().map_error( [&]( const LIBRARY_ERROR& aError ) { - wxMessageDialog dlg( this, _( "Error saving library table." ), _( "File Save Error" ), - wxOK | wxICON_ERROR ); + KICAD_MESSAGE_DIALOG dlg( this, _( "Error saving library table." ), _( "File Save Error" ), + wxOK | wxICON_ERROR ); dlg.SetExtendedMessage( aError.message ); dlg.ShowModal(); } ); diff --git a/eeschema/symbol_editor/symbol_edit_frame.cpp b/eeschema/symbol_editor/symbol_edit_frame.cpp index 353da27dfd..0c4548c6ab 100644 --- a/eeschema/symbol_editor/symbol_edit_frame.cpp +++ b/eeschema/symbol_editor/symbol_edit_frame.cpp @@ -1196,8 +1196,8 @@ wxString SYMBOL_EDIT_FRAME::AddLibraryFile( bool aCreateNew ) table->Save().map_error( [&]( const LIBRARY_ERROR& aError ) { - wxMessageDialog dlg( this, _( "Error saving library table." ), _( "File Save Error" ), - wxOK | wxICON_ERROR ); + KICAD_MESSAGE_DIALOG dlg( this, _( "Error saving library table." ), _( "File Save Error" ), + wxOK | wxICON_ERROR ); dlg.SetExtendedMessage( aError.message ); dlg.ShowModal(); @@ -1247,8 +1247,8 @@ void SYMBOL_EDIT_FRAME::DdAddLibrary( wxString aLibFile ) table->Save().map_error( [&]( const LIBRARY_ERROR& aError ) { - wxMessageDialog dlg( this, _( "Error saving library table." ), _( "File Save Error" ), - wxOK | wxICON_ERROR ); + KICAD_MESSAGE_DIALOG dlg( this, _( "Error saving library table." ), _( "File Save Error" ), + wxOK | wxICON_ERROR ); dlg.SetExtendedMessage( aError.message ); dlg.ShowModal(); @@ -1987,8 +1987,8 @@ bool SYMBOL_EDIT_FRAME::addLibTableEntry( const wxString& aLibFile, LIBRARY_TABL table->Save().map_error( [&]( const LIBRARY_ERROR& aError ) { - wxMessageDialog dlg( this, _( "Error saving library table." ), _( "File Save Error" ), - wxOK | wxICON_ERROR ); + KICAD_MESSAGE_DIALOG dlg( this, _( "Error saving library table." ), _( "File Save Error" ), + wxOK | wxICON_ERROR ); dlg.SetExtendedMessage( aError.message ); dlg.ShowModal(); @@ -2056,8 +2056,8 @@ bool SYMBOL_EDIT_FRAME::replaceLibTableEntry( const wxString& aLibNickname, cons table->Save().map_error( [&]( const LIBRARY_ERROR& aError ) { - wxMessageDialog dlg( this, _( "Error saving library table." ), _( "File Save Error" ), - wxOK | wxICON_ERROR ); + KICAD_MESSAGE_DIALOG dlg( this, _( "Error saving library table." ), _( "File Save Error" ), + wxOK | wxICON_ERROR ); dlg.SetExtendedMessage( aError.message ); dlg.ShowModal(); diff --git a/eeschema/symbol_editor/symbol_editor.cpp b/eeschema/symbol_editor/symbol_editor.cpp index 82afa3c5d1..624db2a7e2 100644 --- a/eeschema/symbol_editor/symbol_editor.cpp +++ b/eeschema/symbol_editor/symbol_editor.cpp @@ -1268,7 +1268,7 @@ void SYMBOL_EDIT_FRAME::DeleteSymbolFromLibrary() for( const wxString& name : derived ) msg += name + wxT( "\n" ); - KICAD_MESSAGE_DIALOG_BASE dlg( this, msg, _( "Warning" ), wxYES_NO | wxICON_WARNING | wxCENTER ); + KICAD_MESSAGE_DIALOG dlg( this, msg, _( "Warning" ), wxYES_NO | wxICON_WARNING | wxCENTER ); dlg.SetExtendedMessage( wxT( " " ) ); dlg.SetYesNoLabels( _( "Delete All Listed Symbols" ), _( "Cancel" ) ); diff --git a/gerbview/dialogs/dialog_map_gerber_layers_to_pcb.cpp b/gerbview/dialogs/dialog_map_gerber_layers_to_pcb.cpp index 12948ad8b6..cbd49ed773 100644 --- a/gerbview/dialogs/dialog_map_gerber_layers_to_pcb.cpp +++ b/gerbview/dialogs/dialog_map_gerber_layers_to_pcb.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include @@ -210,13 +211,12 @@ void DIALOG_MAP_GERBER_LAYERS_TO_PCB::initDialog() if( numMappedGerbers > 0 ) { - // See if the user wants to map the Altium Gerbers to known KiCad PCB layers - int returnVal = wxMessageBox( wxString::Format( _( "Gerbers with known layers: %d" ), numMappedGerbers ) + KICAD_MESSAGE_DIALOG dlg ( this, + wxString::Format( _( "Gerbers with known layers: %d" ), numMappedGerbers ) + wxT( "\n\n" ) + _( "Assign to matching PCB layers?" ), - _( "Automatic Layer Assignment" ), - wxOK | wxCANCEL | wxOK_DEFAULT ); + _( "Automatic Layer Assignment" ), wxOK | wxCANCEL | wxOK_DEFAULT ); - if( returnVal == wxOK ) + if( dlg.ShowModal() == wxOK ) { int total_copper = 0; diff --git a/include/confirm.h b/include/confirm.h index 93f70d85ab..f0e59d4df7 100644 --- a/include/confirm.h +++ b/include/confirm.h @@ -39,12 +39,17 @@ class wxWindow; +// On Windows, to have the best dark mode experience we need to sub in the generic dialogs +// as wx can't retheme the native dialogs #if defined( _WIN32 ) && wxCHECK_VERSION( 3, 3, 0 ) #define KICAD_MESSAGE_DIALOG_BASE wxGenericMessageDialog #define KICAD_RICH_MESSAGE_DIALOG_BASE wxGenericRichMessageDialog +// incase we in the future declare our own message dialog class +#define KICAD_MESSAGE_DIALOG KICAD_MESSAGE_DIALOG_BASE #else #define KICAD_MESSAGE_DIALOG_BASE wxMessageDialog #define KICAD_RICH_MESSAGE_DIALOG_BASE wxRichMessageDialog +#define KICAD_MESSAGE_DIALOG KICAD_MESSAGE_DIALOG_BASE #endif diff --git a/kicad/import_project.cpp b/kicad/import_project.cpp index f9b8e8e5b7..9cd4c17ebd 100644 --- a/kicad/import_project.cpp +++ b/kicad/import_project.cpp @@ -120,8 +120,8 @@ void KICAD_MANAGER_FRAME::ImportNonKiCadProject( const wxString& aWindowTitle, msg = _( "Error creating new directory. Please try a different path. The " "project cannot be imported." ); - wxMessageDialog dirErrorDlg( this, msg, _( "Error" ), - wxOK_DEFAULT | wxICON_ERROR ); + KICAD_MESSAGE_DIALOG dirErrorDlg( this, msg, _( "Error" ), + wxOK_DEFAULT | wxICON_ERROR ); dirErrorDlg.ShowModal(); return; } diff --git a/kicad/project_tree_item.cpp b/kicad/project_tree_item.cpp index 4f79d8a68e..d8488f3810 100644 --- a/kicad/project_tree_item.cpp +++ b/kicad/project_tree_item.cpp @@ -134,9 +134,9 @@ bool PROJECT_TREE_ITEM::Rename( const wxString& name, bool check ) if( check && !ext.IsEmpty() && !newFile.Lower().EndsWith( full_ext ) ) { - wxMessageDialog dialog( m_parent, _( "Changing file extension will change file type.\n" - "Do you want to continue ?" ), - _( "Rename File" ), wxYES_NO | wxICON_QUESTION ); + KICAD_MESSAGE_DIALOG dialog( m_parent, _( "Changing file extension will change file type.\n" + "Do you want to continue ?" ), + _( "Rename File" ), wxYES_NO | wxICON_QUESTION ); if( wxID_YES != dialog.ShowModal() ) return false; @@ -144,8 +144,8 @@ bool PROJECT_TREE_ITEM::Rename( const wxString& name, bool check ) if( !wxRenameFile( GetFileName(), newFile, false ) ) { - wxMessageDialog( m_parent, _( "Unable to rename file ... " ), _( "Permission denied" ), - wxICON_ERROR | wxOK ); + KICAD_MESSAGE_DIALOG( m_parent, _( "Unable to rename file ... " ), _( "Permission denied" ), + wxICON_ERROR | wxOK ); return false; } diff --git a/pcbnew/python/scripting/pcb_scripting_tool.cpp b/pcbnew/python/scripting/pcb_scripting_tool.cpp index c89361ed99..75e5105acc 100644 --- a/pcbnew/python/scripting/pcb_scripting_tool.cpp +++ b/pcbnew/python/scripting/pcb_scripting_tool.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #ifdef KICAD_IPC_API #include @@ -225,7 +226,7 @@ void SCRIPTING_TOOL::ShowPluginFolder() wxString msg = wxString::Format( _( "The plugin directory '%s' does not exist. Create it?" ), pluginpath ); - wxMessageDialog dlg( nullptr, msg, _( "Plugin Directory" ), wxYES_NO | wxICON_QUESTION ); + KICAD_MESSAGE_DIALOG dlg( nullptr, msg, _( "Plugin Directory" ), wxYES_NO | wxICON_QUESTION ); if( dlg.ShowModal() == wxID_YES ) {