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-2022 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
38using namespace std;
39
41{
42public:
43 DIALOG_FIND( PCB_BASE_FRAME* aParent );
44
45 void Preload( const wxString& aFindString );
46
50 inline BOARD_ITEM* GetItem() const
51 {
52 if( m_it != m_hitList.end() )
53 return *m_it;
54 else
55 return nullptr;
56 }
57
63 void SetCallback( std::function<void( BOARD_ITEM* )> aCallback )
64 {
65 m_highlightCallback = aCallback;
66 }
67
71 void FindNext() { search( true ); }
72
79 bool Show( bool show = true ) override;
80
81protected:
82 void OnClose( wxCloseEvent& event ) override;
83 void OnCloseButtonClick( wxCommandEvent& aEvent ) override;
84
85private:
86 void onTextEnter( wxCommandEvent& event ) override;
87 void onFindNextClick( wxCommandEvent& event ) override;
88 void onFindPreviousClick( wxCommandEvent& event ) override;
89 void onSearchAgainClick( wxCommandEvent& event ) override;
90 void search( bool direction );
91
93 std::deque<BOARD_ITEM*> m_hitList;
94 std::deque<BOARD_ITEM*>::iterator m_it;
96
97 std::function<void( BOARD_ITEM* )> m_highlightCallback;
98};
99
100#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:53
Class DIALOG_FIND_BASE.
void SetCallback(std::function< void(BOARD_ITEM *)> aCallback)
Function to be called on each found event.
Definition: dialog_find.h:63
void onTextEnter(wxCommandEvent &event) override
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:94
void Preload(const wxString &aFindString)
Definition: dialog_find.cpp:99
void onFindNextClick(wxCommandEvent &event) override
void search(bool direction)
bool m_upToDate
Definition: dialog_find.h:95
void onSearchAgainClick(wxCommandEvent &event) override
DIALOG_FIND(PCB_BASE_FRAME *aParent)
Definition: dialog_find.cpp:55
void FindNext()
Finds the next item.
Definition: dialog_find.h:71
BOARD_ITEM * GetItem() const
Return the currently found item or nullptr in the case of no items found.
Definition: dialog_find.h:50
void onFindPreviousClick(wxCommandEvent &event) override
void OnClose(wxCloseEvent &event) override
std::function< void(BOARD_ITEM *)> m_highlightCallback
Definition: dialog_find.h:97
void OnCloseButtonClick(wxCommandEvent &aEvent) override
PCB_BASE_FRAME * m_frame
Definition: dialog_find.h:92
std::deque< BOARD_ITEM * > m_hitList
Definition: dialog_find.h:93
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
Definition: bitmap.cpp:64