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.

141 lines
5.1 KiB

5 years ago
5 years ago
5 years ago
5 years ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
  5. * Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
  6. * Copyright (C) 2004-2022 KiCad Developers, see AUTHORS.txt for contributors.
  7. * Copyright (C) 2019 CERN
  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 <bitmaps.h>
  23. #include <macros.h>
  24. #include <symbol_library.h>
  25. #include <eeschema_id.h>
  26. #include <symbol_viewer_frame.h>
  27. #include <sch_painter.h>
  28. #include <tool/action_menu.h>
  29. #include <tool/action_toolbar.h>
  30. #include <tools/ee_actions.h>
  31. #include <tools/symbol_editor_control.h>
  32. #include <widgets/wx_menubar.h>
  33. void SYMBOL_VIEWER_FRAME::ReCreateHToolbar()
  34. {
  35. if( m_mainToolBar )
  36. {
  37. m_mainToolBar->ClearToolbar();
  38. }
  39. else
  40. {
  41. m_mainToolBar = new ACTION_TOOLBAR( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
  42. KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT | wxAUI_TB_HORIZONTAL );
  43. m_mainToolBar->SetAuiManager( &m_auimgr );
  44. }
  45. m_mainToolBar->AddTool( ID_LIBVIEW_SELECT_PART, wxEmptyString,
  46. KiScaledBitmap( BITMAPS::library_browser, this ),
  47. _( "Choose symbol" ) );
  48. m_mainToolBar->AddTool( ID_LIBVIEW_PREVIOUS, wxEmptyString,
  49. KiScaledBitmap( BITMAPS::lib_previous, this ),
  50. _( "Display previous symbol" ) );
  51. m_mainToolBar->AddTool( ID_LIBVIEW_NEXT, wxEmptyString,
  52. KiScaledBitmap( BITMAPS::lib_next, this ),
  53. _( "Display next symbol" ) );
  54. m_mainToolBar->AddScaledSeparator( this );
  55. m_mainToolBar->Add( ACTIONS::zoomRedraw );
  56. m_mainToolBar->Add( ACTIONS::zoomInCenter );
  57. m_mainToolBar->Add( ACTIONS::zoomOutCenter );
  58. m_mainToolBar->Add( ACTIONS::zoomFitScreen );
  59. m_mainToolBar->AddScaledSeparator( this );
  60. m_mainToolBar->Add( EE_ACTIONS::showElectricalTypes, ACTION_TOOLBAR::TOGGLE );
  61. m_mainToolBar->Add( EE_ACTIONS::showPinNumbers, ACTION_TOOLBAR::TOGGLE );
  62. m_mainToolBar->AddScaledSeparator( this );
  63. m_mainToolBar->Add( EE_ACTIONS::showDeMorganStandard, ACTION_TOOLBAR::TOGGLE );
  64. m_mainToolBar->Add( EE_ACTIONS::showDeMorganAlternate, ACTION_TOOLBAR::TOGGLE );
  65. m_mainToolBar->AddScaledSeparator( this );
  66. if( m_unitChoice == nullptr )
  67. m_unitChoice = new wxChoice( m_mainToolBar, ID_LIBVIEW_SELECT_UNIT_NUMBER,
  68. wxDefaultPosition, wxSize( 150, -1 ) );
  69. m_mainToolBar->AddControl( m_unitChoice );
  70. m_mainToolBar->AddScaledSeparator( this );
  71. m_mainToolBar->Add( EE_ACTIONS::showDatasheet );
  72. m_mainToolBar->AddScaledSeparator( this );
  73. m_mainToolBar->Add( EE_ACTIONS::addSymbolToSchematic );
  74. // after adding the buttons to the toolbar, must call Realize() to reflect the changes
  75. m_mainToolBar->KiRealize();
  76. m_mainToolBar->Refresh();
  77. }
  78. void SYMBOL_VIEWER_FRAME::ReCreateVToolbar()
  79. {
  80. }
  81. void SYMBOL_VIEWER_FRAME::ReCreateMenuBar()
  82. {
  83. SYMBOL_EDITOR_CONTROL* libControl = m_toolManager->GetTool<SYMBOL_EDITOR_CONTROL>();
  84. // wxWidgets handles the OSX Application menu behind the scenes, but that means
  85. // we always have to start from scratch with a new wxMenuBar.
  86. wxMenuBar* oldMenuBar = GetMenuBar();
  87. WX_MENUBAR* menuBar = new WX_MENUBAR();
  88. //-- File menu -----------------------------------------------------------
  89. //
  90. ACTION_MENU* fileMenu = new ACTION_MENU( false, libControl );
  91. fileMenu->AddClose( _( "Symbol Viewer" ) );
  92. //-- View menu -----------------------------------------------------------
  93. //
  94. ACTION_MENU* viewMenu = new ACTION_MENU( false, libControl );
  95. viewMenu->Add( ACTIONS::zoomInCenter );
  96. viewMenu->Add( ACTIONS::zoomOutCenter );
  97. viewMenu->Add( ACTIONS::zoomFitScreen );
  98. viewMenu->Add( ACTIONS::zoomRedraw );
  99. viewMenu->AppendSeparator();
  100. viewMenu->Add( ACTIONS::toggleGrid, ACTION_MENU::CHECK );
  101. viewMenu->Add( ACTIONS::gridProperties );
  102. viewMenu->AppendSeparator();
  103. viewMenu->Add( EE_ACTIONS::showElectricalTypes, ACTION_MENU::CHECK );
  104. viewMenu->Add( EE_ACTIONS::showPinNumbers, ACTION_MENU::CHECK );
  105. //-- Menubar -------------------------------------------------------------
  106. //
  107. menuBar->Append( fileMenu, _( "&File" ) );
  108. menuBar->Append( viewMenu, _( "&View" ) );
  109. AddStandardHelpMenu( menuBar );
  110. SetMenuBar( menuBar );
  111. delete oldMenuBar;
  112. }