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 
14 #ifndef _TKMACINT
15 #define _TKMACINT
16 
17 #ifndef _TKINT
18 #include "tkInt.h"
19 #endif
20 
21 /*
22  * Include platform specific public interfaces.
23  */
24 
25 #ifndef _TKMAC
26 #include "tkMacOSX.h"
27 #define Cursor QDCursor
28 #import <Cocoa/Cocoa.h>
29 #undef Cursor
30 #endif
31 
32 /*
33  * Define compatibility platform types used in the structures below so that
34  * this header can be included without pulling in the platform headers.
35  */
36 
37 #ifndef _TKMACPRIV
38 #   ifndef CGGEOMETRY_H_
39 #	ifndef CGFLOAT_DEFINED
40 #	    if __LP64__
41 #		define CGFloat double
42 #	    else
43 #		define CGFloat float
44 #	    endif
45 #	endif
46 #	define CGSize struct {CGFloat width; CGFloat height;}
47 #   endif
48 #   ifndef CGCONTEXT_H_
49 #	define CGContextRef void *
50 #   endif
51 #   ifndef CGCOLOR_H_
52 #	define CGColorRef void *
53 #   endif
54 #   ifndef __HISHAPE__
55 #	define HIShapeRef void *
56 #   endif
57 #   ifndef _APPKITDEFINES_H
58 #	define NSView void *
59 #   endif
60 #endif
61 
62 struct TkWindowPrivate {
63     TkWindow *winPtr;		/* Ptr to tk window or NULL if Pixmap */
64     NSView *view;
65     CGContextRef context;
66     int xOff;			/* X offset from toplevel window */
67     int yOff;			/* Y offset from toplevel window */
68     CGSize size;
69     HIShapeRef visRgn;		/* Visible region of window */
70     HIShapeRef aboveVisRgn;	/* Visible region of window & its children */
71     HIShapeRef drawRgn;		/* Clipped drawing region */
72     int referenceCount;		/* Don't delete toplevel until children are
73 				 * gone. */
74     struct TkWindowPrivate *toplevel;
75 				/* Pointer to the toplevel datastruct. */
76     CGFloat fillRGBA[4];        /* Background used by the ttk FillElement */
77     int flags;			/* Various state see defines below. */
78 };
79 typedef struct TkWindowPrivate MacDrawable;
80 
81 /*
82  * Defines use for the flags field of the MacDrawable data structure.
83  */
84 
85 #define TK_SCROLLBAR_GROW	0x01
86 #define TK_CLIP_INVALID		0x02
87 #define TK_HOST_EXISTS		0x04
88 #define TK_DRAWN_UNDER_MENU	0x08
89 #define TK_IS_PIXMAP		0x10
90 #define TK_IS_BW_PIXMAP		0x20
91 #define TK_DO_NOT_DRAW          0x40
92 #define TTK_HAS_CONTRASTING_BG  0x80
93 
94 /*
95  * I am reserving TK_EMBEDDED = 0x100 in the MacDrawable flags
96  * This is defined in tk.h. We need to duplicate the TK_EMBEDDED flag in the
97  * TkWindow structure for the window, but in the MacWin. This way we can
98  * still tell what the correct port is after the TKWindow structure has been
99  * freed. This actually happens when you bind destroy of a toplevel to
100  * Destroy of a child.
101  */
102 
103 /*
104  * Undef compatibility platform types defined above.
105  */
106 
107 #ifndef _TKMACPRIV
108 #   ifndef CGGEOMETRY_H_
109 #	ifndef CGFLOAT_DEFINED
110 #	    undef CGFloat
111 #	endif
112 #	undef CGSize
113 #   endif
114 #   ifndef CGCONTEXT_H_
115 #	undef CGContextRef
116 #   endif
117 #   ifndef CGCOLOR_H_
118 #	undef CGColorRef
119 #   endif
120 #   ifndef __HISHAPE__
121 #	undef HIShapeRef
122 #   endif
123 #   ifndef _APPKITDEFINES_H
124 #	undef NSView
125 #   endif
126 #endif
127 
128 /*
129  * Defines used for TkMacOSXInvalidateWindow
130  */
131 
132 #define TK_WINDOW_ONLY 0
133 #define TK_PARENT_WINDOW 1
134 
135 /*
136  * Accessor for the privatePtr flags field for the TK_HOST_EXISTS field
137  */
138 
139 #define TkMacOSXHostToplevelExists(tkwin) \
140     (((TkWindow *) (tkwin))->privatePtr->toplevel->flags & TK_HOST_EXISTS)
141 
142 /*
143  * Defines used for the flags argument to TkGenWMConfigureEvent.
144  */
145 
146 #define TK_LOCATION_CHANGED	1
147 #define TK_SIZE_CHANGED		2
148 #define TK_BOTH_CHANGED		3
149 #define TK_MACOSX_HANDLE_EVENT_IMMEDIATELY 1024
150 
151 /*
152  * Defines for tkTextDisp.c and tkFont.c
153  */
154 
155 #define TK_LAYOUT_WITH_BASE_CHUNKS	1
156 #define TK_DRAW_IN_CONTEXT		1
157 
158 /*
159  * Prototypes of internal procs not in the stubs table.
160  */
161 
162 MODULE_SCOPE void TkMacOSXDefaultStartupScript(void);
163 MODULE_SCOPE void TkpClipDrawableToRect(Display *display, Drawable d, int x,
164 	int y, int width, int height);
165 MODULE_SCOPE void TkpRetainRegion(Region r);
166 MODULE_SCOPE void TkpReleaseRegion(Region r);
167 MODULE_SCOPE void TkpShiftButton(NSButton *button, NSPoint delta);
168 MODULE_SCOPE Bool TkTestLogDisplay(Drawable drawable);
169 
170 /*
171  * Include the stubbed internal platform-specific API.
172  */
173 
174 #include "tkIntPlatDecls.h"
175 
176 #endif /* _TKMACINT */
177 
178 /*
179  * Local Variables:
180  * mode: objc
181  * c-basic-offset: 4
182  * fill-column: 79
183  * coding: utf-8
184  * End:
185  */
186