]> git.saurik.com Git - wxWidgets.git/blob - interface/wx/xlocale.h
Add length parameter to AddTextRaw and AppendTextRaw. Closes #1358
[wxWidgets.git] / interface / wx / xlocale.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: xlocale.h
3 // Purpose: interface of wxXLocale
4 // Author: wxWidgets team
5 // RCS-ID: $Id$
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
8
9
10 /**
11 @class wxXLocale
12
13 This class represents a locale object used by so-called xlocale API.
14
15 Unlike wxLocale it doesn't provide any non-trivial operations but simply
16 provides a portable wrapper for POSIX @c locale_t type.
17
18 It exists solely to be provided as an argument to various @c wxFoo_l() functions
19 which are the extensions of the standard locale-dependent functions (hence the
20 name xlocale). These functions do exactly the same thing as the corresponding
21 standard @c foo() except that instead of using the global program locale
22 they use the provided wxXLocale object.
23
24 For example, if the user runs the program in French locale, the standard
25 @c printf() function will output floating point numbers using decimal comma
26 instead of decimal period. If the program needs to format a floating-point
27 number in a standard format it can use:
28 @code wxPrintf_l(wxXLocale::GetCLocale(), "%g", number) @endcode
29 to do it.
30
31 See @ref group_funcmacro_locale for a list of wxXLocale-enabled functions.
32
33 Conversely, if a program wanted to output the number in French locale, even if
34 the current locale is different, it could use wxXLocale(wxLANGUAGE_FRENCH).
35
36
37 @section xlocale_avail Availability
38
39 This class is fully implemented only under the platforms where xlocale POSIX
40 API or equivalent is available. Currently the xlocale API is available under
41 most of the recent Unix systems (including Linux, various BSD and Mac OS X) and
42 Microsoft Visual C++ standard library provides a similar API starting from
43 version 8 (Visual Studio 2005).
44
45 If neither POSIX API nor Microsoft proprietary equivalent are available, this
46 class is still available but works in degraded mode: the only supported locale
47 is the C one and attempts to create wxXLocale object for any other locale will
48 fail. You can use the preprocessor macro @c wxHAS_XLOCALE_SUPPORT to test if
49 full xlocale API is available or only skeleton C locale support is present.
50
51 Notice that wxXLocale is new in wxWidgets 2.9.0 and is not compiled in if
52 @c wxUSE_XLOCALE was set to 0 during the library compilation.
53
54
55 @library{wxbase}
56 @category{cfg}
57
58 @stdobjects
59 @li ::wxNullXLocale
60
61 @see wxLocale
62 */
63 class wxXLocale
64 {
65 public:
66 /**
67 Creates an uninitialized locale object, IsOk() method will return @false.
68 */
69 wxXLocale();
70
71 /**
72 Creates the locale object corresponding to the specified language.
73 */
74 wxXLocale(wxLanguage lang);
75
76 /**
77 Creates the locale object corresponding to the specified locale string.
78 The locale string is system-dependent, use constructor taking wxLanguage
79 for better portability.
80 */
81 wxXLocale(const char* loc);
82
83 /**
84 Returns the global object representing the "C" locale.
85 For an even shorter access to this object a global @c wxCLocale variable
86 (implemented as a macro) is provided and can be used instead of calling
87 this method.
88 */
89 static wxXLocale& GetCLocale();
90
91 /**
92 Returns @true if this object is initialized, i.e. represents a valid locale
93 or @false otherwise.
94 */
95 bool IsOk() const;
96
97 /**
98 Comparison operator.
99 */
100 bool operator==(const wxXLocale& loc) const;
101 };
102
103 /**
104 An empty and invalid wxXLocale object.
105 */
106 wxXLocale wxNullXLocale;
107
108
109
110 // ============================================================================
111 // Global functions/macros
112 // ============================================================================
113
114 /** @addtogroup group_funcmacro_locale */
115 //@{
116
117 int wxIsalnum_l(wchar_t c, const wxXLocale& loc);
118 int wxIsalpha_l(wchar_t c, const wxXLocale& loc);
119 int wxIscntrl_l(wchar_t c, const wxXLocale& loc);
120 int wxIsdigit_l(wchar_t c, const wxXLocale& loc);
121 int wxIsgraph_l(wchar_t c, const wxXLocale& loc);
122 int wxIslower_l(wchar_t c, const wxXLocale& loc);
123 int wxIsprint_l(wchar_t c, const wxXLocale& loc);
124 int wxIspunct_l(wchar_t c, const wxXLocale& loc);
125 int wxIsspace_l(wchar_t c, const wxXLocale& loc);
126 int wxIsupper_l(wchar_t c, const wxXLocale& loc);
127 int wxIsxdigit_l(wchar_t c, const wxXLocale& loc);
128 wchar_t wxTolower_l(wchar_t c, const wxXLocale& loc);
129 wchar_t wxToupper_l(wchar_t c, const wxXLocale& loc);
130
131 double wxStrtod_l(const wchar_t *c, wchar_t **endptr, const wxXLocale& loc);
132 long wxStrtol_l(const wchar_t *c, wchar_t **endptr, int base, const wxXLocale& loc);
133 unsigned long wxStrtoul_l(const wchar_t *c, wchar_t **endptr, int base, const wxXLocale& loc);
134
135 //@}
136