32#include <wx/settings.h>
40 "<meta charset=\"UTF-8\">"
41 "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">"
42 "<title>KiCad Project Template Selector</title>"
44 "body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif; margin: 0; padding: 20px; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: #333; min-height: 100vh; box-sizing: border-box; }"
45 ".container { max-width: 800px; margin: 0 auto; background: rgba(255, 255, 255, 0.95); border-radius: 12px; padding: 30px; box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1); backdrop-filter: blur(10px); }"
46 ".header { text-align: center; margin-bottom: 30px; }"
47 ".logo { font-size: 2.5rem; font-weight: bold; color: #4a5568; margin-bottom: 10px; text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1); }"
48 ".subtitle { font-size: 1.2rem; color: #666; margin-bottom: 20px; }"
50#
if defined( __MINGW32__ )
51 "background: #4299e1;"
53 "background: linear-gradient(135deg, #4299e1, #3182ce);"
55 "color: white; padding: 25px; border-radius: 10px; margin-bottom: 25px; box-shadow: 0 4px 15px rgba(66, 153, 225, 0.3); }"
56 ".welcome-card h2 { margin-top: 0; font-size: 1.8rem; margin-bottom: 15px; }"
57 ".instructions { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; margin-bottom: 25px; }"
58 ".instruction-card { background: #f7fafc; border: 2px solid #e2e8f0; border-radius: 8px; padding: 20px; transition: all 0.3s ease; position: relative; overflow: hidden; }"
59 ".instruction-card:hover { transform: translateY(-2px); box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1); border-color: #4299e1; }"
60 ".instruction-card::before { content: ''; position: absolute; top: 0; left: 0; width: 4px; height: 100%; background: linear-gradient(135deg, #4299e1, #3182ce); }"
61 ".instruction-card h3 { color: #2d3748; margin-top: 0; margin-bottom: 10px; font-size: 1.3rem; }"
62 ".instruction-card p { color: #4a5568; line-height: 1.6; margin: 0; }"
63 ".features { background: #f0fff4; border: 2px solid #9ae6b4; border-radius: 8px; padding: 20px; margin-bottom: 25px; }"
64 ".features h3 { color: #22543d; margin-top: 0; margin-bottom: 15px; font-size: 1.4rem; }"
65 ".features ul { color: #2f855a; line-height: 1.8; margin: 0; padding-left: 20px; }"
66 ".features li { margin-bottom: 8px; }"
67 ".tips { background: #fffaf0; border: 2px solid #fbd38d; border-radius: 8px; padding: 20px; }"
68 ".tips h3 { color: #c05621; margin-top: 0; margin-bottom: 15px; font-size: 1.4rem; }"
69 ".tips p { color: #c05621; line-height: 1.6; margin: 0 0 10px 0; }"
70 ".highlight { background: linear-gradient(120deg, #a8edea 0%, #fed6e3 100%); padding: 2px 6px; border-radius: 4px; font-weight: 600; }"
74 "<div class=\"container\">"
75 "<div class=\"header\">"
76 "<div class=\"logo\">KiCad 📑</div>"
77 "<div class=\"subtitle\">" +
_(
"Project Template Selector" ) +
"</div>"
79 "<div class=\"welcome-card\">"
80 "<h2>" +
_(
"Welcome to Template Selection!" ) +
"</h2>"
81 "<p>" +
_(
"Choose from a variety of pre-configured project templates to jumpstart your PCB design. Templates provide ready-to-use project structures with common components, libraries, and design rules." ) +
"</p>"
83 "<div class=\"instructions\">"
84 "<div class=\"instruction-card\">"
85 "<h3>→ " +
_(
"Browse Templates" ) +
"</h3>"
86 "<p>" +
_(
"Navigate through the template tabs above to explore different categories of project templates. Each tab contains templates organized by type or complexity." ) +
"</p>"
88 "<div class=\"instruction-card\">"
89 "<h3>→ " +
_(
"Select a Template" ) +
"</h3>"
90 "<p>" +
_(
"Click on any template in the list to " ) +
"<span class=\"highlight\">" +
_(
"preview its details" ) +
"</span>. " +
_(
"The template information will appear in this panel, showing descriptions, included components, and project structure." ) +
"</p>"
92 "<div class=\"instruction-card\">"
93 "<h3>→ " +
_(
"Customize Path" ) +
"</h3>"
94 "<p>" +
_(
"Use the " ) +
"<span class=\"highlight\">" +
_(
"folder path field" ) +
"</span> " +
_(
"above to browse custom template directories. Click the folder icon to browse, or the refresh icon to reload templates." ) +
"</p>"
96 "<div class=\"instruction-card\">"
97 "<h3>→ " +
_(
"Create Project" ) +
"</h3>"
98 "<p>" +
_(
"Once you've found the right template, click " ) +
"<span class=\"highlight\">" +
_(
"OK" ) +
"</span> " +
_(
"to create a new project based on the selected template. Your project will inherit all template settings and files." ) +
"</p>"
101 "<div class=\"features\">"
102 "<h3>" +
_(
"What You Get with Templates" ) +
"</h3>"
104 "<li><strong>" +
_(
"Pre-configured libraries" ) +
"</strong> " +
_(
"- Common components and footprints already linked" ) +
"</li>"
105 "<li><strong>" +
_(
"Design rules" ) +
"</strong> " +
_(
"- Appropriate electrical and mechanical constraints" ) +
"</li>"
106 "<li><strong>" +
_(
"Layer stackups" ) +
"</strong> " +
_(
"- Optimized for the intended application" ) +
"</li>"
107 "<li><strong>" +
_(
"Component placement" ) +
"</strong> " +
_(
"- Basic layout and routing guidelines" ) +
"</li>"
108 "<li><strong>" +
_(
"Documentation" ) +
"</strong> " +
_(
"- README files and design notes" ) +
"</li>"
109 "<li><strong>" +
_(
"Manufacturing files" ) +
"</strong> " +
_(
"- Gerber and drill file configurations" ) +
"</li>"
112 "<div class=\"tips\">"
113 "<h3>" +
_(
"Pro Tips" ) +
"</h3>"
114 "<p><strong>" +
_(
"Start Simple:" ) +
"</strong> " +
_(
"Begin with basic templates and add more elements as you go." ) +
"</p>"
115 "<p><strong>" +
_(
"Customize Later:" ) +
"</strong> " +
_(
"Templates are starting points - you can modify libraries, rules, and layouts after project creation." ) +
"</p>"
116 "<p><strong>" +
_(
"Save Your Own:" ) +
"</strong> " +
_(
"Once you develop preferred settings, create a custom template for future projects." ) +
"</p>"
125 const wxString& aPath ) :
165 SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNHIGHLIGHT ) );
173 SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE ) );
199 int newPage =
event.GetSelection();
200 int oldPage =
event.GetOldSelection();
203 if( oldPage != wxNOT_FOUND && (
unsigned)oldPage <
m_panels.size() )
210 if( newPage != wxNOT_FOUND && (
unsigned)newPage <
m_panels.size() )
232 std::map<wxString, wxFileName> aTitleDirMap ) :
241 for(
auto& [title, pathFname] : aTitleDirMap )
244 wxString
path = pathFname.GetFullPath();
302 if( htmlFile.FileExists() && htmlFile.IsFileReadable() )
309 wxString templateHtml = wxString::Format(
311 "<html><head><meta charset='UTF-8'><style>"
312 "body { font-family: Arial, sans-serif; margin: 20px; }"
313 ".template-info { background: #f0f8ff; padding: 20px; border-radius: 8px; }"
314 "h1 { color: #333; margin-top: 0; }"
315 "</style></head><body>"
316 "<div class='template-info'>"
318 "<p>Template selected. Click OK to create a new project based on this template.</p>"
319 "</div></body></html>",
331 m_panels[aPage]->AddTemplateWidget( w );
346 if( dir.Open( aPath ) )
348 if( dir.HasSubDirs(
"meta" ) )
355 wxArrayString subdirs;
357 bool cont = dir.GetFirst( &sub_name, wxEmptyString, wxDIR_DIRS );
361 subdirs.Add( wxString( sub_name ) );
362 cont = dir.GetNext( &sub_name );
365 if( !subdirs.IsEmpty() )
368 for(
const wxString& dir_name : subdirs )
371 wxString sub_full = aPath + dir_name;
373 if( sub_dir.Open( sub_full ) )
388 wxString currPath = fn.GetFullPath();
390 wxDirDialog dirDialog(
this,
_(
"Select Templates Directory" ), currPath,
391 wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST );
393 if( dirDialog.ShowModal() != wxID_OK )
396 wxFileName dirName = wxFileName::DirName( dirDialog.GetPath() );
417 currPath = fn.GetFullPath();
432 wxString title =
m_notebook->GetPageText( page );
439 if( (
unsigned)page <
m_panels.size() )
450 m_notebook->InsertPage( page, tpanel, title,
true );
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
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
WEBVIEW_PANEL * m_webviewPanel
void AddTemplate(int aPage, PROJECT_TEMPLATE *aTemplate)
DIALOG_TEMPLATE_SELECTOR(wxWindow *aParent, const wxPoint &aPos, const wxSize &aSize, std::map< wxString, wxFileName > aTitleDirMap)
void OnPageChange(wxNotebookEvent &event) override
void onReload(wxCommandEvent &event) override
TEMPLATE_WIDGET * m_selectedWidget
void onDirectoryBrowseClicked(wxCommandEvent &event) override
void replaceCurrentPage()
PROJECT_TEMPLATE * GetSelectedTemplate()
void SetWidget(TEMPLATE_WIDGET *aWidget)
void buildPageContent(const wxString &aPath, int aPage)
std::vector< TEMPLATE_SELECTION_PANEL * > m_panels
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
void SetPage(const wxString &htmlContent)
void LoadURL(const wxString &url)
static const wxString GetWelcomeHtml()
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...
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().