From 039ac92480a09266146fc5b0c9ec67a32a2565ad Mon Sep 17 00:00:00 2001 From: saurabhb17 Date: Wed, 26 Feb 2020 16:04:40 +0530 Subject: Added secondary files --- kicad/dialogs/dialog_template_selector.cpp | 280 ++++++ kicad/dialogs/dialog_template_selector.fbp | 1105 +++++++++++++++++++++++ kicad/dialogs/dialog_template_selector.h | 128 +++ kicad/dialogs/dialog_template_selector_base.cpp | 125 +++ kicad/dialogs/dialog_template_selector_base.h | 110 +++ 5 files changed, 1748 insertions(+) create mode 100644 kicad/dialogs/dialog_template_selector.cpp create mode 100644 kicad/dialogs/dialog_template_selector.fbp create mode 100644 kicad/dialogs/dialog_template_selector.h create mode 100644 kicad/dialogs/dialog_template_selector_base.cpp create mode 100644 kicad/dialogs/dialog_template_selector_base.h (limited to 'kicad/dialogs') diff --git a/kicad/dialogs/dialog_template_selector.cpp b/kicad/dialogs/dialog_template_selector.cpp new file mode 100644 index 0000000..f36f66d --- /dev/null +++ b/kicad/dialogs/dialog_template_selector.cpp @@ -0,0 +1,280 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2012 Brian Sidebotham + * Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "dialog_template_selector.h" + +#include +#include + + +TEMPLATE_SELECTION_PANEL::TEMPLATE_SELECTION_PANEL( wxNotebookPage* aParent, + const wxString& aPath ) : + TEMPLATE_SELECTION_PANEL_BASE( aParent ) +{ + m_parent = aParent; + m_templatesPath = aPath; +} + + +TEMPLATE_WIDGET::TEMPLATE_WIDGET( wxWindow* aParent, DIALOG_TEMPLATE_SELECTOR* aDialog ) : + TEMPLATE_WIDGET_BASE( aParent ) +{ + m_parent = aParent; + m_dialog = aDialog; + + // wxWidgets_3.xx way of doing the same... + // Bind(wxEVT_LEFT_DOWN, &TEMPLATE_WIDGET::OnMouse, this ); + + m_bitmapIcon->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( TEMPLATE_WIDGET::OnMouse ), NULL, this ); + m_staticTitle->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( TEMPLATE_WIDGET::OnMouse ), NULL, this ); + + // We're not selected until we're clicked + Unselect(); + + // Start with template being NULL + m_currTemplate = NULL; +} + + +void TEMPLATE_WIDGET::Select() +{ + m_dialog->SetWidget( this ); + SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNHIGHLIGHT ) ); + m_selected = true; + Refresh(); +} + + +void TEMPLATE_WIDGET::Unselect() +{ + SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE ) ); + m_selected = false; + Refresh(); +} + + +void TEMPLATE_WIDGET::SetTemplate(PROJECT_TEMPLATE* aTemplate) +{ + m_currTemplate = aTemplate; + m_staticTitle->SetLabel( *(aTemplate->GetTitle()) ); + m_bitmapIcon->SetBitmap( *(aTemplate->GetIcon()) ); +} + + +void TEMPLATE_WIDGET::OnMouse( wxMouseEvent& event ) +{ + // Toggle selection here + Select(); + event.Skip(); +} + + +void DIALOG_TEMPLATE_SELECTOR::onNotebookResize(wxSizeEvent& event) +{ + for( size_t i=0; i < m_notebook->GetPageCount(); i++ ) + { + m_panels[i]->SetSize( m_notebook->GetSize().GetWidth() - 6, 140 ); + m_panels[i]->m_SizerBase->FitInside( m_panels[i] ); + m_panels[i]->m_scrolledWindow->SetSize( m_panels[i]->GetSize().GetWidth() - 6, + m_panels[i]->GetSize().GetHeight() - 6 ); + m_panels[i]->m_SizerChoice->FitInside( m_panels[i]->m_scrolledWindow ); + } + m_notebook->Refresh(); + + event.Skip(); +} + +void DIALOG_TEMPLATE_SELECTOR::OnPageChange( wxNotebookEvent& event ) +{ + int page = m_notebook->GetSelection(); + + if( page != wxNOT_FOUND && (unsigned)page < m_panels.size() ) + m_tcTemplatePath->SetValue( m_panels[page]->GetPath() ); +} + + +DIALOG_TEMPLATE_SELECTOR::DIALOG_TEMPLATE_SELECTOR( wxWindow* aParent ) : + DIALOG_TEMPLATE_SELECTOR_BASE( aParent ) +{ + m_htmlWin->SetPage( _( "

