1 /* Definitions and headers for communication with NeXT/Open/GNUstep API.
2 Copyright (C) 1989, 1993, 2005, 2008-2012 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_3
30 #define MAC_OS_X_VERSION_10_3 1030
32 #ifndef MAC_OS_X_VERSION_10_4
33 #define MAC_OS_X_VERSION_10_4 1040
35 #ifndef MAC_OS_X_VERSION_10_5
36 #define MAC_OS_X_VERSION_10_5 1050
38 #ifndef MAC_OS_X_VERSION_10_6
39 #define MAC_OS_X_VERSION_10_6 1060
41 #endif /* NS_IMPL_COCOA */
45 /* ==========================================================================
49 ========================================================================== */
51 /* We override sendEvent: as a means to stop/start the event loop */
52 @interface EmacsApp
: NSApplication
55 - (void)logNotification
: (NSNotification
*)notification
;
56 - (void)sendEvent
: (NSEvent
*)theEvent
;
57 - (void)showPreferencesWindow
: (id
)sender
;
58 - (BOOL
) openFile
: (NSString
*)fileName
;
59 - (void)fd_handler
: (id
)unused
;
60 - (void)timeout_handler
: (NSTimer
*)timedEntry
;
61 - (BOOL
)fulfillService
: (NSString
*)name withArg
: (NSString
*)arg
;
65 /* ==========================================================================
69 ========================================================================== */
73 #if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
74 @interface EmacsView
: NSView
<NSTextInput
, NSWindowDelegate
>
76 @interface EmacsView
: NSView
<NSTextInput
>
81 NSString
*workingText
;
82 BOOL processingCompose
;
84 struct frame
*emacsframe
;
86 int scrollbarsNeedingUpdate
;
87 EmacsToolbar
*toolbar
;
91 /* AppKit-side interface */
92 - menuDown
: (id
)sender
;
93 - toolbarClicked
: (id
)item
;
94 - toggleToolbar
: (id
)sender
;
95 - (void)keyDown
: (NSEvent
*)theEvent
;
96 - (void)mouseDown
: (NSEvent
*)theEvent
;
97 - (void)mouseUp
: (NSEvent
*)theEvent
;
98 - setMiniwindowImage
: (BOOL
)setMini
;
100 /* Emacs-side interface */
101 - initFrameFromEmacs
: (struct frame
*) f
;
102 - (void) setRows
: (int) r andColumns
: (int) c
;
103 - (void) setWindowClosing
: (BOOL
)closing
;
104 - (EmacsToolbar
*) toolbar
;
105 - (void) deleteWorkingText
;
106 - (void) updateFrameSize
: (BOOL
) delay
;
108 #ifdef NS_IMPL_GNUSTEP
109 /* Not declared, but useful. */
110 - (void) unlockFocusNeedsFlush
: (BOOL
)needs
;
115 /* Small utility used for processing resize events under Cocoa. */
116 @interface EmacsWindow
: NSWindow
123 /* ==========================================================================
125 The main menu implementation
127 ========================================================================== */
129 #if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
130 @interface EmacsMenu
: NSMenu
<NSMenuDelegate
>
132 @interface EmacsMenu
: NSMenu
136 unsigned long keyEquivModMask
;
139 - initWithTitle
: (NSString
*)title frame
: (struct frame
*)f
;
140 - (void)setFrame
: (struct frame
*)f
;
141 - (void)menuNeedsUpdate
: (NSMenu
*)menu
; /* (delegate method) */
142 - (NSString
*)parseKeyEquiv
: (const char *)key
;
143 - (NSMenuItem
*)addItemWithWidgetValue
: (void *)wvptr
;
144 - (void)fillWithWidgetValue
: (void *)wvptr
;
145 - (EmacsMenu
*)addSubmenuWithTitle
: (const char *)title forFrame
: (struct frame
*)f
;
147 - (Lisp_Object
)runMenuAt
: (NSPoint
)p forFrame
: (struct frame
*)f
148 keymaps
: (int)keymaps
;
152 /* ==========================================================================
156 ========================================================================== */
160 #if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
161 @interface EmacsToolbar
: NSToolbar
<NSToolbarDelegate
>
163 @interface EmacsToolbar
: NSToolbar
166 EmacsView
*emacsView
;
167 NSMutableDictionary
*identifierToItem
;
168 NSMutableArray
*activeIdentifiers
;
169 NSArray
*prevIdentifiers
;
170 unsigned long enablement
, prevEnablement
;
172 - initForView
: (EmacsView
*)view withIdentifier
: (NSString
*)identifier
;
173 - (void) clearActive
;
175 - (void) addDisplayItemWithImage
: (EmacsImage
*)img idx
: (int)idx
176 helpText
: (const char *)help
177 enabled
: (BOOL
)enabled
;
178 /* delegate methods */
179 - (NSToolbarItem
*)toolbar
: (NSToolbar
*)toolbar
180 itemForItemIdentifier
: (NSString
*)itemIdentifier
181 willBeInsertedIntoToolbar
: (BOOL
)flag
;
182 - (NSArray
*)toolbarDefaultItemIdentifiers
: (NSToolbar
*)toolbar
;
183 - (NSArray
*)toolbarAllowedItemIdentifiers
: (NSToolbar
*)toolbar
;
187 /* ==========================================================================
189 Message / question windows
191 ========================================================================== */
193 @interface EmacsDialogPanel
: NSPanel
195 NSTextField
*command
;
199 BOOL timer_fired
, window_closed
;
200 Lisp_Object dialog_return
;
201 Lisp_Object
*button_values
;
203 - initFromContents
: (Lisp_Object
)menu isQuestion
: (BOOL
)isQ
;
204 - (void)process_dialog
: (Lisp_Object
)list
;
205 - (void)addButton
: (char *)str value
: (int)tag row
: (int)row
;
206 - (void)addString
: (char *)str row
: (int)row
;
208 - (Lisp_Object
)runDialogAt
: (NSPoint
)p
;
209 - (void)timeout_handler
: (NSTimer
*)timedEntry
;
212 #if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
213 @interface EmacsTooltip
: NSObject
<NSWindowDelegate
>
215 @interface EmacsTooltip
: NSObject
219 NSTextField
*textField
;
223 - (void) setText
: (char *)text
;
224 - (void) showAtX
: (int)x Y
: (int)y
for: (int)seconds
;
231 /* ==========================================================================
233 File open/save panels
234 This and next override methods to work around OS X behavior of
235 restarting application loop when user dismisses panel.
237 ========================================================================== */
239 @interface EmacsSavePanel
: NSSavePanel
243 @interface EmacsOpenPanel
: NSOpenPanel
248 @interface EmacsFileDelegate
: NSObject
251 - (BOOL
)panel
: (id
)sender isValidFilename
: (NSString
*)filename
;
252 - (BOOL
)panel
: (id
)sender shouldShowFilename
: (NSString
*)filename
;
253 - (NSString
*)panel
: (id
)sender userEnteredFilename
: (NSString
*)filename
254 confirmed
: (BOOL
)okFlag
;
258 /* ==========================================================================
262 ========================================================================== */
264 @interface EmacsImage
: NSImage
268 NSBitmapImageRep
*bmRep
; /* used for accessing pixel data */
269 unsigned char *pixmapData
[5]; /* shortcut to access pixel data */
271 NSColor
*stippleMask
;
273 + allocInitFromFile
: (Lisp_Object
)file
;
275 - imageListSetNext
: (id
)arg
;
278 - initFromXBM
: (unsigned char *)bits width
: (int)w height
: (int)h
280 - initFromSkipXBM
: (unsigned char *)bits width
: (int)w height
: (int)h
281 flip
: (BOOL
)flip length
: (int)length
;
282 - setXBMColor
: (NSColor
*)color
;
283 - initForXPMWithDepth
: (int)depth width
: (int)width height
: (int)height
;
284 - (void)setPixmapData
;
285 - (unsigned long)getPixelAtX
: (int)x Y
: (int)y
;
286 - (void)setPixelAtX
: (int)x Y
: (int)y toRed
: (unsigned char)r
287 green
: (unsigned char)g blue
: (unsigned char)b
288 alpha
:(unsigned char)a
;
289 - (void)setAlphaAtX
: (int)x Y
: (int)y to
: (unsigned char)a
;
290 - (NSColor
*)stippleMask
;
294 /* ==========================================================================
298 ========================================================================== */
300 @interface EmacsScroller
: NSScroller
304 NSResponder
*prevResponder
;
306 /* offset to the bottom of knob of last mouse down */
307 float last_mouse_offset
;
314 /* optimize against excessive positioning calls generated by emacs */
320 - initFrame
: (NSRect
)r window
: (Lisp_Object
)win
;
321 - (void)setFrame
: (NSRect
)r
;
324 - setPosition
: (int) position portion
: (int) portion whole
: (int) whole
;
325 - (int) checkSamePosition
: (int)position portion
: (int)portion
327 - (void) getMouseMotionPart
: (int *)part window
: (Lisp_Object
*)window
328 x
: (Lisp_Object
*)x y
: ( Lisp_Object
*)y
;
329 - (void) sendScrollEventAtLoc
: (float)loc fromEvent
: (NSEvent
*)e
;
330 - repeatScroll
: (NSTimer
*)sender
;
337 /* ==========================================================================
339 Rendering on Panther and above
341 ========================================================================== */
345 @interface EmacsGlyphStorage
: NSObject
<NSGlyphStorage
>
348 NSAttributedString
*attrStr
;
349 NSMutableDictionary
*dict
;
351 unsigned long maxChar
, maxGlyph
;
354 - initWithCapacity
: (unsigned long) c
;
355 - (void) setString
: (NSString
*)str font
: (NSFont
*)font
;
357 #endif /* NS_IMPL_COCOA */
359 extern NSArray
*ns_send_types
, *ns_return_types
;
360 extern NSString
*ns_app_name
;
361 extern EmacsMenu
*mainMenu
, *svcsMenu
, *dockMenu
;
363 /* Apple removed the declaration, but kept the implementation */
364 #if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
365 @interface
NSApplication (EmacsApp
)
366 - (void)setAppleMenu
: (NSMenu
*)menu
;
370 #ifndef NS_HAVE_NSINTEGER
371 #if defined (__LP64__) && __LP64__
372 typedef double CGFloat
;
373 typedef long NSInteger
;
374 typedef unsigned long NSUInteger
;
376 typedef float CGFloat
;
377 typedef int NSInteger
;
378 typedef unsigned int NSUInteger
;
379 #endif /* not LP64 */
380 #endif /* not NS_HAVE_NSINTEGER */
382 #endif /* __OBJC__ */
386 /* ==========================================================================
390 ========================================================================== */
392 /* Special keycodes that we pass down the event chain */
393 #define KEY_NS_POWER_OFF ((1<<28)|(0<<16)|1)
394 #define KEY_NS_OPEN_FILE ((1<<28)|(0<<16)|2)
395 #define KEY_NS_OPEN_TEMP_FILE ((1<<28)|(0<<16)|3)
396 #define KEY_NS_DRAG_FILE ((1<<28)|(0<<16)|4)
397 #define KEY_NS_DRAG_COLOR ((1<<28)|(0<<16)|5)
398 #define KEY_NS_DRAG_TEXT ((1<<28)|(0<<16)|6)
399 #define KEY_NS_CHANGE_FONT ((1<<28)|(0<<16)|7)
400 #define KEY_NS_OPEN_FILE_LINE ((1<<28)|(0<<16)|8)
401 #define KEY_NS_PUT_WORKING_TEXT ((1<<28)|(0<<16)|9)
402 #define KEY_NS_UNPUT_WORKING_TEXT ((1<<28)|(0<<16)|10)
403 #define KEY_NS_SPI_SERVICE_CALL ((1<<28)|(0<<16)|11)
404 #define KEY_NS_NEW_FRAME ((1<<28)|(0<<16)|12)
405 #define KEY_NS_TOGGLE_TOOLBAR ((1<<28)|(0<<16)|13)
406 #define KEY_NS_SHOW_PREFS ((1<<28)|(0<<16)|14)
408 /* could use list to store these, but rest of emacs has a big infrastructure
409 for managing a table of bitmap "records" */
410 struct ns_bitmap_record
419 int height
, width
, depth
;
422 /* this to map between emacs color indices and NSColor objects */
423 struct ns_color_table
429 NSMutableSet
*empty_indices
;
435 #define NS_COLOR_CAPACITY 256
437 #define RGB_TO_ULONG(r, g, b) (((r) << 16) | ((g) << 8) | (b))
438 #define ARGB_TO_ULONG(a, r, g, b) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))
440 #define ALPHA_FROM_ULONG(color) ((color) >> 24)
441 #define RED_FROM_ULONG(color) (((color) >> 16) & 0xff)
442 #define GREEN_FROM_ULONG(color) (((color) >> 8) & 0xff)
443 #define BLUE_FROM_ULONG(color) ((color) & 0xff)
445 /* Do not change `* 0x101' in the following lines to `<< 8'. If
446 changed, image masks in 1-bit depth will not work. */
447 #define RED16_FROM_ULONG(color) (RED_FROM_ULONG(color) * 0x101)
448 #define GREEN16_FROM_ULONG(color) (GREEN_FROM_ULONG(color) * 0x101)
449 #define BLUE16_FROM_ULONG(color) (BLUE_FROM_ULONG(color) * 0x101)
451 /* this extends font backend font */
456 char *name
; /* PostScript name, uniquely identifies on NS systems */
458 /* The following metrics are stored as float rather than int. */
460 float width
; /* Maximum advance for the font. */
467 /* cgfont and synthItal are used only on OS X 10.3+ */
468 #if defined (NS_IMPL_COCOA) && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3)
470 #else /* GNUstep or OS X < 10.3 */
477 char bold
, ital
; /* convenience flags */
479 XCharStruct max_bounds
;
480 /* we compute glyph codes and metrics on-demand in blocks of 256 indexed
482 unsigned short **glyphs
; /* map Unicode index to glyph */
483 struct font_metrics
**metrics
;
487 /* init'd in ns_initialize_display_info () */
488 struct ns_display_info
490 /* Chain of all ns_display_info structures. */
491 struct ns_display_info
*next
;
493 /* The generic display parameters corresponding to this NS display. */
494 struct terminal
*terminal
;
496 /* This is a cons cell of the form (NAME . FONT-LIST-CACHE).
497 The same cons cell also appears in ns_display_name_list. */
498 Lisp_Object name_list_element
;
500 /* The number of fonts loaded. */
503 /* Minimum width over all characters in all fonts in font_table. */
504 int smallest_char_width
;
506 /* Minimum font height over all fonts in font_table. */
507 int smallest_font_height
;
509 struct ns_bitmap_record
*bitmaps
;
510 ptrdiff_t bitmaps_size
;
511 ptrdiff_t bitmaps_last
;
513 struct image_cache
*image_cache
;
515 struct ns_color_table
*color_table
;
517 /* DPI resolution of this screen */
520 /* Mask of things that cause the mouse to be grabbed */
532 /* The cursor to use for vertical scroll bars. */
533 Cursor vertical_scroll_bar_cursor
;
535 /* Information about the range of text currently shown in
537 Mouse_HLInfo mouse_highlight
;
539 struct frame
*x_highlight_frame
;
540 struct frame
*x_focus_frame
;
543 /* This is a chain of structures for all the NS displays currently in use. */
544 extern struct ns_display_info
*x_display_list
;
546 extern Lisp_Object ns_display_name_list
;
547 extern struct ns_display_info
*ns_display_info_for_name (Lisp_Object name
);
549 struct ns_display_info
*check_x_display_info (Lisp_Object frame
);
550 FRAME_PTR
check_x_frame (Lisp_Object frame
);
558 NSColor
*cursor_color
;
559 NSColor
*foreground_color
;
560 NSColor
*background_color
;
561 EmacsToolbar
*toolbar
;
566 void *foreground_color
;
567 void *background_color
;
571 /* NSCursors init'ed in initFrameFromEmacs */
573 Cursor nontext_cursor
;
574 Cursor modeline_cursor
;
576 Cursor hourglass_cursor
;
577 Cursor horizontal_drag_cursor
;
580 Cursor current_pointer
;
582 /* lord knows why Emacs needs to know about our Window ids.. */
583 Window window_desc
, parent_desc
;
584 char explicit_parent
;
589 /* If a fontset is specified for this frame instead of font, this
590 value contains an ID of the fontset, else -1. */
591 int fontset
; /* only used with font_backend */
593 Lisp_Object icon_top
;
594 Lisp_Object icon_left
;
596 /* The size of the extra width currently allotted for vertical
597 scroll bars, in pixels. */
598 int vertical_scroll_bar_extra
;
600 /* The height of the titlebar decoration (included in NSWindow's frame). */
603 /* The height of the toolbar if displayed, else 0. */
606 /* This is the Emacs structure for the NS display this frame is on. */
607 struct ns_display_info
*display_info
;
609 /* Non-zero if we want to constrain the frame to the screen. */
612 /* Non-zero if we are zooming (maximizing) the frame. */
616 /* this dummy decl needed to support TTYs */
619 unsigned long background_pixel
;
620 unsigned long foreground_pixel
;
624 /* This gives the ns_display_info structure for the display F is on. */
625 #define FRAME_NS_DISPLAY_INFO(f) ((f)->output_data.ns->display_info)
626 /* the primacy of X must be constantly worked with... */
627 #define FRAME_X_DISPLAY_INFO(f) ((f)->output_data.ns->display_info)
628 #define FRAME_X_OUTPUT(f) ((f)->output_data.ns)
629 #define FRAME_NS_WINDOW(f) ((f)->output_data.ns->window_desc)
630 #define FRAME_X_WINDOW(f) ((f)->output_data.ns->window_desc)
632 /* This is the `Display *' which frame F is on. */
633 #define FRAME_NS_DISPLAY(f) (0)
634 #define FRAME_X_DISPLAY(f) (0)
635 #define FRAME_X_SCREEN(f) (0)
636 #define FRAME_X_VISUAL(f) FRAME_NS_DISPLAY_INFO(f)->visual
638 #define FRAME_FOREGROUND_COLOR(f) ((f)->output_data.ns->foreground_color)
639 #define FRAME_BACKGROUND_COLOR(f) ((f)->output_data.ns->background_color)
641 #define FRAME_X_IMAGE_CACHE(F) FRAME_NS_DISPLAY_INFO ((F))->image_cache
643 #define NS_FACE_FOREGROUND(f) ((f)->foreground)
644 #define NS_FACE_BACKGROUND(f) ((f)->background)
645 #define FRAME_NS_TITLEBAR_HEIGHT(f) ((f)->output_data.ns->titlebar_height)
646 #define FRAME_TOOLBAR_HEIGHT(f) ((f)->output_data.ns->toolbar_height)
648 #define FONT_WIDTH(f) ((f)->max_width)
649 #define FONT_HEIGHT(f) ((f)->height)
650 /*#define FONT_BASE(f) ((f)->ascent) */
651 #define FONT_BASE(f) (((struct nsfont_info *)f)->max_bounds.ascent)
652 /*#define FONT_DESCENT(f) ((f)->descent) */
653 #define FONT_DESCENT(f) (((struct nsfont_info *)f)->max_bounds.descent)
655 #define FRAME_DEFAULT_FACE(f) FACE_FROM_ID (f, DEFAULT_FACE_ID)
657 #define FRAME_NS_VIEW(f) ((f)->output_data.ns->view)
658 #define FRAME_CURSOR_COLOR(f) ((f)->output_data.ns->cursor_color)
659 #define FRAME_POINTER_TYPE(f) ((f)->output_data.ns->current_pointer)
661 #define FRAME_FONT(f) ((f)->output_data.ns->font)
664 #define XNS_SCROLL_BAR(vec) ((id) XSAVE_VALUE (vec)->pointer)
666 #define XNS_SCROLL_BAR(vec) XSAVE_VALUE (vec)->pointer
669 /* Compute pixel size for vertical scroll bars */
670 #define NS_SCROLL_BAR_WIDTH(f) \
671 (FRAME_HAS_VERTICAL_SCROLL_BARS (f) \
672 ? rint (FRAME_CONFIG_SCROLL_BAR_WIDTH (f) > 0 \
673 ? FRAME_CONFIG_SCROLL_BAR_WIDTH (f) \
674 : (FRAME_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f))) \
677 /* Difference btwn char-column-calculated and actual SB widths.
678 This is only a concern for rendering when SB on left. */
679 #define NS_SCROLL_BAR_ADJUST(w, f) \
680 (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (w) ? \
681 (FRAME_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f) \
682 - NS_SCROLL_BAR_WIDTH (f)) : 0)
684 /* XXX: fix for GNUstep inconsistent accounting for titlebar */
685 #ifdef NS_IMPL_GNUSTEP
686 #define NS_TOP_POS(f) ((f)->top_pos + 18)
688 #define NS_TOP_POS(f) ((f)->top_pos)
691 #define FRAME_NS_FONT_TABLE(f) (FRAME_NS_DISPLAY_INFO (f)->font_table)
693 #define FRAME_FONTSET(f) ((f)->output_data.ns->fontset)
695 #define FRAME_SMALLEST_CHAR_WIDTH(f) \
696 (FRAME_NS_DISPLAY_INFO (f)->smallest_char_width)
697 #define FRAME_SMALLEST_FONT_HEIGHT(f) \
698 (FRAME_NS_DISPLAY_INFO (f)->smallest_font_height)
699 #define FONT_TYPE_FOR_UNIBYTE(font, ch) 0
700 #define FONT_TYPE_FOR_MULTIBYTE(font, ch) 0
701 #define FRAME_BASELINE_OFFSET(f) ((f)->output_data.ns->baseline_offset)
702 #define BLACK_PIX_DEFAULT(f) 0x000000
703 #define WHITE_PIX_DEFAULT(f) 0xFFFFFF
705 /* First position where characters can be shown (instead of scrollbar, if
707 #define FIRST_CHAR_POSITION(f) \
708 (! (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f)) ? 0 \
709 : FRAME_SCROLL_BAR_COLS (f))
711 extern struct ns_display_info
*ns_term_init (Lisp_Object display_name
);
712 extern void ns_term_shutdown (int sig
);
714 /* constants for text rendering */
715 #define NS_DUMPGLYPH_NORMAL 0
716 #define NS_DUMPGLYPH_CURSOR 1
717 #define NS_DUMPGLYPH_FOREGROUND 2
718 #define NS_DUMPGLYPH_MOUSEFACE 3
722 /* In nsfont, called from fontset.c */
723 extern void nsfont_make_fontset_for_font (Lisp_Object name
,
724 Lisp_Object font_object
);
726 /* In nsfont, for debugging */
728 void ns_dump_glyphstring (struct glyph_string
*s
);
730 /* Implemented in nsterm, published in or needed from nsfns. */
731 extern Lisp_Object Qfontsize
;
732 extern Lisp_Object
ns_list_fonts (FRAME_PTR f
, Lisp_Object pattern
,
733 int size
, int maxnames
);
734 extern void ns_clear_frame (struct frame
*f
);
736 extern const char *ns_xlfd_to_fontname (const char *xlfd
);
738 extern void check_ns (void);
739 extern Lisp_Object
ns_map_event_to_object (void);
741 extern Lisp_Object
ns_string_from_pasteboard (id pb
);
742 extern void ns_string_to_pasteboard (id pb
, Lisp_Object str
);
744 extern Lisp_Object
ns_get_local_selection (Lisp_Object selection_name
,
745 Lisp_Object target_type
);
746 extern void nxatoms_of_nsselect (void);
747 extern int ns_lisp_to_cursor_type (Lisp_Object arg
);
748 extern Lisp_Object
ns_cursor_type_to_lisp (int arg
);
749 extern void ns_set_name_as_filename (struct frame
*f
);
750 extern void ns_set_doc_edited (struct frame
*f
, Lisp_Object arg
);
753 ns_defined_color (struct frame
*f
,
755 XColor
*color_def
, int alloc
,
758 ns_query_color (void *col
, XColor
*color_def
, int setPixel
);
761 extern Lisp_Object
ns_color_to_lisp (NSColor
*col
);
762 extern int ns_lisp_to_color (Lisp_Object color
, NSColor
**col
);
763 extern NSColor
*ns_lookup_indexed_color (unsigned long idx
, struct frame
*f
);
764 extern unsigned long ns_index_color (NSColor
*color
, struct frame
*f
);
765 extern void ns_free_indexed_color (unsigned long idx
, struct frame
*f
);
768 /* C access to ObjC functionality */
769 extern void ns_release_object (void *obj
);
770 extern void ns_retain_object (void *obj
);
771 extern void *ns_alloc_autorelease_pool (void);
772 extern void ns_release_autorelease_pool (void *);
773 extern const char *ns_get_defaults_value (const char *key
);
776 extern void update_frame_tool_bar (FRAME_PTR f
);
777 extern void free_frame_tool_bar (FRAME_PTR f
);
778 extern void find_and_call_menu_selection (FRAME_PTR f
,
779 int menu_bar_items_used
, Lisp_Object vector
, void *client_data
);
780 extern Lisp_Object
find_and_return_menu_selection (FRAME_PTR f
,
783 extern Lisp_Object
ns_popup_dialog (Lisp_Object position
, Lisp_Object contents
,
786 #define NSAPP_DATA2_RUNASSCRIPT 10
787 extern void ns_run_ascript (void);
789 extern const char *ns_etc_directory (void);
790 extern const char *ns_exec_path (void);
791 extern const char *ns_load_path (void);
792 extern void syms_of_nsterm (void);
793 extern void syms_of_nsfns (void);
794 extern void syms_of_nsmenu (void);
795 extern void syms_of_nsselect (void);
797 /* From nsimage.m, needed in image.c */
799 extern void *ns_image_from_XBM (unsigned char *bits
, int width
, int height
);
800 extern void *ns_image_for_XPM (int width
, int height
, int depth
);
801 extern void *ns_image_from_file (Lisp_Object file
);
802 extern int ns_load_image (struct frame
*f
, struct image
*img
,
803 Lisp_Object spec_file
, Lisp_Object spec_data
);
804 extern int ns_image_width (void *img
);
805 extern int ns_image_height (void *img
);
806 extern unsigned long ns_get_pixel (void *img
, int x
, int y
);
807 extern void ns_put_pixel (void *img
, int x
, int y
, unsigned long argb
);
808 extern void ns_set_alpha (void *img
, int x
, int y
, unsigned char a
);
810 extern int x_display_pixel_height (struct ns_display_info
*);
811 extern int x_display_pixel_width (struct ns_display_info
*);
813 /* This in nsterm.m */
814 extern int ns_select (int nfds
, fd_set
*readfds
, fd_set
*writefds
,
815 fd_set
*exceptfds
, EMACS_TIME
*timeout
,
817 extern unsigned long ns_get_rgb_color (struct frame
*f
,
818 float r
, float g
, float b
, float a
);
819 extern NSPoint last_mouse_motion_position
;
821 /* From nsterm.m, needed in nsfont.m. */
824 ns_draw_text_decoration (struct glyph_string
*s
, struct face
*face
,
825 NSColor
*defaultCol
, CGFloat width
, CGFloat x
);
828 #ifdef NS_IMPL_GNUSTEP
829 extern char gnustep_base_version
[]; /* version tracking */
835 /* Screen max coordinate
836 Using larger coordinates causes movewindow/placewindow to abort */
837 #define SCREENMAX 16000
839 #define NS_SCROLL_BAR_WIDTH_DEFAULT [EmacsScroller scrollerWidth]
840 /* This is to match emacs on other platforms, ugly though it is. */
841 #define NS_SELECTION_COLOR_DEFAULT @"LightGoldenrod2";
842 #define RESIZE_HANDLE_SIZE 12
844 /* Little utility macros */
845 #define IN_BOUND(min, x, max) (((x) < (min)) \
846 ? (min) : (((x)>(max)) ? (max) : (x)))
847 #define SCREENMAXBOUND(x) (IN_BOUND (-SCREENMAX, x, SCREENMAX))
849 /* needed somewhere... */
850 #define VERTICAL_SCROLL_BAR_WIDTH_TRIM (0)