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.

102 lines
2.8 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2023 KiCad Developers, see AUTHORS.txt for contributors.
  5. *
  6. * This program is free software: you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License as published by the
  8. * Free Software Foundation, either version 3 of the License, or (at your
  9. * option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #include <sch_edit_frame.h>
  20. #include "sch_search_pane.h"
  21. #include "search_handlers.h"
  22. SCH_SEARCH_PANE::SCH_SEARCH_PANE( SCH_EDIT_FRAME* aFrame ) :
  23. SEARCH_PANE( aFrame ),
  24. m_schFrame( aFrame )
  25. {
  26. m_sch = &(m_schFrame->Schematic());
  27. if( m_sch != nullptr )
  28. m_sch->AddListener( this );
  29. m_schFrame->Connect( EDA_EVT_UNITS_CHANGED,
  30. wxCommandEventHandler( SCH_SEARCH_PANE::onUnitsChanged ), nullptr, this );
  31. m_schFrame->Connect( EDA_EVT_SCHEMATIC_CHANGED,
  32. wxCommandEventHandler( SCH_SEARCH_PANE::onSchChanged ), nullptr, this );
  33. wxFont infoFont = KIUI::GetDockedPaneFont( this );
  34. SetFont( infoFont );
  35. m_notebook->SetFont( infoFont );
  36. AddSearcher( new SYMBOL_SEARCH_HANDLER( aFrame ) );
  37. AddSearcher( new TEXT_SEARCH_HANDLER( aFrame ) );
  38. AddSearcher( new LABEL_SEARCH_HANDLER( aFrame ) );
  39. }
  40. SCH_SEARCH_PANE::~SCH_SEARCH_PANE()
  41. {
  42. m_schFrame->Disconnect( EDA_EVT_UNITS_CHANGED,
  43. wxCommandEventHandler( SCH_SEARCH_PANE::onUnitsChanged ), nullptr,
  44. this );
  45. m_schFrame->Disconnect( EDA_EVT_SCHEMATIC_CHANGED,
  46. wxCommandEventHandler( SCH_SEARCH_PANE::onSchChanged ), nullptr,
  47. this );
  48. }
  49. void SCH_SEARCH_PANE::onUnitsChanged( wxCommandEvent& event )
  50. {
  51. ClearAllResults();
  52. RefreshSearch();
  53. event.Skip();
  54. }
  55. void SCH_SEARCH_PANE::onSchChanged( wxCommandEvent& event )
  56. {
  57. ClearAllResults();
  58. RefreshSearch();
  59. event.Skip();
  60. }
  61. void SCH_SEARCH_PANE::OnSchItemsAdded( SCHEMATIC& aBoard, std::vector<SCH_ITEM*>& aBoardItems )
  62. {
  63. if( !IsShownOnScreen() )
  64. return;
  65. RefreshSearch();
  66. }
  67. void SCH_SEARCH_PANE::OnSchItemsRemoved( SCHEMATIC& aBoard, std::vector<SCH_ITEM*>& aBoardItems )
  68. {
  69. if( !IsShownOnScreen() )
  70. return;
  71. RefreshSearch();
  72. }
  73. void SCH_SEARCH_PANE::OnSchItemsChanged( SCHEMATIC& aBoard, std::vector<SCH_ITEM*>& aBoardItems )
  74. {
  75. if( !IsShownOnScreen() )
  76. return;
  77. RefreshSearch();
  78. }