Allow using wxLOCALE_CAT_DEFAULT for numeric or money locale info

Make GetInfo() return information for numbers by default in the Unix
version too instead of asserting, as this is more consistent with the
MSW and Mac versions and also seems more useful.
This commit is contained in:
Vadim Zeitlin 2021-08-03 01:41:27 +02:00
parent a4940bf696
commit 33ae58e457
2 changed files with 28 additions and 10 deletions

View File

@ -116,6 +116,9 @@ enum wxLocaleInfo
This value can be used with either wxLOCALE_CAT_NUMBER or
wxLOCALE_CAT_MONEY categories.
By default, i.e. when wxLOCALE_CAT_DEFAULT is used, the separator for
numbers is returned.
*/
wxLOCALE_THOUSANDS_SEP,
@ -124,6 +127,9 @@ enum wxLocaleInfo
This value can be used with either wxLOCALE_CAT_NUMBER or
wxLOCALE_CAT_MONEY categories.
By default, i.e. when wxLOCALE_CAT_DEFAULT is used, the decimal point
for numbers is returned.
*/
wxLOCALE_DECIMAL_POINT,

View File

@ -1935,22 +1935,34 @@ wxString wxLocale::GetInfo(wxLocaleInfo index, wxLocaleCategory cat)
switch ( index )
{
case wxLOCALE_THOUSANDS_SEP:
if ( cat == wxLOCALE_CAT_NUMBER )
return lc->thousands_sep;
else if ( cat == wxLOCALE_CAT_MONEY )
return lc->mon_thousands_sep;
switch ( cat )
{
case wxLOCALE_CAT_DEFAULT:
case wxLOCALE_CAT_NUMBER:
return lc->thousands_sep;
wxFAIL_MSG( "invalid wxLocaleCategory" );
case wxLOCALE_CAT_MONEY:
return lc->mon_thousands_sep;
default:
wxFAIL_MSG( "invalid wxLocaleCategory" );
}
break;
case wxLOCALE_DECIMAL_POINT:
if ( cat == wxLOCALE_CAT_NUMBER )
return lc->decimal_point;
else if ( cat == wxLOCALE_CAT_MONEY )
return lc->mon_decimal_point;
switch ( cat )
{
case wxLOCALE_CAT_DEFAULT:
case wxLOCALE_CAT_NUMBER:
return lc->decimal_point;
wxFAIL_MSG( "invalid wxLocaleCategory" );
case wxLOCALE_CAT_MONEY:
return lc->mon_decimal_point;
default:
wxFAIL_MSG( "invalid wxLocaleCategory" );
}
break;
case wxLOCALE_SHORT_DATE_FMT: