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
39class SCH_BASE_FRAME;
40struct PICKED_SYMBOL;
41
42
43class PANEL_SYMBOL_CHOOSER : public wxPanel
44{
45public:
58 PANEL_SYMBOL_CHOOSER( SCH_BASE_FRAME* aFrame, wxWindow* aParent,
59 const SYMBOL_LIBRARY_FILTER* aFilter,
60 std::vector<PICKED_SYMBOL>& aHistoryList,
61 std::vector<PICKED_SYMBOL>& aAlreadyPlaced,
62 bool aAllowFieldEdits, bool aShowFootprints,
63 std::function<void()> aAcceptHandler,
64 std::function<void()> aEscapeHandler );
65
67
68 void OnChar( wxKeyEvent& aEvent );
69
70 void FinishSetup();
71
72 void SetPreselect( const LIB_ID& aPreselect );
73
85 LIB_ID GetSelectedLibId( int* aUnit = nullptr ) const;
86
87 int GetItemCount() const { return m_adapter->GetItemCount(); }
88
89 wxWindow* GetFocusTarget() const { return m_tree->GetFocusTarget(); }
90
96 std::vector<std::pair<int, wxString>> GetFields() const
97 {
98 return m_field_edits;
99 }
100
101protected:
102 static constexpr int DBLCLICK_DELAY = 100; // milliseconds
103
104 wxPanel* constructRightPanel( wxWindow* aParent );
105
106 void OnDetailsCharHook( wxKeyEvent& aEvt );
107 void onCloseTimer( wxTimerEvent& aEvent );
108 void onOpenLibsTimer( wxTimerEvent& aEvent );
109
110 void onFootprintSelected( wxCommandEvent& aEvent );
111 void onSymbolSelected( wxCommandEvent& aEvent );
112
119 void onSymbolChosen( wxCommandEvent& aEvent );
120
124 void showFootprintFor( const LIB_ID& aLibId );
125
129 void showFootprint( const wxString& aFootprint );
130
136 void populateFootprintSelector( const LIB_ID& aLibId );
137
138public:
139 static std::mutex g_Mutex;
140
141protected:
142 static wxString g_symbolSearchString;
143 static wxString g_powerSearchString;
144
148 wxSplitterWindow* m_hsplitter;
149 wxSplitterWindow* m_vsplitter;
150
151 wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER> m_adapter;
152
157
159 std::function<void()> m_acceptHandler;
160 std::function<void()> m_escapeHandler;
161
166
167 std::vector<std::pair<int, wxString>> m_field_edits;
168};
169
170#endif /* PANEL_SYMBOL_CHOOSER_H */
Add dark theme support to wxHtmlWindow.
Definition: html_window.h:34
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:434
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.