KiCad PCB EDA Suite
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 (C) 1992-2021 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 #ifndef DIALOG_FIND_BASE_H
27 #define DIALOG_FIND_BASE_H
28 
29 #include <functional>
30 #include <sys/types.h>
31 #include <wx/event.h>
32 #include <deque>
33 
34 #include <board_item.h>
35 
36 #include <dialog_find_base.h>
37 
38 using namespace std;
39 
41 {
42 public:
43  DIALOG_FIND( PCB_BASE_FRAME* aParent );
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() { search( true ); }
70 
71 protected:
72  void OnClose( wxCloseEvent& event ) override;
73  void OnCloseButtonClick( wxCommandEvent& aEvent ) override;
74 
75 private:
76  void onTextEnter( wxCommandEvent& event ) override;
77  void onFindNextClick( wxCommandEvent& event ) override;
78  void onFindPreviousClick( wxCommandEvent& event ) override;
79  void onSearchAgainClick( wxCommandEvent& event ) override;
80  void search( bool direction );
81 
83  std::deque<BOARD_ITEM*> m_hitList;
84  std::deque<BOARD_ITEM*>::iterator m_it;
85  bool m_upToDate;
86 
87  std::function<void( BOARD_ITEM* )> m_highlightCallback;
88 };
89 
90 #endif /* DIALOG_FIND_BASE_H */
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
Definition: bitmap.cpp:64
void SetCallback(std::function< void(BOARD_ITEM *)> aCallback)
Function to be called on each found event.
Definition: dialog_find.h:61
BOARD_ITEM * GetItem() const
Return the currently found item or nullptr in the case of no items found.
Definition: dialog_find.h:48
PCB_BASE_FRAME * m_frame
Definition: dialog_find.h:82
std::function< void(BOARD_ITEM *)> m_highlightCallback
Definition: dialog_find.h:87
bool m_upToDate
Definition: dialog_find.h:85
std::deque< BOARD_ITEM * >::iterator m_it
Definition: dialog_find.h:84
std::deque< BOARD_ITEM * > m_hitList
Definition: dialog_find.h:83
void FindNext()
Finds the next item.
Definition: dialog_find.h:69
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
Class DIALOG_FIND_BASE.