]> git.saurik.com Git - wxWidgets.git/blame - include/wx/chartype.h
Store property name and value in wxPropertyGridEvent, keep track of live event instan...
[wxWidgets.git] / include / wx / chartype.h
CommitLineData
e3f6cbd9
VS
1/*
2 * Name: wx/chartype.h
3 * Purpose: Declarations of wxChar and related types
e9670814 4 * Author: Joel Farley, Ove Kåven
e3f6cbd9
VS
5 * Modified by: Vadim Zeitlin, Robert Roebling, Ron Lee
6 * Created: 1998/06/12
7 * RCS-ID: $Id$
8 * Copyright: (c) 1998-2006 wxWidgets dev team
9 * Licence: wxWindows licence
10 */
11
12/* THIS IS A C FILE, DON'T USE C++ FEATURES (IN PARTICULAR COMMENTS) IN IT */
13
14#ifndef _WX_WXCHARTYPE_H_
15#define _WX_WXCHARTYPE_H_
16
17/* defs.h indirectly includes this file, so don't include it here */
18#include "wx/platform.h"
19
20/* check whether we have wchar_t and which size it is if we do */
21#if !defined(wxUSE_WCHAR_T)
22 #if defined(__UNIX__)
23 #if defined(HAVE_WCSTR_H) || defined(HAVE_WCHAR_H) || defined(__FreeBSD__) || defined(__DARWIN__)
24 #define wxUSE_WCHAR_T 1
25 #else
26 #define wxUSE_WCHAR_T 0
27 #endif
28 #elif defined(__GNUWIN32__) && !defined(__MINGW32__)
29 #define wxUSE_WCHAR_T 0
30 #elif defined(__WATCOMC__)
31 #define wxUSE_WCHAR_T 0
32 #elif defined(__VISAGECPP__) && (__IBMCPP__ < 400)
33 #define wxUSE_WCHAR_T 0
34 #else
35 /* add additional compiler checks if this fails */
36 #define wxUSE_WCHAR_T 1
37 #endif
38#endif /* !defined(wxUSE_WCHAR_T) */
39
40/* Unicode support requires wchar_t */
93928d51
VS
41#if !wxUSE_WCHAR_T
42 #error "wchar_t must be available"
e3f6cbd9
VS
43#endif /* Unicode */
44
45/*
46 non Unix compilers which do have wchar.h (but not tchar.h which is included
47 below and which includes wchar.h anyhow).
48
49 Actually MinGW has tchar.h, but it does not include wchar.h
50 */
51#if defined(__MWERKS__) || defined(__VISAGECPP__) || defined(__MINGW32__) || defined(__WATCOMC__)
52 #ifndef HAVE_WCHAR_H
53 #define HAVE_WCHAR_H
54 #endif
55#endif
56#if defined(__MWERKS__) && !defined(__MACH__)
57 #ifndef HAVE_WCSLEN
58 #define HAVE_WCSLEN
59 #endif
60#endif
61
62#if wxUSE_WCHAR_T
63 #ifdef HAVE_WCHAR_H
64 /* the current (as of Nov 2002) version of cygwin has a bug in its */
65 /* wchar.h -- there is no extern "C" around the declarations in it */
66 /* and this results in linking errors later; also, at least on some */
67 /* Cygwin versions, wchar.h requires sys/types.h */
68 #ifdef __CYGWIN__
69 #include <sys/types.h>
70 #ifdef __cplusplus
71 extern "C" {
72 #endif
73 #endif /* Cygwin */
74
75 #include <wchar.h>
76
77 #if defined(__CYGWIN__) && defined(__cplusplus)
78 }
79 #endif /* Cygwin and C++ */
80
81 #elif defined(HAVE_WCSTR_H)
82 /* old compilers have relevant declarations here */
83 #include <wcstr.h>
84 #elif defined(__FreeBSD__) || defined(__DARWIN__) || defined(__EMX__)
85 /* include stdlib.h for wchar_t */
86 #include <stdlib.h>
87 #endif /* HAVE_WCHAR_H */
88
89 #ifdef HAVE_WIDEC_H
90 #include <widec.h>
91 #endif
e3f6cbd9
VS
92#endif /* wxUSE_WCHAR_T */
93
94/* -------------------------------------------------------------------------- */
95/* define wxHAVE_TCHAR_SUPPORT for the compilers which support the TCHAR type */
96/* mapped to either char or wchar_t depending on the ASCII/Unicode mode and */
97/* have the function mapping _tfoo() -> foo() or wfoo() */
98/* -------------------------------------------------------------------------- */
99
100/* VC++ and BC++ starting with 5.2 have TCHAR support */
101#ifdef __VISUALC__
102 #define wxHAVE_TCHAR_SUPPORT
103#elif defined(__BORLANDC__) && (__BORLANDC__ >= 0x520)
104 #define wxHAVE_TCHAR_SUPPORT
105 #include <ctype.h>
106#elif defined(__WATCOMC__)
107 #define wxHAVE_TCHAR_SUPPORT
108#elif defined(__DMC__)
109 #define wxHAVE_TCHAR_SUPPORT
110#elif defined(__WXPALMOS__)
111 #include <stddef.h>
112#elif defined(__MINGW32__) && wxCHECK_W32API_VERSION( 1, 0 )
113 #define wxHAVE_TCHAR_SUPPORT
114 #include <stddef.h>
115 #include <string.h>
116 #include <ctype.h>
117#elif 0 && defined(__VISAGECPP__) && (__IBMCPP__ >= 400)
118 /* VZ: the old VisualAge definitions were completely wrong and had no */
119 /* chance at all to work in Unicode build anyhow so let's pretend */
120 /* that VisualAge does _not_ support TCHAR for the moment (as */
121 /* indicated by "0 &&" above) until someone really has time to delve */
122 /* into Unicode issues under OS/2 */
123
124 /* VisualAge 4.0+ supports TCHAR */
125 #define wxHAVE_TCHAR_SUPPORT
126#endif /* compilers with (good) TCHAR support */
127
128#ifdef wxHAVE_TCHAR_SUPPORT
129 /* get TCHAR definition if we've got it */
130 #include <tchar.h>
131
132 /* we surely do have wchar_t if we have TCHAR */
133 #ifndef wxUSE_WCHAR_T
134 #define wxUSE_WCHAR_T 1
135 #endif /* !defined(wxUSE_WCHAR_T) */
136#endif /* wxHAVE_TCHAR_SUPPORT */
137
138/* ------------------------------------------------------------------------- */
139/* define wxChar type */
140/* ------------------------------------------------------------------------- */
141
142/* TODO: define wxCharInt to be equal to either int or wint_t? */
143
144#if !wxUSE_UNICODE
145 typedef char wxChar;
146 typedef signed char wxSChar;
147 typedef unsigned char wxUChar;
9a6d1438 148#else
e3f6cbd9
VS
149 /* VZ: note that VC++ defines _T[SU]CHAR simply as wchar_t and not as */
150 /* signed/unsigned version of it which (a) makes sense to me (unlike */
151 /* char wchar_t is always unsigned) and (b) was how the previous */
152 /* definitions worked so keep it like this */
153
154 /* Sun's SunPro compiler supports the wchar_t type and wide character */
155 /* functions, but does not define __WCHAR_TYPE__. Define it here to */
156 /* allow unicode enabled builds. */
b69ae27a
VZ
157 #if (defined(__SUNPRO_CC) || defined(__SUNPRO_C)) && !defined(__WCHAR_TYPE__)
158 #define __WCHAR_TYPE__ wxchar_t
e3f6cbd9
VS
159 #endif
160
161 /* GNU libc has __WCHAR_TYPE__ which requires special treatment, see */
162 /* comment below */
163 #if !defined(__WCHAR_TYPE__) || \
164 (!defined(__GNUC__) || wxCHECK_GCC_VERSION(2, 96))
165 /* standard case */
166 typedef wchar_t wxChar;
167 typedef wchar_t wxSChar;
168 typedef wchar_t wxUChar;
169 #else /* __WCHAR_TYPE__ and gcc < 2.96 */
170 /* VS: wxWidgets used to define wxChar as __WCHAR_TYPE__ here. */
171 /* However, this doesn't work with new GCC 3.x compilers because */
172 /* wchar_t is C++'s builtin type in the new standard. OTOH, old */
173 /* compilers (GCC 2.x) won't accept new definition of */
174 /* wx{S,U}CharType, so we have to define wxChar */
175 /* conditionally depending on detected compiler & compiler */
176 /* version. */
177
178 /* with old definition of wxChar. */
179 #define wchar_t __WCHAR_TYPE__
180 typedef __WCHAR_TYPE__ wxChar;
181 typedef __WCHAR_TYPE__ wxSChar;
182 typedef __WCHAR_TYPE__ wxUChar;
183 #endif /* __WCHAR_TYPE__ */
184#endif /* ASCII/Unicode */
185
8f93a29f
VS
186/* ------------------------------------------------------------------------- */
187/* define wxStringCharType */
188/* ------------------------------------------------------------------------- */
189
190/* depending on the platform, Unicode build can either store wxStrings as
191 wchar_t* or UTF-8 encoded char*: */
192#if wxUSE_UNICODE
28efe654 193 /* FIXME-UTF8: what would be better place for this? */
cb352236
VS
194 #if defined(wxUSE_UTF8_LOCALE_ONLY) && !defined(wxUSE_UNICODE_UTF8)
195 #error "wxUSE_UTF8_LOCALE_ONLY only makes sense with wxUSE_UNICODE_UTF8"
196 #endif
197 #ifndef wxUSE_UTF8_LOCALE_ONLY
198 #define wxUSE_UTF8_LOCALE_ONLY 0
199 #endif
200
81727065
VS
201 #ifndef wxUSE_UNICODE_UTF8
202 #define wxUSE_UNICODE_UTF8 0
203 #endif
204
205 #if wxUSE_UNICODE_UTF8
206 #define wxUSE_UNICODE_WCHAR 0
207 #else
208 #define wxUSE_UNICODE_WCHAR 1
209 #endif
8f93a29f
VS
210#else
211 #define wxUSE_UNICODE_WCHAR 0
212 #define wxUSE_UNICODE_UTF8 0
5becc841 213 #define wxUSE_UTF8_LOCALE_ONLY 0
8f93a29f
VS
214#endif
215
216/* define char type used by wxString internal representation: */
a0516656 217#if wxUSE_UNICODE_WCHAR
8f93a29f 218 typedef wchar_t wxStringCharType;
a0516656 219#else /* wxUSE_UNICODE_UTF8 || ANSI */
8f93a29f
VS
220 typedef char wxStringCharType;
221#endif
222
223
e3f6cbd9 224/* ------------------------------------------------------------------------- */
9a83f860 225/* define wxT() and related macros */
e3f6cbd9
VS
226/* ------------------------------------------------------------------------- */
227
228/* BSD systems define _T() to be something different in ctype.h, override it */
229#if defined(__FreeBSD__) || defined(__DARWIN__)
230 #include <ctype.h>
231 #undef _T
232#endif
233
9a83f860
VZ
234/*
235 wxT ("wx text") macro turns a literal string constant into a wide char
236 constant. It is mostly unnecessary with wx 2.9 but defined for
237 compatibility.
238 */
239#ifndef wxT
e3f6cbd9 240 #if !wxUSE_UNICODE
9a83f860 241 #define wxT(x) x
e3f6cbd9
VS
242 #else /* Unicode */
243 /* use wxCONCAT_HELPER so that x could be expanded if it's a macro */
9a83f860 244 #define wxT(x) wxCONCAT_HELPER(L, x)
e3f6cbd9 245 #endif /* ASCII/Unicode */
9a83f860 246#endif /* !defined(wxT) */
e3f6cbd9 247
a0516656
VZ
248/*
249 wxS ("wx string") macro can be used to create literals using the same
250 representation as wxString does internally, i.e. wchar_t in Unicode build
251 under Windows or char in UTF-8-based Unicode builds and (deprecated) ANSI
252 builds everywhere (see wxStringCharType definition above).
253 */
254#if wxUSE_UNICODE_WCHAR
255 #define wxS(x) wxCONCAT_HELPER(L, x)
256#else /* wxUSE_UNICODE_UTF8 || ANSI */
257 #define wxS(x) x
258#endif
259
9a83f860
VZ
260/*
261 _T() is a synonym for wxT() familiar to Windows programmers. As this macro
262 has even higher risk of conflicting with system headers, its use is
263 discouraged and you may predefine wxNO__T to disable it. Additionally, we
264 do it ourselves for Sun CC which is known to use it in its standard headers
265 (see #10660).
266 */
267#if defined(__SUNPRO_C) || defined(__SUNPRO_CC)
268 #ifndef wxNO__T
269 #define wxNO__T
270 #endif
271#endif
272
273#if !defined(_T) && !defined(wxNO__T)
274 #define _T(x) wxT(x)
275#endif
e3f6cbd9
VS
276
277/* a helper macro allowing to make another macro Unicode-friendly, see below */
9a83f860 278#define wxAPPLY_T(x) wxT(x)
e3f6cbd9
VS
279
280/* Unicode-friendly __FILE__, __DATE__ and __TIME__ analogs */
281#ifndef __TFILE__
282 #define __TFILE__ wxAPPLY_T(__FILE__)
283#endif
284
285#ifndef __TDATE__
286 #define __TDATE__ wxAPPLY_T(__DATE__)
287#endif
288
289#ifndef __TTIME__
290 #define __TTIME__ wxAPPLY_T(__TIME__)
291#endif
292
293#endif /* _WX_WXCHARTYPE_H_ */
294