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.

192 lines
5.6 KiB

  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. /************************************************/
  16. void WinEDA_SchematicFrame::ReCreateMenuBar(void)
  17. /************************************************/
  18. /* create or update the menubar for the schematic frame
  19. */
  20. {
  21. int ii;
  22. wxMenuBar * menuBar = GetMenuBar();
  23. if( menuBar == NULL )
  24. {
  25. menuBar = new wxMenuBar();
  26. m_FilesMenu = new wxMenu;
  27. wxMenuItem *item = new wxMenuItem(m_FilesMenu, ID_LOAD_PROJECT,
  28. _("&Load Schematic Project"),
  29. _("Load a schematic project (Schematic, libraries...)") );
  30. item->SetBitmap(open_xpm);
  31. m_FilesMenu->Append(item);
  32. item = new wxMenuItem(m_FilesMenu, ID_LOAD_ONE_SHEET,
  33. _("&Reload the current sheet"),
  34. _("Load or reload a schematic file from file into the current sheet") );
  35. item->SetBitmap(import_xpm);
  36. m_FilesMenu->Append(item);
  37. m_FilesMenu->AppendSeparator();
  38. item = new wxMenuItem(m_FilesMenu,ID_SAVE_PROJECT,
  39. _("&Save Schematic Project"),
  40. _("Save all") );
  41. item->SetBitmap(save_project_xpm);
  42. m_FilesMenu->Append(item);
  43. m_FilesMenu->AppendSeparator();
  44. item = new wxMenuItem(m_FilesMenu, ID_SAVE_ONE_SHEET,
  45. _("Save &Current sheet"),
  46. _("Save current sheet only") );
  47. item->SetBitmap(save_xpm);
  48. m_FilesMenu->Append(item);
  49. item = new wxMenuItem(m_FilesMenu, ID_SAVE_ONE_SHEET_AS,
  50. _("Save Current sheet &as.."),
  51. _("Save current sheet as..") );
  52. item->SetBitmap(save_as_xpm);
  53. m_FilesMenu->Append(item);
  54. /* Plot Menu */
  55. item = new wxMenuItem(m_FilesMenu, ID_GEN_PRINT,
  56. _("P&rint"), _("Print on current printer") );
  57. item->SetBitmap(print_button);
  58. m_FilesMenu->Append(item);
  59. wxMenu *choice_plot_fmt = new wxMenu;
  60. item = new wxMenuItem(choice_plot_fmt, ID_GEN_PLOT_PS,
  61. _("Plot Postscript"), _("Plotting in Postscript format") );
  62. item->SetBitmap(plot_PS_xpm);
  63. choice_plot_fmt->Append(item);
  64. item = new wxMenuItem(choice_plot_fmt, ID_GEN_PLOT_HPGL,
  65. _("Plot HPGL"), _("Plotting in HPGL format") );
  66. item->SetBitmap(plot_HPG_xpm);
  67. choice_plot_fmt->Append(item);
  68. item = new wxMenuItem(choice_plot_fmt, ID_GEN_PLOT_SVG,
  69. _("Plot SVG"), _("Plotting in SVG format") );
  70. item->SetBitmap(plot_xpm);
  71. choice_plot_fmt->Append(item);
  72. #ifdef __WINDOWS__
  73. /* Under windows, one can draw to the clipboard */
  74. item = new wxMenuItem(choice_plot_fmt, ID_GEN_COPY_SHEET_TO_CLIPBOARD,
  75. _("Plot to Clipboard"), _("Export drawings to clipboard") );
  76. item->SetBitmap(copy_button);
  77. choice_plot_fmt->Append(item);
  78. #endif
  79. m_FilesMenu->AppendSeparator();
  80. ADD_MENUITEM_WITH_HELP_AND_SUBMENU(m_FilesMenu, choice_plot_fmt,
  81. ID_GEN_PLOT, _("&Plot"), _("Plot Hplg, Postscript, SVG"), plot_xpm);
  82. m_FilesMenu->AppendSeparator();
  83. item = new wxMenuItem(m_FilesMenu, ID_EXIT, _("E&xit"), _("Quit Eeschema") );
  84. item->SetBitmap(exit_xpm);
  85. m_FilesMenu->Append(item);
  86. // Create the list of last edited schematic files
  87. m_FilesMenu->AppendSeparator();
  88. int max_file = m_Parent->m_LastProjectMaxCount;
  89. for ( ii = 0; ii < max_file; ii++ )
  90. {
  91. if ( GetLastProject(ii).IsEmpty() ) break;
  92. item = new wxMenuItem(m_FilesMenu, ID_LOAD_FILE_1 + ii,
  93. GetLastProject(ii));
  94. m_FilesMenu->Append(item);
  95. }
  96. // Menu Configuration:
  97. wxMenu * configmenu = new wxMenu;
  98. item = new wxMenuItem(configmenu, ID_CONFIG_REQ,
  99. _("&Libs and Dir"),
  100. _("Setting Libraries, Directories and others...") );
  101. item->SetBitmap(library_xpm);
  102. configmenu->Append(item);
  103. item = new wxMenuItem(configmenu, ID_COLORS_SETUP,
  104. _("&Colors"),
  105. _("Setting colors ...") );
  106. item->SetBitmap(palette_xpm);
  107. configmenu->Append(item);
  108. ADD_MENUITEM(configmenu, ID_OPTIONS_SETUP, _("&Options"), preference_xpm);
  109. // Font selection and setup
  110. AddFontSelectionMenu(configmenu);
  111. m_Parent->SetLanguageList(configmenu);
  112. configmenu->AppendSeparator();
  113. item = new wxMenuItem(configmenu, ID_CONFIG_SAVE, _("&Save Eeschema Setup"),
  114. _("Save options in <project>.pro") );
  115. item->SetBitmap(save_setup_xpm);
  116. configmenu->Append(item);
  117. item = new wxMenuItem(configmenu, ID_CONFIG_READ, _("&Read Setup"),
  118. _("Read options from a selected config file"));
  119. item->SetBitmap(read_setup_xpm);
  120. configmenu->Append(item);
  121. // Menu Help:
  122. wxMenu *helpMenu = new wxMenu;
  123. item = new wxMenuItem(helpMenu , ID_GENERAL_HELP,
  124. _("&Contents"), _("Open the eeschema manual"));
  125. item->SetBitmap(help_xpm);
  126. helpMenu->Append(item);
  127. item = new wxMenuItem(helpMenu , ID_KICAD_ABOUT,
  128. _("&About"), _("About this application"));
  129. item->SetBitmap(info_xpm);
  130. helpMenu->Append(item);
  131. menuBar->Append(m_FilesMenu, _("&Files") );
  132. menuBar->Append(configmenu, _("&Preferences") );
  133. menuBar->Append(helpMenu, _("&Help") );
  134. // Associate the menu bar with the frame
  135. SetMenuBar(menuBar);
  136. }
  137. else // Update the list of last edited schematic files
  138. {
  139. wxMenuItem * item;
  140. int max_file = m_Parent->m_LastProjectMaxCount;
  141. for ( ii = max_file-1; ii >=0 ; ii-- )
  142. {
  143. if( m_FilesMenu->FindItem(ID_LOAD_FILE_1 + ii) )
  144. {
  145. item = m_FilesMenu->Remove(ID_LOAD_FILE_1 + ii);
  146. if ( item ) delete item;
  147. }
  148. }
  149. for ( ii = 0; ii < max_file; ii++ )
  150. {
  151. if ( GetLastProject(ii).IsEmpty() ) break;
  152. item = new wxMenuItem(m_FilesMenu, ID_LOAD_FILE_1 + ii,
  153. GetLastProject(ii));
  154. m_FilesMenu->Append(item);
  155. }
  156. }
  157. }