From 6ba5e40669a2e5a1fed9868cbf0ff31f5cfe89cb Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Thu, 1 Jan 2015 12:37:23 +0100 Subject: [PATCH] Fix a minor issue in fp lib wizard. Remove a duplicate code for dialog select dir list. --- cvpcb/CMakeLists.txt | 1 + pcbnew/CMakeLists.txt | 1 + pcbnew/dialogs/dialog_select_dirlist_base.cpp | 12 +- pcbnew/dialogs/dialog_select_dirlist_base.fbp | 14 +- pcbnew/dialogs/dialog_select_dirlist_base.h | 6 +- pcbnew/dialogs/wizard_add_fplib.cpp | 6 + pcbnew/dialogs/wizard_add_fplib_base.cpp | 49 --- pcbnew/dialogs/wizard_add_fplib_base.fbp | 361 ------------------ pcbnew/dialogs/wizard_add_fplib_base.h | 29 -- 9 files changed, 28 insertions(+), 451 deletions(-) diff --git a/cvpcb/CMakeLists.txt b/cvpcb/CMakeLists.txt index c067236b78..13ee3072f5 100644 --- a/cvpcb/CMakeLists.txt +++ b/cvpcb/CMakeLists.txt @@ -37,6 +37,7 @@ set( CVPCB_DIALOGS ../pcbnew/dialogs/dialog_fp_plugin_options_base.cpp ../pcbnew/dialogs/wizard_add_fplib_base.cpp ../pcbnew/dialogs/wizard_add_fplib.cpp + ../pcbnew/dialogs/dialog_select_dirlist_base.cpp ) set( CVPCB_SRCS diff --git a/pcbnew/CMakeLists.txt b/pcbnew/CMakeLists.txt index eba8f15d57..ae189d2223 100644 --- a/pcbnew/CMakeLists.txt +++ b/pcbnew/CMakeLists.txt @@ -120,6 +120,7 @@ set( PCBNEW_DIALOGS dialogs/dialog_SVG_print_base.cpp dialogs/dialog_select_pretty_lib.cpp dialogs/dialog_select_pretty_lib_base.cpp + dialogs/dialog_select_dirlist_base.cpp dialogs/dialog_set_grid.cpp dialogs/dialog_set_grid_base.cpp dialogs/dialog_target_properties_base.cpp diff --git a/pcbnew/dialogs/dialog_select_dirlist_base.cpp b/pcbnew/dialogs/dialog_select_dirlist_base.cpp index fb81df85d3..3e262208a1 100644 --- a/pcbnew/dialogs/dialog_select_dirlist_base.cpp +++ b/pcbnew/dialogs/dialog_select_dirlist_base.cpp @@ -25,10 +25,12 @@ DIALOG_SELECT_DIRLIST_BASE::DIALOG_SELECT_DIRLIST_BASE( wxWindow* parent, wxWind m_dirCtrl = new wxGenericDirCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxDIRCTRL_3D_INTERNAL|wxDIRCTRL_DIR_ONLY|wxDIRCTRL_MULTIPLE|wxDIRCTRL_SHOW_FILTERS|wxSUNKEN_BORDER, _("*.pretty|*"), 0 ); m_dirCtrl->ShowHidden( false ); + m_dirCtrl->SetMinSize( wxSize( 400,350 ) ); + bSizerMain->Add( m_dirCtrl, 1, wxEXPAND | wxALL, 5 ); - m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); - bSizerMain->Add( m_staticline1, 0, wxEXPAND | wxALL, 5 ); + m_staticline = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); + bSizerMain->Add( m_staticline, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); m_sdbSizer = new wxStdDialogButtonSizer(); m_sdbSizerOK = new wxButton( this, wxID_OK ); @@ -37,7 +39,7 @@ DIALOG_SELECT_DIRLIST_BASE::DIALOG_SELECT_DIRLIST_BASE( wxWindow* parent, wxWind m_sdbSizer->AddButton( m_sdbSizerCancel ); m_sdbSizer->Realize(); - bSizerMain->Add( m_sdbSizer, 0, wxALIGN_RIGHT, 5 ); + bSizerMain->Add( m_sdbSizer, 0, wxALIGN_RIGHT|wxALL, 5 ); this->SetSizer( bSizerMain ); @@ -48,6 +50,8 @@ DIALOG_SELECT_DIRLIST_BASE::DIALOG_SELECT_DIRLIST_BASE( wxWindow* parent, wxWind // Connect Events m_dirCtrl->Connect( wxEVT_COMMAND_TREE_ITEM_ACTIVATED, wxTreeEventHandler( DIALOG_SELECT_DIRLIST_BASE::OnSelectFolder ), NULL, this ); m_dirCtrl->Connect( wxEVT_COMMAND_TREE_SEL_CHANGED, wxTreeEventHandler( DIALOG_SELECT_DIRLIST_BASE::OnSelectFolder ), NULL, this ); + m_sdbSizerCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SELECT_DIRLIST_BASE::OnCancelClick ), NULL, this ); + m_sdbSizerOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SELECT_DIRLIST_BASE::OnOKClick ), NULL, this ); } DIALOG_SELECT_DIRLIST_BASE::~DIALOG_SELECT_DIRLIST_BASE() @@ -55,5 +59,7 @@ DIALOG_SELECT_DIRLIST_BASE::~DIALOG_SELECT_DIRLIST_BASE() // Disconnect Events m_dirCtrl->Disconnect( wxEVT_COMMAND_TREE_ITEM_ACTIVATED, wxTreeEventHandler( DIALOG_SELECT_DIRLIST_BASE::OnSelectFolder ), NULL, this ); m_dirCtrl->Disconnect( wxEVT_COMMAND_TREE_SEL_CHANGED, wxTreeEventHandler( DIALOG_SELECT_DIRLIST_BASE::OnSelectFolder ), NULL, this ); + m_sdbSizerCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SELECT_DIRLIST_BASE::OnCancelClick ), NULL, this ); + m_sdbSizerOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SELECT_DIRLIST_BASE::OnOKClick ), NULL, this ); } diff --git a/pcbnew/dialogs/dialog_select_dirlist_base.fbp b/pcbnew/dialogs/dialog_select_dirlist_base.fbp index 6119123be0..b02ebf74aa 100644 --- a/pcbnew/dialogs/dialog_select_dirlist_base.fbp +++ b/pcbnew/dialogs/dialog_select_dirlist_base.fbp @@ -44,7 +44,7 @@ 400,300 DIALOG_SELECT_DIRLIST_BASE - 400,300 + 400,321 wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER DIALOG_SHIM; dialog_shim.h Select Footprint Library Folder @@ -216,7 +216,7 @@ 0 - + 400,350 1 m_dirCtrl 1 @@ -280,7 +280,7 @@ 5 - wxEXPAND | wxALL + wxEXPAND|wxTOP|wxRIGHT|wxLEFT 0 1 @@ -317,7 +317,7 @@ 0 1 - m_staticline1 + m_staticline 1 @@ -361,7 +361,7 @@ 5 - wxALIGN_RIGHT + wxALIGN_RIGHT|wxALL 0 0 @@ -376,11 +376,11 @@ m_sdbSizer protected - + OnCancelClick - + OnOKClick diff --git a/pcbnew/dialogs/dialog_select_dirlist_base.h b/pcbnew/dialogs/dialog_select_dirlist_base.h index 6a15a11049..916ffd328f 100644 --- a/pcbnew/dialogs/dialog_select_dirlist_base.h +++ b/pcbnew/dialogs/dialog_select_dirlist_base.h @@ -39,18 +39,20 @@ class DIALOG_SELECT_DIRLIST_BASE : public DIALOG_SHIM protected: wxStaticText* m_staticText; wxGenericDirCtrl* m_dirCtrl; - wxStaticLine* m_staticline1; + wxStaticLine* m_staticline; wxStdDialogButtonSizer* m_sdbSizer; wxButton* m_sdbSizerOK; wxButton* m_sdbSizerCancel; // Virtual event handlers, overide them in your derived class virtual void OnSelectFolder( wxTreeEvent& event ) { event.Skip(); } + virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); } + virtual void OnOKClick( wxCommandEvent& event ) { event.Skip(); } public: - DIALOG_SELECT_DIRLIST_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Select Footprint Library Folder"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 400,300 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + DIALOG_SELECT_DIRLIST_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Select Footprint Library Folder"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 400,321 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); ~DIALOG_SELECT_DIRLIST_BASE(); }; diff --git a/pcbnew/dialogs/wizard_add_fplib.cpp b/pcbnew/dialogs/wizard_add_fplib.cpp index c9b74cabc7..2d11bf0cb5 100644 --- a/pcbnew/dialogs/wizard_add_fplib.cpp +++ b/pcbnew/dialogs/wizard_add_fplib.cpp @@ -55,6 +55,7 @@ #include // For PROJECT_VAR_NAME definition #include #include +#include // a key to store the default Kicad Github libs URL #define KICAD_FPLIBS_URL_KEY wxT( "kicad_fplib_url" ) @@ -640,6 +641,11 @@ public: { if( !aDefaultPath.IsEmpty() ) m_dirCtrl->SetPath( aDefaultPath ); + + Layout(); + GetSizer()->Fit( this ); + GetSizer()->SetSizeHints(this); + Centre(); } ~DIALOG_SELECT_DIRLIST() {}; diff --git a/pcbnew/dialogs/wizard_add_fplib_base.cpp b/pcbnew/dialogs/wizard_add_fplib_base.cpp index 8b4a869310..8e21bd5848 100644 --- a/pcbnew/dialogs/wizard_add_fplib_base.cpp +++ b/pcbnew/dialogs/wizard_add_fplib_base.cpp @@ -251,52 +251,3 @@ WIZARD_FPLIB_TABLE_BASE::~WIZARD_FPLIB_TABLE_BASE() m_pages.Clear(); } - -DIALOG_SELECT_DIRLIST_BASE::DIALOG_SELECT_DIRLIST_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style ) -{ - this->SetSizeHints( wxDefaultSize, wxDefaultSize ); - - wxBoxSizer* bSizerMain; - bSizerMain = new wxBoxSizer( wxVERTICAL ); - - m_staticTextInfo = new wxStaticText( this, wxID_ANY, _("The footprint library is a folder.\nFootprints are files inside this folder."), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE ); - m_staticTextInfo->Wrap( -1 ); - m_staticTextInfo->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 92, false, wxEmptyString ) ); - - bSizerMain->Add( m_staticTextInfo, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 ); - - m_dirCtrl = new wxGenericDirCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxDIRCTRL_3D_INTERNAL|wxDIRCTRL_DIR_ONLY|wxDIRCTRL_MULTIPLE|wxSUNKEN_BORDER, wxEmptyString, 0 ); - - m_dirCtrl->ShowHidden( false ); - bSizerMain->Add( m_dirCtrl, 1, wxEXPAND | wxALL, 5 ); - - m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); - bSizerMain->Add( m_staticline1, 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(); - - bSizerMain->Add( m_sdbSizer, 0, wxEXPAND, 5 ); - - - this->SetSizer( bSizerMain ); - this->Layout(); - - this->Centre( wxBOTH ); - - // Connect Events - m_sdbSizerCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SELECT_DIRLIST_BASE::OnCancelClick ), NULL, this ); - m_sdbSizerOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SELECT_DIRLIST_BASE::OnOKClick ), NULL, this ); -} - -DIALOG_SELECT_DIRLIST_BASE::~DIALOG_SELECT_DIRLIST_BASE() -{ - // Disconnect Events - m_sdbSizerCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SELECT_DIRLIST_BASE::OnCancelClick ), NULL, this ); - m_sdbSizerOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SELECT_DIRLIST_BASE::OnOKClick ), NULL, this ); - -} diff --git a/pcbnew/dialogs/wizard_add_fplib_base.fbp b/pcbnew/dialogs/wizard_add_fplib_base.fbp index f9e7971b88..6bf0a8209f 100644 --- a/pcbnew/dialogs/wizard_add_fplib_base.fbp +++ b/pcbnew/dialogs/wizard_add_fplib_base.fbp @@ -2123,366 +2123,5 @@ - - 0 - wxAUI_MGR_DEFAULT - - wxBOTH - - 1 - 1 - impl_virtual - - - - 0 - wxID_ANY - - - DIALOG_SELECT_DIRLIST_BASE - - 346,325 - wxDEFAULT_DIALOG_STYLE - - Select Footprint Library Folder - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bSizerMain - wxVERTICAL - none - - 5 - wxALL|wxALIGN_CENTER_HORIZONTAL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - ,90,92,-1,70,0 - 0 - 0 - wxID_ANY - The footprint library is a folder. Footprints are files inside this folder. - - 0 - - - 0 - - 1 - m_staticTextInfo - 1 - - - protected - 1 - - Resizable - 1 - - wxALIGN_CENTRE - - 0 - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND | wxALL - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - 0 - - Dock - 0 - Left - 1 - - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_dirCtrl - 1 - - - protected - 1 - - Resizable - 1 - 0 - - wxDIRCTRL_3D_INTERNAL|wxDIRCTRL_DIR_ONLY|wxDIRCTRL_MULTIPLE - - 0 - - - - wxSUNKEN_BORDER - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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_staticline1 - 1 - - - protected - 1 - - Resizable - 1 - - wxLI_HORIZONTAL - - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND - 0 - - 0 - 1 - 0 - 0 - 0 - 1 - 0 - 0 - - m_sdbSizer - protected - - OnCancelClick - - - - OnOKClick - - - - - - diff --git a/pcbnew/dialogs/wizard_add_fplib_base.h b/pcbnew/dialogs/wizard_add_fplib_base.h index 25bf783660..884ee29215 100644 --- a/pcbnew/dialogs/wizard_add_fplib_base.h +++ b/pcbnew/dialogs/wizard_add_fplib_base.h @@ -31,8 +31,6 @@ #include #include WX_DEFINE_ARRAY_PTR( wxWizardPageSimple*, WizardPages ); -#include -#include /////////////////////////////////////////////////////////////////////////// @@ -87,31 +85,4 @@ class WIZARD_FPLIB_TABLE_BASE : public wxWizard }; -/////////////////////////////////////////////////////////////////////////////// -/// Class DIALOG_SELECT_DIRLIST_BASE -/////////////////////////////////////////////////////////////////////////////// -class DIALOG_SELECT_DIRLIST_BASE : public wxDialog -{ - private: - - protected: - wxStaticText* m_staticTextInfo; - wxGenericDirCtrl* m_dirCtrl; - wxStaticLine* m_staticline1; - wxStdDialogButtonSizer* m_sdbSizer; - wxButton* m_sdbSizerOK; - wxButton* m_sdbSizerCancel; - - // Virtual event handlers, overide them in your derived class - virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); } - virtual void OnOKClick( wxCommandEvent& event ) { event.Skip(); } - - - public: - - DIALOG_SELECT_DIRLIST_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Select Footprint Library Folder"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 346,325 ), long style = wxDEFAULT_DIALOG_STYLE ); - ~DIALOG_SELECT_DIRLIST_BASE(); - -}; - #endif //__WIZARD_ADD_FPLIB_BASE_H__