KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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 * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
6 * @author Maciej Suminski <[email protected]>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 3
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, you may find one here:
20 * https://www.gnu.org/licenses/gpl-3.0.html
21 * or you may search the http://www.gnu.org website for the version 3 license,
22 * or you may write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 */
25
26#include "symbol_tree_pane.h"
27#include <widgets/lib_tree.h>
29#include <symbol_edit_frame.h>
30#include <symbol_lib_table.h>
31#include <tool/tool_manager.h>
32#include <tools/ee_actions.h>
33
36 : wxPanel( aParent ),
37 m_symbolEditFrame( aParent ),
38 m_tree( nullptr ),
39 m_libMgr( aLibMgr )
40{
41 // Create widgets
42 wxBoxSizer* boxSizer = new wxBoxSizer( wxVERTICAL );
43 m_tree = new LIB_TREE( this, wxT( "symbols" ), &SYMBOL_LIB_TABLE::GetGlobalLibTable(),
45 boxSizer->Add( m_tree, 1, wxEXPAND, 5 );
46
47 SetSizer( boxSizer ); // should remove the previous sizer according to wxWidgets docs
48 Layout();
49 boxSizer->Fit( this );
50
51 m_libMgr->GetAdapter()->FinishTreeInitialization();
52
53 // Event handlers
54 Bind( EVT_LIBITEM_CHOSEN, &SYMBOL_TREE_PANE::onSymbolSelected, this );
55 m_tree->Bind( wxEVT_UPDATE_UI, &SYMBOL_TREE_PANE::onUpdateUI, this );
56}
57
58
60{
61 m_tree->Destroy();
62}
63
64
65void SYMBOL_TREE_PANE::onSymbolSelected( wxCommandEvent& aEvent )
66{
68
69 // Make sure current-part highlighting doesn't get lost in selection highlighting
71
72 // Turn off any previous current-part highlighting
74}
75
76
77void SYMBOL_TREE_PANE::onUpdateUI( wxUpdateUIEvent& aEvent )
78{
79 if( m_symbolEditFrame->GetCanvas()->HasFocus() )
80 {
81 // Don't allow a selected item in the tree when the canvas has focus: it's too easy
82 // to confuse the selected-highlighting with the being-edited-on-canvas-highlighting.
83 if( m_symbolEditFrame->GetCurSymbol() != nullptr )
84 {
86 }
87 }
88}
static TOOL_ACTION editSymbol
Definition: ee_actions.h:218
Symbol library management helper that is specific to the symbol library editor frame.
wxObjectDataPtr< LIB_TREE_MODEL_ADAPTER > & GetAdapter()
Return the adapter object that provides the stored data.
Widget displaying a tree of symbols with optional search text control and description panel....
Definition: lib_tree.h:49
void RefreshLibTree()
Refreshes the tree (mainly to update highlighting and asterisking)
Definition: lib_tree.cpp:440
void Unselect()
Unselect currently selected item in wxDataViewCtrl.
Definition: lib_tree.cpp:355
@ MULTISELECT
Definition: lib_tree.h:59
@ SEARCH
Definition: lib_tree.h:55
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
The symbol library editor main window.
LIB_SYMBOL * GetCurSymbol() const
Return the current symbol being edited or NULL if none selected.
static SYMBOL_LIB_TABLE & GetGlobalLibTable()
void onUpdateUI(wxUpdateUIEvent &aEvent)
LIB_SYMBOL_LIBRARY_MANAGER * m_libMgr
SYMBOL_TREE_PANE(SYMBOL_EDIT_FRAME *aParent, LIB_SYMBOL_LIBRARY_MANAGER *aLibMgr)
SYMBOL_EDIT_FRAME * m_symbolEditFrame
void onSymbolSelected(wxCommandEvent &aEvent)
LIB_TREE * m_tree
symbol search tree widget
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:55
bool RunAction(const std::string &aActionName, T aParam)
Run the specified action immediately, pausing the current action to run the new one.
Definition: tool_manager.h:150