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 m_frame( aFrame )
29{
30 m_frame->Bind( EDA_LANG_CHANGED, &SEARCH_PANE::OnLanguageChange, this );
31}
32
33
35{
36 m_frame->Unbind( EDA_LANG_CHANGED, &SEARCH_PANE::OnLanguageChange, this );
37}
38
39
40void SEARCH_PANE::OnLanguageChange( wxCommandEvent& aEvent )
41{
42 m_searchCtrl1->SetDescriptiveText( _( "Search" ) );
43
44 for( size_t i = 0; i < m_notebook->GetPageCount(); ++i )
45 {
46 wxWindow* page = m_notebook->GetPage( i );
47 SEARCH_PANE_TAB* tab = dynamic_cast<SEARCH_PANE_TAB*>( page );
48
49 wxCHECK( tab, /* void */ );
50
51 tab->RefreshColumnNames();
52 m_notebook->SetPageText( i, wxGetTranslation( tab->GetSearchHandler()->GetName() ) );
53 }
54
55 aEvent.Skip();
56}
57
58
60{
61 SEARCH_PANE_TAB* tab = new SEARCH_PANE_TAB( aHandler, m_notebook );
62
63 m_notebook->AddPage( tab, wxGetTranslation( aHandler->GetName() ) );
64 m_handlers.push_back( aHandler );
65 m_tabs.push_back( tab );
66}
67
68
70{
72
73 if( tab )
74 tab->Search( m_lastQuery );
75}
76
77
79{
80 for( SEARCH_PANE_TAB* tab : m_tabs )
81 {
82 tab->Clear();
83 }
84}
85
86
87void SEARCH_PANE::OnSearchTextEntry( wxCommandEvent& aEvent )
88{
89 wxString query = m_searchCtrl1->GetValue();
90 m_lastQuery = query;
91
93}
94
95
97{
98 m_searchCtrl1->SetFocus();
99}
100
101
102void SEARCH_PANE::OnNotebookPageChanged( wxBookCtrlEvent& aEvent )
103{
105
106 if( tab )
107 tab->Search( m_lastQuery );
108}
109
110
112{
113 return dynamic_cast<SEARCH_PANE_TAB*>( m_notebook->GetCurrentPage() );
114}
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:69
void AddSearcher(SEARCH_HANDLER *aHandler)
Definition: search_pane.cpp:59
void OnSearchTextEntry(wxCommandEvent &aEvent) override
Definition: search_pane.cpp:87
void OnNotebookPageChanged(wxBookCtrlEvent &aEvent) override
std::vector< SEARCH_PANE_TAB * > m_tabs
Definition: search_pane.h:76
void OnLanguageChange(wxCommandEvent &aEvent)
Definition: search_pane.cpp:40
EDA_DRAW_FRAME * m_frame
Definition: search_pane.h:78
SEARCH_PANE(EDA_DRAW_FRAME *aFrame)
Definition: search_pane.cpp:26
SEARCH_PANE_TAB * GetCurrentTab() const
virtual ~SEARCH_PANE()
Definition: search_pane.cpp:34
std::vector< SEARCH_HANDLER * > m_handlers
Definition: search_pane.h:75
void ClearAllResults()
Definition: search_pane.cpp:78
void FocusSearch()
Definition: search_pane.cpp:96
wxString m_lastQuery
Definition: search_pane.h:77
#define _(s)