KiCad PCB EDA Suite
Loading...
Searching...
No Matches
search_pane.h
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 The 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#ifndef SEARCH_PANE_H
21#define SEARCH_PANE_H
22
23#include <memory>
24#include <vector>
25
27#include <wx/listbase.h>
28
29
30class wxAuiManagerEvent;
31class ACTION_MENU;
32class EDA_DRAW_FRAME;
33class SEARCH_PANE_TAB;
34
36{
37public:
38 SEARCH_HANDLER( const wxString& aName ) :
39 m_name( aName )
40 {}
41
43 {}
44
45 wxString GetName() const { return m_name; }
46
47 std::vector<std::tuple<wxString, int, wxListColumnFormat>> GetColumns() const
48 {
49 return m_columns;
50 }
51
52 virtual int Search( const wxString& string ) = 0;
53 virtual wxString GetResultCell( int row, int col ) = 0;
54 virtual void Sort( int aCol, bool aAscending, std::vector<long>* aSelection ) = 0;
55
56 virtual void SelectItems( std::vector<long>& aItemRows ) {}
57 virtual void ActivateItem( long aItemRow ) {}
58
59protected:
60 wxString m_name;
61 std::vector<std::tuple<wxString, int, wxListColumnFormat>> m_columns;
62};
63
64
66{
67public:
68 SEARCH_PANE( EDA_DRAW_FRAME* aFrame );
69 virtual ~SEARCH_PANE();
70
71 // We own at least one list of raw pointers. Don't let the compiler fill in copy c'tors that
72 // will only land us in trouble.
73 SEARCH_PANE( const SEARCH_PANE& ) = delete;
74 SEARCH_PANE& operator=( const SEARCH_PANE& ) = delete;
75
76 void AddSearcher( const std::shared_ptr<SEARCH_HANDLER>& aHandler );
77 void OnSearchTextEntry( wxCommandEvent& aEvent ) override;
78 void OnNotebookPageChanged( wxBookCtrlEvent& aEvent ) override;
79
80 void RefreshSearch();
81 void FocusSearch();
82 void ClearAllResults();
83
84 void OnCharHook( wxKeyEvent& aEvent );
85
86protected:
87 void OnLanguageChange( wxCommandEvent& aEvent );
89 void OnClosed( wxAuiManagerEvent& aEvent );
90
91private:
92 std::vector<std::shared_ptr<SEARCH_HANDLER>> m_handlers;
93 std::vector<SEARCH_PANE_TAB*> m_tabs;
94 wxString m_lastQuery;
97};
98
99#endif
Define the structure of a menu based on ACTIONs.
Definition: action_menu.h:49
The base class for create windows for drawing purpose.
SEARCH_HANDLER(const wxString &aName)
Definition: search_pane.h:38
std::vector< std::tuple< wxString, int, wxListColumnFormat > > GetColumns() const
Definition: search_pane.h:47
virtual wxString GetResultCell(int row, int col)=0
virtual ~SEARCH_HANDLER()
Definition: search_pane.h:42
virtual void Sort(int aCol, bool aAscending, std::vector< long > *aSelection)=0
virtual void SelectItems(std::vector< long > &aItemRows)
Definition: search_pane.h:56
wxString m_name
Definition: search_pane.h:60
std::vector< std::tuple< wxString, int, wxListColumnFormat > > m_columns
Definition: search_pane.h:61
wxString GetName() const
Definition: search_pane.h:45
virtual void ActivateItem(long aItemRow)
Definition: search_pane.h:57
virtual int Search(const wxString &string)=0
Class SEARCH_PANE_BASE.
void RefreshSearch()
void OnSearchTextEntry(wxCommandEvent &aEvent) override
void OnNotebookPageChanged(wxBookCtrlEvent &aEvent) override
void OnCharHook(wxKeyEvent &aEvent)
std::vector< SEARCH_PANE_TAB * > m_tabs
Definition: search_pane.h:93
void OnLanguageChange(wxCommandEvent &aEvent)
EDA_DRAW_FRAME * m_frame
Definition: search_pane.h:95
void AddSearcher(const std::shared_ptr< SEARCH_HANDLER > &aHandler)
SEARCH_PANE_TAB * GetCurrentTab() const
SEARCH_PANE(const SEARCH_PANE &)=delete
ACTION_MENU * m_menu
Definition: search_pane.h:96
std::vector< std::shared_ptr< SEARCH_HANDLER > > m_handlers
Definition: search_pane.h:92
SEARCH_PANE & operator=(const SEARCH_PANE &)=delete
virtual ~SEARCH_PANE()
void ClearAllResults()
void FocusSearch()
wxString m_lastQuery
Definition: search_pane.h:94
void OnClosed(wxAuiManagerEvent &aEvent)