diff --git a/common/dialogs/dialog_text_entry.cpp b/common/dialogs/dialog_text_entry.cpp index 0258134f18..325ec7741b 100644 --- a/common/dialogs/dialog_text_entry.cpp +++ b/common/dialogs/dialog_text_entry.cpp @@ -38,6 +38,25 @@ WX_TEXT_ENTRY_DIALOG::WX_TEXT_ENTRY_DIALOG( wxWindow* aParent, } +WX_TEXT_ENTRY_DIALOG::WX_TEXT_ENTRY_DIALOG( wxWindow* aParent, const wxString& aLabel, const wxString& aCaption, + const wxString& aDefaultValue, const wxString& aChoiceCaption, + const std::vector& aChoices, int aDefaultChoice ) : + WX_TEXT_ENTRY_DIALOG( aParent, aLabel, aCaption, aDefaultValue ) +{ + m_choiceLabel->SetLabel( aChoiceCaption ); + m_choiceLabel->Show( true ); + + for( const wxString& choice : aChoices ) + m_choice->Append( choice ); + + m_choice->SetSelection( aDefaultChoice ); + m_choice->Show( true ); + + this->Layout(); + m_mainSizer->Fit( this ); +} + + void WX_TEXT_ENTRY_DIALOG::SetTextValidator( wxTextValidatorStyle style ) { SetTextValidator( wxTextValidator(style) ); @@ -55,3 +74,9 @@ wxString WX_TEXT_ENTRY_DIALOG::GetValue() const return m_textCtrl->GetValue(); } + +int WX_TEXT_ENTRY_DIALOG::GetChoice() const +{ + return m_choice->GetCurrentSelection(); +} + diff --git a/common/dialogs/dialog_text_entry_base.cpp b/common/dialogs/dialog_text_entry_base.cpp index 771d4230f3..e8b15fbbd6 100644 --- a/common/dialogs/dialog_text_entry_base.cpp +++ b/common/dialogs/dialog_text_entry_base.cpp @@ -1,8 +1,8 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Aug 4 2017) +// C++ code generated with wxFormBuilder (version 3.9.0 Apr 22 2021) // http://www.wxformbuilder.org/ // -// PLEASE DO "NOT" EDIT THIS FILE! +// PLEASE DO *NOT* EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// #include "dialog_text_entry_base.h" @@ -12,39 +12,53 @@ WX_TEXT_ENTRY_DIALOG_BASE::WX_TEXT_ENTRY_DIALOG_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( wxDefaultSize, wxDefaultSize ); - - wxBoxSizer* bSizerMain; - bSizerMain = new wxBoxSizer( wxVERTICAL ); - + + m_mainSizer = new wxBoxSizer( wxVERTICAL ); + wxBoxSizer* bSizerContent; bSizerContent = new wxBoxSizer( wxVERTICAL ); - + m_label = new wxStaticText( this, wxID_ANY, _("MyLabel"), wxDefaultPosition, wxDefaultSize, 0 ); m_label->Wrap( -1 ); bSizerContent->Add( m_label, 0, wxALL|wxEXPAND, 5 ); - + m_textCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); m_textCtrl->SetMinSize( wxSize( 300,-1 ) ); - + bSizerContent->Add( m_textCtrl, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 ); - - - bSizerMain->Add( bSizerContent, 1, wxALL|wxEXPAND, 5 ); - + + wxBoxSizer* bSizer3; + bSizer3 = new wxBoxSizer( wxHORIZONTAL ); + + m_choiceLabel = new wxStaticText( this, wxID_ANY, _("MyLabel"), wxDefaultPosition, wxDefaultSize, 0 ); + m_choiceLabel->Wrap( -1 ); + bSizer3->Add( m_choiceLabel, 2, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 ); + + wxArrayString m_choiceChoices; + m_choice = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_choiceChoices, 0 ); + m_choice->SetSelection( 0 ); + bSizer3->Add( m_choice, 3, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 ); + + + bSizerContent->Add( bSizer3, 1, wxEXPAND, 5 ); + + + m_mainSizer->Add( bSizerContent, 1, wxALL|wxEXPAND, 5 ); + 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(); - - bSizerMain->Add( m_sdbSizer1, 0, wxALL|wxALIGN_RIGHT, 5 ); - - - this->SetSizer( bSizerMain ); + + m_mainSizer->Add( m_sdbSizer1, 0, wxALL|wxALIGN_RIGHT, 5 ); + + + this->SetSizer( m_mainSizer ); this->Layout(); - bSizerMain->Fit( this ); - + m_mainSizer->Fit( this ); + this->Centre( wxBOTH ); } diff --git a/common/dialogs/dialog_text_entry_base.fbp b/common/dialogs/dialog_text_entry_base.fbp index 9a9d1d4fc5..20ab5c662c 100644 --- a/common/dialogs/dialog_text_entry_base.fbp +++ b/common/dialogs/dialog_text_entry_base.fbp @@ -1,310 +1,356 @@ - - - - - - C++ - 1 - source_name - 0 - 0 - res - UTF-8 - connect - dialog_text_entry_base - 1000 - none - 1 - dialog_text_entry_base - - . - - 1 - 1 - 1 - 1 - UI - 0 - 0 - - 0 - wxAUI_MGR_DEFAULT - - wxBOTH - - 1 - 1 - impl_virtual - - - - 0 - wxID_ANY - - - WX_TEXT_ENTRY_DIALOG_BASE - - -1,-1 - wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER - DIALOG_SHIM; dialog_shim.h - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bSizerMain - wxVERTICAL - none - - 5 - wxALL|wxEXPAND - 1 - - - bSizerContent - wxVERTICAL - none - - 5 - wxALL|wxEXPAND - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - MyLabel - - 0 - - - 0 - - 1 - m_label - 1 - - - protected - 1 - - Resizable - 1 - - - ; forward_declare - 0 - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - - 0 - 300,-1 - 1 - m_textCtrl - 1 - - - protected - 1 - - Resizable - 1 - - - ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL|wxALIGN_RIGHT - 0 - - 0 - 1 - 0 - 0 - 0 - 1 - 0 - 0 - - m_sdbSizer1 - protected - - - - - - - - - - - - - - + + + + + + C++ + 1 + source_name + 0 + 0 + res + UTF-8 + connect + dialog_text_entry_base + 1000 + none + + + 1 + dialog_text_entry_base + + . + + 1 + 1 + 1 + 1 + UI + 0 + 0 + 0 + + 0 + wxAUI_MGR_DEFAULT + + wxBOTH + + 1 + 1 + impl_virtual + + + + 0 + wxID_ANY + + + WX_TEXT_ENTRY_DIALOG_BASE + + -1,-1 + wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER + DIALOG_SHIM; dialog_shim.h + + + + + + + + m_mainSizer + wxVERTICAL + protected + + 5 + wxALL|wxEXPAND + 1 + + + bSizerContent + wxVERTICAL + none + + 5 + wxALL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + MyLabel + 0 + + 0 + + + 0 + + 1 + m_label + 1 + + + protected + 1 + + Resizable + 1 + + + ; forward_declare + 0 + + + + + -1 + + + + 5 + wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + + 0 + 300,-1 + 1 + m_textCtrl + 1 + + + protected + 1 + + Resizable + 1 + + + ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + 5 + wxEXPAND + 1 + + + bSizer3 + wxHORIZONTAL + none + + 5 + wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT + 2 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + MyLabel + 0 + + 0 + + + 0 + + 1 + m_choiceLabel + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT + 3 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_choice + 1 + + + protected + 1 + + Resizable + 0 + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + 5 + wxALL|wxALIGN_RIGHT + 0 + + 0 + 1 + 0 + 0 + 0 + 1 + 0 + 0 + + m_sdbSizer1 + protected + + + + + + diff --git a/common/dialogs/dialog_text_entry_base.h b/common/dialogs/dialog_text_entry_base.h index db27afc6b0..dd0b3e31c8 100644 --- a/common/dialogs/dialog_text_entry_base.h +++ b/common/dialogs/dialog_text_entry_base.h @@ -1,18 +1,15 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Aug 4 2017) +// C++ code generated with wxFormBuilder (version 3.9.0 Apr 22 2021) // http://www.wxformbuilder.org/ // -// PLEASE DO "NOT" EDIT THIS FILE! +// PLEASE DO *NOT* EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// -#ifndef __DIALOG_TEXT_ENTRY_BASE_H__ -#define __DIALOG_TEXT_ENTRY_BASE_H__ +#pragma once #include #include #include -class DIALOG_SHIM; - #include "dialog_shim.h" #include #include @@ -21,6 +18,7 @@ class DIALOG_SHIM; #include #include #include +#include #include #include #include @@ -34,19 +32,21 @@ class DIALOG_SHIM; class WX_TEXT_ENTRY_DIALOG_BASE : public DIALOG_SHIM { private: - + protected: + wxBoxSizer* m_mainSizer; wxStaticText* m_label; wxTextCtrl* m_textCtrl; + wxStaticText* m_choiceLabel; + wxChoice* m_choice; wxStdDialogButtonSizer* m_sdbSizer1; wxButton* m_sdbSizer1OK; wxButton* m_sdbSizer1Cancel; - + public: - - WX_TEXT_ENTRY_DIALOG_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + + WX_TEXT_ENTRY_DIALOG_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); ~WX_TEXT_ENTRY_DIALOG_BASE(); - + }; -#endif //__DIALOG_TEXT_ENTRY_BASE_H__ diff --git a/include/dialogs/dialog_text_entry.h b/include/dialogs/dialog_text_entry.h index 67afc0acbb..5335e0839f 100644 --- a/include/dialogs/dialog_text_entry.h +++ b/include/dialogs/dialog_text_entry.h @@ -31,20 +31,27 @@ #ifndef _DIALOG_TEXT_ENTRY_H_ #define _DIALOG_TEXT_ENTRY_H_ +#include + #include #include - class WX_TEXT_ENTRY_DIALOG : public WX_TEXT_ENTRY_DIALOG_BASE { public: WX_TEXT_ENTRY_DIALOG( wxWindow* aParent, const wxString& aLabel, const wxString& aCaption, const wxString& aDefaultValue = wxEmptyString ); + + WX_TEXT_ENTRY_DIALOG( wxWindow* aParent, const wxString& aLabel, const wxString& aCaption, + const wxString& aDefaultValue, const wxString& aChoiceCaption, + const std::vector& aChoices, int aDefaultChoice = 0 ); + void SetTextValidator( wxTextValidatorStyle style ); void SetTextValidator( const wxTextValidator& validator ); wxString GetValue() const; + int GetChoice() const; }; #endif // _DIALOG_TEXT_ENTRY_H_ diff --git a/pcbnew/footprint_libraries_utils.cpp b/pcbnew/footprint_libraries_utils.cpp index 3ff96c8580..9ddb062a7f 100644 --- a/pcbnew/footprint_libraries_utils.cpp +++ b/pcbnew/footprint_libraries_utils.cpp @@ -1152,15 +1152,31 @@ FOOTPRINT* PCB_BASE_FRAME::CreateNewFootprint( const wxString& aFootprintName ) { wxString footprintName = aFootprintName; + // Static to store user preference for a session + static int footprintType = 1; + // Ask for the new footprint name if( footprintName.IsEmpty() ) { WX_TEXT_ENTRY_DIALOG dlg( this, _( "Enter footprint name:" ), _( "New Footprint" ), - footprintName ); + footprintName, _( "Footprint type:" ), + { _( "Through hole" ), _( "SMD" ), _( "Other" ) }, footprintType ); dlg.SetTextValidator( FOOTPRINT_NAME_VALIDATOR( &footprintName ) ); if( dlg.ShowModal() != wxID_OK ) return nullptr; //Aborted by user + + switch( dlg.GetChoice() ) + { + case 0: + footprintType = FP_THROUGH_HOLE; + break; + case 1: + footprintType = FP_SMD; + break; + default: + footprintType = 0; + } } footprintName.Trim( true ); @@ -1181,6 +1197,8 @@ FOOTPRINT* PCB_BASE_FRAME::CreateNewFootprint( const wxString& aFootprintName ) // Update its name in lib footprint->SetFPID( LIB_ID( wxEmptyString, footprintName ) ); + footprint->SetAttributes( footprintType ); + PCB_LAYER_ID txt_layer; wxPoint default_pos; BOARD_DESIGN_SETTINGS& settings = GetDesignSettings();