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