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 <marcom99@gmail.com>
5  * Copyright (C) 2006 Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr>
6  * Copyright (C) 1992-2019 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 <boost/function.hpp>
30 #include <sys/types.h>
31 #include <wx/event.h>
32 #include <deque>
33 
34 #include <class_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 
49  inline BOARD_ITEM* GetItem() const
50  {
51  if( m_it != m_hitList.end() )
52  return *m_it;
53  else
54  return nullptr;
55  }
56 
62  void SetCallback( boost::function<void( BOARD_ITEM* )> aCallback )
63  {
64  m_highlightCallback = aCallback;
65  }
66 
67 
68 private:
70  std::deque<BOARD_ITEM*> m_hitList;
71  std::deque<BOARD_ITEM*>::iterator m_it;
72  bool m_upToDate;
73 
74  boost::function<void( BOARD_ITEM* )> m_highlightCallback;
75 
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 onClose( wxCommandEvent& event ) override;
81  void search( bool direction );
82 };
83 
84 #endif /* DIALOG_FIND_BASE_H */
BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
Classes BOARD_ITEM and BOARD_CONNECTED_ITEM.
Template specialization to enable wxStrings for certain containers (e.g. unordered_map)
Definition: bitmap.cpp:55
BOARD_ITEM * GetItem() const
Returns the currently found item or nullptr in the case of no items found.
Definition: dialog_find.h:49
PCB_BASE_FRAME * m_frame
Definition: dialog_find.h:69
void SetCallback(boost::function< void(BOARD_ITEM *)> aCallback)
Function to be called on each found event.
Definition: dialog_find.h:62
bool m_upToDate
Definition: dialog_find.h:72
std::deque< BOARD_ITEM * >::iterator m_it
Definition: dialog_find.h:71
std::deque< BOARD_ITEM * > m_hitList
Definition: dialog_find.h:70
boost::function< void(BOARD_ITEM *)> m_highlightCallback
Definition: dialog_find.h:74
PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
Class DIALOG_FIND_BASE.