* s/darwin.h (SYSTEM_PURESIZE_EXTRA): Define here.
[bpt/emacs.git] / src / macterm.h
index 2f2ae26..fe61674 100644 (file)
@@ -1,6 +1,6 @@
 /* Display module for Mac OS.
    Copyright (C) 2000, 2001, 2002, 2003, 2004,
-                 2005 Free Software Foundation, Inc.
+                 2005, 2006, 2007 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -44,8 +44,6 @@ Boston, MA 02110-1301, USA.  */
 #define FONT_BASE(f)    ((f)->ascent)
 #define FONT_DESCENT(f) ((f)->descent)
 
-#define FONT_MAX_WIDTH(f) FONT_WIDTH(f)  /* fix later */
-
 /* Structure recording bitmaps and reference count.
    If REFCOUNT is 0 then this record is free to be reused.  */
 
@@ -66,6 +64,9 @@ struct mac_display_info
   /* Chain of all mac_display_info structures.  */
   struct mac_display_info *next;
 
+  /* The generic display parameters corresponding to this X display. */
+  struct terminal *terminal;
+
   /* This is a cons cell of the form (NAME . FONT-LIST-CACHE).
      The same cons cell also appears in x_display_name_list.  */
   Lisp_Object name_list_element;
@@ -206,10 +207,6 @@ extern struct mac_display_info one_mac_display_info;
    FONT-LIST-CACHE records previous values returned by x-list-fonts.  */
 extern Lisp_Object x_display_name_list;
 
-/* A flag to control how to display unibyte 8-bit character.  */
-extern int unibyte_display_via_language_environment;
-
-extern struct x_display_info *x_display_info_for_display P_ ((Display *));
 extern struct x_display_info *x_display_info_for_name P_ ((Lisp_Object));
 
 extern struct mac_display_info *mac_term_init P_ ((Lisp_Object, char *, char *));
@@ -229,7 +226,8 @@ struct x_output
 };
 
 /* The collection of data describing a window on the Mac.  */
