KiCad PCB EDA Suite
Loading...
Searching...
No Matches
LIB_TREE Class Reference

Widget displaying a tree of symbols with optional search text control and description panel. More...

#include <lib_tree.h>

Inheritance diagram for LIB_TREE:

Classes

struct  STATE
 Structure storing state of the symbol tree widget. More...
 

Public Types

enum  FLAGS {
  FLAGS_NONE = 0x00 , SEARCH = 0x01 , FILTERS = 0x02 , DETAILS = 0x04 ,
  ALL_WIDGETS = 0x0F , MULTISELECT = 0x10
}
 < Flags to select extra widgets and options More...
 

Public Member Functions

 LIB_TREE (wxWindow *aParent, const wxString &aRecentSearchesKey, LIB_TABLE *aLibTable, wxObjectDataPtr< LIB_TREE_MODEL_ADAPTER > &aAdapter, int aFlags=ALL_WIDGETS, HTML_WINDOW *aDetails=nullptr)
 Construct a symbol tree.
 
 ~LIB_TREE () override
 
LIB_ID GetSelectedLibId (int *aUnit=nullptr) const
 For multi-unit symbols, if the user selects the symbol itself rather than picking an individual unit, 0 will be returned in aUnit.
 
int GetSelectionCount () const
 
int GetSelectedLibIds (std::vector< LIB_ID > &aSelection, std::vector< int > *aUnit=nullptr) const
 Retrieve a list of selections for trees that allow multi-selection.
 
LIB_TREE_NODEGetCurrentTreeNode () const
 Retrieve the tree node for the first selected item.
 
int GetSelectedTreeNodes (std::vector< LIB_TREE_NODE * > &aSelection) const
 Retrieve a list of pointers to selected tree nodes for trees that allow multi-selection.
 
void SelectLibId (const LIB_ID &aLibId)
 Select an item in the tree widget.
 
void CenterLibId (const LIB_ID &aLibId)
 Ensure that an item is visible (preferably centered).
 
void Unselect ()
 Unselect currently selected item in wxDataViewCtrl.
 
void ExpandLibId (const LIB_ID &aLibId)
 Expand and item i the tree widget.
 
void ExpandAll ()
 
void CollapseAll ()
 
void SetSearchString (const wxString &aSearchString)
 Save/restore search string.
 
wxString GetSearchString () const
 
void SetSortMode (LIB_TREE_MODEL_ADAPTER::SORT_MODE aMode)
 Save/restore the sorting mode.
 
LIB_TREE_MODEL_ADAPTER::SORT_MODE GetSortMode () const
 
void Regenerate (bool aKeepState)
 Regenerate the tree.
 
void RefreshLibTree ()
 Refresh the tree (mainly to update highlighting and asterisking)
 
wxWindow * GetFocusTarget ()
 
wxSizer * GetFiltersSizer ()
 
void FocusSearchFieldIfExists ()
 Focus the search widget if it exists.
 
void ShowChangedLanguage ()
 
void BlockPreview (bool aBlock)
 
void ShutdownPreviews ()
 

Protected Member Functions

void toggleExpand (const wxDataViewItem &aTreeId)
 Expand or collapse a node, switching it to the opposite state.
 
void selectIfValid (const wxDataViewItem &aTreeId)
 If a wxDataViewitem is valid, select it and post a selection event.
 
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.
 
void postSelectEvent ()
 Post #SYMBOL_SELECTED event to notify the selection handler that a part has been selected.
 
STATE getState () const
 Return the symbol tree widget state.
 
void setState (const STATE &aState)
 Restore the symbol tree widget state from an object.
 
void updateRecentSearchMenu ()
 
void showPreview (wxDataViewItem aItem)
 
void hidePreview ()
 
void onQueryText (wxCommandEvent &aEvent)
 
void onQueryCharHook (wxKeyEvent &aEvent)
 
void onQueryMouseMoved (wxMouseEvent &aEvent)
 
void onTreeSelect (wxDataViewEvent &aEvent)
 
