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.Custom event sent when an item is selected in the list. 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
 Retrieves a list of selections for trees that allow multi-selection.
 
LIB_TREE_NODEGetCurrentTreeNode () const
 
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 ()
 Refreshes the tree (mainly to update highlighting and asterisking)
 
wxWindow * GetFocusTarget ()
 
wxSizer * GetFiltersSizer ()
 
void FocusSearchFieldIfExists ()
 Focus the search widget if it exists.
 
void ShowChangedLanguage ()
 

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 destroyPreview ()
 
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
 
STD_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.Custom event sent when an item is selected in the list.

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 51 of file lib_tree.cpp.

References _, LIB_TREE_MODEL_ADAPTER::BEST_MATCH, ACTIONS::collapseAll, DETAILS, ACTIONS::expandAll, FILTERS, g_recentSearches, KiBitmapBundle(), m_adapter, m_debounceTimer, m_details_ctrl, m_filtersSizer, m_hoverTimer, m_query_ctrl, m_recentSearchesKey, 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, STD_BITMAP_BUTTON::SetBitmap(), and updateRecentSearchMenu().

◆ ~LIB_TREE()

Member Function Documentation

◆ centerIfValid()

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

Definition at line 486 of file lib_tree.cpp.

References m_adapter, LIB_TREE_NODE::m_Parent, and m_tree_ctrl.

Referenced by CenterLibId().

◆ CenterLibId()

◆ CollapseAll()

void LIB_TREE::CollapseAll ( )

Definition at line 375 of file lib_tree.cpp.

References WX_DATAVIEWCTRL::CollapseAll(), and m_tree_ctrl.

◆ destroyPreview()

void LIB_TREE::destroyPreview ( )
protected

Definition at line 740 of file lib_tree.cpp.

References hidePreview(), and m_previewWindow.

Referenced by ~LIB_TREE().

◆ ExpandAll()

void LIB_TREE::ExpandAll ( )

Definition at line 369 of file lib_tree.cpp.

References WX_DATAVIEWCTRL::ExpandAll(), and m_tree_ctrl.

◆ expandIfValid()

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

Definition at line 534 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 363 of file lib_tree.cpp.

References expandIfValid(), and m_adapter.

Referenced by SYMBOL_EDIT_FRAME::KiwayMailIn(), FOOTPRINT_EDIT_FRAME::LoadFootprintFromLibrary(), and SYMBOL_EDIT_FRAME::LoadSymbol().

◆ FocusSearchFieldIfExists()

void LIB_TREE::FocusSearchFieldIfExists ( )

Focus the search widget if it exists.

Definition at line 455 of file lib_tree.cpp.

References m_query_ctrl.

Referenced by SYMBOL_EDIT_FRAME::FocusLibraryTreeInput(), and FOOTPRINT_TREE_PANE::FocusSearchFieldIfExists().

◆ GetCurrentTreeNode()

◆ GetFiltersSizer()

wxSizer * LIB_TREE::GetFiltersSizer ( )
inline

Definition at line 155 of file lib_tree.h.

References m_filtersSizer.

Referenced by PANEL_FOOTPRINT_CHOOSER::GetFiltersSizer().

◆ GetFocusTarget()

wxWindow * LIB_TREE::GetFocusTarget ( )

◆ GetSearchString()

◆ GetSelectedLibId()

◆ GetSelectedLibIds()

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

Retrieves 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 315 of file lib_tree.cpp.

References m_adapter, and m_tree_ctrl.

Referenced by SYMBOL_EDIT_FRAME::GetTreeLIBIDs().

◆ 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()

◆ getState()

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

Return the symbol tree widget state.

Definition at line 555 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 599 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 897 of file lib_tree.cpp.

References GetSelectedLibId(), hidePreview(), m_adapter, m_details_ctrl, and HTML_WINDOW::SetPage().

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

◆ onQueryCharHook()

◆ onQueryMouseMoved()

void LIB_TREE::onQueryMouseMoved ( wxMouseEvent &  aEvent)
protected

Definition at line 686 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 589 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 835 of file lib_tree.cpp.

References m_adapter, MD_ALT, MD_CTRL, MD_SHIFT, and onQueryCharHook().

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

◆ onTreeSelect()

void LIB_TREE::onTreeSelect ( wxDataViewEvent &  aEvent)
protected

Definition at line 861 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 541 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 548 of file lib_tree.cpp.

Referenced by onQueryCharHook(), and onTreeActivate().

◆ RefreshLibTree()

◆ 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 474 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)

◆ SetSortMode()

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

Save/restore the sorting mode.

Definition at line 140 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 573 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 707 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().

◆ toggleExpand()

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

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

Definition at line 462 of file lib_tree.cpp.

References m_tree_ctrl.

Referenced by onQueryCharHook(), and onTreeActivate().

◆ Unselect()

◆ updateRecentSearchMenu()

void LIB_TREE::updateRecentSearchMenu ( )
protected

Member Data Documentation

◆ m_adapter

◆ m_debounceTimer

wxTimer* LIB_TREE::m_debounceTimer
protected

Definition at line 243 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 242 of file lib_tree.h.

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

◆ m_filtersSizer

wxBoxSizer* LIB_TREE::m_filtersSizer
protected

Definition at line 248 of file lib_tree.h.

Referenced by GetFiltersSizer(), and LIB_TREE().

◆ m_hoverItem

wxDataViewItem LIB_TREE::m_hoverItem
protected

Definition at line 253 of file lib_tree.h.

Referenced by onHoverTimer(), and onIdle().

◆ m_hoverItemRect

wxRect LIB_TREE::m_hoverItemRect
protected

Definition at line 254 of file lib_tree.h.

Referenced by onHoverTimer(), and onIdle().

◆ m_hoverPos

wxPoint LIB_TREE::m_hoverPos
protected

Definition at line 252 of file lib_tree.h.

Referenced by onHoverTimer(), and onIdle().

◆ m_hoverTimer

wxTimer LIB_TREE::m_hoverTimer
protected

Definition at line 255 of file lib_tree.h.

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

◆ m_inTimerEvent

bool LIB_TREE::m_inTimerEvent
protected

Definition at line 244 of file lib_tree.h.

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

◆ m_previewDisabled

bool LIB_TREE::m_previewDisabled
protected

Definition at line 259 of file lib_tree.h.

Referenced by onHeaderContextMenu(), onHoverTimer(), onIdle(), and onItemContextMenu().

◆ m_previewItem

wxDataViewItem LIB_TREE::m_previewItem
protected

Definition at line 256 of file lib_tree.h.

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

◆ m_previewItemRect

wxRect LIB_TREE::m_previewItemRect
protected

Definition at line 257 of file lib_tree.h.

Referenced by showPreview().

◆ m_previewWindow

wxPopupWindow* LIB_TREE::m_previewWindow
protected

Definition at line 258 of file lib_tree.h.

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

◆ m_query_ctrl

◆ m_recentSearchesKey

wxString LIB_TREE::m_recentSearchesKey
protected

Definition at line 246 of file lib_tree.h.

Referenced by LIB_TREE(), and updateRecentSearchMenu().

◆ m_skipNextRightClick

bool LIB_TREE::m_skipNextRightClick
protected

Definition at line 250 of file lib_tree.h.

Referenced by onItemContextMenu().

◆ m_sort_ctrl

STD_BITMAP_BUTTON* LIB_TREE::m_sort_ctrl
protected

Definition at line 240 of file lib_tree.h.

Referenced by LIB_TREE().

◆ m_tree_ctrl


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