KiCad PCB EDA Suite
Loading...
Searching...
No Matches
panel_symbol_chooser.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2014 Henner Zeller <[email protected]>
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20#ifndef PANEL_SYMBOL_CHOOSER_H
21#define PANEL_SYMBOL_CHOOSER_H
22
23#include <template_fieldnames.h>
25#include <widgets/lib_tree.h>
27#include <footprint_info.h>
28#include <widgets/html_window.h>
29
30class wxPanel;
31class wxTimer;
32class wxSplitterWindow;
33
38class SCH_BASE_FRAME;
39struct PICKED_SYMBOL;
40
41
42class PANEL_SYMBOL_CHOOSER : public wxPanel
43{
44public:
59 PANEL_SYMBOL_CHOOSER( SCH_BASE_FRAME* aFrame, wxWindow* aParent,
60 const SYMBOL_LIBRARY_FILTER* aFilter,
61 std::vector<PICKED_SYMBOL>& aHistoryList,
62 std::vector<PICKED_SYMBOL>& aAlreadyPlaced,
63 bool aAllowFieldEdits, bool aShowFootprints, bool& aCancelled,
64 std::function<void()> aAcceptHandler,
65 std::function<void()> aEscapeHandler );
66
68
69 void OnChar( wxKeyEvent& aEvent );
70
71 void FinishSetup();
72
73 void SetPreselect( const LIB_ID& aPreselect );
74
86 LIB_ID GetSelectedLibId( int* aUnit = nullptr ) const;
87
88 int GetItemCount() const { return m_adapter->GetItemCount(); }
89
90 wxWindow* GetFocusTarget() const { return m_tree->GetFocusTarget(); }
91
97 std::vector<std::pair<FIELD_T, wxString>> GetFields() const
98 {
99 return m_field_edits;
100 }
101
102 void ShutdownCanvases();
103
105
106 wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER> Adapter() const { return m_adapter; }
107
108 void Regenerate();
109
110protected:
111 static constexpr int DBLCLICK_DELAY = 100; // milliseconds
112
113 wxPanel* constructRightPanel( wxWindow* aParent );
114
115 void OnDetailsCharHook( wxKeyEvent& aEvt );
116 void onCloseTimer( wxTimerEvent& aEvent );
117 void onOpenLibsTimer( wxTimerEvent& aEvent );
118
119 void onFootprintSelected( wxCommandEvent& aEvent );
120 void onSymbolSelected( wxCommandEvent& aEvent );
121
125 void onMenuOpen( wxMenuEvent& aEvent );
126 void onMenuClose( wxMenuEvent& aEvent );
127
134 void onSymbolChosen( wxCommandEvent& aEvent );
135
139 void showFootprintFor( const LIB_ID& aLibId );
140
144 void showFootprint( const wxString& aFootprint );
145
151 void populateFootprintSelector( const LIB_ID& aLibId );
152
153public:
154 static std::mutex g_Mutex;
155
156protected:
157 static wxString g_symbolSearchString;
158 static wxString g_powerSearchString;
159
163 wxSplitterWindow* m_hsplitter;
164 wxSplitterWindow* m_vsplitter;
165
166 wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER> m_adapter;
167
172
173 static SCH_BASE_FRAME* m_frame; // Must be static becuase used in a static function
174 std::function<void()> m_acceptHandler;
175 std::function<void()> m_escapeHandler;
176
181
182 std::vector<std::pair<FIELD_T, wxString>> m_field_edits;
183
185};
186
187#endif /* PANEL_SYMBOL_CHOOSER_H */
Add dark theme support to wxHtmlWindow.
Definition html_window.h:31
A logical library item identifier and consists of various portions much like a URI.
Definition lib_id.h:45
Widget displaying a tree of symbols with optional search text control and description panel.
Definition lib_tree.h:46
SYMBOL_PREVIEW_WIDGET * m_symbol_preview
PANEL_SYMBOL_CHOOSER(SCH_BASE_FRAME *aFrame, wxWindow *aParent, const SYMBOL_LIBRARY_FILTER *aFilter, std::vector< PICKED_SYMBOL > &aHistoryList, std::vector< PICKED_SYMBOL > &aAlreadyPlaced, bool aAllowFieldEdits, bool aShowFootprints, bool &aCancelled, std::function< void()> aAcceptHandler, std::function< void()> aEscapeHandler)
Create dialog to choose symbol.
void onSymbolSelected(wxCommandEvent &aEvent)
void showFootprintFor(const LIB_ID &aLibId)
Look up the footprint for a given symbol specified in the LIB_ID and display it.
void onMenuClose(wxMenuEvent &aEvent)
wxSplitterWindow * m_hsplitter
wxWindow * GetFocusTarget() const
void SetCompatibilityCallback(SYMBOL_COMPAT_FUNC aFunc)
std::vector< std::pair< FIELD_T, wxString > > GetFields() const
Get a list of fields edited by the user.
FOOTPRINT_SELECT_WIDGET * m_fp_sel_ctrl
std::function< void()> m_escapeHandler
void OnDetailsCharHook(wxKeyEvent &aEvt)
static wxString g_symbolSearchString
void onMenuOpen(wxMenuEvent &aEvent)
Handle parent frame menu events to block tree preview.
std::vector< std::pair< FIELD_T, wxString > > m_field_edits
void onCloseTimer(wxTimerEvent &aEvent)
wxSplitterWindow * m_vsplitter
static SCH_BASE_FRAME * m_frame
void showFootprint(const wxString &aFootprint)
Display the given footprint by name.
void populateFootprintSelector(const LIB_ID &aLibId)
Populate the footprint selector for a given alias.
void onOpenLibsTimer(wxTimerEvent &aEvent)
wxObjectDataPtr< LIB_TREE_MODEL_ADAPTER > Adapter() const
void onFootprintSelected(wxCommandEvent &aEvent)
static wxString g_powerSearchString
void OnChar(wxKeyEvent &aEvent)
void SetPreselect(const LIB_ID &aPreselect)
std::function< void()> m_acceptHandler
static constexpr int DBLCLICK_DELAY
SYMBOL_COMPAT_FUNC m_compatCallback
FOOTPRINT_PREVIEW_WIDGET * m_fp_preview
wxObjectDataPtr< LIB_TREE_MODEL_ADAPTER > m_adapter
LIB_ID GetSelectedLibId(int *aUnit=nullptr) const
To be called after this dialog returns from ShowModal().
void onSymbolChosen(wxCommandEvent &aEvent)
Handle the selection of an item.
wxPanel * constructRightPanel(wxWindow *aParent)
A shim class between EDA_DRAW_FRAME and several derived classes: SYMBOL_EDIT_FRAME,...
Helper object to filter a list of libraries.
std::function< std::vector< VARIANT_COMPAT_RESULT >(const LIB_ID &)> SYMBOL_COMPAT_FUNC
Callback that evaluates variant symbol compatibility for a given candidate LIB_ID.