KiCad PCB EDA Suite
FOOTPRINT_TREE_PANE Class Reference

Footprint Editor pane with footprint library tree. More...

#include <footprint_tree_pane.h>

Inheritance diagram for FOOTPRINT_TREE_PANE:

Public Member Functions

 FOOTPRINT_TREE_PANE (FOOTPRINT_EDIT_FRAME *aParent)
 
 ~FOOTPRINT_TREE_PANE ()
 
LIB_TREEGetLibTree () const
 
void Regenerate ()
 

Updates the footprint tree

More...
 

Protected Member Functions

void onComponentSelected (wxCommandEvent &aEvent)
 
void onUpdateUI (wxUpdateUIEvent &aEvent)
 

Protected Attributes

FOOTPRINT_EDIT_FRAMEm_frame
 
LIB_TREEm_tree
 component search tree widget More...
 

Detailed Description

Footprint Editor pane with footprint library tree.

Definition at line 39 of file footprint_tree_pane.h.

Constructor & Destructor Documentation

FOOTPRINT_TREE_PANE::FOOTPRINT_TREE_PANE ( FOOTPRINT_EDIT_FRAME aParent)

Definition at line 34 of file footprint_tree_pane.cpp.

References AddMenuItem(), FOOTPRINT_EDIT_FRAME::GetLibTreeAdapter(), GFootprintTable, ID_MODEDIT_ADD_LIBRARY, ID_MODEDIT_COPY_PART, ID_MODEDIT_CREATE_NEW_LIB, ID_MODEDIT_CUT_PART, ID_MODEDIT_DELETE_PART, ID_MODEDIT_EDIT_MODULE, ID_MODEDIT_EXPORT_PART, ID_MODEDIT_IMPORT_PART, ID_MODEDIT_NEW_MODULE, ID_MODEDIT_NEW_MODULE_FROM_WIZARD, ID_MODEDIT_PASTE_PART, ID_MODEDIT_REVERT_PART, ID_MODEDIT_SAVE, ID_MODEDIT_SAVE_AS, LIB_TREE_NODE::INVALID, KiBitmap(), LIB_TREE_NODE::LIB, LIB_TREE_NODE::LIBID, m_frame, m_tree, onComponentSelected(), onUpdateUI(), LIB_TREE::SEARCH, and LIB_TREE::SetMenu().

