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>
24#include <widgets/lib_tree.h>
26#include <footprint_info.h>
27#include <widgets/html_window.h>
28
29class wxPanel;
30class wxTimer;
31class wxSplitterWindow;
32
37class SCH_BASE_FRAME;
38struct PICKED_SYMBOL;
39
40
41class PANEL_SYMBOL_CHOOSER : public wxPanel
42{
43public:
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, bool& aCancelled,
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<FIELD_T, wxString>> GetFields() const
97 {
98 return m_field_edits;
99 }
100
101 void ShutdownCanvases();
102
103 wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER> Adapter() const { return m_adapter; }
104
105 void Regenerate();
106
107protected:
108 static constexpr int DBLCLICK_DELAY = 100; // milliseconds
109
110 wxPanel* constructRightPanel( wxWindow* aParent );
111
112 void OnDetailsCharHook( wxKeyEvent& aEvt );
113 void onCloseTimer( wxTimerEvent& aEvent );
114 void onOpenLibsTimer( wxTimerEvent& aEvent );
115
116 void onFootprintSelected( wxCommandEvent& aEvent );
117 void onSymbolSelected( wxCommandEvent& aEvent );
118
122 void onMenuOpen( wxMenuEvent& aEvent );
123 void onMenuClose( wxMenuEvent& aEvent );
124
131 void onSymbolChosen( wxCommandEvent& aEvent );
132
136 void showFootprintFor( const LIB_ID& aLibId );
137
141 void showFootprint( const wxString& aFootprint );
142
148 void populateFootprintSelector( const LIB_ID& aLibId );
149
150public:
151 static std::mutex g_Mutex;
152
153protected:
154 static wxString g_symbolSearchString;
155 static wxString g_powerSearchString;
156
160 wxSplitterWindow* m_hsplitter;
161 wxSplitterWindow* m_vsplitter;
162
163 wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER> m_adapter;
164
169
170 static SCH_BASE_FRAME* m_frame; // Must be static becuase used in a static function
171 std::function<void()> m_acceptHandler;
172 std::function<void()> m_escapeHandler;
173
178
179 std::vector<std::pair<FIELD_T, wxString>> m_field_edits;
180};
181
182#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
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
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.