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, 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 <wx/toplevel.h>
28
#include <
widgets/lib_tree.h
>
29
#include <
fp_tree_model_adapter.h
>
30
#include <
widgets/footprint_preview_widget.h
>
31
32
class
wxTimer;
33
class
wxSplitterWindow;
34
class
wxBoxSizer;
35
36
class
PCB_BASE_FRAME
;
37
class
FOOTPRINT
;
38
39
// When a new footprint is selected, a custom event is sent, for instance to update
40
// 3D viewer. So declare a FP_SELECTION_EVENT event
41
wxDECLARE_EVENT
(FP_SELECTION_EVENT, wxCommandEvent);
42
43
class
PANEL_FOOTPRINT_CHOOSER
:
public
wxPanel
44
{
45
public
:
54
PANEL_FOOTPRINT_CHOOSER
(
PCB_BASE_FRAME
* aFrame, wxTopLevelWindow* aParent,
55
const
wxArrayString& aFootprintHistoryList,
56
std::function<
bool
(
LIB_TREE_NODE
& )> aFilter,
57
std::function<
void
()> aAcceptHandler,
58
std::function<
void
()> aEscapeHandler );
59
60
~PANEL_FOOTPRINT_CHOOSER
();
61
62
void
OnChar
( wxKeyEvent& aEvent );
63
64
void
FinishSetup
();
65
66
void
SetPreselect
(
const
LIB_ID
& aPreselect );
67
73
LIB_ID
GetSelectedLibId
()
const
;
74
75
int
GetItemCount
()
const
{
return
m_adapter
->GetItemCount(); }
76
77
wxWindow*
GetFocusTarget
()
const
{
return
m_tree
->GetFocusTarget(); }
78
79
wxSizer*
GetFiltersSizer
()
const
{
return
m_tree
->GetFiltersSizer(); }
80
81
void
Regenerate
() {
m_tree
->Regenerate(
true
); }
82
83
FOOTPRINT_PREVIEW_WIDGET
*
GetViewerPanel
()
const
{
return
m_preview_ctrl
; }
84
85
wxSplitterWindow*
GetVerticalSpliter
()
const
{
return
m_vsplitter
; }
86
87
wxPanel*
GetDetailsPanel
()
const
{
return
m_detailsPanel
; }
88
89
protected
:
90
static
constexpr
int
DblClickDelay
= 100;
// milliseconds
91
92
void
OnDetailsCharHook
( wxKeyEvent& aEvt );
93
void
onCloseTimer
( wxTimerEvent& aEvent );
94
void
onOpenLibsTimer
( wxTimerEvent& aEvent );
95
99
void
onMenuOpen
( wxMenuEvent& aEvent );
100
void
onMenuClose
( wxMenuEvent& aEvent );
101
102
void
onFootprintSelected
( wxCommandEvent& aEvent );
103
110
void
onFootprintChosen
( wxCommandEvent& aEvent );
111
112
public
:
113
wxPanel*
m_RightPanel
;
114
wxBoxSizer*
m_RightPanelSizer
;
115
116
const
FOOTPRINT
*
m_CurrFootprint
;
117
118
protected
:
119
wxPanel*
m_detailsPanel
;
120
wxTimer*
m_dbl_click_timer
;
121
wxTimer*
m_open_libs_timer
;
122
wxSplitterWindow*
m_hsplitter
;
123
wxSplitterWindow*
m_vsplitter
;
124
125
wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER>
m_adapter
;
126
127
FOOTPRINT_PREVIEW_WIDGET
*
m_preview_ctrl
;
128
LIB_TREE
*
m_tree
;
129
HTML_WINDOW
*
m_details
;
130
131
PCB_BASE_FRAME
*
m_frame
;
132
std::function<bool(
LIB_TREE_NODE
& )>
m_filter
;
133
std::function<void()>
m_acceptHandler
;
134
std::function<void()>
m_escapeHandler
;
135
136
std::vector<std::unique_ptr<FOOTPRINT>>
m_historyFootprints
;
137
};
138
139
#endif
/* PANEL_FOOTPRINT_CHOOSER_H */
FOOTPRINT_PREVIEW_WIDGET
Definition
footprint_preview_widget.h:42
FOOTPRINT
Definition
footprint.h:219
HTML_WINDOW
Add dark theme support to wxHtmlWindow.
Definition
html_window.h:35
LIB_ID
A logical library item identifier and consists of various portions much like a URI.
Definition
lib_id.h:49
LIB_TREE_NODE
Model class in the component selector Model-View-Adapter (mediated MVC) architecture.
Definition
lib_tree_model.h:75
LIB_TREE
Widget displaying a tree of symbols with optional search text control and description panel.
Definition
lib_tree.h:50
PANEL_FOOTPRINT_CHOOSER::onFootprintSelected
void onFootprintSelected(wxCommandEvent &aEvent)
Definition
panel_footprint_chooser.cpp:331
PANEL_FOOTPRINT_CHOOSER::m_adapter
wxObjectDataPtr< LIB_TREE_MODEL_ADAPTER > m_adapter
Definition
panel_footprint_chooser.h:125
PANEL_FOOTPRINT_CHOOSER::onCloseTimer
void onCloseTimer(wxTimerEvent &aEvent)
Definition
panel_footprint_chooser.cpp:302
PANEL_FOOTPRINT_CHOOSER::m_acceptHandler
std::function< void()> m_acceptHandler
Definition
panel_footprint_chooser.h:133
PANEL_FOOTPRINT_CHOOSER::GetFiltersSizer
wxSizer * GetFiltersSizer() const
Definition
panel_footprint_chooser.h:79
PANEL_FOOTPRINT_CHOOSER::m_preview_ctrl
FOOTPRINT_PREVIEW_WIDGET * m_preview_ctrl
Definition
panel_footprint_chooser.h:127
PANEL_FOOTPRINT_CHOOSER::m_RightPanelSizer
wxBoxSizer * m_RightPanelSizer
Definition
panel_footprint_chooser.h:114
PANEL_FOOTPRINT_CHOOSER::GetFocusTarget
wxWindow * GetFocusTarget() const
Definition
panel_footprint_chooser.h:77
PANEL_FOOTPRINT_CHOOSER::m_CurrFootprint
const FOOTPRINT * m_CurrFootprint
Definition
panel_footprint_chooser.h:116
PANEL_FOOTPRINT_CHOOSER::OnChar
void OnChar(wxKeyEvent &aEvent)
Definition
panel_footprint_chooser.cpp:218
PANEL_FOOTPRINT_CHOOSER::m_escapeHandler
std::function< void()> m_escapeHandler
Definition
panel_footprint_chooser.h:134
PANEL_FOOTPRINT_CHOOSER::onMenuOpen
void onMenuOpen(wxMenuEvent &aEvent)
Handle parent frame menu events to block tree preview.
Definition
panel_footprint_chooser.cpp:239
PANEL_FOOTPRINT_CHOOSER::GetVerticalSpliter
wxSplitterWindow * GetVerticalSpliter() const
Definition
panel_footprint_chooser.h:85
PANEL_FOOTPRINT_CHOOSER::m_open_libs_timer
wxTimer * m_open_libs_timer
Definition
panel_footprint_chooser.h:121
PANEL_FOOTPRINT_CHOOSER::DblClickDelay
static constexpr int DblClickDelay
Definition
panel_footprint_chooser.h:90
PANEL_FOOTPRINT_CHOOSER::~PANEL_FOOTPRINT_CHOOSER
~PANEL_FOOTPRINT_CHOOSER()
Definition
panel_footprint_chooser.cpp:184
PANEL_FOOTPRINT_CHOOSER::m_filter
std::function< bool(LIB_TREE_NODE &)> m_filter
Definition
panel_footprint_chooser.h:132
PANEL_FOOTPRINT_CHOOSER::OnDetailsCharHook
void OnDetailsCharHook(wxKeyEvent &aEvt)
Definition
panel_footprint_chooser.cpp:376
PANEL_FOOTPRINT_CHOOSER::GetDetailsPanel
wxPanel * GetDetailsPanel() const
Definition
panel_footprint_chooser.h:87
PANEL_FOOTPRINT_CHOOSER::m_details
HTML_WINDOW * m_details
Definition
panel_footprint_chooser.h:129
PANEL_FOOTPRINT_CHOOSER::FinishSetup
void FinishSetup()
Definition
panel_footprint_chooser.cpp:253
PANEL_FOOTPRINT_CHOOSER::m_RightPanel
wxPanel * m_RightPanel
Definition
panel_footprint_chooser.h:113
PANEL_FOOTPRINT_CHOOSER::GetViewerPanel
FOOTPRINT_PREVIEW_WIDGET * GetViewerPanel() const
Definition
panel_footprint_chooser.h:83
PANEL_FOOTPRINT_CHOOSER::m_detailsPanel
wxPanel * m_detailsPanel
Definition
panel_footprint_chooser.h:119
PANEL_FOOTPRINT_CHOOSER::onOpenLibsTimer
void onOpenLibsTimer(wxTimerEvent &aEvent)
Definition
panel_footprint_chooser.cpp:324
PANEL_FOOTPRINT_CHOOSER::m_tree
LIB_TREE * m_tree
Definition
panel_footprint_chooser.h:128
PANEL_FOOTPRINT_CHOOSER::SetPreselect
void SetPreselect(const LIB_ID &aPreselect)
Definition
panel_footprint_chooser.cpp:290
PANEL_FOOTPRINT_CHOOSER::GetItemCount
int GetItemCount() const
Definition
panel_footprint_chooser.h:75
PANEL_FOOTPRINT_CHOOSER::m_frame
PCB_BASE_FRAME * m_frame
Definition
panel_footprint_chooser.h:131
PANEL_FOOTPRINT_CHOOSER::m_vsplitter
wxSplitterWindow * m_vsplitter
Definition
panel_footprint_chooser.h:123
PANEL_FOOTPRINT_CHOOSER::PANEL_FOOTPRINT_CHOOSER
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.
Definition
panel_footprint_chooser.cpp:53
PANEL_FOOTPRINT_CHOOSER::m_dbl_click_timer
wxTimer * m_dbl_click_timer
Definition
panel_footprint_chooser.h:120
PANEL_FOOTPRINT_CHOOSER::m_historyFootprints
std::vector< std::unique_ptr< FOOTPRINT > > m_historyFootprints
Definition
panel_footprint_chooser.h:136
PANEL_FOOTPRINT_CHOOSER::onMenuClose
void onMenuClose(wxMenuEvent &aEvent)
Definition
panel_footprint_chooser.cpp:246
PANEL_FOOTPRINT_CHOOSER::Regenerate
void Regenerate()
Definition
panel_footprint_chooser.h:81
PANEL_FOOTPRINT_CHOOSER::onFootprintChosen
void onFootprintChosen(wxCommandEvent &aEvent)
Handle the selection of an item.
Definition
panel_footprint_chooser.cpp:358
PANEL_FOOTPRINT_CHOOSER::m_hsplitter
wxSplitterWindow * m_hsplitter
Definition
panel_footprint_chooser.h:122
PANEL_FOOTPRINT_CHOOSER::GetSelectedLibId
LIB_ID GetSelectedLibId() const
To be called after this dialog returns from ShowModal().
Definition
panel_footprint_chooser.cpp:296
PCB_BASE_FRAME
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
Definition
pcb_base_frame.h:94
footprint_preview_widget.h
fp_tree_model_adapter.h
lib_tree.h
wxDECLARE_EVENT
wxDECLARE_EVENT(FP_SELECTION_EVENT, wxCommandEvent)
src
pcbnew
widgets
panel_footprint_chooser.h
Generated on Sat Feb 21 2026 00:08:10 for KiCad PCB EDA Suite by
1.13.2