35  : wxPanel( aParent ),
36  m_frame( aParent ),
37  m_tree( nullptr )
38 {
39  // Create widgets
40  wxBoxSizer* boxSizer = new wxBoxSizer( wxVERTICAL );
42  boxSizer->Add( m_tree, 1, wxEXPAND, 5 );
43 
44  SetSizer( boxSizer ); // should remove the previous sizer according to wxWidgets docs
45  Layout();
46  boxSizer->Fit( this );
47 
48  // Setup right click-context menus
49  std::unique_ptr<wxMenu> menuLibrary = std::make_unique<wxMenu>();
50 
51  AddMenuItem( menuLibrary.get(), ID_MODEDIT_CREATE_NEW_LIB, _( "&New Library..." ),
52  KiBitmap( new_library_xpm ) );
53 
54  AddMenuItem( menuLibrary.get(), ID_MODEDIT_ADD_LIBRARY, _( "&Add Library..." ),
55  KiBitmap( add_library_xpm ) );
56 
57  AddMenuItem( menuLibrary.get(), ID_MODEDIT_SAVE, _( "&Save" ),
58  KiBitmap( save_xpm ) );
59  AddMenuItem( menuLibrary.get(), ID_MODEDIT_SAVE_AS, _( "Save a Copy &As..." ),
60  KiBitmap( save_as_xpm ) );
61 
62  menuLibrary->AppendSeparator();
63  AddMenuItem( menuLibrary.get(), ID_MODEDIT_NEW_MODULE, _( "&New Footprint..." ),
64  KiBitmap( new_component_xpm ) );
65 #ifdef KICAD_SCRIPTING
66  AddMenuItem( menuLibrary.get(), ID_MODEDIT_NEW_MODULE_FROM_WIZARD, _( "&Create Footprint from Wizard..." ),
67  KiBitmap( new_component_xpm ) );
68 #endif
69  AddMenuItem( menuLibrary.get(), ID_MODEDIT_IMPORT_PART, _( "&Import Footprint..." ),
70  KiBitmap( import_part_xpm ) );
71  AddMenuItem( menuLibrary.get(), ID_MODEDIT_PASTE_PART, _( "Paste Footprint" ),
72  KiBitmap( paste_xpm ) );
73 
74  std::unique_ptr<wxMenu> menuPart = std::make_unique<wxMenu>();
75  AddMenuItem( menuPart.get(), ID_MODEDIT_EDIT_MODULE, _( "&Edit Footprint" ),
76  KiBitmap( edit_xpm ) );
77 
78  menuPart->AppendSeparator();
79  AddMenuItem( menuPart.get(), ID_MODEDIT_SAVE, _( "&Save" ),
80  KiBitmap( save_xpm ) );
81  AddMenuItem( menuPart.get(), ID_MODEDIT_SAVE_AS, _( "Save &As..." ),
82  KiBitmap( save_xpm ) );
83  AddMenuItem( menuPart.get(), ID_MODEDIT_DELETE_PART, _( "&Delete" ),
84  KiBitmap( delete_xpm ) );
85  AddMenuItem( menuPart.get(), ID_MODEDIT_REVERT_PART, _( "Revert" ),
86  KiBitmap( undo_xpm ) );
87 
88  menuPart->AppendSeparator();
89  AddMenuItem( menuPart.get(), ID_MODEDIT_CUT_PART, _( "Cut" ),
90  KiBitmap( cut_xpm ) );
91  AddMenuItem( menuPart.get(), ID_MODEDIT_COPY_PART, _( "Copy" ),
92  KiBitmap( copy_xpm ) );
93 
94  menuPart->AppendSeparator();
95  AddMenuItem( menuPart.get(), ID_MODEDIT_EXPORT_PART, _( "E&xport Footprint..." ),
96  KiBitmap( export_part_xpm ) );
97 
98  // Menu displayed when nothing is selected
99  std::unique_ptr<wxMenu> menuNoSelection = std::make_unique<wxMenu>();
100  AddMenuItem( menuNoSelection.get(), ID_MODEDIT_CREATE_NEW_LIB, _( "&New Library..." ),
101  KiBitmap( new_library_xpm ) );
102 
103  AddMenuItem( menuNoSelection.get(), ID_MODEDIT_ADD_LIBRARY, _( "&Add Library..." ),
104  KiBitmap( add_library_xpm ) );
105 
106  m_tree->SetMenu( LIB_TREE_NODE::LIBID, std::move( menuPart ) );
107  m_tree->SetMenu( LIB_TREE_NODE::LIB, std::move( menuLibrary ) );
108  m_tree->SetMenu( LIB_TREE_NODE::INVALID, std::move( menuNoSelection ) );
109 
110  // Event handlers
111  Bind( COMPONENT_SELECTED, &FOOTPRINT_TREE_PANE::onComponentSelected, this );
112  m_tree->Bind( wxEVT_UPDATE_UI, &FOOTPRINT_TREE_PANE::onUpdateUI, this );
113 }
LIB_TREE_MODEL_ADAPTER::PTR & GetLibTreeAdapter()
Returns the adapter object that provides the stored data.
wxMenuItem * AddMenuItem(wxMenu *aMenu, int aId, const wxString &aText, const wxBitmap &aImage, wxItemKind aType=wxITEM_NORMAL)
Function AddMenuItem is an inline helper function to create and insert a menu item with an icon into ...
Definition: bitmap.cpp:223
FP_LIB_TABLE GFootprintTable
The global footprint library table.
Definition: pcbnew.cpp:333
FOOTPRINT_EDIT_FRAME * m_frame
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:79
void SetMenu(LIB_TREE_NODE::TYPE aType, std::unique_ptr< wxMenu > aMenu)
Associates a right click context menu for a specific node type.
Definition: lib_tree.h:97
void onComponentSelected(wxCommandEvent &aEvent)
LIB_TREE * m_tree
component search tree widget
void onUpdateUI(wxUpdateUIEvent &aEvent)
Widget displaying a tree of components with optional search text control and description panel...
Definition: lib_tree.h:42
FOOTPRINT_TREE_PANE::~FOOTPRINT_TREE_PANE ( )

