38#include <wx/splitter.h>
49 std::vector<LIB_ID>& aHistoryList,
50 std::function<
void()> aSelectHandler,
53 wxPanel( aParent, wxID_ANY, wxDefaultPosition, wxDefaultSize ),
67 m_frame, libs,
m_frame->config()->m_DesignBlockChooserPanel.tree, aContextMenuTool );
73 wxBoxSizer* sizer =
new wxBoxSizer( wxVERTICAL );
75 m_vsplitter =
new wxSplitterWindow(
this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
76 wxSP_LIVE_UPDATE | wxSP_NOBORDER | wxSP_3DSASH );
83 wxBoxSizer* treeSizer =
new wxBoxSizer( wxVERTICAL );
84 treePanel->SetSizer( treeSizer );
101 treeSizer->Add(
m_tree, 1, wxEXPAND, 5 );
103 treeSizer->Fit( treePanel );
153 cfg->m_DesignBlockChooserPanel.width = GetParent()->GetSize().x;
154 cfg->m_DesignBlockChooserPanel.height = GetParent()->GetSize().y;
155 cfg->m_DesignBlockChooserPanel.sash_pos_v =
m_vsplitter->GetSashPosition();
156 cfg->m_DesignBlockChooserPanel.sort_mode =
m_tree->GetSortMode();
164 m_tree->ShowChangedLanguage();
178 if( aEvent.GetKeyCode() == WXK_ESCAPE )
180 wxObject* eventSource = aEvent.GetEventObject();
182 if( wxTextCtrl* textCtrl =
dynamic_cast<wxTextCtrl*
>( eventSource ) )
185 if( textCtrl->GetValue() ==
m_tree->GetSearchString() && !
m_tree->GetSearchString().IsEmpty() )
187 m_tree->SetSearchString( wxEmptyString );
203 auto horizPixelsFromDU =
207 return GetParent()->ConvertDialogToPixels( sz ).x;
212 int w = panelCfg.
width > 40 ? panelCfg.
width : horizPixelsFromDU( 440 );
213 int h = panelCfg.
height > 40 ? panelCfg.
height : horizPixelsFromDU( 340 );
215 GetParent()->SetSize( wxSize( w, h ) );
216 GetParent()->Layout();
222 panelCfg.
sash_pos_h = horizPixelsFromDU( 220 );
225 panelCfg.
sash_pos_v = horizPixelsFromDU( 230 );
254 m_tree->Regenerate(
true );
265 m_adapter->SetPreselectNode( aPreselect, 0 );
271 return m_tree->GetSelectedLibId( aUnit );
277 m_tree->CenterLibId( aLibId );
278 m_tree->SelectLibId( aLibId );
287 wxMouseState state = wxGetMouseState();
289 if( state.LeftIsDown() )
297 m_frame->GetCanvas()->SetFocus();
307 m_adapter->OpenLibs( cfg->m_LibTree.open_libs );
323 m_preview->DisplayDesignBlock( designBlock.get() );
330 if(
m_tree->GetSelectedLibId().IsValid() )
366 m_tree->Regenerate(
true );
377 std::vector<LIB_TREE_ITEM*> historyInfos;
386 if(
info !=
nullptr )
387 historyInfos.push_back(
info );
390 m_adapter->DoAddLibrary( wxT(
"-- " ) +
_(
"Recently Used" ) + wxT(
" --" ), wxEmptyString,
391 historyInfos,
false,
true )
392 .m_IsRecentlyUsedGroup =
true;
404 dlg.
MessageSet(
_(
"Errors were encountered loading design blocks:" ) );
409 while( std::unique_ptr<IO_ERROR> error = DESIGN_BLOCK_LIB_TABLE::GetGlobalList().PopError() )
411 wxString tmp =
EscapeHTML( error->Problem() );
414 tmp.Replace( wxS(
"\n" ), wxS(
"<BR>" ) );
415 msg += wxT(
"<p>" ) + tmp + wxT(
"</p>" );
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
DESIGN_BLOCK * LoadDesignBlock(const wxString &aNickname, const wxString &aDesignBlockName, bool aKeepUUID=false)
Load a design block having aDesignBlockName from the library given by aNickname.
void AddLibraries(EDA_BASE_FRAME *aParent)
static wxObjectDataPtr< LIB_TREE_MODEL_ADAPTER > Create(EDA_BASE_FRAME *aParent, DESIGN_BLOCK_LIBRARY_ADAPTER *aLibs, APP_SETTINGS_BASE::LIB_TREE &aSettings, TOOL_INTERACTIVE *aContextMenuTool)
Factory function: create a model adapter in a reference-counting container.
The base class for create windows for drawing purpose.
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.
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.
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)
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.
wxTimer * m_dbl_click_timer
DESIGN_BLOCK_PANE * m_parent
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 SetPreviewWidget(DESIGN_BLOCK_PREVIEW_WIDGET *aPreview)
void OnChar(wxKeyEvent &aEvent)
wxBoxSizer * m_detailsSizer
static constexpr int DBLCLICK_DELAY
~PANEL_DESIGN_BLOCK_CHOOSER()
void rebuildHistoryNode()
void ShowChangedLanguage()
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)
wxString EscapeHTML(const wxString &aString)
Return a new wxString escaped for embedding in HTML.