void onTreeActivate (wxDataViewEvent &aEvent)
 
void onTreeCharHook (wxKeyEvent &aEvent)
 
void onIdle (wxIdleEvent &aEvent)
 
void onHoverTimer (wxTimerEvent &aEvent)
 
void onDetailsLink (wxHtmlLinkEvent &aEvent)
 
void onPreselect (wxCommandEvent &aEvent)
 
void onItemContextMenu (wxDataViewEvent &aEvent)
 
void onHeaderContextMenu (wxDataViewEvent &aEvent)
 
void onDebounceTimer (wxTimerEvent &aEvent)
 

Protected Attributes

wxObjectDataPtr< LIB_TREE_MODEL_ADAPTERm_adapter
 
wxSearchCtrl * m_query_ctrl
 
BITMAP_BUTTONm_sort_ctrl
 
WX_DATAVIEWCTRLm_tree_ctrl
 
HTML_WINDOWm_details_ctrl
 
wxTimer * m_debounceTimer
 
bool m_inTimerEvent
 
wxString m_recentSearchesKey
 
wxBoxSizer * m_filtersSizer
 
bool m_skipNextRightClick
 
wxPoint m_hoverPos
 
wxDataViewItem m_hoverItem
 
wxRect m_hoverItemRect
 
wxTimer m_hoverTimer
 
wxDataViewItem m_previewItem
 
wxRect m_previewItemRect
 
wxPopupWindow * m_previewWindow
 
bool m_previewDisabled
 

Detailed Description

Widget displaying a tree of symbols with optional search text control and description panel.

Definition at line 48 of file lib_tree.h.

Member Enumeration Documentation

◆ FLAGS

< Flags to select extra widgets and options

Enumerator
FLAGS_NONE 
SEARCH 
FILTERS 
DETAILS 
ALL_WIDGETS 
MULTISELECT 

Definition at line 52 of file lib_tree.h.

Constructor & Destructor Documentation

◆ LIB_TREE()

LIB_TREE::LIB_TREE ( wxWindow * aParent,
const wxString & aRecentSearchesKey,
LIB_TABLE * aLibTable,
wxObjectDataPtr< LIB_TREE_MODEL_ADAPTER > & aAdapter,
int aFlags = ALL_WIDGETS,
HTML_WINDOW * aDetails = nullptr )

Construct a symbol tree.

Parameters
aParentparent window containing this tree widget.
aRecentSearchesKeya key into a global map storing recent searches (usually "power", "symbols", or "footprints", but could be further differentiated).
aLibTabletable containing libraries and items to display.
aAdaptera LIB_TREE_MODEL_ADAPTER instance to use.
aFlagsselection of sub-widgets to include and other options.
aDetailsif not null, a custom HTML_WINDOW to hold symbol details. If null this will be created inside the LIB_TREE.

Definition at line 53 of file lib_tree.cpp.

References _, LIB_TREE_MODEL_ADAPTER::ALPHABETIC, LIB_TREE_MODEL_ADAPTER::BEST_MATCH, CollapseAll(), ACTIONS::collapseAll, config, DETAILS, ExpandAll(), ACTIONS::expandAll, FILTERS, g_recentSearches, KiBitmapBundle(), m_adapter, m_debounceTimer, m_details_ctrl, m_filtersSizer, m_hoverTimer, m_inTimerEvent, m_previewDisabled, m_previewWindow, m_query_ctrl, m_recentSearchesKey, m_skipNextRightClick, m_sort_ctrl, m_tree_ctrl, MULTISELECT, onDebounceTimer(), onDetailsLink(), onHeaderContextMenu(), onHoverTimer(), onIdle(), onItemContextMenu(), onPreselect(), onQueryCharHook(), onQueryMouseMoved(), onQueryText(), onTreeActivate(), onTreeCharHook(), onTreeSelect(), postPreselectEvent(), RECENT_SEARCHES_MAX, Regenerate(), SEARCH, and updateRecentSearchMenu().

◆ ~LIB_TREE()

Member Function Documentation

◆ BlockPreview()

