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-2012 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 
72 public:
77  TEMPLATE_SELECTION_PANEL( wxNotebookPage* aParent, const wxString& aPath );
78 
79  const wxString& GetPath() { return m_templatesPath; }
80 };
81 
82 
84 {
85 protected:
86  std::vector<TEMPLATE_SELECTION_PANEL*> m_panels;
88 
89  void AddTemplate( int aPage, PROJECT_TEMPLATE* aTemplate );
90 
91 public:
92  DIALOG_TEMPLATE_SELECTOR( wxWindow* aParent );
93 
100  void AddTemplatesPage( const wxString& aTitle, wxFileName& aPath );
101 
106 
107 private:
108 
109  void SetHtml( wxFileName aFilename )
110  {
111  m_htmlWin->LoadPage( aFilename.GetFullPath() );
112  }
113 
114 public:
115  void SetWidget( TEMPLATE_WIDGET* aWidget );
116 
117 private:
118  void buildPageContent( const wxString& aPath, int aPage );
119  void replaceCurrentPage();
120 
121  void onNotebookResize( wxSizeEvent& event );
122  void OnPageChange( wxNotebookEvent& event ) override;
123  void onDirectoryBrowseClicked( wxCommandEvent& event ) override;
124  void onValidatePath( wxCommandEvent& event ) override;
125  void OnHtmlLinkActivated( wxHtmlLinkEvent& event ) override;
126 };
127 
128 #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)
void onValidatePath(wxCommandEvent &event) override
void SetHtml(wxFileName aFilename)
Class DIALOG_TEMPLATE_SELECTOR_BASE.
DIALOG_TEMPLATE_SELECTOR * m_dialog
void OnKillFocus(wxFocusEvent &event)
Class TEMPLATE_WIDGET_BASE.
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)