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.

276 lines
9.0 KiB

  1. /**
  2. * @file menubar_libedit.cpp
  3. * @brief Create the main menubar for the component editor frame (LibEdit)
  4. */
  5. #include "fctsys.h"
  6. #include "common.h"
  7. #include "appl_wxstruct.h"
  8. #include "bitmaps.h"
  9. #include "program.h"
  10. #include "general.h"
  11. //#include "protos.h"
  12. #include "libeditframe.h"
  13. #include "eeschema_id.h"
  14. #include "hotkeys.h"
  15. #include "help_common_strings.h"
  16. /**
  17. * @brief Create or update the menubar for the Component Editor frame
  18. */
  19. void WinEDA_LibeditFrame::ReCreateMenuBar()
  20. {
  21. wxString text;
  22. wxMenuItem *item;
  23. wxMenuBar *menuBar = GetMenuBar();
  24. /**
  25. * Destroy the existing menu bar so it can be rebuilt. This allows
  26. * language changes of the menu text on the fly.
  27. */
  28. if( menuBar )
  29. SetMenuBar( NULL );
  30. menuBar = new wxMenuBar();
  31. /**
  32. * File menu
  33. */
  34. wxMenu* filesMenu = new wxMenu;
  35. /* Save current lib */
  36. item = new wxMenuItem( filesMenu, ID_LIBEDIT_SAVE_CURRENT_LIB,
  37. _( "&Save Current Library\tCtrl+S" ),
  38. _( "Save the current active library" ) );
  39. item->SetBitmap( save_xpm );
  40. filesMenu->Append( item );
  41. /* Save as... */
  42. item = new wxMenuItem( filesMenu, ID_LIBEDIT_SAVE_CURRENT_LIB_AS,
  43. _( "Save Current Library &as" ),
  44. _( "Save current active library as..." ) );
  45. item->SetBitmap( save_as_xpm );
  46. filesMenu->Append( item );
  47. /* Separator */
  48. filesMenu->AppendSeparator();
  49. /* Export as png file */
  50. item = new wxMenuItem( filesMenu, ID_LIBEDIT_GEN_PNG_FILE, _( "&Create PNG File from Screen" ),
  51. _( "Create a PNG file from the component displayed on screen" ) );
  52. item->SetBitmap( plot_xpm );
  53. filesMenu->Append( item );
  54. /* Export as SVG file */
  55. item = new wxMenuItem( filesMenu, ID_LIBEDIT_GEN_SVG_FILE, _( "&Create SVG File" ),
  56. _( "Create a SVG file from the current loaded component" ) );
  57. item->SetBitmap( plot_xpm );
  58. filesMenu->Append( item );
  59. /* Quit on all platforms except WXMAC, because else this "breaks" the mac
  60. UI compliance. The Quit item is in a different menu on a mac than
  61. windows or unix machine.
  62. */
  63. #if !defined(__WXMAC__)
  64. filesMenu->AppendSeparator();
  65. item = new wxMenuItem( filesMenu, wxID_EXIT, _( "&Quit" ),
  66. _( "Quit Library Editor" ) );
  67. filesMenu->Append( item );
  68. #endif
  69. /**
  70. * Edit menu
  71. */
  72. wxMenu* editMenu = new wxMenu;
  73. /* Undo */
  74. text = AddHotkeyName( _( "Undo" ), s_Libedit_Hokeys_Descr, HK_UNDO);
  75. item = new wxMenuItem( editMenu, wxID_UNDO, text,
  76. _( "Undo last edition" ), wxITEM_NORMAL );
  77. item->SetBitmap( undo_xpm );
  78. editMenu->Append( item );
  79. /* Redo */
  80. text = AddHotkeyName( _( "Redo" ), s_Libedit_Hokeys_Descr, HK_REDO);
  81. item = new wxMenuItem( editMenu, wxID_REDO, text,
  82. _( "Redo the last undo command" ), wxITEM_NORMAL );
  83. item->SetBitmap( redo_xpm );
  84. editMenu->Append( item );
  85. /* Separator */
  86. editMenu->AppendSeparator();
  87. /* Delete */
  88. item = new wxMenuItem( editMenu, ID_LIBEDIT_DELETE_ITEM_BUTT,
  89. _( "Delete" ), HELP_DELETE_ITEMS, wxITEM_NORMAL );
  90. item->SetBitmap( delete_body_xpm );
  91. editMenu->Append( item );
  92. /**
  93. * View menu
  94. */
  95. wxMenu* viewMenu = new wxMenu;
  96. /* Important Note for ZOOM IN and ZOOM OUT commands from menubar:
  97. * we cannot add hotkey info here, because the hotkey HK_ZOOM_IN and HK_ZOOM_OUT
  98. * events(default = WXK_F1 and WXK_F2) are *NOT* equivalent to this menu command:
  99. * zoom in and out from hotkeys are equivalent to the pop up menu zoom
  100. * From here, zoomming is made around the screen center
  101. * From hotkeys, zoomming is made around the mouse cursor position
  102. * (obvioulsy not possible from the toolbat or menubar command)
  103. *
  104. * in others words HK_ZOOM_IN and HK_ZOOM_OUT *are NOT* accelerators
  105. * for Zoom in and Zoom out sub menus
  106. */
  107. /* Zoom in */
  108. text =_( "Zoom In" );
  109. item = new wxMenuItem( viewMenu, ID_ZOOM_IN, text, HELP_ZOOM_IN,
  110. wxITEM_NORMAL );
  111. item->SetBitmap( zoom_in_xpm );
  112. viewMenu->Append( item );
  113. /* Zoom out */
  114. text = _( "Zoom Out" );
  115. item = new wxMenuItem( viewMenu, ID_ZOOM_OUT, text, HELP_ZOOM_OUT,
  116. wxITEM_NORMAL );
  117. item->SetBitmap( zoom_out_xpm );
  118. viewMenu->Append( item );
  119. /* Fit on screen */
  120. text = AddHotkeyName( _( "Fit on Screen" ), s_Schematic_Hokeys_Descr,
  121. HK_ZOOM_AUTO );
  122. item = new wxMenuItem( viewMenu, ID_ZOOM_PAGE, text,
  123. HELP_ZOOM_FIT, wxITEM_NORMAL );
  124. item->SetBitmap( zoom_auto_xpm );
  125. viewMenu->Append( item );
  126. viewMenu->AppendSeparator();
  127. /* Redraw view */
  128. text = AddHotkeyName( _( "Redraw" ), s_Schematic_Hokeys_Descr,
  129. HK_ZOOM_REDRAW );
  130. item = new wxMenuItem( viewMenu, ID_ZOOM_REDRAW, text,
  131. HELP_ZOOM_REDRAW, wxITEM_NORMAL );
  132. item->SetBitmap( zoom_redraw_xpm );
  133. viewMenu->Append( item );
  134. /**
  135. * Place menu
  136. * TODO: Unify the ID names!
  137. */
  138. wxMenu* placeMenu = new wxMenu;
  139. /* Pin */
  140. item = new wxMenuItem( placeMenu, ID_LIBEDIT_PIN_BUTT, _( "&Pin" ),
  141. HELP_ADD_PIN, wxITEM_NORMAL );
  142. item->SetBitmap( pin_xpm );
  143. placeMenu->Append( item );
  144. /* Graphic text */
  145. item = new wxMenuItem( placeMenu, ID_LIBEDIT_BODY_TEXT_BUTT,
  146. _( "Graphic text" ),
  147. HELP_ADD_BODYTEXT, wxITEM_NORMAL );
  148. item->SetBitmap( add_text_xpm );
  149. placeMenu->Append( item );
  150. /* Graphic rectangle */
  151. item = new wxMenuItem( placeMenu, ID_LIBEDIT_BODY_RECT_BUTT,
  152. _( "Rectangle" ),
  153. HELP_ADD_BODYRECT, wxITEM_NORMAL );
  154. item->SetBitmap( add_rectangle_xpm );
  155. placeMenu->Append( item );
  156. /* Graphic Circle */
  157. item = new wxMenuItem( placeMenu, ID_LIBEDIT_BODY_CIRCLE_BUTT,
  158. _( "Circle" ),
  159. HELP_ADD_BODYCIRCLE,
  160. wxITEM_NORMAL );
  161. item->SetBitmap( add_circle_xpm );
  162. placeMenu->Append( item );
  163. /* Graphic Arc */
  164. item = new wxMenuItem( placeMenu, ID_LIBEDIT_BODY_ARC_BUTT,
  165. _( "Arc" ),
  166. HELP_ADD_BODYARC, wxITEM_NORMAL );
  167. item->SetBitmap( add_arc_xpm );
  168. placeMenu->Append( item );
  169. /* Graphic line or polygon */
  170. item = new wxMenuItem( placeMenu, ID_LIBEDIT_BODY_LINE_BUTT,
  171. _( "Line or Polygon" ),
  172. HELP_ADD_BODYPOLYGON, wxITEM_NORMAL );
  173. item->SetBitmap( add_polygon_xpm );
  174. placeMenu->Append( item );
  175. /**
  176. * Preferences Menu
  177. */
  178. wxMenu* configmenu = new wxMenu;
  179. /* Library */
  180. item = new wxMenuItem( configmenu, ID_CONFIG_REQ, _( "&Library" ),
  181. _( "Library preferences" ) );
  182. item->SetBitmap( library_xpm );
  183. configmenu->Append( item );
  184. /* Colors */
  185. item = new wxMenuItem( configmenu, ID_COLORS_SETUP, _( "&Colors" ),
  186. _( "Color preferences" ) );
  187. item->SetBitmap( palette_xpm );
  188. configmenu->Append( item );
  189. #if 0 // work in progress. activated when finished
  190. /* Dimension */
  191. item = new wxMenuItem( configmenu, ID_LIBEDIT_DIMENSIONS, _( "&Dimensions" ),
  192. _( "Tickness of graphic lines, texts sizes and others" ) );
  193. item->SetBitmap( add_dimension_xpm );
  194. configmenu->Append( item );
  195. #endif
  196. /* Language submenu */
  197. wxGetApp().AddMenuLanguageList( configmenu );
  198. /* Hotkey submenu */
  199. AddHotkeyConfigMenu( configmenu );
  200. /* Separator */
  201. configmenu->AppendSeparator();
  202. /* Save preferences */
  203. item = new wxMenuItem( configmenu, ID_CONFIG_SAVE, _( "&Save preferences" ),
  204. _( "Save application preferences" ) );
  205. item->SetBitmap( save_setup_xpm );
  206. configmenu->Append( item );
  207. /* Read preferences */
  208. item = new wxMenuItem( configmenu, ID_CONFIG_READ, _( "&Read preferences" ),
  209. _( "Read application preferences" ) );
  210. item->SetBitmap( read_setup_xpm );
  211. configmenu->Append( item );
  212. /**
  213. * Help Menu
  214. */
  215. wxMenu* helpMenu = new wxMenu;
  216. item = new wxMenuItem( helpMenu, ID_GENERAL_HELP, _( "&Contents" ),
  217. _( "Open the eeschema manual" ) );
  218. item->SetBitmap( online_help_xpm );
  219. helpMenu->Append( item );
  220. /**
  221. * Create the menubar and append all submenus
  222. */
  223. menuBar->Append( filesMenu, _( "&File" ) );
  224. menuBar->Append( editMenu, _( "&Edit" ) );
  225. menuBar->Append( viewMenu, _( "&View" ) );
  226. menuBar->Append( placeMenu, _( "&Place" ) );
  227. menuBar->Append( configmenu, _( "&Preferences" ) );
  228. menuBar->Append( helpMenu, _( "&Help" ) );
  229. /* Associate the menu bar with the frame */
  230. SetMenuBar( menuBar );
  231. }