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, see <https://www.gnu.org/licenses/>.
20 */
21
22#pragma once
23
24#include <functional>
25#include <sys/types.h>
26#include <wx/event.h>
27#include <deque>
28#include <vector>
29
30#include <board.h>
31#include <board_item.h>
32
33#include <dialog_find_base.h>
34
35using namespace std;
36
38{
39public:
40 DIALOG_FIND( PCB_EDIT_FRAME* aParent );
41 ~DIALOG_FIND() override;
42
43 void Preload( const wxString& aFindString );
44
48 inline BOARD_ITEM* GetItem() const
49 {
50 if( m_it != m_hitList.end() )
51 return *m_it;
52 else
53 return nullptr;
54 }
55
61 void SetCallback( std::function<void( BOARD_ITEM* )> aCallback )
62 {
63 m_highlightCallback = aCallback;
64 }
65
69 void FindNext( bool reverse ) { search( !reverse ); }
70
77 bool Show( bool show = true ) override;
78
79protected:
80 void OnBoardChanged( wxCommandEvent& event );
81
82private:
83 void onTextEnter( wxCommandEvent& event ) override;
84 void onFindNextClick( wxCommandEvent& event ) override;
85 void onFindPreviousClick( wxCommandEvent& event ) override;
86 void onSearchAgainClick( wxCommandEvent& event ) override;
87 void onShowSearchPanel( wxHyperlinkEvent& event ) override;
88
89 void onOptionChanged( wxCommandEvent& aEvent ) override
90 {
91 m_upToDate = false;
92 aEvent.Skip();
93 }
94
95 void search( bool direction );
96
97 // BOARD_LISTENER implementation
98 void OnBoardItemAdded( BOARD&, BOARD_ITEM* ) override
99 {
100 m_upToDate = false;
101 }
102 void OnBoardItemsAdded( BOARD&, std::vector<BOARD_ITEM*>& ) override
103 {
104 m_upToDate = false;
105 }
107 {
108 m_upToDate = false;
109 }
110 void OnBoardItemsRemoved( BOARD&, std::vector<BOARD_ITEM*>& ) override
111 {
112 m_upToDate = false;
113 }
115 {
116 m_upToDate = false;
117 }
118 void OnBoardItemsChanged( BOARD&, std::vector<BOARD_ITEM*>& ) override
119 {
120 m_upToDate = false;
121 }
122 void OnBoardCompositeUpdate( BOARD&, std::vector<BOARD_ITEM*>&,
123 std::vector<BOARD_ITEM*>&, std::vector<BOARD_ITEM*>& ) override
124 {
125 m_upToDate = false;
126 }
127
128private:
131 std::deque<BOARD_ITEM*> m_hitList;
132 std::deque<BOARD_ITEM*>::iterator m_it;
134
135 std::function<void( BOARD_ITEM* )> m_highlightCallback;
136};
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition board_item.h:81
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:372
DIALOG_FIND_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=wxEmptyString, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE)
PCB_EDIT_FRAME * m_frame
void OnBoardCompositeUpdate(BOARD &, std::vector< BOARD_ITEM * > &, std::vector< BOARD_ITEM * > &, std::vector< BOARD_ITEM * > &) override
~DIALOG_FIND() override
void SetCallback(std::function< void(BOARD_ITEM *)> aCallback)
Function to be called on each found event.
Definition dialog_find.h:61
void onTextEnter(wxCommandEvent &event) override
void OnBoardItemsChanged(BOARD &, std::vector< BOARD_ITEM * > &) override
DIALOG_FIND(PCB_EDIT_FRAME *aParent)
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
void OnBoardItemChanged(BOARD &, BOARD_ITEM *) override
void onOptionChanged(wxCommandEvent &aEvent) override
Definition dialog_find.h:89
void Preload(const wxString &aFindString)
void onFindNextClick(wxCommandEvent &event) override
void search(bool direction)
void onSearchAgainClick(wxCommandEvent &event) override
BOARD * m_board
BOARD_ITEM * GetItem() const
Return the currently found item or nullptr in the case of no items found.
Definition dialog_find.h:48
void onShowSearchPanel(wxHyperlinkEvent &event) override
void onFindPreviousClick(wxCommandEvent &event) override
void OnBoardItemAdded(BOARD &, BOARD_ITEM *) override
Definition dialog_find.h:98
std::function< void(BOARD_ITEM *)> m_highlightCallback
void OnBoardItemsAdded(BOARD &, std::vector< BOARD_ITEM * > &) override
void OnBoardItemRemoved(BOARD &, BOARD_ITEM *) override
void OnBoardItemsRemoved(BOARD &, std::vector< BOARD_ITEM * > &) override
void FindNext(bool reverse)
Finds the next item.
Definition dialog_find.h:69
std::deque< BOARD_ITEM * > m_hitList
void OnBoardChanged(wxCommandEvent &event)
The main frame for Pcbnew.
STL namespace.