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 wxChoice;
33class wxSplitterWindow;
34class wxStaticText;
35
37class LIB_SYMBOL;
41class SCH_BASE_FRAME;
42struct PICKED_SYMBOL;
43
44
45class PANEL_SYMBOL_CHOOSER : public wxPanel
46{
47public:
62 PANEL_SYMBOL_CHOOSER( SCH_BASE_FRAME* aFrame, wxWindow* aParent,
63 const SYMBOL_LIBRARY_FILTER* aFilter,
64 std::vector<PICKED_SYMBOL>& aHistoryList,
65 std::vector<PICKED_SYMBOL>& aAlreadyPlaced,
66 bool aAllowFieldEdits, bool aShowFootprints, bool& aCancelled,
67 std::function<void()> aAcceptHandler,
68 std::function<void()> aEscapeHandler );
69
71
72 void OnChar( wxKeyEvent& aEvent );
73
74 void FinishSetup();
75
76 void SetPreselect( const LIB_ID& aPreselect );
77
89 LIB_ID GetSelectedLibId( int* aUnit = nullptr, int* aBodyStyle = nullptr ) const;
90
91 int GetItemCount() const { return m_adapter->GetItemCount(); }
92
93 wxWindow* GetFocusTarget() const { return m_tree->GetFocusTarget(); }
94
100 std::vector<std::pair<FIELD_T, wxString>> GetFields() const
101 {
102 return m_field_edits;
103 }
104
105 void ShutdownCanvases();
106
108
109 wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER> Adapter() const { return m_adapter; }
110
111 void Regenerate();
112
113protected:
114 static constexpr int DBLCLICK_DELAY = 100; // milliseconds
115
116 wxPanel* constructRightPanel( wxWindow* aParent );
117
118 void OnDetailsCharHook( wxKeyEvent& aEvt );
119 void onCloseTimer( wxTimerEvent& aEvent );
120 void onOpenLibsTimer( wxTimerEvent& aEvent );
121
122 void onFootprintSelected( wxCommandEvent& aEvent );
123 void onSymbolSelected( wxCommandEvent& aEvent );
124
125 void onSelectBodyStyle( wxCommandEvent& aEvent );
126 void updateBodyStyleChoice( LIB_SYMBOL* aSymbol );
127
131 void onMenuOpen( wxMenuEvent& aEvent );
132 void onMenuClose( wxMenuEvent& aEvent );
133
140 void onSymbolChosen( wxCommandEvent& aEvent );
141
145 void showFootprintFor( const LIB_ID& aLibId );
146
150 void showFootprint( const wxString& aFootprint );
151
157 void populateFootprintSelector( const LIB_ID& aLibId );
158
159public:
160 static std::mutex g_Mutex;
161
162protected:
163 static wxString g_symbolSearchString;
164 static wxString g_powerSearchString;
165
169 wxSplitterWindow* m_hsplitter;
170 wxSplitterWindow* m_vsplitter;
171
172 wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER> m_adapter;
173
178
179 static SCH_BASE_FRAME* m_frame; // Must be static becuase used in a static function
180 std::function<void()> m_acceptHandler;
181 std::function<void()> m_escapeHandler;
182
187 wxStaticText* m_bodyStyleLabel;
190
191 std::vector<std::pair<FIELD_T, wxString>> m_field_edits;
192
194};
195
196#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
Define a library symbol object.
Definition lib_symbol.h:119
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 updateBodyStyleChoice(LIB_SYMBOL *aSymbol)
void onSelectBodyStyle(wxCommandEvent &aEvent)
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
LIB_ID GetSelectedLibId(int *aUnit=nullptr, int *aBodyStyle=nullptr) const
To be called after this dialog returns from ShowModal().
wxObjectDataPtr< LIB_TREE_MODEL_ADAPTER > m_adapter
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.