From 353f1c5491b844fa9d854e44f36a5d608ac25feb Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 5 Jan 2014 21:10:58 +0000 Subject: [PATCH] Deprecate wxPropertyGrid::DoubleToString(). Simply use wxNumberFormatter instead, this reduces code duplication and avoids bugs due to formatting inconsistencies in DoubleToString(). Closes #15625. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@75561 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/propgrid/propgrid.h | 2 ++ src/propgrid/advprops.cpp | 3 ++- src/propgrid/props.cpp | 11 ++++++----- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/include/wx/propgrid/propgrid.h b/include/wx/propgrid/propgrid.h index 9b12b2eb71..45cdf1c395 100644 --- a/include/wx/propgrid/propgrid.h +++ b/include/wx/propgrid/propgrid.h @@ -1568,6 +1568,7 @@ public: wxRect& rect, int flags ); +#if WXWIN_COMPATIBILITY_3_0 /** Standardized double-to-string conversion. */ static const wxString& DoubleToString( wxString& target, @@ -1575,6 +1576,7 @@ public: int precision, bool removeZeroes, wxString* precTemplate = NULL ); +#endif // WXWIN_COMPATIBILITY_3_0 /** Call this from wxPGProperty::OnEvent() to cause property value to be diff --git a/src/propgrid/advprops.cpp b/src/propgrid/advprops.cpp index 4f6940be06..19295211fb 100644 --- a/src/propgrid/advprops.cpp +++ b/src/propgrid/advprops.cpp @@ -62,6 +62,7 @@ #endif #include "wx/odcombo.h" +#include "wx/numformatter.h" // ----------------------------------------------------------------------- @@ -361,7 +362,7 @@ bool wxPGSpinCtrlEditor::OnEvent( wxPropertyGrid* propgrid, wxPGProperty* proper // Min/Max check wxFloatProperty::DoValidation(property, v_d, NULL, mode); - wxPropertyGrid::DoubleToString(s, v_d, 6, true, NULL); + s = wxNumberFormatter::ToString(v_d, -1, wxNumberFormatter::Style_None); } else { diff --git a/src/propgrid/props.cpp b/src/propgrid/props.cpp index c79faae159..8aba9bd222 100644 --- a/src/propgrid/props.cpp +++ b/src/propgrid/props.cpp @@ -52,6 +52,7 @@ #include "wx/filename.h" #include "wx/propgrid/propgrid.h" +#include "wx/numformatter.h" #define wxPG_CUSTOM_IMAGE_WIDTH 20 // for wxColourProperty etc. @@ -667,6 +668,7 @@ wxFloatProperty::wxFloatProperty( const wxString& label, wxFloatProperty::~wxFloatProperty() { } +#if WXWIN_COMPATIBILITY_3_0 // This helper method provides standard way for floating point-using // properties to convert values to string. const wxString& wxPropertyGrid::DoubleToString(wxString& target, @@ -738,6 +740,7 @@ const wxString& wxPropertyGrid::DoubleToString(wxString& target, return target; } +#endif // WXWIN_COMPATIBILITY_3_0 wxString wxFloatProperty::ValueToString( wxVariant& value, int argFlags ) const @@ -745,11 +748,9 @@ wxString wxFloatProperty::ValueToString( wxVariant& value, wxString text; if ( !value.IsNull() ) { - wxPropertyGrid::DoubleToString(text, - value, - m_precision, - !(argFlags & wxPG_FULL_VALUE), - NULL); + text = wxNumberFormatter::ToString(value.GetDouble(), m_precision, + argFlags & wxPG_FULL_VALUE ? wxNumberFormatter::Style_None + : wxNumberFormatter::Style_NoTrailingZeroes); } return text; }