]> code.delx.au - gnu-emacs/blob - src/macgui.h
(x_set_name_internal): Set icon to `text', derived from name, when
[gnu-emacs] / src / macgui.h
1 /* Definitions and headers for communication on the Mac OS.
2 Copyright (C) 2000, 2001, 2002, 2003, 2004,
3 2005, 2006 Free Software Foundation, Inc.
4
5 This file is part of GNU Emacs.
6
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 2, or (at your option)
10 any later version.
11
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.
16
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. */
21
22 /* Contributed by Andrew Choi (akochoi@mac.com). */
23
24 #ifndef EMACS_MACGUI_H
25 #define EMACS_MACGUI_H
26
27 typedef int Display; /* fix later */
28
29 typedef Lisp_Object XrmDatabase;
30
31 typedef unsigned long Time;
32
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 WindowPtr */
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 */
81
82 /* Whether to use ATSUI (Apple Type Services for Unicode Imaging) for
83 text drawing. */
84 #ifndef USE_ATSUI
85 #ifdef MAC_OSX
86 #define USE_ATSUI 1
87 #endif
88 #endif
89
90 /* Whether to use low-level Quartz 2D (aka Core Graphics) text drawing
91 in preference to ATSUI for ASCII and Latin-1 characters. */
92 #ifndef USE_CG_TEXT_DRAWING
93 #if USE_ATSUI && MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
94 #define USE_CG_TEXT_DRAWING 1
95 #endif
96 #endif
97
98 /* Whether to use Quartz 2D routines for drawing operations other than
99 texts. */
100 #ifndef USE_CG_DRAWING
101 #if USE_ATSUI && MAC_OS_X_VERSION_MAX_ALLOWED >= 1020
102 #define USE_CG_DRAWING 1
103 #endif
104 #endif
105
106 /* Whether to use the standard Font Panel floating dialog. */
107 #ifndef USE_MAC_FONT_PANEL
108 #if USE_ATSUI && MAC_OS_X_VERSION_MAX_ALLOWED >= 1020
109 #define USE_MAC_FONT_PANEL 1
110 #endif
111 #endif
112
113 typedef WindowPtr Window;
114 typedef GWorldPtr Pixmap;
115
116 #define Cursor ThemeCursor
117 #define No_Cursor (-1)
118
119 #define FACE_DEFAULT (~0)
120
121 #if !TARGET_API_MAC_CARBON
122 #define GetPixDepth(pmh) ((*(pmh))->pixelSize)
123 #endif
124
125
126 /* Emulate XCharStruct. */
127 /* If the sum of ascent and descent is negative, that means some
128 special status specified by enum pcm_status. */
129 typedef struct _XCharStruct
130 {
131 short lbearing; /* origin to left edge of raster */
132 short rbearing; /* origin to right edge of raster */
133 short width; /* advance to next char's origin */
134 short ascent; /* baseline to top edge of raster */
135 short descent; /* baseline to bottom edge of raster */
136 #if 0
137 unsigned short attributes; /* per char flags (not predefined) */
138 #endif
139 } XCharStruct;
140
141 enum pcm_status
142 {
143 PCM_VALID = 0, /* pcm data is valid */
144 PCM_INVALID = -1, /* pcm data is invalid */
145 };
146
147 #define STORE_XCHARSTRUCT(xcs, w, bds) \
148 ((xcs).width = (w), \
149 (xcs).lbearing = (bds).left, \
150 (xcs).rbearing = (bds).right, \
151 (xcs).ascent = -(bds).top, \
152 (xcs).descent = (bds).bottom)
153
154 struct MacFontStruct {
155 char *full_name;
156
157 short mac_fontnum; /* font number of font used in this window */
158 int mac_fontsize; /* size of font */
159 short mac_fontface; /* plain, bold, italics, etc. */
160 #if TARGET_API_MAC_CARBON
161 int mac_scriptcode; /* Mac OS script code for font used */
162 #else
163 short mac_scriptcode; /* Mac OS script code for font used */
164 #endif
165 #if USE_ATSUI
166 ATSUStyle mac_style; /* NULL if QuickDraw Text is used */
167 #if USE_CG_TEXT_DRAWING
168 CGFontRef cg_font; /* NULL if ATSUI text drawing is used */
169 CGGlyph *cg_glyphs; /* Likewise */
170 #endif
171 #endif
172
173 /* from Xlib.h */
174 #if 0
175 XExtData *ext_data; /* hook for extension to hang data */
176 Font fid; /* Font id for this font */
177 unsigned direction; /* hint about the direction font is painted */
178 #endif /* 0 */
179 unsigned min_char_or_byte2;/* first character */
180 unsigned max_char_or_byte2;/* last character */
181 unsigned min_byte1; /* first row that exists */
182 unsigned max_byte1; /* last row that exists */
183 #if 0
184 Bool all_chars_exist; /* flag if all characters have nonzero size */
185 unsigned default_char; /* char to print for undefined character */
186 int n_properties; /* how many properties there are */
187 XFontProp *properties; /* pointer to array of additional properties */
188 #endif /* 0 */
189 XCharStruct min_bounds; /* minimum bounds over all existing char */
190 XCharStruct max_bounds; /* maximum bounds over all existing char */
191 union {
192 XCharStruct *per_char; /* first_char to last_char information */
193 XCharStruct **rows; /* first row to last row information */
194 } bounds;
195 int ascent; /* logical extent above baseline for spacing */
196 int descent; /* logical decent below baseline for spacing */
197 };
198
199 typedef struct MacFontStruct MacFontStruct;
200 typedef struct MacFontStruct XFontStruct;
201
202 /* Structure borrowed from Xlib.h to represent two-byte characters. */
203
204 typedef struct {
205 unsigned char byte1;
206 unsigned char byte2;
207 } XChar2b;
208
209 #define STORE_XCHAR2B(chp, b1, b2) \
210 ((chp)->byte1 = (b1), (chp)->byte2 = (b2))
211
212 #define XCHAR2B_BYTE1(chp) \
213 ((chp)->byte1)
214
215 #define XCHAR2B_BYTE2(chp) \
216 ((chp)->byte2)
217
218
219 /* Emulate X GC's by keeping color and font info in a structure. */
220 typedef struct _XGCValues
221 {
222 unsigned long foreground;
223 unsigned long background;
224 XFontStruct *font;
225 } XGCValues;
226
227 typedef struct _XGC
228 {
229 /* Original value. */
230 XGCValues xgcv;
231
232 /* Cached data members follow. */
233
234 /* QuickDraw foreground color. */
235 RGBColor fore_color;
236
237 /* QuickDraw background color. */
238 RGBColor back_color;
239
240 #define MAX_CLIP_RECTS 2
241 /* Number of clipping rectangles. */
242 int n_clip_rects;
243
244 /* QuickDraw clipping region. Ignored if n_clip_rects == 0. */
245 RgnHandle clip_region;
246
247 #if defined (MAC_OSX) && (USE_ATSUI || USE_CG_DRAWING)
248 /* Clipping rectangles used in Quartz 2D drawing. The y-coordinate
249 is in QuickDraw's. */
250 CGRect clip_rects[MAX_CLIP_RECTS];
251 #endif
252 } *GC;
253
254 #define GCForeground (1L<<2)
255 #define GCBackground (1L<<3)
256 #define GCFont (1L<<14)
257 #define GCGraphicsExposures 0
258
259 /* Bit Gravity */
260
261 #define ForgetGravity 0
262 #define NorthWestGravity 1
263 #define NorthGravity 2
264 #define NorthEastGravity 3
265 #define WestGravity 4
266 #define CenterGravity 5
267 #define EastGravity 6
268 #define SouthWestGravity 7
269 #define SouthGravity 8
270 #define SouthEastGravity 9
271 #define StaticGravity 10
272
273 #define NoValue 0x0000
274 #define XValue 0x0001
275 #define YValue 0x0002
276 #define WidthValue 0x0004
277 #define HeightValue 0x0008
278 #define AllValues 0x000F
279 #define XNegative 0x0010
280 #define YNegative 0x0020
281
282 typedef struct {
283 long flags; /* marks which fields in this structure are defined */
284 #if 0
285 int x, y; /* obsolete for new window mgrs, but clients */
286 int width, height; /* should set so old wm's don't mess up */
287 #endif
288 int min_width, min_height;
289 #if 0
290 int max_width, max_height;
291 #endif
292 int width_inc, height_inc;
293 #if 0
294 struct {
295 int x; /* numerator */
296 int y; /* denominator */
297 } min_aspect, max_aspect;
298 #endif
299 int base_width, base_height; /* added by ICCCM version 1 */
300 #if 0
301 int win_gravity; /* added by ICCCM version 1 */
302 #endif
303 } XSizeHints;
304
305 #define USPosition (1L << 0) /* user specified x, y */
306 #define USSize (1L << 1) /* user specified width, height */
307
308 #define PPosition (1L << 2) /* program specified position */
309 #define PSize (1L << 3) /* program specified size */
310 #define PMinSize (1L << 4) /* program specified minimum size */
311 #define PMaxSize (1L << 5) /* program specified maximum size */
312 #define PResizeInc (1L << 6) /* program specified resize increments */
313 #define PAspect (1L << 7) /* program specified min and max aspect ratios */
314 #define PBaseSize (1L << 8) /* program specified base for incrementing */
315 #define PWinGravity (1L << 9) /* program specified window gravity */
316
317 typedef struct {
318 int x, y;
319 unsigned width, height;
320 } XRectangle;
321
322 #define NativeRectangle Rect
323
324 #define CONVERT_TO_XRECT(xr,nr) \
325 ((xr).x = (nr).left, \
326 (xr).y = (nr).top, \
327 (xr).width = ((nr).right - (nr).left), \
328 (xr).height = ((nr).bottom - (nr).top))
329
330 #define CONVERT_FROM_XRECT(xr,nr) \
331 ((nr).left = (xr).x, \
332 (nr).top = (xr).y, \
333 (nr).right = ((xr).x + (xr).width), \
334 (nr).bottom = ((xr).y + (xr).height))
335
336 #define STORE_NATIVE_RECT(nr,x,y,width,height) \
337 ((nr).left = (x), \
338 (nr).top = (y), \
339 (nr).right = ((nr).left + (width)), \
340 (nr).bottom = ((nr).top + (height)))
341
342 #endif /* EMACS_MACGUI_H */
343
344 /* arch-tag: 5a0da49a-35e2-418b-a58c-8a55778ae849
345 (do not change this comment) */