diff --git a/eeschema/dialogs/dialog_edit_component_in_schematic.cpp b/eeschema/dialogs/dialog_edit_component_in_schematic.cpp index 505b4a90e4..ad4f8dc905 100644 --- a/eeschema/dialogs/dialog_edit_component_in_schematic.cpp +++ b/eeschema/dialogs/dialog_edit_component_in_schematic.cpp @@ -21,9 +21,6 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -/** - * @file dialog_edit_component_in_schematic.cpp - */ #include #include @@ -46,6 +43,8 @@ #include #include +#include + #include #ifdef KICAD_SPICE #include @@ -130,6 +129,7 @@ private: void addFieldButtonHandler( wxCommandEvent& event ) override; void deleteFieldButtonHandler( wxCommandEvent& event ) override; void moveUpButtonHandler( wxCommandEvent& event ) override; + void moveDownButtonHandler( wxCommandEvent& event ) override; void showButtonHandler( wxCommandEvent& event ) override; void OnTestChipName( wxCommandEvent& event ) override; void OnSelectChipName( wxCommandEvent& event ) override; @@ -223,6 +223,12 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( wxWindow wxToolTip::Enable( true ); stdDialogButtonSizerOK->SetDefault(); + // Configure button logos + addFieldButton->SetBitmap( KiBitmap( plus_xpm ) ); + deleteFieldButton->SetBitmap( KiBitmap( minus_xpm ) ); + moveUpButton->SetBitmap( KiBitmap( go_up_xpm ) ); + moveDownButton->SetBitmap( KiBitmap( go_down_xpm ) ); + Fit(); } @@ -637,6 +643,44 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::moveUpButtonHandler( wxCommandEvent& ev } +void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::moveDownButtonHandler( wxCommandEvent& event ) +{ + unsigned fieldNdx = getSelectedFieldNdx(); + + // Ensure there is at least one field after this one + if( fieldNdx >= ( m_FieldsBuf.size() - 1 ) ) + { + return; + } + + // The first field which can be moved up is the second user field + // so any field which id < MANDATORY_FIELDS cannot be moved down + if( fieldNdx < MANDATORY_FIELDS ) + return; + + if( !copyPanelToSelectedField() ) + return; + + // swap the fieldNdx field with the one before it, in both the vector + // and in the fieldListCtrl + SCH_FIELD tmp = m_FieldsBuf[fieldNdx + 1]; + + m_FieldsBuf[fieldNdx + 1] = m_FieldsBuf[fieldNdx]; + setRowItem( fieldNdx + 1, m_FieldsBuf[fieldNdx] ); + m_FieldsBuf[fieldNdx + 1].SetId( fieldNdx + 1 ); + + m_FieldsBuf[fieldNdx] = tmp; + setRowItem( fieldNdx, tmp ); + m_FieldsBuf[fieldNdx].SetId( fieldNdx ); + + updateDisplay( ); + + m_skipCopyFromPanel = true; + setSelectedFieldNdx( fieldNdx + 1 ); + m_skipCopyFromPanel = false; +} + + void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::setSelectedFieldNdx( int aFieldNdx ) { /* deselect old selection, but I think this is done by single selection diff --git a/eeschema/dialogs/dialog_edit_component_in_schematic_fbp.cpp b/eeschema/dialogs/dialog_edit_component_in_schematic_fbp.cpp index 08af0ec4ca..c6e399218d 100644 --- a/eeschema/dialogs/dialog_edit_component_in_schematic_fbp.cpp +++ b/eeschema/dialogs/dialog_edit_component_in_schematic_fbp.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Feb 19 2017) +// C++ code generated with wxFormBuilder (version Mar 22 2017) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -123,20 +123,34 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP( gridStaticBoxSizer->Add( fieldListCtrl, 1, wxALL|wxEXPAND, 8 ); - addFieldButton = new wxButton( gridStaticBoxSizer->GetStaticBox(), wxID_ANY, _("New Field"), wxDefaultPosition, wxDefaultSize, 0 ); - addFieldButton->SetToolTip( _("Create new custom field") ); + wxBoxSizer* bSizer9; + bSizer9 = new wxBoxSizer( wxHORIZONTAL ); - gridStaticBoxSizer->Add( addFieldButton, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); - - deleteFieldButton = new wxButton( gridStaticBoxSizer->GetStaticBox(), wxID_ANY, _("Delete Field"), wxDefaultPosition, wxDefaultSize, 0 ); - deleteFieldButton->SetToolTip( _("Delete optional field") ); - - gridStaticBoxSizer->Add( deleteFieldButton, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); - - moveUpButton = new wxButton( gridStaticBoxSizer->GetStaticBox(), wxID_ANY, _("Move Up"), wxDefaultPosition, wxDefaultSize, 0 ); + moveUpButton = new wxBitmapButton( gridStaticBoxSizer->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW ); moveUpButton->SetToolTip( _("Move the selected optional field up one position") ); - gridStaticBoxSizer->Add( moveUpButton, 0, wxALL|wxEXPAND, 5 ); + bSizer9->Add( moveUpButton, 0, wxALL, 5 ); + + moveDownButton = new wxBitmapButton( gridStaticBoxSizer->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW ); + moveDownButton->SetToolTip( _("Move the selected optional field down one position") ); + + bSizer9->Add( moveDownButton, 0, wxALL, 5 ); + + + bSizer9->Add( 0, 0, 1, wxEXPAND, 5 ); + + deleteFieldButton = new wxBitmapButton( gridStaticBoxSizer->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW ); + deleteFieldButton->SetToolTip( _("Delete optional field") ); + + bSizer9->Add( deleteFieldButton, 0, wxALL, 5 ); + + addFieldButton = new wxBitmapButton( gridStaticBoxSizer->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW ); + addFieldButton->SetToolTip( _("Create new custom field") ); + + bSizer9->Add( addFieldButton, 0, wxALL, 5 ); + + + gridStaticBoxSizer->Add( bSizer9, 0, wxEXPAND, 5 ); fieldsSizer->Add( gridStaticBoxSizer, 3, wxEXPAND|wxRIGHT|wxLEFT, 0 ); @@ -298,9 +312,10 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP( defaultsButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::SetInitCmp ), NULL, this ); fieldListCtrl->Connect( wxEVT_COMMAND_LIST_ITEM_DESELECTED, wxListEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::OnListItemDeselected ), NULL, this ); fieldListCtrl->Connect( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::OnListItemSelected ), NULL, this ); - addFieldButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::addFieldButtonHandler ), NULL, this ); - deleteFieldButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::deleteFieldButtonHandler ), NULL, this ); moveUpButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::moveUpButtonHandler ), NULL, this ); + moveDownButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::moveDownButtonHandler ), NULL, this ); + deleteFieldButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::deleteFieldButtonHandler ), NULL, this ); + addFieldButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::addFieldButtonHandler ), NULL, this ); m_show_datasheet_button->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::showButtonHandler ), NULL, this ); stdDialogButtonSizerCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::OnCancelButtonClick ), NULL, this ); stdDialogButtonSizerOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::OnOKButtonClick ), NULL, this ); @@ -317,9 +332,10 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::~DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP( defaultsButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::SetInitCmp ), NULL, this ); fieldListCtrl->Disconnect( wxEVT_COMMAND_LIST_ITEM_DESELECTED, wxListEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::OnListItemDeselected ), NULL, this ); fieldListCtrl->Disconnect( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::OnListItemSelected ), NULL, this ); - addFieldButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::addFieldButtonHandler ), NULL, this ); - deleteFieldButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::deleteFieldButtonHandler ), NULL, this ); moveUpButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::moveUpButtonHandler ), NULL, this ); + moveDownButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::moveDownButtonHandler ), NULL, this ); + deleteFieldButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::deleteFieldButtonHandler ), NULL, this ); + addFieldButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::addFieldButtonHandler ), NULL, this ); m_show_datasheet_button->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::showButtonHandler ), NULL, this ); stdDialogButtonSizerCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::OnCancelButtonClick ), NULL, this ); stdDialogButtonSizerOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::OnOKButtonClick ), NULL, this ); diff --git a/eeschema/dialogs/dialog_edit_component_in_schematic_fbp.fbp b/eeschema/dialogs/dialog_edit_component_in_schematic_fbp.fbp index 6c1d9b2733..20b2332076 100644 --- a/eeschema/dialogs/dialog_edit_component_in_schematic_fbp.fbp +++ b/eeschema/dialogs/dialog_edit_component_in_schematic_fbp.fbp @@ -731,11 +731,11 @@ - + 5 wxEXPAND|wxALL 0 - + wxID_ANY Component Name: @@ -835,11 +835,11 @@ - + 5 wxEXPAND 1 - + bSizerChpinameButt wxHORIZONTAL @@ -1461,7 +1461,7 @@ 5 wxALL|wxEXPAND 1 - + wxID_ANY Fields @@ -1470,11 +1470,11 @@ 1 none - + 0 wxEXPAND|wxRIGHT|wxLEFT 3 - + wxID_ANY -1,-1 @@ -1588,268 +1588,397 @@ - + 5 - wxEXPAND|wxTOP|wxRIGHT|wxLEFT + wxEXPAND 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - New Field - - 0 - - - 0 + - 1 - addFieldButton - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - Create new custom field - - wxFILTER_NONE - wxDefaultValidator - - - - - addFieldButtonHandler - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND|wxTOP|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Delete Field - - 0 - - - 0 - - 1 - deleteFieldButton - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - Delete optional field - - wxFILTER_NONE - wxDefaultValidator - - - - - deleteFieldButtonHandler - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL|wxEXPAND - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Move Up - - 0 - - - 0 - - 1 - moveUpButton - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - Move the selected optional field up one position - - wxFILTER_NONE - wxDefaultValidator - - - - - moveUpButtonHandler - - - - - - - - - - - - - - - - - - - - - - - + bSizer9 + wxHORIZONTAL + none + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + + wxID_ANY + MyButton + + 0 + + + 0 + + 1 + moveUpButton + 1 + + + protected + 1 + + Resizable + + 1 + + wxBU_AUTODRAW + + 0 + Move the selected optional field up one position + + wxFILTER_NONE + wxDefaultValidator + + + + + moveUpButtonHandler + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + + wxID_ANY + MyButton + + 0 + + + 0 + + 1 + moveDownButton + 1 + + + protected + 1 + + Resizable + + 1 + + wxBU_AUTODRAW + + 0 + Move the selected optional field down one position + + wxFILTER_NONE + wxDefaultValidator + + + + + moveDownButtonHandler + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 1 + + 0 + protected + 0 + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + + wxID_ANY + MyButton + + 0 + + + 0 + + 1 + deleteFieldButton + 1 + + + protected + 1 + + Resizable + + 1 + + wxBU_AUTODRAW + + 0 + Delete optional field + + wxFILTER_NONE + wxDefaultValidator + + + + + deleteFieldButtonHandler + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + + wxID_ANY + MyButton + + 0 + + + 0 + + 1 + addFieldButton + 1 + + + protected + 1 + + Resizable + + 1 + + wxBU_AUTODRAW + + 0 + Create new custom field + + wxFILTER_NONE + wxDefaultValidator + + + + + addFieldButtonHandler + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/eeschema/dialogs/dialog_edit_component_in_schematic_fbp.h b/eeschema/dialogs/dialog_edit_component_in_schematic_fbp.h index ce223ac797..b449d2b4ba 100644 --- a/eeschema/dialogs/dialog_edit_component_in_schematic_fbp.h +++ b/eeschema/dialogs/dialog_edit_component_in_schematic_fbp.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Feb 19 2017) +// C++ code generated with wxFormBuilder (version Mar 22 2017) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -29,6 +29,10 @@ class DIALOG_SHIM; #include #include #include +#include +#include +#include +#include #include /////////////////////////////////////////////////////////////////////////// @@ -58,9 +62,10 @@ class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP : public DIALOG_SHIM wxButton* spiceFieldsButton; wxButton* defaultsButton; wxListCtrl* fieldListCtrl; - wxButton* addFieldButton; - wxButton* deleteFieldButton; - wxButton* moveUpButton; + wxBitmapButton* moveUpButton; + wxBitmapButton* moveDownButton; + wxBitmapButton* deleteFieldButton; + wxBitmapButton* addFieldButton; wxRadioBox* m_FieldHJustifyCtrl; wxRadioBox* m_FieldVJustifyCtrl; wxCheckBox* showCheckBox; @@ -93,9 +98,10 @@ class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP : public DIALOG_SHIM virtual void SetInitCmp( wxCommandEvent& event ) { event.Skip(); } virtual void OnListItemDeselected( wxListEvent& event ) { event.Skip(); } virtual void OnListItemSelected( wxListEvent& event ) { event.Skip(); } - virtual void addFieldButtonHandler( wxCommandEvent& event ) { event.Skip(); } - virtual void deleteFieldButtonHandler( wxCommandEvent& event ) { event.Skip(); } virtual void moveUpButtonHandler( wxCommandEvent& event ) { event.Skip(); } + virtual void moveDownButtonHandler( wxCommandEvent& event ) { event.Skip(); } + virtual void deleteFieldButtonHandler( wxCommandEvent& event ) { event.Skip(); } + virtual void addFieldButtonHandler( wxCommandEvent& event ) { event.Skip(); } virtual void showButtonHandler( wxCommandEvent& event ) { event.Skip(); } virtual void OnCancelButtonClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnOKButtonClick( wxCommandEvent& event ) { event.Skip(); }