]> git.saurik.com Git - wxWidgets.git/blob - include/wx/wxchar.h
Added wxNB_LEFT,RIGHT,BOTTOM for notebook tab placement
[wxWidgets.git] / include / wx / wxchar.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wxchar.h
3 // Purpose: Declarations common to wx char/wchar_t usage (wide chars)
4 // Author: Joel Farley
5 // Modified by:
6 // Created: 1998/06/12
7 // RCS-ID: $Id$
8 // Copyright: (c) wxWindows copyright
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_WXCHAR_H_
13 #define _WX_WXCHAR_H_
14
15 //#ifdef __GNUG__
16 //#pragma interface "wxchar.h"
17 //#endif
18
19 // only do SBCS or _UNICODE
20 #if defined (_MBCS )
21 # error "MBCS is not supported by wxChar"
22 #endif
23
24 // set wxUSE_UNICODE to 1 if UNICODE or _UNICODE is defined
25 #if defined(_UNICODE) || defined(UNICODE)
26 # undef wxUSE_UNICODE
27 # define wxUSE_UNICODE 1
28 #else
29 # ifndef wxUSE_UNICODE
30 # define wxUSE_UNICODE 0
31 # endif
32 #endif
33
34 // and vice versa: define UNICODE and _UNICODE if wxUSE_UNICODE is 1...
35 #if wxUSE_UNICODE
36 # ifndef _UNICODE
37 # define _UNICODE
38 # endif
39 # ifndef UNICODE
40 # define UNICODE
41 # endif
42 #endif
43
44 // Windows (VC++) has broad TCHAR support
45 #if defined(__VISUALC__) && defined(__WIN32__)
46
47 # define HAVE_WCSLEN 1
48
49 # include <tchar.h>
50 # if wxUSE_UNICODE // temporary - preserve binary compatibility
51 typedef _TCHAR wxChar;
52 typedef _TSCHAR wxSChar;
53 typedef _TUCHAR wxUChar;
54 # else
55 # define wxChar char
56 # define wxSChar signed char
57 # define wxUChar unsigned char
58 # endif
59 // wchar_t is available
60 # undef wxUSE_WCHAR_T
61 # define wxUSE_WCHAR_T 1
62
63 // ctype.h functions
64 # define wxIsalnum _istalnum
65 # define wxIsalpha _istalpha
66 # define wxIsctrl _istctrl
67 # define wxIsdigit _istdigit
68 # define wxIsgraph _istgraph
69 # define wxIslower _istlower
70 # define wxIsprint _istprint
71 # define wxIspunct _istpunct
72 # define wxIsspace _istspace
73 # define wxIsupper _istupper
74 # define wxIsxdigit _istxdigit
75 # define wxTolower _totlower
76 # define wxToupper _totupper
77
78 // locale.h functons
79 # define wxSetlocale _tsetlocale
80
81 // string.h functions
82 # define wxStrcat _tcscat
83 # define wxStrchr _tcschr
84 # define wxStrcmp _tcscmp
85 # define wxStrcoll _tcscoll
86 # define wxStrcpy _tcscpy
87 # define wxStrcspn _tcscspn
88 # define wxStrftime _tcsftime
89 # define wxStricmp _tcsicmp
90 # define wxStrlen_ _tcslen // used in wxStrlen inline function
91 # define wxStrncat _tcsncat
92 # define wxStrncmp _tcsncmp
93 # define wxStrncpy _tcsncpy
94 # define wxStrpbrk _tcspbrk
95 # define wxStrrchr _tcsrchr
96 # define wxStrspn _tcsspn
97 # define wxStrstr _tcsstr
98 # define wxStrtod _tcstod
99 // is there a _tcstok[_r] ?
100 # define wxStrtol _tcstol
101 # define wxStrtoul _tcstoul
102 # define wxStrxfrm _tcsxfrm
103
104 // stdio.h functions
105 # define wxFgetc _fgettc
106 # define wxFgetchar _fgettchar
107 # define wxFgets _fgetts
108 # define wxFopen _tfopen
109 # define wxFputc _fputtc
110 # define wxFputchar _fputtchar
111 # define wxFprintf _ftprintf
112 # define wxFreopen _tfreopen
113 # define wxFscanf _ftscanf
114 # define wxGetc _gettc
115 # define wxGetchar _gettchar
116 # define wxGets _getts
117 # define wxPerror _tperror
118 # define wxPrintf _tprintf
119 # define wxPutc _puttc
120 # define wxPutchar _puttchar
121 # define wxPuts _putts
122 # define wxRemove _tremove
123 # define wxRename _trename
124 # define wxScanf _tscanf
125 # define wxSprintf _stprintf
126 # define wxSscanf _stscanf
127 # define wxTmpnam _ttmpnam
128 # define wxUngetc _tungetc
129 # define wxVfprint _vftprintf
130 # define wxVprintf _vtprintf
131 # define wxVsscanf _vstscanf
132 # define wxVsprintf _vstprintf
133
134 // stdlib.h functions
135 # if !wxUSE_UNICODE
136 # define wxAtof atof
137 # endif
138 # define wxAtoi _ttoi
139 # define wxAtol _ttol
140 # define wxGetenv _tgetenv
141 # define wxSystem _tsystem
142
143 // time.h functions
144 # define wxAsctime _tasctime
145 # define wxCtime _tctime
146
147 // #elif defined(XXX)
148 // #include XXX-specific files here
149 // typeddef YYY wxChar;
150
151 // translate wxZZZ names
152
153 #elif defined(__BORLANDC__) && defined(__WIN32__)
154
155 // Borland C++ 4.52 doesn't have much tchar support
156 // maybe Borland C++ 5.02 has, can't check right now
157 // but I'll use the Win32 API instead here
158
159 # include <tchar.h>
160 # if wxUSE_UNICODE // temporary - preserve binary compatibility
161 typedef _TCHAR wxChar;
162 typedef _TSCHAR wxSChar;
163 typedef _TUCHAR wxUChar;
164 # else
165 # define wxChar char
166 # define wxSChar signed char
167 # define wxUChar unsigned char
168 # endif
169 // wchar_t is available
170 # undef wxUSE_WCHAR_T
171 # define wxUSE_WCHAR_T 1
172
173 # define wxNEED_WX_CTYPE_H
174 // #define wxStrtok strtok_r // Borland C++ 4.52 doesn't have strtok_r
175 # define wxNEED_WX_STRING_H
176 # define wxNEED_WX_STDIO_H
177 # define wxNEED_WX_STDLIB_H
178 # define wxNEED_WX_TIME_H
179 # define wxNEED_WCSLEN
180
181 #else//!TCHAR-aware compilers
182
183 // check whether we should include wchar.h or equivalent
184 # if wxUSE_UNICODE
185 # undef wxUSE_WCHAR_T
186 # define wxUSE_WCHAR_T 1 // wchar_t *must* be available in Unicode mode
187 # elif !defined(wxUSE_WCHAR_T)
188 # if defined(__VISUALC__) && (__VISUALC__ < 900)
189 # define wxUSE_WCHAR_T 0 // wchar_t is not available for MSVC++ 1.5
190 # elif defined(__UNIX__)
191 # if defined(HAVE_WCSTR_H) || defined(HAVE_WCHAR_H) || defined(__FreeBSD__)
192 # define wxUSE_WCHAR_T 1
193 # else
194 # define wxUSE_WCHAR_T 0
195 # endif
196 # elif defined(__GNUWIN32__) && !defined(__MINGW32__) // Cygwin (not Mingw32) doesn't have wcslen.h, needed in buffer.h
197 # define wxUSE_WCHAR_T 0
198 # elif defined(__BORLANDC__) // WIN16 BC++
199 # define wxUSE_WCHAR_T 0
200 # elif defined(__WATCOMC__)
201 # define wxUSE_WCHAR_T 0
202 # else
203 // add additional compiler checks if this fails
204 # define wxUSE_WCHAR_T 1
205 # endif
206 # endif//wxUSE_UNICODE
207
208 # if wxUSE_WCHAR_T
209 # ifdef HAVE_WCSTR_H
210 # include <wcstr.h>
211 # else
212 # ifndef __FreeBSD__
213 # include <wchar.h>
214 # else
215 # include <stdlib.h>
216 # define wxNEED_WCSLEN
217 # endif
218 # endif
219 # endif
220
221 // check whether we are doing Unicode
222 # if wxUSE_UNICODE
223
224 # include <wctype.h>
225
226 // this is probably glibc-specific
227 # if defined(__WCHAR_TYPE__)
228
229 typedef __WCHAR_TYPE__ wxChar;
230 typedef signed __WCHAR_TYPE__ wxSChar;
231 typedef unsigned __WCHAR_TYPE__ wxUChar;
232
233 # define _T(x) L##x
234
235 // ctype.h functions (wctype.h)
236 # define wxIsalnum iswalnum
237 # define wxIsalpha iswalpha
238 # define wxIsctrl iswcntrl
239 # define wxIsdigit iswdigit
240 # define wxIsgraph iswgraph
241 # define wxIslower iswlower
242 # define wxIsprint iswprint
243 # define wxIspunct iswpunct
244 # define wxIsspace iswspace
245 # define wxIsupper iswupper
246 # define wxIsxdigit iswxdigit
247
248 # if defined(__GLIBC__) && (__GLIBC__ == 2) && (__GLIBC_MINOR__ == 0)
249 // /usr/include/wctype.h incorrectly declares translations tables which
250 // provokes tons of compile-time warnings - try to correct this
251 # define wxTolower(wc) towctrans((wc), (wctrans_t)__ctype_tolower)
252 # define wxToupper(wc) towctrans((wc), (wctrans_t)__ctype_toupper)
253 # else
254 # define wxTolower towlower
255 # define wxToupper towupper
256 # endif // gcc/!gcc
257
258 // string.h functions (wchar.h)
259 # define wxStrcat wcscat
260 # define wxStrchr wcschr
261 # define wxStrcmp wcscmp
262 # define wxStrcoll wcscoll
263 # define wxStrcpy wcscpy
264 # define wxStrcspn wcscspn
265 # define wxStrlen_ wcslen // used in wxStrlen inline function
266 # define wxStrncat wcsncat
267 # define wxStrncmp wcsncmp
268 # define wxStrncpy wcsncpy
269 # define wxStrpbrk wcspbrk
270 # define wxStrrchr wcsrchr
271 # define wxStrspn wcsspn
272 # define wxStrstr wcsstr
273 # define wxStrtod wcstod
274 # define wxStrtok wcstok
275 # define wxStrtol wcstol
276 # define wxStrtoul wcstoul
277 # define wxStrxfrm wcsxfrm
278
279 // glibc doesn't have wc equivalents of the other stuff
280 # define wxNEED_WX_STDIO_H
281 # define wxNEED_WX_STDLIB_H
282 # define wxNEED_WX_TIME_H
283
284 # else//!glibc
285 # error "Please define your compiler's Unicode conventions in wxChar.h"
286 # endif
287 # else//!Unicode
288
289 # include <ctype.h>
290 # include <string.h>
291
292 # if 0 // temporary - preserve binary compatibilty
293 typedef char wxChar;
294 typedef signed char wxSChar;
295 typedef unsigned char wxUChar;
296 # else
297 # define wxChar char
298 # define wxSChar signed char
299 # define wxUChar unsigned char
300 # endif
301
302 # ifdef __FreeBSD__
303 # undef _T
304 # endif
305 # define _T(x) x
306
307 // ctype.h functions
308 # define wxIsalnum isalnum
309 # define wxIsalpha isalpha
310 # define wxIsctrl isctrl
311 # define wxIsdigit isdigit
312 # define wxIsgraph isgraph
313 # define wxIslower islower
314 # define wxIsprint isprint
315 # define wxIspunct ispunct
316 # define wxIsspace isspace
317 # define wxIsupper isupper
318 # define wxIsxdigit isxdigit
319 # define wxTolower tolower
320 # define wxToupper toupper
321
322 // locale.h functons
323 # define wxSetlocale setlocale
324
325 // string.h functions
326 // #define wxStricmp strcasecmp
327 // wxStricmp is defined below!!
328
329 // #define wxStrtok strtok_r // this needs a configure check
330
331 // leave the rest to defaults below
332 # define wxNEED_WX_STRING_H
333 # define wxNEED_WX_STDIO_H
334 # define wxNEED_WX_STDLIB_H
335 # define wxNEED_WX_TIME_H
336
337 # endif//Unicode
338 #endif//TCHAR-aware compilers
339
340 // define wxStricmp for various compilers without Unicode possibilities
341 #if !defined(wxStricmp) && !wxUSE_UNICODE
342 # if defined(__BORLANDC__) || defined(__WATCOMC__) || defined(__SALFORDC__) || defined(__VISAGECPP__) || defined(__EMX__)
343 # define wxStricmp stricmp
344 # elif defined(__SC__) || defined(__VISUALC__) || (defined(__MWERKS__) && defined(__INTEL__))
345 # define wxStricmp _stricmp
346 # elif defined(__UNIX__) || defined(__GNUWIN32__)
347 # define wxStricmp strcasecmp
348 # elif defined(__MWERKS__) && !defined(__INTEL__)
349 // use wxWindows' implementation
350 # else
351 // if you leave wxStricmp undefined, wxWindows' implementation will be used
352 # error "Please define string case-insensitive compare for your OS/compiler"
353 # endif
354 #endif
355
356 // if we need to define for standard headers, and we're not using Unicode,
357 // just define to standard C library routines
358 #if !wxUSE_UNICODE
359 # ifdef wxNEED_WX_STRING_H
360 # define wxStrcat strcat
361 # define wxStrchr strchr
362 # define wxStrcmp strcmp
363 # define wxStrcoll strcoll
364 # define wxStrcpy strcpy
365 # define wxStrcspn strcspn
366 # define wxStrdup strdup
367 # define wxStrlen_ strlen // used in wxStrlen inline function
368 # define wxStrncat strncat
369 # define wxStrncmp strncmp
370 # define wxStrncpy strncpy
371 # define wxStrpbrk strpbrk
372 # define wxStrrchr strrchr
373 # define wxStrspn strspn
374 # define wxStrstr strstr
375 # define wxStrtod strtod
376 # define wxStrtol strtol
377 # define wxStrtoul strtoul
378 # define wxStrxfrm strxfrm
379 # undef wxNEED_WX_STRING_H
380 # endif
381
382 # ifdef wxNEED_WX_STDIO_H
383 # define wxFgetc fgetc
384 # define wxFgetchar fgetchar
385 # define wxFgets fgets
386 # define wxFopen fopen
387 # define wxFputc fputc
388 # define wxFputchar fputchar
389 # define wxFprintf fprintf
390 # define wxFreopen freopen
391 # define wxFscanf fscanf
392 # define wxGetc getc
393 # define wxGetchar getchar
394 # define wxGets gets
395 # define wxPerror perror
396 # define wxPrintf printf
397 # define wxPutc putc
398 # define wxPutchar putchar
399 # define wxPuts puts
400 # define wxRemove remove
401 # define wxRename rename
402 # define wxScanf scanf
403 # define wxSprintf sprintf
404 # define wxSscanf sscanf
405 # define wxTmpnam tmpnam
406 # define wxUngetc ungetc
407 # define wxVfprint vfprintf
408 # define wxVprintf vprintf
409 # define wxVsscanf vsscanf
410 # define wxVsprintf vsprintf
411 # undef wxNEED_WX_STDIO_H
412 # endif
413
414 # ifdef wxNEED_WX_STDLIB_H
415 # define wxAtof atof
416 # define wxAtoi atoi
417 # define wxAtol atol
418 # define wxGetenv getenv
419 # define wxSystem system
420 # undef wxNEED_WX_STDLIB_H
421 # endif
422
423 # ifdef wxNEED_WX_TIME_H
424 # define wxAsctime asctime
425 # define wxCtime ctime
426 # define wxStrftime strftime
427 # undef wxNEED_WX_TIME_H
428 # endif
429 #endif //!Unicode
430
431 #if defined(wxNEED_WCSLEN) && wxUSE_UNICODE
432 # define wcslen wxStrlen
433 # undef wxNEED_WCSLEN
434 #endif
435
436 /// checks whether the passed in pointer is NULL and if the string is empty
437 WXDLLEXPORT inline bool wxIsEmpty(const wxChar *p) { return !p || !*p; }
438
439 #ifndef wxNEED_WX_STRING_H
440 /// safe version of strlen() (returns 0 if passed NULL pointer)
441 WXDLLEXPORT inline size_t wxStrlen(const wxChar *psz)
442 { return psz ? wxStrlen_(psz) : 0; }
443 #endif
444
445 #if wxUSE_WCHAR_T
446 // multibyte<->widechar conversion
447 WXDLLEXPORT size_t wxMB2WC(wchar_t *buf, const char *psz, size_t n);
448 WXDLLEXPORT size_t wxWC2MB(char *buf, const wchar_t *psz, size_t n);
449 # if wxUSE_UNICODE
450 # define wxMB2WX wxMB2WC
451 # define wxWX2MB wxWC2MB
452 # define wxWC2WX wxStrncpy
453 # define wxWX2WC wxStrncpy
454 # else
455 # define wxMB2WX wxStrncpy
456 # define wxWX2MB wxStrncpy
457 # define wxWC2WX wxWC2MB
458 # define wxWX2WC wxMB2WC
459 # endif
460 #else
461 // No wxUSE_WCHAR_T: we have to do something (JACS)
462 # define wxMB2WC wxStrncpy
463 # define wxWC2MB wxStrncpy
464 # define wxMB2WX wxStrncpy
465 # define wxWX2MB wxStrncpy
466 # define wxWC2WX wxWC2MB
467 # define wxWX2WC wxMB2WC
468 #endif
469
470 WXDLLEXPORT bool wxOKlibc(); // for internal use
471
472 // if libc versions are not available, use replacements defined in wxchar.cpp
473 #ifndef wxStrdup
474 WXDLLEXPORT wxChar * wxStrdup(const wxChar *psz);
475 #endif
476
477 #ifndef wxStricmp
478 WXDLLEXPORT int wxStricmp(const wxChar *psz1, const wxChar *psz2);
479 #endif
480
481 #ifndef wxStrtok
482 WXDLLEXPORT wxChar * wxStrtok(wxChar *psz, const wxChar *delim, wxChar **save_ptr);
483 #endif
484
485 #ifndef wxSetlocale
486 WXDLLEXPORT wxChar * wxSetlocale(int category, const wxChar *locale);
487 #endif
488
489 #ifdef wxNEED_WCSLEN // for use in buffer.h
490 WXDLLEXPORT size_t wcslen(const wchar_t *s);
491 #endif
492
493 #ifdef wxNEED_WX_CTYPE_H
494 WXDLLEXPORT int wxIsalnum(wxChar ch);
495 WXDLLEXPORT int wxIsalpha(wxChar ch);
496 WXDLLEXPORT int wxIsctrl(wxChar ch);
497 WXDLLEXPORT int wxIsdigit(wxChar ch);
498 WXDLLEXPORT int wxIsgraph(wxChar ch);
499 WXDLLEXPORT int wxIslower(wxChar ch);
500 WXDLLEXPORT int wxIsprint(wxChar ch);
501 WXDLLEXPORT int wxIspunct(wxChar ch);
502 WXDLLEXPORT int wxIsspace(wxChar ch);
503 WXDLLEXPORT int wxIsupper(wxChar ch);
504 WXDLLEXPORT int wxIsxdigit(wxChar ch);
505 WXDLLEXPORT int wxTolower(wxChar ch);
506 WXDLLEXPORT int wxToupper(wxChar ch);
507 #endif
508
509 #ifdef wxNEED_WX_STRING_H
510 WXDLLEXPORT wxChar * wxStrcat(wxChar *dest, const wxChar *src);
511 WXDLLEXPORT wxChar * wxStrchr(const wxChar *s, wxChar c);
512 WXDLLEXPORT int wxStrcmp(const wxChar *s1, const wxChar *s2);
513 WXDLLEXPORT int wxStrcoll(const wxChar *s1, const wxChar *s2);
514 WXDLLEXPORT wxChar * wxStrcpy(wxChar *dest, const wxChar *src);
515 WXDLLEXPORT size_t wxStrcspn(const wxChar *s, const wxChar *reject);
516 WXDLLEXPORT size_t wxStrlen(const wxChar *s);
517 WXDLLEXPORT wxChar * wxStrncat(wxChar *dest, const wxChar *src, size_t n);
518 WXDLLEXPORT int wxStrncmp(const wxChar *s1, const wxChar *s2, size_t n);
519 WXDLLEXPORT wxChar * wxStrncpy(wxChar *dest, const wxChar *src, size_t n);
520 WXDLLEXPORT wxChar * wxStrpbrk(const wxChar *s, const wxChar *accept);
521 WXDLLEXPORT wxChar * wxStrrchr(const wxChar *s, wxChar c);
522 WXDLLEXPORT size_t wxStrspn(const wxChar *s, const wxChar *accept);
523 WXDLLEXPORT wxChar * wxStrstr(const wxChar *haystack, const wxChar *needle);
524 WXDLLEXPORT double wxStrtod(const wxChar *nptr, wxChar **endptr);
525 WXDLLEXPORT long int wxStrtol(const wxChar *nptr, wxChar **endptr, int base);
526 WXDLLEXPORT unsigned long int wxStrtoul(const wxChar *nptr, wxChar **endptr, int base);
527 WXDLLEXPORT size_t wxStrxfrm(wxChar *dest, const wxChar *src, size_t n);
528 #endif
529
530 #ifdef wxNEED_WX_STDIO_H
531 # include <stdio.h>
532 # include <stdarg.h>
533 WXDLLEXPORT FILE * wxFopen(const wxChar *path, const wxChar *mode);
534 WXDLLEXPORT FILE * wxFreopen(const wxChar *path, const wxChar *mode, FILE *stream);
535 WXDLLEXPORT int wxPrintf(const wxChar *fmt, ...);
536 WXDLLEXPORT int wxVprintf(const wxChar *fmt, va_list argptr);
537 WXDLLEXPORT int wxFprintf(FILE *stream, const wxChar *fmt, ...);
538 WXDLLEXPORT int wxVfprintf(FILE *stream, const wxChar *fmt, va_list argptr);
539 WXDLLEXPORT int wxSprintf(wxChar *buf, const wxChar *fmt, ...);
540 WXDLLEXPORT int wxVsprintf(wxChar *buf, const wxChar *fmt, va_list argptr);
541 WXDLLEXPORT int wxSscanf(const wxChar *buf, const wxChar *fmt, ...);
542 WXDLLEXPORT int wxVsscanf(const wxChar *buf, const wxChar *fmt, va_list argptr);
543 #endif
544
545 #ifndef wxAtof
546 WXDLLEXPORT double wxAtof(const wxChar *psz);
547 #endif
548
549 #ifdef wxNEED_WX_STDLIB_H
550 WXDLLEXPORT int wxAtoi(const wxChar *psz);
551 WXDLLEXPORT long wxAtol(const wxChar *psz);
552 WXDLLEXPORT wxChar * wxGetenv(const wxChar *name);
553 WXDLLEXPORT int wxSystem(const wxChar *psz);
554 #endif
555
556 #ifdef wxNEED_WX_TIME_H
557 WXDLLEXPORT size_t wxStrftime(wxChar *s, size_t max, const wxChar *fmt, const struct tm *tm);
558 #endif
559
560 #endif
561 //_WX_WXCHAR_H_
562