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.

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