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.

247 lines
9.1 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
  5. * Copyright (C) 2015 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
  6. * Copyright (C) 2015 Wayne Stambaugh <stambaughw@gmail.com>
  7. * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; either version 2
  12. * of the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, you may find one here:
  21. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  22. * or you may search the http://www.gnu.org website for the version 2 license,
  23. * or you may write to the Free Software Foundation, Inc.,
  24. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  25. */
  26. #include "footprint_edit_frame.h"
  27. #include "pcbnew_id.h"
  28. #include <bitmaps.h>
  29. #include <tool/actions.h>
  30. #include <tool/action_menu.h>
  31. #include <tool/tool_manager.h>
  32. #include <tools/pcb_actions.h>
  33. #include <tools/pcb_selection_tool.h>
  34. #include <widgets/wx_menubar.h>
  35. void FOOTPRINT_EDIT_FRAME::doReCreateMenuBar()
  36. {
  37. PCB_SELECTION_TOOL* selTool = m_toolManager->GetTool<PCB_SELECTION_TOOL>();
  38. // wxWidgets handles the Mac Application menu behind the scenes, but that means
  39. // we always have to start from scratch with a new wxMenuBar.
  40. wxMenuBar* oldMenuBar = GetMenuBar();
  41. WX_MENUBAR* menuBar = new WX_MENUBAR();
  42. //-- File menu ----------------------------------------------------------
  43. //
  44. ACTION_MENU* fileMenu = new ACTION_MENU( false, selTool );
  45. fileMenu->Add( ACTIONS::newLibrary );
  46. fileMenu->Add( ACTIONS::addLibrary );
  47. fileMenu->Add( PCB_ACTIONS::newFootprint );
  48. fileMenu->Add( PCB_ACTIONS::createFootprint );
  49. fileMenu->Add( PCB_ACTIONS::editLibFpInFpEditor );
  50. fileMenu->AppendSeparator();
  51. fileMenu->Add( ACTIONS::save );
  52. fileMenu->Add( ACTIONS::saveAs );
  53. fileMenu->Add( ACTIONS::revert );
  54. fileMenu->AppendSeparator();
  55. ACTION_MENU* submenuImport = new ACTION_MENU( false, selTool );
  56. submenuImport->SetTitle( _( "Import" ) );
  57. submenuImport->SetIcon( BITMAPS::import );
  58. submenuImport->Add( PCB_ACTIONS::importFootprint, ACTION_MENU::NORMAL, _( "Footprint..." ) );
  59. submenuImport->Add( PCB_ACTIONS::placeImportedGraphics, ACTION_MENU::NORMAL, _( "Graphics..." ) );
  60. fileMenu->Add( submenuImport );
  61. ACTION_MENU* submenuExport = new ACTION_MENU( false, selTool );
  62. submenuExport->SetTitle( _( "Export" ) );
  63. submenuExport->SetIcon( BITMAPS::export_file );
  64. submenuExport->Add( PCB_ACTIONS::exportFootprint, ACTION_MENU::NORMAL, _( "Footprint..." ) );
  65. submenuExport->Add( _( "View as &PNG..." ),
  66. _( "Create a PNG file from the current view" ),
  67. ID_FPEDIT_SAVE_PNG,
  68. BITMAPS::export_png );
  69. fileMenu->Add( submenuExport );
  70. fileMenu->AppendSeparator();
  71. fileMenu->Add( PCB_ACTIONS::footprintProperties );
  72. fileMenu->AppendSeparator();
  73. fileMenu->Add( ACTIONS::print );
  74. fileMenu->AppendSeparator();
  75. fileMenu->AddClose( _( "Footprint Editor" ) );
  76. //-- Edit menu -------------------------------------------------------
  77. //
  78. ACTION_MENU* editMenu = new ACTION_MENU( false, selTool );
  79. editMenu->Add( ACTIONS::undo );
  80. editMenu->Add( ACTIONS::redo );
  81. editMenu->AppendSeparator();
  82. editMenu->Add( ACTIONS::cut );
  83. editMenu->Add( ACTIONS::copy );
  84. editMenu->Add( ACTIONS::paste );
  85. editMenu->Add( ACTIONS::doDelete );
  86. editMenu->Add( ACTIONS::duplicate );
  87. editMenu->AppendSeparator();
  88. editMenu->Add( ACTIONS::selectAll );
  89. editMenu->AppendSeparator();
  90. editMenu->Add( PCB_ACTIONS::editTextAndGraphics );
  91. editMenu->Add( PCB_ACTIONS::defaultPadProperties );
  92. editMenu->Add( PCB_ACTIONS::enumeratePads );
  93. editMenu->Add( ACTIONS::gridOrigin );
  94. //-- View menu -------------------------------------------------------
  95. //
  96. ACTION_MENU* viewMenu = new ACTION_MENU( false, selTool );
  97. ACTION_MENU* showHidePanels = new ACTION_MENU( false, selTool );
  98. showHidePanels->SetTitle( _( "Panels" ) );
  99. showHidePanels->Add( ACTIONS::showProperties, ACTION_MENU::CHECK );
  100. showHidePanels->Add( ACTIONS::showLibraryTree, ACTION_MENU::CHECK );
  101. showHidePanels->Add( PCB_ACTIONS::showLayersManager, ACTION_MENU::CHECK );
  102. viewMenu->Add( showHidePanels );
  103. viewMenu->AppendSeparator();
  104. viewMenu->Add( ACTIONS::showFootprintBrowser );
  105. viewMenu->Add( ACTIONS::show3DViewer );
  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. // Drawing Mode Submenu
  114. ACTION_MENU* drawingModeSubMenu = new ACTION_MENU( false, selTool );
  115. drawingModeSubMenu->SetTitle( _( "&Drawing Mode" ) );
  116. drawingModeSubMenu->SetIcon( BITMAPS::add_zone );
  117. drawingModeSubMenu->Add( PCB_ACTIONS::padDisplayMode, ACTION_MENU::CHECK );
  118. drawingModeSubMenu->Add( PCB_ACTIONS::graphicsOutlines, ACTION_MENU::CHECK );
  119. drawingModeSubMenu->Add( PCB_ACTIONS::textOutlines, ACTION_MENU::CHECK );
  120. viewMenu->Add( drawingModeSubMenu );
  121. // Contrast Mode Submenu
  122. ACTION_MENU* contrastModeSubMenu = new ACTION_MENU( false, selTool );
  123. contrastModeSubMenu->SetTitle( _( "&Contrast Mode" ) );
  124. contrastModeSubMenu->SetIcon( BITMAPS::contrast_mode );
  125. contrastModeSubMenu->Add( ACTIONS::highContrastMode, ACTION_MENU::CHECK );
  126. contrastModeSubMenu->Add( PCB_ACTIONS::layerAlphaDec );
  127. contrastModeSubMenu->Add( PCB_ACTIONS::layerAlphaInc );
  128. viewMenu->Add( contrastModeSubMenu );
  129. viewMenu->Add( PCB_ACTIONS::flipBoard, ACTION_MENU::CHECK );
  130. //-- Place menu -------------------------------------------------------
  131. //
  132. ACTION_MENU* placeMenu = new ACTION_MENU( false, selTool );
  133. placeMenu->Add( PCB_ACTIONS::placePad );
  134. placeMenu->Add( PCB_ACTIONS::drawRuleArea );
  135. placeMenu->AppendSeparator();
  136. placeMenu->Add( PCB_ACTIONS::drawLine );
  137. placeMenu->Add( PCB_ACTIONS::drawArc );
  138. placeMenu->Add( PCB_ACTIONS::drawRectangle );
  139. placeMenu->Add( PCB_ACTIONS::drawCircle );
  140. placeMenu->Add( PCB_ACTIONS::drawPolygon );
  141. placeMenu->Add( PCB_ACTIONS::drawBezier );
  142. placeMenu->Add( PCB_ACTIONS::placeReferenceImage );
  143. placeMenu->Add( PCB_ACTIONS::placeText );
  144. placeMenu->Add( PCB_ACTIONS::drawTextBox );
  145. placeMenu->Add( PCB_ACTIONS::drawTable );
  146. placeMenu->AppendSeparator();
  147. placeMenu->Add( PCB_ACTIONS::drawOrthogonalDimension );
  148. placeMenu->Add( PCB_ACTIONS::drawAlignedDimension );
  149. placeMenu->Add( PCB_ACTIONS::drawCenterDimension );
  150. placeMenu->Add( PCB_ACTIONS::drawRadialDimension );
  151. placeMenu->Add( PCB_ACTIONS::drawLeader );
  152. placeMenu->AppendSeparator();
  153. placeMenu->Add( PCB_ACTIONS::setAnchor );
  154. placeMenu->Add( ACTIONS::gridSetOrigin );
  155. placeMenu->AppendSeparator();
  156. placeMenu->Add( ACTIONS::gridResetOrigin );
  157. //-- Inspect menu ------------------------------------------------------
  158. //
  159. ACTION_MENU* inspectMenu = new ACTION_MENU( false, selTool );
  160. inspectMenu->Add( ACTIONS::measureTool );
  161. inspectMenu->AppendSeparator();
  162. inspectMenu->Add( PCB_ACTIONS::checkFootprint );
  163. inspectMenu->AppendSeparator();
  164. inspectMenu->Add( PCB_ACTIONS::showDatasheet );
  165. //-- Tools menu --------------------------------------------------------
  166. //
  167. ACTION_MENU* toolsMenu = new ACTION_MENU( false, selTool );
  168. toolsMenu->Add( PCB_ACTIONS::loadFpFromBoard );
  169. toolsMenu->Add( PCB_ACTIONS::saveFpToBoard );
  170. toolsMenu->AppendSeparator();
  171. toolsMenu->Add( PCB_ACTIONS::cleanupGraphics );
  172. toolsMenu->Add( PCB_ACTIONS::repairFootprint );
  173. //-- Preferences menu -------------------------------------------------
  174. //
  175. ACTION_MENU* prefsMenu = new ACTION_MENU( false, selTool );
  176. prefsMenu->Add( ACTIONS::configurePaths );
  177. prefsMenu->Add( ACTIONS::showFootprintLibTable );
  178. prefsMenu->Add( ACTIONS::openPreferences );
  179. prefsMenu->AppendSeparator();
  180. AddMenuLanguageList( prefsMenu, selTool );
  181. //--MenuBar -----------------------------------------------------------
  182. //
  183. menuBar->Append( fileMenu, _( "&File" ) );
  184. menuBar->Append( editMenu, _( "&Edit" ) );
  185. menuBar->Append( viewMenu, _( "&View" ) );
  186. menuBar->Append( placeMenu, _( "&Place" ) );
  187. menuBar->Append( inspectMenu, _( "&Inspect" ) );
  188. menuBar->Append( toolsMenu, _( "&Tools" ) );
  189. menuBar->Append( prefsMenu, _( "P&references" ) );
  190. AddStandardHelpMenu( menuBar );
  191. SetMenuBar( menuBar );
  192. delete oldMenuBar;
  193. }