![]() |
KiCad PCB EDA Suite
|
Widget displaying a tree of components with optional search text control and description panel.Custom event sent when a new component is preselected. More...
#include <lib_tree.h>
Classes | |
struct | STATE |
Structure storing state of the component tree widget. More... | |
Public Types | |
enum | WIDGETS { NONE = 0x00, SEARCH = 0x01, DETAILS = 0x02, ALL = 0xFF } |
< Flags to select extra widgets More... | |
Public Member Functions | |
LIB_TREE (wxWindow *aParent, LIB_TABLE *aLibTable, wxObjectDataPtr< LIB_TREE_MODEL_ADAPTER > &aAdapter, WIDGETS aWidgets=ALL, wxHtmlWindow *aDetails=nullptr) | |
Construct a component tree. More... | |
~LIB_TREE () override | |
LIB_ID | GetSelectedLibId (int *aUnit=nullptr) const |
For multi-unit components, if the user selects the component itself rather than picking an individual unit, 0 will be returned in aUnit. More... | |
LIB_TREE_NODE * | GetCurrentTreeNode () const |
void | SelectLibId (const LIB_ID &aLibId) |
Select an item in the tree widget. More... | |
void | CenterLibId (const LIB_ID &aLibId) |
Ensure that an item is visible (preferably centered). More... | |
void | Unselect () |
Unselect currently selected item in wxDataViewCtrl. More... | |
void | ExpandLibId (const LIB_ID &aLibId) |
Expand and item i the tree widget. More... | |
void | Regenerate (bool aKeepState) |
Regenerate the tree. More... | |
void | RefreshLibTree () |
Refreshes the tree (mainly to update highlighting and asterisking) More... | |
wxWindow * | GetFocusTarget () |
Protected Member Functions | |
void | toggleExpand (const wxDataViewItem &aTreeId) |
Expand or collapse a node, switching it to the opposite state. More... | |
void | selectIfValid (const wxDataViewItem &aTreeId) |
If a wxDataViewitem is valid, select it and post a selection event. More... | |
void | centerIfValid (const wxDataViewItem &aTreeId) |
void | expandIfValid (const wxDataViewItem &aTreeId) |
void | postPreselectEvent () |
Post a wxEVT_DATAVIEW_SELECTION_CHANGED to notify the selection handler that a new part has been preselected. More... | |
void | postSelectEvent () |
Post COMPONENT_SELECTED event to notify the selection handler that a part has been selected. More... | |
STATE | getState () const |
Return the component tree widget state. More... | |
void | setState (const STATE &aState) |
Restore the component tree widget state from an object. More... | |
void | onQueryText (wxCommandEvent &aEvent) |
void | onQueryEnter (wxCommandEvent &aEvent) |
void | onQueryCharHook (wxKeyEvent &aEvent) |
void | onTreeSelect (wxDataViewEvent &aEvent) |
void | onTreeActivate (wxDataViewEvent &aEvent) |
void | onDetailsLink (wxHtmlLinkEvent &aEvent) |
void | onPreselect (wxCommandEvent &aEvent) |
void | onContextMenu (wxDataViewEvent &aEvent) |
Protected Attributes | |
LIB_TABLE * | m_lib_table |
wxObjectDataPtr< LIB_TREE_MODEL_ADAPTER > | m_adapter |
wxTextCtrl * | m_query_ctrl |
wxDataViewCtrl * | m_tree_ctrl |
wxHtmlWindow * | m_details_ctrl |
LIB_ID | m_last_libid |
Widget displaying a tree of components with optional search text control and description panel.Custom event sent when a new component is preselected.
Definition at line 42 of file lib_tree.h.
enum LIB_TREE::WIDGETS |
< Flags to select extra widgets
Enumerator | |
---|---|
NONE | |
SEARCH | |
DETAILS | |
ALL |
Definition at line 46 of file lib_tree.h.
LIB_TREE::LIB_TREE | ( | wxWindow * | aParent, |
LIB_TABLE * | aLibTable, | ||
wxObjectDataPtr< LIB_TREE_MODEL_ADAPTER > & | aAdapter, | ||
WIDGETS | aWidgets = ALL , |
||
wxHtmlWindow * | aDetails = nullptr |
||
) |
Construct a component tree.
aParent | parent window containing this tree widget |
aLibTable | table containing libraries and items to display |
aAdapter | a LIB_TREE_MODEL_ADAPTER instance to use |
aWidgets | selection of sub-widgets to include |
aDetails | if not null, a custom wxHtmlWindow to hold symbol details. If null this will be created inside the LIB_TREE. |
Definition at line 35 of file lib_tree.cpp.
References _, DETAILS, m_adapter, m_details_ctrl, m_query_ctrl, m_tree_ctrl, onContextMenu(), onDetailsLink(), onPreselect(), onQueryCharHook(), onQueryEnter(), onQueryText(), onTreeActivate(), onTreeSelect(), postPreselectEvent(), Regenerate(), and SEARCH.
|
override |
|
protected |
void LIB_TREE::CenterLibId | ( | const LIB_ID & | aLibId | ) |
Ensure that an item is visible (preferably centered).
Definition at line 183 of file lib_tree.cpp.
References centerIfValid(), and m_adapter.
Referenced by SYMBOL_EDIT_FRAME::KiwayMailIn(), FOOTPRINT_EDIT_FRAME::RegenerateLibraryTree(), SYMBOL_EDIT_FRAME::RegenerateLibraryTree(), SYMBOL_EDIT_FRAME::SyncLibraries(), and FOOTPRINT_EDIT_FRAME::SyncLibraryTree().
|
protected |
void LIB_TREE::ExpandLibId | ( | const LIB_ID & | aLibId | ) |
Expand and item i the tree widget.
Definition at line 194 of file lib_tree.cpp.
References expandIfValid(), and m_adapter.
Referenced by SYMBOL_EDIT_FRAME::KiwayMailIn().
LIB_TREE_NODE * LIB_TREE::GetCurrentTreeNode | ( | ) | const |
Definition at line 166 of file lib_tree.cpp.
References m_adapter, and m_tree_ctrl.
Referenced by SYMBOL_EDIT_FRAME::GetCurrentTreeNode(), and FOOTPRINT_EDIT_FRAME::GetCurrentTreeNode().
wxWindow * LIB_TREE::GetFocusTarget | ( | ) |
Definition at line 224 of file lib_tree.cpp.
References m_query_ctrl, and m_tree_ctrl.
Referenced by DIALOG_CHOOSE_FOOTPRINT::DIALOG_CHOOSE_FOOTPRINT(), and DIALOG_CHOOSE_SYMBOL::DIALOG_CHOOSE_SYMBOL().
LIB_ID LIB_TREE::GetSelectedLibId | ( | int * | aUnit = nullptr | ) | const |
For multi-unit components, if the user selects the component itself rather than picking an individual unit, 0 will be returned in aUnit.
Beware that this is an invalid unit number - this should be replaced with whatever default is desired (usually 1).
aUnit | if not NULL, the selected unit is filled in here. |
Definition at line 148 of file lib_tree.cpp.
References m_adapter, and m_tree_ctrl.
Referenced by SYMBOL_EDIT_FRAME::CopyPartToClipboard(), SYMBOL_EDIT_FRAME::DuplicatePart(), DIALOG_CHOOSE_FOOTPRINT::GetSelectedLibId(), DIALOG_CHOOSE_SYMBOL::GetSelectedLibId(), getState(), FOOTPRINT_EDIT_FRAME::GetTreeFPID(), SYMBOL_EDIT_FRAME::GetTreeLIBID(), DIALOG_CHOOSE_FOOTPRINT::OnComponentPreselected(), DIALOG_CHOOSE_SYMBOL::OnComponentPreselected(), DIALOG_CHOOSE_FOOTPRINT::OnComponentSelected(), DIALOG_CHOOSE_SYMBOL::OnComponentSelected(), onPreselect(), onQueryEnter(), onTreeActivate(), SYMBOL_EDIT_FRAME::SyncLibraries(), and FOOTPRINT_EDIT_FRAME::SyncLibraryTree().
|
protected |
Return the component tree widget state.
Definition at line 284 of file lib_tree.cpp.
References LIB_TREE::STATE::expanded, GetSelectedLibId(), m_adapter, m_tree_ctrl, and LIB_TREE::STATE::selection.
Referenced by Regenerate().
|
protected |
Definition at line 433 of file lib_tree.cpp.
References TOOL_INTERACTIVE::Activate(), BUT_RIGHT, TOOL_MANAGER::DispatchContextMenu(), TOOL_BASE::GetManager(), TOOL_INTERACTIVE::GetToolMenu(), m_adapter, TOOL_MENU::ShowContextMenu(), TA_MOUSE_CLICK, TC_MOUSE, and TOOL_MANAGER::VetoContextMenuMouseWarp().
Referenced by LIB_TREE().
|
protected |
|
protected |
Definition at line 406 of file lib_tree.cpp.
References Format(), GetSelectedLibId(), m_adapter, and m_details_ctrl.
Referenced by LIB_TREE().
|
protected |
Definition at line 335 of file lib_tree.cpp.
References GetNextItem(), GetPrevItem(), LIB_TREE_NODE::INVALID, KI_FALLTHROUGH, LIB_TREE_NODE::LIB, m_adapter, m_tree_ctrl, selectIfValid(), and toggleExpand().
Referenced by LIB_TREE().
|
protected |
Definition at line 328 of file lib_tree.cpp.
References GetSelectedLibId(), and postSelectEvent().
Referenced by LIB_TREE().
|
protected |
Definition at line 318 of file lib_tree.cpp.
References Regenerate().
Referenced by LIB_TREE().
|
protected |
Definition at line 385 of file lib_tree.cpp.
References GetSelectedLibId(), m_tree_ctrl, postSelectEvent(), and toggleExpand().
Referenced by LIB_TREE().
|
protected |
Definition at line 378 of file lib_tree.cpp.
References m_tree_ctrl, and postPreselectEvent().
Referenced by LIB_TREE().
|
protected |
Post a wxEVT_DATAVIEW_SELECTION_CHANGED to notify the selection handler that a new part has been preselected.
Definition at line 270 of file lib_tree.cpp.
Referenced by LIB_TREE(), onTreeSelect(), Regenerate(), and selectIfValid().
|
protected |
Post COMPONENT_SELECTED event to notify the selection handler that a part has been selected.
Definition at line 277 of file lib_tree.cpp.
Referenced by onQueryEnter(), and onTreeActivate().
void LIB_TREE::RefreshLibTree | ( | ) |
Refreshes the tree (mainly to update highlighting and asterisking)
Definition at line 218 of file lib_tree.cpp.
References m_adapter.
Referenced by SYMBOL_EDIT_FRAME::DeletePartFromLibrary(), SYMBOL_TREE_PANE::onComponentSelected(), FOOTPRINT_EDIT_FRAME::OnModify(), SYMBOL_EDIT_FRAME::OnModify(), FOOTPRINT_EDIT_FRAME::RefreshLibraryTree(), SYMBOL_EDIT_FRAME::RefreshLibraryTree(), SYMBOL_EDIT_FRAME::Save(), SYMBOL_EDIT_FRAME::SaveAll(), SYMBOL_EDIT_FRAME::SaveLibraryAs(), and SYMBOL_EDIT_FRAME::SaveSymbolAs().
void LIB_TREE::Regenerate | ( | bool | aKeepState | ) |
Regenerate the tree.
Definition at line 200 of file lib_tree.cpp.
References filter, getState(), m_adapter, m_query_ctrl, postPreselectEvent(), and setState().
Referenced by LIB_TREE(), onQueryText(), FOOTPRINT_EDIT_FRAME::RegenerateLibraryTree(), SYMBOL_EDIT_FRAME::RegenerateLibraryTree(), SYMBOL_EDIT_FRAME::SyncLibraries(), and FOOTPRINT_EDIT_FRAME::SyncLibraryTree().
|
protected |
If a wxDataViewitem is valid, select it and post a selection event.
Definition at line 245 of file lib_tree.cpp.
References m_tree_ctrl, and postPreselectEvent().
Referenced by onQueryCharHook(), and SelectLibId().
void LIB_TREE::SelectLibId | ( | const LIB_ID & | aLibId | ) |
Select an item in the tree widget.
Definition at line 177 of file lib_tree.cpp.
References m_adapter, and selectIfValid().
Referenced by SYMBOL_EDIT_FRAME::DuplicatePart(), FOOTPRINT_EDIT_FRAME::FocusOnLibID(), SYMBOL_EDIT_FRAME::GetSymbolFromRedoList(), SYMBOL_EDIT_FRAME::GetSymbolFromUndoList(), SYMBOL_EDIT_FRAME::Revert(), SYMBOL_EDIT_FRAME::savePartAs(), SYMBOL_EDIT_FRAME::SetCurPart(), setState(), SYMBOL_EDIT_FRAME::SyncLibraries(), FOOTPRINT_EDIT_FRAME::SyncLibraryTree(), and SYMBOL_EDIT_FRAME::UpdateAfterSymbolProperties().
|
protected |
Restore the component tree widget state from an object.
Definition at line 302 of file lib_tree.cpp.
References UTF8::empty(), LIB_TREE::STATE::expanded, LIB_ID::GetLibItemName(), LIB_ID::GetLibNickname(), m_tree_ctrl, LIB_TREE::STATE::selection, and SelectLibId().
Referenced by Regenerate().
|
protected |
Expand or collapse a node, switching it to the opposite state.
Definition at line 233 of file lib_tree.cpp.
References m_tree_ctrl.
Referenced by onQueryCharHook(), and onTreeActivate().
void LIB_TREE::Unselect | ( | ) |
Unselect currently selected item in wxDataViewCtrl.
Definition at line 189 of file lib_tree.cpp.
References m_tree_ctrl.
Referenced by SYMBOL_EDIT_FRAME::emptyScreen(), FOOTPRINT_TREE_PANE::onComponentSelected(), SYMBOL_TREE_PANE::onComponentSelected(), FOOTPRINT_TREE_PANE::onUpdateUI(), SYMBOL_TREE_PANE::onUpdateUI(), SYMBOL_EDIT_FRAME::SetCurPart(), SYMBOL_EDIT_FRAME::SyncLibraries(), and FOOTPRINT_EDIT_FRAME::SyncLibraryTree().
|
protected |
Definition at line 172 of file lib_tree.h.
Referenced by CenterLibId(), ExpandLibId(), GetCurrentTreeNode(), GetSelectedLibId(), getState(), LIB_TREE(), onContextMenu(), onPreselect(), onQueryCharHook(), RefreshLibTree(), Regenerate(), SelectLibId(), and ~LIB_TREE().
|
protected |
Definition at line 176 of file lib_tree.h.
Referenced by LIB_TREE(), and onPreselect().
|
protected |
Definition at line 178 of file lib_tree.h.
|
protected |
Definition at line 170 of file lib_tree.h.
|
protected |
Definition at line 174 of file lib_tree.h.
Referenced by GetFocusTarget(), LIB_TREE(), and Regenerate().
|
protected |
Definition at line 175 of file lib_tree.h.
Referenced by centerIfValid(), expandIfValid(), GetCurrentTreeNode(), GetFocusTarget(), GetSelectedLibId(), getState(), LIB_TREE(), onQueryCharHook(), onTreeActivate(), onTreeSelect(), selectIfValid(), setState(), toggleExpand(), and Unselect().