Пример #1
0
wxString wxNumberFormatter::PostProcessIntString(wxString s, int style)
{
    if ( style & Style_WithThousandsSep )
        AddThousandsSeparators(s);

    wxASSERT_MSG( !(style & Style_NoTrailingZeroes),
                  "Style_NoTrailingZeroes can't be used with integer values" );

    return s;
}
Пример #2
0
wxString wxNumberFormatter::ToString(double val, int precision, int style)
{
    wxString s = wxString::FromDouble(val,precision);

    if ( style & Style_WithThousandsSep )
        AddThousandsSeparators(s);

    if ( style & Style_NoTrailingZeroes )
        RemoveTrailingZeroes(s);

    return s;
}
Пример #3
0
wxString wxNumberFormatter::ToString(double val, int precision, int style)
{
    const wxString fmt = wxString::Format("%%.%df", precision);
    wxString s = wxString::Format(fmt, val);

    if ( style & Style_WithThousandsSep )
        AddThousandsSeparators(s);

    if ( style & Style_NoTrailingZeroes )
        RemoveTrailingZeroes(s);

    return s;
}
Пример #4
0
wxString NumberFormatter::PostProcessIntString(const wxString &sArg, int style)
{
   wxString s(sArg);

    if ( style & Style_WithThousandsSep )
        AddThousandsSeparators(s);

    wxASSERT_MSG( !(style & Style_NoTrailingZeroes),
                  wxT("Style_NoTrailingZeroes can't be used with integer values") );
    wxASSERT_MSG( !(style & Style_OneTrailingZero),
                  wxT("Style_OneTrailingZero can't be used with integer values") );
    wxASSERT_MSG( !(style & Style_TwoTrailingZeroes),
                  wxT("Style_TwoTrailingZeroes can't be used with integer values") );
    wxASSERT_MSG( !(style & Style_ThreeTrailingZeroes),
                  wxT("Style_ThreeTrailingZeroes can't be used with integer values") );

    return s;
}
Пример #5
0
wxString NumberFormatter::ToString(double val, int precision, int style)
{
    wxString format;
    if ( precision == -1 )
    {
        format = wxT("%g");
    }
    else // Use fixed precision.
    {
        format.Printf(wxT("%%.%df"), precision);
    }

    if (std::isnan(val))
    {
        return _("NaN");
    }
    if (std::isinf(val))
    {
        return _("-Infinity");
    }
    wxString s = wxString::Format(format, val);

    if ( style & Style_WithThousandsSep )
        AddThousandsSeparators(s);

    if ( precision != -1 )
    {
        if ( style & Style_NoTrailingZeroes )
            RemoveTrailingZeroes(s, 0);

        if ( style & Style_OneTrailingZero )
            RemoveTrailingZeroes(s, 1);

        if ( style & Style_TwoTrailingZeroes )
            RemoveTrailingZeroes(s, 2);

        if ( style & Style_ThreeTrailingZeroes )
            RemoveTrailingZeroes(s, 3);
    }
    return s;
}