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 * RCS: @(#) $Id$ 16 */ 17 18#ifndef _TKMACPORT 19#define _TKMACPORT 20 21/* 22 * Macro to use instead of "void" for arguments that must have 23 * type "void *" in ANSI C; maps them to type "char *" in 24 * non-ANSI systems. This macro may be used in some of the include 25 * files below, which is why it is defined here. 26 */ 27 28#ifndef VOID 29# ifdef __STDC__ 30# define VOID void 31# else 32# define VOID char 33# endif 34#endif 35 36#include <stdio.h> 37#include <ctype.h> 38#include <fcntl.h> 39#include <limits.h> 40#include <math.h> 41#include <pwd.h> 42#include <stdlib.h> 43#include <string.h> 44#include <sys/types.h> 45#include <sys/file.h> 46#ifdef HAVE_SYS_SELECT_H 47# include <sys/select.h> 48#endif 49#include <sys/stat.h> 50#ifndef _TCL 51# include <tcl.h> 52#endif 53#if TIME_WITH_SYS_TIME 54# include <sys/time.h> 55# include <time.h> 56#else 57# if HAVE_SYS_TIME_H 58# include <sys/time.h> 59# else 60# include <time.h> 61# endif 62#endif 63#if HAVE_INTTYPES_H 64# include <inttypes.h> 65#endif 66#include <unistd.h> 67#include <X11/Xlib.h> 68#include <X11/cursorfont.h> 69#include <X11/keysym.h> 70#include <X11/Xatom.h> 71#include <X11/Xfuncproto.h> 72#include <X11/Xutil.h> 73#include "tkIntXlibDecls.h" 74 75/* 76 * The following macro defines the type of the mask arguments to 77 * select: 78 */ 79 80#ifndef NO_FD_SET 81# define SELECT_MASK fd_set 82#else 83# ifndef _AIX 84 typedef long fd_mask; 85# endif 86# if defined(_IBMR2) 87# define SELECT_MASK void 88# else 89# define SELECT_MASK int 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#define XFlush(display) 132#define XFree(data) {if ((data) != NULL) ckfree((char *) (data));} 133#define XGrabServer(display) 134#define XNoOp(display) {display->request++;} 135#define XUngrabServer(display) 136#define XSynchronize(display, bool) {display->request++;} 137#define XVisualIDFromVisual(visual) (visual->visualid) 138 139/* 140 * The following functions are not used on the Mac, so we stub them out. 141 */ 142 143#define TkFreeWindowId(dispPtr,w) 144#define TkInitXId(dispPtr) 145#define TkpCmapStressed(tkwin,colormap) (0) 146#define TkpFreeColor(tkColPtr) 147#define TkSetPixmapColormap(p,c) {} 148#define TkpSync(display) 149 150/* 151 * The following macro returns the pixel value that corresponds to the 152 * RGB values in the given XColor structure. 153 */ 154 155#define PIXEL_MAGIC ((unsigned char) 0x69) 156#define TkpGetPixel(p) ((((((PIXEL_MAGIC << 8) \ 157 | (((p)->red >> 8) & 0xff)) << 8) \ 158 | (((p)->green >> 8) & 0xff)) << 8) \ 159 | (((p)->blue >> 8) & 0xff)) 160 161/* 162 * This macro stores a representation of the window handle in a string. 163 * This should perhaps use the real size of an XID. 164 */ 165 166#define TkpPrintWindowId(buf,w) \ 167 sprintf((buf), "0x%x", (unsigned int) (w)) 168 169/* 170 * TkpScanWindowId is just an alias for Tcl_GetInt on Unix. 171 */ 172 173#define TkpScanWindowId(i,s,wp) \ 174 Tcl_GetInt((i),(s),(int *) (wp)) 175 176/* 177 * Turn off Tk double-buffering as Aqua windows are already double-buffered. 178 */ 179 180#define TK_NO_DOUBLE_BUFFERING 1 181 182/* 183 * Magic pixel code values for system colors. 184 * 185 * NOTE: values must be kept in sync with indices into the 186 * systemColorMap array in tkMacOSXColor.c ! 187 */ 188 189#define TRANSPARENT_PIXEL 30 190#define HIGHLIGHT_PIXEL 31 191#define HIGHLIGHT_SECONDARY_PIXEL 32 192#define HIGHLIGHT_TEXT_PIXEL 33 193#define HIGHLIGHT_ALTERNATE_PIXEL 34 194#define CONTROL_TEXT_PIXEL 35 195#define CONTROL_BODY_PIXEL 37 196#define CONTROL_FRAME_PIXEL 39 197#define WINDOW_BODY_PIXEL 41 198#define MENU_ACTIVE_PIXEL 43 199#define MENU_ACTIVE_TEXT_PIXEL 45 200#define MENU_BACKGROUND_PIXEL 47 201#define MENU_DISABLED_PIXEL 49 202#define MENU_TEXT_PIXEL 51 203#define APPEARANCE_PIXEL 52 204 205#endif /* _TKMACPORT */ 206