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 (C) 2014-2023 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, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24#ifndef PANEL_SYMBOL_CHOOSER_H
25#define PANEL_SYMBOL_CHOOSER_H
26
27#include <widgets/lib_tree.h>
29#include <footprint_info.h>
30#include <widgets/html_window.h>
31
32class wxPanel;
33class wxTimer;
34class wxSplitterWindow;
35
40class SCH_BASE_FRAME;
41struct PICKED_SYMBOL;
42
43
44class PANEL_SYMBOL_CHOOSER : public wxPanel
45{
46public:
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,
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<int, wxString>> GetFields() const
98 {
99 return m_field_edits;
100 }
101
102protected:
103 static constexpr int DBLCLICK_DELAY = 100; // milliseconds
104
105 wxPanel* constructRightPanel( wxWindow* aParent );
106
107 void OnDetailsCharHook( wxKeyEvent& aEvt );
108 void onCloseTimer( wxTimerEvent& aEvent );
109 void onOpenLibsTimer( wxTimerEvent& aEvent );
110
111 void onFootprintSelected( wxCommandEvent& aEvent );
112 void onSymbolSelected( wxCommandEvent& aEvent );
113
120 void onSymbolChosen( wxCommandEvent& aEvent );
121
125 void showFootprintFor( const LIB_ID& aLibId );
126
130 void showFootprint( const wxString& aFootprint );
131
137 void populateFootprintSelector( const LIB_ID& aLibId );
138
139public:
140 static std::mutex g_Mutex;
141
142protected:
143 static wxString g_symbolSearchString;
144 static wxString g_powerSearchString;
145
149 wxSplitterWindow* m_hsplitter;
150 wxSplitterWindow* m_vsplitter;
151
152 wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER> m_adapter;
153
158
160 std::function<void()> m_acceptHandler;
161 std::function<void()> m_escapeHandler;
162
167
168 std::vector<std::pair<int, wxString>> m_field_edits;
169};
170
171#endif /* PANEL_SYMBOL_CHOOSER_H */
Add dark theme support to wxHtmlWindow.
Definition: html_window.h:35
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:49
Widget displaying a tree of symbols with optional search text control and description panel....
Definition: lib_tree.h:49
wxWindow * GetFocusTarget()
Definition: lib_tree.cpp:446
SYMBOL_PREVIEW_WIDGET * m_symbol_preview
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.
std::vector< std::pair< int, wxString > > GetFields() const
Get a list of fields edited by the user.
wxSplitterWindow * m_hsplitter
wxWindow * GetFocusTarget() const
FOOTPRINT_SELECT_WIDGET * m_fp_sel_ctrl
std::function< void()> m_escapeHandler
void OnDetailsCharHook(wxKeyEvent &aEvt)
static wxString g_symbolSearchString
void onCloseTimer(wxTimerEvent &aEvent)
wxSplitterWindow * m_vsplitter
std::vector< std::pair< int, wxString > > m_field_edits
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)
static std::mutex g_Mutex
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
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.