1/*
2 * tkWinPort.h --
3 *
4 *	This header file handles porting issues that occur because of
5 *	differences between Windows and Unix. It should be the only
6 *	file that contains #ifdefs to handle different flavors of OS.
7 *
8 * Copyright (c) 1995-1996 Sun Microsystems, Inc.
9 *
10 * See the file "license.terms" for information on usage and redistribution
11 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
12 *
13 * RCS: @(#) $Id$
14 */
15
16#ifndef _WINPORT
17#define _WINPORT
18
19#include <X11/Xlib.h>
20#include <X11/cursorfont.h>
21#include <X11/keysym.h>
22#include <X11/Xatom.h>
23#include <X11/Xutil.h>
24
25#include <malloc.h>
26#include <errno.h>
27#include <ctype.h>
28#include <math.h>
29#include <stdlib.h>
30#include <string.h>
31#include <limits.h>
32#include <fcntl.h>
33#include <io.h>
34
35/*
36 * Need to block out this include for building extensions with MetroWerks
37 * compiler for Win32.
38 */
39
40#ifndef __MWERKS__
41#include <sys/stat.h>
42#endif
43
44#include <time.h>
45
46#ifdef _MSC_VER
47#   ifndef hypot
48#	define hypot _hypot
49#   endif
50#endif /* _MSC_VER */
51
52/*
53 *  Pull in the typedef of TCHAR for windows.
54 */
55#if !defined(_TCHAR_DEFINED)
56#   include <tchar.h>
57#   ifndef _TCHAR_DEFINED
58	/* Borland seems to forget to set this. */
59	typedef _TCHAR TCHAR;
60#	define _TCHAR_DEFINED
61#   endif
62#endif
63
64#ifdef __CYGWIN__
65#   ifndef _vsnprintf
66#	define _vsnprintf vsnprintf
67#   endif
68#   ifndef _wcsicmp
69#	define _wcsicmp wcscasecmp
70#   endif
71#else
72#   ifndef strncasecmp
73#	define strncasecmp strnicmp
74#   endif
75#   ifndef strcasecmp
76#	define strcasecmp stricmp
77#   endif
78#endif
79
80#define NBBY 8
81
82#ifndef OPEN_MAX
83#define OPEN_MAX 32
84#endif
85
86/*
87 * The following define causes Tk to use its internal keysym hash table
88 */
89
90#define REDO_KEYSYM_LOOKUP
91
92/*
93 * The following macro checks to see whether there is buffered
94 * input data available for a stdio FILE.
95 */
96
97#ifdef _MSC_VER
98#    define TK_READ_DATA_PENDING(f) ((f)->_cnt > 0)
99#else /* _MSC_VER */
100#    define TK_READ_DATA_PENDING(f) ((f)->level > 0)
101#endif /* _MSC_VER */
102
103/*
104 * The following stubs implement various calls that don't do anything
105 * under Windows.
106 */
107
108#define TkFreeWindowId(dispPtr,w)
109#define TkInitXId(dispPtr)
110#define TkpCmapStressed(tkwin,colormap) (0)
111#define XFlush(display)
112#define XGrabServer(display)
113#define XUngrabServer(display)
114#define TkpSync(display)
115
116/*
117 * The following functions are implemented as macros under Windows.
118 */
119
120#define XFree(data) {if ((data) != NULL) ckfree((char *) (data));}
121#define XNoOp(display) {display->request++;}
122#define XSynchronize(display, bool) {display->request++;}
123#define XSync(display, bool) {display->request++;}
124#define XVisualIDFromVisual(visual) (visual->visualid)
125
126/*
127 * The following Tk functions are implemented as macros under Windows.
128 */
129
130#define TkpGetPixel(p) (((((p)->red >> 8) & 0xff) \
131	| ((p)->green & 0xff00) | (((p)->blue << 8) & 0xff0000)) | 0x20000000)
132
133/*
134 * These calls implement native bitmaps which are not currently
135 * supported under Windows.  The macros eliminate the calls.
136 */
137
138#define TkpDefineNativeBitmaps()
139#define TkpCreateNativeBitmap(display, source) None
140#define TkpGetNativeAppBitmap(display, name, w, h) None
141
142#endif /* _WINPORT */
143