2008-10-17 16:27:36 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: xlocale.h
|
|
|
|
// Purpose: interface of wxXLocale
|
|
|
|
// Author: wxWidgets team
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Licence: wxWindows license
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@class wxXLocale
|
|
|
|
|
|
|
|
This class represents a locale object used by so-called xlocale API.
|
2008-10-19 08:49:07 -04:00
|
|
|
|
2008-10-17 16:27:36 -04:00
|
|
|
Unlike wxLocale it doesn't provide any non-trivial operations but simply
|
|
|
|
provides a portable wrapper for POSIX @c locale_t type.
|
|
|
|
|
|
|
|
It exists solely to be provided as an argument to various @c wxFoo_l() functions
|
|
|
|
which are the extensions of the standard locale-dependent functions (hence the
|
|
|
|
name xlocale). These functions do exactly the same thing as the corresponding
|
|
|
|
standard @c foo() except that instead of using the global program locale
|
|
|
|
they use the provided wxXLocale object.
|
|
|
|
|
|
|
|
For example, if the user runs the program in French locale, the standard
|
|
|
|
@c printf() function will output floating point numbers using decimal comma
|
|
|
|
instead of decimal period. If the program needs to format a floating-point
|
|
|
|
number in a standard format it can use:
|
|
|
|
@code wxPrintf_l(wxXLocale::GetCLocale(), "%g", number) @endcode
|
|
|
|
to do it.
|
2009-03-19 14:05:49 -04:00
|
|
|
|
|
|
|
See @ref group_funcmacro_locale for a list of wxXLocale-enabled functions.
|
2008-10-17 16:27:36 -04:00
|
|
|
|
|
|
|
Conversely, if a program wanted to output the number in French locale, even if
|
|
|
|
the current locale is different, it could use wxXLocale(wxLANGUAGE_FRENCH).
|
|
|
|
|
|
|
|
|
|
|
|
@section xlocale_avail Availability
|
|
|
|
|
|
|
|
This class is fully implemented only under the platforms where xlocale POSIX
|
|
|
|
API or equivalent is available. Currently the xlocale API is available under
|
|
|
|
most of the recent Unix systems (including Linux, various BSD and Mac OS X) and
|
|
|
|
Microsoft Visual C++ standard library provides a similar API starting from
|
|
|
|
version 8 (Visual Studio 2005).
|
|
|
|
|
|
|
|
If neither POSIX API nor Microsoft proprietary equivalent are available, this
|
|
|
|
class is still available but works in degraded mode: the only supported locale
|
|
|
|
is the C one and attempts to create wxXLocale object for any other locale will
|
|
|
|
fail. You can use the preprocessor macro @c wxHAS_XLOCALE_SUPPORT to test if
|
|
|
|
full xlocale API is available or only skeleton C locale support is present.
|
|
|
|
|
|
|
|
Notice that wxXLocale is new in wxWidgets 2.9.0 and is not compiled in if
|
|
|
|
@c wxUSE_XLOCALE was set to 0 during the library compilation.
|
|
|
|
|
|
|
|
|
|
|
|
@library{wxbase}
|
2009-02-20 06:34:52 -05:00
|
|
|
@category{cfg}
|
2008-10-17 16:27:36 -04:00
|
|
|
|
2009-03-19 14:05:49 -04:00
|
|
|
@stdobjects
|
|
|
|
@li ::wxNullXLocale
|
|
|
|
|
2008-10-17 16:27:36 -04:00
|
|
|
@see wxLocale
|
|
|
|
*/
|
|
|
|
class wxXLocale
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
2008-10-19 08:49:07 -04:00
|
|
|
Creates an uninitialized locale object, IsOk() method will return @false.
|
2008-10-17 16:27:36 -04:00
|
|
|
*/
|
2008-10-29 12:00:56 -04:00
|
|
|
wxXLocale();
|
2008-10-17 16:27:36 -04:00
|
|
|
|
|
|
|
/**
|
2008-10-19 08:49:07 -04:00
|
|
|
Creates the locale object corresponding to the specified language.
|
2008-10-17 16:27:36 -04:00
|
|
|
*/
|
2008-10-29 12:00:56 -04:00
|
|
|
wxXLocale(wxLanguage lang);
|
2008-10-17 16:27:36 -04:00
|
|
|
|
|
|
|
/**
|
2008-10-19 08:49:07 -04:00
|
|
|
Creates the locale object corresponding to the specified locale string.
|
|
|
|
The locale string is system-dependent, use constructor taking wxLanguage
|
|
|
|
for better portability.
|
2008-10-17 16:27:36 -04:00
|
|
|
*/
|
2008-10-29 12:00:56 -04:00
|
|
|
wxXLocale(const char* loc);
|
2008-10-17 16:27:36 -04:00
|
|
|
|
|
|
|
/**
|
2008-10-19 08:49:07 -04:00
|
|
|
Returns the global object representing the "C" locale.
|
|
|
|
For an even shorter access to this object a global @c wxCLocale variable
|
|
|
|
(implemented as a macro) is provided and can be used instead of calling
|
|
|
|
this method.
|
2008-10-17 16:27:36 -04:00
|
|
|
*/
|
2008-10-19 08:49:07 -04:00
|
|
|
static wxXLocale& GetCLocale();
|
2008-10-17 16:27:36 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns @true if this object is initialized, i.e. represents a valid locale
|
2008-10-19 08:49:07 -04:00
|
|
|
or @false otherwise.
|
2008-10-17 16:27:36 -04:00
|
|
|
*/
|
|
|
|
bool IsOk() const;
|
2009-03-19 14:05:49 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
Comparison operator.
|
|
|
|
*/
|
|
|
|
bool operator==(const wxXLocale& loc) const;
|
2008-10-17 16:27:36 -04:00
|
|
|
};
|
2009-03-19 14:05:49 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
An empty and invalid wxXLocale object.
|
|
|
|
*/
|
|
|
|
wxXLocale wxNullXLocale;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ============================================================================
|
|
|
|
// Global functions/macros
|
|
|
|
// ============================================================================
|
|
|
|
|
|
|
|
/** @addtogroup group_funcmacro_locale */
|
|
|
|
//@{
|
|
|
|
|
|
|
|
int wxIsalnum_l(wchar_t c, const wxXLocale& loc);
|
|
|
|
int wxIsalpha_l(wchar_t c, const wxXLocale& loc);
|
|
|
|
int wxIscntrl_l(wchar_t c, const wxXLocale& loc);
|
|
|
|
int wxIsdigit_l(wchar_t c, const wxXLocale& loc);
|
|
|
|
int wxIsgraph_l(wchar_t c, const wxXLocale& loc);
|
|
|
|
int wxIslower_l(wchar_t c, const wxXLocale& loc);
|
|
|
|
int wxIsprint_l(wchar_t c, const wxXLocale& loc);
|
|
|
|
int wxIspunct_l(wchar_t c, const wxXLocale& loc);
|
|
|
|
int wxIsspace_l(wchar_t c, const wxXLocale& loc);
|
|
|
|
int wxIsupper_l(wchar_t c, const wxXLocale& loc);
|
|
|
|
int wxIsxdigit_l(wchar_t c, const wxXLocale& loc);
|
|
|
|
wchar_t wxTolower_l(wchar_t c, const wxXLocale& loc);
|
|
|
|
wchar_t wxToupper_l(wchar_t c, const wxXLocale& loc);
|
|
|
|
|
|
|
|
double wxStrtod_l(const wchar_t *c, wchar_t **endptr, const wxXLocale& loc);
|
|
|
|
long wxStrtol_l(const wchar_t *c, wchar_t **endptr, int base, const wxXLocale& loc);
|
|
|
|
unsigned long wxStrtoul_l(const wchar_t *c, wchar_t **endptr, int base, const wxXLocale& loc);
|
|
|
|
|
|
|
|
//@}
|
|
|
|
|