From 401ea10e8f17040b62e0fcbc81d12e26a8b57f16 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sun, 17 Apr 2011 15:54:17 +0200 Subject: [PATCH] Code cleaning. Coding policy fixes. --- common/basicframe.cpp | 2 - cvpcb/cvframe.cpp | 2 +- cvpcb/menubar.cpp | 14 +++-- eeschema/libeditframe.cpp | 2 +- eeschema/menubar.cpp | 14 +++-- eeschema/menubar_libedit.cpp | 2 +- eeschema/schframe.cpp | 2 +- gerbview/events_called_functions.cpp | 2 +- gerbview/menubar.cpp | 24 ++++++--- include/id.h | 9 ---- include/wxstruct.h | 19 +++++-- kicad/commandframe.cpp | 2 +- kicad/files-io.cpp | 10 ++-- kicad/kicad.cpp | 6 +-- kicad/kicad.h | 12 ++--- kicad/mainframe.cpp | 39 +++++++------- kicad/menubar.cpp | 76 +++++++++++++++------------- kicad/preferences.cpp | 10 ++-- kicad/prjconfig.cpp | 9 ++-- kicad/tree_project_frame.cpp | 2 +- kicad/tree_project_frame.h | 4 +- pcbnew/menubar_modedit.cpp | 4 +- pcbnew/menubar_pcbframe.cpp | 14 +++-- pcbnew/pcbframe.cpp | 2 +- pcbnew/pcbnew_id.h | 6 +++ 25 files changed, 161 insertions(+), 127 deletions(-) diff --git a/common/basicframe.cpp b/common/basicframe.cpp index 05ff7cf521..dd0922f625 100644 --- a/common/basicframe.cpp +++ b/common/basicframe.cpp @@ -213,7 +213,6 @@ void EDA_BASE_FRAME::UpdateFileHistory( const wxString& FullFileName, fileHistory = & wxGetApp().m_fileHistory; fileHistory->AddFileToHistory( FullFileName ); - ReCreateMenuBar(); } @@ -245,7 +244,6 @@ wxString EDA_BASE_FRAME::GetFileFromHistory( int cmdId, const wxString& type, DisplayError( this, msg ); fileHistory->RemoveFileFromHistory( i ); fn = wxEmptyString; - ReCreateMenuBar(); } } diff --git a/cvpcb/cvframe.cpp b/cvpcb/cvframe.cpp index 220dc756e4..9f18b82ce2 100644 --- a/cvpcb/cvframe.cpp +++ b/cvpcb/cvframe.cpp @@ -41,7 +41,7 @@ BEGIN_EVENT_TABLE( CVPCB_MAINFRAME, EDA_BASE_FRAME ) CVPCB_MAINFRAME::SaveQuitCvpcb ) EVT_MENU( wxID_EXIT, CVPCB_MAINFRAME::OnQuit ) - EVT_MENU( ID_GENERAL_HELP, + EVT_MENU( wxID_HELP, CVPCB_MAINFRAME::GetKicadHelp ) EVT_MENU( wxID_ABOUT, CVPCB_MAINFRAME::GetKicadAbout ) diff --git a/cvpcb/menubar.cpp b/cvpcb/menubar.cpp index d8b5774f1b..c759f816b0 100644 --- a/cvpcb/menubar.cpp +++ b/cvpcb/menubar.cpp @@ -45,8 +45,14 @@ void CVPCB_MAINFRAME::ReCreateMenuBar() open_document_xpm ); // Open Recent submenu - wxMenu* openRecentMenu = new wxMenu(); - wxGetApp().m_fileHistory.AddFilesToMenu( openRecentMenu ); + static wxMenu* openRecentMenu; + // Add this menu to list menu managed by m_fileHistory + // (the file history will be updated when adding/removing files in history + if( openRecentMenu ) + wxGetApp().m_fileHistory.RemoveMenu( openRecentMenu ); + openRecentMenu = new wxMenu(); + wxGetApp().m_fileHistory.UseMenu( openRecentMenu ); + wxGetApp().m_fileHistory.AddFilesToMenu( ); ADD_MENUITEM_WITH_HELP_AND_SUBMENU( filesMenu, openRecentMenu, -1, _( "Open &Recent" ), _("Open a recent opened netlist document" ), @@ -111,8 +117,8 @@ void CVPCB_MAINFRAME::ReCreateMenuBar() AddHelpVersionInfoMenuEntry( helpMenu ); // Contents - ADD_MENUITEM_WITH_HELP( helpMenu, ID_GENERAL_HELP, _( "&Contents" ), - _( "Open the cvpcb manual" ), + ADD_MENUITEM_WITH_HELP( helpMenu, wxID_HELP, _( "&Contents" ), + _( "Open the Cvpcb handbook" ), online_help_xpm ); // About diff --git a/eeschema/libeditframe.cpp b/eeschema/libeditframe.cpp index 18d8a37388..074e5bb33b 100644 --- a/eeschema/libeditframe.cpp +++ b/eeschema/libeditframe.cpp @@ -114,7 +114,7 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME ) EVT_MENU( ID_LIBEDIT_SAVE_CURRENT_LIB_AS, LIB_EDIT_FRAME::SaveActiveLibrary ) EVT_MENU( ID_LIBEDIT_GEN_PNG_FILE, LIB_EDIT_FRAME::OnPlotCurrentComponent ) EVT_MENU( ID_LIBEDIT_GEN_SVG_FILE, LIB_EDIT_FRAME::OnPlotCurrentComponent ) - EVT_MENU( ID_GENERAL_HELP, EDA_DRAW_FRAME::GetKicadHelp ) + EVT_MENU( wxID_HELP, EDA_DRAW_FRAME::GetKicadHelp ) EVT_MENU( ID_COLORS_SETUP, LIB_EDIT_FRAME::OnColorConfig ) EVT_MENU( ID_CONFIG_REQ, LIB_EDIT_FRAME::InstallConfigFrame ) diff --git a/eeschema/menubar.cpp b/eeschema/menubar.cpp index ac6f4ad804..2dc686f22a 100644 --- a/eeschema/menubar.cpp +++ b/eeschema/menubar.cpp @@ -61,10 +61,16 @@ void SCH_EDIT_FRAME::ReCreateMenuBar() fileMenu->Append( item ); // Open Recent submenu - wxMenu* openRecentMenu = new wxMenu(); + static wxMenu* openRecentMenu; + // Add this menu to list menu managed by m_fileHistory + // (the file history will be updated when adding/removing files in history + if( openRecentMenu ) + wxGetApp().m_fileHistory.RemoveMenu( openRecentMenu ); + openRecentMenu = new wxMenu(); + wxGetApp().m_fileHistory.UseMenu( openRecentMenu ); wxGetApp().m_fileHistory.AddFilesToMenu( openRecentMenu ); ADD_MENUITEM_WITH_HELP_AND_SUBMENU( fileMenu, openRecentMenu, - -1, _( "Open &Recent" ), + wxID_ANY, _( "Open &Recent" ), _( "Open a recent opened schematic project" ), open_project_xpm ); // Separator @@ -464,9 +470,9 @@ void SCH_EDIT_FRAME::ReCreateMenuBar() // Contents item = new wxMenuItem( helpMenu, - ID_GENERAL_HELP, + wxID_HELP, _( "&Contents" ), - _( "Open the eeschema manual" ) ); + _( "Open the Eeschema handbook" ) ); SET_BITMAP( online_help_xpm ); helpMenu->Append( item ); diff --git a/eeschema/menubar_libedit.cpp b/eeschema/menubar_libedit.cpp index e8337c62c4..9c0c9007e5 100644 --- a/eeschema/menubar_libedit.cpp +++ b/eeschema/menubar_libedit.cpp @@ -275,7 +275,7 @@ void LIB_EDIT_FRAME::ReCreateMenuBar() // Contens item = new wxMenuItem( helpMenu, - ID_GENERAL_HELP, + wxID_HELP, _( "&Contents" ), _( "Open the eeschema manual" ) ); SET_BITMAP( online_help_xpm ); diff --git a/eeschema/schframe.cpp b/eeschema/schframe.cpp index 6c0d3c7452..fdd7d3dd09 100644 --- a/eeschema/schframe.cpp +++ b/eeschema/schframe.cpp @@ -99,7 +99,7 @@ BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME ) EVT_TOOL( ID_FIND_ITEMS, SCH_EDIT_FRAME::OnFindItems ) EVT_TOOL( ID_BACKANNO_ITEMS, SCH_EDIT_FRAME::OnLoadStuffFile ) - EVT_MENU( ID_GENERAL_HELP, EDA_DRAW_FRAME::GetKicadHelp ) + EVT_MENU( wxID_HELP, EDA_DRAW_FRAME::GetKicadHelp ) EVT_MENU( wxID_ABOUT, EDA_DRAW_FRAME::GetKicadAbout ) // Tools and buttons for vertical toolbar. diff --git a/gerbview/events_called_functions.cpp b/gerbview/events_called_functions.cpp index 377f3cda6d..fa8910fe30 100644 --- a/gerbview/events_called_functions.cpp +++ b/gerbview/events_called_functions.cpp @@ -60,7 +60,7 @@ EVT_MENU( ID_MENU_GERBVIEW_SELECT_PREFERED_EDITOR, EVT_MENU( ID_GERBVIEW_GLOBAL_DELETE, GERBVIEW_FRAME::Process_Special_Functions ) // Menu Help -EVT_MENU( ID_GENERAL_HELP, EDA_DRAW_FRAME::GetKicadHelp ) +EVT_MENU( wxID_HELP, EDA_DRAW_FRAME::GetKicadHelp ) EVT_MENU( wxID_ABOUT, EDA_DRAW_FRAME::GetKicadAbout ) EVT_TOOL( wxID_CUT, GERBVIEW_FRAME::Process_Special_Functions ) diff --git a/gerbview/menubar.cpp b/gerbview/menubar.cpp index 0cd37b0516..b0a457c381 100644 --- a/gerbview/menubar.cpp +++ b/gerbview/menubar.cpp @@ -55,8 +55,14 @@ void GERBVIEW_FRAME::ReCreateMenuBar( void ) gerber_open_dcode_file_xpm ); // Recent gerber files - wxMenu* openRecentGbrMenu = new wxMenu(); - wxGetApp().m_fileHistory.AddFilesToMenu( openRecentGbrMenu ); + static wxMenu* openRecentGbrMenu; + // Add this menu to list menu managed by m_fileHistory + // (the file history will be updated when adding/removing files in history + if( openRecentGbrMenu ) + wxGetApp().m_fileHistory.RemoveMenu( openRecentGbrMenu ); + openRecentGbrMenu = new wxMenu(); + wxGetApp().m_fileHistory.UseMenu( openRecentGbrMenu ); + wxGetApp().m_fileHistory.AddFilesToMenu(); ADD_MENUITEM_WITH_HELP_AND_SUBMENU( fileMenu, openRecentGbrMenu, wxID_ANY, _( "Open &Recent Gerber File" ), @@ -64,10 +70,14 @@ void GERBVIEW_FRAME::ReCreateMenuBar( void ) gerber_recent_files_xpm ); // Recent drill files - wxMenu* openRecentDrlMenu = new wxMenu(); - m_drillFileHistory.AddFilesToMenu( openRecentDrlMenu ); + static wxMenu* openRecentDrlMenu; + if( openRecentDrlMenu ) + wxGetApp().m_fileHistory.RemoveMenu( openRecentDrlMenu ); + openRecentDrlMenu = new wxMenu(); + wxGetApp().m_fileHistory.UseMenu( openRecentDrlMenu ); + m_drillFileHistory.AddFilesToMenu( ); ADD_MENUITEM_WITH_HELP_AND_SUBMENU( fileMenu, openRecentDrlMenu, - wxID_ANY, + wxID_ANY, _( "Open Recent &Drill File" ), _( "Open a recent opened drill file" ), open_project_xpm ); @@ -184,9 +194,9 @@ void GERBVIEW_FRAME::ReCreateMenuBar( void ) // Contents ADD_MENUITEM_WITH_HELP( helpMenu, - ID_GENERAL_HELP, + wxID_HELP, _( "&Contents" ), - _( "Open the gerbview manual" ), + _( "Open the Gerbview handbook" ), help_xpm ); // About gerbview diff --git a/include/id.h b/include/id.h index d6cd069e64..bc533d2220 100644 --- a/include/id.h +++ b/include/id.h @@ -51,13 +51,7 @@ enum main_id ID_GEN_COPY_BLOCK_TO_CLIPBOARD, ID_GEN_EXPORT_FILE, - ID_GEN_EXPORT_SPECCTRA, - ID_GEN_EXPORT_FILE_GENCADFORMAT, - ID_GEN_EXPORT_FILE_MODULE_REPORT, - ID_GEN_IMPORT_FILE, - ID_GEN_IMPORT_SPECCTRA_SESSION, - ID_GEN_IMPORT_SPECCTRA_DESIGN, ID_EXIT, ID_OPTIONS_SETUP, @@ -68,10 +62,7 @@ enum main_id ID_OPT_TOOLBAR, ID_AUX_TOOLBAR, - ID_GENERAL_HELP, ID_HELP_COPY_VERSION_STRING, - ID_LOCAL_HELP, - ID_KICAD_ABOUT, // @todo all handle by wxID_ABOUT ID_EDIT, ID_NO_TOOL_SELECTED, diff --git a/include/wxstruct.h b/include/wxstruct.h index a9811fdfe4..0c17ab9413 100644 --- a/include/wxstruct.h +++ b/include/wxstruct.h @@ -192,6 +192,9 @@ public: /** * Function GetFileFromHistory * fetches the file name from the file history list. + * and removes the selected file, if this file does not exists + * Note also the menu is updated, if wxFileHistory::UseMenu + * was called at init time * @param cmdId The command ID associated with the \a aFileHistory object. * @param type Please document me! * @param aFileHistory The wxFileHistory in use. If null, the main application file @@ -203,15 +206,23 @@ public: /** * Function UpdateFileHistory - * ypdates the list of recently opened files. + * Updates the list of recently opened files. + * Note also the menu is updated, if wxFileHistory::UseMenu + * was called at init time * @param FullFileName The full file name including the path. - * @param aFileHistory The wxFileHistory in use. If NULL, the main application file - * history is used. + * @param aFileHistory The wxFileHistory in use. + * If NULL, the main application file history is used. */ - void UpdateFileHistory( const wxString& FullFileName, + void UpdateFileHistory( const wxString& FullFileName, wxFileHistory * aFileHistory = NULL ); void DisplayActivity( int PerCent, const wxString& Text ); + + /** + * Function ReCreateMenuBar + * Creates recreates the menu bar. + * Needed when the language is changed + */ virtual void ReCreateMenuBar(); }; diff --git a/kicad/commandframe.cpp b/kicad/commandframe.cpp index 861908986f..1e7cd1d108 100644 --- a/kicad/commandframe.cpp +++ b/kicad/commandframe.cpp @@ -11,7 +11,7 @@ #include "../bitmap2component/bitmap2component.xpm" -RIGHT_KM_FRAME::RIGHT_KM_FRAME( WinEDA_MainFrame* parent ) : +RIGHT_KM_FRAME::RIGHT_KM_FRAME( KICAD_MANAGER_FRAME* parent ) : wxSashLayoutWindow( parent, wxID_ANY ) { #define BUTTON_HEIGHT 32 diff --git a/kicad/files-io.cpp b/kicad/files-io.cpp index 3e07e0cc6e..9155c40683 100644 --- a/kicad/files-io.cpp +++ b/kicad/files-io.cpp @@ -27,11 +27,11 @@ static const wxString ZipFileExtension( wxT( "zip" ) ); static const wxString ZipFileWildcard( wxT( "Zip file (*.zip) | *.zip" ) ); -void WinEDA_MainFrame::OnFileHistory( wxCommandEvent& event ) +void KICAD_MANAGER_FRAME::OnFileHistory( wxCommandEvent& event ) { wxString fn; - fn = GetFileFromHistory( event.GetId(), _( "Printed circuit board" ) ); + fn = GetFileFromHistory( event.GetId(), _( "Kicad project file" ) ); if( fn != wxEmptyString ) { @@ -39,11 +39,9 @@ void WinEDA_MainFrame::OnFileHistory( wxCommandEvent& event ) m_ProjectFileName = fn; OnLoadProject( cmd ); } - - ReCreateMenuBar(); } -void WinEDA_MainFrame::OnUnarchiveFiles( wxCommandEvent& event ) +void KICAD_MANAGER_FRAME::OnUnarchiveFiles( wxCommandEvent& event ) { wxFileName fn = m_ProjectFileName; fn.SetExt( ZipFileExtension ); @@ -109,7 +107,7 @@ void WinEDA_MainFrame::OnUnarchiveFiles( wxCommandEvent& event ) } -void WinEDA_MainFrame::OnArchiveFiles( wxCommandEvent& event ) +void KICAD_MANAGER_FRAME::OnArchiveFiles( wxCommandEvent& event ) { size_t i; wxFileName fileName = m_ProjectFileName; diff --git a/kicad/kicad.cpp b/kicad/kicad.cpp index b0f5bb9e71..361960d32c 100644 --- a/kicad/kicad.cpp +++ b/kicad/kicad.cpp @@ -43,7 +43,7 @@ IMPLEMENT_APP( WinEDA_App ) * http://wiki.wxwidgets.org/WxMac-specific_topics */ void WinEDA_App::MacOpenFile(const wxString &fileName) { - WinEDA_MainFrame * frame = ((WinEDA_MainFrame*)GetTopWindow()); + KICAD_MANAGER_FRAME * frame = ((KICAD_MANAGER_FRAME*)GetTopWindow()); wxFileName fn = fileName; frame->m_ProjectFileName = fn; @@ -75,7 +75,7 @@ void WinEDA_App::MacOpenFile(const wxString &fileName) { bool WinEDA_App::OnInit() /*****************************************************************************/ { - WinEDA_MainFrame* frame; + KICAD_MANAGER_FRAME* frame; InitEDA_Appl( wxT( "KiCad" ), APP_TYPE_KICAD ); @@ -86,7 +86,7 @@ bool WinEDA_App::OnInit() /* Make nameless project translatable */ wxFileName namelessProject( wxGetCwd(), NAMELESS_PROJECT, ProjectFileExtension ); - frame = new WinEDA_MainFrame( NULL, wxT( "KiCad" ), + frame = new KICAD_MANAGER_FRAME( NULL, wxT( "KiCad" ), wxPoint( 30, 20 ), wxSize( 600, 400 ) ); if( argc > 1 ) diff --git a/kicad/kicad.h b/kicad/kicad.h index 3c50553200..5d8f7e4c6a 100644 --- a/kicad/kicad.h +++ b/kicad/kicad.h @@ -54,10 +54,10 @@ enum id_kicad_frm { }; -/* class WinEDA_MainFrame +/* class KICAD_MANAGER_FRAME * This is the main kicad frame */ -class WinEDA_MainFrame : public EDA_BASE_FRAME +class KICAD_MANAGER_FRAME : public EDA_BASE_FRAME { public: TREE_PROJECT_FRAME* m_LeftWin; @@ -72,10 +72,10 @@ private: public: - WinEDA_MainFrame( wxWindow* parent, const wxString& title, + KICAD_MANAGER_FRAME( wxWindow* parent, const wxString& title, const wxPoint& pos, const wxSize& size ); - ~WinEDA_MainFrame(); + ~KICAD_MANAGER_FRAME(); /** * Function CreateCommandToolbar @@ -143,7 +143,7 @@ class RIGHT_KM_FRAME : public wxSashLayoutWindow public: wxTextCtrl* m_DialogWin; private: - WinEDA_MainFrame* m_Parent; + KICAD_MANAGER_FRAME* m_Parent; int m_ButtonsPanelHeight; wxPanel* m_ButtPanel; int m_ButtonSeparation; // button distance in pixels @@ -153,7 +153,7 @@ private: wxPoint m_ButtonLastPosition; // position of the last button in the window public: - RIGHT_KM_FRAME( WinEDA_MainFrame* parent ); + RIGHT_KM_FRAME( KICAD_MANAGER_FRAME* parent ); ~RIGHT_KM_FRAME() { }; void OnSize( wxSizeEvent& event ); diff --git a/kicad/mainframe.cpp b/kicad/mainframe.cpp index 3f95495fba..c51ed7c506 100644 --- a/kicad/mainframe.cpp +++ b/kicad/mainframe.cpp @@ -1,5 +1,5 @@ /***********************************************************/ -/* mdiframe.cpp - WinEDA_MainFrame is the kicad main frame */ +/* mdiframe.cpp - KICAD_MANAGER_FRAME is the kicad main frame */ /***********************************************************/ #ifdef __GNUG__ @@ -21,7 +21,7 @@ static const wxString TreeFrameWidthEntry( wxT( "LeftWinWidth" ) ); -WinEDA_MainFrame::WinEDA_MainFrame( wxWindow* parent, +KICAD_MANAGER_FRAME::KICAD_MANAGER_FRAME( wxWindow* parent, const wxString& title, const wxPoint& pos, const wxSize& size ) : @@ -99,7 +99,7 @@ WinEDA_MainFrame::WinEDA_MainFrame( wxWindow* parent, } -WinEDA_MainFrame::~WinEDA_MainFrame() +KICAD_MANAGER_FRAME::~KICAD_MANAGER_FRAME() { m_auimgr.UnInit(); } @@ -108,7 +108,7 @@ WinEDA_MainFrame::~WinEDA_MainFrame() /* * Put text in the dialog frame */ -void WinEDA_MainFrame::PrintMsg( const wxString& text ) +void KICAD_MANAGER_FRAME::PrintMsg( const wxString& text ) { m_RightWin->m_DialogWin->AppendText( text ); } @@ -116,13 +116,13 @@ void WinEDA_MainFrame::PrintMsg( const wxString& text ) /* Resize windows when dragging window borders */ -void WinEDA_MainFrame::OnSashDrag( wxSashEvent& event ) +void KICAD_MANAGER_FRAME::OnSashDrag( wxSashEvent& event ) { event.Skip(); } -void WinEDA_MainFrame::OnSize( wxSizeEvent& event ) +void KICAD_MANAGER_FRAME::OnSize( wxSizeEvent& event ) { if( m_auimgr.GetManagedWindow() ) m_auimgr.Update(); @@ -131,7 +131,7 @@ void WinEDA_MainFrame::OnSize( wxSizeEvent& event ) } -void WinEDA_MainFrame::OnCloseWindow( wxCloseEvent& Event ) +void KICAD_MANAGER_FRAME::OnCloseWindow( wxCloseEvent& Event ) { int px, py; @@ -166,18 +166,18 @@ void WinEDA_MainFrame::OnCloseWindow( wxCloseEvent& Event ) } -void WinEDA_MainFrame::OnExit( wxCommandEvent& event ) +void KICAD_MANAGER_FRAME::OnExit( wxCommandEvent& event ) { Close( true ); } -void WinEDA_MainFrame::OnRunBitmapConverter( wxCommandEvent& event ) +void KICAD_MANAGER_FRAME::OnRunBitmapConverter( wxCommandEvent& event ) { ExecuteFile( this, BITMAPCONVERTER_EXE, wxEmptyString ); } -void WinEDA_MainFrame::OnRunPcbNew( wxCommandEvent& event ) +void KICAD_MANAGER_FRAME::OnRunPcbNew( wxCommandEvent& event ) { wxFileName fn( m_ProjectFileName ); @@ -186,7 +186,7 @@ void WinEDA_MainFrame::OnRunPcbNew( wxCommandEvent& event ) } -void WinEDA_MainFrame::OnRunCvpcb( wxCommandEvent& event ) +void KICAD_MANAGER_FRAME::OnRunCvpcb( wxCommandEvent& event ) { wxFileName fn( m_ProjectFileName ); @@ -195,7 +195,7 @@ void WinEDA_MainFrame::OnRunCvpcb( wxCommandEvent& event ) } -void WinEDA_MainFrame::OnRunEeschema( wxCommandEvent& event ) +void KICAD_MANAGER_FRAME::OnRunEeschema( wxCommandEvent& event ) { wxFileName fn( m_ProjectFileName ); @@ -204,7 +204,7 @@ void WinEDA_MainFrame::OnRunEeschema( wxCommandEvent& event ) } -void WinEDA_MainFrame::OnRunGerbview( wxCommandEvent& event ) +void KICAD_MANAGER_FRAME::OnRunGerbview( wxCommandEvent& event ) { wxFileName fn( m_ProjectFileName ); wxString path = wxT("\""); @@ -214,7 +214,7 @@ void WinEDA_MainFrame::OnRunGerbview( wxCommandEvent& event ) } -void WinEDA_MainFrame::OnOpenTextEditor( wxCommandEvent& event ) +void KICAD_MANAGER_FRAME::OnOpenTextEditor( wxCommandEvent& event ) { wxString editorname = wxGetApp().GetEditorName(); @@ -223,7 +223,7 @@ void WinEDA_MainFrame::OnOpenTextEditor( wxCommandEvent& event ) } -void WinEDA_MainFrame::OnOpenFileInTextEditor( wxCommandEvent& event ) +void KICAD_MANAGER_FRAME::OnOpenFileInTextEditor( wxCommandEvent& event ) { wxString mask( wxT( "*" ) ); @@ -246,13 +246,13 @@ void WinEDA_MainFrame::OnOpenFileInTextEditor( wxCommandEvent& event ) } -void WinEDA_MainFrame::OnRefresh( wxCommandEvent& event ) +void KICAD_MANAGER_FRAME::OnRefresh( wxCommandEvent& event ) { m_LeftWin->ReCreateTreePrj(); } -void WinEDA_MainFrame::ClearMsg() +void KICAD_MANAGER_FRAME::ClearMsg() { m_RightWin->m_DialogWin->Clear(); } @@ -264,7 +264,7 @@ void WinEDA_MainFrame::ClearMsg() * Don't forget to call this base method from any derived classes or the * settings will not get loaded. */ -void WinEDA_MainFrame::LoadSettings() +void KICAD_MANAGER_FRAME::LoadSettings() { wxASSERT( wxGetApp().m_EDA_Config != NULL ); @@ -281,7 +281,7 @@ void WinEDA_MainFrame::LoadSettings() * Don't forget to call this base method from any derived classes or the * settings will not get saved. */ -void WinEDA_MainFrame::SaveSettings() +void KICAD_MANAGER_FRAME::SaveSettings() { wxASSERT( wxGetApp().m_EDA_Config != NULL ); @@ -291,4 +291,3 @@ void WinEDA_MainFrame::SaveSettings() cfg->Write( TreeFrameWidthEntry, m_LeftWin->GetSize().x ); } - diff --git a/kicad/menubar.cpp b/kicad/menubar.cpp index b72df77ec6..23f4269be6 100644 --- a/kicad/menubar.cpp +++ b/kicad/menubar.cpp @@ -10,49 +10,49 @@ #include "bitmaps.h" /* Menubar and toolbar event table */ -BEGIN_EVENT_TABLE( WinEDA_MainFrame, EDA_BASE_FRAME ) +BEGIN_EVENT_TABLE( KICAD_MANAGER_FRAME, EDA_BASE_FRAME ) /* Window events */ - EVT_SIZE( WinEDA_MainFrame::OnSize ) - EVT_CLOSE( WinEDA_MainFrame::OnCloseWindow ) + EVT_SIZE( KICAD_MANAGER_FRAME::OnSize ) + EVT_CLOSE( KICAD_MANAGER_FRAME::OnCloseWindow ) /* Sash drag events */ - EVT_SASH_DRAGGED( ID_LEFT_FRAME, WinEDA_MainFrame::OnSashDrag ) + EVT_SASH_DRAGGED( ID_LEFT_FRAME, KICAD_MANAGER_FRAME::OnSashDrag ) /* Toolbar events */ - EVT_TOOL( ID_NEW_PROJECT, WinEDA_MainFrame::OnLoadProject ) - EVT_TOOL( ID_LOAD_PROJECT, WinEDA_MainFrame::OnLoadProject ) - EVT_TOOL( ID_SAVE_PROJECT, WinEDA_MainFrame::OnSaveProject ) - EVT_TOOL( ID_SAVE_AND_ZIP_FILES, WinEDA_MainFrame::OnArchiveFiles ) + EVT_TOOL( ID_NEW_PROJECT, KICAD_MANAGER_FRAME::OnLoadProject ) + EVT_TOOL( ID_LOAD_PROJECT, KICAD_MANAGER_FRAME::OnLoadProject ) + EVT_TOOL( ID_SAVE_PROJECT, KICAD_MANAGER_FRAME::OnSaveProject ) + EVT_TOOL( ID_SAVE_AND_ZIP_FILES, KICAD_MANAGER_FRAME::OnArchiveFiles ) /* Menu events */ - EVT_MENU( ID_SAVE_PROJECT, WinEDA_MainFrame::OnSaveProject ) - EVT_MENU( wxID_EXIT, WinEDA_MainFrame::OnExit ) - EVT_MENU( ID_TO_EDITOR, WinEDA_MainFrame::OnOpenTextEditor ) - EVT_MENU( ID_BROWSE_AN_SELECT_FILE, WinEDA_MainFrame::OnOpenFileInTextEditor ) + EVT_MENU( ID_SAVE_PROJECT, KICAD_MANAGER_FRAME::OnSaveProject ) + EVT_MENU( wxID_EXIT, KICAD_MANAGER_FRAME::OnExit ) + EVT_MENU( ID_TO_EDITOR, KICAD_MANAGER_FRAME::OnOpenTextEditor ) + EVT_MENU( ID_BROWSE_AN_SELECT_FILE, KICAD_MANAGER_FRAME::OnOpenFileInTextEditor ) EVT_MENU( ID_SELECT_PREFERED_EDITOR, EDA_BASE_FRAME::OnSelectPreferredEditor ) - EVT_MENU( ID_SELECT_DEFAULT_PDF_BROWSER, WinEDA_MainFrame::OnSelectDefaultPdfBrowser ) - EVT_MENU( ID_SELECT_PREFERED_PDF_BROWSER, WinEDA_MainFrame::OnSelectPreferredPdfBrowser ) - EVT_MENU( ID_SELECT_PREFERED_PDF_BROWSER_NAME, WinEDA_MainFrame::OnSelectPreferredPdfBrowser ) - EVT_MENU( ID_SAVE_AND_ZIP_FILES, WinEDA_MainFrame::OnArchiveFiles ) - EVT_MENU( ID_READ_ZIP_ARCHIVE, WinEDA_MainFrame::OnUnarchiveFiles ) - EVT_MENU( ID_PROJECT_TREE_REFRESH, WinEDA_MainFrame::OnRefresh ) - EVT_MENU( ID_GENERAL_HELP, WinEDA_MainFrame::GetKicadHelp ) - EVT_MENU( wxID_ABOUT, WinEDA_MainFrame::GetKicadAbout ) + EVT_MENU( ID_SELECT_DEFAULT_PDF_BROWSER, KICAD_MANAGER_FRAME::OnSelectDefaultPdfBrowser ) + EVT_MENU( ID_SELECT_PREFERED_PDF_BROWSER, KICAD_MANAGER_FRAME::OnSelectPreferredPdfBrowser ) + EVT_MENU( ID_SELECT_PREFERED_PDF_BROWSER_NAME, KICAD_MANAGER_FRAME::OnSelectPreferredPdfBrowser ) + EVT_MENU( ID_SAVE_AND_ZIP_FILES, KICAD_MANAGER_FRAME::OnArchiveFiles ) + EVT_MENU( ID_READ_ZIP_ARCHIVE, KICAD_MANAGER_FRAME::OnUnarchiveFiles ) + EVT_MENU( ID_PROJECT_TREE_REFRESH, KICAD_MANAGER_FRAME::OnRefresh ) + EVT_MENU( wxID_HELP, KICAD_MANAGER_FRAME::GetKicadHelp ) + EVT_MENU( wxID_ABOUT, KICAD_MANAGER_FRAME::GetKicadAbout ) /* Range menu events */ - EVT_MENU_RANGE( ID_LANGUAGE_CHOICE, ID_LANGUAGE_CHOICE_END, WinEDA_MainFrame::SetLanguage ) + EVT_MENU_RANGE( ID_LANGUAGE_CHOICE, ID_LANGUAGE_CHOICE_END, KICAD_MANAGER_FRAME::SetLanguage ) - EVT_MENU_RANGE( wxID_FILE1, wxID_FILE9, WinEDA_MainFrame::OnFileHistory ) + EVT_MENU_RANGE( wxID_FILE1, wxID_FILE9, KICAD_MANAGER_FRAME::OnFileHistory ) /* Button events */ - EVT_BUTTON( ID_TO_PCB, WinEDA_MainFrame::OnRunPcbNew ) - EVT_BUTTON( ID_TO_CVPCB, WinEDA_MainFrame::OnRunCvpcb ) - EVT_BUTTON( ID_TO_EESCHEMA, WinEDA_MainFrame::OnRunEeschema ) - EVT_BUTTON( ID_TO_GERBVIEW, WinEDA_MainFrame::OnRunGerbview ) - EVT_BUTTON( ID_TO_BITMAP_CONVERTER, WinEDA_MainFrame::OnRunBitmapConverter ) + EVT_BUTTON( ID_TO_PCB, KICAD_MANAGER_FRAME::OnRunPcbNew ) + EVT_BUTTON( ID_TO_CVPCB, KICAD_MANAGER_FRAME::OnRunCvpcb ) + EVT_BUTTON( ID_TO_EESCHEMA, KICAD_MANAGER_FRAME::OnRunEeschema ) + EVT_BUTTON( ID_TO_GERBVIEW, KICAD_MANAGER_FRAME::OnRunGerbview ) + EVT_BUTTON( ID_TO_BITMAP_CONVERTER, KICAD_MANAGER_FRAME::OnRunBitmapConverter ) - EVT_UPDATE_UI( ID_SELECT_DEFAULT_PDF_BROWSER, WinEDA_MainFrame::OnUpdateDefaultPdfBrowser ) - EVT_UPDATE_UI( ID_SELECT_PREFERED_PDF_BROWSER, WinEDA_MainFrame::OnUpdatePreferredPdfBrowser ) + EVT_UPDATE_UI( ID_SELECT_DEFAULT_PDF_BROWSER, KICAD_MANAGER_FRAME::OnUpdateDefaultPdfBrowser ) + EVT_UPDATE_UI( ID_SELECT_PREFERED_PDF_BROWSER, KICAD_MANAGER_FRAME::OnUpdatePreferredPdfBrowser ) END_EVENT_TABLE() @@ -60,7 +60,7 @@ END_EVENT_TABLE() /** * @brief (Re)Create the menubar */ -void WinEDA_MainFrame::ReCreateMenuBar() +void KICAD_MANAGER_FRAME::ReCreateMenuBar() { // Create and try to get the current menubar wxMenuItem* item; @@ -88,8 +88,14 @@ void WinEDA_MainFrame::ReCreateMenuBar() open_project_xpm ); // Open Recent submenu - wxMenu* openRecentMenu = new wxMenu(); - wxGetApp().m_fileHistory.AddFilesToMenu( openRecentMenu ); + static wxMenu* openRecentMenu; + // Add this menu to list menu managed by m_fileHistory + // (the file history will be updated when adding/removing files in history + if( openRecentMenu ) + wxGetApp().m_fileHistory.RemoveMenu( openRecentMenu ); + openRecentMenu = new wxMenu(); + wxGetApp().m_fileHistory.UseMenu( openRecentMenu ); + wxGetApp().m_fileHistory.AddFilesToMenu( ); ADD_MENUITEM_WITH_HELP_AND_SUBMENU( fileMenu, openRecentMenu, wxID_ANY, _( "Open &Recent" ), @@ -217,9 +223,9 @@ void WinEDA_MainFrame::ReCreateMenuBar() // Contents ADD_MENUITEM_WITH_HELP( helpMenu, - ID_GENERAL_HELP, + wxID_HELP, _( "&Contents" ), - _( "Open the kicad manual" ), + _( "Open the Kicad handbook" ), online_help_xpm ); // Separator @@ -251,7 +257,7 @@ void WinEDA_MainFrame::ReCreateMenuBar() /** * @brief (Re)Create the horizontal toolbar */ -void WinEDA_MainFrame::RecreateBaseHToolbar() +void KICAD_MANAGER_FRAME::RecreateBaseHToolbar() { // Check if toolbar is not already created if( m_HToolBar != NULL ) diff --git a/kicad/preferences.cpp b/kicad/preferences.cpp index a7600dc5fe..56c6d84cf4 100644 --- a/kicad/preferences.cpp +++ b/kicad/preferences.cpp @@ -18,26 +18,26 @@ #include -void WinEDA_MainFrame::OnUpdateDefaultPdfBrowser( wxUpdateUIEvent& event ) +void KICAD_MANAGER_FRAME::OnUpdateDefaultPdfBrowser( wxUpdateUIEvent& event ) { event.Check( wxGetApp().m_PdfBrowserIsDefault ); } -void WinEDA_MainFrame::OnSelectDefaultPdfBrowser( wxCommandEvent& event ) +void KICAD_MANAGER_FRAME::OnSelectDefaultPdfBrowser( wxCommandEvent& event ) { wxGetApp().m_PdfBrowserIsDefault = true; wxGetApp().WritePdfBrowserInfos(); } -void WinEDA_MainFrame::OnUpdatePreferredPdfBrowser( wxUpdateUIEvent& event ) +void KICAD_MANAGER_FRAME::OnUpdatePreferredPdfBrowser( wxUpdateUIEvent& event ) { event.Check( !wxGetApp().m_PdfBrowserIsDefault ); } -void WinEDA_MainFrame::OnSelectPreferredPdfBrowser( wxCommandEvent& event ) +void KICAD_MANAGER_FRAME::OnSelectPreferredPdfBrowser( wxCommandEvent& event ) { bool select = event.GetId() == ID_SELECT_PREFERED_PDF_BROWSER_NAME; @@ -69,7 +69,7 @@ void WinEDA_MainFrame::OnSelectPreferredPdfBrowser( wxCommandEvent& event ) wxGetApp().WritePdfBrowserInfos(); } -void WinEDA_MainFrame::SetLanguage( wxCommandEvent& event ) +void KICAD_MANAGER_FRAME::SetLanguage( wxCommandEvent& event ) { EDA_BASE_FRAME::SetLanguage( event ); } diff --git a/kicad/prjconfig.cpp b/kicad/prjconfig.cpp index 56b6aae275..b5df8a7a91 100644 --- a/kicad/prjconfig.cpp +++ b/kicad/prjconfig.cpp @@ -21,7 +21,7 @@ static const wxString SchematicRootNameEntry( wxT( "RootSch" ) ); static const wxString BoardFileNameEntry( wxT( "BoardNm" ) ); -void WinEDA_MainFrame::CreateNewProject( const wxString PrjFullFileName ) +void KICAD_MANAGER_FRAME::CreateNewProject( const wxString PrjFullFileName ) { wxString filename; wxFileName newProjectName = PrjFullFileName; @@ -59,7 +59,7 @@ void WinEDA_MainFrame::CreateNewProject( const wxString PrjFullFileName ) /** * Loading a new project */ -void WinEDA_MainFrame::OnLoadProject( wxCommandEvent& event ) +void KICAD_MANAGER_FRAME::OnLoadProject( wxCommandEvent& event ) { int style; wxString title; @@ -78,7 +78,6 @@ void WinEDA_MainFrame::OnLoadProject( wxCommandEvent& event ) style = wxFD_OPEN | wxFD_FILE_MUST_EXIST; } - UpdateFileHistory( m_ProjectFileName.GetFullPath() ); wxFileDialog dlg( this, title, wxGetCwd(), wxEmptyString, ProjectFileWildcard, style ); @@ -98,8 +97,6 @@ void WinEDA_MainFrame::OnLoadProject( wxCommandEvent& event ) } CreateNewProject( m_ProjectFileName.GetFullPath() ); } - - UpdateFileHistory( m_ProjectFileName.GetFullPath() ); } wxLogDebug( wxT( "Loading Kicad project file: " ) + @@ -136,7 +133,7 @@ void WinEDA_MainFrame::OnLoadProject( wxCommandEvent& event ) /** * Save the project top level configuration parameters. */ -void WinEDA_MainFrame::OnSaveProject( wxCommandEvent& event ) +void KICAD_MANAGER_FRAME::OnSaveProject( wxCommandEvent& event ) { wxString fn; diff --git a/kicad/tree_project_frame.cpp b/kicad/tree_project_frame.cpp index 2d9b08244e..2058188df2 100644 --- a/kicad/tree_project_frame.cpp +++ b/kicad/tree_project_frame.cpp @@ -94,7 +94,7 @@ END_EVENT_TABLE() /******************************************************************/ -TREE_PROJECT_FRAME::TREE_PROJECT_FRAME( WinEDA_MainFrame* parent ) : +TREE_PROJECT_FRAME::TREE_PROJECT_FRAME( KICAD_MANAGER_FRAME* parent ) : wxSashLayoutWindow( parent, ID_LEFT_FRAME, wxDefaultPosition, diff --git a/kicad/tree_project_frame.h b/kicad/tree_project_frame.h index 7d267c83b6..c1eab4ad5c 100644 --- a/kicad/tree_project_frame.h +++ b/kicad/tree_project_frame.h @@ -66,7 +66,7 @@ protected: TREEPROJECT_ITEM* GetItemIdData(wxTreeItemId aId); public: - WinEDA_MainFrame* m_Parent; + KICAD_MANAGER_FRAME* m_Parent; TREEPROJECTFILES* m_TreeProject; wxTreeItemId m_root; @@ -75,7 +75,7 @@ public: static wxString GetFileExt( TreeFileType type ); static wxString GetFileWildcard( TreeFileType type ); - TREE_PROJECT_FRAME( WinEDA_MainFrame* parent ); + TREE_PROJECT_FRAME( KICAD_MANAGER_FRAME* parent ); ~TREE_PROJECT_FRAME(); void OnSelect( wxTreeEvent& Event ); void OnExpand( wxTreeEvent& Event ); diff --git a/pcbnew/menubar_modedit.cpp b/pcbnew/menubar_modedit.cpp index 20fe3f6388..3bb57649bb 100644 --- a/pcbnew/menubar_modedit.cpp +++ b/pcbnew/menubar_modedit.cpp @@ -304,9 +304,9 @@ void WinEDA_ModuleEditFrame::ReCreateMenuBar() // Contents item = new wxMenuItem( helpMenu, - ID_GENERAL_HELP, + wxID_HELP, _( "&Contents" ), - _( "Open the PCBNew manual" ) ); + _( "Open the PCBNew handbook" ) ); SET_BITMAP( online_help_xpm ); helpMenu->Append( item ); diff --git a/pcbnew/menubar_pcbframe.cpp b/pcbnew/menubar_pcbframe.cpp index 386c1efb88..2f39eedb23 100644 --- a/pcbnew/menubar_pcbframe.cpp +++ b/pcbnew/menubar_pcbframe.cpp @@ -53,8 +53,14 @@ void PCB_EDIT_FRAME::ReCreateMenuBar() filesMenu->Append( item ); // Load Recent submenu - wxMenu* openRecentMenu = new wxMenu(); - wxGetApp().m_fileHistory.AddFilesToMenu( openRecentMenu ); + static wxMenu* openRecentMenu; + // Add this menu to list menu managed by m_fileHistory + // (the file history will be updated when adding/removing files in history + if( openRecentMenu ) + wxGetApp().m_fileHistory.RemoveMenu( openRecentMenu ); + openRecentMenu = new wxMenu(); + wxGetApp().m_fileHistory.UseMenu( openRecentMenu ); + wxGetApp().m_fileHistory.AddFilesToMenu(); ADD_MENUITEM_WITH_HELP_AND_SUBMENU( filesMenu, openRecentMenu, -1, _( "Open &Recent" ), _( "Open a recent opened board" ), @@ -599,9 +605,9 @@ void PCB_EDIT_FRAME::ReCreateMenuBar() AddHelpVersionInfoMenuEntry( helpMenu ); // Contents - item = new wxMenuItem( helpMenu, ID_GENERAL_HELP, + item = new wxMenuItem( helpMenu, wxID_HELP, _( "&Contents" ), - _( "Open the on line PCBnew documentation" ) ); + _( "Open the PCBNew handbook" ) ); SET_BITMAP( online_help_xpm ); helpMenu->Append( item ); diff --git a/pcbnew/pcbframe.cpp b/pcbnew/pcbframe.cpp index eb1611565f..5ecf90b2e4 100644 --- a/pcbnew/pcbframe.cpp +++ b/pcbnew/pcbframe.cpp @@ -139,7 +139,7 @@ BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME ) PCB_EDIT_FRAME::Process_Special_Functions ) // Menu Help - EVT_MENU( ID_GENERAL_HELP, EDA_DRAW_FRAME::GetKicadHelp ) + EVT_MENU( wxID_HELP, EDA_DRAW_FRAME::GetKicadHelp ) EVT_MENU( wxID_ABOUT, EDA_BASE_FRAME::GetKicadAbout ) // Menu 3D Frame diff --git a/pcbnew/pcbnew_id.h b/pcbnew/pcbnew_id.h index e78440cb7d..ad86a69660 100644 --- a/pcbnew/pcbnew_id.h +++ b/pcbnew/pcbnew_id.h @@ -223,7 +223,13 @@ enum pcbnew_ids ID_MENU_PCB_SWAP_LAYERS, ID_MENU_PCB_RESET_TEXTMODULE_REFERENCE_SIZES, ID_MENU_PCB_RESET_TEXTMODULE_VALUE_SIZES, + ID_GEN_EXPORT_FILE_VRML, + ID_GEN_EXPORT_SPECCTRA, + ID_GEN_EXPORT_FILE_GENCADFORMAT, + ID_GEN_EXPORT_FILE_MODULE_REPORT, + ID_GEN_IMPORT_SPECCTRA_SESSION, + ID_GEN_IMPORT_SPECCTRA_DESIGN, ID_TOOLBARH_PCB_MODE_MODULE, ID_TOOLBARH_PCB_MODE_TRACKS,