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.

366 lines
12 KiB

* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2007 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
  5. * Copyright (C) 2009 Wayne Stambaugh <stambaughw@gmail.com>
  6. * Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * as published by the Free Software Foundation; either version 2
  11. * of the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, you may find one here:
  20. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  21. * or you may search the http://www.gnu.org website for the version 2 license,
  22. * or you may write to the Free Software Foundation, Inc.,
  23. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  24. */
  25. /**
  26. * @file eeschema/menubar_libedit.cpp
  27. * @brief (Re)Create the main menubar for the part editor frame (LibEdit)
  28. */
  29. #include <menus_helpers.h>
  30. #include <pgm_base.h>
  31. #include "eeschema_id.h"
  32. #include "general.h"
  33. #include "help_common_strings.h"
  34. #include "hotkeys.h"
  35. #include "lib_edit_frame.h"
  36. void LIB_EDIT_FRAME::ReCreateMenuBar()
  37. {
  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. wxMenuBar* menuBar = new wxMenuBar();
  42. wxString text;
  43. // Recreate all menus:
  44. // Menu File:
  45. wxMenu* fileMenu = new wxMenu;
  46. AddMenuItem( fileMenu,
  47. ID_LIBEDIT_NEW_LIBRARY,
  48. _( "New Library..." ),
  49. _( "Creates an empty library" ),
  50. KiBitmap( new_library_xpm ) );
  51. AddMenuItem( fileMenu,
  52. ID_LIBEDIT_ADD_LIBRARY,
  53. _( "Add Library..." ),
  54. _( "Adds a previously created library" ),
  55. KiBitmap( add_library_xpm ) );
  56. text = AddHotkeyName( _( "&New Symbol..." ), m_hotkeysDescrList, HK_NEW );
  57. AddMenuItem( fileMenu,
  58. ID_LIBEDIT_NEW_PART,
  59. text,
  60. _( "Create a new symbol" ),
  61. KiBitmap( new_component_xpm ) );
  62. fileMenu->AppendSeparator();
  63. text = AddHotkeyName( _( "&Save" ), g_Libedit_Hokeys_Descr, HK_SAVE );
  64. AddMenuItem( fileMenu,
  65. ID_LIBEDIT_SAVE,
  66. text,
  67. _( "Save changes" ),
  68. KiBitmap( save_xpm ) );
  69. text = AddHotkeyName( _( "Save &As..." ), g_Libedit_Hokeys_Descr, HK_SAVEAS );
  70. AddMenuItem( fileMenu,
  71. ID_LIBEDIT_SAVE_AS,
  72. text,
  73. _( "Save a copy to a new name and/or location" ),
  74. KiBitmap( save_as_xpm ) );
  75. AddMenuItem( fileMenu,
  76. ID_LIBEDIT_SAVE_ALL,
  77. _( "Save All" ),
  78. _( "Save all library and symbol changes" ),
  79. KiBitmap( save_xpm ) );
  80. AddMenuItem( fileMenu,
  81. ID_LIBEDIT_REVERT,
  82. _( "&Revert" ),
  83. _( "Throw away changes" ),
  84. KiBitmap( undo_xpm ) );
  85. fileMenu->AppendSeparator();
  86. AddMenuItem( fileMenu,
  87. ID_LIBEDIT_IMPORT_PART,
  88. _( "&Import Symbol..." ),
  89. _( "Import a symbol to the current library" ),
  90. KiBitmap( import_part_xpm ) );
  91. AddMenuItem( fileMenu,
  92. ID_LIBEDIT_EXPORT_PART,
  93. _( "&Export Symbol..." ),
  94. _( "Export the current symbol" ),
  95. KiBitmap( export_part_xpm ) );
  96. AddMenuItem( fileMenu,
  97. ID_LIBEDIT_GEN_PNG_FILE,
  98. _( "Export PNG..." ),
  99. _( "Create a PNG file from the current view" ),
  100. KiBitmap( plot_xpm ) );
  101. AddMenuItem( fileMenu,
  102. ID_LIBEDIT_GEN_SVG_FILE,
  103. _( "Export SVG..." ),
  104. _( "Create a SVG file from the current symbol" ),
  105. KiBitmap( plot_svg_xpm ) );
  106. fileMenu->AppendSeparator();
  107. AddMenuItem( fileMenu,
  108. wxID_EXIT,
  109. _( "&Quit" ),
  110. _( "Quit Library Editor" ),
  111. KiBitmap( exit_xpm ) );
  112. // Edit menu
  113. wxMenu* editMenu = new wxMenu;
  114. text = AddHotkeyName( _( "&Undo" ), g_Libedit_Hokeys_Descr, HK_UNDO );
  115. AddMenuItem( editMenu,
  116. wxID_UNDO,
  117. text,
  118. _( "Undo last edit" ),
  119. KiBitmap( undo_xpm ) );
  120. text = AddHotkeyName( _( "&Redo" ), g_Libedit_Hokeys_Descr, HK_REDO );
  121. AddMenuItem( editMenu,
  122. wxID_REDO,
  123. text,
  124. _( "Redo the last undo command" ),
  125. KiBitmap( redo_xpm ) );
  126. editMenu->AppendSeparator();
  127. AddMenuItem( editMenu,
  128. ID_LIBEDIT_GET_FRAME_EDIT_PART,
  129. _( "&Properties..." ),
  130. _( "Edit symbol properties" ),
  131. KiBitmap( part_properties_xpm ) );
  132. AddMenuItem( editMenu,
  133. ID_LIBEDIT_EDIT_PIN_BY_TABLE,
  134. _( "Pin &Table..." ),
  135. _( "Show pin table" ),
  136. KiBitmap( pin_table_xpm ) );
  137. // Menu View:
  138. wxMenu* viewMenu = new wxMenu;
  139. AddMenuItem( viewMenu,
  140. ID_TO_LIBVIEW,
  141. _( "Library Browser" ),
  142. _( "Open the symbol viewer" ),
  143. KiBitmap( library_browse_xpm ) );
  144. viewMenu->AppendSeparator();
  145. /**
  146. * Important Note for ZOOM IN and ZOOM OUT commands from menubar:
  147. * we cannot add hotkey info here, because the hotkey HK_ZOOM_IN and HK_ZOOM_OUT
  148. * events(default = WXK_F1 and WXK_F2) are *NOT* equivalent to this menu command:
  149. * zoom in and out from hotkeys are equivalent to the pop up menu zoom
  150. * From here, zooming is made around the screen center
  151. * From hotkeys, zooming is made around the mouse cursor position
  152. * (obviously not possible from the toolbar or menubar command)
  153. *
  154. * in others words HK_ZOOM_IN and HK_ZOOM_OUT *are NOT* accelerators
  155. * for Zoom in and Zoom out sub menus
  156. */
  157. // Zoom in
  158. text = _( "Zoom &In" );
  159. AddMenuItem( viewMenu, ID_ZOOM_IN, text, HELP_ZOOM_IN, KiBitmap( zoom_in_xpm ) );
  160. // Zoom out
  161. text = _( "Zoom &Out" );
  162. AddMenuItem( viewMenu, ID_ZOOM_OUT, text, HELP_ZOOM_OUT, KiBitmap( zoom_out_xpm ) );
  163. // Fit on screen
  164. text = AddHotkeyName( _( "&Zoom to Fit" ), g_Libedit_Hokeys_Descr, HK_ZOOM_AUTO );
  165. AddMenuItem( viewMenu, ID_ZOOM_PAGE, text, _( "Zoom to fit symbol" ),
  166. KiBitmap( zoom_fit_in_page_xpm ) );
  167. text = AddHotkeyName( _( "Zoom to Selection" ),
  168. g_Schematic_Hokeys_Descr, HK_ZOOM_SELECTION );
  169. AddMenuItem( viewMenu, ID_MENU_ZOOM_SELECTION, text, KiBitmap( zoom_area_xpm ) );
  170. // Redraw
  171. text = AddHotkeyName( _( "&Redraw" ), g_Libedit_Hokeys_Descr, HK_ZOOM_REDRAW );
  172. AddMenuItem( viewMenu, ID_ZOOM_REDRAW, text, HELP_ZOOM_REDRAW, KiBitmap( zoom_redraw_xpm ) );
  173. viewMenu->AppendSeparator();
  174. AddMenuItem( viewMenu, ID_TB_OPTIONS_SHOW_GRID,
  175. _( "Show &Grid" ), wxEmptyString,
  176. KiBitmap( grid_xpm ), wxITEM_CHECK );
  177. AddMenuItem( viewMenu, ID_GRID_SETTINGS,
  178. _( "Grid Settings..." ), wxEmptyString,
  179. KiBitmap( grid_xpm ) );
  180. // Separator
  181. viewMenu->AppendSeparator();
  182. AddMenuItem( viewMenu,
  183. ID_LIBEDIT_SHOW_HIDE_SEARCH_TREE,
  184. _( "&Search Tree" ),
  185. _( "Toggles the search tree visibility" ),
  186. KiBitmap( search_tree_xpm ) );
  187. // Menu Place:
  188. wxMenu* placeMenu = new wxMenu;
  189. // Pin
  190. AddMenuItem( placeMenu,
  191. ID_LIBEDIT_PIN_BUTT,
  192. _( "&Pin" ),
  193. HELP_ADD_PIN,
  194. KiBitmap( pin_xpm ) );
  195. // Graphic text
  196. AddMenuItem( placeMenu,
  197. ID_LIBEDIT_BODY_TEXT_BUTT,
  198. _( "Graphic &Text" ),
  199. HELP_ADD_BODYTEXT,
  200. KiBitmap( text_xpm ) );
  201. // Graphic rectangle
  202. AddMenuItem( placeMenu,
  203. ID_LIBEDIT_BODY_RECT_BUTT,
  204. _( "&Rectangle" ),
  205. HELP_ADD_BODYRECT,
  206. KiBitmap( add_rectangle_xpm ) );
  207. // Graphic Circle
  208. AddMenuItem( placeMenu,
  209. ID_LIBEDIT_BODY_CIRCLE_BUTT,
  210. _( "&Circle" ),
  211. HELP_ADD_BODYCIRCLE,
  212. KiBitmap( add_circle_xpm ) );
  213. // Graphic Arc
  214. AddMenuItem( placeMenu,
  215. ID_LIBEDIT_BODY_ARC_BUTT,
  216. _( "&Arc" ),
  217. HELP_ADD_BODYARC,
  218. KiBitmap( add_arc_xpm ) );
  219. // Graphic Line or Polygon
  220. AddMenuItem( placeMenu,
  221. ID_LIBEDIT_BODY_LINE_BUTT,
  222. _( "&Line or Polygon" ),
  223. HELP_ADD_BODYPOLYGON,
  224. KiBitmap( add_polygon_xpm ) );
  225. // Menu Inspect:
  226. wxMenu* inspectMenu = new wxMenu;
  227. text = AddHotkeyName( _( "Show Datasheet" ), g_Libedit_Hokeys_Descr, HK_LIBEDIT_VIEW_DOC );
  228. AddMenuItem( inspectMenu,
  229. ID_LIBEDIT_VIEW_DOC,
  230. text,
  231. _( "Open associated datasheet in web browser" ),
  232. KiBitmap( datasheet_xpm ) );
  233. AddMenuItem( inspectMenu,
  234. ID_LIBEDIT_CHECK_PART,
  235. _( "Electrical Rules &Checker" ),
  236. _( "Check duplicate and off grid pins" ),
  237. KiBitmap( erc_xpm ) );
  238. // Menu Preferences:
  239. wxMenu* preferencesMenu = new wxMenu;
  240. // Environment varialbes
  241. AddMenuItem( preferencesMenu,
  242. ID_PREFERENCES_CONFIGURE_PATHS,
  243. _( "&Configure Paths..." ),
  244. _( "Edit path configuration environment variables" ),
  245. KiBitmap( path_xpm ) );
  246. // Library list
  247. AddMenuItem( preferencesMenu,
  248. ID_EDIT_SYM_LIB_TABLE,
  249. _( "Manage &Symbol Libraries..." ),
  250. _( "Edit the global and project symbol library tables." ),
  251. KiBitmap( library_table_xpm ) );
  252. preferencesMenu->AppendSeparator();
  253. // Default values and options
  254. AddMenuItem( preferencesMenu,
  255. wxID_PREFERENCES,
  256. _( "&Preferences..." ),
  257. _( "Show preferences for all open tools" ),
  258. KiBitmap( preference_xpm ) );
  259. // Language submenu
  260. Pgm().AddMenuLanguageList( preferencesMenu );
  261. // Menu Help:
  262. wxMenu* helpMenu = new wxMenu;
  263. // Contents
  264. AddMenuItem( helpMenu,
  265. wxID_HELP,
  266. _( "Eeschema &Manual" ),
  267. _( "Open the Eeschema Manual" ),
  268. KiBitmap( online_help_xpm ) );
  269. AddMenuItem( helpMenu,
  270. wxID_INDEX,
  271. _( "&Getting Started in KiCad" ),
  272. _( "Open the \"Getting Started in KiCad\" guide for beginners" ),
  273. KiBitmap( help_xpm ) );
  274. text = AddHotkeyName( _( "&List Hotkeys..." ), g_Libedit_Hokeys_Descr, HK_HELP );
  275. AddMenuItem( helpMenu,
  276. ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST,
  277. text,
  278. _( "Displays the current hotkeys list and corresponding commands" ),
  279. KiBitmap( hotkeys_xpm ) );
  280. helpMenu->AppendSeparator();
  281. AddMenuItem( helpMenu, ID_HELP_GET_INVOLVED,
  282. _( "Get &Involved" ),
  283. _( "Contribute to KiCad (opens a web browser)" ),
  284. KiBitmap( info_xpm ) );
  285. // About Eeschema
  286. helpMenu->AppendSeparator();
  287. AddMenuItem( helpMenu, wxID_ABOUT, _( "&About KiCad" ), KiBitmap( about_xpm ) );
  288. // Create the menubar and append all submenus
  289. menuBar->Append( fileMenu, _( "&File" ) );
  290. menuBar->Append( editMenu, _( "&Edit" ) );
  291. menuBar->Append( viewMenu, _( "&View" ) );
  292. menuBar->Append( placeMenu, _( "&Place" ) );
  293. menuBar->Append( inspectMenu, _( "&Inspect" ) );
  294. menuBar->Append( preferencesMenu, _( "P&references" ) );
  295. menuBar->Append( helpMenu, _( "&Help" ) );
  296. SetMenuBar( menuBar );
  297. delete oldMenuBar;
  298. }