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, Apple Computer, Inc.
8 * Copyright (c) 2005-2007 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: tkMacOSXInt.h,v 1.3.2.23 2007/11/09 06:26:55 das Exp $
14 */
15
16#ifndef _TKMACINT
17#define _TKMACINT
18
19#ifndef _TKINT
20#include "tkInt.h"
21#endif
22
23#define TextStyle MacTextStyle
24#include <Carbon/Carbon.h>
25#include <ApplicationServices/ApplicationServicesPriv.h>
26#undef TextStyle
27
28/*
29 * Include platform specific public interfaces.
30 */
31
32#ifndef _TKMAC
33#include "tkMacOSX.h"
34#endif
35
36struct TkWindowPrivate {
37    TkWindow *winPtr;		/* Ptr to tk window or NULL if Pixmap */
38    CGrafPtr grafPtr;
39    CGContextRef context;
40    ControlRef rootControl;
41    int xOff;			/* X offset from toplevel window */
42    int yOff;			/* Y offset from toplevel window */
43    CGSize size;
44    HIShapeRef visRgn;		/* Visible region of window */
45    HIShapeRef aboveVisRgn;	/* Visible region of window & its children */
46    CGRect drawRect;		/* Clipped drawing rect */
47    int referenceCount;		/* Don't delete toplevel until children are
48				 * gone. */
49    struct TkWindowPrivate *toplevel;
50				/* Pointer to the toplevel datastruct. */
51    int flags;			/* Various state see defines below. */
52};
53typedef struct TkWindowPrivate MacDrawable;
54
55/*
56 * This list is used to keep track of toplevel windows that have a Mac
57 * window attached. This is useful for several things, not the least
58 * of which is maintaining floating windows.
59 */
60
61typedef struct TkMacOSXWindowList {
62    struct TkMacOSXWindowList *nextPtr;
63				/* The next window in the list. */
64    TkWindow *winPtr;		/* This window */
65} TkMacOSXWindowList;
66
67/*
68 * Defines use for the flags field of the MacDrawable data structure.
69 */
70
71#define TK_SCROLLBAR_GROW	0x01
72#define TK_CLIP_INVALID		0x02
73#define TK_HOST_EXISTS		0x04
74#define TK_DRAWN_UNDER_MENU	0x08
75#define TK_CLIPPED_DRAW		0x10
76#define TK_IS_PIXMAP		0x20
77#define TK_IS_BW_PIXMAP		0x40
78
79/*
80 * I am reserving TK_EMBEDDED = 0x100 in the MacDrawable flags
81 * This is defined in tk.h. We need to duplicate the TK_EMBEDDED flag in the
82 * TkWindow structure for the window, but in the MacWin. This way we can
83 * still tell what the correct port is after the TKWindow structure has been
84 * freed. This actually happens when you bind destroy of a toplevel to
85 * Destroy of a child.
86 */
87
88/*
89 * This structure is for handling Netscape-type in process
90 * embedding where Tk does not control the top-level. It contains
91 * various functions that are needed by Mac specific routines, like
92 * TkMacOSXGetDrawablePort. The definitions of the function types
93 * are in tkMacOSX.h.
94 */
95
96typedef struct {
97    Tk_MacOSXEmbedRegisterWinProc *registerWinProc;
98    Tk_MacOSXEmbedGetGrafPortProc *getPortProc;
99    Tk_MacOSXEmbedMakeContainerExistProc *containerExistProc;
100    Tk_MacOSXEmbedGetClipProc *getClipProc;
101    Tk_MacOSXEmbedGetOffsetInParentProc *getOffsetProc;
102} TkMacOSXEmbedHandler;
103
104MODULE_SCOPE TkMacOSXEmbedHandler *tkMacOSXEmbedHandler;
105
106/*
107 * Defines used for TkMacOSXInvalidateWindow
108 */
109
110#define TK_WINDOW_ONLY 0
111#define TK_PARENT_WINDOW 1
112
113/*
114 * Accessor for the privatePtr flags field for the TK_HOST_EXISTS field
115 */
116
117#define TkMacOSXHostToplevelExists(tkwin) \
118    (((TkWindow *) (tkwin))->privatePtr->toplevel->flags & TK_HOST_EXISTS)
119
120/*
121 * Defines use for the flags argument to TkGenWMConfigureEvent.
122 */
123
124#define TK_LOCATION_CHANGED	1
125#define TK_SIZE_CHANGED		2
126#define TK_BOTH_CHANGED		3
127
128/*
129 * Globals shared among TkAqua.
130 */
131
132MODULE_SCOPE MenuHandle tkCurrentAppleMenu; /* Handle to current Apple Menu */
133MODULE_SCOPE MenuHandle tkAppleMenu;	/* Handle to default Apple Menu */
134MODULE_SCOPE MenuHandle tkFileMenu;	/* Handles to menus */
135MODULE_SCOPE MenuHandle tkEditMenu;	/* Handles to menus */
136MODULE_SCOPE int tkPictureIsOpen;	/* If this is 1, we are drawing to a
137					 * picture The clipping should then be
138					 * done relative to the bounds of the
139					 * picture rather than the window. As
140					 * of OS X.0.4, something is seriously
141					 * wrong: The clipping bounds only
142					 * seem to work if the top,left values
143					 * are 0,0 The destination rectangle
144					 * for CopyBits should also have
145					 * top,left values of 0,0
146					 */
147MODULE_SCOPE TkMacOSXWindowList *tkMacOSXWindowListPtr; /* List of toplevels */
148MODULE_SCOPE Tcl_Encoding TkMacOSXCarbonEncoding;
149
150/*
151 * Prototypes of internal procs not in the stubs table.
152 */
153
154MODULE_SCOPE void TkMacOSXDefaultStartupScript(void);
155#if 0
156MODULE_SCOPE int XSetClipRectangles(Display *d, GC gc, int clip_x_origin,
157	int clip_y_origin, XRectangle* rectangles, int n, int ordering);
158#endif
159MODULE_SCOPE void TkpClipDrawableToRect(Display *display, Drawable d, int x,
160	int y, int width, int height);
161MODULE_SCOPE void TkpRetainRegion(TkRegion r);
162MODULE_SCOPE void TkpReleaseRegion(TkRegion r);
163
164/*
165 * Include the stubbed internal platform-specific API.
166 */
167
168#include "tkIntPlatDecls.h"
169
170#endif /* _TKMACINT */
171