Add wxNumberFormatter::Format() for floating point numbers
The existing ToString() is not flexible enough to be used in wxGrid, which supports specifying the width (and not just the precision) as well as using formats other than "%g" and "%f" which are the only ones supported by the existing function. Note that currently the implementation simply calls wxString::Format() and then adjusts the decimal separator, but it could, in principle, use wxUILocale methods for formatting the floating point numbers using native platform functions for doing this, e.g. CFNumberFormatter under macOS.
This commit is contained in:
@@ -93,6 +93,16 @@ public:
|
||||
static wxString
|
||||
ToString(double val, int precision, int flags = Style_WithThousandsSep);
|
||||
|
||||
/**
|
||||
Format the given number using one of the floating point formats and
|
||||
ensure that the result uses the correct decimal separator.
|
||||
|
||||
Prefer using ToString() if possible, i.e. if format is "%g" or "%.Nf"
|
||||
which are supported by it directly.
|
||||
|
||||
@since 3.1.6
|
||||
*/
|
||||
static wxString Format(const wxString& format, double val);
|
||||
|
||||
/**
|
||||
Parse a string representation of a number possibly including thousands
|
||||
|
Reference in New Issue
Block a user