KiCad PCB EDA Suite
Loading...
Searching...
No Matches
search_pane.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2022-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
20#include <widgets/search_pane.h>
22#include <eda_draw_frame.h>
23#include <kiway.h>
24
25
27 SEARCH_PANE_BASE( aFrame )
28{
29}
30
31
33{
34}
35
36
38{
39 m_searchCtrl1->SetDescriptiveText( _( "Search" ) );
40
41 for( size_t i = 0; i < m_notebook->GetPageCount(); ++i )
42 {
43 wxWindow* page = m_notebook->GetPage( i );
44 SEARCH_PANE_TAB* tab = dynamic_cast<SEARCH_PANE_TAB*>( page );
45
46 wxCHECK( tab, /* void */ );
47
48 tab->RefreshColumnNames();
49 m_notebook->SetPageText( i, wxGetTranslation( tab->GetSearchHandler()->GetName() ) );
50 }
51}
52
53
55{
56 SEARCH_PANE_TAB* tab = new SEARCH_PANE_TAB( aHandler, m_notebook );
57
58 m_notebook->AddPage( tab, wxGetTranslation( aHandler->GetName() ) );
59 m_handlers.push_back( aHandler );
60 m_tabs.push_back( tab );
61}
62
63
65{
67
68 if( tab )
69 tab->Search( m_lastQuery );
70}
71
72
74{
75 for( SEARCH_PANE_TAB* tab : m_tabs )
76 {
77 tab->Clear();
78 }
79}
80
81
82void SEARCH_PANE::OnSearchTextEntry( wxCommandEvent& aEvent )
83{
84 wxString query = m_searchCtrl1->GetValue();
85 m_lastQuery = query;
86
88}
89
90
92{
93 m_searchCtrl1->SetFocus();
94}
95
96
97void SEARCH_PANE::OnNotebookPageChanged( wxBookCtrlEvent& aEvent )
98{
100
101 if( tab )
102 tab->Search( m_lastQuery );
103}
104
105
107{
108 return dynamic_cast<SEARCH_PANE_TAB*>( m_notebook->GetCurrentPage() );
109}
The base class for create windows for drawing purpose.
wxString GetName() const
Definition: search_pane.h:37
Class SEARCH_PANE_BASE.
wxNotebook * m_notebook
wxSearchCtrl * m_searchCtrl1
void Search(wxString &query)
SEARCH_HANDLER * GetSearchHandler() const
void RefreshSearch()
Definition: search_pane.cpp:64
void OnLanguageChange()
Definition: search_pane.cpp:37
void AddSearcher(SEARCH_HANDLER *aHandler)
Definition: search_pane.cpp:54
void OnSearchTextEntry(wxCommandEvent &aEvent) override
Definition: search_pane.cpp:82
void OnNotebookPageChanged(wxBookCtrlEvent &aEvent) override
Definition: search_pane.cpp:97
std::vector< SEARCH_PANE_TAB * > m_tabs
Definition: search_pane.h:76
SEARCH_PANE(EDA_DRAW_FRAME *aFrame)
Definition: search_pane.cpp:26
SEARCH_PANE_TAB * GetCurrentTab() const
virtual ~SEARCH_PANE()
Definition: search_pane.cpp:32
std::vector< SEARCH_HANDLER * > m_handlers
Definition: search_pane.h:75
void ClearAllResults()
Definition: search_pane.cpp:73
void FocusSearch()
Definition: search_pane.cpp:91
wxString m_lastQuery
Definition: search_pane.h:77
#define _(s)