fix propgrid sample when WXWIN_COMPATIBILITY_3_0==0, broken in r75561

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76563 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Paul Cornett
2014-05-17 17:22:30 +00:00
parent ebc6161c59
commit 8a78ec6b38
2 changed files with 9 additions and 14 deletions

View File

@@ -22,6 +22,7 @@
#endif #endif
#include "wx/fontdlg.h" #include "wx/fontdlg.h"
#include "wx/numformatter.h"
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
@@ -343,17 +344,12 @@ public:
void SetPrecision ( int precision ) void SetPrecision ( int precision )
{ {
m_precision = precision; m_precision = precision;
m_dtoaTemplate.Empty();
} }
protected: protected:
// Mandatory array of type // Mandatory array of type
wxArrayDouble m_array; wxArrayDouble m_array;
// Use this to avoid extra wxString creation+Printf
// on double-to-wxString conversion.
wxString m_dtoaTemplate;
int m_precision; int m_precision;
// Mandatory overridden methods // Mandatory overridden methods
@@ -376,9 +372,8 @@ IMPLEMENT_DYNAMIC_CLASS(wxArrayDoubleEditorDialog, wxPGArrayEditorDialog)
wxString wxArrayDoubleEditorDialog::ArrayGet( size_t index ) wxString wxArrayDoubleEditorDialog::ArrayGet( size_t index )
{ {
wxString str; return wxNumberFormatter::ToString(
wxPropertyGrid::DoubleToString(str,m_array[index],m_precision,true,&m_dtoaTemplate); m_array[index], m_precision, wxNumberFormatter::Style_NoTrailingZeroes);
return str;
} }
size_t wxArrayDoubleEditorDialog::ArrayGetCount() size_t wxArrayDoubleEditorDialog::ArrayGetCount()
@@ -551,8 +546,6 @@ wxString wxArrayDoubleProperty::ValueToString( wxVariant& value,
void wxArrayDoubleProperty::GenerateValueAsString( wxString& target, int prec, bool removeZeroes ) const void wxArrayDoubleProperty::GenerateValueAsString( wxString& target, int prec, bool removeZeroes ) const
{ {
wxString s;
wxString template_str;
wxChar between[3] = wxT(", "); wxChar between[3] = wxT(", ");
size_t i; size_t i;
@@ -561,13 +554,13 @@ void wxArrayDoubleProperty::GenerateValueAsString( wxString& target, int prec, b
target.Empty(); target.Empty();
const wxArrayDouble& value = wxArrayDoubleRefFromVariant(m_value); const wxArrayDouble& value = wxArrayDoubleRefFromVariant(m_value);
wxNumberFormatter::Style style = wxNumberFormatter::Style_None;
if (removeZeroes)
style = wxNumberFormatter::Style_NoTrailingZeroes;
for ( i=0; i<value.GetCount(); i++ ) for ( i=0; i<value.GetCount(); i++ )
{ {
target += wxNumberFormatter::ToString(value[i], prec, style);
wxPropertyGrid::DoubleToString(s,value[i],prec,removeZeroes,&template_str);
target += s;
if ( i<(value.GetCount()-1) ) if ( i<(value.GetCount()-1) )
target += between; target += between;

View File

@@ -891,6 +891,7 @@ bool FormMain::RunTests( bool fullTest, bool interactive )
RT_FAILURE(); RT_FAILURE();
} }
#if WXWIN_COMPATIBILITY_3_0
{ {
RT_START_TEST(DoubleToString) RT_START_TEST(DoubleToString)
@@ -911,6 +912,7 @@ bool FormMain::RunTests( bool fullTest, bool interactive )
if ( wxPropertyGrid::DoubleToString(s, -0.000123, 3, true) != "0" ) if ( wxPropertyGrid::DoubleToString(s, -0.000123, 3, true) != "0" )
RT_FAILURE(); RT_FAILURE();
} }
#endif
{ {
wxPropertyGridPage* page1; wxPropertyGridPage* page1;