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 * 9 * See the file "license.terms" for information on usage and redistribution 10 * of this file, and for a DISCLAIMER OF ALL WARRANTIES. 11 * 12 * RCS: @(#) Id 13 */ 14 15 #ifndef _TKMACINT 16 #define _TKMACINT 17 18 #ifndef _TKINT 19 #include "tkInt.h" 20 #endif 21 22 #define TextStyle MacTextStyle 23 #include <Carbon/Carbon.h> 24 #undef TextStyle 25 26 /* 27 * Include platform specific public interfaces. 28 */ 29 30 #ifndef _TKMAC 31 #include "tkMacOSX.h" 32 #endif 33 34 struct TkWindowPrivate { 35 TkWindow *winPtr; /* Ptr to tk window or NULL if Pixmap */ 36 CGrafPtr grafPtr; 37 ControlRef rootControl; 38 int xOff; /* X offset from toplevel window */ 39 int yOff; /* Y offset from toplevel window */ 40 RgnHandle clipRgn; /* Visable region of window */ 41 RgnHandle aboveClipRgn; /* Visable region of window & it's children */ 42 int referenceCount; /* Don't delete toplevel until children are 43 * gone. */ 44 struct TkWindowPrivate *toplevel; /* Pointer to the toplevel 45 * datastruct. */ 46 int flags; /* Various state see defines below. */ 47 }; 48 typedef struct TkWindowPrivate MacDrawable; 49 50 /* 51 * This list is used to keep track of toplevel windows that have a Mac 52 * window attached. This is useful for several things, not the least 53 * of which is maintaining floating windows. 54 */ 55 56 typedef struct TkMacOSXWindowList { 57 struct TkMacOSXWindowList *nextPtr; /* The next window in the list. */ 58 TkWindow *winPtr; /* This window */ 59 } TkMacOSXWindowList; 60 61 /* 62 * Defines use for the flags field of the MacDrawable data structure. 63 */ 64 65 #define TK_SCROLLBAR_GROW 1 66 #define TK_CLIP_INVALID 2 67 #define TK_HOST_EXISTS 4 68 #define TK_DRAWN_UNDER_MENU 8 69 #define TK_MAPPED_IN_PARENT 16 70 71 /* 72 * I am reserving TK_EMBEDDED = 0x100 in the MacDrawable flags 73 * This is defined in tk.h. We need to duplicate the TK_EMBEDDED flag in the 74 * TkWindow structure for the window, but in the MacWin. This way we can 75 * still tell what the correct port is after the TKWindow structure has been 76 * freed. This actually happens when you bind destroy of a toplevel to 77 * Destroy of a child. 78 */ 79 80 /* 81 * This structure is for handling Netscape-type in process 82 * embedding where Tk does not control the top-level. It contains 83 * various functions that are needed by Mac specific routines, like 84 * TkMacOSXGetDrawablePort. The definitions of the function types 85 * are in tclMac.h. 86 */ 87 88 typedef struct { 89 Tk_MacOSXEmbedRegisterWinProc *registerWinProc; 90 Tk_MacOSXEmbedGetGrafPortProc *getPortProc; 91 Tk_MacOSXEmbedMakeContainerExistProc *containerExistProc; 92 Tk_MacOSXEmbedGetClipProc *getClipProc; 93 Tk_MacOSXEmbedGetOffsetInParentProc *getOffsetProc; 94 } TkMacOSXEmbedHandler; 95 96 extern TkMacOSXEmbedHandler *gMacEmbedHandler; 97 98 /* 99 * Defines used for TkMacOSXInvalidateWindow 100 */ 101 102 #define TK_WINDOW_ONLY 0 103 #define TK_PARENT_WINDOW 1 104 105 /* 106 * Accessor for the privatePtr flags field for the TK_HOST_EXISTS field 107 */ 108 109 #define TkMacOSXHostToplevelExists(tkwin) \ 110 (((TkWindow *) (tkwin))->privatePtr->toplevel->flags & TK_HOST_EXISTS) 111 112 /* 113 * Defines use for the flags argument to TkGenWMConfigureEvent. 114 */ 115 116 #define TK_LOCATION_CHANGED 1 117 #define TK_SIZE_CHANGED 2 118 #define TK_BOTH_CHANGED 3 119 120 /* 121 * Variables shared among various Mac Tk modules but are not 122 * exported to the outside world. 123 */ 124 125 /* 126 * Globals shared among Macintosh Tk 127 */ 128 129 extern MenuHandle tkAppleMenu; /* Handle to the Apple Menu */ 130 extern MenuHandle tkFileMenu; /* Handles to menus */ 131 extern MenuHandle tkEditMenu; /* Handles to menus */ 132 extern RgnHandle tkMenuCascadeRgn; /* A region to clip with. */ 133 extern int tkUseMenuCascadeRgn; /* If this is 1, clipping code 134 * should intersect tkMenuCascadeRgn 135 * before drawing occurs. 136 * tkMenuCascadeRgn will only 137 * be valid when the value of this 138 * variable is 1. */ 139 extern int tkPictureIsOpen; /* If this is 1, we are drawing to a 140 * picture The clipping should then be 141 * done relative to the bounds of the 142 * picture rather than the window. As 143 * of OS X.0.4, something is seriously 144 * wrong: The clipping bounds only 145 * seem to work if the top,left values 146 * are 0,0 The destination rectangle 147 * for CopyBits should also have 148 * top,left values of 0,0 149 */ 150 extern TkMacOSXWindowList *tkMacOSXWindowListPtr; 151 /* The list of toplevels */ 152 153 extern Tcl_Encoding TkMacOSXCarbonEncoding; 154 155 extern void TkMacOSXDisplayChanged(Display *display); 156 extern int TkMacOSXUseAntialiasedText(Tcl_Interp *interp, int enable); 157 extern void TkMacOSXInitCarbonEvents(Tcl_Interp *interp); 158 extern int TkMacOSXInitCGDrawing(Tcl_Interp *interp, int enable, int antiAlias); 159 extern void TkMacOSXDefaultStartupScript(void); 160 extern int TkMacOSXGenerateFocusEvent( Window window, int activeFlag); 161 extern WindowClass TkMacOSXWindowClass(TkWindow *winPtr); 162 extern int TkMacOSXIsWindowZoomed(TkWindow *winPtr); 163 164 extern void* TkMacOSXGetNamedSymbol(const char* module, const char* symbol); 165 /* Macro to abstract common use of TkMacOSXGetNamedSymbol to initialize named symbols */ 166 #define TkMacOSXInitNamedSymbol(module, ret, symbol, ...) \ 167 static ret (* symbol)(__VA_ARGS__) = (void*)(-1L); \ 168 if (symbol == (void*)(-1L)) { \ 169 symbol = TkMacOSXGetNamedSymbol(STRINGIFY(module), STRINGIFY(_##symbol));\ 170 } 171 172 #include "tkIntPlatDecls.h" 173 174 #endif /* _TKMACINT */ 175