KiCad PCB EDA Suite
Loading...
Searching...
No Matches
dialog_template_selector.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2012 Brian Sidebotham <[email protected]>
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#ifndef PROJECT_TEMPLATE_SELECTOR_H
26#define PROJECT_TEMPLATE_SELECTOR_H
27
30#include "project_template.h"
31
32#include <vector>
33#include <utility>
34#include <wx/filename.h>
35
37
39{
40public:
41 TEMPLATE_WIDGET( wxWindow* aParent, DIALOG_TEMPLATE_SELECTOR* aDialog );
42
47 void SetTemplate(PROJECT_TEMPLATE* aTemplate);
48
50
51 void Select();
52 void Unselect();
53
54protected:
55 void OnKillFocus( wxFocusEvent& event );
56 void OnMouse( wxMouseEvent& event );
57
58private:
59 bool IsSelected() { return m_selected; }
60
61protected:
63 wxWindow* m_parent;
64 wxPanel* m_panel;
66
68};
69
70
72{
73public:
78 TEMPLATE_SELECTION_PANEL( wxNotebookPage* aParent, const wxString& aPath );
79
80 const wxString& GetPath() { return m_templatesPath; }
81
82 void AddTemplateWidget( TEMPLATE_WIDGET* aTemplateWidget );
83
84 void SortAlphabetically();
85
86protected:
87 wxNotebookPage* m_parent;
88 wxString m_templatesPath;
90};
91
92
94{
95public:
96 DIALOG_TEMPLATE_SELECTOR( wxWindow* aParent, const wxPoint& aPos, const wxSize& aSize,
97 std::vector<std::pair<wxString, wxFileName>> aTitleDirList,
98 const wxFileName& aDefaultTemplate );
99
105
106 void SetWidget( TEMPLATE_WIDGET* aWidget );
107
108protected:
109 void AddTemplate( int aPage, PROJECT_TEMPLATE* aTemplate );
110
111private:
112 void SetHtml( const wxFileName& aFilename )
113 {
114 m_webviewPanel->LoadURL( aFilename.GetFullPath() );
115 }
116
117private:
118 void buildPageContent( const wxString& aPath, int aPage );
119 void replaceCurrentPage();
120
121 void OnPageChange( wxNotebookEvent& event ) override;
122 void onDirectoryBrowseClicked( wxCommandEvent& event ) override;
123 void onReload( wxCommandEvent& event ) override;
124
125protected:
126 std::vector<TEMPLATE_SELECTION_PANEL*> m_panels;
130 // Keep track of all template widgets so we can pick a sensible default
131 std::vector<TEMPLATE_WIDGET*> m_allWidgets;
132};
133
134#endif
DIALOG_TEMPLATE_SELECTOR_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Project Template Selector"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(513, 523), long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
void AddTemplate(int aPage, PROJECT_TEMPLATE *aTemplate)
void OnPageChange(wxNotebookEvent &event) override
void onReload(wxCommandEvent &event) override
DIALOG_TEMPLATE_SELECTOR(wxWindow *aParent, const wxPoint &aPos, const wxSize &aSize, std::vector< std::pair< wxString, wxFileName > > aTitleDirList, const wxFileName &aDefaultTemplate)
void SetHtml(const wxFileName &aFilename)
void onDirectoryBrowseClicked(wxCommandEvent &event) override
std::vector< TEMPLATE_WIDGET * > m_allWidgets
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.
TEMPLATE_SELECTION_PANEL_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxTAB_TRAVERSAL|wxBORDER_NONE, const wxString &name=wxEmptyString)
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)
TEMPLATE_WIDGET_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
PROJECT_TEMPLATE * GetTemplate()
void OnMouse(wxMouseEvent &event)
void SetTemplate(PROJECT_TEMPLATE *aTemplate)
Set the project template for this widget, which will determine the icon and title associated with thi...
DIALOG_TEMPLATE_SELECTOR * m_dialog
void OnKillFocus(wxFocusEvent &event)
TEMPLATE_WIDGET(wxWindow *aParent, DIALOG_TEMPLATE_SELECTOR *aDialog)
PROJECT_TEMPLATE * m_currTemplate