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: tkWinPort.h,v 1.9 2002/10/19 02:10:20 hobbs Exp $
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#ifdef __CYGWIN__
46#    define _T(x) L##x
47#else
48#    include <tchar.h>
49#endif
50
51#ifdef _MSC_VER
52#    define hypot _hypot
53#endif /* _MSC_VER */
54
55#ifndef __GNUC__
56#    define strncasecmp strnicmp
57#    define strcasecmp stricmp
58#endif
59
60#define NBBY 8
61
62#ifndef OPEN_MAX
63#define OPEN_MAX 32
64#endif
65
66/*
67 * The following define causes Tk to use its internal keysym hash table
68 */
69
70#define REDO_KEYSYM_LOOKUP
71
72/*
73 * The following macro checks to see whether there is buffered
74 * input data available for a stdio FILE.
75 */
76
77#ifdef _MSC_VER
78#    define TK_READ_DATA_PENDING(f) ((f)->_cnt > 0)
79#else /* _MSC_VER */
80#    define TK_READ_DATA_PENDING(f) ((f)->level > 0)
81#endif /* _MSC_VER */
82
83/*
84 * The following stubs implement various calls that don't do anything
85 * under Windows.
86 */
87
88#define TkFreeWindowId(dispPtr,w)
89#define TkInitXId(dispPtr)
90#define TkpCmapStressed(tkwin,colormap) (0)
91#define XFlush(display)
92#define XGrabServer(display)
93#define XUngrabServer(display)
94#define TkpSync(display)
95
96/*
97 * The following functions are implemented as macros under Windows.
98 */
99
100#define XFree(data) {if ((data) != NULL) ckfree((char *) (data));}
101#define XNoOp(display) {display->request++;}
102#define XSynchronize(display, bool) {display->request++;}
103#define XSync(display, bool) {display->request++;}
104#define XVisualIDFromVisual(visual) (visual->visualid)
105
106/*
107 * The following Tk functions are implemented as macros under Windows.
108 */
109
110#define TkpGetPixel(p) (((((p)->red >> 8) & 0xff) \
111	| ((p)->green & 0xff00) | (((p)->blue << 8) & 0xff0000)) | 0x20000000)
112
113/*
114 * These calls implement native bitmaps which are not currently
115 * supported under Windows.  The macros eliminate the calls.
116 */
117
118#define TkpDefineNativeBitmaps()
119#define TkpCreateNativeBitmap(display, source) None
120#define TkpGetNativeAppBitmap(display, name, w, h) None
121
122/*
123 * Define timezone for gettimeofday.
124 */
125
126struct timezone {
127    int tz_minuteswest;
128    int tz_dsttime;
129};
130
131#ifndef _TCLINT
132#include <tclInt.h>
133#endif
134
135#endif /* _WINPORT */
136