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 The 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, see <https://www.gnu.org/licenses/>.
18 */
19#ifndef PANEL_DESIGN_BLOCK_CHOOSER_H
20#define PANEL_DESIGN_BLOCK_CHOOSER_H
21
22#include <widgets/lib_tree.h>
24#include <widgets/html_window.h>
25
26class wxPanel;
27class wxTimer;
28class wxSplitterWindow;
29
30class EDA_DRAW_FRAME;
33
34
35class PANEL_DESIGN_BLOCK_CHOOSER : public wxPanel
36{
37public:
48 std::vector<LIB_ID>& aHistoryList,
49 std::function<void()> aSelectHandler,
50 TOOL_INTERACTIVE* aContextMenuTool );
51
53
54 void SaveSettings();
55
56 void OnChar( wxKeyEvent& aEvent );
57
58 wxPanel* GetDetailsPanel() { return m_detailsPanel; }
59
62
63 void FinishSetup();
64
65 void SetPreselect( const LIB_ID& aPreselect );
66
67 void RefreshLibs( bool aProgress = false );
68
80 LIB_ID GetSelectedLibId( int* aUnit = nullptr ) const;
81 void SelectLibId( const LIB_ID& aLibId );
82
83 LIB_TREE* GetLibTree() { return m_tree; }
84
86
87protected:
88 static constexpr int DBLCLICK_DELAY = 100; // milliseconds
89
90 void OnDetailsCharHook( wxKeyEvent& aEvt );
91 void onCloseTimer( wxTimerEvent& aEvent );
92 void onOpenLibsTimer( wxTimerEvent& aEvent );
93
94 void onDesignBlockSelected( wxCommandEvent& aEvent );
95
102 void onDesignBlockChosen( wxCommandEvent& aEvent );
103
104 void addDesignBlockToHistory( const LIB_ID& aLibId );
105 void rebuildHistoryNode();
106
107 void displayErrors( wxTopLevelWindow* aWindow );
108
109protected:
111
114 wxSplitterWindow* m_vsplitter;
116 wxBoxSizer* m_detailsSizer;
117
118 wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER> m_adapter;
119
122
125 std::function<void()> m_selectHandler;
126
127 std::vector<LIB_ID> m_historyList;
128};
129
130#endif /* PANEL_DESIGN_BLOCK_CHOOSER_H */
The base class for create windows for drawing purpose.
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
DESIGN_BLOCK_PREVIEW_WIDGET * m_preview
void onOpenLibsTimer(wxTimerEvent &aEvent)
DESIGN_BLOCK_PREVIEW_WIDGET * GetPreviewWidget() const
void addDesignBlockToHistory(const LIB_ID &aLibId)
PANEL_DESIGN_BLOCK_CHOOSER(EDA_DRAW_FRAME *aFrame, DESIGN_BLOCK_PANE *aParent, std::vector< LIB_ID > &aHistoryList, std::function< void()> aSelectHandler, TOOL_INTERACTIVE *aContextMenuTool)
Panel for using design blocks.
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 SetPreviewWidget(DESIGN_BLOCK_PREVIEW_WIDGET *aPreview)
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)