OSDN Git Service

Please enter the commit message for your changes. Lines starting
[eos/base.git] / util / src / TclTk / tk8.6.12 / macosx / tkMacOSXPort.h
1 /*
2  * tkMacOSXPort.h --
3  *
4  *      This file is included by all of the Tk C files.  It contains
5  *      information that may be configuration-dependent, such as
6  *      #includes for system include files and a few other things.
7  *
8  * Copyright (c) 1994-1996 Sun Microsystems, Inc.
9  * Copyright 2001-2009, Apple Inc.
10  * Copyright (c) 2005-2009 Daniel A. Steffen <das@users.sourceforge.net>
11  *
12  * See the file "license.terms" for information on usage and redistribution
13  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
14  */
15
16 #ifndef _TKMACPORT
17 #define _TKMACPORT
18
19 #include <stdio.h>
20 #include <pwd.h>
21 #include <assert.h>
22 #include <errno.h>
23 #include <fcntl.h>
24 #include <ctype.h>
25 #include <math.h>
26 #include <string.h>
27 #include <limits.h>
28 #include <stdlib.h>
29 #include <sys/types.h>
30 #include <sys/file.h>
31 #ifdef HAVE_SYS_SELECT_H
32 #   include <sys/select.h>
33 #endif
34 #include <sys/stat.h>
35 #ifndef _TCL
36 #   include <tcl.h>
37 #endif
38 #if TIME_WITH_SYS_TIME
39 #   include <sys/time.h>
40 #   include <time.h>
41 #else
42 #   if HAVE_SYS_TIME_H
43 #       include <sys/time.h>
44 #   else
45 #       include <time.h>
46 #   endif
47 #endif
48 #if HAVE_INTTYPES_H
49 #    include <inttypes.h>
50 #endif
51 #include <unistd.h>
52 #if defined(__GNUC__) && !defined(__cplusplus)
53 #   pragma GCC diagnostic ignored "-Wc++-compat"
54 #endif
55 #include <X11/Xlib.h>
56 #include <X11/cursorfont.h>
57 #include <X11/keysym.h>
58 #include <X11/Xatom.h>
59 #include <X11/Xfuncproto.h>
60 #include <X11/Xutil.h>
61
62 /*
63  * The following macro defines the type of the mask arguments to
64  * select:
65  */
66
67 #ifndef NO_FD_SET
68 #   define SELECT_MASK fd_set
69 #else
70 #   ifndef _AIX
71         typedef long fd_mask;
72 #   endif
73 #   if defined(_IBMR2)
74 #       define SELECT_MASK void
75 #   else
76 #       define SELECT_MASK int
77 #   endif
78 #endif
79
80 /*
81  * Used to tag functions that are only to be visible within the module being
82  * built and not outside it (where this is supported by the linker).
83  */
84
85 #ifndef MODULE_SCOPE
86 #   ifdef __cplusplus
87 #       define MODULE_SCOPE extern "C"
88 #   else
89 #       define MODULE_SCOPE extern
90 #   endif
91 #endif
92
93 /*
94  * The following macro defines the number of fd_masks in an fd_set:
95  */
96
97 #ifndef FD_SETSIZE
98 #   ifdef OPEN_MAX
99 #       define FD_SETSIZE OPEN_MAX
100 #   else
101 #       define FD_SETSIZE 256
102 #   endif
103 #endif
104 #if !defined(howmany)
105 #   define howmany(x, y) (((x)+((y)-1))/(y))
106 #endif
107 #ifndef NFDBITS
108 #   define NFDBITS NBBY*sizeof(fd_mask)
109 #endif
110 #define MASK_SIZE howmany(FD_SETSIZE, NFDBITS)
111
112 /*
113  * Define "NBBY" (number of bits per byte) if it's not already defined.
114  */
115
116 #ifndef NBBY
117 #   define NBBY 8
118 #endif
119
120 /*
121  * The following define causes Tk to use its internal keysym hash table
122  */
123
124 #define REDO_KEYSYM_LOOKUP
125
126 /*
127  * Defines for X functions that are used by Tk but are treated as
128  * no-op functions on the Macintosh.
129  */
130
131 #undef XFlush
132 #define XFlush(display) (0)
133 #undef XFree
134 #define XFree(data) (((data) != NULL) ? (ckfree(data),0) : 0)
135 #undef XGrabServer
136 #define XGrabServer(display) (0)
137 #undef XNoOp
138 #define XNoOp(display) (display->request++,0)
139 #undef XUngrabServer
140 #define XUngrabServer(display) (0)
141 #undef XSynchronize
142 #define XSynchronize(display, onoff) (display->request++,NULL)
143 #undef XVisualIDFromVisual
144 #define XVisualIDFromVisual(visual) (visual->visualid)
145
146 /*
147  * The following functions are not used on the Mac, so we stub them out.
148  */
149
150 #define TkpCmapStressed(tkwin,colormap) (0)
151 #define TkpFreeColor(tkColPtr)
152 #define TkSetPixmapColormap(p,c) {}
153 #define TkpSync(display)
154
155 /*
156  * TkMacOSXGetCapture is a legacy function used on the Mac. When fixing
157  * [943d5ebe51], TkpGetCapture was added to the Windows port. Both
158  * are actually the same feature and should bear the same name. However,
159  * in order to avoid potential backwards incompatibilities, renaming
160  * TkMacOSXGetCapture into TkpGetCapture in *PlatDecls.h shall not be
161  * done in a patch release, therefore use a define here.
162  */
163
164 #define TkpGetCapture TkMacOSXGetCapture
165
166 /*
167  * This macro stores a representation of the window handle in a string.
168  */
169
170 #define TkpPrintWindowId(buf,w) \
171         sprintf((buf), "0x%lx", (unsigned long) (w))
172
173 /*
174  * Turn off Tk double-buffering as Aqua windows are already double-buffered.
175  */
176
177 #define TK_NO_DOUBLE_BUFFERING 1
178 #define TK_HAS_DYNAMIC_COLORS 1
179 #define TK_DYNAMIC_COLORMAP 0x0fffffff
180
181 /*
182  * Inform tkImgPhInstance.c that we implement TkpPutRGBAImage to render RGBA
183  * images directly into a window.
184  */
185
186 #define TK_CAN_RENDER_RGBA
187
188 MODULE_SCOPE int TkpPutRGBAImage(
189                      Display* display, Drawable drawable, GC gc,XImage* image,
190                      int src_x, int src_y, int dest_x, int dest_y,
191                      unsigned int width, unsigned int height);
192
193 /*
194  * Used by xcolor.c
195  */
196
197 MODULE_SCOPE unsigned long TkMacOSXRGBPixel(unsigned long red, unsigned long green,
198                                             unsigned long blue);
199 #define TkpGetPixel(p) (TkMacOSXRGBPixel(p->red >> 8, p->green >> 8, p->blue >> 8))
200
201 /*
202  * Used by tkWindow.c
203  */
204
205 MODULE_SCOPE void TkMacOSXHandleMapOrUnmap(Tk_Window tkwin, XEvent *event);
206
207 #define TkpHandleMapOrUnmap(tkwin, event)  TkMacOSXHandleMapOrUnmap(tkwin, event)
208
209 /*
210  * Used by tkAppInit
211  */
212
213 #define USE_CUSTOM_EXIT_PROC
214 EXTERN int TkpWantsExitProc(void);
215 EXTERN TCL_NORETURN void TkpExitProc(void *);
216
217 #endif /* _TKMACPORT */