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 for( size_t i = 0; i < m_notebook->GetPageCount(); ++i )
40 {
41 wxWindow* page = m_notebook->GetPage( i );
42 SEARCH_PANE_TAB* tab = dynamic_cast<SEARCH_PANE_TAB*>( page );
43
44 wxCHECK( tab, /* void */ );
45
46 tab->RefreshColumnNames();
47 m_notebook->SetPageText( i, wxGetTranslation( tab->GetSearchHandler()->GetName() ) );
48 }
49}
50
51
53{
54 SEARCH_PANE_TAB* tab = new SEARCH_PANE_TAB( aHandler, m_notebook );
55
56 m_notebook->AddPage( tab, wxGetTranslation( aHandler->GetName() ) );
57 m_handlers.push_back( aHandler );
58 m_tabs.push_back( tab );
59}
60
61
63{
65
66 if( tab )
67 tab->Search( m_lastQuery );
68}
69
70
72{
73 for( SEARCH_PANE_TAB* tab : m_tabs )
74 {
75 tab->Clear();
76 }
77}
78
79
80void SEARCH_PANE::OnSearchTextEntry( wxCommandEvent& aEvent )
81{
82 wxString query = m_searchCtrl1->GetValue();
83 m_lastQuery = query;
84
86}
87
88
90{
91 m_searchCtrl1->SetFocus();
92}
93
94
95void SEARCH_PANE::OnNotebookPageChanged( wxBookCtrlEvent& aEvent )
96{
98
99 if( tab )
100 tab->Search( m_lastQuery );
101}
102
103
105{
106 return dynamic_cast<SEARCH_PANE_TAB*>( m_notebook->GetCurrentPage() );
107}
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:62
void OnLanguageChange()
Definition: search_pane.cpp:37
void AddSearcher(SEARCH_HANDLER *aHandler)
Definition: search_pane.cpp:52
void OnSearchTextEntry(wxCommandEvent &aEvent) override
Definition: search_pane.cpp:80
void OnNotebookPageChanged(wxBookCtrlEvent &aEvent) override
Definition: search_pane.cpp:95
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:71
void FocusSearch()
Definition: search_pane.cpp:89
wxString m_lastQuery
Definition: search_pane.h:77