From e90cc8adf546612d10e2164da0f17da012833022 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Thu, 8 Mar 2012 18:47:23 +0100 Subject: [PATCH] All: added a standard exit dialog called by int DisplayExitDialog( wxWindow* aParent, const wxString& aMessage ) Called when closing pcbnew, cvpcb and eeschema. Minor code cleaning: remove duplicate or not used strings (mainly file extensions and wildcards) --- common/CMakeLists.txt | 1 + common/confirm.cpp | 28 + common/dialogs/dialog_exit_base.cpp | 96 +++ common/dialogs/dialog_exit_base.fbp | 804 ++++++++++++++++++ common/dialogs/dialog_exit_base.h | 61 ++ common/drawpanel.cpp | 2 +- common/footprint_info.cpp | 3 +- common/pcbcommon.cpp | 9 - common/wildcards_and_files_ext.cpp | 8 + cvpcb/cvframe.cpp | 9 +- cvpcb/dialogs/dialog_cvpcb_config.cpp | 2 +- cvpcb/loadcmp.cpp | 3 +- eeschema/dialogs/dialog_schematic_find.cpp | 1 + eeschema/schframe.cpp | 12 +- include/confirm.h | 15 + include/pcbcommon.h | 6 - include/wildcards_and_files_ext.h | 5 + .../dialog_edit_module_for_BoardEditor.cpp | 7 +- .../dialog_edit_module_for_Modedit.cpp | 7 +- pcbnew/dialogs/dialog_netlist.cpp | 4 +- .../dialog_pcbnew_config_libs_and_paths.cpp | 4 +- pcbnew/librairi.cpp | 14 +- pcbnew/loadcmp.cpp | 3 +- pcbnew/modedit.cpp | 7 +- pcbnew/moduleframe.cpp | 3 +- pcbnew/modview.cpp | 5 +- pcbnew/modview_frame.cpp | 5 +- pcbnew/pcbframe.cpp | 10 +- pcbnew/pcbnew.cpp | 3 - pcbnew/pcbnew.h | 14 +- pcbnew/xchgmod.cpp | 7 +- 31 files changed, 1084 insertions(+), 74 deletions(-) create mode 100644 common/dialogs/dialog_exit_base.cpp create mode 100644 common/dialogs/dialog_exit_base.fbp create mode 100644 common/dialogs/dialog_exit_base.h diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 3749bc051d..d0daea73f5 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -15,6 +15,7 @@ set(COMMON_ABOUT_DLG_SRCS dialog_about/dialog_about.cpp dialog_about/dialog_about_base.cpp dialogs/dialog_display_info_HTML_base.cpp + dialogs/dialog_exit_base.cpp dialogs/dialog_image_editor.cpp dialogs/dialog_image_editor_base.cpp dialogs/dialog_get_component.cpp diff --git a/common/confirm.cpp b/common/confirm.cpp index 95a8a96616..4c480f48af 100644 --- a/common/confirm.cpp +++ b/common/confirm.cpp @@ -8,7 +8,35 @@ #include #include #include +#include +#include +class DIALOG_EXIT: public DIALOG_EXIT_BASE +{ +public: + DIALOG_EXIT( wxWindow * parent, const wxString& aMessage ) : + DIALOG_EXIT_BASE( parent ) + { + m_bitmap->SetBitmap( KiBitmap( cancel_xpm ) ); + if( ! aMessage.IsEmpty() ) + m_TextInfo->SetLabel( aMessage ); + GetSizer()->Fit( this ); + GetSizer()->SetSizeHints( this ); + }; + +private: + void OnSaveAndExit( wxCommandEvent& event ) { EndModal( wxID_OK ); } + void OnCancel( wxCommandEvent& event ) { EndModal( wxID_CANCEL ); } + void OnExitNoSave( wxCommandEvent& event ) { EndModal( wxID_NO ); } +}; + +int DisplayExitDialog( wxWindow* parent, const wxString& aMessage ) +{ + DIALOG_EXIT dlg( parent, aMessage ); + + int ret = dlg.ShowModal(); + return ret; +} void DisplayError( wxWindow* parent, const wxString& text, int displaytime ) { diff --git a/common/dialogs/dialog_exit_base.cpp b/common/dialogs/dialog_exit_base.cpp new file mode 100644 index 0000000000..4d0205dafc --- /dev/null +++ b/common/dialogs/dialog_exit_base.cpp @@ -0,0 +1,96 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Feb 9 2012) +// http://www.wxformbuilder.org/ +// +// PLEASE DO "NOT" EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#include "dialog_exit_base.h" + +/////////////////////////////////////////////////////////////////////////// + +DIALOG_EXIT_BASE::DIALOG_EXIT_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style ) +{ + this->SetSizeHints( wxDefaultSize, wxDefaultSize ); + + wxBoxSizer* bSizerMain; + bSizerMain = new wxBoxSizer( wxVERTICAL ); + + wxBoxSizer* bSizerUpper; + bSizerUpper = new wxBoxSizer( wxHORIZONTAL ); + + wxBoxSizer* bSizerBitmap; + bSizerBitmap = new wxBoxSizer( wxVERTICAL ); + + m_bitmap = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 ); + bSizerBitmap->Add( m_bitmap, 0, wxALL, 5 ); + + + bSizerUpper->Add( bSizerBitmap, 0, 0, 5 ); + + wxBoxSizer* bSizerMessages; + bSizerMessages = new wxBoxSizer( wxVERTICAL ); + + m_TextInfo = new wxStaticText( this, wxID_ANY, _("Save the changes before closing?"), wxDefaultPosition, wxDefaultSize, 0 ); + m_TextInfo->Wrap( -1 ); + m_TextInfo->SetFont( wxFont( 8, 74, 90, 92, false, wxT("MS Shell Dlg 2") ) ); + + bSizerMessages->Add( m_TextInfo, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 ); + + + bSizerMessages->Add( 10, 10, 0, 0, 5 ); + + m_staticText2 = new wxStaticText( this, wxID_ANY, _("If you don't save, all your changes will be permanently lost."), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText2->Wrap( -1 ); + bSizerMessages->Add( m_staticText2, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 ); + + + bSizerUpper->Add( bSizerMessages, 1, wxEXPAND, 5 ); + + + bSizerMain->Add( bSizerUpper, 1, wxEXPAND, 5 ); + + wxBoxSizer* bSizerLower; + bSizerLower = new wxBoxSizer( wxVERTICAL ); + + m_staticline = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); + bSizerLower->Add( m_staticline, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); + + wxBoxSizer* bSizerButtons; + bSizerButtons = new wxBoxSizer( wxHORIZONTAL ); + + m_buttonSaveAndExit = new wxButton( this, wxID_ANY, _("Save and Exit"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizerButtons->Add( m_buttonSaveAndExit, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + + m_buttonExitNoSave = new wxButton( this, wxID_ANY, _("Exit without Save"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizerButtons->Add( m_buttonExitNoSave, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + + m_buttonCancel = new wxButton( this, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizerButtons->Add( m_buttonCancel, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + + + bSizerLower->Add( bSizerButtons, 0, wxALIGN_RIGHT, 5 ); + + + bSizerMain->Add( bSizerLower, 0, wxEXPAND, 5 ); + + + this->SetSizer( bSizerMain ); + this->Layout(); + + this->Centre( wxBOTH ); + + // Connect Events + m_buttonSaveAndExit->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EXIT_BASE::OnSaveAndExit ), NULL, this ); + m_buttonExitNoSave->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EXIT_BASE::OnExitNoSave ), NULL, this ); + m_buttonCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EXIT_BASE::OnCancel ), NULL, this ); +} + +DIALOG_EXIT_BASE::~DIALOG_EXIT_BASE() +{ + // Disconnect Events + m_buttonSaveAndExit->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EXIT_BASE::OnSaveAndExit ), NULL, this ); + m_buttonExitNoSave->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EXIT_BASE::OnExitNoSave ), NULL, this ); + m_buttonCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EXIT_BASE::OnCancel ), NULL, this ); + +} diff --git a/common/dialogs/dialog_exit_base.fbp b/common/dialogs/dialog_exit_base.fbp new file mode 100644 index 0000000000..a5702a029e --- /dev/null +++ b/common/dialogs/dialog_exit_base.fbp @@ -0,0 +1,804 @@ + + + + + + C++ + 1 + source_name + 0 + 0 + res + UTF-8 + connect + dialog_exit_base + 1000 + none + 1 + dialog_exit_base + + . + + 1 + 1 + 1 + 0 + 0 + + 1 + 1 + 1 + 1 + + 0 + + + + + + + 1 + wxBOTH + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + impl_virtual + + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + DIALOG_EXIT_BASE + 1 + + + 1 + + Resizable + 1 + 345,155 + wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + bSizerMain + wxVERTICAL + none + + 5 + wxEXPAND + 1 + + + bSizerUpper + wxHORIZONTAL + none + + 5 + + 0 + + + bSizerBitmap + wxVERTICAL + none + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_bitmap + 1 + + + protected + 1 + + Resizable + 1 + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 1 + + + bSizerMessages + wxVERTICAL + none + + 5 + wxALL|wxALIGN_CENTER_HORIZONTAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + MS Shell Dlg 2,90,92,8,74,0 + 0 + 0 + wxID_ANY + Save the changes before closing? + + 0 + + + 0 + + 1 + m_TextInfo + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + + 0 + + 10 + protected + 10 + + + + 5 + wxALL|wxALIGN_CENTER_HORIZONTAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + If you don't save, all your changes will be permanently lost. + + 0 + + + 0 + + 1 + m_staticText2 + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 0 + + + bSizerLower + wxVERTICAL + none + + 5 + wxEXPAND|wxTOP|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_staticline + 1 + + + protected + 1 + + Resizable + 1 + + wxLI_HORIZONTAL + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALIGN_RIGHT + 0 + + + bSizerButtons + wxHORIZONTAL + none + + 5 + wxALL|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Save and Exit + + 0 + + + 0 + + 1 + m_buttonSaveAndExit + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnSaveAndExit + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Exit without Save + + 0 + + + 0 + + 1 + m_buttonExitNoSave + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnExitNoSave + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_CANCEL + Cancel + + 0 + + + 0 + + 1 + m_buttonCancel + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnCancel + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/common/dialogs/dialog_exit_base.h b/common/dialogs/dialog_exit_base.h new file mode 100644 index 0000000000..43ebdc5e9f --- /dev/null +++ b/common/dialogs/dialog_exit_base.h @@ -0,0 +1,61 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Feb 9 2012) +// http://www.wxformbuilder.org/ +// +// PLEASE DO "NOT" EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#ifndef __DIALOG_EXIT_BASE_H__ +#define __DIALOG_EXIT_BASE_H__ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/////////////////////////////////////////////////////////////////////////// + + +/////////////////////////////////////////////////////////////////////////////// +/// Class DIALOG_EXIT_BASE +/////////////////////////////////////////////////////////////////////////////// +class DIALOG_EXIT_BASE : public wxDialog +{ + private: + + protected: + wxStaticBitmap* m_bitmap; + wxStaticText* m_TextInfo; + wxStaticText* m_staticText2; + wxStaticLine* m_staticline; + wxButton* m_buttonSaveAndExit; + wxButton* m_buttonExitNoSave; + wxButton* m_buttonCancel; + + // Virtual event handlers, overide them in your derived class + virtual void OnSaveAndExit( wxCommandEvent& event ) { event.Skip(); } + virtual void OnExitNoSave( wxCommandEvent& event ) { event.Skip(); } + virtual void OnCancel( wxCommandEvent& event ) { event.Skip(); } + + + public: + + DIALOG_EXIT_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 345,155 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + ~DIALOG_EXIT_BASE(); + +}; + +#endif //__DIALOG_EXIT_BASE_H__ diff --git a/common/drawpanel.cpp b/common/drawpanel.cpp index 0514b6a424..b4ff7f47e0 100644 --- a/common/drawpanel.cpp +++ b/common/drawpanel.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com + * Copyright (C) 2009 Jean-Pierre Charras, jean-pierre.charras@gipsa-lab.inpg.fr * Copyright (C) 2007-2011 Wayne Stambaugh * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors. * diff --git a/common/footprint_info.cpp b/common/footprint_info.cpp index fead30cbb2..0907ca81a1 100644 --- a/common/footprint_info.cpp +++ b/common/footprint_info.cpp @@ -22,6 +22,7 @@ #include #include +#include /* Read the list of libraries (*.mod files) @@ -53,7 +54,7 @@ bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString & aFootprintsLibNames ) for( unsigned ii = 0; ii < aFootprintsLibNames.GetCount(); ii++ ) { filename = aFootprintsLibNames[ii]; - filename.SetExt( ModuleFileExtension ); + filename.SetExt( FootprintLibFileExtension ); libname = wxGetApp().FindLibraryPath( filename ); diff --git a/common/pcbcommon.cpp b/common/pcbcommon.cpp index 7d0d53bb4a..058af23ea9 100644 --- a/common/pcbcommon.cpp +++ b/common/pcbcommon.cpp @@ -81,15 +81,6 @@ int g_TabAllCopperLayerMask[NB_COPPER_LAYERS] = { DISPLAY_OPTIONS DisplayOpt; /* Display options for board items */ -/* PCB file name extension definitions. */ -wxString NetExtBuffer( wxT( "net" ) ); -wxString NetCmpExtBuffer( wxT( "cmp" ) ); -wxString g_Shapes3DExtBuffer( wxT( "wrl" ) ); -const wxString ModuleFileExtension( wxT( "mod" ) ); - -/* PCB file name wild card definitions. */ -const wxString ModuleFileWildcard( _( "KiCad footprint library files (*.mod)|*.mod" ) ); - int g_RotationAngle; int g_AnchorColor = BLUE; diff --git a/common/wildcards_and_files_ext.cpp b/common/wildcards_and_files_ext.cpp index ba15f597cf..b95206625f 100644 --- a/common/wildcards_and_files_ext.cpp +++ b/common/wildcards_and_files_ext.cpp @@ -32,9 +32,12 @@ * file extensions and wildcards used in kicad. */ +const wxString VrmlFileExtension( wxT( "wrl" ) ); + const wxString ProjectFileExtension( wxT( "pro" ) ); const wxString SchematicFileExtension( wxT( "sch" ) ); const wxString NetlistFileExtension( wxT( "net" ) ); +const wxString FootprintLibFileExtension( wxT( "mod" ) ); const wxString ComponentFileExtension( wxT( "cmp" ) ); const wxString GerberFileExtension( wxT( "pho" ) ); const wxString PcbFileExtension( wxT( "brd" ) ); @@ -44,11 +47,15 @@ const wxString DrillFileExtension( wxT( "drl" ) ); const wxString ReportFileExtension( wxT( "rpt" ) ); const wxString FootprintPlaceFileExtension( wxT( "pos" ) ); +// These strings are wildcards for file selection dialogs. +// Because thes are static, one should explicitely call wxGetTranslation +// to display them translated. const wxString ProjectFileWildcard( _( "KiCad project files (*.pro)|*.pro" ) ); const wxString SchematicFileWildcard( _( "KiCad schematic files (*.sch)|*.sch" ) ); const wxString NetlistFileWildcard( _( "KiCad netlist files (*.net)|*.net" ) ); const wxString GerberFileWildcard( _( "Gerber files (*.pho)|*.pho" ) ); const wxString PcbFileWildcard( _( "KiCad printed circuit board files (*.brd)|*.brd" ) ); +const wxString FootprintLibFileWildcard( _( "KiCad footprint library file (*.mod)|*.mod" ) ); const wxString PdfFileWildcard( _( "Portable document format files (*.pdf)|*.pdf" ) ); const wxString MacrosFileWildcard( _( "KiCad recorded macros (*.mcr)|*.mcr" ) ); const wxString AllFilesWildcard( _( "All files (*)|*" ) ); @@ -59,3 +66,4 @@ const wxString ComponentFileWildcard( _( "KiCad cmp/footprint link files (*.cmp) const wxString DrillFileWildcard( _( "Drill files (*.drl)|*.drl;*.DRL" ) ); const wxString ReportFileWildcard = _( "Report files (*.rpt)|*.rpt" ); const wxString FootprintPlaceFileWildcard = _( "Footprint place files (*.pos)|*.pos" ); +const wxString VrmlFileWildcard( _( "Vrml files (*.wrl)|*.wrl" ) ); diff --git a/cvpcb/cvframe.cpp b/cvpcb/cvframe.cpp index 0903bb9bf9..84172ef68e 100644 --- a/cvpcb/cvframe.cpp +++ b/cvpcb/cvframe.cpp @@ -240,13 +240,8 @@ void CVPCB_MAINFRAME::OnCloseWindow( wxCloseEvent& Event ) if( m_modified ) { - unsigned ii; - wxMessageDialog dialog( this, - _( "Component to Footprint links modified.\nSave before exit ?" ), - _( "Confirmation" ), - wxYES_NO | wxCANCEL | wxICON_EXCLAMATION | wxYES_DEFAULT ); - - ii = dialog.ShowModal(); + wxString msg = _( "Component to Footprint links modified.\nSave before exit ?" ); + int ii = DisplayExitDialog( this, msg ); switch( ii ) { diff --git a/cvpcb/dialogs/dialog_cvpcb_config.cpp b/cvpcb/dialogs/dialog_cvpcb_config.cpp index 5fc56bfe83..b53bec3ea5 100644 --- a/cvpcb/dialogs/dialog_cvpcb_config.cpp +++ b/cvpcb/dialogs/dialog_cvpcb_config.cpp @@ -299,7 +299,7 @@ void DIALOG_CVPCB_CONFIG::OnAddOrInsertLibClick( wxCommandEvent& event ) if( (event.GetId() == ID_ADD_LIB) || (event.GetId() == ID_INSERT_LIB) ) { list = m_ListLibr; - wildcard = ModuleFileWildcard; + wildcard = FootprintLibFileWildcard; } wxArrayInt selections; diff --git a/cvpcb/loadcmp.cpp b/cvpcb/loadcmp.cpp index 0e212776dc..0bd78719a9 100644 --- a/cvpcb/loadcmp.cpp +++ b/cvpcb/loadcmp.cpp @@ -19,6 +19,7 @@ #include #include #include +#include /** @@ -42,7 +43,7 @@ MODULE* DISPLAY_FOOTPRINTS_FRAME::Get_Module( const wxString& CmpName ) for( ii = 0; ii < parent->m_ModuleLibNames.GetCount(); ii++ ) { fn = parent->m_ModuleLibNames[ii]; - fn.SetExt( ModuleFileExtension ); + fn.SetExt( FootprintLibFileExtension ); tmp = wxGetApp().FindLibraryPath( fn ); diff --git a/eeschema/dialogs/dialog_schematic_find.cpp b/eeschema/dialogs/dialog_schematic_find.cpp index 0cfe86b1ba..d5d23ec283 100644 --- a/eeschema/dialogs/dialog_schematic_find.cpp +++ b/eeschema/dialogs/dialog_schematic_find.cpp @@ -78,6 +78,7 @@ DIALOG_SCH_FIND::DIALOG_SCH_FIND( wxWindow* aParent, wxFindReplaceData* aData, // Adjust the height of the dialog to prevent controls from being hidden when // switching between the find and find/replace modes of the dialog. This ignores // the users preferred height if any of the controls would be hidden. + GetSizer()->SetSizeHints( this ); wxSize size = aSize; if( aSize != wxDefaultSize ) diff --git a/eeschema/schframe.cpp b/eeschema/schframe.cpp index 6022d6d391..6a660b7dc0 100644 --- a/eeschema/schframe.cpp +++ b/eeschema/schframe.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -422,12 +423,13 @@ void SCH_EDIT_FRAME::OnCloseWindow( wxCloseEvent& aEvent ) if( SheetList.IsModified() ) { - wxMessageDialog dialog( this, - _( "Schematic modified, Save before exit?" ), - _( "Confirmation" ), wxYES_NO | wxCANCEL | - wxICON_EXCLAMATION | wxYES_DEFAULT ); + wxString msg; + msg.Printf( _("Save the changes in\n<%s>\nbefore closing?"), + GetChars( g_RootSheet->GetScreen()->GetFileName() ) ); - switch( dialog.ShowModal() ) + int ii = DisplayExitDialog( this, msg ); + + switch( ii ) { case wxID_CANCEL: aEvent.Veto(); diff --git a/include/confirm.h b/include/confirm.h index f00208de54..8a1ef11758 100644 --- a/include/confirm.h +++ b/include/confirm.h @@ -8,6 +8,21 @@ #ifndef __INCLUDE__CONFIRM_H__ #define __INCLUDE__CONFIRM_H__ 1 +/** + * Function DisplayExitDialog + * displays a dialog with 3 buttons: + * Save and Exit + * Cancel + * Exit without save + * + * @param aParent = the parent window + * @param aMessage = the main message to put in dialog + * If empty, the standard message will be shown: + * Save the changes before closing? + * @return wxID_YES, wxID_CANCEL, wxID_NO. + */ +int DisplayExitDialog( wxWindow* aParent, const wxString& aMessage ); + /** * Function DisplayError diff --git a/include/pcbcommon.h b/include/pcbcommon.h index 0cc432bde7..1fc354e525 100644 --- a/include/pcbcommon.h +++ b/include/pcbcommon.h @@ -35,12 +35,6 @@ extern int g_TabAllCopperLayerMask[NB_COPPER_LAYERS]; extern DISPLAY_OPTIONS DisplayOpt; -extern wxString NetExtBuffer; -extern wxString NetCmpExtBuffer; -extern const wxString ModuleFileExtension; - -extern const wxString ModuleFileWildcard; - extern int g_CurrentVersionPCB; extern int g_RotationAngle; diff --git a/include/wildcards_and_files_ext.h b/include/wildcards_and_files_ext.h index b1ae8c55e9..e6a01c9c7e 100644 --- a/include/wildcards_and_files_ext.h +++ b/include/wildcards_and_files_ext.h @@ -41,11 +41,13 @@ * that they cannot be changed. * Mainly wild cards are most of time translated when displayed */ +extern const wxString VrmlFileExtension; extern const wxString ProjectFileExtension; extern const wxString SchematicFileExtension; extern const wxString NetlistFileExtension; extern const wxString GerberFileExtension; extern const wxString PcbFileExtension; +extern const wxString FootprintLibFileExtension; extern const wxString PdfFileExtension; extern const wxString MacrosFileExtension; extern const wxString ComponentFileExtension; @@ -67,5 +69,8 @@ extern const wxString ComponentFileWildcard; extern const wxString DrillFileWildcard; extern const wxString ReportFileWildcard; extern const wxString FootprintPlaceFileWildcard; +extern const wxString VrmlFileWildcard; +extern const wxString DocModulesFileName; +extern const wxString FootprintLibFileWildcard; #endif // INCLUDE_WILDCARDS_AND_FILES_EXT_H_ diff --git a/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp b/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp index 783fbafb1c..540be1f5cb 100644 --- a/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp +++ b/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp @@ -17,6 +17,7 @@ #include #include +#include DIALOG_MODULE_BOARD_EDITOR::DIALOG_MODULE_BOARD_EDITOR( PCB_EDIT_FRAME* aParent, @@ -404,18 +405,16 @@ void DIALOG_MODULE_BOARD_EDITOR::Browse3DLib( wxCommandEvent& event ) { wxString fullfilename, shortfilename; wxString fullpath; - wxString mask = wxT( "*" ); fullpath = wxGetApp().ReturnLastVisitedLibraryPath( LIB3D_PATH ); - mask += g_Shapes3DExtBuffer; #ifdef __WINDOWS__ fullpath.Replace( wxT( "/" ), wxT( "\\" ) ); #endif fullfilename = EDA_FileSelector( _( "3D Shape:" ), fullpath, wxEmptyString, - g_Shapes3DExtBuffer, - mask, + VrmlFileExtension, + wxGetTranslation( VrmlFileWildcard ), this, wxFD_OPEN, true diff --git a/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp b/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp index 546b927369..3274aa7abb 100644 --- a/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp +++ b/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp @@ -16,6 +16,7 @@ #include #include #include +#include DIALOG_MODULE_MODULE_EDITOR::DIALOG_MODULE_MODULE_EDITOR( FOOTPRINT_EDIT_FRAME* aParent, @@ -259,18 +260,16 @@ void DIALOG_MODULE_MODULE_EDITOR::BrowseAndAdd3DLib( wxCommandEvent& event ) { wxString fullfilename, shortfilename; wxString fullpath; - wxString mask = wxT( "*" ); fullpath = wxGetApp().ReturnLastVisitedLibraryPath( LIB3D_PATH ); - mask += g_Shapes3DExtBuffer; #ifdef __WINDOWS__ fullpath.Replace( wxT( "/" ), wxT( "\\" ) ); #endif fullfilename = EDA_FileSelector( _( "3D Shape:" ), fullpath, wxEmptyString, - g_Shapes3DExtBuffer, - mask, + VrmlFileExtension, + wxGetTranslation( VrmlFileWildcard ), this, wxFD_OPEN, true diff --git a/pcbnew/dialogs/dialog_netlist.cpp b/pcbnew/dialogs/dialog_netlist.cpp index 25d690e8b6..6c7c07ed47 100644 --- a/pcbnew/dialogs/dialog_netlist.cpp +++ b/pcbnew/dialogs/dialog_netlist.cpp @@ -29,7 +29,7 @@ void PCB_EDIT_FRAME::InstallNetlistFrame( wxDC* DC ) if( !fn.FileExists() ) { fn = GetScreen()->GetFileName(); - fn.SetExt( NetExtBuffer ); + fn.SetExt( NetlistFileExtension ); lastNetlistName = fn.GetFullPath(); } @@ -102,7 +102,7 @@ void DIALOG_NETLIST::OnOpenNelistClick( wxCommandEvent& event ) void DIALOG_NETLIST::OnReadNetlistFileClick( wxCommandEvent& event ) { wxFileName fn = m_NetlistFilenameCtrl->GetValue(); - fn.SetExt( NetCmpExtBuffer ); + fn.SetExt( ComponentFileExtension ); m_Parent->ReadPcbNetlist( m_NetlistFilenameCtrl->GetValue(), fn.GetFullPath(), m_MessageWindow, diff --git a/pcbnew/dialogs/dialog_pcbnew_config_libs_and_paths.cpp b/pcbnew/dialogs/dialog_pcbnew_config_libs_and_paths.cpp index db74fe5499..684a5d9f6c 100644 --- a/pcbnew/dialogs/dialog_pcbnew_config_libs_and_paths.cpp +++ b/pcbnew/dialogs/dialog_pcbnew_config_libs_and_paths.cpp @@ -43,6 +43,7 @@ #include #include +#include void PCB_EDIT_FRAME::InstallConfigFrame( ) @@ -271,7 +272,8 @@ void DIALOG_PCBNEW_CONFIG_LIBS::OnAddOrInsertLibClick( wxCommandEvent& event ) libpath = wxGetApp().ReturnLastVisitedLibraryPath(); wxFileDialog FilesDialog( this, _( "Footprint library files:" ), libpath, - wxEmptyString, g_FootprintLibFileWildcard, + wxEmptyString, + wxGetTranslation( FootprintLibFileWildcard ), wxFD_DEFAULT_STYLE | wxFD_MULTIPLE ); if( FilesDialog.ShowModal() != wxID_OK ) diff --git a/pcbnew/librairi.cpp b/pcbnew/librairi.cpp index 80108cda86..37611da303 100644 --- a/pcbnew/librairi.cpp +++ b/pcbnew/librairi.cpp @@ -22,6 +22,7 @@ #include #include #include +#include /* @@ -151,7 +152,7 @@ void FOOTPRINT_EDIT_FRAME::Export_Module( MODULE* aModule, bool aCreateSysLib ) return; fn.SetName( aModule->m_LibRef ); - fn.SetExt( aCreateSysLib ? ModuleFileExtension : ModExportFileExtension ); + fn.SetExt( aCreateSysLib ? FootprintLibFileExtension : ModExportFileExtension ); if( aCreateSysLib ) path = wxGetApp().ReturnLastVisitedLibraryPath(); @@ -160,8 +161,9 @@ void FOOTPRINT_EDIT_FRAME::Export_Module( MODULE* aModule, bool aCreateSysLib ) fn.SetPath( path ); title = aCreateSysLib ? _( "Create New Library" ) : _( "Export Module" ); - wildcard = aCreateSysLib ? ModuleFileWildcard : ModExportFileWildcard; - wxFileDialog dlg( this, msg, fn.GetPath(), fn.GetFullName(), wildcard, + wildcard = aCreateSysLib ? FootprintLibFileWildcard : ModExportFileWildcard; + wxFileDialog dlg( this, msg, fn.GetPath(), fn.GetFullName(), + wxGetTranslation( wildcard ), wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); if( dlg.ShowModal() == wxID_CANCEL ) @@ -369,7 +371,8 @@ void PCB_EDIT_FRAME::ArchiveModulesOnBoard( const wxString& aLibName, bool aNewM if( aLibName.IsEmpty() ) { wxFileDialog dlg( this, _( "Library" ), path, - wxEmptyString, ModuleFileWildcard, + wxEmptyString, + wxGetTranslation( FootprintLibFileWildcard ), wxFD_SAVE ); if( dlg.ShowModal() == wxID_CANCEL ) @@ -730,7 +733,8 @@ void FOOTPRINT_EDIT_FRAME::Select_Active_Library() if( dlg.ShowModal() != wxID_OK ) return; - wxFileName fileName = wxFileName( wxEmptyString, dlg.GetTextSelection(), ModuleFileExtension ); + wxFileName fileName = wxFileName( wxEmptyString, dlg.GetTextSelection(), + FootprintLibFileExtension ); fileName = wxGetApp().FindLibraryPath( fileName ); if( fileName.IsOk() && fileName.FileExists() ) diff --git a/pcbnew/loadcmp.cpp b/pcbnew/loadcmp.cpp index b533e099a3..95e4b04a08 100644 --- a/pcbnew/loadcmp.cpp +++ b/pcbnew/loadcmp.cpp @@ -49,6 +49,7 @@ #include #include #include +#include static void DisplayCmpDoc( wxString& Name ); @@ -272,7 +273,7 @@ MODULE* PCB_BASE_FRAME::GetModuleLibrary( const wxString& aLibraryFullFilename, if( one_lib ) fn = aLibraryFullFilename; else - fn = wxFileName( wxEmptyString, g_LibraryNames[ii], ModuleFileExtension ); + fn = wxFileName( wxEmptyString, g_LibraryNames[ii], FootprintLibFileExtension ); tmp = wxGetApp().FindLibraryPath( fn ); diff --git a/pcbnew/modedit.cpp b/pcbnew/modedit.cpp index ee9e1c2f5d..809311a386 100644 --- a/pcbnew/modedit.cpp +++ b/pcbnew/modedit.cpp @@ -27,6 +27,7 @@ #include #include +#include // Functions defined in block_module_editor, but used here // These 2 functions are used in modedit to rotate or mirror the whole footprint @@ -247,7 +248,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) case ID_MODEDIT_DELETE_PART: { - wxFileName fn = wxFileName( wxEmptyString, m_CurrentLib, ModuleFileExtension ); + wxFileName fn = wxFileName( wxEmptyString, m_CurrentLib, FootprintLibFileExtension ); wxString full_libraryfilename = wxGetApp().FindLibraryPath( fn ); if( wxFileName::FileExists( full_libraryfilename ) ) @@ -287,7 +288,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) break; { wxFileName fn; - fn = wxFileName( wxEmptyString, m_CurrentLib, ModuleFileExtension ); + fn = wxFileName( wxEmptyString, m_CurrentLib, FootprintLibFileExtension ); wxString full_filename = wxGetApp().FindLibraryPath( fn ); Save_Module_In_Library( full_filename, GetBoard()->m_Modules, true, true ); GetScreen()->ClrModify(); @@ -415,7 +416,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) if( !m_CurrentLib.IsEmpty() ) { - wxFileName fn = wxFileName( wxEmptyString, m_CurrentLib, ModuleFileExtension ); + wxFileName fn = wxFileName( wxEmptyString, m_CurrentLib, FootprintLibFileExtension ); full_libraryfilename = wxGetApp().FindLibraryPath( fn ); } diff --git a/pcbnew/moduleframe.cpp b/pcbnew/moduleframe.cpp index e7ec4482e4..2fe1ecfe75 100644 --- a/pcbnew/moduleframe.cpp +++ b/pcbnew/moduleframe.cpp @@ -45,6 +45,7 @@ #include #include #include +#include static PCB_SCREEN* s_screenModule; // the PCB_SCREEN used by the footprint editor @@ -492,7 +493,7 @@ void FOOTPRINT_EDIT_FRAME::UpdateTitle() } else { - wxFileName fileName = wxFileName( wxEmptyString, m_CurrentLib, ModuleFileExtension ); + wxFileName fileName = wxFileName( wxEmptyString, m_CurrentLib, FootprintLibFileExtension ); fileName = wxGetApp().FindLibraryPath( fileName ); if( !fileName.IsOk() || !fileName.FileExists() ) diff --git a/pcbnew/modview.cpp b/pcbnew/modview.cpp index c4fab2f2a7..df7f1065d7 100644 --- a/pcbnew/modview.cpp +++ b/pcbnew/modview.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #define NEXT_PART 1 @@ -109,7 +110,7 @@ void FOOTPRINT_VIEWER_FRAME::SelectCurrentLibrary( wxCommandEvent& event ) */ void FOOTPRINT_VIEWER_FRAME::SelectCurrentFootprint( wxCommandEvent& event ) { - wxString libname = m_libraryName + wxT(".") + ModuleFileExtension; + wxString libname = m_libraryName + wxT(".") + FootprintLibFileExtension; MODULE* oldmodule = GetBoard()->m_Modules; MODULE * module = Load_Module_From_Library( libname, false ); if( module ) @@ -160,7 +161,7 @@ void FOOTPRINT_VIEWER_FRAME::SelectAndViewFootprint( int aMode ) SetCurItem( NULL ); // Delete the current footprint GetBoard()->m_Modules.DeleteAll(); - GetModuleLibrary( m_libraryName + wxT(".") + ModuleFileExtension, + GetModuleLibrary( m_libraryName + wxT(".") + FootprintLibFileExtension, m_footprintName, true ); Update3D_Frame(); } diff --git a/pcbnew/modview_frame.cpp b/pcbnew/modview_frame.cpp index 85c3b09b50..0e6f2780d6 100644 --- a/pcbnew/modview_frame.cpp +++ b/pcbnew/modview_frame.cpp @@ -44,6 +44,7 @@ #include #include +#include /** @@ -188,7 +189,7 @@ FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( wxWindow* parent, wxSemaphore* s // If a footprint was previsiously loaded, reload it if( !m_libraryName.IsEmpty() && !m_footprintName.IsEmpty() ) - GetModuleLibrary( m_libraryName + wxT(".") + ModuleFileExtension, + GetModuleLibrary( m_libraryName + wxT(".") + FootprintLibFileExtension, m_footprintName, false ); @@ -436,7 +437,7 @@ void FOOTPRINT_VIEWER_FRAME::ClickOnFootprintList( wxCommandEvent& event ) SetCurItem( NULL ); // Delete the current footprint GetBoard()->m_Modules.DeleteAll(); - GetModuleLibrary( m_libraryName + wxT(".") + ModuleFileExtension, + GetModuleLibrary( m_libraryName + wxT(".") + FootprintLibFileExtension, m_footprintName, true ); DisplayLibInfos(); Zoom_Automatique( false ); diff --git a/pcbnew/pcbframe.cpp b/pcbnew/pcbframe.cpp index 97a29a56d6..aef0669b73 100644 --- a/pcbnew/pcbframe.cpp +++ b/pcbnew/pcbframe.cpp @@ -461,13 +461,11 @@ void PCB_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event ) if( GetScreen()->IsModify() ) { - unsigned ii; - wxMessageDialog dialog( this, _( "Board modified, Save before exit ?" ), - _( "Confirmation" ), - wxYES_NO | wxCANCEL | wxICON_EXCLAMATION | wxYES_DEFAULT ); - - ii = dialog.ShowModal(); + wxString msg; + msg.Printf( _("Save the changes in\n<%s>\nbefore closing?"), + GetChars( GetScreen()->GetFileName() ) ); + int ii = DisplayExitDialog( this, msg ); switch( ii ) { case wxID_CANCEL: diff --git a/pcbnew/pcbnew.cpp b/pcbnew/pcbnew.cpp index 3face0a320..c188009bf2 100644 --- a/pcbnew/pcbnew.cpp +++ b/pcbnew/pcbnew.cpp @@ -73,9 +73,6 @@ int g_MagneticTrackOption = capture_cursor_in_track_tool; wxPoint g_Offset_Module; /* Distance to offset module trace when moving. */ -// Wildcard for footprint libraries filesnames -const wxString g_FootprintLibFileWildcard( _( "KiCad footprint library file (*.mod)|*.mod" ) ); - /* Name of the document footprint list * usually located in share/modules/footprints_doc * this is of the responsibility to users to create this file diff --git a/pcbnew/pcbnew.h b/pcbnew/pcbnew.h index ca9db9d4cd..6ef054e972 100644 --- a/pcbnew/pcbnew.h +++ b/pcbnew/pcbnew.h @@ -40,6 +40,14 @@ /* Flag to force the SKETCH mode to display items (.m_Flags member) */ #define FORCE_SKETCH ( IS_DRAGGED | IN_EDIT ) +/* Name of the document footprint list + * usually located in share/modules/footprints_doc + * this is of the responsibility to users to create this file + * if they want to have a list of footprints + * default is "footprints_doc/footprints.pdf" + */ +extern wxString g_DocModulesFileName; + /* variables */ extern bool Drc_On; extern bool g_AutoDeleteOldTrack; @@ -47,15 +55,9 @@ extern bool g_Drag_Pistes_On; extern bool g_Show_Module_Ratsnest; extern bool g_Show_Pads_Module_in_Move; extern bool g_Raccord_45_Auto; - -extern const wxString g_FootprintLibFileWildcard; // Wildcard for footprint libraries filesnames - - extern bool g_Track_45_Only_Allowed; extern bool g_Alternate_Track_Posture; extern bool Segments_45_Only; -extern wxString g_Shapes3DExtBuffer; -extern wxString g_DocModulesFileName; /* Layer pair for auto routing and switch layers by hotkey */ extern int Route_Layer_TOP; diff --git a/pcbnew/xchgmod.cpp b/pcbnew/xchgmod.cpp index ee94b38ef2..f32fe805f9 100644 --- a/pcbnew/xchgmod.cpp +++ b/pcbnew/xchgmod.cpp @@ -16,6 +16,7 @@ #include #include #include +#include static char* quiet_gcc_4_4_3; // GCC 4.4.3 and next .. @@ -160,7 +161,7 @@ int DIALOG_EXCHANGE_MODULE::Maj_ListeCmp( const wxString& reference, /* Build CMP file name by changing the extension of NetList filename */ fn = m_Parent->GetScreen()->GetFileName(); - fn.SetExt( NetCmpExtBuffer ); + fn.SetExt( ComponentFileExtension ); FichCmp = wxFopen( fn.GetFullPath(), wxT( "rt" ) ); @@ -598,8 +599,8 @@ void PCB_EDIT_FRAME::RecreateCmpFileFromBoard( wxCommandEvent& aEvent ) /* Calculation file name by changing the extension name to NetList */ fn = GetScreen()->GetFileName(); - fn.SetExt( NetCmpExtBuffer ); - wildcard = _( "Component files (." ) + NetCmpExtBuffer + wxT( ")|*." ) + NetCmpExtBuffer; + fn.SetExt( ComponentFileExtension ); + wildcard = wxGetTranslation( ComponentFileWildcard ); wxFileDialog dlg( this, _( "Save Component Files" ), wxGetCwd(), fn.GetFullName(), wildcard,