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.

215 lines
7.7 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
  5. * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
  6. * Copyright (C) 2012-2015 Wayne Stambaugh <stambaughw@verizon.net>
  7. * Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; either version 2
  12. * of the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, you may find one here:
  21. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  22. * or you may search the http://www.gnu.org website for the version 2 license,
  23. * or you may write to the Free Software Foundation, Inc.,
  24. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  25. */
  26. /**
  27. * @file tool_modview.cpp
  28. * @brief Build the toolbars for the library browser.
  29. */
  30. #include <dialog_helpers.h>
  31. #include <macros.h>
  32. #include <menus_helpers.h>
  33. #include <wxPcbStruct.h>
  34. #include "help_common_strings.h"
  35. #include "hotkeys.h"
  36. #include "modview_frame.h"
  37. #include "pcbnew.h"
  38. #include "pcbnew_id.h"
  39. void FOOTPRINT_VIEWER_FRAME::ReCreateHToolbar()
  40. {
  41. wxString msg;
  42. if( m_mainToolBar == NULL )
  43. {
  44. m_mainToolBar = new wxAuiToolBar( this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
  45. wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_HORZ_LAYOUT
  46. | wxAUI_TB_OVERFLOW );
  47. // Set up toolbar
  48. m_mainToolBar->AddTool( ID_MODVIEW_SELECT_LIB, wxEmptyString,
  49. KiBitmap( library_xpm ),
  50. _( "Select library to browse" ) );
  51. m_mainToolBar->AddTool( ID_MODVIEW_SELECT_PART, wxEmptyString,
  52. KiBitmap( module_xpm ),
  53. _( "Select footprint to browse" ) );
  54. m_mainToolBar->AddSeparator();
  55. m_mainToolBar->AddTool( ID_MODVIEW_PREVIOUS, wxEmptyString,
  56. KiBitmap( lib_previous_xpm ),
  57. _( "Display previous footprint" ) );
  58. m_mainToolBar->AddTool( ID_MODVIEW_NEXT, wxEmptyString,
  59. KiBitmap( lib_next_xpm ),
  60. _( "Display next footprint" ) );
  61. m_mainToolBar->AddSeparator();
  62. m_mainToolBar->AddTool( ID_MODVIEW_SHOW_3D_VIEW, wxEmptyString,
  63. KiBitmap( three_d_xpm ),
  64. _( "Show footprint in 3D viewer" ) );
  65. m_mainToolBar->AddSeparator();
  66. msg = AddHotkeyName( _( "Zoom in" ), g_Module_Viewer_Hokeys_Descr,
  67. HK_ZOOM_IN, IS_COMMENT );
  68. m_mainToolBar->AddTool( ID_VIEWER_ZOOM_IN, wxEmptyString,
  69. KiBitmap( zoom_in_xpm ), msg );
  70. msg = AddHotkeyName( _( "Zoom out" ), g_Module_Viewer_Hokeys_Descr,
  71. HK_ZOOM_OUT, IS_COMMENT );
  72. m_mainToolBar->AddTool( ID_VIEWER_ZOOM_OUT, wxEmptyString,
  73. KiBitmap( zoom_out_xpm ), msg );
  74. msg = AddHotkeyName( _( "Redraw view" ), g_Module_Viewer_Hokeys_Descr,
  75. HK_ZOOM_REDRAW );
  76. m_mainToolBar->AddTool( ID_VIEWER_ZOOM_REDRAW, wxEmptyString,
  77. KiBitmap( zoom_redraw_xpm ), msg );
  78. msg = AddHotkeyName( _( "Zoom auto" ), g_Module_Viewer_Hokeys_Descr,
  79. HK_ZOOM_AUTO );
  80. m_mainToolBar->AddTool( ID_VIEWER_ZOOM_PAGE, wxEmptyString,
  81. KiBitmap( zoom_fit_in_page_xpm ), msg );
  82. if( IsModal() )
  83. {
  84. m_mainToolBar->AddSeparator();
  85. m_mainToolBar->AddTool( ID_MODVIEW_FOOTPRINT_EXPORT_TO_BOARD, wxEmptyString,
  86. KiBitmap( export_footprint_names_xpm ),
  87. _( "Insert footprint in board" ) );
  88. }
  89. // after adding the buttons to the toolbar, must call Realize() to
  90. // reflect the changes
  91. m_mainToolBar->Realize();
  92. }
  93. m_mainToolBar->Refresh();
  94. }
  95. void FOOTPRINT_VIEWER_FRAME::ReCreateVToolbar()
  96. {
  97. }
  98. // Virtual function
  99. void FOOTPRINT_VIEWER_FRAME::ReCreateMenuBar( void )
  100. {
  101. // Create and try to get the current menubar
  102. wxMenuBar* menuBar = GetMenuBar();
  103. if( !menuBar )
  104. menuBar = new wxMenuBar();
  105. // Delete all existing menus so they can be rebuilt.
  106. // This allows language changes of the menu text on the fly.
  107. menuBar->Freeze();
  108. while( menuBar->GetMenuCount() )
  109. delete menuBar->Remove( 0 );
  110. // Recreate all menus:
  111. wxString text;
  112. // Menu File:
  113. wxMenu* fileMenu = new wxMenu;
  114. // Active library selection
  115. AddMenuItem( fileMenu, ID_MODVIEW_SELECT_LIB, _("Set Current Library"),
  116. _( "Select library to be displayed" ), KiBitmap( open_library_xpm ) );
  117. fileMenu->AppendSeparator();
  118. // Close viewer
  119. AddMenuItem( fileMenu, wxID_EXIT,
  120. _( "Cl&ose" ),
  121. _( "Close footprint viewer" ),
  122. KiBitmap( exit_xpm ) );
  123. // View menu
  124. wxMenu* viewMenu = new wxMenu;
  125. text = AddHotkeyName( _( "Zoom &In" ), g_Module_Viewer_Hokeys_Descr,
  126. HK_ZOOM_IN, IS_ACCELERATOR );
  127. AddMenuItem( viewMenu, ID_VIEWER_ZOOM_IN, text, HELP_ZOOM_IN, KiBitmap( zoom_in_xpm ) );
  128. text = AddHotkeyName( _( "Zoom &Out" ), g_Module_Viewer_Hokeys_Descr,
  129. HK_ZOOM_OUT, IS_ACCELERATOR );
  130. AddMenuItem( viewMenu, ID_VIEWER_ZOOM_OUT, text, HELP_ZOOM_OUT, KiBitmap( zoom_out_xpm ) );
  131. text = AddHotkeyName( _( "&Fit on Screen" ), g_Module_Viewer_Hokeys_Descr,
  132. HK_ZOOM_AUTO );
  133. AddMenuItem( viewMenu, ID_VIEWER_ZOOM_PAGE, text, HELP_ZOOM_FIT,
  134. KiBitmap( zoom_fit_in_page_xpm ) );
  135. text = AddHotkeyName( _( "&Redraw" ), g_Module_Viewer_Hokeys_Descr, HK_ZOOM_REDRAW );
  136. AddMenuItem( viewMenu, ID_VIEWER_ZOOM_REDRAW, text,
  137. HELP_ZOOM_REDRAW, KiBitmap( zoom_redraw_xpm ) );
  138. viewMenu->AppendSeparator();
  139. // 3D view
  140. text = AddHotkeyName( _( "3&D Viewer" ), g_Module_Viewer_Hokeys_Descr, HK_3D_VIEWER );
  141. AddMenuItem( viewMenu, ID_MODVIEW_SHOW_3D_VIEW, text, _( "Show footprint in 3D viewer" ),
  142. KiBitmap( three_d_xpm ) );
  143. // Menu Help:
  144. wxMenu* helpMenu = new wxMenu;
  145. // Contents
  146. AddMenuItem( helpMenu, wxID_HELP,
  147. _( "Pcbnew &Manual" ),
  148. _( "Open the Pcbnew manual" ),
  149. KiBitmap( online_help_xpm ) );
  150. AddMenuItem( helpMenu, wxID_INDEX,
  151. _( "&Getting Started in KiCad" ),
  152. _( "Open the \"Getting Started in KiCad\" guide for beginners" ),
  153. KiBitmap( help_xpm ) );
  154. // About Pcbnew
  155. helpMenu->AppendSeparator();
  156. AddMenuItem( helpMenu, wxID_ABOUT,
  157. _( "&About Pcbnew" ),
  158. _( "About Pcbnew PCB designer" ),
  159. KiBitmap( info_xpm ) );
  160. // Append menus to the menubar
  161. menuBar->Append( fileMenu, _( "&File" ) );
  162. menuBar->Append( viewMenu, _( "&View" ) );
  163. menuBar->Append( helpMenu, _( "&Help" ) );
  164. menuBar->Thaw();
  165. // Associate the menu bar with the frame, if no previous menubar
  166. if( GetMenuBar() == NULL )
  167. SetMenuBar( menuBar );
  168. else
  169. menuBar->Refresh();
  170. }