42#include <wx/splitter.h>
53 std::vector<LIB_ID>& aHistoryList,
54 std::function<
void()> aSelectHandler,
57 wxPanel( aParent, wxID_ANY, wxDefaultPosition, wxDefaultSize ),
71 m_frame, libs,
m_frame->config()->m_DesignBlockChooserPanel.tree, aContextMenuTool );
77 wxBoxSizer* sizer =
new wxBoxSizer( wxVERTICAL );
79 m_vsplitter =
new wxSplitterWindow(
this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
80 wxSP_LIVE_UPDATE | wxSP_NOBORDER | wxSP_3DSASH );
87 wxBoxSizer* treeSizer =
new wxBoxSizer( wxVERTICAL );
88 treePanel->SetSizer( treeSizer );
105 treeSizer->Add(
m_tree, 1, wxEXPAND, 5 );
107 treeSizer->Fit( treePanel );
157 cfg->m_DesignBlockChooserPanel.width = GetParent()->GetSize().x;
158 cfg->m_DesignBlockChooserPanel.height = GetParent()->GetSize().y;
159 cfg->m_DesignBlockChooserPanel.sash_pos_v =
m_vsplitter->GetSashPosition();
160 cfg->m_DesignBlockChooserPanel.sort_mode =
m_tree->GetSortMode();
168 m_tree->ShowChangedLanguage();
182 if( aEvent.GetKeyCode() == WXK_ESCAPE )
184 wxObject* eventSource = aEvent.GetEventObject();
186 if( wxTextCtrl* textCtrl =
dynamic_cast<wxTextCtrl*
>( eventSource ) )
189 if( textCtrl->GetValue() ==
m_tree->GetSearchString() && !
m_tree->GetSearchString().IsEmpty() )
191 m_tree->SetSearchString( wxEmptyString );
207 auto horizPixelsFromDU =
211 return GetParent()->ConvertDialogToPixels( sz ).x;
216 int w = panelCfg.
width > 40 ? panelCfg.
width : horizPixelsFromDU( 440 );
217 int h = panelCfg.
height > 40 ? panelCfg.
height : horizPixelsFromDU( 340 );
219 GetParent()->SetSize( wxSize( w, h ) );
220 GetParent()->Layout();
226 panelCfg.
sash_pos_h = horizPixelsFromDU( 220 );
229 panelCfg.
sash_pos_v = horizPixelsFromDU( 230 );
257 m_tree->Regenerate(
true );
264 m_adapter->SetPreselectNode( aPreselect, 0 );
270 return m_tree->GetSelectedLibId( aUnit );
276 m_tree->CenterLibId( aLibId );
277 m_tree->SelectLibId( aLibId );
286 wxMouseState state = wxGetMouseState();
288 if( state.LeftIsDown() )
296 m_frame->GetCanvas()->SetFocus();
306 m_adapter->OpenLibs( cfg->m_LibTree.open_libs );
319 m_preview->DisplayDesignBlock( designBlock.get() );
326 if(
m_tree->GetSelectedLibId().IsValid() )
362 m_tree->Regenerate(
true );
373 std::vector<LIB_TREE_ITEM*> historyInfos;
382 if(
info !=
nullptr )
383 historyInfos.push_back(
info );
386 m_adapter->DoAddLibrary( wxT(
"-- " ) +
_(
"Recently Used" ) + wxT(
" --" ), wxEmptyString,
387 historyInfos,
false,
true )
388 .m_IsRecentlyUsedGroup =
true;
400 dlg.
MessageSet(
_(
"Errors were encountered loading design blocks:" ) );
405 while( std::unique_ptr<IO_ERROR> error = DESIGN_BLOCK_LIB_TABLE::GetGlobalList().PopError() )
407 wxString tmp =
EscapeHTML( error->Problem() );
410 tmp.Replace( wxS(
"\n" ), wxS(
"<BR>" ) );
411 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.
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)
void Refresh()
Update the board display after modifying it by a python script (note: it is automatically called by a...
wxString EscapeHTML(const wxString &aString)
Return a new wxString escaped for embedding in HTML.