Commit Graph

6 Commits

Author SHA1 Message Date
Vadim Zeitlin
3fc031e75b 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.
2021-08-20 23:37:28 +02:00
Vadim Zeitlin
b3cab73680 Use wxUILocale in wxNumberFormatter
Always use the UI locale conventions for floating point numbers in
wxNumberFormatter, making it different from wxString::{To,From}Double()
functions that use C locale, which may, or not, correspond to the UI
locale.
2021-08-20 23:37:28 +02:00
Vadim Zeitlin
eb64202ad4 Add support for unsigned long long to wxNumberFormatter
This is necessary in order to deal with the numbers greater than
wxINT64_MAX that can't be represented in just long long.

It also allows to implement the intuitive handling of minus sign for the
unsigned numbers, i.e. not to accept it in FromString(), unlike the
standard functions which do (and parse -1 as 0xffff...fff).

Also extend the tests to check for more boundary cases.
2021-02-22 11:49:19 +01:00
Vadim Zeitlin
d3f051e328 Document wxNumberFormatter overloads using long long
These overloads were added back in f2a5052baa (Add support for long long
to wxNumberFormatter., 2011-01-19) but never documented.
2021-02-21 16:43:04 +01:00
Vadim Zeitlin
6d0b86b7c7 Fix a typo in wxNumberFormatter styles documentation.
s/cab/can/

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73940 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2013-05-06 13:08:43 +00:00
Vadim Zeitlin
6686fbad16 Add wxNumberFormatter class helping to deal with thousands separators.
wxNumberFormatter formats and parses numbers with thousands separators.

Add the class itself as well as documentation and the unit test for it.

See #12166.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66710 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2011-01-19 10:47:40 +00:00