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, Apple Computer, Inc. 10 * Copyright (c) 2005-2007 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: tkMacOSXPort.h,v 1.3.2.7 2007/04/29 02:26:50 das Exp $ 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#include <unistd.h> 64#include <X11/Xlib.h> 65#include <X11/cursorfont.h> 66#include <X11/keysym.h> 67#include <X11/Xatom.h> 68#include <X11/Xfuncproto.h> 69#include <X11/Xutil.h> 70#include "tkIntXlibDecls.h" 71 72/* 73 * The following macro defines the type of the mask arguments to 74 * select: 75 */ 76 77#ifndef NO_FD_SET 78# define SELECT_MASK fd_set 79#else 80# ifndef _AIX 81 typedef long fd_mask; 82# endif 83# if defined(_IBMR2) 84# define SELECT_MASK void 85# else 86# define SELECT_MASK int 87# endif 88#endif 89 90/* 91 * The following macro defines the number of fd_masks in an fd_set: 92 */ 93 94#ifndef FD_SETSIZE 95# ifdef OPEN_MAX 96# define FD_SETSIZE OPEN_MAX 97# else 98# define FD_SETSIZE 256 99# endif 100#endif 101#if !defined(howmany) 102# define howmany(x, y) (((x)+((y)-1))/(y)) 103#endif 104#ifndef NFDBITS 105# define NFDBITS NBBY*sizeof(fd_mask) 106#endif 107#define MASK_SIZE howmany(FD_SETSIZE, NFDBITS) 108 109/* 110 * Define "NBBY" (number of bits per byte) if it's not already defined. 111 */ 112 113#ifndef NBBY 114# define NBBY 8 115#endif 116 117/* 118 * The following define causes Tk to use its internal keysym hash table 119 */ 120 121#define REDO_KEYSYM_LOOKUP 122 123/* 124 * Defines for X functions that are used by Tk but are treated as 125 * no-op functions on the Macintosh. 126 */ 127 128#define XFlush(display) 129#define XFree(data) {if ((data) != NULL) ckfree((char *) (data));} 130#define XGrabServer(display) 131#define XNoOp(display) {display->request++;} 132#define XUngrabServer(display) 133#define XSynchronize(display, bool) {display->request++;} 134#define XVisualIDFromVisual(visual) (visual->visualid) 135 136/* 137 * The following functions are not used on the Mac, so we stub them out. 138 */ 139 140#define TkFreeWindowId(dispPtr,w) 141#define TkInitXId(dispPtr) 142#define TkpButtonSetDefaults(specPtr) {} 143#define TkpCmapStressed(tkwin,colormap) (0) 144#define TkpFreeColor(tkColPtr) 145#define TkSetPixmapColormap(p,c) {} 146#define TkpSync(display) 147 148/* 149 * The following macro returns the pixel value that corresponds to the 150 * RGB values in the given XColor structure. 151 */ 152 153#define PIXEL_MAGIC ((unsigned char) 0x69) 154#define TkpGetPixel(p) ((((((PIXEL_MAGIC << 8) \ 155 | (((p)->red >> 8) & 0xff)) << 8) \ 156 | (((p)->green >> 8) & 0xff)) << 8) \ 157 | (((p)->blue >> 8) & 0xff)) 158 159/* 160 * This macro stores a representation of the window handle in a string. 161 * This should perhaps use the real size of an XID. 162 */ 163 164#define TkpPrintWindowId(buf,w) \ 165 sprintf((buf), "0x%x", (unsigned int) (w)) 166 167/* 168 * TkpScanWindowId is just an alias for Tcl_GetInt on Unix. 169 */ 170 171#define TkpScanWindowId(i,s,wp) \ 172 Tcl_GetInt((i),(s),(int *) (wp)) 173 174/* 175 * Turn off Tk double-buffering as Aqua windows are already double-buffered. 176 */ 177 178#define TK_NO_DOUBLE_BUFFERING 1 179 180/* 181 * Magic pixel code values for system colors. 182 * 183 * NOTE: values must be kept in sync with indices into the 184 * systemColorMap array in tkMacOSXColor.c ! 185 */ 186 187#define TRANSPARENT_PIXEL 30 188#define HIGHLIGHT_PIXEL 31 189#define HIGHLIGHT_SECONDARY_PIXEL 32 190#define HIGHLIGHT_TEXT_PIXEL 33 191#define HIGHLIGHT_ALTERNATE_PIXEL 34 192#define CONTROL_TEXT_PIXEL 35 193#define CONTROL_BODY_PIXEL 37 194#define CONTROL_FRAME_PIXEL 39 195#define WINDOW_BODY_PIXEL 41 196#define MENU_ACTIVE_PIXEL 43 197#define MENU_ACTIVE_TEXT_PIXEL 45 198#define MENU_BACKGROUND_PIXEL 47 199#define MENU_DISABLED_PIXEL 49 200#define MENU_TEXT_PIXEL 51 201#define APPEARANCE_PIXEL 52 202 203#endif /* _TKMACPORT */ 204