void LIB_TREE::BlockPreview ( bool aBlock)
inline

Definition at line 178 of file lib_tree.h.

References m_previewDisabled.

◆ centerIfValid()

void LIB_TREE::centerIfValid ( const wxDataViewItem & aTreeId)
protected

Definition at line 518 of file lib_tree.cpp.

References m_adapter, LIB_TREE_NODE::m_Parent, and m_tree_ctrl.

Referenced by CenterLibId().

◆ CenterLibId()

void LIB_TREE::CenterLibId ( const LIB_ID & aLibId)

Ensure that an item is visible (preferably centered).

Definition at line 381 of file lib_tree.cpp.

References centerIfValid(), and m_adapter.

Referenced by SYMBOL_EDIT_FRAME::KiwayMailIn(), LIBRARY_EDITOR_CONTROL::regenerateLibraryTree(), SYMBOL_EDIT_FRAME::SyncLibraries(), and FOOTPRINT_EDIT_FRAME::SyncLibraryTree().

◆ CollapseAll()

void LIB_TREE::CollapseAll ( )

Definition at line 407 of file lib_tree.cpp.

References m_tree_ctrl.

Referenced by LIB_TREE().

◆ ExpandAll()

void LIB_TREE::ExpandAll ( )

Definition at line 401 of file lib_tree.cpp.

References m_tree_ctrl.

Referenced by LIB_TREE().

◆ expandIfValid()

void LIB_TREE::expandIfValid ( const wxDataViewItem & aTreeId)
protected

Definition at line 566 of file lib_tree.cpp.

References m_tree_ctrl.

Referenced by ExpandLibId().

◆ ExpandLibId()

void LIB_TREE::ExpandLibId ( const LIB_ID & aLibId)

Expand and item i the tree widget.

Definition at line 395 of file lib_tree.cpp.

References expandIfValid(), and m_adapter.

Referenced by SYMBOL_EDIT_FRAME::KiwayMailIn().

◆ FocusSearchFieldIfExists()

void LIB_TREE::FocusSearchFieldIfExists ( )

Focus the search widget if it exists.

Definition at line 487 of file lib_tree.cpp.

References m_query_ctrl.

Referenced by SYMBOL_EDIT_FRAME::FocusLibraryTreeInput().

◆ GetCurrentTreeNode()

LIB_TREE_NODE * LIB_TREE::GetCurrentTreeNode ( ) const

Retrieve the tree node for the first selected item.

Returns
the tree node for the first selected item.

Definition at line 351 of file lib_tree.cpp.

References m_adapter, and m_tree_ctrl.

Referenced by DESIGN_BLOCK_CONTROL::getCurrentTreeNode(), and onItemContextMenu().

◆ GetFiltersSizer()

wxSizer * LIB_TREE::GetFiltersSizer ( )
inline

Definition at line 169 of file lib_tree.h.

References m_filtersSizer.

◆ GetFocusTarget()

wxWindow * LIB_TREE::GetFocusTarget ( )

Definition at line 478 of file lib_tree.cpp.

References m_query_ctrl, and m_tree_ctrl.

◆ GetSearchString()

wxString LIB_TREE::GetSearchString ( ) const

Definition at line 419 of file lib_tree.cpp.

References m_query_ctrl.

Referenced by updateRecentSearchMenu().

◆ GetSelectedLibId()

LIB_ID LIB_TREE::GetSelectedLibId ( int * aUnit = nullptr) const

For multi-unit symbols, if the user selects the symbol 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).

Parameters
aUnitif not NULL, the selected unit is filled in here.
Returns
the library id of the symbol that has been selected.

Definition at line 314 of file lib_tree.cpp.

References m_adapter, and m_tree_ctrl.

Referenced by getState(), FOOTPRINT_EDIT_FRAME::GetTargetFPID(), SYMBOL_EDIT_FRAME::GetTreeLIBID(), onPreselect(), onQueryCharHook(), onTreeActivate(), SYMBOL_EDIT_FRAME::SyncLibraries(), and FOOTPRINT_EDIT_FRAME::SyncLibraryTree().

◆ GetSelectedLibIds()

int LIB_TREE::GetSelectedLibIds ( std::vector< LIB_ID > & aSelection,
std::vector< int > * aUnit = nullptr ) const

Retrieve a list of selections for trees that allow multi-selection.

See also
GetSelectedLibId for details on how aUnit will be filled.
Parameters
aSelectionwill be filled with a list of selected LIB_IDs.
aUnitis an optional pointer to a list to fill with unit numbers.
Returns
the number of selected items.

Definition at line 334 of file lib_tree.cpp.

References m_adapter, and m_tree_ctrl.

Referenced by SYMBOL_EDIT_FRAME::GetTreeLIBIDs().

◆ GetSelectedTreeNodes()

int LIB_TREE::GetSelectedTreeNodes ( std::vector< LIB_TREE_NODE * > & aSelection) const

Retrieve a list of pointers to selected tree nodes for trees that allow multi-selection.

Parameters
aSelectionwill be filled with a list of pointers of selected tree nodes.
Returns
the number of selected items.

Definition at line 361 of file lib_tree.cpp.

References m_adapter, and m_tree_ctrl.

Referenced by LIBRARY_EDITOR_CONTROL::AddContextMenuItems(), and LIBRARY_EDITOR_CONTROL::changeSelectedPinStatus().

◆ GetSelectionCount()

int LIB_TREE::GetSelectionCount ( ) const
inline

Definition at line 91 of file lib_tree.h.

References m_tree_ctrl.

Referenced by SYMBOL_EDIT_FRAME::GetTreeSelectionCount().

◆ GetSortMode()

LIB_TREE_MODEL_ADAPTER::SORT_MODE LIB_TREE::GetSortMode ( ) const
inline

Definition at line 155 of file lib_tree.h.

References m_adapter.

Referenced by FOOTPRINT_EDIT_FRAME::SaveSettings(), and SYMBOL_EDIT_FRAME::SaveSettings().

◆ getState()

LIB_TREE::STATE LIB_TREE::getState ( ) const
protected

Return the symbol tree widget state.

Definition at line 587 of file lib_tree.cpp.

References LIB_TREE::STATE::expanded, GetSelectedLibId(), m_adapter, m_tree_ctrl, and LIB_TREE::STATE::selection.

Referenced by Regenerate().

◆ hidePreview()

void LIB_TREE::hidePreview ( )
protected

◆ onDebounceTimer()

void LIB_TREE::onDebounceTimer ( wxTimerEvent & aEvent)
protected

Definition at line 631 of file lib_tree.cpp.

References m_inTimerEvent, and Regenerate().

Referenced by LIB_TREE(), and ~LIB_TREE().

◆ onDetailsLink()

void LIB_TREE::onDetailsLink ( wxHtmlLinkEvent & aEvent)
protected

◆ onHeaderContextMenu()

void LIB_TREE::onHeaderContextMenu ( wxDataViewEvent & aEvent)
protected

◆ onHoverTimer()

void LIB_TREE::onHoverTimer ( wxTimerEvent & aEvent)
protected

◆ onIdle()

void LIB_TREE::onIdle ( wxIdleEvent & aEvent)
protected

◆ onItemContextMenu()

◆ onPreselect()

void LIB_TREE::onPreselect ( wxCommandEvent & aEvent)
protected

Definition at line 953 of file lib_tree.cpp.

References GetSelectedLibId(), hidePreview(), m_adapter, and m_details_ctrl.

Referenced by LIB_TREE(), and ~LIB_TREE().

◆ onQueryCharHook()

void LIB_TREE::onQueryCharHook ( wxKeyEvent & aEvent)
protected

◆ onQueryMouseMoved()

void LIB_TREE::onQueryMouseMoved ( wxMouseEvent & aEvent)
protected

Definition at line 740 of file lib_tree.cpp.

References m_query_ctrl.

Referenced by LIB_TREE(), and ~LIB_TREE().

◆ onQueryText()

void LIB_TREE::onQueryText ( wxCommandEvent & aEvent)
protected

