1/*
2 * tkMacOSXInt.h --
3 *
4 *	Declarations of Macintosh specific shared variables and procedures.
5 *
6 * Copyright (c) 1995-1997 Sun Microsystems, Inc.
7 * Copyright 2001-2009, Apple Inc.
8 * Copyright (c) 2005-2009 Daniel A. Steffen <das@users.sourceforge.net>
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$
14 */
15
16#ifndef _TKMACINT
17#define _TKMACINT
18
19#ifndef _TKINT
20#include "tkInt.h"
21#endif
22
23/*
24 * Include platform specific public interfaces.
25 */
26
27#ifndef _TKMAC
28#include "tkMacOSX.h"
29#endif
30
31/*
32 * Define compatibility platform types used in the structures below so that
33 * this header can be included without pulling in the platform headers.
34 */
35
36#ifndef _TKMACPRIV
37#   ifndef CGGEOMETRY_H_
38#	ifndef CGFLOAT_DEFINED
39#	    if __LP64__
40#		define CGFloat double
41#	    else
42#		define CGFloat float
43#	    endif
44#	endif
45#	define CGSize struct {CGFloat width; CGFloat height;}
46#   endif
47#   ifndef CGCONTEXT_H_
48#	define CGContextRef void *
49#   endif
50#   ifndef CGCOLOR_H_
51#	define CGColorRef void *
52#   endif
53#   ifndef __HISHAPE__
54#	define HIShapeRef void *
55#   endif
56#   ifndef _APPKITDEFINES_H
57#	define NSView void *
58#   endif
59#endif
60
61struct TkWindowPrivate {
62    TkWindow *winPtr;		/* Ptr to tk window or NULL if Pixmap */
63    NSView *view;
64    CGContextRef context;
65    int xOff;			/* X offset from toplevel window */
66    int yOff;			/* Y offset from toplevel window */
67    CGSize size;
68    HIShapeRef visRgn;		/* Visible region of window */
69    HIShapeRef aboveVisRgn;	/* Visible region of window & its children */
70    HIShapeRef drawRgn;		/* Clipped drawing region */
71    int referenceCount;		/* Don't delete toplevel until children are
72				 * gone. */
73    struct TkWindowPrivate *toplevel;
74				/* Pointer to the toplevel datastruct. */
75    int flags;			/* Various state see defines below. */
76};
77typedef struct TkWindowPrivate MacDrawable;
78
79/*
80 * Defines use for the flags field of the MacDrawable data structure.
81 */
82
83#define TK_SCROLLBAR_GROW	0x01
84#define TK_CLIP_INVALID		0x02
85#define TK_HOST_EXISTS		0x04
86#define TK_DRAWN_UNDER_MENU	0x08
87#define TK_FOCUSED_VIEW		0x10
88#define TK_IS_PIXMAP		0x20
89#define TK_IS_BW_PIXMAP		0x40
90
91/*
92 * I am reserving TK_EMBEDDED = 0x100 in the MacDrawable flags
93 * This is defined in tk.h. We need to duplicate the TK_EMBEDDED flag in the
94 * TkWindow structure for the window, but in the MacWin. This way we can
95 * still tell what the correct port is after the TKWindow structure has been
96 * freed. This actually happens when you bind destroy of a toplevel to
97 * Destroy of a child.
98 */
99
100/*
101 * This structure is for handling Netscape-type in process
102 * embedding where Tk does not control the top-level. It contains
103 * various functions that are needed by Mac specific routines, like
104 * TkMacOSXGetDrawablePort. The definitions of the function types
105 * are in tkMacOSX.h.
106 */
107
108typedef struct {
109    Tk_MacOSXEmbedRegisterWinProc *registerWinProc;
110    Tk_MacOSXEmbedGetGrafPortProc *getPortProc;
111    Tk_MacOSXEmbedMakeContainerExistProc *containerExistProc;
112    Tk_MacOSXEmbedGetClipProc *getClipProc;
113    Tk_MacOSXEmbedGetOffsetInParentProc *getOffsetProc;
114} TkMacOSXEmbedHandler;
115
116MODULE_SCOPE TkMacOSXEmbedHandler *tkMacOSXEmbedHandler;
117
118/*
119 * GC CGColorRef cache for tkMacOSXColor.c
120 */
121
122typedef struct {
123    unsigned long cachedForeground;
124    CGColorRef cachedForegroundColor;
125    unsigned long cachedBackground;
126    CGColorRef cachedBackgroundColor;
127} TkpGCCache;
128
129MODULE_SCOPE TkpGCCache *TkpGetGCCache(GC gc);
130MODULE_SCOPE void TkpInitGCCache(GC gc);
131MODULE_SCOPE void TkpFreeGCCache(GC gc);
132
133/*
134 * Undef compatibility platform types defined above.
135 */
136
137#ifndef _TKMACPRIV
138#   ifndef CGGEOMETRY_H_
139#	ifndef CGFLOAT_DEFINED
140#	    undef CGFloat
141#	endif
142#	undef CGSize
143#   endif
144#   ifndef CGCONTEXT_H_
145#	undef CGContextRef
146#   endif
147#   ifndef CGCOLOR_H_
148#	undef CGColorRef
149#   endif
150#   ifndef __HISHAPE__
151#	undef HIShapeRef
152#   endif
153#   ifndef _APPKITDEFINES_H
154#	undef NSView
155#   endif
156#endif
157
158/*
159 * Defines used for TkMacOSXInvalidateWindow
160 */
161
162#define TK_WINDOW_ONLY 0
163#define TK_PARENT_WINDOW 1
164
165/*
166 * Accessor for the privatePtr flags field for the TK_HOST_EXISTS field
167 */
168
169#define TkMacOSXHostToplevelExists(tkwin) \
170    (((TkWindow *) (tkwin))->privatePtr->toplevel->flags & TK_HOST_EXISTS)
171
172/*
173 * Defines used for the flags argument to TkGenWMConfigureEvent.
174 */
175
176#define TK_LOCATION_CHANGED	1
177#define TK_SIZE_CHANGED		2
178#define TK_BOTH_CHANGED		3
179#define TK_MACOSX_HANDLE_EVENT_IMMEDIATELY 1024
180
181/*
182 * Defines for tkTextDisp.c
183 */
184
185#define TK_LAYOUT_WITH_BASE_CHUNKS	1
186#define TK_DRAW_IN_CONTEXT		1
187
188/*
189 * Prototypes of internal procs not in the stubs table.
190 */
191
192MODULE_SCOPE void TkMacOSXDefaultStartupScript(void);
193#if 0
194MODULE_SCOPE int XSetClipRectangles(Display *d, GC gc, int clip_x_origin,
195	int clip_y_origin, XRectangle* rectangles, int n, int ordering);
196#endif
197MODULE_SCOPE void TkpClipDrawableToRect(Display *display, Drawable d, int x,
198	int y, int width, int height);
199MODULE_SCOPE void TkpRetainRegion(TkRegion r);
200MODULE_SCOPE void TkpReleaseRegion(TkRegion r);
201
202/*
203 * Include the stubbed internal platform-specific API.
204 */
205
206#include "tkIntPlatDecls.h"
207
208#endif /* _TKMACINT */
209