28 #include <wx/dirdlg.h> 29 #include <wx/settings.h> 33 const wxString& aPath ) :
45 int height = aTemplateWidget->GetBestSize().GetHeight();
75 SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNHIGHLIGHT ) );
83 SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE ) );
109 for(
size_t i = 0; i <
m_notebook->GetPageCount(); i++ )
114 const int h_margin = 10;
116 int max_width =
m_notebook->GetClientSize().GetWidth() - h_margin;
117 m_panels[i]->SetSize( max_width, -1);
128 int page =
event.GetSelection();
130 if( page != wxNOT_FOUND && (
unsigned)page <
m_panels.size() )
165 m_panels[aPage]->AddTemplateWidget( w );
179 wxNotebookPage* newPage =
new wxNotebookPage(
m_notebook, wxID_ANY );
182 wxString
path = aPath.GetFullPath();
198 const int margin = 50;
201 if(
m_notebook->GetMinClientSize().GetHeight() < min_height )
202 m_notebook->SetMinClientSize( wxSize( -1, min_height ) );
211 if( dir.Open( aPath ) )
213 if( dir.HasSubDirs( wxT(
"meta" ) ) )
222 bool cont = dir.GetFirst( &sub_name, wxEmptyString, wxDIR_DIRS );
226 wxString sub_full = aPath + sub_name;
228 if( sub_dir.Open( sub_full ) )
231 cont = dir.GetNext( &sub_name );
243 wxString currPath = fn.GetFullPath();
245 wxDirDialog dirDialog(
this,
_(
"Select Templates Directory" ), currPath,
246 wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST );
248 if( dirDialog.ShowModal() != wxID_OK )
251 wxFileName dirName = wxFileName::DirName( dirDialog.GetPath() );
272 currPath = fn.GetFullPath();
287 wxString title =
m_notebook->GetPageText( page );
292 wxNotebookPage* newPage =
new wxNotebookPage(
m_notebook, wxID_ANY );
295 m_notebook->InsertPage( page, newPage, title,
true );
306 wxString url =
event.GetLinkInfo().GetHref();
307 wxLaunchDefaultBrowser( url );
void buildPageContent(const wxString &aPath, int aPage)
void OnPageChange(wxNotebookEvent &event) override
PROJECT_TEMPLATE * GetSelectedTemplate()
void onNotebookResize(wxSizeEvent &event)
wxFileName GetHtmlFile()
Get the full Html filename for the project template.
void OnHtmlLinkActivated(wxHtmlLinkEvent &event) override
DIALOG_TEMPLATE_SELECTOR(wxWindow *aParent)
void onDirectoryBrowseClicked(wxCommandEvent &event) override
A class which provides project template functionality.
wxBitmapButton * m_reloadButton
std::vector< TEMPLATE_SELECTION_PANEL * > m_panels
wxBitmapButton * m_browseButton
void Refresh()
Update the board display after modifying it by a python script (note: it is automatically called by a...
TEMPLATE_WIDGET * m_selectedWidget
void AddTemplate(int aPage, PROJECT_TEMPLATE *aTemplate)
wxGridSizer * m_SizerChoice
bool SetPage(const wxString &aSource) override
int m_minHeight
minimal height to show templates (this is the height of the biggest template widget)
wxString * GetTitle()
Get the title of the project (extracted from the html title tag)
Class DIALOG_TEMPLATE_SELECTOR_BASE.
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
void SetHtml(const wxFileName &aFilename)
wxTextCtrl * m_tcTemplatePath
void AddTemplateWidget(TEMPLATE_WIDGET *aTemplateWidget)
Class TEMPLATE_SELECTION_PANEL_BASE.
TEMPLATE_SELECTION_PANEL(wxNotebookPage *aParent, const wxString &aPath)
void SetWidget(TEMPLATE_WIDGET *aWidget)
void AddTemplatesPage(const wxString &aTitle, wxFileName &aPath)
Add a new page with aTitle, populated with templates from aPath.
wxNotebookPage * m_parent
wxString m_templatesPath
the path to access to the folder containing the templates (which are also folders)
void replaceCurrentPage()
void onReload(wxCommandEvent &event) override
wxBitmap * GetIcon()
Get the 64px^2 icon for the project template.