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.

304 lines
10 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
  5. * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
  6. * Copyright (C) 2012 Wayne Stambaugh <stambaughw@verizon.net>
  7. * Copyright (C) 1992-2012 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. /**
  27. * @file pcbnew/menubar_modedit.cpp
  28. * @brief (Re)Create the main menubar for the module editor
  29. */
  30. #include <fctsys.h>
  31. #include <pcbnew.h>
  32. #include <wxPcbStruct.h>
  33. #include <module_editor_frame.h>
  34. #include <menus_helpers.h>
  35. #include <pcbnew_id.h>
  36. #include <hotkeys.h>
  37. void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar()
  38. {
  39. // Create and try to get the current menubar
  40. wxMenuBar* menuBar = GetMenuBar();
  41. if( !menuBar )
  42. menuBar = new wxMenuBar();
  43. // Delete all existing menus so they can be rebuilt.
  44. // This allows language changes of the menu text on the fly.
  45. menuBar->Freeze();
  46. while( menuBar->GetMenuCount() )
  47. delete menuBar->Remove( 0 );
  48. // Recreate all menus:
  49. wxString text;
  50. // Menu File:
  51. wxMenu* fileMenu = new wxMenu;
  52. // Active library selection
  53. AddMenuItem( fileMenu, ID_MODEDIT_SELECT_CURRENT_LIB, _("Current Library"),
  54. _( "Select active library" ),
  55. KiBitmap( open_library_xpm ) );
  56. fileMenu->AppendSeparator();
  57. // New module
  58. AddMenuItem( fileMenu, ID_MODEDIT_NEW_MODULE,
  59. _( "&New Module" ), _( "Create new module" ),
  60. KiBitmap( new_footprint_xpm ) );
  61. // Open submenu
  62. wxMenu* openSubmenu = new wxMenu;
  63. // from File
  64. AddMenuItem( openSubmenu, ID_MODEDIT_IMPORT_PART,
  65. _( "&Import Module from File" ),
  66. _( "Import a footprint from an existing file" ),
  67. KiBitmap( import_module_xpm ) );
  68. // from Library
  69. AddMenuItem( openSubmenu, ID_MODEDIT_LOAD_MODULE,
  70. _( "Load Module from Current Li&brary" ),
  71. _( "Open a footprint module from a Library" ),
  72. KiBitmap( module_xpm ) );
  73. // from current Board
  74. AddMenuItem( openSubmenu, ID_MODEDIT_LOAD_MODULE_FROM_BOARD,
  75. _( "Load Module from &Current Board" ),
  76. _( "Load a footprint module from the current loaded board" ),
  77. KiBitmap( load_module_board_xpm ) );
  78. /* Append openSubmenu to fileMenu */
  79. AddMenuItem( fileMenu, openSubmenu, -1,
  80. _( "&Load Module" ),
  81. _( "Load a footprint module" ),
  82. KiBitmap( open_document_xpm ) );
  83. fileMenu->AppendSeparator();
  84. // Save the currently loaded legacy library as an s-expression library.
  85. AddMenuItem( fileMenu, ID_MODEDIT_SAVE_LIBRARY_AS,
  86. _( "Save Current Library as ..." ),
  87. _( "Save entire current library under a new name." ),
  88. wxNullBitmap );
  89. // Save module
  90. text = AddHotkeyName( _( "&Save Module in Active Library" ),
  91. g_Module_Editor_Hokeys_Descr, HK_SAVE_MODULE );
  92. AddMenuItem( fileMenu, ID_MODEDIT_SAVE_LIBMODULE, text,
  93. _( "Save module in active library" ),
  94. KiBitmap( save_library_xpm ) );
  95. // Save module in new lib
  96. AddMenuItem( fileMenu, ID_MODEDIT_CREATE_NEW_LIB_AND_SAVE_CURRENT_PART,
  97. _( "S&ave Module into a New Library" ),
  98. _( "Create a new library and save current module into it" ),
  99. KiBitmap( new_library_xpm ) );
  100. // Export module
  101. AddMenuItem( fileMenu, ID_MODEDIT_EXPORT_PART,
  102. _( "&Export Module" ),
  103. _( "Save the current loaded module to a file" ),
  104. KiBitmap( export_module_xpm ) );
  105. fileMenu->AppendSeparator();
  106. // Print
  107. AddMenuItem( fileMenu, wxID_PRINT,
  108. _( "&Print" ),
  109. _( "Print the current module" ),
  110. KiBitmap( plot_xpm ) );
  111. // Separator
  112. fileMenu->AppendSeparator();
  113. // Close editor
  114. AddMenuItem( fileMenu, wxID_EXIT,
  115. _( "Cl&ose" ),
  116. _( "Close the footprint editor" ),
  117. KiBitmap( exit_xpm ) );
  118. // Menu Edit:
  119. wxMenu* editMenu = new wxMenu;
  120. // Undo
  121. text = AddHotkeyName( _( "&Undo" ), g_Module_Editor_Hokeys_Descr, HK_UNDO );
  122. AddMenuItem( editMenu, wxID_UNDO,
  123. text, _( "Undo last edit" ),
  124. KiBitmap( undo_xpm ) );
  125. // Redo
  126. text = AddHotkeyName( _( "&Redo" ), g_Module_Editor_Hokeys_Descr, HK_REDO );
  127. AddMenuItem( editMenu, wxID_REDO,
  128. text, _( "Redo the last undo action" ),
  129. KiBitmap( redo_xpm ) );
  130. // Delete items
  131. AddMenuItem( editMenu, ID_MODEDIT_DELETE_TOOL,
  132. _( "&Delete" ), _( "Delete objects with the eraser" ),
  133. KiBitmap( delete_xpm ) );
  134. // Separator
  135. editMenu->AppendSeparator();
  136. // Properties
  137. AddMenuItem( editMenu, ID_MODEDIT_EDIT_MODULE_PROPERTIES,
  138. _( "&Properties" ),
  139. _( "Edit module properties" ),
  140. KiBitmap( module_options_xpm ) );
  141. // Dimensions submenu
  142. wxMenu* dimensions_Submenu = new wxMenu;
  143. // Sizes and Widths
  144. AddMenuItem( dimensions_Submenu, ID_PCB_DRAWINGS_WIDTHS_SETUP,
  145. _( "&Sizes and Widths" ),
  146. _( "Adjust width for texts and drawings" ),
  147. KiBitmap( options_text_xpm ) );
  148. // Pad settings
  149. AddMenuItem( dimensions_Submenu, ID_MODEDIT_PAD_SETTINGS,
  150. _( "&Pad Settings" ), _( "Edit the settings for new pads" ),
  151. KiBitmap( pad_dimensions_xpm ) );
  152. // User grid size
  153. AddMenuItem( dimensions_Submenu, ID_PCB_USER_GRID_SETUP,
  154. _( "&User Grid Size" ), _( "Adjust user grid" ),
  155. KiBitmap( grid_xpm ) );
  156. // View menu
  157. wxMenu* viewMenu = new wxMenu;
  158. // Zoom In
  159. AddMenuItem( viewMenu, ID_ZOOM_IN,
  160. _( "Zoom &In" ), _( "Zoom in on the module" ),
  161. KiBitmap( zoom_in_xpm ) );
  162. // Zoom Out
  163. AddMenuItem( viewMenu, ID_ZOOM_OUT,
  164. _( "Zoom &Out" ), _( "Zoom out on the module" ),
  165. KiBitmap( zoom_out_xpm ) );
  166. // Fit on Screen
  167. AddMenuItem( viewMenu, ID_ZOOM_PAGE,
  168. _( "&Fit on Screen" ),
  169. _( "Zoom and fit the module in the window" ),
  170. KiBitmap( zoom_fit_in_page_xpm ) );
  171. viewMenu->AppendSeparator();
  172. // Redraw
  173. AddMenuItem( viewMenu, ID_ZOOM_REDRAW,
  174. _( "&Redraw" ), _( "Redraw the window's viewport" ),
  175. KiBitmap( zoom_redraw_xpm ) );
  176. // 3D view
  177. AddMenuItem( viewMenu, ID_MENU_PCB_SHOW_3D_FRAME,
  178. _( "3&D View" ),
  179. _( "Show board in 3D viewer" ),
  180. KiBitmap( three_d_xpm ) );
  181. // Menu Place:
  182. wxMenu* placeMenu = new wxMenu;
  183. // Pad
  184. AddMenuItem( placeMenu, ID_MODEDIT_PAD_TOOL,
  185. _( "&Pad" ), _( "Add pad" ),
  186. KiBitmap( pad_xpm ) );
  187. placeMenu->AppendSeparator();
  188. // Circle
  189. AddMenuItem( placeMenu, ID_MODEDIT_CIRCLE_TOOL,
  190. _( "&Circle" ), _( "Add graphic circle" ),
  191. KiBitmap( add_circle_xpm ) );
  192. // Line or Polygon
  193. AddMenuItem( placeMenu, ID_MODEDIT_LINE_TOOL,
  194. _( "&Line or Polygon" ),
  195. _( "Add graphic line or polygon" ),
  196. KiBitmap( add_polygon_xpm ) );
  197. // Arc
  198. AddMenuItem( placeMenu, ID_MODEDIT_ARC_TOOL,
  199. _( "&Arc" ), _( "Add graphic arc" ),
  200. KiBitmap( add_arc_xpm ) );
  201. // Text
  202. AddMenuItem( placeMenu, ID_MODEDIT_TEXT_TOOL,
  203. _( "&Text" ), _( "Add graphic text" ),
  204. KiBitmap( add_text_xpm ) );
  205. placeMenu->AppendSeparator();
  206. // Anchor
  207. AddMenuItem( placeMenu, ID_MODEDIT_ANCHOR_TOOL,
  208. _( "A&nchor" ),
  209. _( "Place the footprint module reference anchor" ),
  210. KiBitmap( anchor_xpm ) );
  211. // Menu Help:
  212. wxMenu* helpMenu = new wxMenu;
  213. // Version info
  214. AddHelpVersionInfoMenuEntry( helpMenu );
  215. // Contents
  216. AddMenuItem( helpMenu, wxID_HELP,
  217. _( "&Contents" ),
  218. _( "Open the Pcbnew handbook" ),
  219. KiBitmap( online_help_xpm ) );
  220. AddMenuItem( helpMenu, wxID_INDEX,
  221. _( "&Getting Started in KiCad" ),
  222. _( "Open the \"Getting Started in KiCad\" guide for beginners" ),
  223. KiBitmap( help_xpm ) );
  224. // About Pcbnew
  225. helpMenu->AppendSeparator();
  226. AddMenuItem( helpMenu, wxID_ABOUT,
  227. _( "&About Pcbnew" ),
  228. _( "About Pcbnew PCB designer" ),
  229. KiBitmap( info_xpm ) );
  230. // Append menus to the menubar
  231. menuBar->Append( fileMenu, _( "&File" ) );
  232. menuBar->Append( editMenu, _( "&Edit" ) );
  233. menuBar->Append( dimensions_Submenu, _( "Di&mensions" ) );
  234. menuBar->Append( viewMenu, _( "&View" ) );
  235. menuBar->Append( placeMenu, _( "&Place" ) );
  236. menuBar->Append( helpMenu, _( "&Help" ) );
  237. menuBar->Thaw();
  238. // Associate the menu bar with the frame, if no previous menubar
  239. if( GetMenuBar() == NULL )
  240. SetMenuBar( menuBar );
  241. else
  242. menuBar->Refresh();
  243. }