Add Enter event to coordinates and Segment, Rectangle properties

This commit is contained in:
Josue 2023-06-27 11:09:23 -05:00 committed by Josue Huaroto
parent 8d7255aae3
commit 54aaec3a57
4 changed files with 97 additions and 18 deletions

View File

@ -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 )
{

View File

@ -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 );

View File

@ -272,7 +272,7 @@
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="style">wxTE_PROCESS_ENTER</property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
@ -284,6 +284,7 @@
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnTextEnter">startCtrlOnTextEnter</event>
</object>
</object>
<object class="gbsizeritem" expanded="1">
@ -470,7 +471,7 @@
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="style">wxTE_PROCESS_ENTER</property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
@ -482,6 +483,7 @@
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnTextEnter">startCtrlOnTextEnter</event>
</object>
</object>
<object class="gbsizeritem" expanded="1">
@ -733,7 +735,7 @@
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="style">wxTE_PROCESS_ENTER</property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
@ -745,6 +747,7 @@
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnTextEnter">endCtrlOnTextEnter</event>
</object>
</object>
<object class="gbsizeritem" expanded="1">
@ -931,7 +934,7 @@
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="style">wxTE_PROCESS_ENTER</property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
@ -943,6 +946,7 @@
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnTextEnter">endCtrlOnTextEnter</event>
</object>
</object>
<object class="gbsizeritem" expanded="1">
@ -2540,7 +2544,7 @@
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="style">wxTE_PROCESS_ENTER</property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
@ -2552,6 +2556,7 @@
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnTextEnter">segmentOnTextEnter</event>
</object>
</object>
<object class="gbsizeritem" expanded="1">
@ -2735,7 +2740,7 @@
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="style">wxTE_PROCESS_ENTER</property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
@ -2747,6 +2752,7 @@
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnTextEnter">segmentOnTextEnter</event>
</object>
</object>
<object class="gbsizeritem" expanded="1">
@ -2930,7 +2936,7 @@
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="style">wxTE_PROCESS_ENTER</property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
@ -2942,6 +2948,7 @@
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnTextEnter">rectangleOnTextEnter</event>
</object>
</object>
<object class="gbsizeritem" expanded="1">
@ -3125,7 +3132,7 @@
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="style">wxTE_PROCESS_ENTER</property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
@ -3137,6 +3144,7 @@
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnTextEnter">rectangleOnTextEnter</event>
</object>
</object>
<object class="gbsizeritem" expanded="1">

View File

@ -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(); }