1 /* Definitions and headers for communication with NeXT/Open/GNUstep API.
2 Copyright (C) 1989, 1993, 2005, 2008-2011 Free Software Foundation, Inc.
4 This file is part of GNU Emacs.
6 GNU Emacs is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 GNU Emacs is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
20 #include "dispextern.h"
22 #include "character.h"
24 #include "sysselect.h"
29 #ifndef MAC_OS_X_VERSION_10_6
30 #define MAC_OS_X_VERSION_10_6 1060
36 /* ==========================================================================
40 ========================================================================== */
42 /* We override sendEvent: as a means to stop/start the event loop */
43 @interface EmacsApp
: NSApplication
46 - (void)logNotification
: (NSNotification
*)notification
;
47 - (void)sendEvent
: (NSEvent
*)theEvent
;
48 - (void)showPreferencesWindow
: (id
)sender
;
49 - (BOOL
) openFile
: (NSString
*)fileName
;
50 - (void)fd_handler
: (NSTimer
*) fdEntry
;
51 - (void)timeout_handler
: (NSTimer
*)timedEntry
;
52 - (BOOL
)fulfillService
: (NSString
*)name withArg
: (NSString
*)arg
;
56 /* ==========================================================================
60 ========================================================================== */
64 @interface EmacsView
: NSView
<NSTextInput
> /* 10.6+: NSWindowDelegate */
68 NSString
*workingText
;
69 BOOL processingCompose
;
71 struct frame
*emacsframe
;
73 int scrollbarsNeedingUpdate
;
74 EmacsToolbar
*toolbar
;
78 /* AppKit-side interface */
80 - toolbarClicked
: (id
)item
;
81 - toggleToolbar
: (id
)sender
;
82 - (void)keyDown
: (NSEvent
*)theEvent
;
83 - (void)mouseDown
: (NSEvent
*)theEvent
;
84 - (void)mouseUp
: (NSEvent
*)theEvent
;
85 - setMiniwindowImage
: (BOOL
)setMini
;
87 /* Emacs-side interface */
88 - initFrameFromEmacs
: (struct frame
*) f
;
89 - (void) setRows
: (int) r andColumns
: (int) c
;
90 - (void) setWindowClosing
: (BOOL
)closing
;
91 - (EmacsToolbar
*) toolbar
;
92 - (void) deleteWorkingText
;
94 #ifdef NS_IMPL_GNUSTEP
95 /* Not declared, but useful. */
96 - (void) unlockFocusNeedsFlush
: (BOOL
)needs
;
101 /* Small utility used for processing resize events under Cocoa. */
102 @interface EmacsWindow
: NSWindow
109 /* ==========================================================================
111 The main menu implementation
113 ========================================================================== */
115 @interface EmacsMenu
: NSMenu
/* 10.6+: <NSMenuDelegate> */
118 unsigned long keyEquivModMask
;
121 - initWithTitle
: (NSString
*)title frame
: (struct frame
*)f
;
122 - (void)setFrame
: (struct frame
*)f
;
123 - (void)menuNeedsUpdate
: (NSMenu
*)menu
; /* (delegate method) */
124 - (NSString
*)parseKeyEquiv
: (const char *)key
;
125 - (NSMenuItem
*)addItemWithWidgetValue
: (void *)wvptr
;
126 - (void)fillWithWidgetValue
: (void *)wvptr
;
127 - (EmacsMenu
*)addSubmenuWithTitle
: (const char *)title forFrame
: (struct frame
*)f
;
129 - (Lisp_Object
)runMenuAt
: (NSPoint
)p forFrame
: (struct frame
*)f
130 keymaps
: (int)keymaps
;
134 /* ==========================================================================
138 ========================================================================== */
142 @interface EmacsToolbar
: NSToolbar
/* 10.6+: <NSToolbarDelegate> */
144 EmacsView
*emacsView
;
145 NSMutableDictionary
*identifierToItem
;
146 NSMutableArray
*activeIdentifiers
;
147 NSArray
*prevIdentifiers
;
148 unsigned long enablement
, prevEnablement
;
150 - initForView
: (EmacsView
*)view withIdentifier
: (NSString
*)identifier
;
151 - (void) clearActive
;
153 - (void) addDisplayItemWithImage
: (EmacsImage
*)img idx
: (int)idx
154 helpText
: (const char *)help
155 enabled
: (BOOL
)enabled
;
156 /* delegate methods */
157 - (NSToolbarItem
*)toolbar
: (NSToolbar
*)toolbar
158 itemForItemIdentifier
: (NSString
*)itemIdentifier
159 willBeInsertedIntoToolbar
: (BOOL
)flag
;
160 - (NSArray
*)toolbarDefaultItemIdentifiers
: (NSToolbar
*)toolbar
;
161 - (NSArray
*)toolbarAllowedItemIdentifiers
: (NSToolbar
*)toolbar
;
165 /* ==========================================================================
167 Message / question windows
169 ========================================================================== */
171 @interface EmacsDialogPanel
: NSPanel
173 NSTextField
*command
;
178 - initFromContents
: (Lisp_Object
)menu isQuestion
: (BOOL
)isQ
;
179 - addButton
: (char *)str value
: (Lisp_Object
)val row
: (int)row
;
180 - addString
: (char *)str row
: (int)row
;
182 - (Lisp_Object
)runDialogAt
: (NSPoint
)p
;
185 @interface EmacsTooltip
: NSObject
/* 10.6+: <NSWindowDelegate> */
188 NSTextField
*textField
;
192 - (void) setText
: (char *)text
;
193 - (void) showAtX
: (int)x Y
: (int)y
for: (int)seconds
;
200 /* ==========================================================================
202 File open/save panels
203 This and next override methods to work around OS X behavior of
204 restarting application loop when user dismisses panel.
206 ========================================================================== */
208 @interface EmacsSavePanel
: NSSavePanel
212 @interface EmacsOpenPanel
: NSOpenPanel
217 @interface EmacsFileDelegate
: NSObject
220 - (BOOL
)panel
: (id
)sender isValidFilename
: (NSString
*)filename
;
221 - (BOOL
)panel
: (id
)sender shouldShowFilename
: (NSString
*)filename
;
222 - (NSString
*)panel
: (id
)sender userEnteredFilename
: (NSString
*)filename
223 confirmed
: (BOOL
)okFlag
;
227 /* ==========================================================================
231 ========================================================================== */
233 @interface EmacsImage
: NSImage
237 NSBitmapImageRep
*bmRep
; /* used for accessing pixel data */
238 unsigned char *pixmapData
[5]; /* shortcut to access pixel data */
240 NSColor
*stippleMask
;
242 + allocInitFromFile
: (Lisp_Object
)file
;
244 - imageListSetNext
: (id
)arg
;
247 - initFromXBM
: (unsigned char *)bits width
: (int)w height
: (int)h
249 - initFromSkipXBM
: (unsigned char *)bits width
: (int)w height
: (int)h
250 flip
: (BOOL
)flip length
: (int)length
;
251 - setXBMColor
: (NSColor
*)color
;
252 - initForXPMWithDepth
: (int)depth width
: (int)width height
: (int)height
;
253 - (void)setPixmapData
;
254 - (unsigned long)getPixelAtX
: (int)x Y
: (int)y
;
255 - (void)setPixelAtX
: (int)x Y
: (int)y toRed
: (unsigned char)r
256 green
: (unsigned char)g blue
: (unsigned char)b
257 alpha
:(unsigned char)a
;
258 - (void)setAlphaAtX
: (int)x Y
: (int)y to
: (unsigned char)a
;
259 - (NSColor
*)stippleMask
;
263 /* ==========================================================================
267 ========================================================================== */
269 @interface EmacsScroller
: NSScroller
273 NSResponder
*prevResponder
;
275 /* offset to the bottom of knob of last mouse down */
276 float last_mouse_offset
;
283 /* optimize against excessive positioning calls generated by emacs */
289 - initFrame
: (NSRect
)r window
: (Lisp_Object
)win
;
290 - (void)setFrame
: (NSRect
)r
;
293 - setPosition
: (int) position portion
: (int) portion whole
: (int) whole
;
294 - (int) checkSamePosition
: (int)position portion
: (int)portion
296 - (void) getMouseMotionPart
: (int *)part window
: (Lisp_Object
*)window
297 x
: (Lisp_Object
*)x y
: ( Lisp_Object
*)y
;
298 - (void) sendScrollEventAtLoc
: (float)loc fromEvent
: (NSEvent
*)e
;
299 - repeatScroll
: (NSTimer
*)sender
;
306 /* ==========================================================================
308 Rendering on Panther and above
310 ========================================================================== */
314 @interface EmacsGlyphStorage
: NSObject
<NSGlyphStorage
>
317 NSAttributedString
*attrStr
;
318 NSMutableDictionary
*dict
;
320 unsigned long maxChar
, maxGlyph
;
323 - initWithCapacity
: (unsigned long) c
;
324 - (void) setString
: (NSString
*)str font
: (NSFont
*)font
;
326 #endif /* NS_IMPL_COCOA */
328 extern NSArray
*ns_send_types
, *ns_return_types
;
329 extern NSString
*ns_app_name
;
330 extern EmacsMenu
*mainMenu
, *svcsMenu
, *dockMenu
;
332 /* Apple removed the declaration, but kept the implementation */
333 #if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
334 @interface
NSApplication (EmacsApp
)
335 - (void)setAppleMenu
: (NSMenu
*)menu
;
339 #ifndef NS_HAVE_NSINTEGER
340 #if defined(__LP64__) && __LP64__
341 typedef double CGFloat
;
342 typedef long NSInteger
;
343 typedef unsigned long NSUInteger
;
345 typedef float CGFloat
;
346 typedef int NSInteger
;
347 typedef unsigned int NSUInteger
;
348 #endif /* not LP64 */
349 #endif /* not NS_HAVE_NSINTEGER */
351 #endif /* __OBJC__ */
355 /* ==========================================================================
359 ========================================================================== */
361 /* Special keycodes that we pass down the event chain */
362 #define KEY_NS_POWER_OFF ((1<<28)|(0<<16)|1)
363 #define KEY_NS_OPEN_FILE ((1<<28)|(0<<16)|2)
364 #define KEY_NS_OPEN_TEMP_FILE ((1<<28)|(0<<16)|3)
365 #define KEY_NS_DRAG_FILE ((1<<28)|(0<<16)|4)
366 #define KEY_NS_DRAG_COLOR ((1<<28)|(0<<16)|5)
367 #define KEY_NS_DRAG_TEXT ((1<<28)|(0<<16)|6)
368 #define KEY_NS_CHANGE_FONT ((1<<28)|(0<<16)|7)
369 #define KEY_NS_OPEN_FILE_LINE ((1<<28)|(0<<16)|8)
370 #define KEY_NS_PUT_WORKING_TEXT ((1<<28)|(0<<16)|9)
371 #define KEY_NS_UNPUT_WORKING_TEXT ((1<<28)|(0<<16)|10)
372 #define KEY_NS_SPI_SERVICE_CALL ((1<<28)|(0<<16)|11)
373 #define KEY_NS_NEW_FRAME ((1<<28)|(0<<16)|12)
374 #define KEY_NS_TOGGLE_TOOLBAR ((1<<28)|(0<<16)|13)
375 #define KEY_NS_SHOW_PREFS ((1<<28)|(0<<16)|14)
377 /* could use list to store these, but rest of emacs has a big infrastructure
378 for managing a table of bitmap "records" */
379 struct ns_bitmap_record
388 int height
, width
, depth
;
391 /* this to map between emacs color indices and NSColor objects */
392 struct ns_color_table
398 NSMutableSet
*empty_indices
;
404 #define NS_COLOR_CAPACITY 256
406 #define RGB_TO_ULONG(r, g, b) (((r) << 16) | ((g) << 8) | (b))
407 #define ARGB_TO_ULONG(a, r, g, b) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))
409 #define ALPHA_FROM_ULONG(color) ((color) >> 24)
410 #define RED_FROM_ULONG(color) (((color) >> 16) & 0xff)
411 #define GREEN_FROM_ULONG(color) (((color) >> 8) & 0xff)
412 #define BLUE_FROM_ULONG(color) ((color) & 0xff)
414 /* Do not change `* 0x101' in the following lines to `<< 8'. If
415 changed, image masks in 1-bit depth will not work. */
416 #define RED16_FROM_ULONG(color) (RED_FROM_ULONG(color) * 0x101)
417 #define GREEN16_FROM_ULONG(color) (GREEN_FROM_ULONG(color) * 0x101)
418 #define BLUE16_FROM_ULONG(color) (BLUE_FROM_ULONG(color) * 0x101)
420 /* this extends font backend font */
425 char *name
; /* postscript name, uniquely identifies on NS systems */
426 float width
; /* this and following metrics stored as float rather than int */
433 /* cgfont and synthItal are used only on OS X 10.3+ */
434 #if defined (NS_IMPL_COCOA) && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3)
436 #else /* GNUstep or OS X < 10.3 */
443 char bold
, ital
; /* convenience flags */
445 float voffset
; /* mean of ascender/descender offsets */
446 XCharStruct max_bounds
;
447 /* we compute glyph codes and metrics on-demand in blocks of 256 indexed
449 unsigned short **glyphs
; /* map unicode index to glyph */
450 struct font_metrics
**metrics
;
454 /* init'd in ns_initialize_display_info () */
455 struct ns_display_info
457 /* Chain of all ns_display_info structures. */
458 struct ns_display_info
*next
;
460 /* The generic display parameters corresponding to this NS display. */
461 struct terminal
*terminal
;
463 /* This is a cons cell of the form (NAME . FONT-LIST-CACHE).
464 The same cons cell also appears in ns_display_name_list. */
465 Lisp_Object name_list_element
;
467 /* The number of fonts loaded. */
470 /* Minimum width over all characters in all fonts in font_table. */
471 int smallest_char_width
;
473 /* Minimum font height over all fonts in font_table. */
474 int smallest_font_height
;
476 struct ns_bitmap_record
*bitmaps
;
477 ptrdiff_t bitmaps_size
;
478 ptrdiff_t bitmaps_last
;
480 struct image_cache
*image_cache
;
482 struct ns_color_table
*color_table
;
484 /* DPI resolution of this screen */
487 /* Mask of things that cause the mouse to be grabbed */
499 /* The cursor to use for vertical scroll bars. */
500 Cursor vertical_scroll_bar_cursor
;
502 /* Information about the range of text currently shown in
504 Mouse_HLInfo mouse_highlight
;
506 struct frame
*x_highlight_frame
;
507 struct frame
*x_focus_frame
;
510 /* This is a chain of structures for all the NS displays currently in use. */
511 extern struct ns_display_info
*x_display_list
;
513 extern Lisp_Object ns_display_name_list
;
514 extern struct ns_display_info
*ns_display_info_for_name ();
516 struct ns_display_info
*check_x_display_info (Lisp_Object frame
);
517 FRAME_PTR
check_x_frame (Lisp_Object frame
);
525 NSColor
*cursor_color
;
526 NSColor
*foreground_color
;
527 NSColor
*background_color
;
528 EmacsToolbar
*toolbar
;
533 void *foreground_color
;
534 void *background_color
;
538 /* NSCursors init'ed in initFrameFromEmacs */
540 Cursor nontext_cursor
;
541 Cursor modeline_cursor
;
543 Cursor hourglass_cursor
;
544 Cursor horizontal_drag_cursor
;
547 Cursor current_pointer
;
549 /* lord knows why Emacs needs to know about our Window ids.. */
550 Window window_desc
, parent_desc
;
551 char explicit_parent
;
556 /* If a fontset is specified for this frame instead of font, this
557 value contains an ID of the fontset, else -1. */
558 int fontset
; /* only used with font_backend */
560 Lisp_Object icon_top
;
561 Lisp_Object icon_left
;
563 /* The size of the extra width currently allotted for vertical
564 scroll bars, in pixels. */
565 int vertical_scroll_bar_extra
;
567 /* The height of the titlebar decoration (included in NSWindow's frame). */
570 /* The height of the toolbar if displayed, else 0. */
573 /* This is the Emacs structure for the NS display this frame is on. */
574 struct ns_display_info
*display_info
;
576 /* Non-zero if we want to constrain the frame to the screen. */
579 /* Non-zero if we are zooming (maximizing) the frame. */
583 /* this dummy decl needed to support TTYs */
586 unsigned long background_pixel
;
587 unsigned long foreground_pixel
;
591 /* This gives the ns_display_info structure for the display F is on. */
592 #define FRAME_NS_DISPLAY_INFO(f) ((f)->output_data.ns->display_info)
593 /* the primacy of X must be constantly worked with... */
594 #define FRAME_X_DISPLAY_INFO(f) ((f)->output_data.ns->display_info)
595 #define FRAME_X_OUTPUT(f) ((f)->output_data.ns)
596 #define FRAME_NS_WINDOW(f) ((f)->output_data.ns->window_desc)
597 #define FRAME_X_WINDOW(f) ((f)->output_data.ns->window_desc)
599 /* This is the `Display *' which frame F is on. */
600 #define FRAME_NS_DISPLAY(f) (0)
601 #define FRAME_X_DISPLAY(f) (0)
603 #define FRAME_FOREGROUND_COLOR(f) ((f)->output_data.ns->foreground_color)
604 #define FRAME_BACKGROUND_COLOR(f) ((f)->output_data.ns->background_color)
606 #define FRAME_X_IMAGE_CACHE(F) FRAME_NS_DISPLAY_INFO ((F))->image_cache
608 #define NS_FACE_FOREGROUND(f) ((f)->foreground)
609 #define NS_FACE_BACKGROUND(f) ((f)->background)
610 #define FRAME_NS_TITLEBAR_HEIGHT(f) ((f)->output_data.ns->titlebar_height)
611 #define FRAME_TOOLBAR_HEIGHT(f) ((f)->output_data.ns->toolbar_height)
613 #define FONT_WIDTH(f) ((f)->max_width)
614 #define FONT_HEIGHT(f) ((f)->height)
615 /*#define FONT_BASE(f) ((f)->ascent) */
616 #define FONT_BASE(f) (((struct nsfont_info *)f)->max_bounds.ascent)
617 /*#define FONT_DESCENT(f) ((f)->descent) */
618 #define FONT_DESCENT(f) (((struct nsfont_info *)f)->max_bounds.descent)
620 #define FRAME_DEFAULT_FACE(f) FACE_FROM_ID (f, DEFAULT_FACE_ID)
622 #define FRAME_NS_VIEW(f) ((f)->output_data.ns->view)
623 #define FRAME_CURSOR_COLOR(f) ((f)->output_data.ns->cursor_color)
624 #define FRAME_POINTER_TYPE(f) ((f)->output_data.ns->current_pointer)
626 #define FRAME_FONT(f) ((f)->output_data.ns->font)
629 #define XNS_SCROLL_BAR(vec) ((id) XSAVE_VALUE (vec)->pointer)
631 #define XNS_SCROLL_BAR(vec) XSAVE_VALUE (vec)->pointer
634 /* Compute pixel size for vertical scroll bars */
635 #define NS_SCROLL_BAR_WIDTH(f) \
636 (FRAME_HAS_VERTICAL_SCROLL_BARS (f) \
637 ? rint (FRAME_CONFIG_SCROLL_BAR_WIDTH (f) > 0 \
638 ? FRAME_CONFIG_SCROLL_BAR_WIDTH (f) \
639 : (FRAME_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f))) \
642 /* Difference btwn char-column-calculated and actual SB widths.
643 This is only a concern for rendering when SB on left. */
644 #define NS_SCROLL_BAR_ADJUST(w, f) \
645 (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (w) ? \
646 (FRAME_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f) \
647 - NS_SCROLL_BAR_WIDTH (f)) : 0)
649 /* XXX: fix for GNUstep inconsistent accounting for titlebar */
650 #ifdef NS_IMPL_GNUSTEP
651 #define NS_TOP_POS(f) ((f)->top_pos + 18)
653 #define NS_TOP_POS(f) ((f)->top_pos)
656 #define FRAME_NS_FONT_TABLE(f) (FRAME_NS_DISPLAY_INFO (f)->font_table)
658 #define FRAME_FONTSET(f) ((f)->output_data.ns->fontset)
660 #define FRAME_SMALLEST_CHAR_WIDTH(f) \
661 (FRAME_NS_DISPLAY_INFO (f)->smallest_char_width)
662 #define FRAME_SMALLEST_FONT_HEIGHT(f) \
663 (FRAME_NS_DISPLAY_INFO (f)->smallest_font_height)
664 #define FONT_TYPE_FOR_UNIBYTE(font, ch) 0
665 #define FONT_TYPE_FOR_MULTIBYTE(font, ch) 0
666 #define FRAME_BASELINE_OFFSET(f) ((f)->output_data.ns->baseline_offset)
667 #define BLACK_PIX_DEFAULT(f) 0x000000
668 #define WHITE_PIX_DEFAULT(f) 0xFFFFFF
670 /* First position where characters can be shown (instead of scrollbar, if
672 #define FIRST_CHAR_POSITION(f) \
673 (! (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f)) ? 0 \
674 : FRAME_SCROLL_BAR_COLS (f))
676 extern struct ns_display_info
*ns_term_init ();
677 extern void ns_term_shutdown (int sig
);
679 /* constants for text rendering */
680 #define NS_DUMPGLYPH_NORMAL 0
681 #define NS_DUMPGLYPH_CURSOR 1
682 #define NS_DUMPGLYPH_FOREGROUND 2
683 #define NS_DUMPGLYPH_MOUSEFACE 3
686 EXFUN (Fx_display_grayscale_p
, 1);
687 EXFUN (Fx_display_planes
, 1);
689 /* In nsfont, called from fontset.c */
690 extern void nsfont_make_fontset_for_font (Lisp_Object name
,
691 Lisp_Object font_object
);
693 /* In nsfont, for debugging */
695 void ns_dump_glyphstring (struct glyph_string
*s
);
697 /* Implemented in nsterm, published in or needed from nsfns. */
698 extern Lisp_Object Qfontsize
;
699 extern Lisp_Object
ns_list_fonts (FRAME_PTR f
, Lisp_Object pattern
,
700 int size
, int maxnames
);
701 extern void ns_clear_frame (struct frame
*f
);
703 extern const char *ns_xlfd_to_fontname (const char *xlfd
);
705 extern void check_ns (void);
706 extern Lisp_Object
ns_map_event_to_object ();
707 extern Lisp_Object
ns_string_from_pasteboard ();
708 extern void ns_string_to_pasteboard ();
709 extern Lisp_Object
ns_get_local_selection (Lisp_Object selection_name
,
710 Lisp_Object target_type
);
711 extern void nxatoms_of_nsselect ();
712 extern int ns_lisp_to_cursor_type ();
713 extern Lisp_Object
ns_cursor_type_to_lisp (int arg
);
714 extern Lisp_Object Qnone
;
715 extern void ns_set_name_as_filename (struct frame
*f
);
716 extern void ns_set_doc_edited (struct frame
*f
, Lisp_Object arg
);
719 ns_defined_color (struct frame
*f
,
721 XColor
*color_def
, int alloc
,
724 ns_query_color (void *col
, XColor
*color_def
, int setPixel
);
727 extern Lisp_Object
ns_color_to_lisp (NSColor
*col
);
728 extern int ns_lisp_to_color (Lisp_Object color
, NSColor
**col
);
729 extern NSColor
*ns_lookup_indexed_color (unsigned long idx
, struct frame
*f
);
730 extern unsigned long ns_index_color (NSColor
*color
, struct frame
*f
);
731 extern void ns_free_indexed_color (unsigned long idx
, struct frame
*f
);
734 /* C access to ObjC functionality */
735 extern void ns_release_object (void *obj
);
736 extern void ns_retain_object (void *obj
);
737 extern void *ns_alloc_autorelease_pool ();
738 extern void ns_release_autorelease_pool ();
741 extern void update_frame_tool_bar (FRAME_PTR f
);
742 extern void free_frame_tool_bar (FRAME_PTR f
);
743 extern void find_and_call_menu_selection (FRAME_PTR f
,
744 int menu_bar_items_used
, Lisp_Object vector
, void *client_data
);
745 extern Lisp_Object
find_and_return_menu_selection (FRAME_PTR f
,
748 extern Lisp_Object
ns_popup_dialog (Lisp_Object position
, Lisp_Object contents
,
751 /* More prototypes that should be moved to a more general include file */
752 extern void set_frame_menubar (struct frame
*f
, int first_time
, int deep_p
);
753 extern void x_set_window_size (struct frame
*f
, int change_grav
,
755 extern void x_sync (struct frame
*);
756 extern Lisp_Object
x_get_focus_frame (struct frame
*);
757 extern void x_set_mouse_position (struct frame
*f
, int h
, int v
);
758 extern void x_set_mouse_pixel_position (struct frame
*f
, int pix_x
, int pix_y
);
759 extern void x_make_frame_visible (struct frame
*f
);
760 extern void x_make_frame_invisible (struct frame
*f
);
761 extern void x_iconify_frame (struct frame
*f
);
762 extern int x_char_width (struct frame
*f
);
763 extern int x_char_height (struct frame
*f
);
764 extern int x_pixel_width (struct frame
*f
);
765 extern int x_pixel_height (struct frame
*f
);
766 extern void x_set_frame_alpha (struct frame
*f
);
767 extern void x_set_menu_bar_lines (struct frame
*, Lisp_Object
, Lisp_Object
);
768 extern void x_set_tool_bar_lines (struct frame
*f
,
771 extern void x_activate_menubar (struct frame
*);
772 extern void free_frame_menubar (struct frame
*);
774 extern void ns_init_paths (void);
775 extern void syms_of_nsterm (void);
776 extern void syms_of_nsfns (void);
777 extern void syms_of_nsmenu (void);
778 extern void syms_of_nsselect (void);
780 /* From nsimage.m, needed in image.c */
782 extern void *ns_image_from_XBM (unsigned char *bits
, int width
, int height
);
783 extern void *ns_image_for_XPM (int width
, int height
, int depth
);
784 extern void *ns_image_from_file (Lisp_Object file
);
785 extern int ns_load_image (struct frame
*f
, struct image
*img
,
786 Lisp_Object spec_file
, Lisp_Object spec_data
);
787 extern int ns_image_width (void *img
);
788 extern int ns_image_height (void *img
);
789 extern unsigned long ns_get_pixel (void *img
, int x
, int y
);
790 extern void ns_put_pixel (void *img
, int x
, int y
, unsigned long argb
);
791 extern void ns_set_alpha (void *img
, int x
, int y
, unsigned char a
);
793 extern int x_display_pixel_height (struct ns_display_info
*);
794 extern int x_display_pixel_width (struct ns_display_info
*);
796 /* This in nsterm.m */
797 extern int ns_select (int nfds
, fd_set
*readfds
, fd_set
*writefds
,
798 fd_set
*exceptfds
, struct timeval
*timeout
);
799 extern unsigned long ns_get_rgb_color (struct frame
*f
,
800 float r
, float g
, float b
, float a
);
801 extern NSPoint last_mouse_motion_position
;
803 #ifdef NS_IMPL_GNUSTEP
804 extern char gnustep_base_version
[]; /* version tracking */
810 /* Screen max coordinate
811 Using larger coordinates causes movewindow/placewindow to abort */
812 #define SCREENMAX 16000
814 #define NS_SCROLL_BAR_WIDTH_DEFAULT [EmacsScroller scrollerWidth]
815 /* This is to match emacs on other platforms, ugly though it is. */
816 #define NS_SELECTION_COLOR_DEFAULT @"LightGoldenrod2";
817 #define RESIZE_HANDLE_SIZE 12
819 /* Little utility macros */
820 #define IN_BOUND(min, x, max) (((x) < (min)) \
821 ? (min) : (((x)>(max)) ? (max) : (x)))
822 #define SCREENMAXBOUND(x) (IN_BOUND (-SCREENMAX, x, SCREENMAX))
824 /* needed somewhere... */
825 #define VERTICAL_SCROLL_BAR_WIDTH_TRIM (0)