From ffeba9de93205c943a9bc3032b7da8d6b08634dc Mon Sep 17 00:00:00 2001 From: Mathias Grimmberger Date: Fri, 25 Aug 2017 16:46:49 +0200 Subject: [PATCH] Change track width setting to dropbox --- common/wx_unit_binder.cpp | 18 ++++++++++-------- include/wx_unit_binder.h | 8 ++++---- pcbnew/dialogs/dialog_track_via_properties.cpp | 7 +++++++ pcbnew/dialogs/dialog_track_via_properties.h | 6 +++--- .../dialog_track_via_properties_base.cpp | 13 ++----------- .../dialog_track_via_properties_base.fbp | 8 ++++---- .../dialogs/dialog_track_via_properties_base.h | 4 ++-- 7 files changed, 32 insertions(+), 32 deletions(-) diff --git a/common/wx_unit_binder.cpp b/common/wx_unit_binder.cpp index 6a9236b329..c1f0fef500 100644 --- a/common/wx_unit_binder.cpp +++ b/common/wx_unit_binder.cpp @@ -24,7 +24,7 @@ #include #include -#include +#include #include #include #include @@ -33,9 +33,9 @@ #include "wx_unit_binder.h" -WX_UNIT_BINDER::WX_UNIT_BINDER( wxWindow* aParent, wxTextCtrl* aTextInput, +WX_UNIT_BINDER::WX_UNIT_BINDER( wxWindow* aParent, wxTextEntry* aTextInput, wxStaticText* aUnitLabel, wxSpinButton* aSpinButton ) : - m_textCtrl( aTextInput ), + m_textEntry( aTextInput ), m_unitLabel( aUnitLabel ), m_units( g_UserUnit ), m_step( 1 ), @@ -43,7 +43,7 @@ WX_UNIT_BINDER::WX_UNIT_BINDER( wxWindow* aParent, wxTextCtrl* aTextInput, m_max( 1 ) { // Use the currently selected units - m_textCtrl->SetValue( wxT( "0" ) ); + m_textEntry->SetValue( wxT( "0" ) ); m_unitLabel->SetLabel( GetAbbreviatedUnitsLabel( m_units ) ); } @@ -57,7 +57,7 @@ void WX_UNIT_BINDER::SetValue( int aValue ) { wxString s = StringFromValue( m_units, aValue, false ); - m_textCtrl->SetValue( s ); + m_textEntry->SetValue( s ); m_unitLabel->SetLabel( GetAbbreviatedUnitsLabel( m_units ) ); } @@ -65,7 +65,7 @@ void WX_UNIT_BINDER::SetValue( int aValue ) int WX_UNIT_BINDER::GetValue() const { - wxString s = m_textCtrl->GetValue(); + wxString s = m_textEntry->GetValue(); return ValueFromString( m_units, s ); } @@ -75,12 +75,14 @@ bool WX_UNIT_BINDER::Valid() const { double dummy; - return m_textCtrl->GetValue().ToDouble( &dummy ); + return m_textEntry->GetValue().ToDouble( &dummy ); } void WX_UNIT_BINDER::Enable( bool aEnable ) { - m_textCtrl->Enable( aEnable ); + wxWindow* wxWin = dynamic_cast ( m_textEntry ); + wxWin->Enable( aEnable ); m_unitLabel->Enable( aEnable ); } + diff --git a/include/wx_unit_binder.h b/include/wx_unit_binder.h index ad4741d563..7639c8494a 100644 --- a/include/wx_unit_binder.h +++ b/include/wx_unit_binder.h @@ -28,7 +28,7 @@ #include #include -class wxTextCtrl; +class wxTextEntry; class wxSpinButton; class wxStaticText; @@ -39,11 +39,11 @@ public: /** * Constructor. * @param aParent is the parent window. - * @param aTextInput is the text input widget used to edit the given value. + * @param aTextInput is the text input widget used to edit the given value (wxTextCtrl, wxComboBox, ...). * @param aUnitLabel is the units label displayed next to the text field. * @param aSpinButton is an optional spin button (for adjusting the input value) */ - WX_UNIT_BINDER( wxWindow* aParent, wxTextCtrl* aTextInput, wxStaticText* aUnitLabel, wxSpinButton* aSpinButton = NULL ); + WX_UNIT_BINDER( wxWindow* aParent, wxTextEntry* aTextInput, wxStaticText* aUnitLabel, wxSpinButton* aSpinButton = NULL ); virtual ~WX_UNIT_BINDER(); @@ -77,7 +77,7 @@ protected: void onTextChanged( wxEvent& aEvent ); ///> Text input control. - wxTextCtrl* m_textCtrl; + wxTextEntry* m_textEntry; ///> Label showing currently used units. wxStaticText* m_unitLabel; diff --git a/pcbnew/dialogs/dialog_track_via_properties.cpp b/pcbnew/dialogs/dialog_track_via_properties.cpp index 4a2c69a264..28d4c1b303 100644 --- a/pcbnew/dialogs/dialog_track_via_properties.cpp +++ b/pcbnew/dialogs/dialog_track_via_properties.cpp @@ -204,6 +204,13 @@ DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES( PCB_BASE_FRAME* aParen setCommonVal( trackEndY, m_TrackEndYCtrl, m_trackEndY ); setCommonVal( trackWidth, m_TrackWidthCtrl, m_trackWidth ); + for( unsigned ii = 0; ii < aParent->GetDesignSettings().m_TrackWidthList.size(); ii++ ) + { + int width = aParent->GetDesignSettings().m_TrackWidthList[ii]; + wxString msg = StringFromValue( g_UserUnit, width, false ); + m_TrackWidthCtrl->Append( msg ); + } + m_TrackLayerCtrl->SetLayersHotkeys( false ); m_TrackLayerCtrl->SetLayerSet( LSET::AllNonCuMask() ); m_TrackLayerCtrl->SetBoardFrame( aParent ); diff --git a/pcbnew/dialogs/dialog_track_via_properties.h b/pcbnew/dialogs/dialog_track_via_properties.h index 3be7d4d77f..14e15518c7 100644 --- a/pcbnew/dialogs/dialog_track_via_properties.h +++ b/pcbnew/dialogs/dialog_track_via_properties.h @@ -59,14 +59,14 @@ private: ///> Checks if the dialog values are correct. bool check() const; - ///> Sets wxTextCtrl to the value stored in boost::optional or "<...>" if it is not available. + ///> Sets wxTextEntry to the value stored in boost::optional or "<...>" if it is not available. template - void setCommonVal( const boost::optional& aVal, wxTextCtrl* aTxtCtrl, WX_UNIT_BINDER& aBinder ) + void setCommonVal( const boost::optional& aVal, wxTextEntry* aTxtEntry, WX_UNIT_BINDER& aBinder ) { if( aVal ) aBinder.SetValue( *aVal ); else - aTxtCtrl->SetValue( "<...>" ); + aTxtEntry->SetValue( "<...>" ); } ///> Selected items to be modified. diff --git a/pcbnew/dialogs/dialog_track_via_properties_base.cpp b/pcbnew/dialogs/dialog_track_via_properties_base.cpp index 7cc9c2e5c3..5af355aba3 100644 --- a/pcbnew/dialogs/dialog_track_via_properties_base.cpp +++ b/pcbnew/dialogs/dialog_track_via_properties_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Jun 17 2015) +// C++ code generated with wxFormBuilder (version Aug 20 2017) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -65,7 +65,6 @@ DIALOG_TRACK_VIA_PROPERTIES_BASE::DIALOG_TRACK_VIA_PROPERTIES_BASE( wxWindow* pa fgTrackLeftGridSizer->Add( m_TrackStartXLabel, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 5 ); m_TrackStartXCtrl = new wxTextCtrl( m_sbTrackSizer->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - m_TrackStartXCtrl->SetMaxLength( 0 ); fgTrackLeftGridSizer->Add( m_TrackStartXCtrl, 0, wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 ); m_TrackStartXUnit = new wxStaticText( m_sbTrackSizer->GetStaticBox(), wxID_ANY, _("Unit"), wxDefaultPosition, wxDefaultSize, 0 ); @@ -77,7 +76,6 @@ DIALOG_TRACK_VIA_PROPERTIES_BASE::DIALOG_TRACK_VIA_PROPERTIES_BASE( wxWindow* pa fgTrackLeftGridSizer->Add( m_TrackStartYLabel, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 5 ); m_TrackStartYCtrl = new wxTextCtrl( m_sbTrackSizer->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - m_TrackStartYCtrl->SetMaxLength( 0 ); fgTrackLeftGridSizer->Add( m_TrackStartYCtrl, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); m_TrackStartYUnit = new wxStaticText( m_sbTrackSizer->GetStaticBox(), wxID_ANY, _("Unit"), wxDefaultPosition, wxDefaultSize, 0 ); @@ -89,7 +87,6 @@ DIALOG_TRACK_VIA_PROPERTIES_BASE::DIALOG_TRACK_VIA_PROPERTIES_BASE( wxWindow* pa fgTrackLeftGridSizer->Add( m_TrackEndXLabel, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 5 ); m_TrackEndXCtrl = new wxTextCtrl( m_sbTrackSizer->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - m_TrackEndXCtrl->SetMaxLength( 0 ); fgTrackLeftGridSizer->Add( m_TrackEndXCtrl, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); m_TrackEndXUnit = new wxStaticText( m_sbTrackSizer->GetStaticBox(), wxID_ANY, _("Unit"), wxDefaultPosition, wxDefaultSize, 0 ); @@ -101,7 +98,6 @@ DIALOG_TRACK_VIA_PROPERTIES_BASE::DIALOG_TRACK_VIA_PROPERTIES_BASE( wxWindow* pa fgTrackLeftGridSizer->Add( m_TrackEndYLabel, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 5 ); m_TrackEndYCtrl = new wxTextCtrl( m_sbTrackSizer->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - m_TrackEndYCtrl->SetMaxLength( 0 ); fgTrackLeftGridSizer->Add( m_TrackEndYCtrl, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); m_TrackEndYUnit = new wxStaticText( m_sbTrackSizer->GetStaticBox(), wxID_ANY, _("Unit"), wxDefaultPosition, wxDefaultSize, 0 ); @@ -123,8 +119,7 @@ DIALOG_TRACK_VIA_PROPERTIES_BASE::DIALOG_TRACK_VIA_PROPERTIES_BASE( wxWindow* pa m_TrackWidthLabel->Wrap( -1 ); fgTrackRightSizer->Add( m_TrackWidthLabel, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxTOP|wxBOTTOM|wxRIGHT, 5 ); - m_TrackWidthCtrl = new wxTextCtrl( m_sbTrackSizer->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - m_TrackWidthCtrl->SetMaxLength( 0 ); + m_TrackWidthCtrl = new wxComboBox( m_sbTrackSizer->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 ); fgTrackRightSizer->Add( m_TrackWidthCtrl, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); m_TrackWidthUnit = new wxStaticText( m_sbTrackSizer->GetStaticBox(), wxID_ANY, _("Unit"), wxDefaultPosition, wxDefaultSize, 0 ); @@ -168,7 +163,6 @@ DIALOG_TRACK_VIA_PROPERTIES_BASE::DIALOG_TRACK_VIA_PROPERTIES_BASE( wxWindow* pa fgViaLeftSizer->Add( m_ViaXLabel, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 5 ); m_ViaXCtrl = new wxTextCtrl( m_sbViaSizer->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - m_ViaXCtrl->SetMaxLength( 0 ); fgViaLeftSizer->Add( m_ViaXCtrl, 0, wxEXPAND, 5 ); m_ViaXUnit = new wxStaticText( m_sbViaSizer->GetStaticBox(), wxID_ANY, _("Unit"), wxDefaultPosition, wxDefaultSize, 0 ); @@ -180,7 +174,6 @@ DIALOG_TRACK_VIA_PROPERTIES_BASE::DIALOG_TRACK_VIA_PROPERTIES_BASE( wxWindow* pa fgViaLeftSizer->Add( m_ViaYLabel, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 5 ); m_ViaYCtrl = new wxTextCtrl( m_sbViaSizer->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - m_ViaYCtrl->SetMaxLength( 0 ); fgViaLeftSizer->Add( m_ViaYCtrl, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); m_ViaYUnit = new wxStaticText( m_sbViaSizer->GetStaticBox(), wxID_ANY, _("Unit"), wxDefaultPosition, wxDefaultSize, 0 ); @@ -203,7 +196,6 @@ DIALOG_TRACK_VIA_PROPERTIES_BASE::DIALOG_TRACK_VIA_PROPERTIES_BASE( wxWindow* pa fgViaRightSizer->Add( m_ViaDiameterLabel, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 5 ); m_ViaDiameterCtrl = new wxTextCtrl( m_sbViaSizer->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - m_ViaDiameterCtrl->SetMaxLength( 0 ); fgViaRightSizer->Add( m_ViaDiameterCtrl, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); m_ViaDiameterUnit = new wxStaticText( m_sbViaSizer->GetStaticBox(), wxID_ANY, _("Unit"), wxDefaultPosition, wxDefaultSize, 0 ); @@ -215,7 +207,6 @@ DIALOG_TRACK_VIA_PROPERTIES_BASE::DIALOG_TRACK_VIA_PROPERTIES_BASE( wxWindow* pa fgViaRightSizer->Add( m_ViaDrillLabel, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 5 ); m_ViaDrillCtrl = new wxTextCtrl( m_sbViaSizer->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - m_ViaDrillCtrl->SetMaxLength( 0 ); fgViaRightSizer->Add( m_ViaDrillCtrl, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); m_ViaDrillUnit = new wxStaticText( m_sbViaSizer->GetStaticBox(), wxID_ANY, _("Unit"), wxDefaultPosition, wxDefaultSize, 0 ); diff --git a/pcbnew/dialogs/dialog_track_via_properties_base.fbp b/pcbnew/dialogs/dialog_track_via_properties_base.fbp index a886bb710a..c285ca20de 100644 --- a/pcbnew/dialogs/dialog_track_via_properties_base.fbp +++ b/pcbnew/dialogs/dialog_track_via_properties_base.fbp @@ -1728,7 +1728,7 @@ 5 wxALIGN_CENTER_VERTICAL|wxEXPAND 0 - + 1 1 1 @@ -1742,6 +1742,7 @@ 1 0 + 1 1 @@ -1759,7 +1760,6 @@ 0 - 0 0 @@ -1772,6 +1772,7 @@ 1 Resizable + -1 1 @@ -1787,6 +1788,7 @@ + @@ -1810,8 +1812,6 @@ - - diff --git a/pcbnew/dialogs/dialog_track_via_properties_base.h b/pcbnew/dialogs/dialog_track_via_properties_base.h index 721d9144eb..2a0fa250b1 100644 --- a/pcbnew/dialogs/dialog_track_via_properties_base.h +++ b/pcbnew/dialogs/dialog_track_via_properties_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Jun 17 2015) +// C++ code generated with wxFormBuilder (version Aug 20 2017) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -65,7 +65,7 @@ class DIALOG_TRACK_VIA_PROPERTIES_BASE : public DIALOG_SHIM wxStaticText* m_TrackEndYUnit; wxStaticLine* m_trackStaticLine; wxStaticText* m_TrackWidthLabel; - wxTextCtrl* m_TrackWidthCtrl; + wxComboBox* m_TrackWidthCtrl; wxStaticText* m_TrackWidthUnit; wxCheckBox* m_trackNetclass; wxStaticText* m_TrackLayerLabel;