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.

195 lines
7.1 KiB

7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2007 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
  5. * Copyright (C) 2009 Wayne Stambaugh <stambaughw@gmail.com>
  6. * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * as published by the Free Software Foundation; either version 2
  11. * of the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, you may find one here:
  20. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  21. * or you may search the http://www.gnu.org website for the version 2 license,
  22. * or you may write to the Free Software Foundation, Inc.,
  23. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  24. */
  25. #include <bitmaps.h>
  26. #include <tool/action_menu.h>
  27. #include <tool/tool_manager.h>
  28. #include <tools/sch_actions.h>
  29. #include <tools/sch_selection_tool.h>
  30. #include <symbol_library_manager.h>
  31. #include "symbol_edit_frame.h"
  32. #include <widgets/wx_menubar.h>
  33. void SYMBOL_EDIT_FRAME::doReCreateMenuBar()
  34. {
  35. SCH_SELECTION_TOOL* selTool = m_toolManager->GetTool<SCH_SELECTION_TOOL>();
  36. // wxWidgets handles the Mac Application menu behind the scenes, but that means
  37. // we always have to start from scratch with a new wxMenuBar.
  38. wxMenuBar* oldMenuBar = GetMenuBar();
  39. WX_MENUBAR* menuBar = new WX_MENUBAR();
  40. //-- File menu -----------------------------------------------
  41. //
  42. ACTION_MENU* fileMenu = new ACTION_MENU( false, selTool );
  43. fileMenu->Add( ACTIONS::newLibrary );
  44. fileMenu->Add( ACTIONS::addLibrary );
  45. fileMenu->Add( SCH_ACTIONS::saveLibraryAs );
  46. fileMenu->Add( SCH_ACTIONS::newSymbol );
  47. fileMenu->Add( SCH_ACTIONS::editLibSymbolWithLibEdit );
  48. fileMenu->AppendSeparator();
  49. fileMenu->Add( ACTIONS::save );
  50. fileMenu->Add( SCH_ACTIONS::saveSymbolAs );
  51. fileMenu->Add( SCH_ACTIONS::saveSymbolCopyAs );
  52. if( !IsSymbolFromSchematic() )
  53. fileMenu->Add( ACTIONS::saveAll );
  54. fileMenu->Add( ACTIONS::revert );
  55. fileMenu->AppendSeparator();
  56. ACTION_MENU* submenuImport = new ACTION_MENU( false, selTool );
  57. submenuImport->SetTitle( _( "Import" ) );
  58. submenuImport->SetIcon( BITMAPS::import );
  59. submenuImport->Add( SCH_ACTIONS::importSymbol, ACTION_MENU::NORMAL, _( "Symbol..." ) );
  60. submenuImport->Add( SCH_ACTIONS::importGraphics, ACTION_MENU::NORMAL, _( "Graphics..." ) );
  61. fileMenu->Add( submenuImport );
  62. // Export submenu
  63. ACTION_MENU* submenuExport = new ACTION_MENU( false, selTool );
  64. submenuExport->SetTitle( _( "Export" ) );
  65. submenuExport->SetIcon( BITMAPS::export_file );
  66. submenuExport->Add( SCH_ACTIONS::exportSymbol, ACTION_MENU::NORMAL, _( "Symbol..." ) );
  67. submenuExport->Add( SCH_ACTIONS::exportSymbolView, ACTION_MENU::NORMAL, _( "View as PNG..." ) );
  68. submenuExport->Add( SCH_ACTIONS::exportSymbolAsSVG, ACTION_MENU::NORMAL, _( "Symbol as SVG..." ) );
  69. fileMenu->Add( submenuExport );
  70. fileMenu->AppendSeparator();
  71. fileMenu->Add( SCH_ACTIONS::symbolProperties );
  72. fileMenu->AppendSeparator();
  73. fileMenu->AddClose( _( "Library Editor" ) );
  74. //-- Edit menu -----------------------------------------------
  75. //
  76. ACTION_MENU* editMenu = new ACTION_MENU( false, selTool );
  77. editMenu->Add( ACTIONS::undo );
  78. editMenu->Add( ACTIONS::redo );
  79. editMenu->AppendSeparator();
  80. editMenu->Add( ACTIONS::cut );
  81. editMenu->Add( ACTIONS::copy );
  82. editMenu->Add( ACTIONS::copyAsText );
  83. editMenu->Add( ACTIONS::paste );
  84. editMenu->Add( ACTIONS::doDelete );
  85. editMenu->Add( ACTIONS::duplicate );
  86. editMenu->AppendSeparator();
  87. editMenu->Add( ACTIONS::selectAll );
  88. editMenu->Add( ACTIONS::unselectAll );
  89. editMenu->AppendSeparator();
  90. editMenu->Add( ACTIONS::find );
  91. editMenu->Add( ACTIONS::findAndReplace );
  92. editMenu->AppendSeparator();
  93. editMenu->Add( SCH_ACTIONS::pinTable );
  94. editMenu->Add( SCH_ACTIONS::setUnitDisplayName );
  95. editMenu->Add( SCH_ACTIONS::updateSymbolFields );
  96. //-- View menu -----------------------------------------------
  97. //
  98. ACTION_MENU* viewMenu = new ACTION_MENU( false, selTool );
  99. ACTION_MENU* showHidePanels = new ACTION_MENU( false, selTool );
  100. showHidePanels->SetTitle( _( "Panels" ) );
  101. showHidePanels->Add( ACTIONS::showProperties, ACTION_MENU::CHECK );
  102. showHidePanels->Add( ACTIONS::showLibraryTree, ACTION_MENU::CHECK );
  103. viewMenu->Add( showHidePanels );
  104. viewMenu->AppendSeparator();
  105. viewMenu->Add( ACTIONS::showSymbolBrowser );
  106. viewMenu->AppendSeparator();
  107. viewMenu->Add( ACTIONS::zoomInCenter );
  108. viewMenu->Add( ACTIONS::zoomOutCenter );
  109. viewMenu->Add( ACTIONS::zoomFitScreen );
  110. viewMenu->Add( ACTIONS::zoomTool );
  111. viewMenu->Add( ACTIONS::zoomRedraw );
  112. viewMenu->AppendSeparator();
  113. viewMenu->Add( SCH_ACTIONS::showHiddenPins, ACTION_MENU::CHECK );
  114. viewMenu->Add( SCH_ACTIONS::showHiddenFields, ACTION_MENU::CHECK );
  115. viewMenu->Add( SCH_ACTIONS::togglePinAltIcons, ACTION_MENU::CHECK );
  116. //-- Place menu -----------------------------------------------
  117. //
  118. ACTION_MENU* placeMenu = new ACTION_MENU( false, selTool );
  119. placeMenu->Add( SCH_ACTIONS::placeSymbolPin );
  120. placeMenu->Add( SCH_ACTIONS::placeSymbolText );
  121. placeMenu->Add( SCH_ACTIONS::drawSymbolTextBox );
  122. placeMenu->Add( SCH_ACTIONS::drawRectangle );
  123. placeMenu->Add( SCH_ACTIONS::drawCircle );
  124. placeMenu->Add( SCH_ACTIONS::drawArc );
  125. placeMenu->Add( SCH_ACTIONS::drawBezier );
  126. placeMenu->Add( SCH_ACTIONS::drawSymbolLines );
  127. placeMenu->Add( SCH_ACTIONS::drawSymbolPolygon );
  128. //-- Inspect menu -----------------------------------------------
  129. //
  130. ACTION_MENU* inspectMenu = new ACTION_MENU( false, selTool );
  131. inspectMenu->Add( ACTIONS::showDatasheet );
  132. inspectMenu->AppendSeparator();
  133. inspectMenu->Add( SCH_ACTIONS::checkSymbol );
  134. //-- Preferences menu -----------------------------------------------
  135. //
  136. ACTION_MENU* prefsMenu = new ACTION_MENU( false, selTool );
  137. prefsMenu->Add( ACTIONS::configurePaths );
  138. prefsMenu->Add( ACTIONS::showSymbolLibTable );
  139. prefsMenu->Add( ACTIONS::openPreferences );
  140. prefsMenu->AppendSeparator();
  141. AddMenuLanguageList( prefsMenu, selTool );
  142. //-- Menubar -------------------------------------------------------------
  143. //
  144. menuBar->Append( fileMenu, _( "&File" ) );
  145. menuBar->Append( editMenu, _( "&Edit" ) );
  146. menuBar->Append( viewMenu, _( "&View" ) );
  147. menuBar->Append( placeMenu, _( "&Place" ) );
  148. menuBar->Append( inspectMenu, _( "&Inspect" ) );
  149. menuBar->Append( prefsMenu, _( "P&references" ) );
  150. AddStandardHelpMenu( menuBar );
  151. SetMenuBar( menuBar );
  152. delete oldMenuBar;
  153. }