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)
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
;
36 #if ! HAVE_MKTIME || BROKEN_MKTIME
43 /* Macros max and min defined in lisp.h conflict with those in
44 precompiled header Carbon.h. */
48 #include <Carbon/Carbon.h>
49 #if ! HAVE_MKTIME || BROKEN_MKTIME
51 #define mktime emacs_mktime
54 #define free unexec_free
56 #define malloc unexec_malloc
58 #define realloc unexec_realloc
60 #define min(a, b) ((a) < (b) ? (a) : (b))
62 #define max(a, b) ((a) > (b) ? (a) : (b))
64 #define init_process emacs_init_process
66 #else /* not MAC_OSX */
70 #endif /* not MAC_OSX */
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 */
80 #endif /* not HAVE_CARBON */
82 /* Whether to use ATSUI (Apple Type Services for Unicode Imaging) for
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
98 /* Whether to use Quartz 2D routines for drawing operations other than
100 #ifndef USE_CG_DRAWING
101 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020
102 #define USE_CG_DRAWING 1
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
113 /* Whether to use Text Services Manager. */
115 #if TARGET_API_MAC_CARBON
116 #define USE_MAC_TSM 1
120 /* Whether to use HIToolbar. */
121 #ifndef USE_MAC_TOOLBAR
122 #if USE_CG_DRAWING && MAC_OS_X_VERSION_MAX_ALLOWED >= 1030 && MAC_OS_X_VERSION_MIN_REQUIRED != 1020
123 #define USE_MAC_TOOLBAR 1
127 typedef WindowRef Window
;
128 #if TARGET_API_MAC_CARBON
129 typedef ScrapRef Selection
;
131 typedef int Selection
;
133 #define mac_set_window_title SetWindowTitleWithCFString
134 #define mac_set_window_modified SetWindowModified
135 #define mac_is_window_visible IsWindowVisible
136 #define mac_is_window_collapsed IsWindowCollapsed
137 #define mac_bring_window_to_front BringToFront
138 #define mac_send_window_behind SendBehind
139 #define mac_hide_window HideWindow
140 #define mac_show_window ShowWindow
141 #define mac_collapse_window CollapseWindow
142 #define mac_front_non_floating_window FrontNonFloatingWindow
143 #define mac_active_non_floating_window ActiveNonFloatingWindow
144 #define mac_activate_window ActivateWindow
145 #define mac_move_window_structure MoveWindowStructure
146 #define mac_move_window MoveWindow
147 #define mac_size_window SizeWindow
148 #define mac_get_global_mouse GetGlobalMouse
149 #define mac_is_window_toolbar_visible IsWindowToolbarVisible
150 typedef GWorldPtr Pixmap
;
152 #define Cursor ThemeCursor
153 #define No_Cursor (-1)
155 #define FACE_DEFAULT (~0)
157 #if !TARGET_API_MAC_CARBON
158 #define GetPixDepth(pmh) ((*(pmh))->pixelSize)
162 /* Emulate XCharStruct. */
163 /* If the sum of ascent and descent is negative, that means some
164 special status specified by enum pcm_status. */
165 typedef struct _XCharStruct
167 short lbearing
; /* origin to left edge of raster */
168 short rbearing
; /* origin to right edge of raster */
169 short width
; /* advance to next char's origin */
170 short ascent
; /* baseline to top edge of raster */
171 short descent
; /* baseline to bottom edge of raster */
173 unsigned short attributes
; /* per char flags (not predefined) */
179 PCM_VALID
= 0, /* pcm data is valid */
180 PCM_INVALID
= -1, /* pcm data is invalid */
183 #define STORE_XCHARSTRUCT(xcs, w, bds) \
184 ((xcs).width = (w), \
185 (xcs).lbearing = (bds).left, \
186 (xcs).rbearing = (bds).right, \
187 (xcs).ascent = -(bds).top, \
188 (xcs).descent = (bds).bottom)
190 struct MacFontStruct
{
193 short mac_fontnum
; /* font number of font used in this window */
194 int mac_fontsize
; /* size of font */
195 short mac_fontface
; /* plain, bold, italics, etc. */
196 #if TARGET_API_MAC_CARBON
197 int mac_scriptcode
; /* Mac OS script code for font used */
199 short mac_scriptcode
; /* Mac OS script code for font used */
202 ATSUStyle mac_style
; /* NULL if QuickDraw Text is used */
203 #if USE_CG_TEXT_DRAWING
204 CGFontRef cg_font
; /* NULL if ATSUI text drawing is used */
205 CGGlyph
*cg_glyphs
; /* Likewise */
211 XExtData
*ext_data
; /* hook for extension to hang data */
212 Font fid
; /* Font id for this font */
213 unsigned direction
; /* hint about the direction font is painted */
215 unsigned min_char_or_byte2
;/* first character */
216 unsigned max_char_or_byte2
;/* last character */
217 unsigned min_byte1
; /* first row that exists */
218 unsigned max_byte1
; /* last row that exists */
220 Bool all_chars_exist
; /* flag if all characters have nonzero size */
221 unsigned default_char
; /* char to print for undefined character */
222 int n_properties
; /* how many properties there are */
223 XFontProp
*properties
; /* pointer to array of additional properties */
225 XCharStruct min_bounds
; /* minimum bounds over all existing char */
226 XCharStruct max_bounds
; /* maximum bounds over all existing char */
228 XCharStruct
*per_char
; /* first_char to last_char information */
229 XCharStruct
**rows
; /* first row to last row information */
231 int ascent
; /* logical extent above baseline for spacing */
232 int descent
; /* logical decent below baseline for spacing */
235 typedef struct MacFontStruct MacFontStruct
;
236 typedef struct MacFontStruct XFontStruct
;
238 /* Structure borrowed from Xlib.h to represent two-byte characters. */
245 #define STORE_XCHAR2B(chp, b1, b2) \
246 ((chp)->byte1 = (b1), (chp)->byte2 = (b2))
248 #define XCHAR2B_BYTE1(chp) \
251 #define XCHAR2B_BYTE2(chp) \
255 /* Emulate X GC's by keeping color and font info in a structure. */
256 typedef struct _XGCValues
258 unsigned long foreground
;
259 unsigned long background
;
265 /* Original value. */
268 /* Cached data members follow. */
270 /* QuickDraw foreground color. */
273 /* QuickDraw background color. */
276 #if USE_CG_DRAWING && MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
277 /* Quartz 2D foreground color. */
278 CGColorRef cg_fore_color
;
280 /* Quartz 2D background color. */
281 CGColorRef cg_back_color
;
284 #define MAX_CLIP_RECTS 2
285 /* Number of clipping rectangles. */
288 /* QuickDraw clipping region. Ignored if n_clip_rects == 0. */
289 RgnHandle clip_region
;
291 #if defined (MAC_OSX) && (USE_ATSUI || USE_CG_DRAWING)
292 /* Clipping rectangles used in Quartz 2D drawing. The y-coordinate
293 is in QuickDraw's. */
294 CGRect clip_rects
[MAX_CLIP_RECTS
];
298 #define GCForeground (1L<<2)
299 #define GCBackground (1L<<3)
300 #define GCFont (1L<<14)
301 #define GCGraphicsExposures 0
305 #define ForgetGravity 0
306 #define NorthWestGravity 1
307 #define NorthGravity 2
308 #define NorthEastGravity 3
309 #define WestGravity 4
310 #define CenterGravity 5
311 #define EastGravity 6
312 #define SouthWestGravity 7
313 #define SouthGravity 8
314 #define SouthEastGravity 9
315 #define StaticGravity 10
317 #define NoValue 0x0000
318 #define XValue 0x0001
319 #define YValue 0x0002
320 #define WidthValue 0x0004
321 #define HeightValue 0x0008
322 #define AllValues 0x000F
323 #define XNegative 0x0010
324 #define YNegative 0x0020
327 long flags
; /* marks which fields in this structure are defined */
329 int x
, y
; /* obsolete for new window mgrs, but clients */
330 int width
, height
; /* should set so old wm's don't mess up */
332 int min_width
, min_height
;
334 int max_width
, max_height
;
336 int width_inc
, height_inc
;
339 int x
; /* numerator */
340 int y
; /* denominator */
341 } min_aspect
, max_aspect
;
343 int base_width
, base_height
; /* added by ICCCM version 1 */
345 int win_gravity
; /* added by ICCCM version 1 */
349 #define USPosition (1L << 0) /* user specified x, y */
350 #define USSize (1L << 1) /* user specified width, height */
352 #define PPosition (1L << 2) /* program specified position */
353 #define PSize (1L << 3) /* program specified size */
354 #define PMinSize (1L << 4) /* program specified minimum size */
355 #define PMaxSize (1L << 5) /* program specified maximum size */
356 #define PResizeInc (1L << 6) /* program specified resize increments */
357 #define PAspect (1L << 7) /* program specified min and max aspect ratios */
358 #define PBaseSize (1L << 8) /* program specified base for incrementing */
359 #define PWinGravity (1L << 9) /* program specified window gravity */
363 unsigned width
, height
;
366 #define NativeRectangle Rect
368 #define CONVERT_TO_XRECT(xr,nr) \
369 ((xr).x = (nr).left, \
371 (xr).width = ((nr).right - (nr).left), \
372 (xr).height = ((nr).bottom - (nr).top))
374 #define CONVERT_FROM_XRECT(xr,nr) \
375 ((nr).left = (xr).x, \
377 (nr).right = ((xr).x + (xr).width), \
378 (nr).bottom = ((xr).y + (xr).height))
380 #define STORE_NATIVE_RECT(nr,x,y,width,height) \
383 (nr).right = ((nr).left + (width)), \
384 (nr).bottom = ((nr).top + (height)))
386 /* Definitions copied from lwlib.h */
388 typedef void * XtPointer
;
397 /* This structure is based on the one in ../lwlib/lwlib.h, modified
399 typedef struct _widget_value
404 /* value (meaning depend on widget type) */
406 /* keyboard equivalent. no implications for XtTranslations */
409 /* Help string or nil if none.
410 GC finds this string through the frame's menu_bar_vector
411 or through menu_items. */
413 /* true if enabled */
415 /* true if selected */
417 /* The type of a button. */
418 enum button_type button_type
;
419 /* true if menu title */
422 /* true if was edited (maintained by get_value) */
424 /* true if has changed (maintained by lw library) */
426 /* true if this widget itself has changed,
427 but not counting the other widgets found in the `next' field. */
428 change_type this_one_change
;
430 /* Contents of the sub-widgets, also selected slot for checkbox */
431 struct _widget_value
* contents
;
432 /* data passed to callback */
434 /* next one in the list */
435 struct _widget_value
* next
;
437 /* slot for the toolkit dependent part. Always initialize to NULL. */
439 /* tell us if we should free the toolkit data slot when freeing the
440 widget_value itself. */
441 Boolean free_toolkit_data
;
443 /* we resource the widget_value structures; this points to the next
444 one on the free list if this one has been deallocated.
446 struct _widget_value
*free_list
;
454 #define EXTRA_STACK_ALLOC (256 * 1024)
456 #define ARGV_STRING_LIST_ID 129
457 #define RAM_TOO_LARGE_ALERT_ID 129
458 #define ABOUT_ALERT_ID 128
461 #define DIALOG_LEFT_MARGIN (112)
462 #define DIALOG_TOP_MARGIN (24)
463 #define DIALOG_RIGHT_MARGIN (24)
464 #define DIALOG_BOTTOM_MARGIN (20)
465 #define DIALOG_MIN_INNER_WIDTH (338)
466 #define DIALOG_MAX_INNER_WIDTH (564)
467 #define DIALOG_BUTTON_BUTTON_HORIZONTAL_SPACE (12)
468 #define DIALOG_BUTTON_BUTTON_VERTICAL_SPACE (12)
469 #define DIALOG_BUTTON_MIN_WIDTH (68)
470 #define DIALOG_TEXT_MIN_HEIGHT (50)
471 #define DIALOG_TEXT_BUTTONS_VERTICAL_SPACE (10)
472 #define DIALOG_ICON_WIDTH (64)
473 #define DIALOG_ICON_HEIGHT (64)
474 #define DIALOG_ICON_LEFT_MARGIN (24)
475 #define DIALOG_ICON_TOP_MARGIN (15)
477 #endif /* EMACS_MACGUI_H */
479 /* arch-tag: 5a0da49a-35e2-418b-a58c-8a55778ae849
480 (do not change this comment) */