39#include <wx/clipbrd.h>
43#include <wx/splitter.h>
54 std::vector<LIB_ID>& aHistoryList,
55 std::function<
void()> aSelectHandler ) :
56 wxPanel( aParent, wxID_ANY, wxDefaultPosition, wxDefaultSize ),
57 m_vsplitter( nullptr ),
61 m_selectHandler(
std::
move( aSelectHandler ) ),
62 m_historyList( aHistoryList )
79 delete progressReporter;
90 wxBoxSizer* sizer =
new wxBoxSizer( wxVERTICAL );
92 m_vsplitter =
new wxSplitterWindow(
this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
93 wxSP_LIVE_UPDATE | wxSP_NOBORDER | wxSP_3DSASH );
100 wxBoxSizer* treeSizer =
new wxBoxSizer( wxVERTICAL );
101 treePanel->SetSizer( treeSizer );
103 wxPanel* detailsPanel =
new wxPanel(
m_vsplitter );
104 wxBoxSizer* detailsSizer =
new wxBoxSizer( wxVERTICAL );
105 detailsPanel->SetSizer( detailsSizer );
109 detailsSizer->Add(
m_preview, 1, wxEXPAND, 5 );
110 detailsPanel->Layout();
111 detailsSizer->Fit( detailsPanel );
115 m_vsplitter->SplitHorizontally( treePanel, detailsPanel );
123 treeSizer->Add(
m_tree, 1, wxEXPAND, 5 );
125 treeSizer->Fit( treePanel );
173 cfg->m_DesignBlockChooserPanel.width = GetParent()->GetSize().x;
174 cfg->m_DesignBlockChooserPanel.height = GetParent()->GetSize().y;
177 cfg->m_DesignBlockChooserPanel.sash_pos_v =
m_vsplitter->GetSashPosition();
186 if( aEvent.GetKeyCode() == WXK_ESCAPE )
188 wxObject* eventSource = aEvent.GetEventObject();
190 if( wxTextCtrl* textCtrl =
dynamic_cast<wxTextCtrl*
>( eventSource ) )
212 auto horizPixelsFromDU =
216 return GetParent()->ConvertDialogToPixels( sz ).x;
221 int w = panelCfg.
width > 40 ? panelCfg.
width : horizPixelsFromDU( 440 );
222 int h = panelCfg.
height > 40 ? panelCfg.
height : horizPixelsFromDU( 340 );
224 GetParent()->SetSize( wxSize( w, h ) );
225 GetParent()->Layout();
231 panelCfg.
sash_pos_h = horizPixelsFromDU( 220 );
234 panelCfg.
sash_pos_v = horizPixelsFromDU( 230 );
265 progressReporter.Show(
false );
285 m_adapter->SetPreselectNode( aPreselect, 0 );
307 wxMouseState state = wxGetMouseState();
309 if( state.LeftIsDown() )
326 m_adapter->OpenLibs( cfg->m_LibTree.open_libs );
387 wxString history = wxT(
"-- " ) +
_(
"Recently Used" ) + wxT(
" --" );
392 std::vector<LIB_TREE_ITEM*> historyInfos;
397 lib.GetLibNickname(), lib.GetLibItemName() );
400 if( fp_info !=
nullptr )
401 historyInfos.push_back( fp_info );
404 m_adapter->DoAddLibrary( history, wxEmptyString, historyInfos,
false,
true );
416 dlg.
MessageSet(
_(
"Errors were encountered loading footprints:" ) );
422 wxString tmp =
EscapeHTML( error->Problem() );
425 tmp.Replace( wxS(
"\n" ), wxS(
"<BR>" ) );
426 msg += wxT(
"<p>" ) + tmp + wxT(
"</p>" );
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
static DESIGN_BLOCK_LIST_IMPL & GetGlobalList()
bool ReadDesignBlockFiles(DESIGN_BLOCK_LIB_TABLE *aTable, const wxString *aNickname=nullptr, PROGRESS_REPORTER *aProgressReporter=nullptr) override
Read all the design blocks provided by the combination of aTable and aNickname.
DESIGN_BLOCK_INFO * GetDesignBlockInfo(const wxString &aDesignBlockName)
Get info for a design block by id.
static wxObjectDataPtr< LIB_TREE_MODEL_ADAPTER > Create(EDA_BASE_FRAME *aParent, LIB_TABLE *aLibs)
Factory function: create a model adapter in a reference-counting container.
void AddLibraries(EDA_BASE_FRAME *aParent)
@ GAL_TYPE_OPENGL
OpenGL implementation.
void MessageSet(const wxString &message)
Add a message (in bold) to message list.
void AddHTML_Text(const wxString &message)
Add HTML text (without any change) to message list.
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
A logical library item identifier and consists of various portions much like a URI.
bool IsValid() const
Check if this LID_ID is valid.
A mix-in to provide polymorphism between items stored in libraries (symbols, aliases and footprints).
void SetPreselectNode(const LIB_ID &aLibId, int aUnit)
Set the symbol name to be selected if there are no search results.
Widget displaying a tree of symbols with optional search text control and description panel....
void CenterLibId(const LIB_ID &aLibId)
Ensure that an item is visible (preferably centered).
void SelectLibId(const LIB_ID &aLibId)
Select an item in the tree widget.
LIB_TREE_MODEL_ADAPTER::SORT_MODE GetSortMode() const
wxString GetSearchString() const
void Unselect()
Unselect currently selected item in wxDataViewCtrl.
LIB_ID GetSelectedLibId(int *aUnit=nullptr) const
For multi-unit symbols, if the user selects the symbol itself rather than picking an individual unit,...
void SetSearchString(const wxString &aSearchString)
Save/restore search string.
void Regenerate(bool aKeepState)
Regenerate the tree.
static wxString g_designBlockSearchString
DESIGN_BLOCK_PREVIEW_WIDGET * m_preview
std::function< void()> m_selectHandler
void onOpenLibsTimer(wxTimerEvent &aEvent)
void addDesignBlockToHistory(const LIB_ID &aLibId)
wxTimer * m_dbl_click_timer
void SetPreselect(const LIB_ID &aPreselect)
void onCloseTimer(wxTimerEvent &aEvent)
wxSplitterWindow * m_vsplitter
void displayErrors(wxTopLevelWindow *aWindow)
LIB_ID GetSelectedLibId(int *aUnit=nullptr) const
To be called after this dialog returns from ShowModal().
void OnChar(wxKeyEvent &aEvent)
static constexpr int DBLCLICK_DELAY
~PANEL_DESIGN_BLOCK_CHOOSER()
PANEL_DESIGN_BLOCK_CHOOSER(SCH_EDIT_FRAME *aFrame, wxWindow *aParent, std::vector< LIB_ID > &aHistoryList, std::function< void()> aSelectHandler)
Create dialog to choose design_block.
void rebuildHistoryNode()
void RefreshLibs(bool aProgress=false)
std::vector< LIB_ID > m_historyList
wxObjectDataPtr< LIB_TREE_MODEL_ADAPTER > m_adapter
wxTimer * m_open_libs_timer
void onDesignBlockSelected(wxCommandEvent &aEvent)
void onDesignBlockChosen(wxCommandEvent &aEvent)
Handle the selection of an item.
void SelectLibId(const LIB_ID &aLibId)
virtual SETTINGS_MANAGER & GetSettingsManager() const
virtual DESIGN_BLOCK_LIB_TABLE * DesignBlockLibs()
Return the table of design block libraries.
Schematic editor (Eeschema) main window.
DESIGN_BLOCK * GetDesignBlock(const LIB_ID &aLibId, bool aUseCacheLib=false, bool aShowErrorMsg=false)
Load design block from design block library table.
T * GetAppSettings()
Returns a handle to the a given settings by type If the settings have already been loaded,...
Multi-thread safe progress reporter dialog, intended for use of tasks that parallel reporting back of...
PGM_BASE & Pgm()
The global Program "get" accessor.
wxString EscapeHTML(const wxString &aString)
Return a new wxString escaped for embedding in HTML.