KiCad PCB EDA Suite
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 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 m_frame( aFrame )
29{
30}
31
32
34{
35}
36
37
39{
40 for( size_t i = 0; i < m_notebook->GetPageCount(); ++i )
41 {
42 wxWindow* page = m_notebook->GetPage( i );
43 SEARCH_PANE_TAB* tab = dynamic_cast<SEARCH_PANE_TAB*>( page );
44
45 tab->RefreshColumnNames();
46 m_notebook->SetPageText( i, _( tab->GetSearchHandler()->GetName() ) );
47 }
48}
49
50
52{
53 SEARCH_PANE_TAB* tab = new SEARCH_PANE_TAB( aHandler, m_notebook );
54
55 m_notebook->AddPage( tab, _( aHandler->GetName() ) );
56 m_handlers.push_back( aHandler );
57 m_tabs.push_back( tab );
58}
59
60
62{
64
65 if( tab )
66 tab->Search( m_lastQuery );
67}
68
69
71{
72 for( SEARCH_PANE_TAB* tab : m_tabs )
73 {
74 tab->Clear();
75 }
76}
77
78
79void SEARCH_PANE::OnSearchTextEntry( wxCommandEvent& aEvent )
80{
81 wxString query = m_searchCtrl1->GetValue();
82 m_lastQuery = query;
83
85}
86
87
89{
90 m_searchCtrl1->SetFocus();
91}
92
93
94void SEARCH_PANE::OnNotebookPageChanged( wxBookCtrlEvent& aEvent )
95{
97
98 if( tab )
99 tab->Search( m_lastQuery );
100}
101
102
104{
105 return dynamic_cast<SEARCH_PANE_TAB*>( m_notebook->GetCurrentPage() );
106}
The base class for create windows for drawing purpose.
wxString GetName() const
Definition: search_pane.h:35
Class SEARCH_PANE_BASE.
wxNotebook * m_notebook
wxSearchCtrl * m_searchCtrl1
void Search(wxString &query)
SEARCH_HANDLER * GetSearchHandler() const
void RefreshSearch()
Definition: search_pane.cpp:61
void OnLanguageChange()
Definition: search_pane.cpp:38
void AddSearcher(SEARCH_HANDLER *aHandler)
Definition: search_pane.cpp:51
void OnSearchTextEntry(wxCommandEvent &aEvent) override
Definition: search_pane.cpp:79
void OnNotebookPageChanged(wxBookCtrlEvent &aEvent) override
Definition: search_pane.cpp:94
std::vector< SEARCH_PANE_TAB * > m_tabs
Definition: search_pane.h:70
SEARCH_PANE(EDA_DRAW_FRAME *aFrame)
Definition: search_pane.cpp:26
SEARCH_PANE_TAB * GetCurrentTab() const
virtual ~SEARCH_PANE()
Definition: search_pane.cpp:33
std::vector< SEARCH_HANDLER * > m_handlers
Definition: search_pane.h:69
void ClearAllResults()
Definition: search_pane.cpp:70
void FocusSearch()
Definition: search_pane.cpp:88
wxString m_lastQuery
Definition: search_pane.h:71
#define _(s)