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.

256 lines
9.0 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
* 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
* 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) 2016 KiCad Developers, see AUTHORS.txt for contributors.
  5. * Copyright (C) 2013 CERN
  6. * @author Jean-Pierre Charras, jp.charras at wanadoo.fr
  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 pagelayout_editor/menubar.cpp
  27. * @brief (Re)Create the main menubar for Pl_Editor
  28. */
  29. #include <kiface_i.h>
  30. #include <menus_helpers.h>
  31. #include <pgm_base.h>
  32. #include "hotkeys.h"
  33. #include "pl_editor_frame.h"
  34. #include "pl_editor_id.h"
  35. void PL_EDITOR_FRAME::ReCreateMenuBar()
  36. {
  37. wxString msg;
  38. static wxMenu* openRecentMenu; // Open Recent submenu,
  39. // static to remember this menu
  40. // Create and try to get the current menubar
  41. wxMenuBar* menuBar = GetMenuBar();
  42. if( !menuBar )
  43. menuBar = new wxMenuBar();
  44. // Delete all existing menus so they can be rebuilt.
  45. // This allows language changes of the menu text on the fly.
  46. menuBar->Freeze();
  47. // Before deleting, remove the menus managed by m_fileHistory
  48. // (the file history will be updated when adding/removing files in history
  49. if( openRecentMenu )
  50. Kiface().GetFileHistory().RemoveMenu( openRecentMenu );
  51. // Delete all existing menus
  52. while( menuBar->GetMenuCount() )
  53. delete menuBar->Remove( 0 );
  54. // Recreate all menus:
  55. // File Menu:
  56. wxMenu* fileMenu = new wxMenu;
  57. msg = AddHotkeyName( _( "&New" ), PlEditorHokeysDescr, HK_NEW );
  58. AddMenuItem( fileMenu, wxID_NEW, msg,
  59. _( "Create new page layout design" ),
  60. KiBitmap( new_page_layout_xpm ) );
  61. msg = AddHotkeyName( _( "&Open..." ), PlEditorHokeysDescr, HK_OPEN );
  62. AddMenuItem( fileMenu, wxID_OPEN, msg,
  63. _( "Open an existing page layout design file" ),
  64. KiBitmap( open_page_layout_xpm ) );
  65. openRecentMenu = new wxMenu();
  66. Kiface().GetFileHistory().UseMenu( openRecentMenu );
  67. Kiface().GetFileHistory().AddFilesToMenu();
  68. AddMenuItem( fileMenu, openRecentMenu,
  69. wxID_ANY,
  70. _( "Open &Recent" ),
  71. _( "Open recent page layout design file" ),
  72. KiBitmap( recent_xpm ) );
  73. fileMenu->AppendSeparator();
  74. msg = AddHotkeyName( _( "&Save" ), PlEditorHokeysDescr, HK_SAVE );
  75. AddMenuItem( fileMenu, wxID_SAVE, msg,
  76. _( "Save current page layout design file" ),
  77. KiBitmap( save_xpm ) );
  78. msg = AddHotkeyName( _( "Save &As..." ), PlEditorHokeysDescr, HK_SAVEAS );
  79. AddMenuItem( fileMenu, wxID_SAVEAS, msg,
  80. _( "Save current page layout design file with a different name" ),
  81. KiBitmap( save_as_xpm ) );
  82. fileMenu->AppendSeparator();
  83. msg = AddHotkeyName( _( "&Print..." ), PlEditorHokeysDescr, HK_PRINT );
  84. AddMenuItem( fileMenu, wxID_PRINT, msg,
  85. wxEmptyString, KiBitmap( print_button_xpm ) );
  86. AddMenuItem( fileMenu, wxID_PREVIEW, _( "Print Pre&view..." ),
  87. wxEmptyString, KiBitmap( print_button_xpm ) );
  88. fileMenu->AppendSeparator();
  89. AddMenuItem( fileMenu, wxID_EXIT, _( "&Close" ),
  90. _( "Close Page Layout Editor" ), KiBitmap( exit_xpm ) );
  91. // Edit Menu:
  92. wxMenu* editMenu = new wxMenu;
  93. msg = AddHotkeyName( _( "Undo" ), PlEditorHokeysDescr, HK_UNDO );
  94. AddMenuItem( editMenu, wxID_UNDO, msg, wxEmptyString, KiBitmap( undo_xpm ) );
  95. msg = AddHotkeyName( _( "Redo" ), PlEditorHokeysDescr, HK_REDO );
  96. AddMenuItem( editMenu, wxID_REDO, msg, wxEmptyString, KiBitmap( redo_xpm ) );
  97. editMenu->AppendSeparator();
  98. AddMenuItem( editMenu, wxID_CUT, _( "Delete" ), wxEmptyString, KiBitmap( delete_xpm ) );
  99. // View Menu:
  100. wxMenu* viewMenu = new wxMenu;
  101. msg = AddHotkeyName( _( "Zoom In" ), PlEditorHokeysDescr, HK_ZOOM_IN );
  102. AddMenuItem( viewMenu, ID_ZOOM_IN, msg, wxEmptyString, KiBitmap( zoom_in_xpm ) );
  103. msg = AddHotkeyName( _( "Zoom Out" ), PlEditorHokeysDescr, HK_ZOOM_OUT );
  104. AddMenuItem( viewMenu, ID_ZOOM_OUT, msg, wxEmptyString, KiBitmap( zoom_out_xpm ) );
  105. msg = AddHotkeyName( _( "Zoom All" ), PlEditorHokeysDescr, HK_ZOOM_AUTO );
  106. AddMenuItem( viewMenu, ID_ZOOM_PAGE, msg, wxEmptyString, KiBitmap( zoom_fit_in_page_xpm ) );
  107. msg = AddHotkeyName( _( "Zoom to Selection" ), PlEditorHokeysDescr, HK_ZOOM_SELECTION );
  108. AddMenuItem( viewMenu, ID_ZOOM_SELECTION, msg, wxEmptyString, KiBitmap( zoom_area_xpm ) );
  109. viewMenu->AppendSeparator();
  110. msg = AddHotkeyName( _( "Redraw View" ), PlEditorHokeysDescr, HK_ZOOM_REDRAW );
  111. AddMenuItem( viewMenu, ID_ZOOM_REDRAW, msg, wxEmptyString, KiBitmap( zoom_redraw_xpm ) );
  112. // Place Menu:
  113. wxMenu* placeMenu = new wxMenu;
  114. AddMenuItem( placeMenu, ID_POPUP_ITEM_ADD_LINE, _( "&Line..." ),
  115. wxEmptyString, KiBitmap( add_dashed_line_xpm ) );
  116. AddMenuItem( placeMenu, ID_POPUP_ITEM_ADD_RECT, _( "&Rectangle..." ),
  117. wxEmptyString, KiBitmap( add_rectangle_xpm ) );
  118. AddMenuItem( placeMenu, ID_POPUP_ITEM_ADD_TEXT, _( "&Text..." ),
  119. wxEmptyString, KiBitmap( text_xpm ) );
  120. AddMenuItem( placeMenu, ID_POPUP_ITEM_ADD_BITMAP, _( "&Bitmap..." ),
  121. wxEmptyString, KiBitmap( image_xpm ) );
  122. placeMenu->AppendSeparator();
  123. AddMenuItem( placeMenu, ID_APPEND_DESCR_FILE, _( "&Append Existing Page Layout Design File..." ),
  124. _( "Append an existing page layout design file to current file" ),
  125. KiBitmap( pagelayout_load_xpm ) );
  126. // Menu for preferences
  127. wxMenu* preferencesMenu = new wxMenu;
  128. AddMenuItem( preferencesMenu,
  129. ID_MENU_SWITCH_BGCOLOR,
  130. GetDrawBgColor() == WHITE ?
  131. _( "&Background Black" ) : _( "&Background White" ),
  132. wxEmptyString, KiBitmap( palette_xpm ) );
  133. AddMenuItem( preferencesMenu,
  134. ID_MENU_GRID_ONOFF,
  135. IsGridVisible() ? _( "Hide &Grid" ) : _( "Show &Grid" ),
  136. wxEmptyString, KiBitmap( grid_xpm ) );
  137. // Text editor selection
  138. AddMenuItem( preferencesMenu,
  139. ID_MENU_PL_EDITOR_SELECT_PREFERED_EDITOR,
  140. _( "Set &Text Editor..." ),
  141. _( "Select your preferred text editor" ),
  142. KiBitmap( editor_xpm ) );
  143. // Language submenu
  144. Pgm().AddMenuLanguageList( preferencesMenu );
  145. // Icons options submenu
  146. AddMenuIconsOptions( preferencesMenu );
  147. // Hotkey submenu
  148. AddHotkeyConfigMenu( preferencesMenu );
  149. // Menu Help
  150. wxMenu* helpMenu = new wxMenu;
  151. // Contents
  152. AddMenuItem( helpMenu,
  153. wxID_HELP,
  154. _( "Page Layout Editor &Manual" ),
  155. _( "Open the Page Layout Editor Manual" ),
  156. KiBitmap( online_help_xpm ) );
  157. AddMenuItem( helpMenu,
  158. wxID_INDEX,
  159. _( "&Getting Started in KiCad" ),
  160. _( "Open \"Getting Started in KiCad\" guide for beginners" ),
  161. KiBitmap( help_xpm ) );
  162. msg = AddHotkeyName( _( "&List Hotkeys" ), PlEditorHokeysDescr, HK_HELP );
  163. AddMenuItem( helpMenu, ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST, msg,
  164. _( "Displays the current hotkeys list and corresponding commands" ),
  165. KiBitmap( hotkeys_xpm ) );
  166. helpMenu->AppendSeparator();
  167. AddMenuItem( helpMenu, ID_HELP_GET_INVOLVED,
  168. _( "Get &Involved" ),
  169. _( "Contribute to KiCad (opens a web browser)" ),
  170. KiBitmap( info_xpm ) );
  171. // Separator
  172. helpMenu->AppendSeparator();
  173. // About Kicad
  174. AddMenuItem( helpMenu,
  175. wxID_ABOUT,
  176. _( "&About KiCad" ),
  177. _( "About KiCad" ),
  178. KiBitmap( about_xpm ) );
  179. // Append menus to the menubar
  180. menuBar->Append( fileMenu, _( "&File" ) );
  181. menuBar->Append( editMenu, _( "&Edit" ) );
  182. menuBar->Append( viewMenu, _( "&View" ) );
  183. menuBar->Append( placeMenu, _( "&Place" ) );
  184. menuBar->Append( preferencesMenu, _( "P&references" ) );
  185. menuBar->Append( helpMenu, _( "&Help" ) );
  186. menuBar->Thaw();
  187. // Associate the menu bar with the frame, if no previous menubar
  188. if( GetMenuBar() == NULL )
  189. SetMenuBar( menuBar );
  190. else
  191. menuBar->Refresh();
  192. }