Template Selector

" ) ); + m_notebook->Connect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_TEMPLATE_SELECTOR::onNotebookResize ), NULL, this ); + m_selectedWidget = NULL; +} + + +void DIALOG_TEMPLATE_SELECTOR::SetWidget( TEMPLATE_WIDGET* aWidget ) +{ + if( m_selectedWidget != NULL ) + m_selectedWidget->Unselect(); + + m_selectedWidget = aWidget; + SetHtml( m_selectedWidget->GetTemplate()->GetHtmlFile() ); +} + +void DIALOG_TEMPLATE_SELECTOR::AddTemplate( int aPage, PROJECT_TEMPLATE* aTemplate ) +{ + TEMPLATE_WIDGET* w = new TEMPLATE_WIDGET( m_panels[aPage]->m_scrolledWindow, this ); + w->SetTemplate( aTemplate ); + + m_panels[aPage]->m_SizerChoice->Add( w ); + m_panels[aPage]->m_SizerChoice->Layout(); + m_panels[aPage]->SetSize( m_notebook->GetSize().GetWidth() - 6, 140 ); + m_panels[aPage]->m_SizerBase->FitInside( m_panels[aPage] ); + m_panels[aPage]->m_scrolledWindow->SetSize( m_panels[aPage]->GetSize().GetWidth() - 6, + m_panels[aPage]->GetSize().GetHeight() - 6 ); + m_panels[aPage]->m_SizerChoice->FitInside( m_panels[aPage]->m_scrolledWindow ); + + m_notebook->Refresh(); +} + + +PROJECT_TEMPLATE* DIALOG_TEMPLATE_SELECTOR::GetSelectedTemplate() +{ + return m_selectedWidget? m_selectedWidget->GetTemplate() : NULL; +} + +void DIALOG_TEMPLATE_SELECTOR::AddTemplatesPage( const wxString& aTitle, wxFileName& aPath ) +{ + wxNotebookPage* newPage = new wxNotebookPage( m_notebook, wxID_ANY ); + + aPath.Normalize(); + wxString path = aPath.GetFullPath(); // caller ensures this ends with file separator. + + TEMPLATE_SELECTION_PANEL* tpanel = new TEMPLATE_SELECTION_PANEL( newPage, path ); + m_panels.push_back( tpanel ); + + m_notebook->AddPage( newPage, aTitle ); + + if( m_notebook->GetPageCount() == 1 ) + m_tcTemplatePath->SetValue( path ); + + buildPageContent( path, m_notebook->GetPageCount() - 1 ); +} + +void DIALOG_TEMPLATE_SELECTOR::buildPageContent( const wxString& aPath, int aPage ) +{ + // Get a list of files under the template path to include as choices... + wxArrayString files; + wxDir dir; + + if( dir.Open( aPath ) ) + { + wxDir sub_dir; + wxString sub_name; + + bool cont = dir.GetFirst( &sub_name, wxEmptyString, wxDIR_DIRS ); + while( cont ) + { + wxString sub_full = aPath + sub_name; + if( sub_dir.Open( sub_full ) ) + { + files.Add( sub_name ); + + PROJECT_TEMPLATE* pt = new PROJECT_TEMPLATE( sub_full ); + AddTemplate( aPage, pt ); + } + + cont = dir.GetNext( &sub_name ); + } + } +} + + +void DIALOG_TEMPLATE_SELECTOR::onDirectoryBrowseClicked( wxCommandEvent& event ) +{ + wxFileName fn; + fn.AssignDir( m_tcTemplatePath->GetValue() ); + fn.Normalize(); + wxString currPath = fn.GetFullPath(); + + wxDirDialog dirDialog( this, _( "Select Templates Directory" ), + currPath, + wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST ); + + if( dirDialog.ShowModal() != wxID_OK ) + return; + + wxFileName dirName = wxFileName::DirName( dirDialog.GetPath() ); + + m_tcTemplatePath->SetValue( dirName.GetFullPath() ); + + if( currPath == m_tcTemplatePath->GetValue() ) + return; // No change + + // Rebuild the page from the new templates path: + replaceCurrentPage(); +} + + +void DIALOG_TEMPLATE_SELECTOR::onValidatePath( wxCommandEvent& event ) +{ + int page = m_notebook->GetSelection(); + + if( page < 0 ) + return; // Should not happen + + wxString currPath = m_tcTemplatePath->GetValue(); + + if( currPath == m_panels[page]->GetPath() ) // No change + return; + + wxFileName fn; + fn.AssignDir( m_tcTemplatePath->GetValue() ); + fn.Normalize(); + currPath = fn.GetFullPath(); + m_tcTemplatePath->SetValue( currPath ); + + replaceCurrentPage(); +} + + +void DIALOG_TEMPLATE_SELECTOR::replaceCurrentPage() +{ + // Rebuild the page from the new templates path: + int page = m_notebook->GetSelection(); + + if( page < 0 ) + return; // Should not happen + + wxString title = m_notebook->GetPageText( page ); + wxString currPath = m_tcTemplatePath->GetValue(); + + m_notebook->DeletePage( page ); + + wxNotebookPage* newPage = new wxNotebookPage( m_notebook, wxID_ANY ); + TEMPLATE_SELECTION_PANEL* tpanel = new TEMPLATE_SELECTION_PANEL( newPage, currPath ); + m_panels[page] = tpanel; + m_notebook->InsertPage( page, newPage, title, true ); + + buildPageContent( m_tcTemplatePath->GetValue(), page ); + + m_selectedWidget = NULL; +} + + +void DIALOG_TEMPLATE_SELECTOR::OnHtmlLinkActivated( wxHtmlLinkEvent& event ) +{ + wxString url = event.GetLinkInfo().GetHref(); + wxLaunchDefaultBrowser( url); +} diff --git a/kicad/dialogs/dialog_template_selector.fbp b/kicad/dialogs/dialog_template_selector.fbp new file mode 100644 index 0000000..687a923 --- /dev/null +++ b/kicad/dialogs/dialog_template_selector.fbp @@ -0,0 +1,1105 @@ + + + + + + C++ + 1 + source_name + 0 + 0 + res + UTF-8 + connect + dialog_template_selector_base + 1000 + none + 1 + DIALOG_TEMPLATE_SELECTOR_BASE + + . + + 1 + 1 + 1 + 1 + UI + 0 + 0 + + 0 + wxAUI_MGR_DEFAULT + + wxBOTH + + 1 + 1 + impl_virtual + + + + 0 + wxID_ANY + + 640,480 + DIALOG_TEMPLATE_SELECTOR_BASE + + 640,480 + wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER + DIALOG_SHIM; dialog_shim.h + Project Template Selector + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + bmainSizer + wxVERTICAL + none + + 3 + wxEXPAND | wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + -1,-1 + + 0 + -1,-1 + 1 + m_notebook + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + + + + + + + + + + + + + + + + + OnPageChange + + + + + + + + + + + + 3 + wxALL|wxEXPAND + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_htmlWin + 1 + + + protected + 1 + + Resizable + 1 + -1,-1 + wxHW_SCROLLBAR_AUTO + + 0 + + + + + + + + + + OnHtmlLinkActivated + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxTOP|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Template path + + 0 + + + 0 + + 1 + m_staticTextTpath + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 0 + + + bsizerTemplateSelector + wxHORIZONTAL + none + + 5 + wxBOTTOM|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + + 0 + + 1 + m_tcTemplatePath + 1 + + + protected + 1 + + Resizable + 1 + + wxTE_PROCESS_ENTER + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Browse + + 0 + + + 0 + + 1 + m_buttonBrowse + 1 + + + protected + 1 + + Resizable + 1 + + wxBU_EXACTFIT + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + onDirectoryBrowseClicked + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Validate + + 0 + + + 0 + + 1 + m_buttonValidate + 1 + + + protected + 1 + + Resizable + 1 + + wxBU_EXACTFIT + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + onValidatePath + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND | wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_staticline + 1 + + + protected + 1 + + Resizable + 1 + + wxLI_HORIZONTAL + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 3 + wxALL|wxEXPAND + 0 + + 0 + 1 + 0 + 0 + 0 + 1 + 0 + 0 + + m_sdbSizer + protected + + + + + + + + + + + + + + 0 + wxAUI_MGR_DEFAULT + + + 1 + 1 + impl_virtual + + + 0 + wxID_ANY + -1,-1 + -1,-1 + TEMPLATE_SELECTION_PANEL_BASE + + -1,140 + + + + + wxNO_BORDER|wxTAB_TRAVERSAL + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + m_SizerBase + wxHORIZONTAL + public + + 3 + wxEXPAND | wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_scrolledWindow + 1 + + + public + 1 + + Resizable + 5 + 5 + 1 + + + 0 + + + + wxHSCROLL + + + + + + + + + + + + + + + + + + + + + + + + + + m_SizerChoice + wxHORIZONTAL + public + + + + + + + 0 + wxAUI_MGR_DEFAULT + + + 1 + 1 + impl_virtual + + + 0 + wxID_ANY + 74,-1 + 74,-1 + TEMPLATE_WIDGET_BASE + + 74,-1 + + + + + wxTAB_TRAVERSAL + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + bSizer4 + wxVERTICAL + none + + 3 + wxALIGN_CENTER_HORIZONTAL|wxALL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_bitmapIcon + 1 + + + protected + 1 + + Resizable + 1 + 64,64 + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 3 + wxALIGN_CENTER_HORIZONTAL|wxALL|wxEXPAND + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Project Template Title + + 0 + + + 0 + + 1 + m_staticTitle + 1 + + + protected + 1 + + Resizable + 1 + + wxALIGN_CENTRE + + 0 + + + + + 150 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/kicad/dialogs/dialog_template_selector.h b/kicad/dialogs/dialog_template_selector.h new file mode 100644 index 0000000..17a7a62 --- /dev/null +++ b/kicad/dialogs/dialog_template_selector.h @@ -0,0 +1,128 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2012 Brian Sidebotham + * Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef PROJECT_TEMPLATE_SELECTOR_H +#define PROJECT_TEMPLATE_SELECTOR_H + +#include +#include "project_template.h" + +class DIALOG_TEMPLATE_SELECTOR; + +class TEMPLATE_WIDGET : public TEMPLATE_WIDGET_BASE +{ +protected: + DIALOG_TEMPLATE_SELECTOR* m_dialog; + wxWindow* m_parent; + wxPanel* m_panel; + bool m_selected; + + PROJECT_TEMPLATE* m_currTemplate; + + void OnKillFocus( wxFocusEvent& event ); + void OnMouse( wxMouseEvent& event ); + +public: + TEMPLATE_WIDGET( wxWindow* aParent, DIALOG_TEMPLATE_SELECTOR* aDialog ); + + /** + * Set the project template for this widget, which will determine the icon and title + * associated with this project template widget + */ + void SetTemplate(PROJECT_TEMPLATE* aTemplate); + + PROJECT_TEMPLATE* GetTemplate() { return m_currTemplate; } + + void Select(); + void Unselect(); + +private: + bool IsSelected() { return m_selected; } +}; + + +class TEMPLATE_SELECTION_PANEL : public TEMPLATE_SELECTION_PANEL_BASE +{ +protected: + wxNotebookPage* m_parent; + wxString m_templatesPath; ///< the path to access to the folder + ///< containing the templates (which are also folders) + +public: + /** + * @param aParent The window creating the dialog + * @param aPath the path + */ + TEMPLATE_SELECTION_PANEL( wxNotebookPage* aParent, const wxString& aPath ); + + const wxString& GetPath() { return m_templatesPath; } +}; + + +class DIALOG_TEMPLATE_SELECTOR : public DIALOG_TEMPLATE_SELECTOR_BASE +{ +protected: + std::vector m_panels; + TEMPLATE_WIDGET* m_selectedWidget; + + void AddTemplate( int aPage, PROJECT_TEMPLATE* aTemplate ); + +public: + DIALOG_TEMPLATE_SELECTOR( wxWindow* aParent ); + + /** + * Add a new page with \a aTitle, populated with templates from \a aPath + * - All directories under the path are treated as templates + * @param aTitle = the title of the wxNoteBook page + * @param aPath = the path of the main folder containing templates + */ + void AddTemplatesPage( const wxString& aTitle, wxFileName& aPath ); + + /** + * @return the selected template, or NULL + */ + PROJECT_TEMPLATE* GetSelectedTemplate(); + +private: + + void SetHtml( wxFileName aFilename ) + { + m_htmlWin->LoadPage( aFilename.GetFullPath() ); + } + +public: + void SetWidget( TEMPLATE_WIDGET* aWidget ); + +private: + void buildPageContent( const wxString& aPath, int aPage ); + void replaceCurrentPage(); + + void onNotebookResize( wxSizeEvent& event ); + void OnPageChange( wxNotebookEvent& event ); + void onDirectoryBrowseClicked( wxCommandEvent& event ); + void onValidatePath( wxCommandEvent& event ); + void OnHtmlLinkActivated( wxHtmlLinkEvent& event ); +}; + +#endif diff --git a/kicad/dialogs/dialog_template_selector_base.cpp b/kicad/dialogs/dialog_template_selector_base.cpp new file mode 100644 index 0000000..7328f89 --- /dev/null +++ b/kicad/dialogs/dialog_template_selector_base.cpp @@ -0,0 +1,125 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Jun 17 2015) +// http://www.wxformbuilder.org/ +// +// PLEASE DO "NOT" EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#include "dialog_template_selector_base.h" + +/////////////////////////////////////////////////////////////////////////// + +DIALOG_TEMPLATE_SELECTOR_BASE::DIALOG_TEMPLATE_SELECTOR_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style ) +{ + this->SetSizeHints( wxSize( 640,480 ), wxDefaultSize ); + + wxBoxSizer* bmainSizer; + bmainSizer = new wxBoxSizer( wxVERTICAL ); + + m_notebook = new wxNotebook( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); + + bmainSizer->Add( m_notebook, 0, wxEXPAND | wxALL, 3 ); + + m_htmlWin = new wxHtmlWindow( this, wxID_ANY, wxDefaultPosition, wxSize( -1,-1 ), wxHW_SCROLLBAR_AUTO ); + bmainSizer->Add( m_htmlWin, 1, wxALL|wxEXPAND, 3 ); + + m_staticTextTpath = new wxStaticText( this, wxID_ANY, _("Template path"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticTextTpath->Wrap( -1 ); + bmainSizer->Add( m_staticTextTpath, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); + + wxBoxSizer* bsizerTemplateSelector; + bsizerTemplateSelector = new wxBoxSizer( wxHORIZONTAL ); + + m_tcTemplatePath = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER ); + bsizerTemplateSelector->Add( m_tcTemplatePath, 1, wxBOTTOM|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 ); + + m_buttonBrowse = new wxButton( this, wxID_ANY, _("Browse"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT ); + bsizerTemplateSelector->Add( m_buttonBrowse, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT, 5 ); + + m_buttonValidate = new wxButton( this, wxID_ANY, _("Validate"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT ); + bsizerTemplateSelector->Add( m_buttonValidate, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT, 5 ); + + + bmainSizer->Add( bsizerTemplateSelector, 0, wxEXPAND, 5 ); + + m_staticline = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); + bmainSizer->Add( m_staticline, 0, wxEXPAND | wxALL, 5 ); + + m_sdbSizer = new wxStdDialogButtonSizer(); + m_sdbSizerOK = new wxButton( this, wxID_OK ); + m_sdbSizer->AddButton( m_sdbSizerOK ); + m_sdbSizerCancel = new wxButton( this, wxID_CANCEL ); + m_sdbSizer->AddButton( m_sdbSizerCancel ); + m_sdbSizer->Realize(); + + bmainSizer->Add( m_sdbSizer, 0, wxALL|wxEXPAND, 3 ); + + + this->SetSizer( bmainSizer ); + this->Layout(); + + this->Centre( wxBOTH ); + + // Connect Events + m_notebook->Connect( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, wxNotebookEventHandler( DIALOG_TEMPLATE_SELECTOR_BASE::OnPageChange ), NULL, this ); + m_htmlWin->Connect( wxEVT_COMMAND_HTML_LINK_CLICKED, wxHtmlLinkEventHandler( DIALOG_TEMPLATE_SELECTOR_BASE::OnHtmlLinkActivated ), NULL, this ); + m_buttonBrowse->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_TEMPLATE_SELECTOR_BASE::onDirectoryBrowseClicked ), NULL, this ); + m_buttonValidate->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_TEMPLATE_SELECTOR_BASE::onValidatePath ), NULL, this ); +} + +DIALOG_TEMPLATE_SELECTOR_BASE::~DIALOG_TEMPLATE_SELECTOR_BASE() +{ + // Disconnect Events + m_notebook->Disconnect( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, wxNotebookEventHandler( DIALOG_TEMPLATE_SELECTOR_BASE::OnPageChange ), NULL, this ); + m_htmlWin->Disconnect( wxEVT_COMMAND_HTML_LINK_CLICKED, wxHtmlLinkEventHandler( DIALOG_TEMPLATE_SELECTOR_BASE::OnHtmlLinkActivated ), NULL, this ); + m_buttonBrowse->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_TEMPLATE_SELECTOR_BASE::onDirectoryBrowseClicked ), NULL, this ); + m_buttonValidate->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_TEMPLATE_SELECTOR_BASE::onValidatePath ), NULL, this ); + +} + +TEMPLATE_SELECTION_PANEL_BASE::TEMPLATE_SELECTION_PANEL_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style ) : wxPanel( parent, id, pos, size, style ) +{ + m_SizerBase = new wxBoxSizer( wxHORIZONTAL ); + + m_scrolledWindow = new wxScrolledWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL ); + m_scrolledWindow->SetScrollRate( 5, 5 ); + m_SizerChoice = new wxBoxSizer( wxHORIZONTAL ); + + + m_scrolledWindow->SetSizer( m_SizerChoice ); + m_scrolledWindow->Layout(); + m_SizerChoice->Fit( m_scrolledWindow ); + m_SizerBase->Add( m_scrolledWindow, 0, wxEXPAND | wxALL, 3 ); + + + this->SetSizer( m_SizerBase ); + this->Layout(); +} + +TEMPLATE_SELECTION_PANEL_BASE::~TEMPLATE_SELECTION_PANEL_BASE() +{ +} + +TEMPLATE_WIDGET_BASE::TEMPLATE_WIDGET_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style ) : wxPanel( parent, id, pos, size, style ) +{ + this->SetMinSize( wxSize( 74,-1 ) ); + this->SetMaxSize( wxSize( 74,-1 ) ); + + wxBoxSizer* bSizer4; + bSizer4 = new wxBoxSizer( wxVERTICAL ); + + m_bitmapIcon = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 64,64 ), 0 ); + bSizer4->Add( m_bitmapIcon, 0, wxALIGN_CENTER_HORIZONTAL|wxALL|wxEXPAND, 3 ); + + m_staticTitle = new wxStaticText( this, wxID_ANY, _("Project Template Title"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE ); + m_staticTitle->Wrap( 150 ); + bSizer4->Add( m_staticTitle, 1, wxALIGN_CENTER_HORIZONTAL|wxALL|wxEXPAND, 3 ); + + + this->SetSizer( bSizer4 ); + this->Layout(); +} + +TEMPLATE_WIDGET_BASE::~TEMPLATE_WIDGET_BASE() +{ +} diff --git a/kicad/dialogs/dialog_template_selector_base.h b/kicad/dialogs/dialog_template_selector_base.h new file mode 100644 index 0000000..6bfcbea --- /dev/null +++ b/kicad/dialogs/dialog_template_selector_base.h @@ -0,0 +1,110 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Jun 17 2015) +// http://www.wxformbuilder.org/ +// +// PLEASE DO "NOT" EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#ifndef __DIALOG_TEMPLATE_SELECTOR_BASE_H__ +#define __DIALOG_TEMPLATE_SELECTOR_BASE_H__ + +#include +#include +#include +class DIALOG_SHIM; + +#include "dialog_shim.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/////////////////////////////////////////////////////////////////////////// + + +/////////////////////////////////////////////////////////////////////////////// +/// Class DIALOG_TEMPLATE_SELECTOR_BASE +/////////////////////////////////////////////////////////////////////////////// +class DIALOG_TEMPLATE_SELECTOR_BASE : public DIALOG_SHIM +{ + private: + + protected: + wxNotebook* m_notebook; + wxHtmlWindow* m_htmlWin; + wxStaticText* m_staticTextTpath; + wxTextCtrl* m_tcTemplatePath; + wxButton* m_buttonBrowse; + wxButton* m_buttonValidate; + wxStaticLine* m_staticline; + wxStdDialogButtonSizer* m_sdbSizer; + wxButton* m_sdbSizerOK; + wxButton* m_sdbSizerCancel; + + // Virtual event handlers, overide them in your derived class + virtual void OnPageChange( wxNotebookEvent& event ) { event.Skip(); } + virtual void OnHtmlLinkActivated( wxHtmlLinkEvent& event ) { event.Skip(); } + virtual void onDirectoryBrowseClicked( wxCommandEvent& event ) { event.Skip(); } + virtual void onValidatePath( wxCommandEvent& event ) { event.Skip(); } + + + public: + + DIALOG_TEMPLATE_SELECTOR_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Project Template Selector"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 640,480 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + ~DIALOG_TEMPLATE_SELECTOR_BASE(); + +}; + +/////////////////////////////////////////////////////////////////////////////// +/// Class TEMPLATE_SELECTION_PANEL_BASE +/////////////////////////////////////////////////////////////////////////////// +class TEMPLATE_SELECTION_PANEL_BASE : public wxPanel +{ + private: + + protected: + + public: + wxBoxSizer* m_SizerBase; + wxScrolledWindow* m_scrolledWindow; + wxBoxSizer* m_SizerChoice; + + TEMPLATE_SELECTION_PANEL_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,140 ), long style = wxNO_BORDER|wxTAB_TRAVERSAL ); + ~TEMPLATE_SELECTION_PANEL_BASE(); + +}; + +/////////////////////////////////////////////////////////////////////////////// +/// Class TEMPLATE_WIDGET_BASE +/////////////////////////////////////////////////////////////////////////////// +class TEMPLATE_WIDGET_BASE : public wxPanel +{ + private: + + protected: + wxStaticBitmap* m_bitmapIcon; + wxStaticText* m_staticTitle; + + public: + + TEMPLATE_WIDGET_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 74,-1 ), long style = wxTAB_TRAVERSAL ); + ~TEMPLATE_WIDGET_BASE(); + +}; + +#endif //__DIALOG_TEMPLATE_SELECTOR_BASE_H__ -- cgit