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, see <https://www.gnu.org/licenses/>.
18
*/
19
20
#include "
footprint_tree_pane.h
"
21
#include "
fp_tree_synchronizing_adapter.h
"
22
#include <
widgets/lib_tree.h
>
23
#include <
footprint_edit_frame.h
>
24
25
26
FOOTPRINT_TREE_PANE::FOOTPRINT_TREE_PANE
(
FOOTPRINT_EDIT_FRAME
* aParent )
27
: wxPanel( aParent ),
28
m_frame
( aParent ),
29
m_tree
( nullptr )
30
{
31
// Create widgets
32
wxBoxSizer* boxSizer =
new
wxBoxSizer( wxVERTICAL );
33
m_tree
=
new
LIB_TREE
(
this
, wxT(
"footprints"
),
34
m_frame
->GetLibTreeAdapter(),
LIB_TREE::SEARCH
);
35
boxSizer->Add(
m_tree
, 1, wxEXPAND, 5 );
36
37
SetSizer( boxSizer );
// should remove the previous sizer according to wxWidgets docs
38
Layout();
39
boxSizer->Fit(
this
);
40
41
m_frame
->GetLibTreeAdapter()->FinishTreeInitialization();
42
43
// Event handlers
44
Bind( EVT_LIBITEM_CHOSEN, &
FOOTPRINT_TREE_PANE::onComponentSelected
,
this
);
45
m_tree
->Bind( wxEVT_UPDATE_UI, &
FOOTPRINT_TREE_PANE::onUpdateUI
,
this
);
46
m_frame
->Bind( wxEVT_MENU_OPEN, &
FOOTPRINT_TREE_PANE::onMenuOpen
,
this
);
47
m_frame
->Bind( wxEVT_MENU_CLOSE, &
FOOTPRINT_TREE_PANE::onMenuClose
,
this
);
48
}
49
50
51
void
FOOTPRINT_TREE_PANE::FocusSearchFieldIfExists
()
52
{
53
if
(
m_tree
)
54
{
55
m_tree
->FocusSearchFieldIfExists();
56
}
57
}
58
59
60
FOOTPRINT_TREE_PANE::~FOOTPRINT_TREE_PANE
()
61
{
62
m_frame
->Unbind( wxEVT_MENU_OPEN, &
FOOTPRINT_TREE_PANE::onMenuOpen
,
this
);
63
m_frame
->Unbind( wxEVT_MENU_CLOSE, &
FOOTPRINT_TREE_PANE::onMenuClose
,
this
);
64
m_tree
->Unbind( wxEVT_UPDATE_UI, &
FOOTPRINT_TREE_PANE::onUpdateUI
,
this
);
65
Unbind( EVT_LIBITEM_CHOSEN, &
FOOTPRINT_TREE_PANE::onComponentSelected
,
this
);
66
m_tree
->Destroy();
67
}
68
69
70
void
FOOTPRINT_TREE_PANE::onMenuOpen
( wxMenuEvent& aEvent )
71
{
72
m_tree
->BlockPreview(
true
);
73
aEvent.Skip();
74
}
75
76
77
void
FOOTPRINT_TREE_PANE::onMenuClose
( wxMenuEvent& aEvent )
78
{
79
m_tree
->BlockPreview(
false
);
80
aEvent.Skip();
81
}
82
83
84
void
FOOTPRINT_TREE_PANE::onComponentSelected
( wxCommandEvent& aEvent )
85
{
86
m_frame
->LoadFootprintFromLibrary(
GetLibTree
()->GetSelectedLibId() );
87
// Make sure current-part highlighting doesn't get lost in seleciton highlighting
88
m_tree
->Unselect();
89
}
90
91
92
void
FOOTPRINT_TREE_PANE::onUpdateUI
( wxUpdateUIEvent& aEvent )
93
{
94
if
(
m_frame
->GetCanvas()->HasFocus() )
95
{
96
// Don't allow a selected item in the tree when the canvas has focus: it's too easy
97
// to confuse the selected-highlighting with the being-edited-on-canvas-highlighting.
98
m_tree
->Unselect();
99
}
100
}
FOOTPRINT_EDIT_FRAME
Definition
footprint_edit_frame.h:47
FOOTPRINT_TREE_PANE::m_tree
LIB_TREE * m_tree
component search tree widget
Definition
footprint_tree_pane.h:64
FOOTPRINT_TREE_PANE::onMenuClose
void onMenuClose(wxMenuEvent &aEvent)
Definition
footprint_tree_pane.cpp:77
FOOTPRINT_TREE_PANE::onUpdateUI
void onUpdateUI(wxUpdateUIEvent &aEvent)
Definition
footprint_tree_pane.cpp:92
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:70
FOOTPRINT_TREE_PANE::m_frame
FOOTPRINT_EDIT_FRAME * m_frame
Definition
footprint_tree_pane.h:63
FOOTPRINT_TREE_PANE::FocusSearchFieldIfExists
void FocusSearchFieldIfExists()
Focus the search widget if it exists.
Definition
footprint_tree_pane.cpp:51
FOOTPRINT_TREE_PANE::onComponentSelected
void onComponentSelected(wxCommandEvent &aEvent)
Definition
footprint_tree_pane.cpp:84
FOOTPRINT_TREE_PANE::~FOOTPRINT_TREE_PANE
~FOOTPRINT_TREE_PANE()
Definition
footprint_tree_pane.cpp:60
FOOTPRINT_TREE_PANE::FOOTPRINT_TREE_PANE
FOOTPRINT_TREE_PANE(FOOTPRINT_EDIT_FRAME *aParent)
Definition
footprint_tree_pane.cpp:26
FOOTPRINT_TREE_PANE::GetLibTree
LIB_TREE * GetLibTree() const
Definition
footprint_tree_pane.h:42
LIB_TREE
Widget displaying a tree of symbols with optional search text control and description panel.
Definition
lib_tree.h:46
LIB_TREE::SEARCH
@ SEARCH
Definition
lib_tree.h:52
footprint_edit_frame.h
footprint_tree_pane.h
fp_tree_synchronizing_adapter.h
lib_tree.h
src
pcbnew
footprint_tree_pane.cpp
Generated on Fri Jun 26 2026 00:05:39 for KiCad PCB EDA Suite by
1.13.2