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 The 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, see <https://www.gnu.org/licenses/>.
19 */
20#ifndef PANEL_FOOTPRINT_CHOOSER_H
21#define PANEL_FOOTPRINT_CHOOSER_H
22
23#include <wx/toplevel.h>
24#include <widgets/lib_tree.h>
27
28class wxTimer;
29class wxSplitterWindow;
30class wxBoxSizer;
31
32class PCB_BASE_FRAME;
33class FOOTPRINT;
34
35// When a new footprint is selected, a custom event is sent, for instance to update
36// 3D viewer. So declare a FP_SELECTION_EVENT event
37wxDECLARE_EVENT(FP_SELECTION_EVENT, wxCommandEvent);
38
39class PANEL_FOOTPRINT_CHOOSER : public wxPanel
40{
41public:
52 PANEL_FOOTPRINT_CHOOSER( PCB_BASE_FRAME* aFrame, wxTopLevelWindow* aParent,
53 const wxArrayString& aFootprintHistoryList,
54 std::function<bool( LIB_TREE_NODE& )> aFilter,
55 std::function<void()> aAcceptHandler,
56 std::function<void()> aEscapeHandler );
57
59
60 void OnChar( wxKeyEvent& aEvent );
61
62 void FinishSetup();
63
64 void SetPreselect( const LIB_ID& aPreselect );
65
72
73 int GetItemCount() const { return m_adapter->GetItemCount(); }
74
75 wxWindow* GetFocusTarget() const { return m_tree->GetFocusTarget(); }
76
77 wxSizer* GetFiltersSizer() const { return m_tree->GetFiltersSizer(); }
78
79 void Regenerate() { m_tree->Regenerate( true ); }
80
82
83 wxSplitterWindow* GetVerticalSpliter() const { return m_vsplitter; }
84
85 wxPanel* GetDetailsPanel() const { return m_detailsPanel; }
86
87protected:
88 static constexpr int DblClickDelay = 100; // milliseconds
89
90 void OnDetailsCharHook( wxKeyEvent& aEvt );
91 void onCloseTimer( wxTimerEvent& aEvent );
92 void onOpenLibsTimer( wxTimerEvent& aEvent );
93
97 void onMenuOpen( wxMenuEvent& aEvent );
98 void onMenuClose( wxMenuEvent& aEvent );
99
100 void onFootprintSelected( wxCommandEvent& aEvent );
101
108 void onFootprintChosen( wxCommandEvent& aEvent );
109
110public:
111 wxPanel* m_RightPanel;
112 wxBoxSizer* m_RightPanelSizer;
113
115
116protected:
120 wxSplitterWindow* m_hsplitter;
121 wxSplitterWindow* m_vsplitter;
122
123 wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER> m_adapter;
124
128
130 std::function<bool( LIB_TREE_NODE& )> m_filter;
131 std::function<void()> m_acceptHandler;
132 std::function<void()> m_escapeHandler;
133
135
136 std::vector<std::unique_ptr<FOOTPRINT>> m_historyFootprints;
137};
138
139#endif /* PANEL_FOOTPRINT_CHOOSER_H */
Add dark theme support to wxHtmlWindow.
Definition html_window.h:31
A logical library item identifier and consists of various portions much like a URI.
Definition lib_id.h:45
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:44
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
void OnChar(wxKeyEvent &aEvent)
std::function< void()> m_escapeHandler
void onMenuOpen(wxMenuEvent &aEvent)
Handle parent frame menu events to block tree preview.
wxSplitterWindow * GetVerticalSpliter() const
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)
PANEL_FOOTPRINT_CHOOSER(PCB_BASE_FRAME *aFrame, wxTopLevelWindow *aParent, const wxArrayString &aFootprintHistoryList, std::function< bool(LIB_TREE_NODE &)> aFilter, std::function< void()> aAcceptHandler, std::function< void()> aEscapeHandler)
Create dialog to choose component.
std::vector< std::unique_ptr< FOOTPRINT > > m_historyFootprints
void onMenuClose(wxMenuEvent &aEvent)
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)