Fix several rounding problems with float values in wxPropertyGrid.

Loss of precision when converting floating point numbers to text and back
could result in several problems, notably comparing a valid value with the
minimum could fail after a round trip through wxSpinCtrl.

Fix this by using a specialization of NumericValidation() handling floating
point values specially and correctly.

Closes #15625.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@75980 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2014-02-22 14:54:54 +00:00
parent 4ec4dcd3f5
commit c59b815f2c
3 changed files with 125 additions and 2 deletions

View File

@@ -362,7 +362,14 @@ bool wxPGSpinCtrlEditor::OnEvent( wxPropertyGrid* propgrid, wxPGProperty* proper
// Min/Max check
wxFloatProperty::DoValidation(property, v_d, NULL, mode);
s = wxNumberFormatter::ToString(v_d, -1, wxNumberFormatter::Style_None);
int precision = -1;
wxVariant v = property->GetAttribute(wxPG_FLOAT_PRECISION);
if ( !v.IsNull() )
{
precision = v.GetInteger();
}
s = wxNumberFormatter::ToString(v_d, precision, wxNumberFormatter::Style_NoTrailingZeroes);
}
else
{