#ifndef EMACS_MACGUI_H
#define EMACS_MACGUI_H
typedef struct _XDisplay Display;
typedef Lisp_Object XrmDatabase;
typedef unsigned long Time;
#ifdef HAVE_CARBON
#undef Z
#ifdef MAC_OSX
#if ! HAVE_MKTIME || BROKEN_MKTIME
#undef mktime
#endif
#undef DEBUG
#undef free
#undef malloc
#undef realloc
#undef max
#undef min
#undef init_process
#include <Carbon/Carbon.h>
#if ! HAVE_MKTIME || BROKEN_MKTIME
#undef mktime
#define mktime emacs_mktime
#endif
#undef free
#define free unexec_free
#undef malloc
#define malloc unexec_malloc
#undef realloc
#define realloc unexec_realloc
#undef min
#define min(a, b) ((a) < (b) ? (a) : (b))
#undef max
#define max(a, b) ((a) > (b) ? (a) : (b))
#undef init_process
#define init_process emacs_init_process
#undef INFINITY
#else
#undef SIGHUP
#define OLDP2C 1
#include <Carbon.h>
#endif
#undef Z
#define Z (current_buffer->text->z)
#else
#include <QuickDraw.h>
#include <QDOffscreen.h>
#include <Appearance.h>
#include <Windows.h>
#include <Controls.h>
#include <Gestalt.h>
#endif
#ifndef USE_ATSUI
#ifdef MAC_OSX
#define USE_ATSUI 1
#endif
#endif
#ifndef USE_CG_TEXT_DRAWING
#if USE_ATSUI && MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
#define USE_CG_TEXT_DRAWING 1
#endif
#endif
#ifndef USE_CG_DRAWING
#if USE_ATSUI && MAC_OS_X_VERSION_MAX_ALLOWED >= 1020
#define USE_CG_DRAWING 1
#endif
#endif
#ifndef USE_MAC_FONT_PANEL
#if USE_ATSUI && MAC_OS_X_VERSION_MAX_ALLOWED >= 1020
#define USE_MAC_FONT_PANEL 1
#endif
#endif
#ifndef USE_MAC_TSM
#if TARGET_API_MAC_CARBON
#define USE_MAC_TSM 1
#endif
#endif
typedef WindowPtr Window;
typedef GWorldPtr Pixmap;
#define Cursor ThemeCursor
#define No_Cursor (-1)
#define FACE_DEFAULT (~0)
#if !TARGET_API_MAC_CARBON
#define GetPixDepth(pmh) ((*(pmh))->pixelSize)
#endif
typedef struct _XCharStruct
{
short lbearing;
short rbearing;
short width;
short ascent;
short descent;
#if 0
unsigned short attributes;
#endif
} XCharStruct;
enum pcm_status
{
PCM_VALID = 0,
PCM_INVALID = -1,
};
#define STORE_XCHARSTRUCT(xcs, w, bds) \
((xcs).width = (w), \
(xcs).lbearing = (bds).left, \
(xcs).rbearing = (bds).right, \
(xcs).ascent = -(bds).top, \
(xcs).descent = (bds).bottom)
struct MacFontStruct {
char *full_name;
short mac_fontnum;
int mac_fontsize;
short mac_fontface;
#if TARGET_API_MAC_CARBON
int mac_scriptcode;
#else
short mac_scriptcode;
#endif
#if USE_ATSUI
ATSUStyle mac_style;
#if USE_CG_TEXT_DRAWING
CGFontRef cg_font;
CGGlyph *cg_glyphs;
#endif
#endif
#if 0
XExtData *ext_data;
Font fid;
unsigned direction;
#endif
unsigned min_char_or_byte2;
unsigned max_char_or_byte2;
unsigned min_byte1;
unsigned max_byte1;
#if 0
Bool all_chars_exist;
unsigned default_char;
int n_properties;
XFontProp *properties;
#endif
XCharStruct min_bounds;
XCharStruct max_bounds;
union {
XCharStruct *per_char;
XCharStruct **rows;
} bounds;
int ascent;
int descent;
};
typedef struct MacFontStruct MacFontStruct;
typedef struct MacFontStruct XFontStruct;
typedef struct {
unsigned char byte1;
unsigned char byte2;
} XChar2b;
#define STORE_XCHAR2B(chp, b1, b2) \
((chp)->byte1 = (b1), (chp)->byte2 = (b2))
#define XCHAR2B_BYTE1(chp) \
((chp)->byte1)
#define XCHAR2B_BYTE2(chp) \
((chp)->byte2)
typedef struct _XGCValues
{
unsigned long foreground;
unsigned long background;
XFontStruct *font;
} XGCValues;
typedef struct _XGC
{
XGCValues xgcv;
RGBColor fore_color;
RGBColor back_color;
#if USE_CG_DRAWING && MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
CGColorRef cg_fore_color;
CGColorRef cg_back_color;
#endif
#define MAX_CLIP_RECTS 2
int n_clip_rects;
RgnHandle clip_region;
#if defined (MAC_OSX) && (USE_ATSUI || USE_CG_DRAWING)
CGRect clip_rects[MAX_CLIP_RECTS];
#endif
} *GC;
#define GCForeground (1L<<2)
#define GCBackground (1L<<3)
#define GCFont (1L<<14)
#define GCGraphicsExposures 0
#define ForgetGravity 0
#define NorthWestGravity 1
#define NorthGravity 2
#define NorthEastGravity 3
#define WestGravity 4
#define CenterGravity 5
#define EastGravity 6
#define SouthWestGravity 7
#define SouthGravity 8
#define SouthEastGravity 9
#define StaticGravity 10
#define NoValue 0x0000
#define XValue 0x0001
#define YValue 0x0002
#define WidthValue 0x0004
#define HeightValue 0x0008
#define AllValues 0x000F
#define XNegative 0x0010
#define YNegative 0x0020
typedef struct {
long flags;
#if 0
int x, y;
int width, height;
#endif
int min_width, min_height;
#if 0
int max_width, max_height;
#endif
int width_inc, height_inc;
#if 0
struct {
int x;
int y;
} min_aspect, max_aspect;
#endif
int base_width, base_height;
#if 0
int win_gravity;
#endif
} XSizeHints;
#define USPosition (1L << 0)
#define USSize (1L << 1)
#define PPosition (1L << 2)
#define PSize (1L << 3)
#define PMinSize (1L << 4)
#define PMaxSize (1L << 5)
#define PResizeInc (1L << 6)
#define PAspect (1L << 7)
#define PBaseSize (1L << 8)
#define PWinGravity (1L << 9)
typedef struct {
int x, y;
unsigned width, height;
} XRectangle;
#define NativeRectangle Rect
#define CONVERT_TO_XRECT(xr,nr) \
((xr).x = (nr).left, \
(xr).y = (nr).top, \
(xr).width = ((nr).right - (nr).left), \
(xr).height = ((nr).bottom - (nr).top))
#define CONVERT_FROM_XRECT(xr,nr) \
((nr).left = (xr).x, \
(nr).top = (xr).y, \
(nr).right = ((xr).x + (xr).width), \
(nr).bottom = ((xr).y + (xr).height))
#define STORE_NATIVE_RECT(nr,x,y,width,height) \
((nr).left = (x), \
(nr).top = (y), \
(nr).right = ((nr).left + (width)), \
(nr).bottom = ((nr).top + (height)))
#endif