diff --git a/kicad/dialogs/dialog_template_selector.cpp b/kicad/dialogs/dialog_template_selector.cpp index ec8ef90c20..cb040c7d01 100644 --- a/kicad/dialogs/dialog_template_selector.cpp +++ b/kicad/dialogs/dialog_template_selector.cpp @@ -28,10 +28,12 @@ #include -TEMPLATE_SELECTION_PANEL::TEMPLATE_SELECTION_PANEL( wxWindow* aParent ) : +TEMPLATE_SELECTION_PANEL::TEMPLATE_SELECTION_PANEL( wxWindow* aParent, + const wxString& aPath ) : TEMPLATE_SELECTION_PANEL_BASE( aParent ) { parent = aParent; + m_templatesPath = aPath; } @@ -127,6 +129,14 @@ void DIALOG_TEMPLATE_SELECTOR::onNotebookResize(wxSizeEvent& event) event.Skip(); } +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() ); +} + DIALOG_TEMPLATE_SELECTOR::DIALOG_TEMPLATE_SELECTOR( wxWindow* aParent ) : DIALOG_TEMPLATE_SELECTOR_BASE( aParent ) @@ -186,15 +196,19 @@ void DIALOG_TEMPLATE_SELECTOR::AddPage( const wxString& aTitle, wxFileName& aPat wxNotebookPage* newPage = new wxNotebookPage( m_notebook, wxID_ANY ); m_notebook->AddPage( newPage, aTitle ); - TEMPLATE_SELECTION_PANEL* p = new TEMPLATE_SELECTION_PANEL( newPage ); - m_panels.push_back( p ); + 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 ); + + if( m_notebook->GetPageCount() == 1 ) + m_textCtrlTemplatePath->SetValue( path ); + // Get a list of files under the template path to include as choices... wxArrayString files; wxDir dir; - wxString path = aPath.GetFullPath(); // caller ensures this ends with file separator. - if( dir.Open( path ) ) { wxDir sub_dir; diff --git a/kicad/dialogs/dialog_template_selector.fbp b/kicad/dialogs/dialog_template_selector.fbp index af5c1529c7..c100c43624 100644 --- a/kicad/dialogs/dialog_template_selector.fbp +++ b/kicad/dialogs/dialog_template_selector.fbp @@ -88,7 +88,7 @@ - bSizer1 + bmainSizer wxVERTICAL none @@ -164,7 +164,7 @@ - + OnPageChange @@ -259,6 +259,180 @@ + + 5 + wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Templates path + + 0 + + + 0 + + 1 + m_staticTextTpath + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + + 0 + + 1 + m_textCtrlTemplatePath + 1 + + + protected + 1 + + Resizable + 1 + + wxTE_READONLY + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 3 wxALL|wxEXPAND @@ -273,7 +447,7 @@ 0 0 - m_sdbSizer1 + m_sdbSizer protected diff --git a/kicad/dialogs/dialog_template_selector.h b/kicad/dialogs/dialog_template_selector.h index e7e9443cad..41006aab25 100644 --- a/kicad/dialogs/dialog_template_selector.h +++ b/kicad/dialogs/dialog_template_selector.h @@ -60,13 +60,16 @@ class TEMPLATE_SELECTION_PANEL : public TEMPLATE_SELECTION_PANEL_BASE { protected: wxWindow* parent; + wxString m_templatesPath; public: /** * @param aParent The window creating the dialog */ - TEMPLATE_SELECTION_PANEL( wxWindow* aParent ); + TEMPLATE_SELECTION_PANEL( wxWindow* aParent, const wxString& aPath ); ~TEMPLATE_SELECTION_PANEL(); + + const wxString& GetPath() { return m_templatesPath; } }; class DIALOG_TEMPLATE_SELECTOR : public DIALOG_TEMPLATE_SELECTOR_BASE @@ -81,15 +84,15 @@ public: ~DIALOG_TEMPLATE_SELECTOR(); /** - * Add a new page with \a aTitle, populated with templates from \a aPath - All directories - * directories under the path are treated as templates + * Add a new page with \a aTitle, populated with templates from \a aPath + * - All directories under the path are treated as templates */ void AddPage( const wxString& aTitle, wxFileName& aPath ); void SetHtml( wxFileName aFilename ); TEMPLATE_WIDGET* GetWidget(); void SetWidget( TEMPLATE_WIDGET* aWidget ); - void onNotebookResize(wxSizeEvent& event); - + void onNotebookResize( wxSizeEvent& event ); + void OnPageChange( wxNotebookEvent& event ); }; #endif diff --git a/kicad/dialogs/dialog_template_selector_base.cpp b/kicad/dialogs/dialog_template_selector_base.cpp index 0f26bba13e..6bd4105aa8 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 Apr 10 2012) +// C++ code generated with wxFormBuilder (version Oct 8 2012) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -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 ) { this->SetSizeHints( wxSize( 640,480 ), wxDefaultSize ); - - wxBoxSizer* bSizer1; - bSizer1 = new wxBoxSizer( wxVERTICAL ); - + + wxBoxSizer* bmainSizer; + bmainSizer = new wxBoxSizer( wxVERTICAL ); + 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 ); - bSizer1->Add( m_htmlWin, 1, wxALL|wxEXPAND, 3 ); - - m_sdbSizer1 = new wxStdDialogButtonSizer(); - m_sdbSizer1OK = new wxButton( this, wxID_OK ); - m_sdbSizer1->AddButton( m_sdbSizer1OK ); - m_sdbSizer1Cancel = new wxButton( this, wxID_CANCEL ); - m_sdbSizer1->AddButton( m_sdbSizer1Cancel ); - m_sdbSizer1->Realize(); - - bSizer1->Add( m_sdbSizer1, 0, wxALL|wxEXPAND, 3 ); - - - this->SetSizer( bSizer1 ); + bmainSizer->Add( m_htmlWin, 1, wxALL|wxEXPAND, 3 ); + + 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 ); + + m_textCtrlTemplatePath = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY ); + bmainSizer->Add( m_textCtrlTemplatePath, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 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 ); } 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 ) { m_SizerBase = new wxBoxSizer( wxHORIZONTAL ); - + m_scrolledWindow1 = new wxScrolledWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL ); m_scrolledWindow1->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 ); - - + + this->SetSizer( m_SizerBase ); this->Layout(); } @@ -70,18 +83,18 @@ TEMPLATE_WIDGET_BASE::TEMPLATE_WIDGET_BASE( wxWindow* parent, wxWindowID id, con { 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, wxT("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(); } diff --git a/kicad/dialogs/dialog_template_selector_base.h b/kicad/dialogs/dialog_template_selector_base.h index 847e4ffda0..0ec6f94c63 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 Apr 10 2012) +// C++ code generated with wxFormBuilder (version Oct 8 2012) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -10,6 +10,8 @@ #include #include +class DIALOG_SHIM; + #include "dialog_shim.h" #include #include @@ -18,6 +20,8 @@ #include #include #include +#include +#include #include #include #include @@ -27,7 +31,6 @@ #include #include #include -#include /////////////////////////////////////////////////////////////////////////// @@ -38,56 +41,62 @@ class DIALOG_TEMPLATE_SELECTOR_BASE : public DIALOG_SHIM { private: - + protected: wxNotebook* m_notebook; wxHtmlWindow* m_htmlWin; - wxStdDialogButtonSizer* m_sdbSizer1; - wxButton* m_sdbSizer1OK; - wxButton* m_sdbSizer1Cancel; - + wxStaticText* m_staticTextTpath; + wxTextCtrl* m_textCtrlTemplatePath; + 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: - - 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(); - + }; /////////////////////////////////////////////////////////////////////////////// /// Class TEMPLATE_SELECTION_PANEL_BASE /////////////////////////////////////////////////////////////////////////////// -class TEMPLATE_SELECTION_PANEL_BASE : public wxPanel +class TEMPLATE_SELECTION_PANEL_BASE : public wxPanel { private: - + protected: - + public: wxBoxSizer* m_SizerBase; wxScrolledWindow* m_scrolledWindow1; 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(); - + }; /////////////////////////////////////////////////////////////////////////////// /// Class TEMPLATE_WIDGET_BASE /////////////////////////////////////////////////////////////////////////////// -class TEMPLATE_WIDGET_BASE : public wxPanel +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( 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__ diff --git a/pcbnew/edit_pcb_text.cpp b/pcbnew/edit_pcb_text.cpp index 3037184890..c7a62aaa01 100644 --- a/pcbnew/edit_pcb_text.cpp +++ b/pcbnew/edit_pcb_text.cpp @@ -208,7 +208,7 @@ TEXTE_PCB* PCB_EDIT_FRAME::CreateTextePcb( wxDC* aDC, TEXTE_PCB* aText ) // Set the mirrored option for layers on the BACK side of the board if( layer == LAYER_N_BACK || layer == SILKSCREEN_N_BACK || - layer == SOLDERPASTE_N_BACK || layer == SOLDERMASK_N_FRONT || + layer == SOLDERPASTE_N_BACK || layer == SOLDERMASK_N_BACK || layer == ADHESIVE_N_BACK ) textePcb->SetMirrored( true ); @@ -241,12 +241,12 @@ void PCB_EDIT_FRAME::Rotate_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC ) if( TextePcb == NULL ) return; - /* Erase previous text. */ + // Erase previous text: TextePcb->Draw( m_canvas, DC, GR_XOR ); TextePcb->SetOrientation( TextePcb->GetOrientation() + angle ); - /* Redraw text in new position. */ + // Redraw text in new position: TextePcb->Draw( m_canvas, DC, GR_XOR ); SetMsgPanel( TextePcb ); @@ -276,7 +276,7 @@ void PCB_EDIT_FRAME::FlipTextePcb( TEXTE_PCB* aTextePcb, wxDC* aDC ) if( aTextePcb->GetFlags() == 0 ) // i.e. not edited, or moved SaveCopyInUndoList( aTextePcb, UR_FLIPPED, aTextePcb->GetTextPosition() ); - else // set flag edit, to show it was a complex command + else // set edit flag, for the current command aTextePcb->SetFlags( IN_EDIT ); OnModify();