KiCad PCB EDA Suite
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 <brian.sidebotham@gmail.com>
5  * Copyright (C) 1992-2018 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 {
35 protected:
37  wxWindow* m_parent;
38  wxPanel* m_panel;
39  bool m_selected;
40 
42 
43  void OnKillFocus( wxFocusEvent& event );
44  void OnMouse( wxMouseEvent& event );
45 
46 public:
47  TEMPLATE_WIDGET( wxWindow* aParent, DIALOG_TEMPLATE_SELECTOR* aDialog );
48 
53  void SetTemplate(PROJECT_TEMPLATE* aTemplate);
54 
56 
57  void Select();
58  void Unselect();
59 
60 private:
61  bool IsSelected() { return m_selected; }
62 };
63 
64 
66 {
67 protected:
68  wxNotebookPage* m_parent;
69  wxString m_templatesPath;
70  int m_minHeight;
72 
74 public:
79  TEMPLATE_SELECTION_PANEL( wxNotebookPage* aParent, const wxString& aPath );
80 
81  const wxString& GetPath() { return m_templatesPath; }
82 
83  void AddTemplateWidget( TEMPLATE_WIDGET* aTemplateWidget );
84 
85  int GetMinHeight() { return m_minHeight; }
86 };
87 
88 
90 {
91 protected:
92  std::vector<TEMPLATE_SELECTION_PANEL*> m_panels;
94 
95  void AddTemplate( int aPage, PROJECT_TEMPLATE* aTemplate );
96 
97 public:
98  DIALOG_TEMPLATE_SELECTOR( wxWindow* aParent );
99 
106  void AddTemplatesPage( const wxString& aTitle, wxFileName& aPath );
107 
112 
113 private:
114 
115  void SetHtml( const wxFileName& aFilename )
116  {
117  m_htmlWin->LoadPage( aFilename.GetFullPath() );
118  }
119 
120 public:
121  void SetWidget( TEMPLATE_WIDGET* aWidget );
122 
123 private:
124  void buildPageContent( const wxString& aPath, int aPage );
125  void replaceCurrentPage();
126 
127  void onNotebookResize( wxSizeEvent& event );
128  void OnPageChange( wxNotebookEvent& event ) override;
129  void onDirectoryBrowseClicked( wxCommandEvent& event ) override;
130  void onReload( wxCommandEvent& event ) override;
131  void OnHtmlLinkActivated( wxHtmlLinkEvent& event ) override;
132 };
133 
134 #endif
TEMPLATE_WIDGET(wxWindow *aParent, DIALOG_TEMPLATE_SELECTOR *aDialog)
void buildPageContent(const wxString &aPath, int aPage)
void OnPageChange(wxNotebookEvent &event) override
PROJECT_TEMPLATE * GetSelectedTemplate()
void onNotebookResize(wxSizeEvent &event)
void OnHtmlLinkActivated(wxHtmlLinkEvent &event) override
DIALOG_TEMPLATE_SELECTOR(wxWindow *aParent)
void onDirectoryBrowseClicked(wxCommandEvent &event) override
A class which provides project template functionality.
std::vector< TEMPLATE_SELECTION_PANEL * > m_panels
PROJECT_TEMPLATE * GetTemplate()
void AddTemplate(int aPage, PROJECT_TEMPLATE *aTemplate)
int m_minHeight
minimal height to show templates (this is the height of the biggest template widget)
Class DIALOG_TEMPLATE_SELECTOR_BASE.
DIALOG_TEMPLATE_SELECTOR * m_dialog
void OnKillFocus(wxFocusEvent &event)
void SetHtml(const wxFileName &aFilename)
Class TEMPLATE_WIDGET_BASE.
void AddTemplateWidget(TEMPLATE_WIDGET *aTemplateWidget)
Class TEMPLATE_SELECTION_PANEL_BASE.
PROJECT_TEMPLATE * m_currTemplate
TEMPLATE_SELECTION_PANEL(wxNotebookPage *aParent, const wxString &aPath)
void SetTemplate(PROJECT_TEMPLATE *aTemplate)
Set the project template for this widget, which will determine the icon and title associated with thi...
void SetWidget(TEMPLATE_WIDGET *aWidget)
void AddTemplatesPage(const wxString &aTitle, wxFileName &aPath)
Add a new page with aTitle, populated with templates from aPath.
wxString m_templatesPath
the path to access to the folder containing the templates (which are also folders)
void OnMouse(wxMouseEvent &event)
void onReload(wxCommandEvent &event) override