(calendar-location-name, calendar-latitude)
[emacs.git] / src / macgui.h
blob755bffbd4616f5d76c0d8d6598b0e9871036c445
1 /* Definitions and headers for communication on the Mac OS.
2 Copyright (C) 2000, 2001, 2002, 2003, 2004,
3 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
5 This file is part of GNU Emacs.
7 GNU Emacs is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
10 any later version.
12 GNU Emacs is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU Emacs; see the file COPYING. If not, write to
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA. */
22 /* Contributed by Andrew Choi (akochoi@mac.com). */
24 #ifndef EMACS_MACGUI_H
25 #define EMACS_MACGUI_H
27 typedef struct _XDisplay Display; /* opaque */
29 typedef Lisp_Object XrmDatabase;
31 typedef unsigned long Time;
33 #ifdef HAVE_CARBON
34 #undef Z
35 #ifdef MAC_OSX
36 #if ! HAVE_MKTIME || BROKEN_MKTIME
37 #undef mktime
38 #endif
39 #undef DEBUG
40 #undef free
41 #undef malloc
42 #undef realloc
43 /* Macros max and min defined in lisp.h conflict with those in
44 precompiled header Carbon.h. */
45 #undef max
46 #undef min
47 #undef init_process
48 #include <Carbon/Carbon.h>
49 #if ! HAVE_MKTIME || BROKEN_MKTIME
50 #undef mktime
51 #define mktime emacs_mktime
52 #endif
53 #undef free
54 #define free unexec_free
55 #undef malloc
56 #define malloc unexec_malloc
57 #undef realloc
58 #define realloc unexec_realloc
59 #undef min
60 #define min(a, b) ((a) < (b) ? (a) : (b))
61 #undef max
62 #define max(a, b) ((a) > (b) ? (a) : (b))
63 #undef init_process
64 #define init_process emacs_init_process
65 #undef INFINITY
66 #else /* not MAC_OSX */
67 #undef SIGHUP
68 #define OLDP2C 1
69 #include <Carbon.h>
70 #endif /* not MAC_OSX */
71 #undef Z
72 #define Z (current_buffer->text->z)
73 #else /* not HAVE_CARBON */
74 #include <QuickDraw.h> /* for WindowRef */
75 #include <QDOffscreen.h> /* for GWorldPtr */
76 #include <Appearance.h> /* for ThemeCursor */
77 #include <Windows.h>
78 #include <Controls.h>
79 #include <Gestalt.h>
80 #endif /* not HAVE_CARBON */
82 /* Whether to use ATSUI (Apple Type Services for Unicode Imaging) for
83 text drawing. */
84 #if 0 /* Don't enable by default on the emacs-unicode-2 branch. */
85 #ifndef USE_ATSUI
86 #ifdef MAC_OSX
87 #define USE_ATSUI 1
88 #endif
89 #endif
90 #endif
92 /* Whether to use low-level Quartz 2D (aka Core Graphics) text drawing
93 in preference to ATSUI for ASCII and Latin-1 characters. */
94 #ifndef USE_CG_TEXT_DRAWING
95 #if USE_ATSUI && MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
96 #define USE_CG_TEXT_DRAWING 1
97 #endif
98 #endif
100 /* Whether to use Quartz 2D routines for drawing operations other than
101 texts. */
102 #ifndef USE_CG_DRAWING
103 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020
104 #define USE_CG_DRAWING 1
105 #endif
106 #endif
108 /* Whether to use the standard Font Panel floating dialog. */
109 #ifndef USE_MAC_FONT_PANEL
110 #if USE_ATSUI && MAC_OS_X_VERSION_MAX_ALLOWED >= 1020
111 #define USE_MAC_FONT_PANEL 1
112 #endif
113 #endif
115 /* Whether to use Text Services Manager. */
116 #ifndef USE_MAC_TSM
117 #if TARGET_API_MAC_CARBON
118 #define USE_MAC_TSM 1
119 #endif
120 #endif
122 /* Whether to use HIToolbar. */
123 #ifndef USE_MAC_TOOLBAR
124 #if USE_CG_DRAWING && MAC_OS_X_VERSION_MAX_ALLOWED >= 1030 && MAC_OS_X_VERSION_MIN_REQUIRED != 1020
125 #define USE_MAC_TOOLBAR 1
126 #endif
127 #endif
129 typedef WindowRef Window;
130 typedef GWorldPtr Pixmap;
132 #define Cursor ThemeCursor
133 #define No_Cursor (-1)
135 #define FACE_DEFAULT (~0)
137 #if !TARGET_API_MAC_CARBON
138 #define GetPixDepth(pmh) ((*(pmh))->pixelSize)
139 #endif
142 /* Emulate XCharStruct. */
143 /* If the sum of ascent and descent is negative, that means some
144 special status specified by enum pcm_status. */
145 typedef struct _XCharStruct
147 short lbearing; /* origin to left edge of raster */
148 short rbearing; /* origin to right edge of raster */
149 short width; /* advance to next char's origin */
150 short ascent; /* baseline to top edge of raster */
151 short descent; /* baseline to bottom edge of raster */
152 #if 0
153 unsigned short attributes; /* per char flags (not predefined) */
154 #endif
155 } XCharStruct;
157 enum pcm_status
159 PCM_VALID = 0, /* pcm data is valid */
160 PCM_INVALID = -1, /* pcm data is invalid */
163 #define STORE_XCHARSTRUCT(xcs, w, bds) \
164 ((xcs).width = (w), \
165 (xcs).lbearing = (bds).left, \
166 (xcs).rbearing = (bds).right, \
167 (xcs).ascent = -(bds).top, \
168 (xcs).descent = (bds).bottom)
170 struct MacFontStruct {
171 char *full_name;
173 short mac_fontnum; /* font number of font used in this window */
174 int mac_fontsize; /* size of font */
175 short mac_fontface; /* plain, bold, italics, etc. */
176 #if TARGET_API_MAC_CARBON
177 int mac_scriptcode; /* Mac OS script code for font used */
178 #else
179 short mac_scriptcode; /* Mac OS script code for font used */
180 #endif
181 #if USE_ATSUI
182 ATSUStyle mac_style; /* NULL if QuickDraw Text is used */
183 #if USE_CG_TEXT_DRAWING
184 CGFontRef cg_font; /* NULL if ATSUI text drawing is used */
185 CGGlyph *cg_glyphs; /* Likewise */
186 #endif
187 #endif
189 /* from Xlib.h */
190 #if 0
191 XExtData *ext_data; /* hook for extension to hang data */
192 Font fid; /* Font id for this font */
193 unsigned direction; /* hint about the direction font is painted */
194 #endif /* 0 */
195 unsigned min_char_or_byte2;/* first character */
196 unsigned max_char_or_byte2;/* last character */
197 unsigned min_byte1; /* first row that exists */
198 unsigned max_byte1; /* last row that exists */
199 #if 0
200 Bool all_chars_exist; /* flag if all characters have nonzero size */
201 unsigned default_char; /* char to print for undefined character */
202 int n_properties; /* how many properties there are */
203 XFontProp *properties; /* pointer to array of additional properties */
204 #endif /* 0 */
205 XCharStruct min_bounds; /* minimum bounds over all existing char */
206 XCharStruct max_bounds; /* maximum bounds over all existing char */
207 union {
208 XCharStruct *per_char; /* first_char to last_char information */
209 XCharStruct **rows; /* first row to last row information */
210 } bounds;
211 int ascent; /* logical extent above baseline for spacing */
212 int descent; /* logical decent below baseline for spacing */
215 typedef struct MacFontStruct MacFontStruct;
216 typedef struct MacFontStruct XFontStruct;
218 /* Structure borrowed from Xlib.h to represent two-byte characters. */
220 typedef struct {
221 unsigned char byte1;
222 unsigned char byte2;
223 } XChar2b;
225 #define STORE_XCHAR2B(chp, b1, b2) \
226 ((chp)->byte1 = (b1), (chp)->byte2 = (b2))
228 #define XCHAR2B_BYTE1(chp) \
229 ((chp)->byte1)
231 #define XCHAR2B_BYTE2(chp) \
232 ((chp)->byte2)
235 /* Emulate X GC's by keeping color and font info in a structure. */
236 typedef struct _XGCValues
238 unsigned long foreground;
239 unsigned long background;
240 XFontStruct *font;
241 } XGCValues;
243 typedef struct _XGC
245 /* Original value. */
246 XGCValues xgcv;
248 /* Cached data members follow. */
250 /* QuickDraw foreground color. */
251 RGBColor fore_color;
253 /* QuickDraw background color. */
254 RGBColor back_color;
256 #if USE_CG_DRAWING && MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
257 /* Quartz 2D foreground color. */
258 CGColorRef cg_fore_color;
260 /* Quartz 2D background color. */
261 CGColorRef cg_back_color;
262 #endif
264 #define MAX_CLIP_RECTS 2
265 /* Number of clipping rectangles. */
266 int n_clip_rects;
268 /* QuickDraw clipping region. Ignored if n_clip_rects == 0. */
269 RgnHandle clip_region;
271 #if defined (MAC_OSX) && (USE_ATSUI || USE_CG_DRAWING)
272 /* Clipping rectangles used in Quartz 2D drawing. The y-coordinate
273 is in QuickDraw's. */
274 CGRect clip_rects[MAX_CLIP_RECTS];
275 #endif
276 } *GC;
278 #define GCForeground (1L<<2)
279 #define GCBackground (1L<<3)
280 #define GCFont (1L<<14)
281 #define GCGraphicsExposures 0
283 /* Bit Gravity */
285 #define ForgetGravity 0
286 #define NorthWestGravity 1
287 #define NorthGravity 2
288 #define NorthEastGravity 3
289 #define WestGravity 4
290 #define CenterGravity 5
291 #define EastGravity 6
292 #define SouthWestGravity 7
293 #define SouthGravity 8
294 #define SouthEastGravity 9
295 #define StaticGravity 10
297 #define NoValue 0x0000
298 #define XValue 0x0001
299 #define YValue 0x0002
300 #define WidthValue 0x0004
301 #define HeightValue 0x0008
302 #define AllValues 0x000F
303 #define XNegative 0x0010
304 #define YNegative 0x0020
306 typedef struct {
307 long flags; /* marks which fields in this structure are defined */
308 #if 0
309 int x, y; /* obsolete for new window mgrs, but clients */
310 int width, height; /* should set so old wm's don't mess up */
311 #endif
312 int min_width, min_height;
313 #if 0
314 int max_width, max_height;
315 #endif
316 int width_inc, height_inc;
317 #if 0
318 struct {
319 int x; /* numerator */
320 int y; /* denominator */
321 } min_aspect, max_aspect;
322 #endif
323 int base_width, base_height; /* added by ICCCM version 1 */
324 #if 0
325 int win_gravity; /* added by ICCCM version 1 */
326 #endif
327 } XSizeHints;
329 #define USPosition (1L << 0) /* user specified x, y */
330 #define USSize (1L << 1) /* user specified width, height */
332 #define PPosition (1L << 2) /* program specified position */
333 #define PSize (1L << 3) /* program specified size */
334 #define PMinSize (1L << 4) /* program specified minimum size */
335 #define PMaxSize (1L << 5) /* program specified maximum size */
336 #define PResizeInc (1L << 6) /* program specified resize increments */
337 #define PAspect (1L << 7) /* program specified min and max aspect ratios */
338 #define PBaseSize (1L << 8) /* program specified base for incrementing */
339 #define PWinGravity (1L << 9) /* program specified window gravity */
341 typedef struct {
342 int x, y;
343 unsigned width, height;
344 } XRectangle;
346 #define NativeRectangle Rect
348 #define CONVERT_TO_XRECT(xr,nr) \
349 ((xr).x = (nr).left, \
350 (xr).y = (nr).top, \
351 (xr).width = ((nr).right - (nr).left), \
352 (xr).height = ((nr).bottom - (nr).top))
354 #define CONVERT_FROM_XRECT(xr,nr) \
355 ((nr).left = (xr).x, \
356 (nr).top = (xr).y, \
357 (nr).right = ((xr).x + (xr).width), \
358 (nr).bottom = ((xr).y + (xr).height))
360 #define STORE_NATIVE_RECT(nr,x,y,width,height) \
361 ((nr).left = (x), \
362 (nr).top = (y), \
363 (nr).right = ((nr).left + (width)), \
364 (nr).bottom = ((nr).top + (height)))
366 #endif /* EMACS_MACGUI_H */
368 /* arch-tag: 5a0da49a-35e2-418b-a58c-8a55778ae849
369 (do not change this comment) */