From 54aaec3a5745091b9830e08a07a224d91723ad32 Mon Sep 17 00:00:00 2001 From: Josue Date: Tue, 27 Jun 2023 11:09:23 -0500 Subject: [PATCH] Add Enter event to coordinates and Segment, Rectangle properties --- .../dialog_graphic_item_properties.cpp | 55 ++++++++++++++++++- .../dialog_graphic_item_properties_base.cpp | 32 ++++++++--- .../dialog_graphic_item_properties_base.fbp | 24 +++++--- .../dialog_graphic_item_properties_base.h | 4 ++ 4 files changed, 97 insertions(+), 18 deletions(-) diff --git a/pcbnew/dialogs/dialog_graphic_item_properties.cpp b/pcbnew/dialogs/dialog_graphic_item_properties.cpp index 0de8b9c199..c5a93b74bf 100644 --- a/pcbnew/dialogs/dialog_graphic_item_properties.cpp +++ b/pcbnew/dialogs/dialog_graphic_item_properties.cpp @@ -64,6 +64,12 @@ private: void onFilledCheckbox( wxCommandEvent& event ) override; void onLayerSelection( wxCommandEvent& event ) override; + void startCtrlOnTextEnter( wxCommandEvent& event ) override; + void endCtrlOnTextEnter( wxCommandEvent& event ) override; + + void segmentOnTextEnter( wxCommandEvent& event ) override; + + void rectangleOnTextEnter( wxCommandEvent& event ) override; bool Validate() override; @@ -230,6 +236,51 @@ void DIALOG_GRAPHIC_ITEM_PROPERTIES::onFilledCheckbox( wxCommandEvent& event ) } } +void DIALOG_GRAPHIC_ITEM_PROPERTIES::startCtrlOnTextEnter( wxCommandEvent& event ) +{ + switch( m_item->GetShape() ) + { + case SHAPE_T::SEGMENT: + TransferDataFromWindow(); + TransferDataToWindow(); + break; + case SHAPE_T::RECT: + TransferDataFromWindow(); + TransferDataToWindow(); + break; + default: + break; + } +} + +void DIALOG_GRAPHIC_ITEM_PROPERTIES::endCtrlOnTextEnter( wxCommandEvent& event ) +{ + switch( m_item->GetShape() ) + { + case SHAPE_T::SEGMENT: + TransferDataFromWindow(); + TransferDataToWindow(); + break; + case SHAPE_T::RECT: + TransferDataFromWindow(); + TransferDataToWindow(); + break; + default: + break; + } +} + +void DIALOG_GRAPHIC_ITEM_PROPERTIES::segmentOnTextEnter( wxCommandEvent& event ) +{ + TransferDataFromWindow(); + TransferDataToWindow(); +} + +void DIALOG_GRAPHIC_ITEM_PROPERTIES::rectangleOnTextEnter( wxCommandEvent& event ) +{ + TransferDataFromWindow(); + TransferDataToWindow(); +} bool DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataToWindow() { @@ -491,7 +542,7 @@ bool DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataFromWindow() { bool change_begin = ( begin_point != m_item->GetStart() ); bool change_end = ( end_point != m_item->GetEnd() ); - bool change_length = ( rectangle_height != m_rectangleHeight.GetValue() ); + bool change_height = ( rectangle_height != m_rectangleHeight.GetValue() ); bool change_width = ( rectangle_width != m_rectangleWidth.GetValue() ); @@ -500,7 +551,7 @@ bool DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataFromWindow() rectangle_height = m_rectangleHeight.GetValue(); rectangle_width = m_rectangleWidth.GetValue(); - if( change_length || change_width ) + if( change_height || change_width ) { if( change_end ) { diff --git a/pcbnew/dialogs/dialog_graphic_item_properties_base.cpp b/pcbnew/dialogs/dialog_graphic_item_properties_base.cpp index 418d44dfa9..b1f15c4bb8 100644 --- a/pcbnew/dialogs/dialog_graphic_item_properties_base.cpp +++ b/pcbnew/dialogs/dialog_graphic_item_properties_base.cpp @@ -34,7 +34,7 @@ DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE( wxWind m_startXLabel->Wrap( -1 ); m_sizerLeft->Add( m_startXLabel, wxGBPosition( 1, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); - m_startXCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + m_startXCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER ); m_sizerLeft->Add( m_startXCtrl, wxGBPosition( 1, 1 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 ); m_startXUnits = new wxStaticText( this, wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 ); @@ -45,7 +45,7 @@ DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE( wxWind m_startYLabel->Wrap( -1 ); m_sizerLeft->Add( m_startYLabel, wxGBPosition( 2, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); - m_startYCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + m_startYCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER ); m_sizerLeft->Add( m_startYCtrl, wxGBPosition( 2, 1 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 ); m_startYUnits = new wxStaticText( this, wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 ); @@ -60,7 +60,7 @@ DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE( wxWind m_endXLabel->Wrap( -1 ); m_sizerLeft->Add( m_endXLabel, wxGBPosition( 1, 3 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); - m_endXCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + m_endXCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER ); m_sizerLeft->Add( m_endXCtrl, wxGBPosition( 1, 4 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 ); m_endXUnits = new wxStaticText( this, wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 ); @@ -71,7 +71,7 @@ DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE( wxWind m_endYLabel->Wrap( -1 ); m_sizerLeft->Add( m_endYLabel, wxGBPosition( 2, 3 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); - m_endYCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + m_endYCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER ); m_sizerLeft->Add( m_endYCtrl, wxGBPosition( 2, 4 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 ); m_endYUnits = new wxStaticText( this, wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 ); @@ -145,7 +145,7 @@ DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE( wxWind m_segmentLengthLabel->Wrap( -1 ); gbSizer2->Add( m_segmentLengthLabel, wxGBPosition( 0, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxALL, 5 ); - m_segmentLengthCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + m_segmentLengthCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER ); gbSizer2->Add( m_segmentLengthCtrl, wxGBPosition( 0, 1 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxEXPAND|wxTOP, 5 ); m_segmentLengthUnits = new wxStaticText( this, wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 ); @@ -156,7 +156,7 @@ DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE( wxWind m_segmentAngleLabel->Wrap( -1 ); gbSizer2->Add( m_segmentAngleLabel, wxGBPosition( 1, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxALL, 5 ); - m_segmentAngleCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + m_segmentAngleCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER ); #ifdef __WXGTK__ if ( !m_segmentAngleCtrl->HasFlag( wxTE_MULTILINE ) ) { @@ -175,7 +175,7 @@ DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE( wxWind m_rectangleHeightLabel->Wrap( -1 ); gbSizer2->Add( m_rectangleHeightLabel, wxGBPosition( 2, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxALL, 5 ); - m_rectangleHeightCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + m_rectangleHeightCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER ); gbSizer2->Add( m_rectangleHeightCtrl, wxGBPosition( 2, 1 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxEXPAND|wxTOP, 5 ); m_rectangleHeightUnits = new wxStaticText( this, wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 ); @@ -186,7 +186,7 @@ DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE( wxWind m_rectangleWidthLabel->Wrap( -1 ); gbSizer2->Add( m_rectangleWidthLabel, wxGBPosition( 3, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxALL, 5 ); - m_rectangleWidthCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + m_rectangleWidthCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER ); gbSizer2->Add( m_rectangleWidthCtrl, wxGBPosition( 3, 1 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxEXPAND|wxTOP, 5 ); m_rectangleWidthUnits = new wxStaticText( this, wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 ); @@ -274,6 +274,14 @@ DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE( wxWind // Connect Events this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::OnClose ) ); this->Connect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::OnInitDlg ) ); + m_startXCtrl->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::startCtrlOnTextEnter ), NULL, this ); + m_startYCtrl->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::startCtrlOnTextEnter ), NULL, this ); + m_endXCtrl->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::endCtrlOnTextEnter ), NULL, this ); + m_endYCtrl->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::endCtrlOnTextEnter ), NULL, this ); + m_segmentLengthCtrl->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::segmentOnTextEnter ), NULL, this ); + m_segmentAngleCtrl->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::segmentOnTextEnter ), NULL, this ); + m_rectangleHeightCtrl->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::rectangleOnTextEnter ), NULL, this ); + m_rectangleWidthCtrl->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::rectangleOnTextEnter ), NULL, this ); m_filledCtrl->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::onFilledCheckbox ), NULL, this ); m_LayerSelectionCtrl->Connect( wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler( DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::onLayerSelection ), NULL, this ); } @@ -283,6 +291,14 @@ DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::~DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE() // Disconnect Events this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::OnClose ) ); this->Disconnect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::OnInitDlg ) ); + m_startXCtrl->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::startCtrlOnTextEnter ), NULL, this ); + m_startYCtrl->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::startCtrlOnTextEnter ), NULL, this ); + m_endXCtrl->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::endCtrlOnTextEnter ), NULL, this ); + m_endYCtrl->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::endCtrlOnTextEnter ), NULL, this ); + m_segmentLengthCtrl->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::segmentOnTextEnter ), NULL, this ); + m_segmentAngleCtrl->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::segmentOnTextEnter ), NULL, this ); + m_rectangleHeightCtrl->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::rectangleOnTextEnter ), NULL, this ); + m_rectangleWidthCtrl->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::rectangleOnTextEnter ), NULL, this ); m_filledCtrl->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::onFilledCheckbox ), NULL, this ); m_LayerSelectionCtrl->Disconnect( wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler( DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE::onLayerSelection ), NULL, this ); diff --git a/pcbnew/dialogs/dialog_graphic_item_properties_base.fbp b/pcbnew/dialogs/dialog_graphic_item_properties_base.fbp index 68befce936..eb28863cfd 100644 --- a/pcbnew/dialogs/dialog_graphic_item_properties_base.fbp +++ b/pcbnew/dialogs/dialog_graphic_item_properties_base.fbp @@ -272,7 +272,7 @@ Resizable 1 - + wxTE_PROCESS_ENTER ; ; forward_declare 0 @@ -284,6 +284,7 @@ + startCtrlOnTextEnter @@ -470,7 +471,7 @@ Resizable 1 - + wxTE_PROCESS_ENTER ; ; forward_declare 0 @@ -482,6 +483,7 @@ + startCtrlOnTextEnter @@ -733,7 +735,7 @@ Resizable 1 - + wxTE_PROCESS_ENTER ; ; forward_declare 0 @@ -745,6 +747,7 @@ + endCtrlOnTextEnter @@ -931,7 +934,7 @@ Resizable 1 - + wxTE_PROCESS_ENTER ; ; forward_declare 0 @@ -943,6 +946,7 @@ + endCtrlOnTextEnter @@ -2540,7 +2544,7 @@ Resizable 1 - + wxTE_PROCESS_ENTER ; ; forward_declare 0 @@ -2552,6 +2556,7 @@ + segmentOnTextEnter @@ -2735,7 +2740,7 @@ Resizable 1 - + wxTE_PROCESS_ENTER ; ; forward_declare 0 @@ -2747,6 +2752,7 @@ + segmentOnTextEnter @@ -2930,7 +2936,7 @@ Resizable 1 - + wxTE_PROCESS_ENTER ; ; forward_declare 0 @@ -2942,6 +2948,7 @@ + rectangleOnTextEnter @@ -3125,7 +3132,7 @@ Resizable 1 - + wxTE_PROCESS_ENTER ; ; forward_declare 0 @@ -3137,6 +3144,7 @@ + rectangleOnTextEnter diff --git a/pcbnew/dialogs/dialog_graphic_item_properties_base.h b/pcbnew/dialogs/dialog_graphic_item_properties_base.h index 53f8a1155f..1a9aee9008 100644 --- a/pcbnew/dialogs/dialog_graphic_item_properties_base.h +++ b/pcbnew/dialogs/dialog_graphic_item_properties_base.h @@ -101,6 +101,10 @@ class DIALOG_GRAPHIC_ITEM_PROPERTIES_BASE : public DIALOG_SHIM // Virtual event handlers, override them in your derived class virtual void OnClose( wxCloseEvent& event ) { event.Skip(); } virtual void OnInitDlg( wxInitDialogEvent& event ) { event.Skip(); } + virtual void startCtrlOnTextEnter( wxCommandEvent& event ) { event.Skip(); } + virtual void endCtrlOnTextEnter( wxCommandEvent& event ) { event.Skip(); } + virtual void segmentOnTextEnter( wxCommandEvent& event ) { event.Skip(); } + virtual void rectangleOnTextEnter( wxCommandEvent& event ) { event.Skip(); } virtual void onFilledCheckbox( wxCommandEvent& event ) { event.Skip(); } virtual void onLayerSelection( wxCommandEvent& event ) { event.Skip(); }