KiCad PCB EDA Suite
Loading...
Searching...
No Matches
panel_footprint_chooser.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) 2023 CERN
5 * Copyright (C) 2014-2023 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24#ifndef PANEL_FOOTPRINT_CHOOSER_H
25#define PANEL_FOOTPRINT_CHOOSER_H
26
27#include <widgets/lib_tree.h>
29#include <footprint_info.h>
31
32class wxTimer;
33class wxSplitterWindow;
34class wxBoxSizer;
35
36class PCB_BASE_FRAME;
37
38// When a new footprint is selected, a custom event is sent, for instance to update
39// 3D viewer. So declare a FP_SELECTION_EVENT event
40wxDECLARE_EVENT(FP_SELECTION_EVENT, wxCommandEvent);
41
42class PANEL_FOOTPRINT_CHOOSER : public wxPanel
43{
44public:
53 PANEL_FOOTPRINT_CHOOSER( PCB_BASE_FRAME* aFrame, wxTopLevelWindow* aParent,
54 const wxArrayString& aFootprintHistoryList,
55 std::function<bool( LIB_TREE_NODE& )> aFilter,
56 std::function<void()> aAcceptHandler,
57 std::function<void()> aEscapeHandler );
58
60
61 void FinishSetup();
62
63 void SetPreselect( const LIB_ID& aPreselect );
64
71
72 int GetItemCount() const { return m_adapter->GetItemCount(); }
73
74 wxWindow* GetFocusTarget() const { return m_tree->GetFocusTarget(); }
75
76 wxSizer* GetFiltersSizer() const { return m_tree->GetFiltersSizer(); }
77
78 void Regenerate() { m_tree->Regenerate( true ); }
79
81
82protected:
83 static constexpr int DblClickDelay = 100; // milliseconds
84
85 void OnDetailsCharHook( wxKeyEvent& aEvt );
86 void onCloseTimer( wxTimerEvent& aEvent );
87 void onOpenLibsTimer( wxTimerEvent& aEvent );
88
89 void onFootprintSelected( wxCommandEvent& aEvent );
90
97 void onFootprintChosen( wxCommandEvent& aEvent );
98
99public:
100 wxPanel* m_RightPanel;
101 wxBoxSizer* m_RightPanelSizer;
102
104
105protected:
108 wxSplitterWindow* m_hsplitter;
109 wxSplitterWindow* m_vsplitter;
110
111 wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER> m_adapter;
112
116
118 std::function<bool( LIB_TREE_NODE& )> m_filter;
119 std::function<void()> m_acceptHandler;
120 std::function<void()> m_escapeHandler;
121};
122
123#endif /* PANEL_FOOTPRINT_CHOOSER_H */
Add dark theme support to wxHtmlWindow.
Definition: html_window.h:35
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:49
Model class in the component selector Model-View-Adapter (mediated MVC) architecture.
Widget displaying a tree of symbols with optional search text control and description panel....
Definition: lib_tree.h:49
wxWindow * GetFocusTarget()
Definition: lib_tree.cpp:446
wxSizer * GetFiltersSizer()
Definition: lib_tree.h:155
void Regenerate(bool aKeepState)
Regenerate the tree.
Definition: lib_tree.cpp:422
void onFootprintSelected(wxCommandEvent &aEvent)
wxObjectDataPtr< LIB_TREE_MODEL_ADAPTER > m_adapter
void onCloseTimer(wxTimerEvent &aEvent)
std::function< void()> m_acceptHandler
FOOTPRINT_PREVIEW_WIDGET * m_preview_ctrl
wxWindow * GetFocusTarget() const
std::function< void()> m_escapeHandler
static constexpr int DblClickDelay
std::function< bool(LIB_TREE_NODE &)> m_filter
void OnDetailsCharHook(wxKeyEvent &aEvt)
FOOTPRINT_PREVIEW_WIDGET * GetViewerPanel() const
void onOpenLibsTimer(wxTimerEvent &aEvent)
void SetPreselect(const LIB_ID &aPreselect)
void onFootprintChosen(wxCommandEvent &aEvent)
Handle the selection of an item.
LIB_ID GetSelectedLibId() const
To be called after this dialog returns from ShowModal().
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
wxDECLARE_EVENT(FP_SELECTION_EVENT, wxCommandEvent)