diff --git a/common/properties/pg_editors.cpp b/common/properties/pg_editors.cpp index 1ae3446ba8..b66eada40c 100644 --- a/common/properties/pg_editors.cpp +++ b/common/properties/pg_editors.cpp @@ -76,13 +76,28 @@ wxPGWindowList PG_UNIT_EDITOR::CreateControls( wxPropertyGrid* aPropGrid, wxPGPr else if( dynamic_cast( aProperty ) ) m_unitBinder->SetUnits( EDA_UNITS::DEGREES ); + UpdateControl( aProperty, win ); + return ret; } void PG_UNIT_EDITOR::UpdateControl( wxPGProperty* aProperty, wxWindow* aCtrl ) const { - m_unitBinder->ChangeValue( aProperty->GetValueAsString() ); + wxVariant var = aProperty->GetValue(); + + if( var.GetType() == wxPG_VARIANT_TYPE_LONG ) + { + m_unitBinder->ChangeValue( var.GetLong() ); + } + else if( var.GetType() == wxPG_VARIANT_TYPE_DOUBLE ) + { + m_unitBinder->ChangeValue( var.GetDouble() ); + } + else + { + wxFAIL_MSG( wxT( "PG_UNIT_EDITOR should only be used with numeric properties!" ) ); + } } diff --git a/common/properties/pg_properties.cpp b/common/properties/pg_properties.cpp index f4bf15191c..618b2b8bbc 100644 --- a/common/properties/pg_properties.cpp +++ b/common/properties/pg_properties.cpp @@ -194,7 +194,6 @@ bool PGPROPERTY_DISTANCE::StringToDistance( wxVariant& aVariant, const wxString& wxString PGPROPERTY_DISTANCE::DistanceToString( wxVariant& aVariant, int aArgFlags ) const { wxCHECK( aVariant.GetType() == wxPG_VARIANT_TYPE_LONG, wxEmptyString ); - // TODO(JE) This should be handled by UNIT_BINDER long distanceIU = aVariant.GetLong(); diff --git a/common/widgets/unit_binder.cpp b/common/widgets/unit_binder.cpp index bd71f8fbca..667abac5b5 100644 --- a/common/widgets/unit_binder.cpp +++ b/common/widgets/unit_binder.cpp @@ -236,7 +236,18 @@ void UNIT_BINDER::onKillFocus( wxFocusEvent& aEvent ) if( m_eval.Process( textEntry->GetValue() ) ) { textEntry->GetSelection( &m_selStart, &m_selEnd ); - textEntry->ChangeValue( m_eval.Result() ); + + wxString value = m_eval.Result(); + + if( m_unitsInValue ) + { + if( !( m_units == EDA_UNITS::DEGREES || m_units == EDA_UNITS::PERCENT ) ) + value += wxT( " " ); + + value += EDA_UNIT_UTILS::GetLabel( m_units, m_dataType ); + } + + textEntry->ChangeValue( value ); #ifdef __WXGTK__ // Manually copy the selected text to the primary selection clipboard