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.

253 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 (C) 1992-2021 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 <menus_helpers.h>
  30. #include <tool/actions.h>
  31. #include <tool/action_menu.h>
  32. #include <tool/tool_manager.h>
  33. #include <tools/pcb_actions.h>
  34. #include <tools/pcb_selection_tool.h>
  35. #include <widgets/wx_menubar.h>
  36. void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar()
  37. {
  38. PCB_SELECTION_TOOL* selTool = m_toolManager->GetTool<PCB_SELECTION_TOOL>();
  39. // wxWidgets handles the Mac Application menu behind the scenes, but that means
  40. // we always have to start from scratch with a new wxMenuBar.
  41. wxMenuBar* oldMenuBar = GetMenuBar();
  42. WX_MENUBAR* menuBar = new WX_MENUBAR();
  43. //-- File menu ----------------------------------------------------------
  44. //
  45. ACTION_MENU* fileMenu = new ACTION_MENU( false, selTool );
  46. fileMenu->Add( ACTIONS::newLibrary );
  47. fileMenu->Add( ACTIONS::addLibrary );
  48. fileMenu->Add( PCB_ACTIONS::newFootprint );
  49. fileMenu->Add( PCB_ACTIONS::createFootprint );
  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::defaultPadProperties );
  91. //-- View menu -------------------------------------------------------
  92. //
  93. ACTION_MENU* viewMenu = new ACTION_MENU( false, selTool );
  94. viewMenu->Add( ACTIONS::showFootprintBrowser );
  95. viewMenu->Add( ACTIONS::show3DViewer );
  96. viewMenu->AppendSeparator();
  97. viewMenu->Add( ACTIONS::zoomInCenter );
  98. viewMenu->Add( ACTIONS::zoomOutCenter );
  99. viewMenu->Add( ACTIONS::zoomFitScreen );
  100. viewMenu->Add( ACTIONS::zoomTool );
  101. viewMenu->Add( ACTIONS::zoomRedraw );
  102. viewMenu->AppendSeparator();
  103. viewMenu->Add( ACTIONS::toggleGrid, ACTION_MENU::CHECK );
  104. viewMenu->Add( ACTIONS::gridProperties );
  105. viewMenu->Add( PCB_ACTIONS::togglePolarCoords, ACTION_MENU::CHECK );
  106. // Units submenu
  107. ACTION_MENU* unitsSubMenu = new ACTION_MENU( false, selTool );
  108. unitsSubMenu->SetTitle( _( "&Units" ) );
  109. unitsSubMenu->SetIcon( BITMAPS::unit_mm );
  110. unitsSubMenu->Add( ACTIONS::inchesUnits, ACTION_MENU::CHECK );
  111. unitsSubMenu->Add( ACTIONS::milsUnits, ACTION_MENU::CHECK );
  112. unitsSubMenu->Add( ACTIONS::millimetersUnits, ACTION_MENU::CHECK );
  113. viewMenu->Add( unitsSubMenu );
  114. viewMenu->Add( ACTIONS::toggleCursorStyle, ACTION_MENU::CHECK );
  115. viewMenu->AppendSeparator();
  116. // Drawing Mode Submenu
  117. ACTION_MENU* drawingModeSubMenu = new ACTION_MENU( false, selTool );
  118. drawingModeSubMenu->SetTitle( _( "&Drawing Mode" ) );
  119. drawingModeSubMenu->SetIcon( BITMAPS::add_zone );
  120. drawingModeSubMenu->Add( PCB_ACTIONS::padDisplayMode, ACTION_MENU::CHECK );
  121. drawingModeSubMenu->Add( PCB_ACTIONS::graphicsOutlines, ACTION_MENU::CHECK );
  122. drawingModeSubMenu->Add( PCB_ACTIONS::textOutlines, ACTION_MENU::CHECK );
  123. viewMenu->Add( drawingModeSubMenu );
  124. // Contrast Mode Submenu
  125. ACTION_MENU* contrastModeSubMenu = new ACTION_MENU( false, selTool );
  126. contrastModeSubMenu->SetTitle( _( "&Contrast Mode" ) );
  127. contrastModeSubMenu->SetIcon( BITMAPS::contrast_mode );
  128. contrastModeSubMenu->Add( ACTIONS::highContrastMode, ACTION_MENU::CHECK );
  129. contrastModeSubMenu->Add( PCB_ACTIONS::layerAlphaDec );
  130. contrastModeSubMenu->Add( PCB_ACTIONS::layerAlphaInc );
  131. viewMenu->Add( contrastModeSubMenu );
  132. viewMenu->Add( PCB_ACTIONS::flipBoard, ACTION_MENU::CHECK );
  133. viewMenu->AppendSeparator();
  134. viewMenu->Add( PCB_ACTIONS::showFootprintTree, ACTION_MENU::CHECK );
  135. viewMenu->Add( PCB_ACTIONS::showLayersManager, ACTION_MENU::CHECK );
  136. //-- Place menu -------------------------------------------------------
  137. //
  138. ACTION_MENU* placeMenu = new ACTION_MENU( false, selTool );
  139. placeMenu->Add( PCB_ACTIONS::placePad );
  140. placeMenu->AppendSeparator();
  141. placeMenu->Add( PCB_ACTIONS::placeText );
  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::drawRuleArea );
  148. placeMenu->AppendSeparator();
  149. placeMenu->Add( PCB_ACTIONS::setAnchor );
  150. placeMenu->Add( ACTIONS::gridSetOrigin );
  151. //-- Inspect menu ------------------------------------------------------
  152. //
  153. ACTION_MENU* inspectMenu = new ACTION_MENU( false, selTool );
  154. inspectMenu->Add( ACTIONS::measureTool );
  155. inspectMenu->AppendSeparator();
  156. inspectMenu->Add( PCB_ACTIONS::checkFootprint );
  157. //-- Tools menu --------------------------------------------------------
  158. //
  159. ACTION_MENU* toolsMenu = new ACTION_MENU( false, selTool );
  160. toolsMenu->Add( _( "&Load Footprint from PCB..." ),
  161. _( "Load a footprint from the current board into the editor" ),
  162. ID_LOAD_FOOTPRINT_FROM_BOARD,
  163. BITMAPS::load_module_board );
  164. toolsMenu->Add( _( "&Insert Footprint on PCB" ),
  165. _( "Insert footprint onto current board" ),
  166. ID_ADD_FOOTPRINT_TO_BOARD,
  167. BITMAPS::insert_module_board );
  168. toolsMenu->AppendSeparator();
  169. toolsMenu->Add( PCB_ACTIONS::cleanupGraphics );
  170. toolsMenu->Add( PCB_ACTIONS::repairFootprint );
  171. //-- Preferences menu -------------------------------------------------
  172. //
  173. ACTION_MENU* prefsMenu = new ACTION_MENU( false, selTool );
  174. prefsMenu->Add( ACTIONS::configurePaths );
  175. prefsMenu->Add( ACTIONS::showFootprintLibTable );
  176. // We can't use ACTIONS::showPreferences yet because wxWidgets moves this on
  177. // Mac, and it needs the wxID_PREFERENCES id to find it.
  178. prefsMenu->Add( _( "Preferences..." ) + "\tCtrl+,",
  179. _( "Show preferences for all open tools" ),
  180. wxID_PREFERENCES,
  181. BITMAPS::preference );
  182. prefsMenu->AppendSeparator();
  183. AddMenuLanguageList( prefsMenu, selTool );
  184. //--MenuBar -----------------------------------------------------------
  185. //
  186. menuBar->Append( fileMenu, _( "&File" ) );
  187. menuBar->Append( editMenu, _( "&Edit" ) );
  188. menuBar->Append( viewMenu, _( "&View" ) );
  189. menuBar->Append( placeMenu, _( "&Place" ) );
  190. menuBar->Append( inspectMenu, _( "&Inspect" ) );
  191. menuBar->Append( toolsMenu, _( "&Tools" ) );
  192. menuBar->Append( prefsMenu, _( "P&references" ) );
  193. AddStandardHelpMenu( menuBar );
  194. SetMenuBar( menuBar );
  195. delete oldMenuBar;
  196. }