]> code.delx.au - gnu-emacs/blob - src/macgui.h
Update years in copyright notice; nfc.
[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 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 typedef WindowPtr Window;
83 typedef GWorldPtr Pixmap;
84
85 #define Cursor ThemeCursor
86 #define No_Cursor (-1)
87
88 #define FACE_DEFAULT (~0)
89
90
91 /* Emulate XCharStruct. */
92 typedef struct _XCharStruct
93 {
94 int rbearing;
95 int lbearing;
96 int width;
97 int ascent;
98 int descent;
99 } XCharStruct;
100
101 #define STORE_XCHARSTRUCT(xcs, w, bds) \
102 ((xcs).width = (w), \
103 (xcs).lbearing = (bds).left, \
104 (xcs).rbearing = (bds).right, \
105 (xcs).ascent = -(bds).top, \
106 (xcs).descent = (bds).bottom)
107
108 struct MacFontStruct {
109 char *full_name;
110
111 short mac_fontnum; /* font number of font used in this window */
112 int mac_fontsize; /* size of font */
113 short mac_fontface; /* plain, bold, italics, etc. */
114 #if TARGET_API_MAC_CARBON
115 int mac_scriptcode; /* Mac OS script code for font used */
116 #else
117 short mac_scriptcode; /* Mac OS script code for font used */
118 #endif
119
120 #if 0
121 SInt16 mFontNum; /* font number of font used in this window */
122 short mScriptCode; /* Mac OS script code for font used */
123 int mFontSize; /* size of font */
124 Style mFontFace; /* plain, bold, italics, etc. */
125 int mHeight; /* height of one line of text in pixels */
126 int mWidth; /* width of one character in pixels */
127 int mAscent;
128 int mDescent;
129 int mLeading;
130 char mTwoByte; /* true for two-byte font */
131 #endif /* 0 */
132
133 /* from Xlib.h */
134 #if 0
135 XExtData *ext_data; /* hook for extension to hang data */
136 Font fid; /* Font id for this font */
137 unsigned direction; /* hint about the direction font is painted */
138 #endif /* 0 */
139 unsigned min_char_or_byte2;/* first character */
140 unsigned max_char_or_byte2;/* last character */
141 unsigned min_byte1; /* first row that exists */
142 unsigned max_byte1; /* last row that exists */
143 #if 0
144 Bool all_chars_exist; /* flag if all characters have nonzero size */
145 unsigned default_char; /* char to print for undefined character */
146 int n_properties; /* how many properties there are */
147 XFontProp *properties; /* pointer to array of additional properties */
148 #endif /* 0 */
149 XCharStruct min_bounds; /* minimum bounds over all existing char */
150 XCharStruct max_bounds; /* maximum bounds over all existing char */
151 XCharStruct *per_char; /* first_char to last_char information */
152 int ascent; /* logical extent above baseline for spacing */
153 int descent; /* logical decent below baseline for spacing */
154 };
155
156 typedef struct MacFontStruct MacFontStruct;
157 typedef struct MacFontStruct XFontStruct;
158
159 /* Structure borrowed from Xlib.h to represent two-byte characters. */
160
161 typedef struct {
162 unsigned char byte1;
163 unsigned char byte2;
164 } XChar2b;
165
166 #define STORE_XCHAR2B(chp, b1, b2) \
167 ((chp)->byte1 = (b1), (chp)->byte2 = (b2))
168
169 #define XCHAR2B_BYTE1(chp) \
170 ((chp)->byte1)
171
172 #define XCHAR2B_BYTE2(chp) \
173 ((chp)->byte2)
174
175
176 /* Emulate X GC's by keeping color and font info in a structure. */
177 typedef struct _XGCValues
178 {
179 unsigned long foreground;
180 unsigned long background;
181 XFontStruct *font;
182 } XGCValues;
183
184 typedef struct _XGC
185 {
186 /* Original value. */
187 XGCValues xgcv;
188
189 /* Cached data members follow. */
190
191 /* QuickDraw foreground color. */
192 RGBColor fore_color;
193
194 /* QuickDraw background color. */
195 RGBColor back_color;
196 } *GC;
197
198 #define GCForeground (1L<<2)
199 #define GCBackground (1L<<3)
200 #define GCFont (1L<<14)
201 #define GCGraphicsExposures 0
202
203 /* Bit Gravity */
204
205 #define ForgetGravity 0
206 #define NorthWestGravity 1
207 #define NorthGravity 2
208 #define NorthEastGravity 3
209 #define WestGravity 4
210 #define CenterGravity 5
211 #define EastGravity 6
212 #define SouthWestGravity 7
213 #define SouthGravity 8
214 #define SouthEastGravity 9
215 #define StaticGravity 10
216
217 #define NoValue 0x0000
218 #define XValue 0x0001
219 #define YValue 0x0002
220 #define WidthValue 0x0004
221 #define HeightValue 0x0008
222 #define AllValues 0x000F
223 #define XNegative 0x0010
224 #define YNegative 0x0020
225
226 typedef struct {
227 long flags; /* marks which fields in this structure are defined */
228 #if 0
229 int x, y; /* obsolete for new window mgrs, but clients */
230 int width, height; /* should set so old wm's don't mess up */
231 #endif
232 int min_width, min_height;
233 #if 0
234 int max_width, max_height;
235 #endif
236 int width_inc, height_inc;
237 #if 0
238 struct {
239 int x; /* numerator */
240 int y; /* denominator */
241 } min_aspect, max_aspect;
242 #endif
243 int base_width, base_height; /* added by ICCCM version 1 */
244 #if 0
245 int win_gravity; /* added by ICCCM version 1 */
246 #endif
247 } XSizeHints;
248
249 #define USPosition (1L << 0) /* user specified x, y */
250 #define USSize (1L << 1) /* user specified width, height */
251
252 #define PPosition (1L << 2) /* program specified position */
253 #define PSize (1L << 3) /* program specified size */
254 #define PMinSize (1L << 4) /* program specified minimum size */
255 #define PMaxSize (1L << 5) /* program specified maximum size */
256 #define PResizeInc (1L << 6) /* program specified resize increments */
257 #define PAspect (1L << 7) /* program specified min and max aspect ratios */
258 #define PBaseSize (1L << 8) /* program specified base for incrementing */
259 #define PWinGravity (1L << 9) /* program specified window gravity */
260
261 typedef struct {
262 int x, y;
263 unsigned width, height;
264 } XRectangle;
265
266 #define NativeRectangle Rect
267
268 #define CONVERT_TO_XRECT(xr,nr) \
269 ((xr).x = (nr).left, \
270 (xr).y = (nr).top, \
271 (xr).width = ((nr).right - (nr).left), \
272 (xr).height = ((nr).bottom - (nr).top))
273
274 #define CONVERT_FROM_XRECT(xr,nr) \
275 ((nr).left = (xr).x, \
276 (nr).top = (xr).y, \
277 (nr).right = ((xr).x + (xr).width), \
278 (nr).bottom = ((xr).y + (xr).height))
279
280 #define STORE_NATIVE_RECT(nr,x,y,width,height) \
281 ((nr).left = (x), \
282 (nr).top = (y), \
283 (nr).right = ((nr).left + (width)), \
284 (nr).bottom = ((nr).top + (height)))
285
286 #endif /* EMACS_MACGUI_H */
287
288 /* arch-tag: 5a0da49a-35e2-418b-a58c-8a55778ae849
289 (do not change this comment) */