KiCad PCB EDA Suite
symbol_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 (C) 2017 CERN
5  * @author Maciej Suminski <maciej.suminski@cern.ch>
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 3
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  * https://www.gnu.org/licenses/gpl-3.0.html
20  * or you may search the http://www.gnu.org website for the version 3 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 
25 #include "symbol_tree_pane.h"
26 #include <widgets/lib_tree.h>
27 #include <lib_manager.h>
28 #include <lib_edit_frame.h>
29 #include <symbol_lib_table.h>
30 #include <tool/tool_manager.h>
31 #include <tools/ee_actions.h>
32 
34  : wxPanel( aParent ),
35  m_libEditFrame( aParent ),
36  m_tree( nullptr ),
37  m_libMgr( aLibMgr )
38 {
39  // Create widgets
40  wxBoxSizer* boxSizer = new wxBoxSizer( wxVERTICAL );
43  boxSizer->Add( m_tree, 1, wxEXPAND, 5 );
44 
45  SetSizer( boxSizer ); // should remove the previous sizer according to wxWidgets docs
46  Layout();
47  boxSizer->Fit( this );
48 
49  // Event handlers
50  Bind( COMPONENT_SELECTED, &SYMBOL_TREE_PANE::onComponentSelected, this );
51 }
52 
53 
55 {
56  m_tree->Destroy();
57 }
58 
59 
61 {
62  if( m_tree )
63  m_tree->Regenerate( true );
64 }
65 
66 
67 void SYMBOL_TREE_PANE::onComponentSelected( wxCommandEvent& aEvent )
68 {
70 
71  // Make sure current-part highlighting doesn't get lost in selection highlighting
72  m_tree->Unselect();
73 
74  // Turn off any previous current-part highlighting
76 }
static SYMBOL_LIB_TABLE & GetGlobalLibTable()
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
LIB_MANAGER * m_libMgr
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:109
LIB_EDIT_FRAME * m_libEditFrame
static TOOL_ACTION editSymbol
Definition: ee_actions.h:166
void onComponentSelected(wxCommandEvent &aEvent)
LIB_TREE * m_tree
component search tree widget
void Regenerate(bool aKeepState)
Regenerates the tree.
Definition: lib_tree.cpp:186
void Unselect()
Unselect currently selected item in wxDataViewCtrl.
Definition: lib_tree.cpp:175
void RefreshLibTree()
Refreshes the tree (mainly to update highlighting and asterisking)
Definition: lib_tree.cpp:204
Class to handle modifications to the symbol libraries.
Definition: lib_manager.h:98
The symbol library editor main window.
SYMBOL_TREE_PANE(LIB_EDIT_FRAME *aParent, LIB_MANAGER *aLibMgr)
LIB_TREE_MODEL_ADAPTER::PTR & GetAdapter()
Returns the adapter object that provides the stored data.
Definition: lib_manager.h:269
void Regenerate()
Updates the component tree
Widget displaying a tree of components with optional search text control and description panel.
Definition: lib_tree.h:42