Definition at line 116 of file footprint_tree_pane.cpp.

References m_tree.

117 {
118  m_tree->Destroy();
119 }
LIB_TREE * m_tree
component search tree widget

Member Function Documentation

LIB_TREE* FOOTPRINT_TREE_PANE::GetLibTree ( ) const
inline

Definition at line 45 of file footprint_tree_pane.h.

References m_tree, onComponentSelected(), onUpdateUI(), and Regenerate().

Referenced by FOOTPRINT_EDIT_FRAME::getTargetFPID(), FOOTPRINT_EDIT_FRAME::OnModify(), and FOOTPRINT_EDIT_FRAME::SyncLibraryTree().

46  {
47  return m_tree;
48  }
LIB_TREE * m_tree
component search tree widget
void FOOTPRINT_TREE_PANE::onComponentSelected ( wxCommandEvent &  aEvent)
protected

Definition at line 129 of file footprint_tree_pane.cpp.

References ID_MODEDIT_EDIT_MODULE, m_frame, m_tree, FOOTPRINT_EDIT_FRAME::Process_Special_Functions(), and LIB_TREE::Unselect().

Referenced by FOOTPRINT_TREE_PANE(), and GetLibTree().

130 {
131  wxCommandEvent evt( wxEVT_COMMAND_TOOL_CLICKED, ID_MODEDIT_EDIT_MODULE );
133 
134  // Make sure current-part highlighting doesn't get lost in seleciton highlighting
135  m_tree->Unselect();
136 }
FOOTPRINT_EDIT_FRAME * m_frame
void Unselect()
Unselect currently selected item in wxDataViewCtrl.
Definition: lib_tree.cpp:174
void Process_Special_Functions(wxCommandEvent &event)
LIB_TREE * m_tree
component search tree widget
void FOOTPRINT_TREE_PANE::onUpdateUI ( wxUpdateUIEvent &  aEvent)
protected

Definition at line 139 of file footprint_tree_pane.cpp.

References EDA_DRAW_FRAME::GetGalCanvas(), m_frame, m_tree, and LIB_TREE::Unselect().

Referenced by FOOTPRINT_TREE_PANE(), and GetLibTree().

140 {
141  if( m_frame->GetGalCanvas()->HasFocus() )
142  {
143  // Don't allow a selected item in the tree when the canvas has focus: it's too easy
144  // to confuse the selected-highlighting with the being-edited-on-canvas-highlighting.
145  m_tree->Unselect();
146  }
147 }
FOOTPRINT_EDIT_FRAME * m_frame
void Unselect()
Unselect currently selected item in wxDataViewCtrl.
Definition: lib_tree.cpp:174
LIB_TREE * m_tree
component search tree widget
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:918
void FOOTPRINT_TREE_PANE::Regenerate ( )

Updates the footprint tree

Definition at line 122 of file footprint_tree_pane.cpp.

References m_tree, and LIB_TREE::Regenerate().

Referenced by GetLibTree(), and FOOTPRINT_EDIT_FRAME::SyncLibraryTree().

123 {
124  if( m_tree )
125  m_tree->Regenerate();
126 }
void Regenerate()
Regenerates the tree.
Definition: lib_tree.cpp:185
LIB_TREE * m_tree
component search tree widget

Member Data Documentation

FOOTPRINT_EDIT_FRAME* FOOTPRINT_TREE_PANE::m_frame
protected

Definition at line 57 of file footprint_tree_pane.h.

Referenced by FOOTPRINT_TREE_PANE(), onComponentSelected(), and onUpdateUI().

LIB_TREE* FOOTPRINT_TREE_PANE::m_tree
protected

component search tree widget

Definition at line 58 of file footprint_tree_pane.h.

Referenced by FOOTPRINT_TREE_PANE(), GetLibTree(), onComponentSelected(), onUpdateUI(), Regenerate(), and ~FOOTPRINT_TREE_PANE().


The documentation for this class was generated from the following files: