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 (C) 1992-2022 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
29#include "project_template.h"
30
32
34{
35public:
36 TEMPLATE_WIDGET( wxWindow* aParent, DIALOG_TEMPLATE_SELECTOR* aDialog );
37
42 void SetTemplate(PROJECT_TEMPLATE* aTemplate);
43
45
46 void Select();
47 void Unselect();
48
49protected:
50 void OnKillFocus( wxFocusEvent& event );
51 void OnMouse( wxMouseEvent& event );
52
53private:
54 bool IsSelected() { return m_selected; }
55
56protected:
58 wxWindow* m_parent;
59 wxPanel* m_panel;
61
63};
64
65
67{
68public:
73 TEMPLATE_SELECTION_PANEL( wxNotebookPage* aParent, const wxString& aPath );
74
75 const wxString& GetPath() { return m_templatesPath; }
76
77 void AddTemplateWidget( TEMPLATE_WIDGET* aTemplateWidget );
78
79 int GetMinHeight() { return m_minHeight; }
80
81protected:
82 wxNotebookPage* m_parent;
83 wxString m_templatesPath;
87};
88
89
91{
92public:
93 DIALOG_TEMPLATE_SELECTOR( wxWindow* aParent );
94
101 void AddTemplatesPage( const wxString& aTitle, wxFileName& aPath );
102
107
108 void SetWidget( TEMPLATE_WIDGET* aWidget );
109
110protected:
111 void AddTemplate( int aPage, PROJECT_TEMPLATE* aTemplate );
112
113private:
114 void SetHtml( const wxFileName& aFilename )
115 {
116 m_htmlWin->LoadPage( aFilename.GetFullPath() );
117 }
118
119private:
120 void buildPageContent( const wxString& aPath, int aPage );
121 void replaceCurrentPage();
122
123 void onNotebookResize( wxSizeEvent& event );
124 void OnPageChange( wxNotebookEvent& event ) override;
125 void onDirectoryBrowseClicked( wxCommandEvent& event ) override;
126 void onReload( wxCommandEvent& event ) override;
127 void OnHtmlLinkActivated( wxHtmlLinkEvent& event ) override;
128
129protected:
130 std::vector<TEMPLATE_SELECTION_PANEL*> m_panels;
132};
133
134#endif
Class DIALOG_TEMPLATE_SELECTOR_BASE.
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)
void onDirectoryBrowseClicked(wxCommandEvent &event) override
void onNotebookResize(wxSizeEvent &event)
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
A class which provides project template functionality.
Class TEMPLATE_SELECTION_PANEL_BASE.
wxString m_templatesPath
the path to access to the folder containing the templates (which are also folders)
void AddTemplateWidget(TEMPLATE_WIDGET *aTemplateWidget)
int m_minHeight
minimal height to show templates (this is the height of the biggest template widget)
Class TEMPLATE_WIDGET_BASE.
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)
PROJECT_TEMPLATE * m_currTemplate