Definition at line 621 of file lib_tree.cpp.

References m_debounceTimer.

Referenced by LIB_TREE(), and ~LIB_TREE().

◆ onTreeActivate()

void LIB_TREE::onTreeActivate ( wxDataViewEvent & aEvent)
protected

◆ onTreeCharHook()

void LIB_TREE::onTreeCharHook ( wxKeyEvent & aEvent)
protected

Definition at line 874 of file lib_tree.cpp.

References m_adapter, MD_ALT, MD_ALTGR, MD_CTRL, MD_META, MD_SHIFT, MD_SUPER, and onQueryCharHook().

Referenced by LIB_TREE(), and ~LIB_TREE().

◆ onTreeSelect()

void LIB_TREE::onTreeSelect ( wxDataViewEvent & aEvent)
protected

Definition at line 917 of file lib_tree.cpp.

References m_inTimerEvent, m_tree_ctrl, postPreselectEvent(), and updateRecentSearchMenu().

Referenced by LIB_TREE(), and ~LIB_TREE().

◆ postPreselectEvent()

void LIB_TREE::postPreselectEvent ( )
protected

Post a wxEVT_DATAVIEW_SELECTION_CHANGED to notify the selection handler that a new part has been preselected.

Definition at line 573 of file lib_tree.cpp.

Referenced by LIB_TREE(), onTreeSelect(), Regenerate(), and selectIfValid().

◆ postSelectEvent()

void LIB_TREE::postSelectEvent ( )
protected

Post #SYMBOL_SELECTED event to notify the selection handler that a part has been selected.

Definition at line 580 of file lib_tree.cpp.

Referenced by onQueryCharHook(), and onTreeActivate().

◆ RefreshLibTree()

void LIB_TREE::RefreshLibTree ( )

Refresh the tree (mainly to update highlighting and asterisking)

Definition at line 472 of file lib_tree.cpp.

References m_adapter.

Referenced by FOOTPRINT_EDIT_FRAME::OnModify(), SYMBOL_EDIT_FRAME::OnModify(), FOOTPRINT_EDIT_FRAME::RefreshLibraryTree(), SYMBOL_EDIT_FRAME::RefreshLibraryTree(), and SYMBOL_EDIT_FRAME::UpdateLibraryTree().

◆ Regenerate()

◆ selectIfValid()

void LIB_TREE::selectIfValid ( const wxDataViewItem & aTreeId)
protected

If a wxDataViewitem is valid, select it and post a selection event.

Definition at line 506 of file lib_tree.cpp.

References m_tree_ctrl, and postPreselectEvent().

Referenced by onQueryCharHook(), and SelectLibId().

◆ SelectLibId()

◆ SetSearchString()

void LIB_TREE::SetSearchString ( const wxString & aSearchString)

Save/restore search string.

Definition at line 413 of file lib_tree.cpp.

References m_query_ctrl.

◆ SetSortMode()

void LIB_TREE::SetSortMode ( LIB_TREE_MODEL_ADAPTER::SORT_MODE aMode)
inline

Save/restore the sorting mode.

Definition at line 154 of file lib_tree.h.

References m_adapter.

Referenced by FOOTPRINT_EDIT_FRAME::LoadSettings().

◆ setState()

void LIB_TREE::setState ( const STATE & aState)
protected

Restore the symbol tree widget state from an object.

Definition at line 605 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().

◆ ShowChangedLanguage()

void LIB_TREE::ShowChangedLanguage ( )

◆ showPreview()

void LIB_TREE::showPreview ( wxDataViewItem aItem)
protected

Definition at line 761 of file lib_tree.cpp.

References m_adapter, m_previewItem, m_previewItemRect, m_previewWindow, m_tree_ctrl, and PREVIEW_SIZE.

Referenced by onHoverTimer(), and onIdle().

◆ ShutdownPreviews()

void LIB_TREE::ShutdownPreviews ( )

◆ toggleExpand()

void LIB_TREE::toggleExpand ( const wxDataViewItem & aTreeId)
protected

