KiCad PCB EDA Suite
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
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 <h.zeller@acm.org>
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, 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 <template_fieldnames.h>
28#include <widgets/lib_tree.h>
30#include <footprint_info.h>
31#include <widgets/html_window.h>
32
33class wxPanel;
34class wxTimer;
35class wxSplitterWindow;
36
41class SCH_BASE_FRAME;
42struct PICKED_SYMBOL;
43
44
45class PANEL_SYMBOL_CHOOSER : public wxPanel
46{
47public:
60 PANEL_SYMBOL_CHOOSER( SCH_BASE_FRAME* aFrame, wxWindow* aParent,
61 const SYMBOL_LIBRARY_FILTER* aFilter,
62 std::vector<PICKED_SYMBOL>& aHistoryList,
63 std::vector<PICKED_SYMBOL>& aAlreadyPlaced,
64 bool aAllowFieldEdits, bool aShowFootprints,
65 std::function<void()> aAcceptHandler,
66 std::function<void()> aEscapeHandler );
67
69
70 void OnChar( wxKeyEvent& aEvent );
71
72 void FinishSetup();
73
74 void SetPreselect( const LIB_ID& aPreselect );
75
87 LIB_ID GetSelectedLibId( int* aUnit = nullptr ) const;
88
89 int GetItemCount() const { return m_adapter->GetItemCount(); }
90
91 wxWindow* GetFocusTarget() const { return m_tree->GetFocusTarget(); }
92
98 std::vector<std::pair<FIELD_T, wxString>> GetFields() const
99 {
100 return m_field_edits;
101 }
102
103protected:
104 static constexpr int DBLCLICK_DELAY = 100; // milliseconds
105
106 wxPanel* constructRightPanel( wxWindow* aParent );
107
108 void OnDetailsCharHook( wxKeyEvent& aEvt );
109 void onCloseTimer( wxTimerEvent& aEvent );
110 void onOpenLibsTimer( wxTimerEvent& aEvent );
111
112 void onFootprintSelected( wxCommandEvent& aEvent );
113 void onSymbolSelected( wxCommandEvent& aEvent );
114
118 void onMenuOpen( wxMenuEvent& aEvent );
119 void onMenuClose( wxMenuEvent& aEvent );
120
127 void onSymbolChosen( wxCommandEvent& aEvent );
128
132 void showFootprintFor( const LIB_ID& aLibId );
133
137 void showFootprint( const wxString& aFootprint );
138
144 void populateFootprintSelector( const LIB_ID& aLibId );
145
146public:
147 static std::mutex g_Mutex;
148
149protected:
150 static wxString g_symbolSearchString;
151 static wxString g_powerSearchString;
152
156 wxSplitterWindow* m_hsplitter;
157 wxSplitterWindow* m_vsplitter;
158
159 wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER> m_adapter;
160
165
167 std::function<void()> m_acceptHandler;
168 std::function<void()> m_escapeHandler;
169
174
175 std::vector<std::pair<FIELD_T, wxString>> m_field_edits;
176};
177
178#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:465
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.
void onMenuClose(wxMenuEvent &aEvent)
wxSplitterWindow * m_hsplitter
wxWindow * GetFocusTarget() const
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
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.