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.

262 lines
9.9 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-2022 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::editTextAndGraphics );
  91. editMenu->Add( PCB_ACTIONS::defaultPadProperties );
  92. //-- View menu -------------------------------------------------------
  93. //
  94. ACTION_MENU* viewMenu = new ACTION_MENU( false, selTool );
  95. viewMenu->Add( ACTIONS::showFootprintBrowser );
  96. viewMenu->Add( ACTIONS::show3DViewer );
  97. viewMenu->AppendSeparator();
  98. viewMenu->Add( ACTIONS::zoomInCenter );
  99. viewMenu->Add( ACTIONS::zoomOutCenter );
  100. viewMenu->Add( ACTIONS::zoomFitScreen );
  101. viewMenu->Add( ACTIONS::zoomTool );
  102. viewMenu->Add( ACTIONS::zoomRedraw );
  103. viewMenu->AppendSeparator();
  104. viewMenu->Add( ACTIONS::toggleGrid, ACTION_MENU::CHECK );
  105. viewMenu->Add( ACTIONS::gridProperties );
  106. viewMenu->Add( PCB_ACTIONS::togglePolarCoords, ACTION_MENU::CHECK );
  107. // Units submenu
  108. ACTION_MENU* unitsSubMenu = new ACTION_MENU( false, selTool );
  109. unitsSubMenu->SetTitle( _( "&Units" ) );
  110. unitsSubMenu->SetIcon( BITMAPS::unit_mm );
  111. unitsSubMenu->Add( ACTIONS::inchesUnits, ACTION_MENU::CHECK );
  112. unitsSubMenu->Add( ACTIONS::milsUnits, ACTION_MENU::CHECK );
  113. unitsSubMenu->Add( ACTIONS::millimetersUnits, ACTION_MENU::CHECK );
  114. viewMenu->Add( unitsSubMenu );
  115. viewMenu->Add( ACTIONS::toggleCursorStyle, ACTION_MENU::CHECK );
  116. viewMenu->AppendSeparator();
  117. // Drawing Mode Submenu
  118. ACTION_MENU* drawingModeSubMenu = new ACTION_MENU( false, selTool );
  119. drawingModeSubMenu->SetTitle( _( "&Drawing Mode" ) );
  120. drawingModeSubMenu->SetIcon( BITMAPS::add_zone );
  121. drawingModeSubMenu->Add( PCB_ACTIONS::padDisplayMode, ACTION_MENU::CHECK );
  122. drawingModeSubMenu->Add( PCB_ACTIONS::graphicsOutlines, ACTION_MENU::CHECK );
  123. drawingModeSubMenu->Add( PCB_ACTIONS::textOutlines, ACTION_MENU::CHECK );
  124. viewMenu->Add( drawingModeSubMenu );
  125. // Contrast Mode Submenu
  126. ACTION_MENU* contrastModeSubMenu = new ACTION_MENU( false, selTool );
  127. contrastModeSubMenu->SetTitle( _( "&Contrast Mode" ) );
  128. contrastModeSubMenu->SetIcon( BITMAPS::contrast_mode );
  129. contrastModeSubMenu->Add( ACTIONS::highContrastMode, ACTION_MENU::CHECK );
  130. contrastModeSubMenu->Add( PCB_ACTIONS::layerAlphaDec );
  131. contrastModeSubMenu->Add( PCB_ACTIONS::layerAlphaInc );
  132. viewMenu->Add( contrastModeSubMenu );
  133. viewMenu->Add( PCB_ACTIONS::flipBoard, ACTION_MENU::CHECK );
  134. viewMenu->AppendSeparator();
  135. viewMenu->Add( PCB_ACTIONS::showFootprintTree, ACTION_MENU::CHECK );
  136. viewMenu->Add( PCB_ACTIONS::showLayersManager, ACTION_MENU::CHECK );
  137. //-- Place menu -------------------------------------------------------
  138. //
  139. ACTION_MENU* placeMenu = new ACTION_MENU( false, selTool );
  140. placeMenu->Add( PCB_ACTIONS::placePad );
  141. placeMenu->Add( PCB_ACTIONS::drawRuleArea );
  142. placeMenu->AppendSeparator();
  143. placeMenu->Add( PCB_ACTIONS::drawLine );
  144. placeMenu->Add( PCB_ACTIONS::drawArc );
  145. placeMenu->Add( PCB_ACTIONS::drawRectangle );
  146. placeMenu->Add( PCB_ACTIONS::drawCircle );
  147. placeMenu->Add( PCB_ACTIONS::drawPolygon );
  148. placeMenu->Add( PCB_ACTIONS::placeText );
  149. placeMenu->Add( PCB_ACTIONS::drawTextBox );
  150. placeMenu->AppendSeparator();
  151. placeMenu->Add( PCB_ACTIONS::drawAlignedDimension );
  152. placeMenu->Add( PCB_ACTIONS::drawOrthogonalDimension );
  153. placeMenu->Add( PCB_ACTIONS::drawCenterDimension );
  154. placeMenu->Add( PCB_ACTIONS::drawRadialDimension );
  155. placeMenu->Add( PCB_ACTIONS::drawLeader );
  156. placeMenu->AppendSeparator();
  157. placeMenu->Add( PCB_ACTIONS::setAnchor );
  158. placeMenu->Add( ACTIONS::gridSetOrigin );
  159. //-- Inspect menu ------------------------------------------------------
  160. //
  161. ACTION_MENU* inspectMenu = new ACTION_MENU( false, selTool );
  162. inspectMenu->Add( ACTIONS::measureTool );
  163. inspectMenu->AppendSeparator();
  164. inspectMenu->Add( PCB_ACTIONS::checkFootprint );
  165. //-- Tools menu --------------------------------------------------------
  166. //
  167. ACTION_MENU* toolsMenu = new ACTION_MENU( false, selTool );
  168. toolsMenu->Add( _( "&Load Footprint from PCB..." ),
  169. _( "Load a footprint from the current board into the editor" ),
  170. ID_LOAD_FOOTPRINT_FROM_BOARD,
  171. BITMAPS::load_module_board );
  172. toolsMenu->Add( _( "&Insert Footprint on PCB" ),
  173. _( "Insert footprint onto current board" ),
  174. ID_ADD_FOOTPRINT_TO_BOARD,
  175. BITMAPS::insert_module_board );
  176. toolsMenu->AppendSeparator();
  177. toolsMenu->Add( PCB_ACTIONS::cleanupGraphics );
  178. toolsMenu->Add( PCB_ACTIONS::repairFootprint );
  179. //-- Preferences menu -------------------------------------------------
  180. //
  181. ACTION_MENU* prefsMenu = new ACTION_MENU( false, selTool );
  182. prefsMenu->Add( ACTIONS::configurePaths );
  183. prefsMenu->Add( ACTIONS::showFootprintLibTable );
  184. // We can't use ACTIONS::showPreferences yet because wxWidgets moves this on
  185. // Mac, and it needs the wxID_PREFERENCES id to find it.
  186. prefsMenu->Add( _( "Preferences..." ) + wxT( "\tCtrl+," ),
  187. _( "Show preferences for all open tools" ),
  188. wxID_PREFERENCES,
  189. BITMAPS::preference );
  190. prefsMenu->AppendSeparator();
  191. AddMenuLanguageList( prefsMenu, selTool );
  192. //--MenuBar -----------------------------------------------------------
  193. //
  194. menuBar->Append( fileMenu, _( "&File" ) );
  195. menuBar->Append( editMenu, _( "&Edit" ) );
  196. menuBar->Append( viewMenu, _( "&View" ) );
  197. menuBar->Append( placeMenu, _( "&Place" ) );
  198. menuBar->Append( inspectMenu, _( "&Inspect" ) );
  199. menuBar->Append( toolsMenu, _( "&Tools" ) );
  200. menuBar->Append( prefsMenu, _( "P&references" ) );
  201. AddStandardHelpMenu( menuBar );
  202. SetMenuBar( menuBar );
  203. delete oldMenuBar;
  204. }