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.

258 lines
9.5 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. // Select Submenu
  89. ACTION_MENU* selectSubMenu = new ACTION_MENU( false, selTool );
  90. selectSubMenu->SetTitle( _( "&Select" ) );
  91. selectSubMenu->Add( ACTIONS::selectAll );
  92. selectSubMenu->Add( ACTIONS::unselectAll );
  93. editMenu->Add( selectSubMenu );
  94. editMenu->AppendSeparator();
  95. editMenu->Add( PCB_ACTIONS::editTextAndGraphics );
  96. editMenu->Add( PCB_ACTIONS::padTable );
  97. editMenu->Add( PCB_ACTIONS::defaultPadProperties );
  98. editMenu->Add( PCB_ACTIONS::enumeratePads );
  99. editMenu->Add( ACTIONS::gridOrigin );
  100. //-- View menu -------------------------------------------------------
  101. //
  102. ACTION_MENU* viewMenu = new ACTION_MENU( false, selTool );
  103. ACTION_MENU* showHidePanels = new ACTION_MENU( false, selTool );
  104. showHidePanels->SetTitle( _( "Panels" ) );
  105. showHidePanels->Add( ACTIONS::showProperties, ACTION_MENU::CHECK );
  106. showHidePanels->Add( ACTIONS::showLibraryTree, ACTION_MENU::CHECK );
  107. showHidePanels->Add( PCB_ACTIONS::showLayersManager, ACTION_MENU::CHECK );
  108. viewMenu->Add( showHidePanels );
  109. viewMenu->AppendSeparator();
  110. viewMenu->Add( ACTIONS::showFootprintBrowser );
  111. viewMenu->Add( ACTIONS::show3DViewer );
  112. viewMenu->AppendSeparator();
  113. viewMenu->Add( ACTIONS::zoomInCenter );
  114. viewMenu->Add( ACTIONS::zoomOutCenter );
  115. viewMenu->Add( ACTIONS::zoomFitScreen );
  116. viewMenu->Add( ACTIONS::zoomTool );
  117. viewMenu->Add( ACTIONS::zoomRedraw );
  118. viewMenu->AppendSeparator();
  119. // Drawing Mode Submenu
  120. ACTION_MENU* drawingModeSubMenu = new ACTION_MENU( false, selTool );
  121. drawingModeSubMenu->SetTitle( _( "&Drawing Mode" ) );
  122. drawingModeSubMenu->SetIcon( BITMAPS::add_zone );
  123. drawingModeSubMenu->Add( PCB_ACTIONS::padDisplayMode, ACTION_MENU::CHECK );
  124. drawingModeSubMenu->Add( PCB_ACTIONS::graphicsOutlines, ACTION_MENU::CHECK );
  125. drawingModeSubMenu->Add( PCB_ACTIONS::textOutlines, ACTION_MENU::CHECK );
  126. viewMenu->Add( drawingModeSubMenu );
  127. // Contrast Mode Submenu
  128. ACTION_MENU* contrastModeSubMenu = new ACTION_MENU( false, selTool );
  129. contrastModeSubMenu->SetTitle( _( "&Contrast Mode" ) );
  130. contrastModeSubMenu->SetIcon( BITMAPS::contrast_mode );
  131. contrastModeSubMenu->Add( ACTIONS::highContrastMode, ACTION_MENU::CHECK );
  132. contrastModeSubMenu->Add( PCB_ACTIONS::layerAlphaDec );
  133. contrastModeSubMenu->Add( PCB_ACTIONS::layerAlphaInc );
  134. viewMenu->Add( contrastModeSubMenu );
  135. viewMenu->Add( PCB_ACTIONS::flipBoard, ACTION_MENU::CHECK );
  136. //-- Place menu -------------------------------------------------------
  137. //
  138. ACTION_MENU* placeMenu = new ACTION_MENU( false, selTool );
  139. placeMenu->Add( PCB_ACTIONS::placePad );
  140. placeMenu->Add( PCB_ACTIONS::drawRuleArea );
  141. placeMenu->AppendSeparator();
  142. placeMenu->Add( PCB_ACTIONS::drawLine );
  143. placeMenu->Add( PCB_ACTIONS::drawArc );
  144. placeMenu->Add( PCB_ACTIONS::drawRectangle );
  145. placeMenu->Add( PCB_ACTIONS::drawCircle );
  146. placeMenu->Add( PCB_ACTIONS::drawPolygon );
  147. placeMenu->Add( PCB_ACTIONS::drawBezier );
  148. placeMenu->Add( PCB_ACTIONS::placeReferenceImage );
  149. placeMenu->Add( PCB_ACTIONS::placeText );
  150. placeMenu->Add( PCB_ACTIONS::drawTextBox );
  151. placeMenu->Add( PCB_ACTIONS::drawTable );
  152. placeMenu->Add( PCB_ACTIONS::placePoint );
  153. placeMenu->Add( PCB_ACTIONS::placeBarcode );
  154. placeMenu->AppendSeparator();
  155. placeMenu->Add( PCB_ACTIONS::drawOrthogonalDimension );
  156. placeMenu->Add( PCB_ACTIONS::drawAlignedDimension );
  157. placeMenu->Add( PCB_ACTIONS::drawCenterDimension );
  158. placeMenu->Add( PCB_ACTIONS::drawRadialDimension );
  159. placeMenu->Add( PCB_ACTIONS::drawLeader );
  160. placeMenu->AppendSeparator();
  161. placeMenu->Add( PCB_ACTIONS::setAnchor );
  162. placeMenu->Add( ACTIONS::gridSetOrigin );
  163. placeMenu->AppendSeparator();
  164. placeMenu->Add( ACTIONS::gridResetOrigin );
  165. //-- Inspect menu ------------------------------------------------------
  166. //
  167. ACTION_MENU* inspectMenu = new ACTION_MENU( false, selTool );
  168. inspectMenu->Add( ACTIONS::measureTool );
  169. inspectMenu->AppendSeparator();
  170. inspectMenu->Add( PCB_ACTIONS::checkFootprint );
  171. inspectMenu->AppendSeparator();
  172. inspectMenu->Add( PCB_ACTIONS::showDatasheet );
  173. //-- Tools menu --------------------------------------------------------
  174. //
  175. ACTION_MENU* toolsMenu = new ACTION_MENU( false, selTool );
  176. toolsMenu->Add( PCB_ACTIONS::loadFpFromBoard );
  177. toolsMenu->Add( PCB_ACTIONS::saveFpToBoard );
  178. toolsMenu->AppendSeparator();
  179. toolsMenu->Add( PCB_ACTIONS::cleanupGraphics );
  180. toolsMenu->Add( PCB_ACTIONS::repairFootprint );
  181. //-- Preferences menu -------------------------------------------------
  182. //
  183. ACTION_MENU* prefsMenu = new ACTION_MENU( false, selTool );
  184. prefsMenu->Add( ACTIONS::configurePaths );
  185. prefsMenu->Add( ACTIONS::showFootprintLibTable );
  186. prefsMenu->Add( ACTIONS::openPreferences );
  187. prefsMenu->AppendSeparator();
  188. AddMenuLanguageList( prefsMenu, selTool );
  189. //--MenuBar -----------------------------------------------------------
  190. //
  191. menuBar->Append( fileMenu, _( "&File" ) );
  192. menuBar->Append( editMenu, _( "&Edit" ) );
  193. menuBar->Append( viewMenu, _( "&View" ) );
  194. menuBar->Append( placeMenu, _( "&Place" ) );
  195. menuBar->Append( inspectMenu, _( "&Inspect" ) );
  196. menuBar->Append( toolsMenu, _( "&Tools" ) );
  197. menuBar->Append( prefsMenu, _( "P&references" ) );
  198. AddStandardHelpMenu( menuBar );
  199. SetMenuBar( menuBar );
  200. delete oldMenuBar;
  201. }