From e74eccede30d6f61f319f9021cae4e8d4f5c2d72 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sat, 16 May 2015 11:20:26 +0200 Subject: [PATCH] Kicad manager: Allows the selection of templates paths, in template selector dialog. --- kicad/dialogs/dialog_template_selector.cpp | 173 ++++++---- kicad/dialogs/dialog_template_selector.fbp | 304 +++++++++++++++++- kicad/dialogs/dialog_template_selector.h | 61 ++-- .../dialogs/dialog_template_selector_base.cpp | 39 ++- kicad/dialogs/dialog_template_selector_base.h | 14 +- kicad/prjconfig.cpp | 12 +- 6 files changed, 482 insertions(+), 121 deletions(-) diff --git a/kicad/dialogs/dialog_template_selector.cpp b/kicad/dialogs/dialog_template_selector.cpp index cb040c7d01..89a942f58d 100644 --- a/kicad/dialogs/dialog_template_selector.cpp +++ b/kicad/dialogs/dialog_template_selector.cpp @@ -28,28 +28,22 @@ #include -TEMPLATE_SELECTION_PANEL::TEMPLATE_SELECTION_PANEL( wxWindow* aParent, +TEMPLATE_SELECTION_PANEL::TEMPLATE_SELECTION_PANEL( wxNotebookPage* aParent, const wxString& aPath ) : TEMPLATE_SELECTION_PANEL_BASE( aParent ) { - parent = aParent; + m_parent = aParent; m_templatesPath = aPath; } -TEMPLATE_SELECTION_PANEL::~TEMPLATE_SELECTION_PANEL() -{ - -} - - -TEMPLATE_WIDGET::TEMPLATE_WIDGET( wxWindow* aParent, wxDialog* aDialog ) : +TEMPLATE_WIDGET::TEMPLATE_WIDGET( wxWindow* aParent, DIALOG_TEMPLATE_SELECTOR* aDialog ) : TEMPLATE_WIDGET_BASE( aParent ) { - parent = aParent; - dialog = aDialog; + m_parent = aParent; + m_dialog = aDialog; - // wxWidgets 2.9.x way of doing the same... + // 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 ); @@ -59,21 +53,15 @@ TEMPLATE_WIDGET::TEMPLATE_WIDGET( wxWindow* aParent, wxDialog* aDialog ) : Unselect(); // Start with template being NULL - templ = NULL; + m_currTemplate = NULL; } -TEMPLATE_WIDGET::~TEMPLATE_WIDGET() -{ - -} - void TEMPLATE_WIDGET::Select() { - DIALOG_TEMPLATE_SELECTOR* d = (DIALOG_TEMPLATE_SELECTOR*)dialog; - d->SetWidget( this ); + m_dialog->SetWidget( this ); SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNHIGHLIGHT ) ); - selected = true; + m_selected = true; Refresh(); } @@ -81,26 +69,14 @@ void TEMPLATE_WIDGET::Select() void TEMPLATE_WIDGET::Unselect() { SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE ) ); - selected = false; + m_selected = false; Refresh(); } -bool TEMPLATE_WIDGET::IsSelected() -{ - return selected; -} - - -PROJECT_TEMPLATE* TEMPLATE_WIDGET::GetTemplate() -{ - return templ; -} - - void TEMPLATE_WIDGET::SetTemplate(PROJECT_TEMPLATE* aTemplate) { - templ = aTemplate; + m_currTemplate = aTemplate; m_staticTitle->SetLabel( *(aTemplate->GetTitle()) ); m_bitmapIcon->SetBitmap( *(aTemplate->GetIcon()) ); } @@ -108,7 +84,7 @@ void TEMPLATE_WIDGET::SetTemplate(PROJECT_TEMPLATE* aTemplate) void TEMPLATE_WIDGET::OnMouse( wxMouseEvent& event ) { - /* Toggle selection here */ + // Toggle selection here Select(); event.Skip(); } @@ -120,9 +96,9 @@ void DIALOG_TEMPLATE_SELECTOR::onNotebookResize(wxSizeEvent& event) { m_panels[i]->SetSize( m_notebook->GetSize().GetWidth() - 6, 140 ); m_panels[i]->m_SizerBase->FitInside( m_panels[i] ); - m_panels[i]->m_scrolledWindow1->SetSize( m_panels[i]->GetSize().GetWidth() - 6, + 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_scrolledWindow1 ); + m_panels[i]->m_SizerChoice->FitInside( m_panels[i]->m_scrolledWindow ); } m_notebook->Refresh(); @@ -134,7 +110,7 @@ void DIALOG_TEMPLATE_SELECTOR::OnPageChange( wxNotebookEvent& event ) int page = m_notebook->GetSelection(); if( page != wxNOT_FOUND && (unsigned)page < m_panels.size() ) - m_textCtrlTemplatePath->SetValue( m_panels[page]->GetPath() ); + m_tcTemplatePath->SetValue( m_panels[page]->GetPath() ); } @@ -147,24 +123,6 @@ DIALOG_TEMPLATE_SELECTOR::DIALOG_TEMPLATE_SELECTOR( wxWindow* aParent ) : } -void DIALOG_TEMPLATE_SELECTOR::SetHtml( wxFileName aFilename ) -{ - m_htmlWin->LoadPage( aFilename.GetFullPath() ); -} - - -DIALOG_TEMPLATE_SELECTOR::~DIALOG_TEMPLATE_SELECTOR() -{ - -} - - -TEMPLATE_WIDGET* DIALOG_TEMPLATE_SELECTOR::GetWidget() -{ - return m_selectedWidget; -} - - void DIALOG_TEMPLATE_SELECTOR::SetWidget( TEMPLATE_WIDGET* aWidget ) { if( m_selectedWidget != NULL ) @@ -176,40 +134,51 @@ void DIALOG_TEMPLATE_SELECTOR::SetWidget( TEMPLATE_WIDGET* aWidget ) void DIALOG_TEMPLATE_SELECTOR::AddTemplate( int aPage, PROJECT_TEMPLATE* aTemplate ) { - TEMPLATE_WIDGET* w = new TEMPLATE_WIDGET( m_panels[aPage]->m_scrolledWindow1, this ); + 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_scrolledWindow1->SetSize( m_panels[aPage]->GetSize().GetWidth() - 6, + 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_scrolledWindow1 ); + m_panels[aPage]->m_SizerChoice->FitInside( m_panels[aPage]->m_scrolledWindow ); m_notebook->Refresh(); } -void DIALOG_TEMPLATE_SELECTOR::AddPage( const wxString& aTitle, wxFileName& aPath ) +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 ); - m_notebook->AddPage( newPage, aTitle ); + 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_textCtrlTemplatePath->SetValue( path ); + 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( path ) ) + if( dir.Open( aPath ) ) { wxDir sub_dir; wxString sub_name; @@ -217,16 +186,88 @@ void DIALOG_TEMPLATE_SELECTOR::AddPage( const wxString& aTitle, wxFileName& aPat bool cont = dir.GetFirst( &sub_name, wxEmptyString, wxDIR_DIRS ); while( cont ) { - wxString sub_full = path + sub_name; + 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( m_notebook->GetPageCount() - 1, pt ); + 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; +} diff --git a/kicad/dialogs/dialog_template_selector.fbp b/kicad/dialogs/dialog_template_selector.fbp index c100c43624..6dbe35de94 100644 --- a/kicad/dialogs/dialog_template_selector.fbp +++ b/kicad/dialogs/dialog_template_selector.fbp @@ -1,6 +1,6 @@ - + C++ @@ -20,8 +20,10 @@ . 1 + 1 1 1 + UI 0 0 @@ -261,7 +263,7 @@ 5 - wxRIGHT|wxLEFT + wxTOP|wxRIGHT|wxLEFT 0 1 @@ -344,9 +346,287 @@ 5 - wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT + 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 @@ -377,12 +657,11 @@ 0 - 0 1 - m_textCtrlTemplatePath + m_staticline 1 @@ -392,15 +671,10 @@ Resizable 1 - wxTE_READONLY + wxLI_HORIZONTAL 0 - - wxFILTER_NONE - wxDefaultValidator - - @@ -426,10 +700,6 @@ - - - - @@ -557,7 +827,7 @@ 0 1 - m_scrolledWindow1 + m_scrolledWindow 1 diff --git a/kicad/dialogs/dialog_template_selector.h b/kicad/dialogs/dialog_template_selector.h index 2b59ea66c0..ae3dc2d3c4 100644 --- a/kicad/dialogs/dialog_template_selector.h +++ b/kicad/dialogs/dialog_template_selector.h @@ -28,49 +28,53 @@ #include #include "project_template.h" +class DIALOG_TEMPLATE_SELECTOR; class TEMPLATE_WIDGET : public TEMPLATE_WIDGET_BASE { protected: - wxDialog* dialog; - wxWindow* parent; - wxPanel* panel; - bool selected; + DIALOG_TEMPLATE_SELECTOR* m_dialog; + wxWindow* m_parent; + wxPanel* m_panel; + bool m_selected; - PROJECT_TEMPLATE* templ; + PROJECT_TEMPLATE* m_currTemplate; void OnKillFocus( wxFocusEvent& event ); void OnMouse( wxMouseEvent& event ); public: - TEMPLATE_WIDGET( wxWindow* aParent, wxDialog* aDialog ); - ~TEMPLATE_WIDGET(); + 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(); + + PROJECT_TEMPLATE* GetTemplate() { return m_currTemplate; } + void Select(); void Unselect(); - bool IsSelected(); + +private: + bool IsSelected() { return m_selected; } }; class TEMPLATE_SELECTION_PANEL : public TEMPLATE_SELECTION_PANEL_BASE { protected: - wxWindow* parent; - wxString m_templatesPath; + 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( wxWindow* aParent, const wxString& aPath ); - ~TEMPLATE_SELECTION_PANEL(); + TEMPLATE_SELECTION_PANEL( wxNotebookPage* aParent, const wxString& aPath ); const wxString& GetPath() { return m_templatesPath; } }; @@ -80,23 +84,44 @@ class DIALOG_TEMPLATE_SELECTOR : public DIALOG_TEMPLATE_SELECTOR_BASE { protected: std::vector m_panels; - void AddTemplate( int aPage, PROJECT_TEMPLATE* aTemplate ); TEMPLATE_WIDGET* m_selectedWidget; + void AddTemplate( int aPage, PROJECT_TEMPLATE* aTemplate ); + public: DIALOG_TEMPLATE_SELECTOR( wxWindow* aParent ); - ~DIALOG_TEMPLATE_SELECTOR(); /** * 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 AddPage( const wxString& aTitle, wxFileName& aPath ); - void SetHtml( wxFileName aFilename ); - TEMPLATE_WIDGET* GetWidget(); + 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 ); }; #endif diff --git a/kicad/dialogs/dialog_template_selector_base.cpp b/kicad/dialogs/dialog_template_selector_base.cpp index 6bd4105aa8..fe866c1da5 100644 --- a/kicad/dialogs/dialog_template_selector_base.cpp +++ b/kicad/dialogs/dialog_template_selector_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Oct 8 2012) +// C++ code generated with wxFormBuilder (version Jun 5 2014) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -25,10 +25,25 @@ DIALOG_TEMPLATE_SELECTOR_BASE::DIALOG_TEMPLATE_SELECTOR_BASE( wxWindow* parent, m_staticTextTpath = new wxStaticText( this, wxID_ANY, wxT("Templates path"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextTpath->Wrap( -1 ); - bmainSizer->Add( m_staticTextTpath, 0, wxRIGHT|wxLEFT, 5 ); + bmainSizer->Add( m_staticTextTpath, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); - m_textCtrlTemplatePath = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY ); - bmainSizer->Add( m_textCtrlTemplatePath, 0, wxEXPAND|wxBOTTOM|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, wxT("Browse"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT ); + bsizerTemplateSelector->Add( m_buttonBrowse, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT, 5 ); + + m_buttonValidate = new wxButton( this, wxID_ANY, wxT("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 ); @@ -47,12 +62,16 @@ DIALOG_TEMPLATE_SELECTOR_BASE::DIALOG_TEMPLATE_SELECTOR_BASE( wxWindow* parent, // Connect Events m_notebook->Connect( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, wxNotebookEventHandler( DIALOG_TEMPLATE_SELECTOR_BASE::OnPageChange ), 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_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 ); } @@ -60,15 +79,15 @@ TEMPLATE_SELECTION_PANEL_BASE::TEMPLATE_SELECTION_PANEL_BASE( wxWindow* parent, { m_SizerBase = new wxBoxSizer( wxHORIZONTAL ); - m_scrolledWindow1 = new wxScrolledWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL ); - m_scrolledWindow1->SetScrollRate( 5, 5 ); + m_scrolledWindow = new wxScrolledWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL ); + m_scrolledWindow->SetScrollRate( 5, 5 ); m_SizerChoice = new wxBoxSizer( wxHORIZONTAL ); - m_scrolledWindow1->SetSizer( m_SizerChoice ); - m_scrolledWindow1->Layout(); - m_SizerChoice->Fit( m_scrolledWindow1 ); - m_SizerBase->Add( m_scrolledWindow1, 0, wxEXPAND | wxALL, 3 ); + 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 ); diff --git a/kicad/dialogs/dialog_template_selector_base.h b/kicad/dialogs/dialog_template_selector_base.h index 0ec6f94c63..0e86954f76 100644 --- a/kicad/dialogs/dialog_template_selector_base.h +++ b/kicad/dialogs/dialog_template_selector_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Oct 8 2012) +// C++ code generated with wxFormBuilder (version Jun 5 2014) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -22,8 +22,9 @@ class DIALOG_SHIM; #include #include #include -#include #include +#include +#include #include #include #include @@ -46,13 +47,18 @@ class DIALOG_TEMPLATE_SELECTOR_BASE : public DIALOG_SHIM wxNotebook* m_notebook; wxHtmlWindow* m_htmlWin; wxStaticText* m_staticTextTpath; - wxTextCtrl* m_textCtrlTemplatePath; + 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 onDirectoryBrowseClicked( wxCommandEvent& event ) { event.Skip(); } + virtual void onValidatePath( wxCommandEvent& event ) { event.Skip(); } public: @@ -73,7 +79,7 @@ class TEMPLATE_SELECTION_PANEL_BASE : public wxPanel public: wxBoxSizer* m_SizerBase; - wxScrolledWindow* m_scrolledWindow1; + 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 ); diff --git a/kicad/prjconfig.cpp b/kicad/prjconfig.cpp index b7a2aedfe5..bcac13de69 100644 --- a/kicad/prjconfig.cpp +++ b/kicad/prjconfig.cpp @@ -108,13 +108,13 @@ void KICAD_MANAGER_FRAME::CreateNewProject( const wxString& aPrjFullFileName, templatePath = GetOSXKicadDataDir() + sep + wxT( "template" ); #endif - ps->AddPage( _( "System Templates" ), templatePath ); + ps->AddTemplatesPage( _( "System Templates" ), templatePath ); // Add a new tab for user templates wxFileName userPath = wxStandardPaths::Get().GetDocumentsDir() + sep + wxT( "kicad" ) + sep + wxT( "template" ) + sep; - ps->AddPage( _( "User Templates" ), userPath ); + ps->AddTemplatesPage( _( "User Templates" ), userPath ); // Check to see if a custom template location is available and setup a // new selection tab if there is. @@ -128,15 +128,15 @@ void KICAD_MANAGER_FRAME::CreateNewProject( const wxString& aPrjFullFileName, wxFileName envPath = envStr; - ps->AddPage( _( "Portable Templates" ), envPath ); + ps->AddTemplatesPage( _( "Portable Templates" ), envPath ); } // Show the project template selector dialog int result = ps->ShowModal(); - if( (result != wxID_OK) || (ps->GetWidget() == NULL) ) + if( ( result != wxID_OK ) || ( ps->GetSelectedTemplate() == NULL ) ) { - if( ps->GetWidget() == NULL ) + if( ps->GetSelectedTemplate() == NULL ) { wxMessageBox( _( "No project template was selected. Cannot generate new " "project." ), @@ -149,7 +149,7 @@ void KICAD_MANAGER_FRAME::CreateNewProject( const wxString& aPrjFullFileName, { // The selected template widget contains the template we're attempting to use to // create a project - if( !ps->GetWidget()->GetTemplate()->CreateProject( newProjectName ) ) + if( !ps->GetSelectedTemplate()->CreateProject( newProjectName ) ) { wxMessageBox( _( "Problem whilst creating new project from template!" ), _( "Template Error" ),