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.

442 lines
16 KiB

18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
  1. /*************************************************************/
  2. /* menubar.cpp - create the menubar for the schematic frame */
  3. /*************************************************************/
  4. #ifdef __GNUG__
  5. #pragma implementation
  6. #endif
  7. #include "fctsys.h"
  8. #include "common.h"
  9. #include "program.h"
  10. #include "libcmp.h"
  11. #include "general.h"
  12. #include "bitmaps.h"
  13. #include "protos.h"
  14. #include "id.h"
  15. #include "hotkeys.h"
  16. /************************************************/
  17. void WinEDA_SchematicFrame::ReCreateMenuBar()
  18. /************************************************/
  19. /* create or update the menubar for the schematic frame
  20. */
  21. {
  22. int ii;
  23. wxMenuBar* menuBar = GetMenuBar();
  24. wxString msg;
  25. if( menuBar == NULL )
  26. {
  27. menuBar = new wxMenuBar();
  28. m_FilesMenu = new wxMenu;
  29. // Menu File:
  30. wxMenuItem* item = new wxMenuItem( m_FilesMenu, ID_NEW_PROJECT,
  31. _( "&New" ),
  32. _( "New schematic" ) );
  33. item->SetBitmap( new_xpm );
  34. m_FilesMenu->Append( item );
  35. item = new wxMenuItem( m_FilesMenu, ID_LOAD_PROJECT,
  36. _( "&Open" ),
  37. _( "Open a schematic" ) );
  38. item->SetBitmap( open_xpm );
  39. m_FilesMenu->Append( item );
  40. m_FilesMenu->AppendSeparator();
  41. item = new wxMenuItem( m_FilesMenu, ID_SAVE_PROJECT,
  42. _( "&Save" ),
  43. _( "Save schematic project" ) );
  44. item->SetBitmap( save_project_xpm );
  45. m_FilesMenu->Append( item );
  46. m_FilesMenu->AppendSeparator();
  47. item = new wxMenuItem( m_FilesMenu, ID_SAVE_ONE_SHEET,
  48. _( "Save &Current sheet" ),
  49. _( "Save current sheet only" ) );
  50. item->SetBitmap( save_xpm );
  51. m_FilesMenu->Append( item );
  52. item = new wxMenuItem( m_FilesMenu, ID_SAVE_ONE_SHEET_AS,
  53. _( "Save Current sheet &as.." ),
  54. _( "Save current sheet as.." ) );
  55. item->SetBitmap( save_as_xpm );
  56. m_FilesMenu->Append( item );
  57. // Print and Plot section:
  58. m_FilesMenu->AppendSeparator();
  59. item = new wxMenuItem( m_FilesMenu, ID_GEN_PRINT,
  60. _( "P&rint" ), _( "Print on current printer" ) );
  61. item->SetBitmap( print_button );
  62. m_FilesMenu->Append( item );
  63. /* Plot Submenu */
  64. wxMenu* choice_plot_fmt = new wxMenu;
  65. item = new wxMenuItem( choice_plot_fmt, ID_GEN_PLOT_PS,
  66. _( "Plot PostScript" ), _( "Plotting in PostScript format" ) );
  67. item->SetBitmap( plot_PS_xpm );
  68. choice_plot_fmt->Append( item );
  69. item = new wxMenuItem( choice_plot_fmt, ID_GEN_PLOT_HPGL,
  70. _( "Plot HPGL" ), _( "Plotting in HPGL format" ) );
  71. item->SetBitmap( plot_HPG_xpm );
  72. choice_plot_fmt->Append( item );
  73. item = new wxMenuItem( choice_plot_fmt, ID_GEN_PLOT_SVG,
  74. _( "Plot SVG" ), _( "Plotting in SVG format" ) );
  75. item->SetBitmap( plot_xpm );
  76. choice_plot_fmt->Append( item );
  77. #ifdef __WINDOWS__
  78. /* Under windows, one can draw to the clipboard */
  79. item = new wxMenuItem( choice_plot_fmt, ID_GEN_COPY_SHEET_TO_CLIPBOARD,
  80. _( "Plot to Clipboard" ), _( "Export drawings to clipboard" ) );
  81. item->SetBitmap( copy_button );
  82. choice_plot_fmt->Append( item );
  83. #endif
  84. ADD_MENUITEM_WITH_HELP_AND_SUBMENU( m_FilesMenu, choice_plot_fmt,
  85. ID_GEN_PLOT, _( "&Plot" ),
  86. _( "Plot HPGL, PostScript, SVG" ), plot_xpm );
  87. m_FilesMenu->AppendSeparator();
  88. item = new wxMenuItem( m_FilesMenu, ID_EXIT, _( "E&xit" ), _( "Quit Eeschema" ) );
  89. item->SetBitmap( exit_xpm );
  90. m_FilesMenu->Append( item );
  91. // Create the list of last edited schematic files
  92. m_FilesMenu->AppendSeparator();
  93. int max_file = m_Parent->m_LastProjectMaxCount;
  94. for( ii = 0; ii < max_file; ii++ )
  95. {
  96. if( GetLastProject( ii ).IsEmpty() )
  97. break;
  98. item = new wxMenuItem( m_FilesMenu, ID_LOAD_FILE_1 + ii,
  99. GetLastProject( ii ) );
  100. m_FilesMenu->Append( item );
  101. }
  102. // Menu Edit:
  103. wxMenu* editMenu = new wxMenu;
  104. msg = AddHotkeyName( _( "&Undo\t" ), s_Schematic_Hokeys_Descr,
  105. HK_UNDO );
  106. item = new wxMenuItem( editMenu, ID_SCHEMATIC_UNDO,
  107. msg, _( "Undo last edition" ),
  108. wxITEM_NORMAL );
  109. item->SetBitmap( undo_xpm );
  110. editMenu->Append( item );
  111. msg = AddHotkeyName( _( "&Redo\t" ), s_Schematic_Hokeys_Descr,
  112. HK_REDO );
  113. item = new wxMenuItem( editMenu, ID_SCHEMATIC_REDO,
  114. msg, _( "Redo the last undo command" ),
  115. wxITEM_NORMAL );
  116. item->SetBitmap( redo_xpm );
  117. editMenu->Append( item );
  118. editMenu->AppendSeparator();
  119. item = new wxMenuItem( editMenu, ID_SCHEMATIC_DELETE_ITEM_BUTT,
  120. _( "Delete" ), _( "Delete items" ),
  121. wxITEM_NORMAL );
  122. item->SetBitmap( delete_body_xpm );
  123. editMenu->Append( item );
  124. editMenu->AppendSeparator();
  125. item = new wxMenuItem( editMenu, ID_FIND_ITEMS,
  126. _( "Find" ), _( "Find components and texts" ),
  127. wxITEM_NORMAL );
  128. item->SetBitmap( find_xpm );
  129. editMenu->Append( item );
  130. editMenu->AppendSeparator();
  131. item = new wxMenuItem( editMenu, ID_BACKANNO_ITEMS,
  132. _( "BackAnno" ), _( "Back Annotated Footprint Fields" ),
  133. wxITEM_NORMAL );
  134. item->SetBitmap( backanno_xpm );
  135. editMenu->Append( item );
  136. // Menu View:
  137. wxMenu* viewMenu = new wxMenu;
  138. msg = AddHotkeyName( _( "Zoom in" ), s_Schematic_Hokeys_Descr,
  139. HK_ZOOM_IN);
  140. item = new wxMenuItem( viewMenu, ID_ZOOM_IN_BUTT,
  141. msg, _( "Zoom in" ),
  142. wxITEM_NORMAL );
  143. item->SetBitmap( zoom_in_xpm );
  144. viewMenu->Append( item );
  145. msg = AddHotkeyName( _( "Zoom out" ), s_Schematic_Hokeys_Descr,
  146. HK_ZOOM_OUT );
  147. item = new wxMenuItem( viewMenu, ID_ZOOM_OUT_BUTT,
  148. msg, _( "Zoom out" ),
  149. wxITEM_NORMAL );
  150. item->SetBitmap( zoom_out_xpm );
  151. viewMenu->Append( item );
  152. item = new wxMenuItem( viewMenu, ID_ZOOM_PAGE_BUTT,
  153. _( "Zoom auto" ), _( "Zoom auto" ),
  154. wxITEM_NORMAL );
  155. item->SetBitmap( zoom_optimal_xpm );
  156. viewMenu->Append( item );
  157. viewMenu->AppendSeparator();
  158. msg = AddHotkeyName( _( "redraw" ), s_Schematic_Hokeys_Descr,
  159. HK_ZOOM_REDRAW );
  160. item = new wxMenuItem( viewMenu, ID_ZOOM_REDRAW_BUTT,
  161. msg, _( "Zoom auto" ),
  162. wxITEM_NORMAL );
  163. item->SetBitmap( repaint_xpm );
  164. viewMenu->Append( item );
  165. // Place Menu
  166. //TODO: Unify the ID names!
  167. wxMenu* placeMenu = new wxMenu;
  168. item = new wxMenuItem( placeMenu, ID_COMPONENT_BUTT,
  169. _( "&Component" ), _( "Place the component" ),
  170. wxITEM_NORMAL );
  171. item->SetBitmap( add_component_xpm );
  172. placeMenu->Append( item );
  173. item = new wxMenuItem( placeMenu, ID_PLACE_POWER_BUTT,
  174. _( "&Power port" ), _( "Place the power port" ),
  175. wxITEM_NORMAL );
  176. item->SetBitmap( add_power_xpm );
  177. placeMenu->Append( item );
  178. item = new wxMenuItem( placeMenu, ID_WIRE_BUTT,
  179. _( "&Wire" ), _( "Place the wire" ),
  180. wxITEM_NORMAL );
  181. item->SetBitmap( add_line_xpm );
  182. placeMenu->Append( item );
  183. item = new wxMenuItem(
  184. placeMenu,
  185. ID_BUS_BUTT,
  186. _( "&Bus" ),
  187. _( "Place the bus" ),
  188. wxITEM_NORMAL
  189. );
  190. item->SetBitmap( add_bus_xpm );
  191. placeMenu->Append( item );
  192. item = new wxMenuItem(
  193. placeMenu,
  194. ID_WIRETOBUS_ENTRY_BUTT,
  195. _( "W&ire to bus entry" ),
  196. _( "Place the wire to bus entry" ),
  197. wxITEM_NORMAL
  198. );
  199. item->SetBitmap( add_line2bus_xpm );
  200. placeMenu->Append( item );
  201. item = new wxMenuItem(
  202. placeMenu,
  203. ID_BUSTOBUS_ENTRY_BUTT,
  204. _( "B&us to bus entry" ),
  205. _( "Place the bus to bus entry" ),
  206. wxITEM_NORMAL
  207. );
  208. item->SetBitmap( add_bus2bus_xpm );
  209. placeMenu->Append( item );
  210. item = new wxMenuItem(
  211. placeMenu,
  212. ID_NOCONN_BUTT,
  213. _( "No connect flag" ),
  214. _( "Place the no connect flag" ),
  215. wxITEM_NORMAL
  216. );
  217. item->SetBitmap( noconn_button );
  218. placeMenu->Append( item );
  219. item = new wxMenuItem(
  220. placeMenu,
  221. ID_LABEL_BUTT,
  222. _( "Net name" ),
  223. _( "Place the net name" ),
  224. wxITEM_NORMAL
  225. );
  226. item->SetBitmap( add_line_label_xpm );
  227. placeMenu->Append( item );
  228. item = new wxMenuItem( placeMenu, ID_GLABEL_BUTT,
  229. _( "Global label" ),
  230. _( "Place the global label. Warning: all global labels with the same name are connected in whole hierarchy" ),
  231. wxITEM_NORMAL
  232. );
  233. item->SetBitmap( add_glabel_xpm );
  234. placeMenu->Append( item );
  235. item = new wxMenuItem(
  236. placeMenu,
  237. ID_JUNCTION_BUTT,
  238. _( "Junction" ),
  239. _( "Place the junction" ),
  240. wxITEM_NORMAL
  241. );
  242. item->SetBitmap( add_junction_xpm );
  243. placeMenu->Append( item );
  244. placeMenu->AppendSeparator();
  245. item = new wxMenuItem(
  246. placeMenu,
  247. ID_HIERLABEL_BUTT,
  248. _( "Hierarchical label" ),
  249. _( "Place the hierarchical label. This label will be seen as a pin sheet in the sheet symbol" ),
  250. wxITEM_NORMAL
  251. );
  252. item->SetBitmap( add_hierarchical_label_xpm );
  253. placeMenu->Append( item );
  254. item = new wxMenuItem(
  255. placeMenu,
  256. ID_SHEET_SYMBOL_BUTT,
  257. _( "Hierarchical sheet" ),
  258. _( "Place the hierarchical sheet" ),
  259. wxITEM_NORMAL
  260. );
  261. item->SetBitmap( add_hierarchical_subsheet_xpm );
  262. placeMenu->Append( item );
  263. item = new wxMenuItem(
  264. placeMenu,
  265. ID_IMPORT_GLABEL_BUTT,
  266. _( "Imported hierarchical label" ),
  267. _( "Place the pin sheet (imported hierarchical label from sheet)" ),
  268. wxITEM_NORMAL
  269. );
  270. item->SetBitmap( import_hierarchical_label_xpm );
  271. placeMenu->Append( item );
  272. item = new wxMenuItem(
  273. placeMenu,
  274. ID_SHEET_LABEL_BUTT,
  275. _( "Hierarchical pin to sheet" ),
  276. _( "Place the hierarchical pin to sheet" ),
  277. wxITEM_NORMAL
  278. );
  279. item->SetBitmap( add_hierar_pin_xpm );
  280. placeMenu->Append( item );
  281. placeMenu->AppendSeparator();
  282. item = new wxMenuItem(
  283. placeMenu,
  284. ID_LINE_COMMENT_BUTT,
  285. _( "Graphic line or poligon" ),
  286. _( "Place the graphic line or poligon" ),
  287. wxITEM_NORMAL
  288. );
  289. item->SetBitmap( add_dashed_line_xpm );
  290. placeMenu->Append( item );
  291. item = new wxMenuItem(
  292. placeMenu,
  293. ID_TEXT_COMMENT_BUTT,
  294. _( "Graphic text (comment)" ),
  295. _( "Place the graphic text (comment)" ),
  296. wxITEM_NORMAL
  297. );
  298. item->SetBitmap( add_text_xpm );
  299. placeMenu->Append( item );
  300. // Menu Configuration:
  301. wxMenu* configmenu = new wxMenu;
  302. item = new wxMenuItem( configmenu, ID_CONFIG_REQ,
  303. _( "&Libs and Dir" ),
  304. _( "Setting Libraries, Directories and others..." ) );
  305. item->SetBitmap( library_xpm );
  306. configmenu->Append( item );
  307. item = new wxMenuItem( configmenu, ID_COLORS_SETUP,
  308. _( "&Colors" ),
  309. _( "Setting colors..." ) );
  310. item->SetBitmap( palette_xpm );
  311. configmenu->Append( item );
  312. // ADD_MENUITEM(configmenu, ID_OPTIONS_SETUP, _("&Options"), preference_xpm);
  313. item = new wxMenuItem( configmenu, ID_OPTIONS_SETUP,
  314. _( "&Options" ),
  315. _( "Select general options..." ) );
  316. item->SetBitmap( preference_xpm );
  317. configmenu->Append( item );
  318. // Font selection and setup
  319. AddFontSelectionMenu( configmenu );
  320. m_Parent->SetLanguageList( configmenu );
  321. configmenu->AppendSeparator();
  322. item = new wxMenuItem( configmenu, ID_CONFIG_SAVE, _( "&Save preferences" ),
  323. _( "Save application preferences" ) );
  324. item->SetBitmap( save_setup_xpm );
  325. configmenu->Append( item );
  326. item = new wxMenuItem( configmenu, ID_CONFIG_READ, _( "&Read preferences" ),
  327. _( "Read application preferences" ) );
  328. item->SetBitmap( read_setup_xpm );
  329. configmenu->Append( item );
  330. configmenu->AppendSeparator();
  331. AddHotkeyConfigMenu( configmenu );
  332. // Menu Help:
  333. wxMenu* helpMenu = new wxMenu;
  334. item = new wxMenuItem( helpMenu, ID_GENERAL_HELP,
  335. _( "&Contents" ), _( "Open the eeschema manual" ) );
  336. item->SetBitmap( help_xpm );
  337. helpMenu->Append( item );
  338. item = new wxMenuItem( helpMenu, ID_KICAD_ABOUT,
  339. _( "&About" ), _( "About this application" ) );
  340. item->SetBitmap( info_xpm );
  341. helpMenu->Append( item );
  342. menuBar->Append( m_FilesMenu, _( "&File" ) );
  343. menuBar->Append( editMenu, _( "&Edit" ) );
  344. menuBar->Append( viewMenu, _( "&View" ) );
  345. menuBar->Append( placeMenu, _( "&Place" ) );
  346. menuBar->Append( configmenu, _( "&Preferences" ) );
  347. menuBar->Append( helpMenu, _( "&Help" ) );
  348. // Associate the menu bar with the frame
  349. SetMenuBar( menuBar );
  350. }
  351. else // Update the list of last edited schematic files
  352. {
  353. wxMenuItem* item;
  354. int max_file = m_Parent->m_LastProjectMaxCount;
  355. for( ii = max_file - 1; ii >=0; ii-- )
  356. {
  357. if( m_FilesMenu->FindItem( ID_LOAD_FILE_1 + ii ) )
  358. {
  359. item = m_FilesMenu->Remove( ID_LOAD_FILE_1 + ii );
  360. if( item )
  361. {
  362. SAFE_DELETE( item );
  363. }
  364. }
  365. }
  366. for( ii = 0; ii < max_file; ii++ )
  367. {
  368. if( GetLastProject( ii ).IsEmpty() )
  369. break;
  370. item = new wxMenuItem( m_FilesMenu, ID_LOAD_FILE_1 + ii,
  371. GetLastProject( ii ) );
  372. m_FilesMenu->Append( item );
  373. }
  374. }
  375. }