You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

99 lines
3.6 KiB

6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
  5. * Copyright (C) 2004-2019 KiCad Developers, see AUTHORS.txt for contributors.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version 2
  10. * of the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, you may find one here:
  19. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  20. * or you may search the http://www.gnu.org website for the version 2 license,
  21. * or you may write to the Free Software Foundation, Inc.,
  22. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  23. */
  24. #include <bitmaps.h>
  25. #include <menus_helpers.h>
  26. #include <pgm_base.h>
  27. #include <tool/actions.h>
  28. #include <tool/common_control.h>
  29. #include <tool/conditional_menu.h>
  30. #include <tool/tool_manager.h>
  31. #include <cvpcb_id.h>
  32. #include <cvpcb_mainframe.h>
  33. #include <tools/cvpcb_actions.h>
  34. void CVPCB_MAINFRAME::ReCreateMenuBar()
  35. {
  36. COMMON_CONTROL* tool = m_toolManager->GetTool<COMMON_CONTROL>();
  37. // wxWidgets handles the Mac Application menu behind the scenes, but that means
  38. // we always have to start from scratch with a new wxMenuBar.
  39. wxMenuBar* oldMenuBar = GetMenuBar();
  40. wxMenuBar* menuBar = new wxMenuBar();
  41. //-- File menu -----------------------------------------------------------
  42. //
  43. CONDITIONAL_MENU* fileMenu = new CONDITIONAL_MENU( false, tool );
  44. fileMenu->AddItem( CVPCB_ACTIONS::saveAssociations, SELECTION_CONDITIONS::ShowAlways );
  45. fileMenu->Resolve();
  46. //-- Preferences menu -----------------------------------------------
  47. //
  48. CONDITIONAL_MENU* editMenu = new CONDITIONAL_MENU( false, tool );
  49. auto enableUndoCondition = [ this ] ( const SELECTION& sel )
  50. {
  51. return m_undoList.size() > 0;
  52. };
  53. auto enableRedoCondition = [ this ] ( const SELECTION& sel )
  54. {
  55. return m_redoList.size() > 0;
  56. };
  57. editMenu->AddItem( ACTIONS::undo, enableUndoCondition );
  58. editMenu->AddItem( ACTIONS::redo, enableRedoCondition );
  59. editMenu->Resolve();
  60. //-- Preferences menu -----------------------------------------------
  61. //
  62. CONDITIONAL_MENU* prefsMenu = new CONDITIONAL_MENU( false, tool );
  63. prefsMenu->AddItem( ACTIONS::configurePaths, SELECTION_CONDITIONS::ShowAlways );
  64. prefsMenu->AddItem( ACTIONS::showFootprintLibTable, SELECTION_CONDITIONS::ShowAlways );
  65. prefsMenu->AddItem( wxID_PREFERENCES,
  66. _( "Preferences...\tCTRL+," ),
  67. _( "Show preferences for all open tools" ),
  68. preference_xpm, SELECTION_CONDITIONS::ShowAlways );
  69. prefsMenu->AddSeparator();
  70. prefsMenu->AddItem( CVPCB_ACTIONS::showEquFileTable, SELECTION_CONDITIONS::ShowAlways );
  71. prefsMenu->AddSeparator();
  72. AddMenuLanguageList( prefsMenu, tool );
  73. prefsMenu->Resolve();
  74. //-- Menubar -------------------------------------------------------------
  75. //
  76. menuBar->Append( fileMenu, _( "&File" ) );
  77. menuBar->Append( editMenu, _( "&Edit" ) );
  78. menuBar->Append( prefsMenu, _( "&Preferences" ) );
  79. AddStandardHelpMenu( menuBar );
  80. SetMenuBar( menuBar );
  81. delete oldMenuBar;
  82. }