kicad-source/eeschema/widgets/sch_search_pane.cpp

109 lines
3.2 KiB
C++
Raw Normal View History

2023-05-14 21:35:39 -04:00
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
2023-05-14 21:35:39 -04:00
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <sch_edit_frame.h>
#include "sch_search_pane.h"
#include "search_handlers.h"
SCH_SEARCH_PANE::SCH_SEARCH_PANE( SCH_EDIT_FRAME* aFrame ) :
SEARCH_PANE( aFrame ),
m_schFrame( aFrame )
2023-05-14 21:35:39 -04:00
{
m_sch = &(m_schFrame->Schematic());
if( m_sch != nullptr )
m_sch->AddListener( this );
m_schFrame->Connect( EDA_EVT_UNITS_CHANGED, wxCommandEventHandler( SCH_SEARCH_PANE::onUnitsChanged ),
nullptr, this );
2023-05-14 21:35:39 -04:00
m_schFrame->Connect( EDA_EVT_SCHEMATIC_CHANGED, wxCommandEventHandler( SCH_SEARCH_PANE::onSchChanged ),
nullptr, this );
2023-05-14 21:35:39 -04:00
m_schFrame->Bind( EDA_EVT_SCHEMATIC_CHANGING, [&]( wxCommandEvent& )
{
ClearAllResults();
} );
2023-05-14 21:35:39 -04:00
wxFont infoFont = KIUI::GetDockedPaneFont( this );
SetFont( infoFont );
m_notebook->SetFont( infoFont );
AddSearcher( std::make_shared<SYMBOL_SEARCH_HANDLER>( aFrame ) );
AddSearcher( std::make_shared<POWER_SEARCH_HANDLER>( aFrame ) );
AddSearcher( std::make_shared<TEXT_SEARCH_HANDLER>( aFrame ) );
AddSearcher( std::make_shared<LABEL_SEARCH_HANDLER>( aFrame ) );
AddSearcher( std::make_shared<GROUP_SEARCH_HANDLER>( aFrame ) );
2023-05-14 21:35:39 -04:00
}
SCH_SEARCH_PANE::~SCH_SEARCH_PANE()
{
m_schFrame->Disconnect( EDA_EVT_UNITS_CHANGED, wxCommandEventHandler( SCH_SEARCH_PANE::onUnitsChanged ),
nullptr, this );
m_schFrame->Disconnect( EDA_EVT_SCHEMATIC_CHANGED, wxCommandEventHandler( SCH_SEARCH_PANE::onSchChanged ),
nullptr, this );
2023-05-14 21:35:39 -04:00
}
void SCH_SEARCH_PANE::onUnitsChanged( wxCommandEvent& event )
{
ClearAllResults();
RefreshSearch();
event.Skip();
}
void SCH_SEARCH_PANE::onSchChanged( wxCommandEvent& event )
{
ClearAllResults();
RefreshSearch();
event.Skip();
}
void SCH_SEARCH_PANE::OnSchItemsAdded( SCHEMATIC& aBoard, std::vector<SCH_ITEM*>& aBoardItems )
{
if( !IsShownOnScreen() )
2023-05-14 21:35:39 -04:00
return;
RefreshSearch();
}
void SCH_SEARCH_PANE::OnSchItemsRemoved( SCHEMATIC& aBoard, std::vector<SCH_ITEM*>& aBoardItems )
{
if( !IsShownOnScreen() )
2023-05-14 21:35:39 -04:00
return;
RefreshSearch();
}
void SCH_SEARCH_PANE::OnSchItemsChanged( SCHEMATIC& aBoard, std::vector<SCH_ITEM*>& aBoardItems )
{
if( !IsShownOnScreen() )
2023-05-14 21:35:39 -04:00
return;
RefreshSearch();
}