-struct mac_output {
+struct mac_output
+{
   /* Placeholder for things accessed through output_data.x.  Must
      appear first.  */
   struct x_output x_compatible;
@@ -319,9 +317,6 @@ struct mac_output {
   /* Nonzero means tried already to make this frame visible.  */
   char asked_for_visible;
 
-  /* Nonzero means menubar is currently active.  */
-  char menubar_active;
-
   /* Relief GCs, colors etc.  */
   struct relief
   {
@@ -335,8 +330,16 @@ struct mac_output {
      They are changed only when a different background is involved.  */
   unsigned long relief_background;
 
+  /* Width of the internal border.  */
+  int internal_border_width;
+
   /* Hints for the size and the position of a window.  */
   XSizeHints *size_hints;
+
+#if USE_CG_DRAWING
+  /* Quartz 2D graphics context.  */
+  CGContextRef cg_context;
+#endif
 };
 
 typedef struct mac_output mac_output;
@@ -403,8 +406,8 @@ struct scroll_bar {
   /* The next and previous in the chain of scroll bars in this frame.  */
   Lisp_Object next, prev;
 
-  /* The Mac control handle of this scroll bar.  Since this is a full
-     32-bit quantity, we store it split into two 32-bit values.  */
+  /* The Mac control handle of this scroll bar.  Since this is a
+     pointer value, we store it split into two Lisp integers.  */
   Lisp_Object control_handle_low, control_handle_high;
 
   /* The position and size of the scroll bar in pixels, relative to the
@@ -426,7 +429,9 @@ struct scroll_bar {
 
   /* If the scroll bar handle is currently being dragged by the user,
      this is the number of pixels from the top of the handle to the
-     place where the user grabbed it.  If the handle isn't currently
+     place where the user grabbed it.  If the handle is pressed but
+     not dragged yet, this is a negative integer whose absolute value
+     is the number of pixels plus 1.  If the handle isn't currently
      being dragged, this is Qnil.  */
   Lisp_Object dragging;
 
@@ -434,6 +439,9 @@ struct scroll_bar {
   /* The position and size of the scroll bar handle track area in
      pixels, relative to the frame.  */
   Lisp_Object track_top, track_height;
+
+  /* Minimum length of the scroll bar handle, in pixels.  */
+  Lisp_Object min_handle;
 #endif
 };
 
@@ -447,13 +455,13 @@ struct scroll_bar {
 #define XSCROLL_BAR(vec) ((struct scroll_bar *) XVECTOR (vec))
 
 
-/* Building a 32-bit C integer from two 16-bit lisp integers.  */
+/* Building a C long integer from two lisp integers.  */
 #define SCROLL_BAR_PACK(low, high) (XINT (high) << 16 | XINT (low))
 
-/* Setting two lisp integers to the low and high words of a 32-bit C int.  */
-#define SCROLL_BAR_UNPACK(low, high, int32) \
-  (XSETINT ((low),   (int32)        & 0xffff), \
-   XSETINT ((high), ((int32) >> 16) & 0xffff))
+/* Setting two lisp integers to two parts of a C unsigned long.  */
+#define SCROLL_BAR_UNPACK(low, high, ulong) \
+  (XSETINT ((low),  (ulong) & 0xffff), \
+   XSETINT ((high), (ulong) >> 16))
 
 
 /* Extract the Mac control handle of the scroll bar from a struct
@@ -463,9 +471,9 @@ struct scroll_bar {
                                     (ptr)->control_handle_high))
 
 /* Store a Mac control handle in a struct scroll_bar.  */
-#define SET_SCROLL_BAR_CONTROL_HANDLE(ptr, id) \
+#define SET_SCROLL_BAR_CONTROL_HANDLE(ptr, handle) \
   (SCROLL_BAR_UNPACK ((ptr)->control_handle_low, \
-                      (ptr)->control_handle_high, (int) id))
+                      (ptr)->control_handle_high, (unsigned long) (handle)))
 
 /* Return the inside width of a vertical scroll bar, given the outside
    width.  */
@@ -519,9 +527,65 @@ struct scroll_bar {
    text from glomming up against the scroll bar */
 #define VERTICAL_SCROLL_BAR_WIDTH_TRIM (0)
 
+/* Variations of possible Aqua scroll bar width.  */
+#define MAC_AQUA_VERTICAL_SCROLL_BAR_WIDTH (15)
+#define MAC_AQUA_SMALL_VERTICAL_SCROLL_BAR_WIDTH (11)
+
 /* Size of hourglass controls */
-#define HOURGLASS_WIDTH 16
-#define HOURGLASS_HEIGHT 16
+#define HOURGLASS_WIDTH (16)
+#define HOURGLASS_HEIGHT (16)
+
+/* Some constants that are used locally.  */
+/* Creator code for Emacs on Mac OS.  */
+enum {
+  MAC_EMACS_CREATOR_CODE       = 'EMAx'
+};
+
+/* Apple event descriptor types */
+enum {
+  TYPE_FILE_NAME               = 'fNam'
+};
+
+/* Keywords for Apple event attributes */
+enum {
+  KEY_EMACS_SUSPENSION_ID_ATTR = 'esId' /* typeUInt32 */
+};
+
+/* Carbon event parameter names.  */
+enum {
+  EVENT_PARAM_TEXT_INPUT_SEQUENCE_NUMBER = 'tsSn' /* typeUInt32 */
+};
+
+/* Some constants that are not defined in older versions.  */
+#if MAC_OS_X_VERSION_MAX_ALLOWED < 1030
+/* Keywords for Apple event attributes */
+enum {
+  keyReplyRequestedAttr                = 'repq'
+};
+#endif
+
+#if MAC_OS_X_VERSION_MAX_ALLOWED < 1040
+/* Gestalt selectors */
+enum {
+  gestaltSystemVersionMajor    = 'sys1',
+  gestaltSystemVersionMinor    = 'sys2',
+  gestaltSystemVersionBugFix   = 'sys3'
+};
+#endif
+
+#ifdef MAC_OSX
+#if MAC_OS_X_VERSION_MAX_ALLOWED < 1020
+/* Apple event descriptor types */
+enum {
+  typeUTF8Text                 = 'utf8'
+};
+
+/* Carbon event parameter names */
+enum {
+  kEventParamWindowMouseLocation = 'wmou'
+};
+#endif
+#endif
 
 struct frame;
 struct face;
@@ -541,8 +605,15 @@ extern int XParseGeometry P_ ((char *, int *, int *, unsigned int *,
 /* Defined in macterm.c.  */
 
 extern void x_set_window_size P_ ((struct frame *, int, int, int));
+extern void x_set_mouse_position P_ ((struct frame *, int, int));
+extern void x_set_mouse_pixel_position P_ ((struct frame *, int, int));
 extern void x_make_frame_visible P_ ((struct frame *));
-extern void mac_initialize P_ ((void));
+extern void x_make_frame_invisible P_ ((struct frame *));
+extern void x_iconify_frame P_ ((struct frame *));
+extern void x_free_frame_resources P_ ((struct frame *));
+extern void x_destroy_window P_ ((struct frame *));
+extern void x_wm_set_size_hint P_ ((struct frame *, long, int));
+extern void x_delete_display P_ ((struct x_display_info *));
 extern Pixmap XCreatePixmap P_ ((Display *, WindowPtr, unsigned int,
                                 unsigned int, unsigned int));
 extern Pixmap XCreatePixmapFromBitmapData P_ ((Display *, WindowPtr, char *,
@@ -550,37 +621,69 @@ extern Pixmap XCreatePixmapFromBitmapData P_ ((Display *, WindowPtr, char *,
                                               unsigned long, unsigned long,
                                               unsigned int));
 extern void XFreePixmap P_ ((Display *, Pixmap));
-extern GC XCreateGC P_ ((Display *, Window, unsigned long, XGCValues *));
+extern GC XCreateGC P_ ((Display *, void *, unsigned long, XGCValues *));
+extern void XFreeGC P_ ((Display *, GC));
 extern void XSetForeground P_ ((Display *, GC, unsigned long));
 extern void XSetBackground P_ ((Display *, GC, unsigned long));
 extern void XSetWindowBackground P_ ((Display *, WindowPtr, unsigned long));
-extern void mac_draw_line_to_pixmap P_ ((Display *, Pixmap, GC, int, int,
-                                        int, int));
+extern void XDrawLine P_ ((Display *, Pixmap, GC, int, int, int, int));
 extern void mac_clear_area P_ ((struct frame *, int, int,
                                unsigned int, unsigned int));
 extern void mac_unload_font P_ ((struct mac_display_info *, XFontStruct *));
-extern OSErr install_window_handler P_ ((WindowPtr));
+extern int mac_font_panel_visible_p P_ ((void));
+extern OSStatus mac_show_hide_font_panel P_ ((void));
+extern OSStatus mac_set_font_info_for_selection P_ ((struct frame *, int, int));
+extern OSStatus install_window_handler P_ ((WindowPtr));
 extern void remove_window_handler P_ ((WindowPtr));
-extern Lisp_Object mac_make_lispy_event_code P_ ((int));
+extern OSStatus mac_post_mouse_moved_event P_ ((void));
+#if !TARGET_API_MAC_CARBON
+extern void do_apple_menu P_ ((SInt16));
+#endif
+#if USE_CG_DRAWING
+extern void mac_prepare_for_quickdraw P_ ((struct frame *));
+#endif
+extern int mac_quit_char_key_p P_ ((UInt32, UInt32));
 
 #define FONT_TYPE_FOR_UNIBYTE(font, ch) 0
 #define FONT_TYPE_FOR_MULTIBYTE(font, ch) 0
 
-#define TYPE_FILE_NAME 'fNam'
-
 /* Defined in macselect.c */
 
 extern void x_clear_frame_selections P_ ((struct frame *));
 
+/* Defined in macfns.c */
+
+extern int have_menus_p P_ ((void));
+
+extern void x_real_positions P_ ((struct frame *, int *, int *));
+extern void x_set_menu_bar_lines P_ ((struct frame *, Lisp_Object, Lisp_Object));
+extern int x_pixel_width P_ ((struct frame *));
+extern int x_pixel_height P_ ((struct frame *));
+extern int x_char_width P_ ((struct frame *));
+extern int x_char_height P_ ((struct frame *));
+extern void x_sync P_ ((struct frame *));
+extern void x_set_tool_bar_lines P_ ((struct frame *, Lisp_Object, Lisp_Object));
+extern void mac_update_title_bar P_ ((struct frame *, int));
+extern Lisp_Object x_get_focus_frame P_ ((struct frame *));
+
+/* Defined in macmenu.c */
+
+extern void x_activate_menubar P_ ((struct frame *));
+extern void free_frame_menubar P_ ((struct frame *));
+
 /* Defined in mac.c.  */
 
 extern void mac_clear_font_name_table P_ ((void));
-extern Lisp_Object mac_aedesc_to_lisp P_ ((AEDesc *));
+extern Lisp_Object mac_aedesc_to_lisp P_ ((const AEDesc *));
+extern OSErr mac_ae_put_lisp P_ ((AEDescList *, UInt32, Lisp_Object));
 #if TARGET_API_MAC_CARBON
-extern OSErr create_apple_event_from_event_ref P_ ((EventRef, UInt32,
-                                                   EventParamName *,
-                                                   EventParamType *,
-                                                   AppleEvent *));
+extern OSStatus create_apple_event_from_event_ref P_ ((EventRef, UInt32,
+                                                      const EventParamName *,
+                                                      const EventParamType *,
+                                                      AppleEvent *));
+extern OSErr create_apple_event_from_drag_ref P_ ((DragRef, UInt32,
+                                                  const FlavorType *,
+                                                  AppleEvent *));
 extern CFStringRef cfstring_create_with_utf8_cstring P_ ((const char *));
 extern CFStringRef cfstring_create_with_string P_ ((Lisp_Object));
 extern Lisp_Object cfdata_to_lisp P_ ((CFDataRef));
@@ -591,10 +694,12 @@ extern Lisp_Object cfdate_to_lisp P_ ((CFDateRef));
 extern Lisp_Object cfboolean_to_lisp P_ ((CFBooleanRef));
 extern Lisp_Object cfobject_desc_to_lisp P_ ((CFTypeRef));
 extern Lisp_Object cfproperty_list_to_lisp P_ ((CFPropertyListRef, int, int));
+extern void mac_wakeup_from_rne P_ ((void));
 #endif
-extern void xrm_merge_string_database P_ ((XrmDatabase, char *));
-extern Lisp_Object xrm_get_resource P_ ((XrmDatabase, char *, char *));
-extern XrmDatabase xrm_get_preference_database P_ ((char *));
+extern void xrm_merge_string_database P_ ((XrmDatabase, const char *));
+extern Lisp_Object xrm_get_resource P_ ((XrmDatabase, const char *,
+                                        const char *));
+extern XrmDatabase xrm_get_preference_database P_ ((const char *));
 EXFUN (Fmac_get_preference, 4);
 
 /* arch-tag: 6b4ca125-5bef-476d-8ee8-31ed808b7e79