2018-07-29 15:33:58 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2021-06-10 14:10:55 +00:00
|
|
|
* Copyright (C) 2018-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
2018-07-29 15:33:58 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 3
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* https://www.gnu.org/licenses/gpl-3.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 3 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "footprint_tree_pane.h"
|
|
|
|
#include "fp_tree_synchronizing_adapter.h"
|
|
|
|
#include <widgets/lib_tree.h>
|
|
|
|
#include <footprint_edit_frame.h>
|
|
|
|
#include <fp_lib_table.h>
|
|
|
|
|
|
|
|
FOOTPRINT_TREE_PANE::FOOTPRINT_TREE_PANE( FOOTPRINT_EDIT_FRAME* aParent )
|
|
|
|
: wxPanel( aParent ),
|
|
|
|
m_frame( aParent ),
|
|
|
|
m_tree( nullptr )
|
|
|
|
{
|
|
|
|
// Create widgets
|
|
|
|
wxBoxSizer* boxSizer = new wxBoxSizer( wxVERTICAL );
|
2022-09-15 13:32:27 +00:00
|
|
|
m_tree = new LIB_TREE( this, wxT( "footprints" ), &GFootprintTable,
|
|
|
|
m_frame->GetLibTreeAdapter(), LIB_TREE::SEARCH );
|
2018-07-29 15:33:58 +00:00
|
|
|
boxSizer->Add( m_tree, 1, wxEXPAND, 5 );
|
|
|
|
|
|
|
|
SetSizer( boxSizer ); // should remove the previous sizer according to wxWidgets docs
|
|
|
|
Layout();
|
|
|
|
boxSizer->Fit( this );
|
2020-01-03 15:39:05 +00:00
|
|
|
|
2021-04-01 09:49:05 +00:00
|
|
|
m_frame->GetLibTreeAdapter()->FinishTreeInitialization();
|
|
|
|
|
2018-07-29 15:33:58 +00:00
|
|
|
// Event handlers
|
2021-06-10 14:10:55 +00:00
|
|
|
Bind( SYMBOL_SELECTED, &FOOTPRINT_TREE_PANE::onComponentSelected, this );
|
2018-07-29 15:33:58 +00:00
|
|
|
m_tree->Bind( wxEVT_UPDATE_UI, &FOOTPRINT_TREE_PANE::onUpdateUI, this );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
FOOTPRINT_TREE_PANE::~FOOTPRINT_TREE_PANE()
|
|
|
|
{
|
|
|
|
m_tree->Destroy();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FOOTPRINT_TREE_PANE::onComponentSelected( wxCommandEvent& aEvent )
|
|
|
|
{
|
2020-11-10 20:31:52 +00:00
|
|
|
m_frame->LoadFootprintFromLibrary( GetLibTree()->GetSelectedLibId() );
|
2018-07-29 15:33:58 +00:00
|
|
|
// Make sure current-part highlighting doesn't get lost in seleciton highlighting
|
|
|
|
m_tree->Unselect();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FOOTPRINT_TREE_PANE::onUpdateUI( wxUpdateUIEvent& aEvent )
|
|
|
|
{
|
2019-06-13 17:28:55 +00:00
|
|
|
if( m_frame->GetCanvas()->HasFocus() )
|
2018-07-29 15:33:58 +00:00
|
|
|
{
|
|
|
|
// Don't allow a selected item in the tree when the canvas has focus: it's too easy
|
|
|
|
// to confuse the selected-highlighting with the being-edited-on-canvas-highlighting.
|
|
|
|
m_tree->Unselect();
|
|
|
|
}
|
|
|
|
}
|