KiCad PCB EDA Suite
Loading...
Searching...
No Matches
dialog_find.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 (C) 2012 Marco Mattila <[email protected]>
5 * Copyright (C) 2006 Jean-Pierre Charras <[email protected]>
6 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, you may find one here:
20 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21 * or you may search the http://www.gnu.org website for the version 2 license,
22 * or you may write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 */
25
26#pragma once
27
28#include <functional>
29#include <sys/types.h>
30#include <wx/event.h>
31#include <deque>
32#include <vector>
33
34#include <board.h>
35#include <board_item.h>
36
37#include <dialog_find_base.h>
38
39using namespace std;
40
42{
43public:
44 DIALOG_FIND( PCB_EDIT_FRAME* aParent );
45 ~DIALOG_FIND() override;
46
47 void Preload( const wxString& aFindString );
48
52 inline BOARD_ITEM* GetItem() const
53 {
54 if( m_it != m_hitList.end() )
55 return *m_it;
56 else
57 return nullptr;
58 }
59
65 void SetCallback( std::function<void( BOARD_ITEM* )> aCallback )
66 {
67 m_highlightCallback = aCallback;
68 }
69
73 void FindNext( bool reverse ) { search( !reverse ); }
74
81 bool Show( bool show = true ) override;
82
83protected:
84 void OnBoardChanged( wxCommandEvent& event );
85
86private:
87 void onTextEnter( wxCommandEvent& event ) override;
88 void onFindNextClick( wxCommandEvent& event ) override;
89 void onFindPreviousClick( wxCommandEvent& event ) override;
90 void onSearchAgainClick( wxCommandEvent& event ) override;
91 void onShowSearchPanel( wxHyperlinkEvent& event ) override;
92
93 void onOptionChanged( wxCommandEvent& aEvent ) override
94 {
95 m_upToDate = false;
96 aEvent.Skip();
97 }
98
99 void search( bool direction );
100
101 // BOARD_LISTENER implementation
103 {
104 m_upToDate = false;
105 }
106 void OnBoardItemsAdded( BOARD&, std::vector<BOARD_ITEM*>& ) override
107 {
108 m_upToDate = false;
109 }
111 {
112 m_upToDate = false;
113 }
114 void OnBoardItemsRemoved( BOARD&, std::vector<BOARD_ITEM*>& ) override
115 {
116 m_upToDate = false;
117 }
119 {
120 m_upToDate = false;
121 }
122 void OnBoardItemsChanged( BOARD&, std::vector<BOARD_ITEM*>& ) override
123 {
124 m_upToDate = false;
125 }
126 void OnBoardCompositeUpdate( BOARD&, std::vector<BOARD_ITEM*>&,
127 std::vector<BOARD_ITEM*>&, std::vector<BOARD_ITEM*>& ) override
128 {
129 m_upToDate = false;
130 }
131
132private:
135 std::deque<BOARD_ITEM*> m_hitList;
136 std::deque<BOARD_ITEM*>::iterator m_it;
138
139 std::function<void( BOARD_ITEM* )> m_highlightCallback;
140};
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:79
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:317
Class DIALOG_FIND_BASE.
PCB_EDIT_FRAME * m_frame
Definition: dialog_find.h:133
void OnBoardCompositeUpdate(BOARD &, std::vector< BOARD_ITEM * > &, std::vector< BOARD_ITEM * > &, std::vector< BOARD_ITEM * > &) override
Definition: dialog_find.h:126
~DIALOG_FIND() override
Definition: dialog_find.cpp:87
void SetCallback(std::function< void(BOARD_ITEM *)> aCallback)
Function to be called on each found event.
Definition: dialog_find.h:65
void onTextEnter(wxCommandEvent &event) override
void OnBoardItemsChanged(BOARD &, std::vector< BOARD_ITEM * > &) override
Definition: dialog_find.h:122
bool Show(bool show=true) override
The Show method is overridden to make the search combobox focused by default.
std::deque< BOARD_ITEM * >::iterator m_it
Definition: dialog_find.h:136
void OnBoardItemChanged(BOARD &, BOARD_ITEM *) override
Definition: dialog_find.h:118
void onOptionChanged(wxCommandEvent &aEvent) override
Definition: dialog_find.h:93
void Preload(const wxString &aFindString)
Definition: dialog_find.cpp:96
void onFindNextClick(wxCommandEvent &event) override
void search(bool direction)
bool m_upToDate
Definition: dialog_find.h:137
void onSearchAgainClick(wxCommandEvent &event) override
BOARD * m_board
Definition: dialog_find.h:134
BOARD_ITEM * GetItem() const
Return the currently found item or nullptr in the case of no items found.
Definition: dialog_find.h:52
void onShowSearchPanel(wxHyperlinkEvent &event) override
void onFindPreviousClick(wxCommandEvent &event) override
void OnBoardItemAdded(BOARD &, BOARD_ITEM *) override
Definition: dialog_find.h:102
std::function< void(BOARD_ITEM *)> m_highlightCallback
Definition: dialog_find.h:139
void OnBoardItemsAdded(BOARD &, std::vector< BOARD_ITEM * > &) override
Definition: dialog_find.h:106
void OnBoardItemRemoved(BOARD &, BOARD_ITEM *) override
Definition: dialog_find.h:110
void OnBoardItemsRemoved(BOARD &, std::vector< BOARD_ITEM * > &) override
Definition: dialog_find.h:114
void FindNext(bool reverse)
Finds the next item.
Definition: dialog_find.h:73
std::deque< BOARD_ITEM * > m_hitList
Definition: dialog_find.h:135
void OnBoardChanged(wxCommandEvent &event)
The main frame for Pcbnew.
STL namespace.