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.

148 lines
5.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 Wayne Stambaugh <stambaughw@gmail.com>
  7. * Copyright (C) 1992-2019 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. #include <macros.h>
  23. #include <bitmaps.h>
  24. #include <tool/action_toolbar.h>
  25. #include <tool/conditional_menu.h>
  26. #include <tool/tool_manager.h>
  27. #include <tools/selection_tool.h>
  28. #include <tools/pcb_actions.h>
  29. #include "footprint_viewer_frame.h"
  30. #include "pcbnew_id.h"
  31. void FOOTPRINT_VIEWER_FRAME::ReCreateHToolbar()
  32. {
  33. // Note:
  34. // To rebuild the aui toolbar, the more easy way is to clear ( calling m_mainToolBar.Clear() )
  35. // all wxAuiToolBarItems.
  36. // However the wxAuiToolBarItems are not the owners of controls managed by
  37. // them ( m_zoomSelectBox and m_gridSelectBox ), and therefore do not delete them
  38. // So we do not recreate them after clearing the tools.
  39. wxString msg;
  40. if( m_mainToolBar )
  41. m_mainToolBar->Clear();
  42. else
  43. m_mainToolBar = new ACTION_TOOLBAR( this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
  44. KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT );
  45. // Set up toolbar
  46. m_mainToolBar->AddTool( ID_MODVIEW_OPTIONS, wxEmptyString,
  47. KiScaledBitmap( config_xpm, this ),
  48. _( "Display options" ) );
  49. m_mainToolBar->AddSeparator();
  50. m_mainToolBar->AddTool( ID_MODVIEW_PREVIOUS, wxEmptyString,
  51. KiScaledBitmap( lib_previous_xpm, this ),
  52. _( "Display previous footprint" ) );
  53. m_mainToolBar->AddTool( ID_MODVIEW_NEXT, wxEmptyString,
  54. KiScaledBitmap( lib_next_xpm, this ),
  55. _( "Display next footprint" ) );
  56. m_mainToolBar->AddSeparator();
  57. m_mainToolBar->Add( ACTIONS::zoomRedraw );
  58. m_mainToolBar->Add( ACTIONS::zoomInCenter );
  59. m_mainToolBar->Add( ACTIONS::zoomOutCenter );
  60. m_mainToolBar->Add( ACTIONS::zoomFitScreen );
  61. KiScaledSeparator( m_mainToolBar, this );
  62. m_mainToolBar->Add( ACTIONS::show3DViewer );
  63. m_mainToolBar->AddTool( ID_ADD_FOOTPRINT_TO_BOARD, wxEmptyString,
  64. KiScaledBitmap( export_xpm, this ),
  65. _( "Insert footprint in board" ) );
  66. KiScaledSeparator( m_mainToolBar, this );
  67. // Grid selection choice box.
  68. if( m_gridSelectBox == nullptr )
  69. m_gridSelectBox = new wxChoice( m_mainToolBar, ID_ON_GRID_SELECT,
  70. wxDefaultPosition, wxDefaultSize, 0, NULL );
  71. UpdateGridSelectBox();
  72. m_mainToolBar->AddControl( m_gridSelectBox );
  73. KiScaledSeparator( m_mainToolBar, this );
  74. // Zoom selection choice box.
  75. if( m_zoomSelectBox == nullptr )
  76. m_zoomSelectBox = new wxChoice( m_mainToolBar, ID_ON_ZOOM_SELECT,
  77. wxDefaultPosition, wxDefaultSize, 0, NULL );
  78. updateZoomSelectBox();
  79. m_mainToolBar->AddControl( m_zoomSelectBox );
  80. // after adding the buttons to the toolbar, must call Realize() to
  81. // reflect the changes
  82. m_mainToolBar->Realize();
  83. m_mainToolBar->Refresh();
  84. }
  85. void FOOTPRINT_VIEWER_FRAME::ReCreateVToolbar()
  86. {
  87. }
  88. void FOOTPRINT_VIEWER_FRAME::ReCreateMenuBar()
  89. {
  90. SELECTION_TOOL* selTool = m_toolManager->GetTool<SELECTION_TOOL>();
  91. // wxWidgets handles the Mac Application menu behind the scenes, but that means
  92. // we always have to start from scratch with a new wxMenuBar.
  93. wxMenuBar* oldMenuBar = GetMenuBar();
  94. wxMenuBar* menuBar = new wxMenuBar();
  95. //----- File menu -----------------------------------------------------------
  96. //
  97. CONDITIONAL_MENU* fileMenu = new CONDITIONAL_MENU( false, selTool );
  98. fileMenu->AddClose( _( "Footprint Viewer" ) );
  99. fileMenu->Resolve();
  100. //----- View menu -----------------------------------------------------------
  101. //
  102. CONDITIONAL_MENU* viewMenu = new CONDITIONAL_MENU( false, selTool );
  103. viewMenu->AddSeparator();
  104. viewMenu->AddItem( ACTIONS::zoomInCenter, SELECTION_CONDITIONS::ShowAlways );
  105. viewMenu->AddItem( ACTIONS::zoomOutCenter, SELECTION_CONDITIONS::ShowAlways );
  106. viewMenu->AddItem( ACTIONS::zoomFitScreen, SELECTION_CONDITIONS::ShowAlways );
  107. viewMenu->AddItem( ACTIONS::zoomRedraw, SELECTION_CONDITIONS::ShowAlways );
  108. viewMenu->AddSeparator();
  109. viewMenu->AddItem( ACTIONS::show3DViewer, SELECTION_CONDITIONS::ShowAlways );
  110. viewMenu->Resolve();
  111. //----- Menubar -------------------------------------------------------------
  112. //
  113. menuBar->Append( fileMenu, _( "&File" ) );
  114. menuBar->Append( viewMenu, _( "&View" ) );
  115. AddStandardHelpMenu( menuBar );
  116. SetMenuBar( menuBar );
  117. delete oldMenuBar;
  118. }