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