Expand or collapse a node, switching it to the opposite state.

Definition at line 494 of file lib_tree.cpp.

References m_tree_ctrl.

Referenced by onQueryCharHook(), and onTreeActivate().

◆ Unselect()

void LIB_TREE::Unselect ( )

Unselect currently selected item in wxDataViewCtrl.

Definition at line 387 of file lib_tree.cpp.

References m_tree_ctrl.

Referenced by SYMBOL_EDIT_FRAME::emptyScreen(), SYMBOL_EDIT_FRAME::SetCurSymbol(), SYMBOL_EDIT_FRAME::SyncLibraries(), and FOOTPRINT_EDIT_FRAME::SyncLibraryTree().

◆ updateRecentSearchMenu()

void LIB_TREE::updateRecentSearchMenu ( )
protected

Member Data Documentation

◆ m_adapter

◆ m_debounceTimer

wxTimer* LIB_TREE::m_debounceTimer
protected

Definition at line 263 of file lib_tree.h.

Referenced by LIB_TREE(), onQueryText(), and ~LIB_TREE().

◆ m_details_ctrl

HTML_WINDOW* LIB_TREE::m_details_ctrl
protected

Definition at line 262 of file lib_tree.h.

Referenced by LIB_TREE(), onPreselect(), and ~LIB_TREE().

◆ m_filtersSizer

wxBoxSizer* LIB_TREE::m_filtersSizer
protected

Definition at line 268 of file lib_tree.h.

Referenced by GetFiltersSizer(), and LIB_TREE().

◆ m_hoverItem

wxDataViewItem LIB_TREE::m_hoverItem
protected

Definition at line 273 of file lib_tree.h.

Referenced by onHoverTimer(), and onIdle().

◆ m_hoverItemRect

wxRect LIB_TREE::m_hoverItemRect
protected

Definition at line 274 of file lib_tree.h.

Referenced by onHoverTimer(), and onIdle().

◆ m_hoverPos

wxPoint LIB_TREE::m_hoverPos
protected

Definition at line 272 of file lib_tree.h.

Referenced by onHoverTimer(), and onIdle().

◆ m_hoverTimer

wxTimer LIB_TREE::m_hoverTimer
protected

Definition at line 275 of file lib_tree.h.

Referenced by LIB_TREE(), onHoverTimer(), onIdle(), ShutdownPreviews(), and ~LIB_TREE().

◆ m_inTimerEvent

bool LIB_TREE::m_inTimerEvent
protected

Definition at line 264 of file lib_tree.h.

Referenced by LIB_TREE(), onDebounceTimer(), onTreeActivate(), and onTreeSelect().

◆ m_previewDisabled

bool LIB_TREE::m_previewDisabled
protected

◆ m_previewItem

wxDataViewItem LIB_TREE::m_previewItem
protected

Definition at line 276 of file lib_tree.h.

Referenced by hidePreview(), onIdle(), and showPreview().

◆ m_previewItemRect

wxRect LIB_TREE::m_previewItemRect
protected

Definition at line 277 of file lib_tree.h.

Referenced by showPreview().

◆ m_previewWindow

wxPopupWindow* LIB_TREE::m_previewWindow
protected

Definition at line 278 of file lib_tree.h.

Referenced by hidePreview(), LIB_TREE(), showPreview(), and ShutdownPreviews().

◆ m_query_ctrl

◆ m_recentSearchesKey

wxString LIB_TREE::m_recentSearchesKey
protected

Definition at line 266 of file lib_tree.h.

Referenced by LIB_TREE(), and updateRecentSearchMenu().

◆ m_skipNextRightClick

bool LIB_TREE::m_skipNextRightClick
protected

Definition at line 270 of file lib_tree.h.

Referenced by LIB_TREE(), and onItemContextMenu().

◆ m_sort_ctrl

BITMAP_BUTTON* LIB_TREE::m_sort_ctrl
protected

Definition at line 260 of file lib_tree.h.

Referenced by LIB_TREE().

◆ m_tree_ctrl


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