KiCad PCB EDA Suite
|
Widget displaying a tree of symbols with optional search text control and description panel.Custom event sent when a new symbol is preselected. More...
#include <lib_tree.h>
Classes | |
struct | STATE |
Structure storing state of the symbol tree widget. More... | |
Public Types | |
enum | FLAGS { NONE = 0x00 , SEARCH = 0x01 , DETAILS = 0x02 , 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. More... | |
~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. More... | |
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. 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 | SetSearchString (const wxString &aSearchString) |
Save/restore search string. More... | |
wxString | GetSearchString () const |
void | Regenerate (bool aKeepState) |
Regenerate the tree. More... | |
void | RefreshLibTree () |
Refreshes the tree (mainly to update highlighting and asterisking) More... | |
wxWindow * | GetFocusTarget () |
void | FocusSearchFieldIfExists () |
Focus the search widget if it exists. More... | |
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 SYMBOL_SELECTED event to notify the selection handler that a part has been selected. More... | |
STATE | getState () const |
Return the symbol tree widget state. More... | |
void | setState (const STATE &aState) |
Restore the symbol tree widget state from an object. More... | |
void | updateRecentSearchMenu () |
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 | onSize (wxSizeEvent &aEvent) |
void | onDetailsLink (wxHtmlLinkEvent &aEvent) |
void | onPreselect (wxCommandEvent &aEvent) |
void | onItemContextMenu (wxDataViewEvent &aEvent) |
void | onHeaderContextMenu (wxDataViewEvent &aEvent) |
void | onDebounceTimer (wxTimerEvent &aEvent) |
Protected Attributes | |
LIB_TABLE * | m_lib_table |
wxObjectDataPtr< LIB_TREE_MODEL_ADAPTER > | m_adapter |
wxSearchCtrl * | m_query_ctrl |
wxDataViewCtrl * | m_tree_ctrl |
HTML_WINDOW * | m_details_ctrl |
wxTimer * | m_debounceTimer |
bool | m_inTimerEvent |
LIB_ID | m_last_libid |
wxString | m_recentSearchesKey |
bool | m_skipNextRightClick |
Widget displaying a tree of symbols with optional search text control and description panel.Custom event sent when a new symbol is preselected.
Definition at line 45 of file lib_tree.h.
enum LIB_TREE::FLAGS |
< Flags to select extra widgets and options
Enumerator | |
---|---|
NONE | |
SEARCH | |
DETAILS | |
ALL_WIDGETS | |
MULTISELECT |
Definition at line 49 of file lib_tree.h.
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.
aParent | parent window containing this tree widget |
aRecentSearchesKey | a key into a global map storing recent searches (usually "power", "symbols", or "footprints", but could be further differentiated) |
aLibTable | table containing libraries and items to display |
aAdapter | a LIB_TREE_MODEL_ADAPTER instance to use |
aFlags | selection of sub-widgets to include and other options |
aDetails | if not null, a custom HTML_WINDOW to hold symbol details. If null this will be created inside the LIB_TREE. |
Definition at line 44 of file lib_tree.cpp.
References _, DETAILS, g_recentSearches, m_adapter, m_debounceTimer, m_details_ctrl, m_query_ctrl, m_recentSearchesKey, m_tree_ctrl, MULTISELECT, onDebounceTimer(), onDetailsLink(), onHeaderContextMenu(), onItemContextMenu(), onPreselect(), onQueryCharHook(), onQueryMouseMoved(), onQueryText(), onSize(), onTreeActivate(), onTreeCharHook(), onTreeSelect(), postPreselectEvent(), RECENT_SEARCHES_MAX, Regenerate(), SEARCH, and updateRecentSearchMenu().
|
override |
Definition at line 181 of file lib_tree.cpp.
References m_debounceTimer.
|
protected |
Definition at line 361 of file lib_tree.cpp.
References m_adapter, LIB_TREE_NODE::m_Parent, and m_tree_ctrl.
Referenced by CenterLibId().
void LIB_TREE::CenterLibId | ( | const LIB_ID & | aLibId | ) |
Ensure that an item is visible (preferably centered).
Definition at line 236 of file lib_tree.cpp.
References centerIfValid(), and m_adapter.
Referenced by SYMBOL_EDIT_FRAME::centerItemIdleHandler(), FOOTPRINT_EDIT_FRAME::centerItemIdleHandler(), SYMBOL_EDIT_FRAME::KiwayMailIn(), SYMBOL_EDIT_FRAME::RegenerateLibraryTree(), FOOTPRINT_EDIT_FRAME::RegenerateLibraryTree(), SYMBOL_EDIT_FRAME::SyncLibraries(), and FOOTPRINT_EDIT_FRAME::SyncLibraryTree().
|
protected |
Definition at line 409 of file lib_tree.cpp.
References m_tree_ctrl.
Referenced by ExpandLibId().
void LIB_TREE::ExpandLibId | ( | const LIB_ID & | aLibId | ) |
Expand and item i the tree widget.
Definition at line 248 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().
void LIB_TREE::FocusSearchFieldIfExists | ( | ) |
Focus the search widget if it exists.
Definition at line 328 of file lib_tree.cpp.
References m_query_ctrl.
Referenced by FOOTPRINT_TREE_PANE::FocusSearchFieldIfExists().
LIB_TREE_NODE * LIB_TREE::GetCurrentTreeNode | ( | ) | const |
Definition at line 219 of file lib_tree.cpp.
References m_adapter, and m_tree_ctrl.
Referenced by SYMBOL_EDIT_FRAME::GetCurrentTreeNode(), FOOTPRINT_EDIT_FRAME::GetCurrentTreeNode(), DIALOG_CHOOSE_SYMBOL::OnComponentPreselected(), and onItemContextMenu().
wxWindow * LIB_TREE::GetFocusTarget | ( | ) |
Definition at line 319 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().
wxString LIB_TREE::GetSearchString | ( | ) | const |
Definition at line 260 of file lib_tree.cpp.
References m_query_ctrl.
Referenced by updateRecentSearchMenu(), and DIALOG_CHOOSE_SYMBOL::~DIALOG_CHOOSE_SYMBOL().
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).
aUnit | if not NULL, the selected unit is filled in here. |
Definition at line 188 of file lib_tree.cpp.
References m_adapter, and m_tree_ctrl.
Referenced by DIALOG_CHOOSE_FOOTPRINT::GetSelectedLibId(), DIALOG_CHOOSE_SYMBOL::GetSelectedLibId(), getState(), FOOTPRINT_EDIT_FRAME::GetTreeFPID(), SYMBOL_EDIT_FRAME::GetTreeLIBID(), DIALOG_CHOOSE_FOOTPRINT::OnComponentPreselected(), DIALOG_CHOOSE_SYMBOL::OnComponentSelected(), DIALOG_CHOOSE_FOOTPRINT::OnComponentSelected(), onPreselect(), onQueryCharHook(), onTreeActivate(), SYMBOL_EDIT_FRAME::SyncLibraries(), and FOOTPRINT_EDIT_FRAME::SyncLibraryTree().
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.
aSelection | will be filled with a list of selected LIB_IDs |
aUnit | is an optional pointer to a list to fill with unit numbers |
Definition at line 202 of file lib_tree.cpp.
References m_adapter, and m_tree_ctrl.
Referenced by SYMBOL_EDIT_FRAME::GetTreeLIBIDs().
|
inline |
Definition at line 87 of file lib_tree.h.
References m_tree_ctrl.
Referenced by SYMBOL_EDIT_FRAME::GetTreeSelectionCount().
|
protected |
Return the symbol tree widget state.
Definition at line 430 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 474 of file lib_tree.cpp.
References m_inTimerEvent, and Regenerate().
Referenced by LIB_TREE().
|
protected |
Definition at line 598 of file lib_tree.cpp.
References info.
Referenced by LIB_TREE().
|
protected |
Definition at line 692 of file lib_tree.cpp.
References _, ACTION_MENU::Add(), EDA_REORDERABLE_LIST_DIALOG::EnabledList(), m_adapter, m_skipNextRightClick, and ACTIONS::selectColumns.
Referenced by LIB_TREE().
|
protected |
Definition at line 622 of file lib_tree.cpp.
References ACTION_MENU::Add(), BUT_RIGHT, GetCurrentTreeNode(), LIB_TREE_NODE::LIB, m_adapter, LIB_TREE_NODE::m_Pinned, m_skipNextRightClick, m_tree_ctrl, LIB_TREE_NODE::m_Type, ACTIONS::pinLibrary, TA_MOUSE_CLICK, TC_MOUSE, and ACTIONS::unpinLibrary.
Referenced by LIB_TREE().
|
protected |
Definition at line 605 of file lib_tree.cpp.
References GetSelectedLibId(), SIM_VALUE_GRAMMAR::IsValid(), m_adapter, m_details_ctrl, and HTML_WINDOW::SetPage().
Referenced by LIB_TREE().
|
protected |
Definition at line 482 of file lib_tree.cpp.
References GetNextItem(), GetPrevItem(), GetSelectedLibId(), LIB_TREE_NODE::INVALID, SIM_VALUE_GRAMMAR::IsValid(), LIB_TREE_NODE::LIB, m_adapter, m_tree_ctrl, postSelectEvent(), selectIfValid(), toggleExpand(), and updateRecentSearchMenu().
Referenced by LIB_TREE(), and onTreeCharHook().
|
protected |
Definition at line 532 of file lib_tree.cpp.
References m_query_ctrl.
Referenced by LIB_TREE().
|
protected |
Definition at line 464 of file lib_tree.cpp.
References m_debounceTimer.
Referenced by LIB_TREE().
|
protected |
|
protected |
Definition at line 583 of file lib_tree.cpp.
References GetSelectedLibId(), SIM_VALUE_GRAMMAR::IsValid(), m_tree_ctrl, postSelectEvent(), and toggleExpand().
Referenced by LIB_TREE().
|
protected |
Definition at line 547 of file lib_tree.cpp.
References m_adapter, MD_ALT, MD_CTRL, MD_SHIFT, and onQueryCharHook().
Referenced by LIB_TREE().
|
protected |
Definition at line 573 of file lib_tree.cpp.
References m_inTimerEvent, m_tree_ctrl, postPreselectEvent(), and updateRecentSearchMenu().
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 416 of file lib_tree.cpp.
Referenced by LIB_TREE(), onTreeSelect(), Regenerate(), and selectIfValid().
|
protected |
Post SYMBOL_SELECTED event to notify the selection handler that a part has been selected.
Definition at line 423 of file lib_tree.cpp.
Referenced by onQueryCharHook(), and onTreeActivate().
void LIB_TREE::RefreshLibTree | ( | ) |
Refreshes the tree (mainly to update highlighting and asterisking)
Definition at line 313 of file lib_tree.cpp.
References m_adapter.
Referenced by SYMBOL_EDIT_FRAME::DeleteSymbolFromLibrary(), FOOTPRINT_EDIT_FRAME::LoadFootprintFromBoard(), FOOTPRINT_EDIT_FRAME::LoadFootprintFromLibrary(), SYMBOL_EDIT_FRAME::OnModify(), FOOTPRINT_EDIT_FRAME::OnModify(), SYMBOL_TREE_PANE::onSymbolSelected(), SYMBOL_EDIT_FRAME::RefreshLibraryTree(), FOOTPRINT_EDIT_FRAME::RefreshLibraryTree(), SYMBOL_EDIT_FRAME::Save(), SYMBOL_EDIT_FRAME::SaveAll(), SYMBOL_EDIT_FRAME::SaveLibraryAs(), SYMBOL_EDIT_FRAME::SaveSymbolAs(), SYMBOL_EDIT_FRAME::UpdateLibraryTree(), and FOOTPRINT_EDIT_FRAME::UpdateLibraryTree().
void LIB_TREE::Regenerate | ( | bool | aKeepState | ) |
Regenerate the tree.
Definition at line 295 of file lib_tree.cpp.
References filter, getState(), m_adapter, m_query_ctrl, postPreselectEvent(), and setState().
Referenced by LIB_TREE(), onDebounceTimer(), SYMBOL_EDIT_FRAME::RegenerateLibraryTree(), FOOTPRINT_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 349 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 230 of file lib_tree.cpp.
References m_adapter, and selectIfValid().
Referenced by SYMBOL_EDIT_FRAME::DuplicateSymbol(), SYMBOL_EDIT_FRAME::FocusOnLibId(), FOOTPRINT_EDIT_FRAME::FocusOnLibID(), SYMBOL_EDIT_FRAME::GetSymbolFromRedoList(), SYMBOL_EDIT_FRAME::GetSymbolFromUndoList(), SYMBOL_EDIT_FRAME::KiwayMailIn(), FOOTPRINT_EDIT_FRAME::KiwayMailIn(), SYMBOL_EDIT_FRAME::LoadSymbol(), SYMBOL_EDIT_FRAME::Revert(), SYMBOL_EDIT_FRAME::saveSymbolAs(), SYMBOL_EDIT_FRAME::SetCurSymbol(), setState(), SYMBOL_EDIT_FRAME::SyncLibraries(), FOOTPRINT_EDIT_FRAME::SyncLibraryTree(), and SYMBOL_EDIT_FRAME::UpdateAfterSymbolProperties().
void LIB_TREE::SetSearchString | ( | const wxString & | aSearchString | ) |
Save/restore search string.
Definition at line 254 of file lib_tree.cpp.
References m_query_ctrl.
Referenced by DIALOG_CHOOSE_SYMBOL::DIALOG_CHOOSE_SYMBOL().
|
protected |
Restore the symbol tree widget state from an object.
Definition at line 448 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 337 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 242 of file lib_tree.cpp.
References m_tree_ctrl.
Referenced by SYMBOL_EDIT_FRAME::emptyScreen(), FOOTPRINT_TREE_PANE::onComponentSelected(), SYMBOL_TREE_PANE::onSymbolSelected(), SYMBOL_TREE_PANE::onUpdateUI(), FOOTPRINT_TREE_PANE::onUpdateUI(), SYMBOL_EDIT_FRAME::SetCurSymbol(), SYMBOL_EDIT_FRAME::SyncLibraries(), and FOOTPRINT_EDIT_FRAME::SyncLibraryTree().
|
protected |
Definition at line 266 of file lib_tree.cpp.
References _, alg::contains(), alg::delete_matching(), g_recentSearches, GetSearchString(), m_query_ctrl, m_recentSearchesKey, recent, and RECENT_SEARCHES_MAX.
Referenced by LIB_TREE(), onQueryCharHook(), and onTreeSelect().
|
protected |
Definition at line 217 of file lib_tree.h.
Referenced by centerIfValid(), CenterLibId(), ExpandLibId(), GetCurrentTreeNode(), GetSelectedLibId(), GetSelectedLibIds(), getState(), LIB_TREE(), onHeaderContextMenu(), onItemContextMenu(), onPreselect(), onQueryCharHook(), onSize(), onTreeCharHook(), RefreshLibTree(), Regenerate(), and SelectLibId().
|
protected |
Definition at line 222 of file lib_tree.h.
Referenced by LIB_TREE(), onQueryText(), and ~LIB_TREE().
|
protected |
Definition at line 221 of file lib_tree.h.
Referenced by LIB_TREE(), and onPreselect().
|
protected |
Definition at line 223 of file lib_tree.h.
Referenced by onDebounceTimer(), and onTreeSelect().
|
protected |
Definition at line 225 of file lib_tree.h.
|
protected |
Definition at line 215 of file lib_tree.h.
|
protected |
Definition at line 219 of file lib_tree.h.
Referenced by FocusSearchFieldIfExists(), GetFocusTarget(), GetSearchString(), LIB_TREE(), onQueryMouseMoved(), Regenerate(), SetSearchString(), and updateRecentSearchMenu().
|
protected |
Definition at line 226 of file lib_tree.h.
Referenced by LIB_TREE(), and updateRecentSearchMenu().
|
protected |
Definition at line 228 of file lib_tree.h.
Referenced by onHeaderContextMenu(), and onItemContextMenu().
|
protected |
Definition at line 220 of file lib_tree.h.
Referenced by centerIfValid(), expandIfValid(), GetCurrentTreeNode(), GetFocusTarget(), GetSelectedLibId(), GetSelectedLibIds(), GetSelectionCount(), getState(), LIB_TREE(), onItemContextMenu(), onQueryCharHook(), onTreeActivate(), onTreeSelect(), selectIfValid(), setState(), toggleExpand(), and Unselect().