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.

177 lines
5.7 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
  5. * Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version 2
  10. * of the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, you may find one here:
  19. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  20. * or you may search the http://www.gnu.org website for the version 2 license,
  21. * or you may write to the Free Software Foundation, Inc.,
  22. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  23. */
  24. /**
  25. * @file cvpcb/menubar.cpp
  26. * @brief (Re)Create the menubar for CvPcb
  27. */
  28. #include <fctsys.h>
  29. #include <appl_wxstruct.h>
  30. #include <confirm.h>
  31. #include <gestfich.h>
  32. #include <menus_helpers.h>
  33. #include <cvpcb.h>
  34. #include <cvpcb_mainframe.h>
  35. #include <cvpcb_id.h>
  36. #include <common_help_msg.h>
  37. /**
  38. * @brief (Re)Create the menubar for the CvPcb mainframe
  39. */
  40. void CVPCB_MAINFRAME::ReCreateMenuBar()
  41. {
  42. // Create and try to get the current menubar
  43. wxMenuItem* item;
  44. wxMenuBar* menuBar = GetMenuBar();
  45. if( ! menuBar ) // Delete all menus
  46. menuBar = new wxMenuBar();
  47. // Delete all existing menus so they can be rebuilt.
  48. // This allows language changes of the menu text on the fly.
  49. menuBar->Freeze();
  50. while( menuBar->GetMenuCount() )
  51. delete menuBar->Remove( 0 );
  52. // Recreate all menus:
  53. // Menu File:
  54. wxMenu* filesMenu = new wxMenu;
  55. // Open
  56. AddMenuItem( filesMenu,
  57. ID_LOAD_PROJECT,
  58. _( "&Open" ), LOAD_FILE_HELP, KiBitmap( open_document_xpm ) );
  59. // Open Recent submenu
  60. static wxMenu* openRecentMenu;
  61. // Add this menu to list menu managed by m_fileHistory
  62. // (the file history will be updated when adding/removing files in history
  63. if( openRecentMenu )
  64. wxGetApp().GetFileHistory().RemoveMenu( openRecentMenu );
  65. openRecentMenu = new wxMenu();
  66. wxGetApp().GetFileHistory().UseMenu( openRecentMenu );
  67. wxGetApp().GetFileHistory().AddFilesToMenu();
  68. AddMenuItem( filesMenu, openRecentMenu, -1,
  69. _( "Open &Recent" ),
  70. _( "Open a recent opened netlist document" ),
  71. KiBitmap( open_project_xpm ) );
  72. // Separator
  73. filesMenu->AppendSeparator();
  74. // Save the .cmp file
  75. AddMenuItem( filesMenu,
  76. wxID_SAVE,
  77. _( "&Save\tCtrl+S" ), SAVE_HLP_MSG, KiBitmap( save_xpm ) );
  78. // Save as the .cmp file
  79. AddMenuItem( filesMenu,
  80. wxID_SAVEAS,
  81. _( "Save &As...\tCtrl+Shift+S" ), SAVE_AS_HLP_MSG, KiBitmap( save_xpm ) );
  82. // Separator
  83. filesMenu->AppendSeparator();
  84. // Quit
  85. AddMenuItem( filesMenu,
  86. wxID_EXIT,
  87. _( "&Quit" ),
  88. _( "Quit CvPcb" ),
  89. KiBitmap( exit_xpm ) );
  90. // Menu Preferences:
  91. wxMenu* preferencesMenu = new wxMenu;
  92. #if !defined( USE_FP_LIB_TABLE )
  93. // Libraries to load
  94. AddMenuItem( preferencesMenu, wxID_PREFERENCES,
  95. _( "&Libraries" ),
  96. _( "Set footprint libraries to load and library search paths" ),
  97. KiBitmap( config_xpm ) );
  98. #else
  99. AddMenuItem( preferencesMenu, ID_CVPCB_LIB_TABLE_EDIT,
  100. _( "Li&brary Tables" ), _( "Setup footprint libraries" ),
  101. KiBitmap( library_table_xpm ) );
  102. #endif
  103. // Language submenu
  104. wxGetApp().AddMenuLanguageList( preferencesMenu );
  105. // Keep open on save
  106. item = new wxMenuItem( preferencesMenu, ID_CVPCB_CONFIG_KEEP_OPEN_ON_SAVE,
  107. _( "Keep Open On Save" ),
  108. _( "Prevent CvPcb from exiting after saving netlist file" ),
  109. wxITEM_CHECK );
  110. preferencesMenu->Append( item );
  111. SETBITMAPS( window_close_xpm );
  112. // Separator
  113. preferencesMenu->AppendSeparator();
  114. AddMenuItem( preferencesMenu, ID_SAVE_PROJECT,
  115. _( "&Save Project File" ),
  116. _( "Save changes to the project configuration file" ),
  117. KiBitmap( save_setup_xpm ) );
  118. AddMenuItem( preferencesMenu, ID_SAVE_PROJECT_AS,
  119. _( "&Save Project File As" ),
  120. _( "Save changes to the project configuration to a new file" ),
  121. KiBitmap( save_setup_xpm ) );
  122. // Menu Help:
  123. wxMenu* helpMenu = new wxMenu;
  124. // Version info
  125. AddHelpVersionInfoMenuEntry( helpMenu );
  126. // Contents
  127. AddMenuItem( helpMenu, wxID_HELP, _( "&Contents" ),
  128. _( "Open the CvPcb handbook" ),
  129. KiBitmap( online_help_xpm ) );
  130. // About
  131. AddMenuItem( helpMenu, wxID_ABOUT,
  132. _( "&About CvPcb" ),
  133. _( "About CvPcb footprint selector" ),
  134. KiBitmap( info_xpm ) );
  135. // Create the menubar and append all submenus
  136. menuBar->Append( filesMenu, _( "&File" ) );
  137. menuBar->Append( preferencesMenu, _( "&Preferences" ) );
  138. menuBar->Append( helpMenu, _( "&Help" ) );
  139. menuBar->Thaw();
  140. // Associate the menu bar with the frame, if no previous menubar
  141. if( GetMenuBar() == NULL )
  142. SetMenuBar( menuBar );
  143. else
  144. menuBar->Refresh();
  145. }