Commit 43afa81a authored by jean-pierre charras's avatar jean-pierre charras

Kicad template selector dialog: add info line showing the template path in use.

parent 5560cb54
...@@ -28,10 +28,12 @@ ...@@ -28,10 +28,12 @@
#include <wx/settings.h> #include <wx/settings.h>
TEMPLATE_SELECTION_PANEL::TEMPLATE_SELECTION_PANEL( wxWindow* aParent ) : TEMPLATE_SELECTION_PANEL::TEMPLATE_SELECTION_PANEL( wxWindow* aParent,
const wxString& aPath ) :
TEMPLATE_SELECTION_PANEL_BASE( aParent ) TEMPLATE_SELECTION_PANEL_BASE( aParent )
{ {
parent = aParent; parent = aParent;
m_templatesPath = aPath;
} }
...@@ -127,6 +129,13 @@ void DIALOG_TEMPLATE_SELECTOR::onNotebookResize(wxSizeEvent& event) ...@@ -127,6 +129,13 @@ void DIALOG_TEMPLATE_SELECTOR::onNotebookResize(wxSizeEvent& event)
event.Skip(); event.Skip();
} }
void DIALOG_TEMPLATE_SELECTOR::OnPageChange( wxNotebookEvent& event )
{
int page = m_notebook->GetSelection();
if( page != wxNOT_FOUND )
m_textCtrlTemplatePath->SetValue( m_panels[page]->GetPath() );
}
DIALOG_TEMPLATE_SELECTOR::DIALOG_TEMPLATE_SELECTOR( wxWindow* aParent ) : DIALOG_TEMPLATE_SELECTOR::DIALOG_TEMPLATE_SELECTOR( wxWindow* aParent ) :
DIALOG_TEMPLATE_SELECTOR_BASE( aParent ) DIALOG_TEMPLATE_SELECTOR_BASE( aParent )
...@@ -186,15 +195,19 @@ void DIALOG_TEMPLATE_SELECTOR::AddPage( const wxString& aTitle, wxFileName& aPat ...@@ -186,15 +195,19 @@ void DIALOG_TEMPLATE_SELECTOR::AddPage( const wxString& aTitle, wxFileName& aPat
wxNotebookPage* newPage = new wxNotebookPage( m_notebook, wxID_ANY ); wxNotebookPage* newPage = new wxNotebookPage( m_notebook, wxID_ANY );
m_notebook->AddPage( newPage, aTitle ); m_notebook->AddPage( newPage, aTitle );
TEMPLATE_SELECTION_PANEL* p = new TEMPLATE_SELECTION_PANEL( newPage ); wxString path = aPath.GetFullPath(); // caller ensures this ends with file separator.
m_panels.push_back( p );
TEMPLATE_SELECTION_PANEL* tpanel = new TEMPLATE_SELECTION_PANEL( newPage, path );
m_panels.push_back( tpanel );
if( m_notebook->GetPageCount() == 1 )
m_textCtrlTemplatePath->SetValue( path );
// Get a list of files under the template path to include as choices... // Get a list of files under the template path to include as choices...
wxArrayString files; wxArrayString files;
wxDir dir; wxDir dir;
wxString path = aPath.GetFullPath(); // caller ensures this ends with file separator.
if( dir.Open( path ) ) if( dir.Open( path ) )
{ {
wxDir sub_dir; wxDir sub_dir;
......
This diff is collapsed.
...@@ -60,13 +60,16 @@ class TEMPLATE_SELECTION_PANEL : public TEMPLATE_SELECTION_PANEL_BASE ...@@ -60,13 +60,16 @@ class TEMPLATE_SELECTION_PANEL : public TEMPLATE_SELECTION_PANEL_BASE
{ {
protected: protected:
wxWindow* parent; wxWindow* parent;
wxString m_templatesPath;
public: public:
/** /**
* @param aParent The window creating the dialog * @param aParent The window creating the dialog
*/ */
TEMPLATE_SELECTION_PANEL( wxWindow* aParent ); TEMPLATE_SELECTION_PANEL( wxWindow* aParent, const wxString& aPath );
~TEMPLATE_SELECTION_PANEL(); ~TEMPLATE_SELECTION_PANEL();
const wxString& GetPath() { return m_templatesPath; }
}; };
class DIALOG_TEMPLATE_SELECTOR : public DIALOG_TEMPLATE_SELECTOR_BASE class DIALOG_TEMPLATE_SELECTOR : public DIALOG_TEMPLATE_SELECTOR_BASE
...@@ -81,15 +84,15 @@ public: ...@@ -81,15 +84,15 @@ public:
~DIALOG_TEMPLATE_SELECTOR(); ~DIALOG_TEMPLATE_SELECTOR();
/** /**
* Add a new page with \a aTitle, populated with templates from \a aPath - All directories * Add a new page with \a aTitle, populated with templates from \a aPath
* directories under the path are treated as templates * - All directories under the path are treated as templates
*/ */
void AddPage( const wxString& aTitle, wxFileName& aPath ); void AddPage( const wxString& aTitle, wxFileName& aPath );
void SetHtml( wxFileName aFilename ); void SetHtml( wxFileName aFilename );
TEMPLATE_WIDGET* GetWidget(); TEMPLATE_WIDGET* GetWidget();
void SetWidget( TEMPLATE_WIDGET* aWidget ); void SetWidget( TEMPLATE_WIDGET* aWidget );
void onNotebookResize(wxSizeEvent& event); void onNotebookResize( wxSizeEvent& event );
void OnPageChange( wxNotebookEvent& event );
}; };
#endif #endif
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 10 2012) // C++ code generated with wxFormBuilder (version Oct 8 2012)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO "NOT" EDIT THIS FILE! // PLEASE DO "NOT" EDIT THIS FILE!
...@@ -12,52 +12,65 @@ ...@@ -12,52 +12,65 @@
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 ) 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 ); this->SetSizeHints( wxSize( 640,480 ), wxDefaultSize );
wxBoxSizer* bSizer1; wxBoxSizer* bmainSizer;
bSizer1 = new wxBoxSizer( wxVERTICAL ); bmainSizer = new wxBoxSizer( wxVERTICAL );
m_notebook = new wxNotebook( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); m_notebook = new wxNotebook( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
bSizer1->Add( m_notebook, 0, wxEXPAND | wxALL, 3 ); bmainSizer->Add( m_notebook, 0, wxEXPAND | wxALL, 3 );
m_htmlWin = new wxHtmlWindow( this, wxID_ANY, wxDefaultPosition, wxSize( -1,-1 ), wxHW_SCROLLBAR_AUTO ); m_htmlWin = new wxHtmlWindow( this, wxID_ANY, wxDefaultPosition, wxSize( -1,-1 ), wxHW_SCROLLBAR_AUTO );
bSizer1->Add( m_htmlWin, 1, wxALL|wxEXPAND, 3 ); bmainSizer->Add( m_htmlWin, 1, wxALL|wxEXPAND, 3 );
m_sdbSizer1 = new wxStdDialogButtonSizer(); m_staticTextTpath = new wxStaticText( this, wxID_ANY, wxT("Templates path"), wxDefaultPosition, wxDefaultSize, 0 );
m_sdbSizer1OK = new wxButton( this, wxID_OK ); m_staticTextTpath->Wrap( -1 );
m_sdbSizer1->AddButton( m_sdbSizer1OK ); bmainSizer->Add( m_staticTextTpath, 0, wxRIGHT|wxLEFT, 5 );
m_sdbSizer1Cancel = new wxButton( this, wxID_CANCEL );
m_sdbSizer1->AddButton( m_sdbSizer1Cancel ); m_textCtrlTemplatePath = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY );
m_sdbSizer1->Realize(); bmainSizer->Add( m_textCtrlTemplatePath, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
bSizer1->Add( m_sdbSizer1, 0, wxALL|wxEXPAND, 3 ); m_sdbSizer = new wxStdDialogButtonSizer();
m_sdbSizerOK = new wxButton( this, wxID_OK );
m_sdbSizer->AddButton( m_sdbSizerOK );
this->SetSizer( bSizer1 ); 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->Layout();
this->Centre( wxBOTH ); this->Centre( wxBOTH );
// Connect Events
m_notebook->Connect( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, wxNotebookEventHandler( DIALOG_TEMPLATE_SELECTOR_BASE::OnPageChange ), NULL, this );
} }
DIALOG_TEMPLATE_SELECTOR_BASE::~DIALOG_TEMPLATE_SELECTOR_BASE() 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 );
} }
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 ) 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_SizerBase = new wxBoxSizer( wxHORIZONTAL );
m_scrolledWindow1 = new wxScrolledWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL ); m_scrolledWindow1 = new wxScrolledWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL );
m_scrolledWindow1->SetScrollRate( 5, 5 ); m_scrolledWindow1->SetScrollRate( 5, 5 );
m_SizerChoice = new wxBoxSizer( wxHORIZONTAL ); m_SizerChoice = new wxBoxSizer( wxHORIZONTAL );
m_scrolledWindow1->SetSizer( m_SizerChoice ); m_scrolledWindow1->SetSizer( m_SizerChoice );
m_scrolledWindow1->Layout(); m_scrolledWindow1->Layout();
m_SizerChoice->Fit( m_scrolledWindow1 ); m_SizerChoice->Fit( m_scrolledWindow1 );
m_SizerBase->Add( m_scrolledWindow1, 0, wxEXPAND | wxALL, 3 ); m_SizerBase->Add( m_scrolledWindow1, 0, wxEXPAND | wxALL, 3 );
this->SetSizer( m_SizerBase ); this->SetSizer( m_SizerBase );
this->Layout(); this->Layout();
} }
...@@ -70,18 +83,18 @@ TEMPLATE_WIDGET_BASE::TEMPLATE_WIDGET_BASE( wxWindow* parent, wxWindowID id, con ...@@ -70,18 +83,18 @@ TEMPLATE_WIDGET_BASE::TEMPLATE_WIDGET_BASE( wxWindow* parent, wxWindowID id, con
{ {
this->SetMinSize( wxSize( 74,-1 ) ); this->SetMinSize( wxSize( 74,-1 ) );
this->SetMaxSize( wxSize( 74,-1 ) ); this->SetMaxSize( wxSize( 74,-1 ) );
wxBoxSizer* bSizer4; wxBoxSizer* bSizer4;
bSizer4 = new wxBoxSizer( wxVERTICAL ); bSizer4 = new wxBoxSizer( wxVERTICAL );
m_bitmapIcon = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 64,64 ), 0 ); m_bitmapIcon = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 64,64 ), 0 );
bSizer4->Add( m_bitmapIcon, 0, wxALIGN_CENTER_HORIZONTAL|wxALL|wxEXPAND, 3 ); bSizer4->Add( m_bitmapIcon, 0, wxALIGN_CENTER_HORIZONTAL|wxALL|wxEXPAND, 3 );
m_staticTitle = new wxStaticText( this, wxID_ANY, wxT("Project Template Title"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE ); m_staticTitle = new wxStaticText( this, wxID_ANY, wxT("Project Template Title"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE );
m_staticTitle->Wrap( 150 ); m_staticTitle->Wrap( 150 );
bSizer4->Add( m_staticTitle, 1, wxALIGN_CENTER_HORIZONTAL|wxALL|wxEXPAND, 3 ); bSizer4->Add( m_staticTitle, 1, wxALIGN_CENTER_HORIZONTAL|wxALL|wxEXPAND, 3 );
this->SetSizer( bSizer4 ); this->SetSizer( bSizer4 );
this->Layout(); this->Layout();
} }
......
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 10 2012) // C++ code generated with wxFormBuilder (version Oct 8 2012)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO "NOT" EDIT THIS FILE! // PLEASE DO "NOT" EDIT THIS FILE!
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
#include <wx/artprov.h> #include <wx/artprov.h>
#include <wx/xrc/xmlres.h> #include <wx/xrc/xmlres.h>
class DIALOG_SHIM;
#include "dialog_shim.h" #include "dialog_shim.h"
#include <wx/gdicmn.h> #include <wx/gdicmn.h>
#include <wx/notebook.h> #include <wx/notebook.h>
...@@ -18,6 +20,8 @@ ...@@ -18,6 +20,8 @@
#include <wx/settings.h> #include <wx/settings.h>
#include <wx/string.h> #include <wx/string.h>
#include <wx/html/htmlwin.h> #include <wx/html/htmlwin.h>
#include <wx/stattext.h>
#include <wx/textctrl.h>
#include <wx/sizer.h> #include <wx/sizer.h>
#include <wx/button.h> #include <wx/button.h>
#include <wx/dialog.h> #include <wx/dialog.h>
...@@ -27,7 +31,6 @@ ...@@ -27,7 +31,6 @@
#include <wx/image.h> #include <wx/image.h>
#include <wx/icon.h> #include <wx/icon.h>
#include <wx/statbmp.h> #include <wx/statbmp.h>
#include <wx/stattext.h>
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
...@@ -38,56 +41,62 @@ ...@@ -38,56 +41,62 @@
class DIALOG_TEMPLATE_SELECTOR_BASE : public DIALOG_SHIM class DIALOG_TEMPLATE_SELECTOR_BASE : public DIALOG_SHIM
{ {
private: private:
protected: protected:
wxNotebook* m_notebook; wxNotebook* m_notebook;
wxHtmlWindow* m_htmlWin; wxHtmlWindow* m_htmlWin;
wxStdDialogButtonSizer* m_sdbSizer1; wxStaticText* m_staticTextTpath;
wxButton* m_sdbSizer1OK; wxTextCtrl* m_textCtrlTemplatePath;
wxButton* m_sdbSizer1Cancel; 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(); }
public: public:
DIALOG_TEMPLATE_SELECTOR_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Project Template Selector"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 640,480 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); DIALOG_TEMPLATE_SELECTOR_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Project Template Selector"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 640,480 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DIALOG_TEMPLATE_SELECTOR_BASE(); ~DIALOG_TEMPLATE_SELECTOR_BASE();
}; };
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
/// Class TEMPLATE_SELECTION_PANEL_BASE /// Class TEMPLATE_SELECTION_PANEL_BASE
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
class TEMPLATE_SELECTION_PANEL_BASE : public wxPanel class TEMPLATE_SELECTION_PANEL_BASE : public wxPanel
{ {
private: private:
protected: protected:
public: public:
wxBoxSizer* m_SizerBase; wxBoxSizer* m_SizerBase;
wxScrolledWindow* m_scrolledWindow1; wxScrolledWindow* m_scrolledWindow1;
wxBoxSizer* m_SizerChoice; 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( 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(); ~TEMPLATE_SELECTION_PANEL_BASE();
}; };
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
/// Class TEMPLATE_WIDGET_BASE /// Class TEMPLATE_WIDGET_BASE
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
class TEMPLATE_WIDGET_BASE : public wxPanel class TEMPLATE_WIDGET_BASE : public wxPanel
{ {
private: private:
protected: protected:
wxStaticBitmap* m_bitmapIcon; wxStaticBitmap* m_bitmapIcon;
wxStaticText* m_staticTitle; wxStaticText* m_staticTitle;
public: 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( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 74,-1 ), long style = wxTAB_TRAVERSAL );
~TEMPLATE_WIDGET_BASE(); ~TEMPLATE_WIDGET_BASE();
}; };
#endif //__DIALOG_TEMPLATE_SELECTOR_BASE_H__ #endif //__DIALOG_TEMPLATE_SELECTOR_BASE_H__
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment