KiCad PCB EDA Suite
Loading...
Searching...
No Matches
footprint_tree_pane.cpp
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 The KiCad Developers, see AUTHORS.txt for contributors.
5
*
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 3
9
* of the License, or (at your option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, you may find one here:
18
* https://www.gnu.org/licenses/gpl-3.0.html
19
* or you may search the http://www.gnu.org website for the version 3 license,
20
* or you may write to the Free Software Foundation, Inc.,
21
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22
*/
23
24
#include "
footprint_tree_pane.h
"
25
#include "
fp_tree_synchronizing_adapter.h
"
26
#include <
widgets/lib_tree.h
>
27
#include <
footprint_edit_frame.h
>
28
#include <
fp_lib_table.h
>
29
30
FOOTPRINT_TREE_PANE::FOOTPRINT_TREE_PANE
(
FOOTPRINT_EDIT_FRAME
* aParent )
31
: wxPanel( aParent ),
32
m_frame
( aParent ),
33
m_tree
( nullptr )
34
{
35
// Create widgets
36
wxBoxSizer* boxSizer =
new
wxBoxSizer( wxVERTICAL );
37
m_tree
=
new
LIB_TREE
(
this
, wxT(
"footprints"
), &
GFootprintTable
,
38
m_frame
->GetLibTreeAdapter(),
LIB_TREE::SEARCH
);
39
boxSizer->Add(
m_tree
, 1, wxEXPAND, 5 );
40
41
SetSizer( boxSizer );
// should remove the previous sizer according to wxWidgets docs
42
Layout();
43
boxSizer->Fit(
this
);
44
45
m_frame
->GetLibTreeAdapter()->FinishTreeInitialization();
46
47
// Event handlers
48
Bind( EVT_LIBITEM_CHOSEN, &
FOOTPRINT_TREE_PANE::onComponentSelected
,
this
);
49
m_tree
->Bind( wxEVT_UPDATE_UI, &
FOOTPRINT_TREE_PANE::onUpdateUI
,
this
);
50
m_frame
->Bind( wxEVT_MENU_OPEN, &
FOOTPRINT_TREE_PANE::onMenuOpen
,
this
);
51
m_frame
->Bind( wxEVT_MENU_CLOSE, &
FOOTPRINT_TREE_PANE::onMenuClose
,
this
);
52
}
53
54
55
void
FOOTPRINT_TREE_PANE::FocusSearchFieldIfExists
()
56
{
57
if
(
m_tree
)
58
{
59
m_tree
->FocusSearchFieldIfExists();
60
}
61
}
62
63
64
FOOTPRINT_TREE_PANE::~FOOTPRINT_TREE_PANE
()
65
{
66
m_frame
->Unbind( wxEVT_MENU_OPEN, &
FOOTPRINT_TREE_PANE::onMenuOpen
,
this
);
67
m_frame
->Unbind( wxEVT_MENU_CLOSE, &
FOOTPRINT_TREE_PANE::onMenuClose
,
this
);
68
m_tree
->Unbind( wxEVT_UPDATE_UI, &
FOOTPRINT_TREE_PANE::onUpdateUI
,
this
);
69
Unbind( EVT_LIBITEM_CHOSEN, &
FOOTPRINT_TREE_PANE::onComponentSelected
,
this
);
70
m_tree
->Destroy();
71
}
72
73
74
void
FOOTPRINT_TREE_PANE::onMenuOpen
( wxMenuEvent& aEvent )
75
{
76
m_tree
->BlockPreview(
true
);
77
aEvent.Skip();
78
}
79
80
81
void
FOOTPRINT_TREE_PANE::onMenuClose
( wxMenuEvent& aEvent )
82
{
83
m_tree
->BlockPreview(
false
);
84
aEvent.Skip();
85
}
86
87
88
void
FOOTPRINT_TREE_PANE::onComponentSelected
( wxCommandEvent& aEvent )
89
{
90
m_frame
->LoadFootprintFromLibrary(
GetLibTree
()->GetSelectedLibId() );
91
// Make sure current-part highlighting doesn't get lost in seleciton highlighting
92
m_tree
->Unselect();
93
}
94
95
96
void
FOOTPRINT_TREE_PANE::onUpdateUI
( wxUpdateUIEvent& aEvent )
97
{
98
if
(
m_frame
->GetCanvas()->HasFocus() )
99
{
100
// Don't allow a selected item in the tree when the canvas has focus: it's too easy
101
// to confuse the selected-highlighting with the being-edited-on-canvas-highlighting.
102
m_tree
->Unselect();
103
}
104
}
FOOTPRINT_EDIT_FRAME
Definition
footprint_edit_frame.h:41
FOOTPRINT_TREE_PANE::m_tree
LIB_TREE * m_tree
component search tree widget
Definition
footprint_tree_pane.h:68
FOOTPRINT_TREE_PANE::onMenuClose
void onMenuClose(wxMenuEvent &aEvent)
Definition
footprint_tree_pane.cpp:81
FOOTPRINT_TREE_PANE::onUpdateUI
void onUpdateUI(wxUpdateUIEvent &aEvent)
Definition
footprint_tree_pane.cpp:96
FOOTPRINT_TREE_PANE::onMenuOpen
void onMenuOpen(wxMenuEvent &aEvent)
Handle parent menu events to block preview updates while the menu is open.
Definition
footprint_tree_pane.cpp:74
FOOTPRINT_TREE_PANE::m_frame
FOOTPRINT_EDIT_FRAME * m_frame
Definition
footprint_tree_pane.h:67
FOOTPRINT_TREE_PANE::FocusSearchFieldIfExists
void FocusSearchFieldIfExists()
Focus the search widget if it exists.
Definition
footprint_tree_pane.cpp:55
FOOTPRINT_TREE_PANE::onComponentSelected
void onComponentSelected(wxCommandEvent &aEvent)
Definition
footprint_tree_pane.cpp:88
FOOTPRINT_TREE_PANE::~FOOTPRINT_TREE_PANE
~FOOTPRINT_TREE_PANE()
Definition
footprint_tree_pane.cpp:64
FOOTPRINT_TREE_PANE::FOOTPRINT_TREE_PANE
FOOTPRINT_TREE_PANE(FOOTPRINT_EDIT_FRAME *aParent)
Definition
footprint_tree_pane.cpp:30
FOOTPRINT_TREE_PANE::GetLibTree
LIB_TREE * GetLibTree() const
Definition
footprint_tree_pane.h:46
LIB_TREE
Widget displaying a tree of symbols with optional search text control and description panel.
Definition
lib_tree.h:49
LIB_TREE::SEARCH
@ SEARCH
Definition
lib_tree.h:55
GFootprintTable
FP_LIB_TABLE GFootprintTable
The global footprint library table.
Definition
cvpcb.cpp:150
footprint_edit_frame.h
footprint_tree_pane.h
fp_lib_table.h
fp_tree_synchronizing_adapter.h
lib_tree.h
src
pcbnew
footprint_tree_pane.cpp
Generated on Sun Sep 21 2025 01:05:29 for KiCad PCB EDA Suite by
1.13.2