32#include <wx/settings.h>
36 const wxString& aPath ) :
48 int height = aTemplateWidget->GetBestSize().GetHeight();
78 SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNHIGHLIGHT ) );
86 SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE ) );
113 for(
size_t i = 0; i <
m_notebook->GetPageCount(); i++ )
118 const int h_margin = 10;
119 const int v_margin = 22;
121 int max_width =
m_notebook->GetClientSize().GetWidth() - h_margin;
122 int min_height =
m_panels[i]->GetMinHeight() + v_margin;
123 m_panels[i]->SetSize( max_width, std::max(
m_panels[i]->GetSize().GetY(), min_height ) );
124 m_panels[i]->SetMinSize( wxSize( -1, min_height ) );
135 int page =
event.GetSelection();
137 if( page != wxNOT_FOUND && (
unsigned)page <
m_panels.size() )
175 m_panels[aPage]->AddTemplateWidget( w );
189 wxNotebookPage* newPage =
new wxNotebookPage(
m_notebook, wxID_ANY );
192 wxString
path = aPath.GetFullPath();
208 const int margin = 50;
211 if(
m_notebook->GetMinClientSize().GetHeight() < min_height )
212 m_notebook->SetMinClientSize( wxSize( -1, min_height ) );
221 if( dir.Open( aPath ) )
223 if( dir.HasSubDirs(
"meta" ) )
230 wxArrayString subdirs;
232 bool cont = dir.GetFirst( &sub_name, wxEmptyString, wxDIR_DIRS );
236 subdirs.Add( wxString( sub_name ) );
237 cont = dir.GetNext( &sub_name );
240 if( !subdirs.IsEmpty() )
243 for(
const wxString& dir_name : subdirs )
246 wxString sub_full = aPath + dir_name;
248 if( sub_dir.Open( sub_full ) )
264 wxString currPath = fn.GetFullPath();
266 wxDirDialog dirDialog(
this,
_(
"Select Templates Directory" ), currPath,
267 wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST );
269 if( dirDialog.ShowModal() != wxID_OK )
272 wxFileName dirName = wxFileName::DirName( dirDialog.GetPath() );
293 currPath = fn.GetFullPath();
308 wxString title =
m_notebook->GetPageText( page );
313 wxNotebookPage* newPage =
new wxNotebookPage(
m_notebook, wxID_ANY );
316 m_notebook->InsertPage( page, newPage, title,
true );
327 wxString url =
event.GetLinkInfo().GetHref();
328 wxLaunchDefaultBrowser( url );
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap)
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
Class DIALOG_TEMPLATE_SELECTOR_BASE.
STD_BITMAP_BUTTON * m_browseButton
wxTextCtrl * m_tcTemplatePath
STD_BITMAP_BUTTON * m_reloadButton
void AddTemplate(int aPage, PROJECT_TEMPLATE *aTemplate)
void OnPageChange(wxNotebookEvent &event) override
void AddTemplatesPage(const wxString &aTitle, wxFileName &aPath)
Add a new page with aTitle, populated with templates from aPath.
void onReload(wxCommandEvent &event) override
void SetHtml(const wxFileName &aFilename)
TEMPLATE_WIDGET * m_selectedWidget
void onDirectoryBrowseClicked(wxCommandEvent &event) override
void onNotebookResize(wxSizeEvent &event)
void replaceCurrentPage()
DIALOG_TEMPLATE_SELECTOR(wxWindow *aParent, const wxPoint &aPos, const wxSize &aSize)
PROJECT_TEMPLATE * GetSelectedTemplate()
void SetWidget(TEMPLATE_WIDGET *aWidget)
void buildPageContent(const wxString &aPath, int aPage)
void OnHtmlLinkActivated(wxHtmlLinkEvent &event) override
std::vector< TEMPLATE_SELECTION_PANEL * > m_panels
bool SetPage(const wxString &aSource) override
A class which provides project template functionality.
wxBitmap * GetIcon()
Get the 64px^2 icon for the project template.
wxFileName GetHtmlFile()
Get the full Html filename for the project template.
wxString * GetTitle()
Get the title of the project (extracted from the html title tag)
Class TEMPLATE_SELECTION_PANEL_BASE.
wxBoxSizer * m_SizerChoice
TEMPLATE_SELECTION_PANEL(wxNotebookPage *aParent, const wxString &aPath)
wxString m_templatesPath
the path to access to the folder containing the templates (which are also folders)
void AddTemplateWidget(TEMPLATE_WIDGET *aTemplateWidget)
wxNotebookPage * m_parent
int m_minHeight
minimal height to show templates (this is the height of the biggest template widget)
KICOMMON_API wxFont GetInfoFont(wxWindow *aWindow)
void Refresh()
Update the board display after modifying it by a python script (note: it is automatically called by a...
std::vector< FAB_LAYER_COLOR > dummy
Functions to provide common constants and other functions to assist in making a consistent UI.
#define FN_NORMALIZE_FLAGS
Default flags to pass to wxFileName::Normalize().