KiCad PCB EDA Suite
Loading...
Searching...
No Matches
panel_design_block_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-2024 KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23#ifndef PANEL_DESIGN_BLOCK_CHOOSER_H
24#define PANEL_DESIGN_BLOCK_CHOOSER_H
25
26#include <widgets/lib_tree.h>
28#include <widgets/html_window.h>
29
30class wxPanel;
31class wxTimer;
32class wxSplitterWindow;
33
34class SCH_EDIT_FRAME;
36
37
38class PANEL_DESIGN_BLOCK_CHOOSER : public wxPanel
39{
40public:
49 PANEL_DESIGN_BLOCK_CHOOSER( SCH_EDIT_FRAME* aFrame, wxWindow* aParent,
50 std::vector<LIB_ID>& aHistoryList,
51 std::function<void()> aSelectHandler );
52
54
55 void OnChar( wxKeyEvent& aEvent );
56
57 void FinishSetup();
58
59 void SetPreselect( const LIB_ID& aPreselect );
60
61 void RefreshLibs( bool aProgress = false );
62
74 LIB_ID GetSelectedLibId( int* aUnit = nullptr ) const;
75 void SelectLibId( const LIB_ID& aLibId );
76
77 LIB_TREE* GetLibTree() { return m_tree; }
78
79protected:
80 static constexpr int DBLCLICK_DELAY = 100; // milliseconds
81
82 void OnDetailsCharHook( wxKeyEvent& aEvt );
83 void onCloseTimer( wxTimerEvent& aEvent );
84 void onOpenLibsTimer( wxTimerEvent& aEvent );
85
86 void onDesignBlockSelected( wxCommandEvent& aEvent );
87
94 void onDesignBlockChosen( wxCommandEvent& aEvent );
95
96 void addDesignBlockToHistory( const LIB_ID& aLibId );
97 void rebuildHistoryNode();
98
99 void displayErrors( wxTopLevelWindow* aWindow );
100
102
105 wxSplitterWindow* m_vsplitter;
106
107 wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER> m_adapter;
108
111
113 std::function<void()> m_selectHandler;
114
115 std::vector<LIB_ID> m_historyList;
116};
117
118#endif /* PANEL_DESIGN_BLOCK_CHOOSER_H */
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
DESIGN_BLOCK_PREVIEW_WIDGET * m_preview
std::function< void()> m_selectHandler
void onOpenLibsTimer(wxTimerEvent &aEvent)
void addDesignBlockToHistory(const LIB_ID &aLibId)
void SetPreselect(const LIB_ID &aPreselect)
void onCloseTimer(wxTimerEvent &aEvent)
void displayErrors(wxTopLevelWindow *aWindow)
LIB_ID GetSelectedLibId(int *aUnit=nullptr) const
To be called after this dialog returns from ShowModal().
void OnDetailsCharHook(wxKeyEvent &aEvt)
void RefreshLibs(bool aProgress=false)
wxObjectDataPtr< LIB_TREE_MODEL_ADAPTER > m_adapter
void onDesignBlockSelected(wxCommandEvent &aEvent)
void onDesignBlockChosen(wxCommandEvent &aEvent)
Handle the selection of an item.
void SelectLibId(const LIB_ID &aLibId)
Schematic editor (Eeschema) main window.