1 /* Definitions and headers for communication with NeXT/Open/GNUstep API.
2 Copyright (C) 1989, 1993, 2005, 2008 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"
29 /* ==========================================================================
33 ========================================================================== */
35 /* We override sendEvent: as a means to stop/start the event loop */
36 @interface EmacsApp
: NSApplication
39 - (void)logNotification
: (NSNotification
*)notification
;
40 - (void)sendEvent
: (NSEvent
*)theEvent
;
41 - (void)showPreferencesWindow
: (id
)sender
;
42 - (BOOL
) openFile
: (NSString
*)fileName
;
43 - (void)fd_handler
: (NSTimer
*) fdEntry
;
44 - (void)timeout_handler
: (NSTimer
*)timedEntry
;
45 - (BOOL
)fulfillService
: (NSString
*)name withArg
: (NSString
*)arg
;
49 /* ==========================================================================
53 ========================================================================== */
57 @interface EmacsView
: NSView
<NSTextInput
>
61 NSString
*workingText
;
62 BOOL processingCompose
;
64 struct frame
*emacsframe
;
66 int scrollbarsNeedingUpdate
;
67 EmacsToolbar
*toolbar
;
70 /* AppKit-side interface */
72 - toolbarClicked
: (id
)item
;
73 - toggleToolbar
: (id
)sender
;
74 - (void)keyDown
: (NSEvent
*)theEvent
;
75 - (void)mouseDown
: (NSEvent
*)theEvent
;
76 - (void)mouseUp
: (NSEvent
*)theEvent
;
77 - setMiniwindowImage
: (BOOL
)setMini
;
79 /* Emacs-side interface */
80 - initFrameFromEmacs
: (struct frame
*) f
;
81 - (void) setRows
: (int) r andColumns
: (int) c
;
82 - (void) setWindowClosing
: (BOOL
)closing
;
83 - (EmacsToolbar
*) toolbar
;
84 - (void) deleteWorkingText
;
86 #ifdef NS_IMPL_GNUSTEP
87 /* Not declared, but useful. */
88 - (void) unlockFocusNeedsFlush
: (BOOL
)needs
;
93 /* Small utility used for processing resize events under Cocoa. */
94 @interface EmacsWindow
: NSWindow
101 /* ==========================================================================
103 The main menu implementation
105 ========================================================================== */
107 @interface EmacsMenu
: NSMenu
110 unsigned long keyEquivModMask
;
113 - initWithTitle
: (NSString
*)title frame
: (struct frame
*)f
;
114 - (void)setFrame
: (struct frame
*)f
;
115 - (void)menuNeedsUpdate
: (NSMenu
*)menu
; /* (delegate method) */
116 - (NSString
*)parseKeyEquiv
: (char *)key
;
117 - (NSMenuItem
*)addItemWithWidgetValue
: (void *)wvptr
;
118 - (void)fillWithWidgetValue
: (void *)wvptr
;
119 - (EmacsMenu
*)addSubmenuWithTitle
: (char *)title forFrame
: (struct frame
*)f
;
121 - (Lisp_Object
)runMenuAt
: (NSPoint
)p forFrame
: (struct frame
*)f
122 keymaps
: (int)keymaps
;
126 /* ==========================================================================
130 ========================================================================== */
134 @interface EmacsToolbar
: NSToolbar
136 EmacsView
*emacsView
;
137 NSMutableDictionary
*identifierToItem
;
138 NSMutableArray
*activeIdentifiers
;
139 NSArray
*prevIdentifiers
;
140 unsigned long enablement
, prevEnablement
;
142 - initForView
: (EmacsView
*)view withIdentifier
: (NSString
*)identifier
;
143 - (void) clearActive
;
145 - (void) addDisplayItemWithImage
: (EmacsImage
*)img idx
: (int)idx
146 helpText
: (char *)help
147 enabled
: (BOOL
)enabled
;
148 /* delegate methods */
149 - (NSToolbarItem
*)toolbar
: (NSToolbar
*)toolbar
150 itemForItemIdentifier
: (NSString
*)itemIdentifier
151 willBeInsertedIntoToolbar
: (BOOL
)flag
;
152 - (NSArray
*)toolbarDefaultItemIdentifiers
: (NSToolbar
*)toolbar
;
153 - (NSArray
*)toolbarAllowedItemIdentifiers
: (NSToolbar
*)toolbar
;
157 /* ==========================================================================
159 Message / question windows
161 ========================================================================== */
163 @interface EmacsDialogPanel
: NSPanel
165 NSTextField
*command
;
170 - initFromContents
: (Lisp_Object
)menu isQuestion
: (BOOL
)isQ
;
171 - addButton
: (char *)str value
: (Lisp_Object
)val row
: (int)row
;
172 - addString
: (char *)str row
: (int)row
;
174 - (Lisp_Object
)runDialogAt
: (NSPoint
)p
;
177 @interface EmacsTooltip
: NSObject
180 NSTextField
*textField
;
184 - (void) setText
: (char *)text
;
185 - (void) showAtX
: (int)x Y
: (int)y
for: (int)seconds
;
192 /* ==========================================================================
194 File open/save panels
195 This and next override methods to work around OS X behavior of
196 restarting application loop when user dismisses panel.
198 ========================================================================== */
200 @interface EmacsSavePanel
: NSSavePanel
204 @interface EmacsOpenPanel
: NSOpenPanel
209 @interface EmacsFileDelegate
: NSObject
212 - (BOOL
)panel
: (id
)sender isValidFilename
: (NSString
*)filename
;
213 - (BOOL
)panel
: (id
)sender shouldShowFilename
: (NSString
*)filename
;
214 - (NSString
*)panel
: (id
)sender userEnteredFilename
: (NSString
*)filename
215 confirmed
: (BOOL
)okFlag
;
219 /* ==========================================================================
223 ========================================================================== */
225 @interface EmacsImage
: NSImage
229 NSBitmapImageRep
*bmRep
; /* used for accessing pixel data */
230 unsigned char *pixmapData
[5]; /* shortcut to access pixel data */
232 NSColor
*stippleMask
;
234 + allocInitFromFile
: (Lisp_Object
)file
;
236 - imageListSetNext
: (id
)arg
;
239 - initFromXBM
: (unsigned char *)bits width
: (int)w height
: (int)h
241 - initFromSkipXBM
: (unsigned char *)bits width
: (int)w height
: (int)h
242 flip
: (BOOL
)flip length
: (int)length
;
243 - setXBMColor
: (NSColor
*)color
;
244 - initForXPMWithDepth
: (int)depth width
: (int)width height
: (int)height
;
245 - (void)setPixmapData
;
246 - (unsigned long)getPixelAtX
: (int)x Y
: (int)y
;
247 - (void)setPixelAtX
: (int)x Y
: (int)y toRed
: (unsigned char)r
248 green
: (unsigned char)g blue
: (unsigned char)b
249 alpha
:(unsigned char)a
;
250 - (void)setAlphaAtX
: (int)x Y
: (int)y to
: (unsigned char)a
;
251 - (NSColor
*)stippleMask
;
255 /* ==========================================================================
259 ========================================================================== */
261 @interface EmacsScroller
: NSScroller
265 NSResponder
*prevResponder
;
267 /* offset to the bottom of knob of last mouse down */
268 float last_mouse_offset
;
275 /* optimize against excessive positioning calls generated by emacs */
281 - initFrame
: (NSRect
)r window
: (Lisp_Object
)win
;
282 - (void)setFrame
: (NSRect
)r
;
285 - setPosition
: (int) position portion
: (int) portion whole
: (int) whole
;
286 - (int) checkSamePosition
: (int)position portion
: (int)portion
288 - (void) getMouseMotionPart
: (int *)part window
: (Lisp_Object
*)window
289 x
: (Lisp_Object
*)x y
: ( Lisp_Object
*)y
;
290 - (void) sendScrollEventAtLoc
: (float)loc fromEvent
: (NSEvent
*)e
;
291 - repeatScroll
: (NSTimer
*)sender
;
298 /* ==========================================================================
300 Rendering on Panther and above
302 ========================================================================== */
306 @interface EmacsGlyphStorage
: NSObject
<NSGlyphStorage
>
309 NSAttributedString
*attrStr
;
310 NSMutableDictionary
*dict
;
312 unsigned long maxChar
, maxGlyph
;
315 - initWithCapacity
: (unsigned long) c
;
316 - (void) setString
: (NSString
*)str font
: (NSFont
*)font
;
318 #endif /* NS_IMPL_COCOA */
321 /* ==========================================================================
323 Running the preferences window
325 ========================================================================== */
327 @interface EmacsPrefsController
: NSObject
330 IBOutlet NSWindow
*prefsWindow
;
331 IBOutlet NSPopUpButton
*alternateModMenu
;
332 IBOutlet NSPopUpButton
*commandModMenu
;
334 IBOutlet NSPopUpButton
*controlModMenu
;
335 IBOutlet NSPopUpButton
*functionModMenu
;
337 IBOutlet NSMatrix
*cursorTypeMatrix
;
338 IBOutlet NSSlider
*cursorBlinkSlider
;
339 IBOutlet NSSlider
*expandSpaceSlider
;
341 IBOutlet NSButton
*smoothFontsCheck
;
342 IBOutlet NSButton
*useQuickdrawCheck
;
343 IBOutlet NSButton
*useSysHiliteCheck
;
344 Lisp_Object prevUseHighlightColor
;
346 float prevExpandSpace
;
349 - (IBAction
)cancel
: (id
)sender
;
350 - (IBAction
)ok
: (id
)sender
;
351 - (IBAction
)resetToDefaults
: (id
)sender
;
352 - (IBAction
)runHelp
: (id
)sender
;
353 - (IBAction
)setColors
: (id
)sender
;
354 - (IBAction
)setDefaultFont
: (id
)sender
;
356 - (void) showForFrame
: (struct frame
*)f
;
357 - (void) setPanelFromValues
;
358 - (void) setValuesFromPanel
;
361 extern NSArray
*ns_send_types
, *ns_return_types
;
362 extern EmacsMenu
*mainMenu
, *svcsMenu
, *dockMenu
;
364 /* Apple removed the declaration, but kept the implementation */
365 #if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_4
366 @interface
NSApplication (EmacsApp
)
367 - (void)setAppleMenu
: (NSMenu
*)menu
;
371 #ifndef NS_HAVE_NSINTEGER
372 typedef long NSInteger
;
373 typedef unsigned long NSUInteger
;
374 #endif /* not NS_HAVE_NSINTEGER */
376 #endif /* __OBJC__ */
380 /* ==========================================================================
384 ========================================================================== */
396 /* could use list to store these, but rest of emacs has a big infrastructure
397 for managing a table of bitmap "records" */
398 struct ns_bitmap_record
407 int height
, width
, depth
;
410 /* this to map between emacs color indices and NSColor objects */
411 struct ns_color_table
417 NSMutableSet
*empty_indices
;
423 #define NS_COLOR_CAPACITY 256
425 #define RGB_TO_ULONG(r, g, b) (((r) << 16) | ((g) << 8) | (b))
426 #define ARGB_TO_ULONG(a, r, g, b) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))
428 #define ALPHA_FROM_ULONG(color) ((color) >> 24)
429 #define RED_FROM_ULONG(color) (((color) >> 16) & 0xff)
430 #define GREEN_FROM_ULONG(color) (((color) >> 8) & 0xff)
431 #define BLUE_FROM_ULONG(color) ((color) & 0xff)
433 /* Do not change `* 0x101' in the following lines to `<< 8'. If
434 changed, image masks in 1-bit depth will not work. */
435 #define RED16_FROM_ULONG(color) (RED_FROM_ULONG(color) * 0x101)
436 #define GREEN16_FROM_ULONG(color) (GREEN_FROM_ULONG(color) * 0x101)
437 #define BLUE16_FROM_ULONG(color) (BLUE_FROM_ULONG(color) * 0x101)
439 /* this extends font backend font */
444 char *name
; /* postscript name, uniquely identifies on NS systems */
445 float width
; /* this and following metrics stored as float rather than int */
452 /* cgfont and synthItal are used only on OS X 10.3+ */
453 #if defined (NS_IMPL_COCOA) && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3)
455 #else /* GNUstep or OS X < 10.3 */
462 char bold
, ital
; /* convenience flags */
464 float voffset
; /* mean of ascender/descender offsets */
465 XCharStruct max_bounds
; /* 23 */
466 /* we compute glyph codes and metrics on-demand in blocks of 256 indexed
468 unsigned short **glyphs
; /* map unicode index to glyph */
469 struct font_metrics
**metrics
;
473 /* init'd in ns_initialize_display_info () */
474 struct ns_display_info
476 /* Chain of all ns_display_info structures. */
477 struct ns_display_info
*next
;
479 /* The generic display parameters corresponding to this NS display. */
480 struct terminal
*terminal
;
482 /* This is a cons cell of the form (NAME . FONT-LIST-CACHE).
483 The same cons cell also appears in ns_display_name_list. */
484 Lisp_Object name_list_element
;
486 /* The number of fonts loaded. */
489 /* Minimum width over all characters in all fonts in font_table. */
490 int smallest_char_width
;
492 /* Minimum font height over all fonts in font_table. */
493 int smallest_font_height
;
496 struct ns_bitmap_record
*bitmaps
;
501 struct image_cache
*image_cache
;
503 struct ns_color_table
*color_table
;
505 /* 23: Dimensions and DPI resolution of this screen */
509 /* 23: Mask of things that cause the mouse to be grabbed */
524 /* 23: The cursor to use for vertical scroll bars. */
525 Cursor vertical_scroll_bar_cursor
;
527 /* 23: most mouse face stuff moved in here (and reasonably so) */
528 int mouse_face_beg_row
, mouse_face_beg_col
;
529 int mouse_face_end_row
, mouse_face_end_col
;
530 int mouse_face_beg_x
, mouse_face_beg_y
;
531 int mouse_face_end_x
, mouse_face_end_y
;
532 int mouse_face_past_end
;
533 Lisp_Object mouse_face_window
;
534 int mouse_face_face_id
;
535 int mouse_face_deferred_gc
;
536 Lisp_Object mouse_face_overlay
;
537 FRAME_PTR mouse_face_mouse_frame
;
538 int mouse_face_mouse_x
, mouse_face_mouse_y
;
539 int mouse_face_defer
;
540 int mouse_face_hidden
;
541 int mouse_face_image_state
;
543 struct frame
*x_highlight_frame
;
544 struct frame
*x_focus_frame
;
547 /* This is a chain of structures for all the NS displays currently in use. */
548 extern struct ns_display_info
*x_display_list
;
550 extern Lisp_Object ns_display_name_list
;
551 extern struct ns_display_info
*ns_display_info_for_name ();
553 /* 23: FIXME: these functions (we defined in nsfns) are used in various
554 places, but no prototypes are provided */
555 struct ns_display_info
*check_x_display_info (Lisp_Object frame
);
556 FRAME_PTR
check_x_frame (Lisp_Object frame
);
564 NSColor
*current_cursor_color
;
565 NSColor
*desired_cursor_color
;
566 NSColor
*foreground_color
;
567 NSColor
*background_color
;
568 EmacsToolbar
*toolbar
;
572 void *current_cursor_color
;
573 void *desired_cursor_color
;
574 void *foreground_color
;
575 void *background_color
;
579 /* 23: NSCursors init'ed in initFrameFromEmacs */
581 Cursor nontext_cursor
;
582 Cursor modeline_cursor
;
584 Cursor hourglass_cursor
;
585 Cursor horizontal_drag_cursor
;
587 /* 23: NS-specific */
588 Cursor current_pointer
;
590 /* 23: lord knows why Emacs needs to know about our Window ids.. */
591 Window window_desc
, parent_desc
;
592 char explicit_parent
;
597 /* If a fontset is specified for this frame instead of font, this
598 value contains an ID of the fontset, else -1. */
599 int fontset
; /* only used with font_backend */
601 Lisp_Object icon_top
;
602 Lisp_Object icon_left
;
603 enum ns_cursor_types current_cursor
, desired_cursor
;
604 unsigned char last_inactive
;
606 /* The size of the extra width currently allotted for vertical
607 scroll bars, in pixels. */
608 int vertical_scroll_bar_extra
;
610 /* The height of the titlebar decoration (included in NSWindow's frame). */
613 /* The height of the toolbar if displayed, else 0. */
616 /* This is the Emacs structure for the NS display this frame is on. */
617 struct ns_display_info
*display_info
;
620 /* 23: this dummy decl now needed to support TTYs */
623 unsigned long background_pixel
;
624 unsigned long foreground_pixel
;
628 /* This gives the ns_display_info structure for the display F is on. */
629 #define FRAME_NS_DISPLAY_INFO(f) ((f)->output_data.ns->display_info)
630 /* the primacy of X must be constantly worked with... */
631 #define FRAME_X_DISPLAY_INFO(f) ((f)->output_data.ns->display_info)
632 #define FRAME_X_OUTPUT(f) ((f)->output_data.ns)
633 #define FRAME_NS_WINDOW(f) ((f)->output_data.ns->window_desc)
634 #define FRAME_X_WINDOW(f) ((f)->output_data.ns->window_desc)
636 /* This is the `Display *' which frame F is on. */
637 #define FRAME_NS_DISPLAY(f) (0)
638 #define FRAME_X_DISPLAY(f) (0)
640 #define FRAME_FOREGROUND_COLOR(f) ((f)->output_data.ns->foreground_color)
641 #define FRAME_BACKGROUND_COLOR(f) ((f)->output_data.ns->background_color)
643 #define FRAME_X_IMAGE_CACHE(F) FRAME_NS_DISPLAY_INFO ((F))->image_cache
645 #define NS_FACE_FOREGROUND(f) ((f)->foreground)
646 #define NS_FACE_BACKGROUND(f) ((f)->background)
647 #define FRAME_NS_TITLEBAR_HEIGHT(f) ((f)->output_data.ns->titlebar_height)
648 #define FRAME_NS_TOOLBAR_HEIGHT(f) ((f)->output_data.ns->toolbar_height)
650 #define FONT_WIDTH(f) ((f)->max_width)
651 #define FONT_HEIGHT(f) ((f)->height)
652 /*#define FONT_BASE(f) ((f)->ascent) */
653 #define FONT_BASE(f) (((struct nsfont_info *)f)->max_bounds.ascent)
654 /*#define FONT_DESCENT(f) ((f)->descent) */
655 #define FONT_DESCENT(f) (((struct nsfont_info *)f)->max_bounds.descent)
657 #define FRAME_DEFAULT_FACE(f) FACE_FROM_ID (f, DEFAULT_FACE_ID)
659 #define FRAME_NS_VIEW(f) ((f)->output_data.ns->view)
660 #define FRAME_CURSOR(f) ((f)->output_data.ns->current_cursor)
661 #define FRAME_CURSOR_COLOR(f) ((f)->output_data.ns->current_cursor_color)
662 #define FRAME_NEW_CURSOR_COLOR(f) ((f)->output_data.ns->desired_cursor_color)
663 #define FRAME_NEW_CURSOR(f) ((f)->output_data.ns->desired_cursor)
664 #define FRAME_POINTER_TYPE(f) ((f)->output_data.ns->current_pointer)
665 #define FRAME_LAST_INACTIVE(f) ((f)->output_data.ns->last_inactive)
667 #define FRAME_FONT(f) ((f)->output_data.ns->font)
670 #define XNS_SCROLL_BAR(vec) ((id) XSAVE_VALUE (vec)->pointer)
672 #define XNS_SCROLL_BAR(vec) XSAVE_VALUE (vec)->pointer
675 /* Compute pixel size for vertical scroll bars */
676 #define NS_SCROLL_BAR_WIDTH(f) \
677 (FRAME_HAS_VERTICAL_SCROLL_BARS (f) \
678 ? rint (FRAME_CONFIG_SCROLL_BAR_WIDTH (f) > 0 \
679 ? FRAME_CONFIG_SCROLL_BAR_WIDTH (f) \
680 : (FRAME_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f))) \
683 /* Difference btwn char-column-calculated and actual SB widths.
684 This is only a concern for rendering when SB on left. */
685 #define NS_SCROLL_BAR_ADJUST(w, f) \
686 (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (w) ? \
687 (FRAME_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f) \
688 - NS_SCROLL_BAR_WIDTH (f)) : 0)
690 /* XXX: fix for GNUstep inconsistent accounting for titlebar */
691 #ifdef NS_IMPL_GNUSTEP
692 #define NS_TOP_POS(f) ((f)->top_pos + 18)
694 #define NS_TOP_POS(f) ((f)->top_pos)
697 #define FRAME_NS_FONT_TABLE(f) (FRAME_NS_DISPLAY_INFO (f)->font_table)
699 #define FRAME_FONTSET(f) ((f)->output_data.ns->fontset)
702 #define FRAME_SMALLEST_CHAR_WIDTH(f) \
703 (FRAME_NS_DISPLAY_INFO (f)->smallest_char_width)
704 #define FRAME_SMALLEST_FONT_HEIGHT(f) \
705 (FRAME_NS_DISPLAY_INFO (f)->smallest_font_height)
706 #define FONT_TYPE_FOR_UNIBYTE(font, ch) 0
707 #define FONT_TYPE_FOR_MULTIBYTE(font, ch) 0
708 #define FRAME_BASELINE_OFFSET(f) ((f)->output_data.ns->baseline_offset)
709 #define BLACK_PIX_DEFAULT(f) 0x000000
710 #define WHITE_PIX_DEFAULT(f) 0xFFFFFF
712 /* First position where characters can be shown (instead of scrollbar, if
714 #define FIRST_CHAR_POSITION(f) \
715 (! (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f)) ? 0 \
716 : FRAME_SCROLL_BAR_COLS (f))
718 extern struct ns_display_info
*ns_term_init ();
719 extern void ns_term_shutdown (int sig
);
721 /* constants for text rendering */
722 #define NS_DUMPGLYPH_NORMAL 0
723 #define NS_DUMPGLYPH_CURSOR 1
724 #define NS_DUMPGLYPH_FOREGROUND 2
725 #define NS_DUMPGLYPH_MOUSEFACE 3
728 EXFUN (Fx_display_grayscale_p
, 1);
729 EXFUN (Fx_display_planes
, 1);
731 /* In nsfont, called from fontset.c */
732 extern void nsfont_make_fontset_for_font (Lisp_Object name
,
733 Lisp_Object font_object
);
735 /* In nsfont, for debugging */
737 void dump_glyphstring (struct glyph_string
*s
);
739 /* Implemented in nsterm, published in or needed from nsfns. */
740 extern Lisp_Object Qfontsize
;
741 extern Lisp_Object
ns_list_fonts (FRAME_PTR f
, Lisp_Object pattern
,
742 int size
, int maxnames
);
743 extern void ns_clear_frame (struct frame
*f
);
745 extern const char *ns_xlfd_to_fontname (const char *xlfd
);
747 extern void check_ns (void);
748 extern Lisp_Object
ns_map_event_to_object ();
749 extern Lisp_Object
ns_string_from_pasteboard ();
750 extern void ns_string_to_pasteboard ();
751 extern void nxatoms_of_nsselect ();
752 extern int ns_lisp_to_cursor_type ();
753 extern Lisp_Object
ns_cursor_type_to_lisp (int arg
);
754 extern Lisp_Object Qnone
;
756 /* XColor defined in dispextern.h (we use color_def->pixel = NSColor id), but
757 this causes an #include snafu, so we can't declare it. */
759 ns_defined_color (struct frame
*f
, char *name
, XColor
*color_def
, int alloc
,
763 extern Lisp_Object
ns_color_to_lisp (NSColor
*col
);
764 extern int ns_lisp_to_color (Lisp_Object color
, NSColor
**col
);
765 extern NSColor
*ns_lookup_indexed_color (unsigned long idx
, struct frame
*f
);
766 extern unsigned long ns_index_color (NSColor
*color
, struct frame
*f
);
767 extern void ns_free_indexed_color (unsigned long idx
, struct frame
*f
);
770 /* C access to ObjC functionality */
771 extern void ns_release_object (void *obj
);
772 extern void ns_retain_object (void *obj
);
773 extern void *ns_alloc_autorelease_pool ();
774 extern void ns_release_autorelease_pool ();
777 extern void update_frame_tool_bar (FRAME_PTR f
);
778 extern void free_frame_tool_bar (FRAME_PTR f
);
779 extern void find_and_call_menu_selection (FRAME_PTR f
,
780 int menu_bar_items_used
, Lisp_Object vector
, void *client_data
);
781 extern Lisp_Object
find_and_return_menu_selection (FRAME_PTR f
,
784 extern Lisp_Object
ns_popup_dialog (Lisp_Object position
, Lisp_Object contents
,
787 /* two more prototypes that should be moved to a more general include file */
788 extern void set_frame_menubar (struct frame
*f
, int first_time
, int deep_p
);
789 extern void x_set_window_size (struct frame
*f
, int change_grav
,
792 /* From nsimage.m, needed in image.c */
794 extern void *ns_image_from_XBM (unsigned char *bits
, int width
, int height
);
795 extern void *ns_image_for_XPM (int width
, int height
, int depth
);
796 extern void *ns_image_from_file (Lisp_Object file
);
797 extern int ns_load_image (struct frame
*f
, struct image
*img
,
798 Lisp_Object spec_file
, Lisp_Object spec_data
);
799 extern int ns_image_width (void *img
);
800 extern int ns_image_height (void *img
);
801 extern unsigned long ns_get_pixel (void *img
, int x
, int y
);
802 extern void ns_put_pixel (void *img
, int x
, int y
, unsigned long argb
);
803 extern void ns_set_alpha (void *img
, int x
, int y
, unsigned char a
);
805 /* This in nsterm.m */
806 extern unsigned long ns_get_rgb_color (struct frame
*f
,
807 float r
, float g
, float b
, float a
);
808 extern NSPoint last_mouse_motion_position
;
810 #ifdef NS_IMPL_GNUSTEP
811 extern char gnustep_base_version
[]; /* version tracking */
817 /* Screen max coordinate
818 Using larger coordinates causes movewindow/placewindow to abort */
819 #define SCREENMAX 16000
821 #define NS_SCROLL_BAR_WIDTH_DEFAULT [EmacsScroller scrollerWidth]
822 /* This is to match emacs on other platforms, ugly though it is. */
823 #define NS_SELECTION_COLOR_DEFAULT @"LightGoldenrod2";
824 #define RESIZE_HANDLE_SIZE 12
826 /* Little utility macros */
827 #define IN_BOUND(min, x, max) (((x) < (min)) \
828 ? (min) : (((x)>(max)) ? (max) : (x)))
829 #define SCREENMAXBOUND(x) (IN_BOUND (-SCREENMAX, x, SCREENMAX))
831 /* 23: needed somewhere... */
832 #define VERTICAL_SCROLL_BAR_WIDTH_TRIM (0)
837 /* arch-tag: 0a28b142-4ac1-4a81-a243-abcd82d9c4e5
838 (do not change this comment) */