diff --git a/eeschema/dialogs/dialog_edit_sheet_pin.cpp b/eeschema/dialogs/dialog_edit_sheet_pin.cpp index 476c845ab6..0d6a6b37b5 100644 --- a/eeschema/dialogs/dialog_edit_sheet_pin.cpp +++ b/eeschema/dialogs/dialog_edit_sheet_pin.cpp @@ -48,12 +48,12 @@ DIALOG_EDIT_SHEET_PIN::DIALOG_EDIT_SHEET_PIN( SCH_EDIT_FRAME* parent, SCH_SHEET_ m_choiceConnectionType->Append( sheetPinType ); m_choiceConnectionType->SetSelection( 0 ); - SetInitialFocus( m_textName ); + SetInitialFocus( m_comboName ); m_sdbSizerOK->SetDefault(); // Set invalid label characters list: SCH_NETNAME_VALIDATOR validator; - m_textName->SetValidator( validator ); + m_comboName->SetValidator( validator ); // Now all widgets have the size fixed, call FinishDialogSettings FinishDialogSettings(); @@ -76,8 +76,15 @@ DIALOG_EDIT_SHEET_PIN::DIALOG_EDIT_SHEET_PIN( SCH_EDIT_FRAME* parent, SCH_SHEET_ bool DIALOG_EDIT_SHEET_PIN::TransferDataToWindow() { - m_textName->SetValue( UnescapeString( m_sheetPin->GetText() ) ); - m_textName->SelectAll(); + SCH_SCREEN* screen = m_sheetPin->GetParent()->GetScreen(); + + for( SCH_ITEM* item : screen->Items().OfType( SCH_HIER_LABEL_T ) ) + { + m_comboName->Append( static_cast( item )->GetText() ); + } + + m_comboName->SetValue( UnescapeString( m_sheetPin->GetText() ) ); + m_comboName->SelectAll(); // Currently, eeschema uses only the text width as text size // (only the text width is saved in files), and expects text width = text height m_textSize.SetValue( m_sheetPin->GetTextWidth() ); @@ -92,7 +99,7 @@ bool DIALOG_EDIT_SHEET_PIN::TransferDataFromWindow() if( !m_sheetPin->IsNew() ) m_frame->SaveCopyInUndoList( (SCH_ITEM*) m_sheetPin->GetParent(), UR_CHANGED ); - m_sheetPin->SetText( EscapeString( m_textName->GetValue(), CTX_NETNAME ) ); + m_sheetPin->SetText( EscapeString( m_comboName->GetValue(), CTX_NETNAME ) ); // Currently, eeschema uses only the text width as text size, // and expects text width = text height m_sheetPin->SetTextSize( wxSize( m_textSize.GetValue(), m_textSize.GetValue() ) ); @@ -118,3 +125,20 @@ void DIALOG_EDIT_SHEET_PIN::OnSyntaxHelp( wxHyperlinkEvent& aEvent ) { SCH_TEXT::ShowSyntaxHelp( this ); } + + +void DIALOG_EDIT_SHEET_PIN::onComboBox( wxCommandEvent& aEvent ) +{ + SCH_SCREEN* screen = m_sheetPin->GetParent()->GetScreen(); + + for( SCH_ITEM* item : screen->Items().OfType( SCH_HIER_LABEL_T ) ) + { + auto hierLabelItem = static_cast( item ); + + if( m_comboName->GetValue().CmpNoCase( hierLabelItem->GetText() ) == 0 ) + { + m_choiceConnectionType->SetSelection( static_cast( hierLabelItem->GetShape() ) ); + break; + } + } +} diff --git a/eeschema/dialogs/dialog_edit_sheet_pin.h b/eeschema/dialogs/dialog_edit_sheet_pin.h index e3400dc264..b65d875f75 100644 --- a/eeschema/dialogs/dialog_edit_sheet_pin.h +++ b/eeschema/dialogs/dialog_edit_sheet_pin.h @@ -49,6 +49,7 @@ public: private: void onOKButton( wxCommandEvent& event ) override; void OnSyntaxHelp( wxHyperlinkEvent& event ) override; + void onComboBox( wxCommandEvent& event ) override; }; #endif // DIALOG_EDIT_SHEET_PIN_H diff --git a/eeschema/dialogs/dialog_edit_sheet_pin_base.cpp b/eeschema/dialogs/dialog_edit_sheet_pin_base.cpp index 1a22591885..04cce57a3d 100644 --- a/eeschema/dialogs/dialog_edit_sheet_pin_base.cpp +++ b/eeschema/dialogs/dialog_edit_sheet_pin_base.cpp @@ -29,10 +29,8 @@ DIALOG_EDIT_SHEET_PIN_BASE::DIALOG_EDIT_SHEET_PIN_BASE( wxWindow* parent, wxWind m_staticText1->Wrap( -1 ); fgSizer2->Add( m_staticText1, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT, 5 ); - m_textName = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - m_textName->SetMinSize( wxSize( 160,-1 ) ); - - fgSizer2->Add( m_textName, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT, 5 ); + m_comboName = new wxComboBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 ); + fgSizer2->Add( m_comboName, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxRIGHT|wxTOP, 5 ); fgSizer2->Add( 0, 0, 1, wxEXPAND, 5 ); @@ -103,6 +101,7 @@ DIALOG_EDIT_SHEET_PIN_BASE::DIALOG_EDIT_SHEET_PIN_BASE( wxWindow* parent, wxWind this->Centre( wxBOTH ); // Connect Events + m_comboName->Connect( wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler( DIALOG_EDIT_SHEET_PIN_BASE::onComboBox ), NULL, this ); m_hyperlink1->Connect( wxEVT_COMMAND_HYPERLINK, wxHyperlinkEventHandler( DIALOG_EDIT_SHEET_PIN_BASE::OnSyntaxHelp ), NULL, this ); m_sdbSizerOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_SHEET_PIN_BASE::onOKButton ), NULL, this ); } @@ -110,6 +109,7 @@ DIALOG_EDIT_SHEET_PIN_BASE::DIALOG_EDIT_SHEET_PIN_BASE( wxWindow* parent, wxWind DIALOG_EDIT_SHEET_PIN_BASE::~DIALOG_EDIT_SHEET_PIN_BASE() { // Disconnect Events + m_comboName->Disconnect( wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler( DIALOG_EDIT_SHEET_PIN_BASE::onComboBox ), NULL, this ); m_hyperlink1->Disconnect( wxEVT_COMMAND_HYPERLINK, wxHyperlinkEventHandler( DIALOG_EDIT_SHEET_PIN_BASE::OnSyntaxHelp ), NULL, this ); m_sdbSizerOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_SHEET_PIN_BASE::onOKButton ), NULL, this ); diff --git a/eeschema/dialogs/dialog_edit_sheet_pin_base.fbp b/eeschema/dialogs/dialog_edit_sheet_pin_base.fbp index 0f121f5de0..8ce9d277c8 100644 --- a/eeschema/dialogs/dialog_edit_sheet_pin_base.fbp +++ b/eeschema/dialogs/dialog_edit_sheet_pin_base.fbp @@ -146,9 +146,9 @@ 5 - wxEXPAND|wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT + wxALIGN_CENTER_VERTICAL|wxEXPAND|wxRIGHT|wxTOP 0 - + 1 1 1 @@ -162,6 +162,7 @@ 1 0 + 1 1 @@ -179,12 +180,11 @@ 0 - 0 0 - 160,-1 + 1 - m_textName + m_comboName 1 @@ -192,10 +192,11 @@ 1 Resizable + -1 1 - + ; ; forward_declare 0 @@ -206,6 +207,7 @@ + onComboBox diff --git a/eeschema/dialogs/dialog_edit_sheet_pin_base.h b/eeschema/dialogs/dialog_edit_sheet_pin_base.h index d0f05172e1..5675f09914 100644 --- a/eeschema/dialogs/dialog_edit_sheet_pin_base.h +++ b/eeschema/dialogs/dialog_edit_sheet_pin_base.h @@ -17,10 +17,11 @@ #include #include #include -#include +#include #include #include #include +#include #include #include #include @@ -37,7 +38,7 @@ class DIALOG_EDIT_SHEET_PIN_BASE : public DIALOG_SHIM protected: wxStaticText* m_staticText1; - wxTextCtrl* m_textName; + wxComboBox* m_comboName; wxHyperlinkCtrl* m_hyperlink1; wxStaticLine* m_staticline3; wxStaticText* m_textSizeLabel; @@ -51,6 +52,7 @@ class DIALOG_EDIT_SHEET_PIN_BASE : public DIALOG_SHIM wxButton* m_sdbSizerCancel; // Virtual event handlers, overide them in your derived class + virtual void onComboBox( wxCommandEvent& event ) { event.Skip(); } virtual void OnSyntaxHelp( wxHyperlinkEvent& event ) { event.Skip(); } virtual void onOKButton( wxCommandEvent& event ) { event.Skip(); }