Replace wxFloatingPointValidator by our UNIT_BINDER in DIALOG_TEXT_PROPERTIES.

wxFloatingPointValidator has some limitations, but mainly the change is a try
to fix an annoying issue (#6670) we cannot reproduce but is probably related
to a locale issue.
This commit is contained in:
jean-pierre charras 2020-12-09 19:38:35 +01:00
parent e8bc4632b4
commit 676d35f559
4 changed files with 24 additions and 13 deletions

View File

@ -57,7 +57,8 @@ UNIT_BINDER::UNIT_BINDER( EDA_DRAW_FRAME* aParent,
textEntry->ChangeValue( wxT( "0" ) );
}
m_unitLabel->SetLabel( GetAbbreviatedUnitsLabel( m_units, m_useMils ) );
if( m_unitLabel )
m_unitLabel->SetLabel( GetAbbreviatedUnitsLabel( m_units, m_useMils ) );
m_value->Connect( wxEVT_SET_FOCUS, wxFocusEventHandler( UNIT_BINDER::onSetFocus ), NULL, this );
m_value->Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( UNIT_BINDER::onKillFocus ), NULL, this );
@ -69,7 +70,9 @@ void UNIT_BINDER::SetUnits( EDA_UNITS_T aUnits, bool aUseMils )
{
m_units = aUnits;
m_useMils = aUseMils;
m_unitLabel->SetLabel( GetAbbreviatedUnitsLabel( m_units, m_useMils ) );
if( m_unitLabel )
m_unitLabel->SetLabel( GetAbbreviatedUnitsLabel( m_units, m_useMils ) );
}
@ -208,7 +211,8 @@ void UNIT_BINDER::SetValue( wxString aValue )
if( m_allowEval )
m_eval.Clear();
m_unitLabel->SetLabel( GetAbbreviatedUnitsLabel( m_units, m_useMils ) );
if( m_unitLabel )
m_unitLabel->SetLabel( GetAbbreviatedUnitsLabel( m_units, m_useMils ) );
}
@ -231,7 +235,8 @@ void UNIT_BINDER::ChangeValue( wxString aValue )
if( m_allowEval )
m_eval.Clear();
m_unitLabel->SetLabel( GetAbbreviatedUnitsLabel( m_units, m_useMils ) );
if( m_unitLabel )
m_unitLabel->SetLabel( GetAbbreviatedUnitsLabel( m_units, m_useMils ) );
}
@ -278,7 +283,9 @@ void UNIT_BINDER::Enable( bool aEnable )
{
m_label->Enable( aEnable );
m_value->Enable( aEnable );
m_unitLabel->Enable( aEnable );
if( m_unitLabel )
m_unitLabel->Enable( aEnable );
}
@ -286,6 +293,8 @@ void UNIT_BINDER::Show( bool aShow )
{
m_label->Show( aShow );
m_value->Show( aShow );
m_unitLabel->Show( aShow );
if( m_unitLabel )
m_unitLabel->Show( aShow );
}

View File

@ -48,6 +48,7 @@ public:
* @param aValue is the control used to edit or display the given value (wxTextCtrl,
* wxComboBox, wxStaticText, etc.).
* @param aUnitLabel is the units label displayed after the text input widget
* can be nullptr
* @param aUseMils specifies the use of mils for imperial units (instead of inches)
* @param aAllowEval indicates \a aTextInput's content should be eval'ed before storing
*/

View File

@ -65,7 +65,7 @@ DIALOG_TEXT_PROPERTIES::DIALOG_TEXT_PROPERTIES( PCB_BASE_EDIT_FRAME* aParent, BO
m_posY( aParent, m_PositionYLabel, m_PositionYCtrl, m_PositionYUnits ),
m_linesThickness( aParent, m_LinesThicknessLabel, m_LinesThicknessCtrl,
m_LinesThicknessUnits, true ),
m_OrientValidator( 1, &m_OrientValue )
m_orientation( aParent, m_OrientLabel, m_OrientCtrl, nullptr, true )
{
wxString title;
@ -140,9 +140,7 @@ DIALOG_TEXT_PROPERTIES::DIALOG_TEXT_PROPERTIES( PCB_BASE_EDIT_FRAME* aParent, BO
m_LayerSelectionCtrl->Resync();
m_OrientValue = 0.0;
m_OrientValidator.SetRange( -360.0, 360.0 );
m_OrientCtrl->SetValidator( m_OrientValidator );
m_OrientValidator.SetWindow( m_OrientCtrl );
m_orientation.SetUnits( DEGREES );
// Handle decimal separators in combo dropdown
for( size_t i = 0; i < m_OrientCtrl->GetCount(); ++i )
@ -344,7 +342,8 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataToWindow()
m_Italic->SetValue( m_edaText->IsItalic() );
EDA_TEXT_HJUSTIFY_T hJustify = m_edaText->GetHorizJustify();
m_JustifyChoice->SetSelection( (int) hJustify + 1 );
m_OrientValue = m_edaText->GetTextAngleDegrees();
m_OrientValue = m_edaText->GetTextAngle();
m_orientation.SetValue( m_OrientValue );
m_Mirrored->SetValue( m_edaText->IsMirrored() );
if( m_modText )
@ -436,7 +435,9 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataFromWindow()
m_edaText->SetVisible( m_Visible->GetValue() );
m_edaText->SetItalic( m_Italic->GetValue() );
m_edaText->SetTextAngle( KiROUND( m_OrientValue * 10.0 ) );
m_OrientValue = m_orientation.GetValue();
NORMALIZE_ANGLE_180( m_OrientValue );
m_edaText->SetTextAngle( m_OrientValue );
m_edaText->SetMirrored( m_Mirrored->GetValue() );
if( m_modText )

View File

@ -57,8 +57,8 @@ private:
UNIT_BINDER m_posX;
UNIT_BINDER m_posY;
UNIT_BINDER m_linesThickness; // lines thikness for dimension graphic
UNIT_BINDER m_orientation; // rotation in degrees
wxFloatingPointValidator<double> m_OrientValidator;
double m_OrientValue;
bool TransferDataToWindow() override;