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)cursor_blink_handler
: (NSTimer
*)cursorEntry
;
45 - (void)timeout_handler
: (NSTimer
*)timedEntry
;
46 - (BOOL
)fulfillService
: (NSString
*)name withArg
: (NSString
*)arg
;
50 /* ==========================================================================
54 ========================================================================== */
58 @interface EmacsView
: NSView
<NSTextInput
>
62 NSString
*workingText
;
63 BOOL processingCompose
;
65 struct frame
*emacsframe
;
67 int scrollbarsNeedingUpdate
;
68 EmacsToolbar
*toolbar
;
71 /* AppKit-side interface */
73 - toolbarClicked
: (id
)item
;
74 - toggleToolbar
: (id
)sender
;
75 - (void)keyDown
: (NSEvent
*)theEvent
;
76 - (void)mouseDown
: (NSEvent
*)theEvent
;
77 - (void)mouseUp
: (NSEvent
*)theEvent
;
78 - setMiniwindowImage
: (BOOL
)setMini
;
80 /* Emacs-side interface */
81 - initFrameFromEmacs
: (struct frame
*) f
;
82 - (void) setRows
: (int) r andColumns
: (int) c
;
83 - (void) setWindowClosing
: (BOOL
)closing
;
84 - (EmacsToolbar
*) toolbar
;
85 - (void) deleteWorkingText
;
89 /* Small utility used for processing resize events under Cocoa. */
90 @interface EmacsWindow
: NSWindow
97 /* ==========================================================================
99 The main menu implementation
101 ========================================================================== */
103 @interface EmacsMenu
: NSMenu
106 unsigned long keyEquivModMask
;
109 - initWithTitle
: (NSString
*)title frame
: (struct frame
*)f
;
110 - (void)setFrame
: (struct frame
*)f
;
111 - (void)menuNeedsUpdate
: (NSMenu
*)menu
; /* (delegate method) */
112 - (NSString
*)parseKeyEquiv
: (char *)key
;
113 - (NSMenuItem
*)addItemWithWidgetValue
: (void *)wvptr
;
114 - (void)fillWithWidgetValue
: (void *)wvptr
;
115 - (EmacsMenu
*)addSubmenuWithTitle
: (char *)title forFrame
: (struct frame
*)f
;
117 - (Lisp_Object
)runMenuAt
: (NSPoint
)p forFrame
: (struct frame
*)f
118 keymaps
: (int)keymaps
;
122 /* ==========================================================================
126 ========================================================================== */
130 @interface EmacsToolbar
: NSToolbar
132 EmacsView
*emacsView
;
133 NSMutableDictionary
*identifierToItem
;
134 NSMutableArray
*activeIdentifiers
;
135 NSArray
*prevIdentifiers
;
136 unsigned long enablement
, prevEnablement
;
138 - initForView
: (EmacsView
*)view withIdentifier
: (NSString
*)identifier
;
139 - (void) clearActive
;
141 - (void) addDisplayItemWithImage
: (EmacsImage
*)img idx
: (int)idx
142 helpText
: (char *)help
143 enabled
: (BOOL
)enabled
;
144 /* delegate methods */
145 - (NSToolbarItem
*)toolbar
: (NSToolbar
*)toolbar
146 itemForItemIdentifier
: (NSString
*)itemIdentifier
147 willBeInsertedIntoToolbar
: (BOOL
)flag
;
148 - (NSArray
*)toolbarDefaultItemIdentifiers
: (NSToolbar
*)toolbar
;
149 - (NSArray
*)toolbarAllowedItemIdentifiers
: (NSToolbar
*)toolbar
;
153 /* ==========================================================================
155 Message / question windows
157 ========================================================================== */
159 @interface EmacsDialogPanel
: NSPanel
161 NSTextField
*command
;
166 - initFromContents
: (Lisp_Object
)menu isQuestion
: (BOOL
)isQ
;
167 - addButton
: (char *)str value
: (Lisp_Object
)val row
: (int)row
;
168 - addString
: (char *)str row
: (int)row
;
170 - (Lisp_Object
)runDialogAt
: (NSPoint
)p
;
173 @interface EmacsTooltip
: NSObject
176 NSTextField
*textField
;
180 - (void) setText
: (char *)text
;
181 - (void) showAtX
: (int)x Y
: (int)y
for: (int)seconds
;
188 /* ==========================================================================
190 File open/save panels
191 This and next override methods to work around OS X behavior of
192 restarting application loop when user dismisses panel.
194 ========================================================================== */
196 @interface EmacsSavePanel
: NSSavePanel
200 @interface EmacsOpenPanel
: NSOpenPanel
205 @interface EmacsFileDelegate
: NSObject
208 - (BOOL
)panel
: (id
)sender isValidFilename
: (NSString
*)filename
;
209 - (BOOL
)panel
: (id
)sender shouldShowFilename
: (NSString
*)filename
;
210 - (NSString
*)panel
: (id
)sender userEnteredFilename
: (NSString
*)filename
211 confirmed
: (BOOL
)okFlag
;
215 /* ==========================================================================
219 ========================================================================== */
221 @interface EmacsImage
: NSImage
225 NSBitmapImageRep
*bmRep
; /* used for accessing pixel data */
226 unsigned char *pixmapData
[5]; /* shortcut to access pixel data */
228 NSColor
*stippleMask
;
230 + allocInitFromFile
: (Lisp_Object
)file
;
232 - imageListSetNext
: (id
)arg
;
235 - initFromXBM
: (unsigned char *)bits width
: (int)w height
: (int)h
237 - initFromSkipXBM
: (unsigned char *)bits width
: (int)w height
: (int)h
238 flip
: (BOOL
)flip length
: (int)length
;
239 - setXBMColor
: (NSColor
*)color
;
240 - initForXPMWithDepth
: (int)depth width
: (int)width height
: (int)height
;
241 - (void)setPixmapData
;
242 - (unsigned long)getPixelAtX
: (int)x Y
: (int)y
;
243 - (void)setPixelAtX
: (int)x Y
: (int)y toRed
: (unsigned char)r
244 green
: (unsigned char)g blue
: (unsigned char)b
245 alpha
:(unsigned char)a
;
246 - (void)setAlphaAtX
: (int)x Y
: (int)y to
: (unsigned char)a
;
247 - (NSColor
*)stippleMask
;
251 /* ==========================================================================
255 ========================================================================== */
257 @interface EmacsScroller
: NSScroller
261 NSResponder
*prevResponder
;
263 /* offset to the bottom of knob of last mouse down */
264 float last_mouse_offset
;
271 /* optimize against excessive positioning calls generated by emacs */
277 - initFrame
: (NSRect
)r window
: (Lisp_Object
)win
;
278 - (void)setFrame
: (NSRect
)r
;
281 - setPosition
: (int) position portion
: (int) portion whole
: (int) whole
;
282 - (int) checkSamePosition
: (int)position portion
: (int)portion
284 - (void) getMouseMotionPart
: (int *)part window
: (Lisp_Object
*)window
285 x
: (Lisp_Object
*)x y
: ( Lisp_Object
*)y
;
286 - (void) sendScrollEventAtLoc
: (float)loc fromEvent
: (NSEvent
*)e
;
287 - repeatScroll
: (NSTimer
*)sender
;
294 /* ==========================================================================
296 Rendering on Panther and above
298 ========================================================================== */
302 @interface EmacsGlyphStorage
: NSObject
<NSGlyphStorage
>
305 NSAttributedString
*attrStr
;
306 NSMutableDictionary
*dict
;
308 unsigned long maxChar
, maxGlyph
;
311 - initWithCapacity
: (unsigned long) c
;
312 - (void) setString
: (NSString
*)str font
: (NSFont
*)font
;
314 #endif /* NS_IMPL_COCOA */
317 /* ==========================================================================
319 Running the preferences window
321 ========================================================================== */
323 @interface EmacsPrefsController
: NSObject
326 IBOutlet NSWindow
*prefsWindow
;
327 IBOutlet NSPopUpButton
*alternateModMenu
;
328 IBOutlet NSPopUpButton
*commandModMenu
;
330 IBOutlet NSPopUpButton
*controlModMenu
;
331 IBOutlet NSPopUpButton
*functionModMenu
;
333 IBOutlet NSMatrix
*cursorTypeMatrix
;
334 IBOutlet NSSlider
*cursorBlinkSlider
;
335 IBOutlet NSSlider
*expandSpaceSlider
;
337 IBOutlet NSButton
*smoothFontsCheck
;
338 IBOutlet NSButton
*useQuickdrawCheck
;
339 IBOutlet NSButton
*useSysHiliteCheck
;
340 Lisp_Object prevUseHighlightColor
;
342 float prevExpandSpace
;
345 - (IBAction
)cancel
: (id
)sender
;
346 - (IBAction
)ok
: (id
)sender
;
347 - (IBAction
)resetToDefaults
: (id
)sender
;
348 - (IBAction
)runHelp
: (id
)sender
;
349 - (IBAction
)setColors
: (id
)sender
;
350 - (IBAction
)setDefaultFont
: (id
)sender
;
352 - (void) showForFrame
: (struct frame
*)f
;
353 - (void) setPanelFromValues
;
354 - (void) setValuesFromPanel
;
357 extern NSArray
*ns_send_types
, *ns_return_types
;
358 extern EmacsMenu
*mainMenu
, *svcsMenu
, *dockMenu
;
360 /* Apple removed the declaration, but kept the implementation */
361 #if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_4
362 @interface
NSApplication (EmacsApp
)
363 - (void)setAppleMenu
: (NSMenu
*)menu
;
367 #ifndef NS_HAVE_INTEGER
368 typedef long NSInteger
;
369 typedef unsigned long NSUInteger
;
370 #endif /* not NS_HAVE_INTEGER */
372 #endif /* __OBJC__ */
376 /* ==========================================================================
380 ========================================================================== */
392 /* could use list to store these, but rest of emacs has a big infrastructure
393 for managing a table of bitmap "records" */
394 struct ns_bitmap_record
403 int height
, width
, depth
;
406 /* this to map between emacs color indices and NSColor objects */
407 struct ns_color_table
413 NSMutableSet
*empty_indices
;
419 #define NS_COLOR_CAPACITY 256
421 #define RGB_TO_ULONG(r, g, b) (((r) << 16) | ((g) << 8) | (b))
422 #define ARGB_TO_ULONG(a, r, g, b) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))
424 #define ALPHA_FROM_ULONG(color) ((color) >> 24)
425 #define RED_FROM_ULONG(color) (((color) >> 16) & 0xff)
426 #define GREEN_FROM_ULONG(color) (((color) >> 8) & 0xff)
427 #define BLUE_FROM_ULONG(color) ((color) & 0xff)
429 /* Do not change `* 0x101' in the following lines to `<< 8'. If
430 changed, image masks in 1-bit depth will not work. */
431 #define RED16_FROM_ULONG(color) (RED_FROM_ULONG(color) * 0x101)
432 #define GREEN16_FROM_ULONG(color) (GREEN_FROM_ULONG(color) * 0x101)
433 #define BLUE16_FROM_ULONG(color) (BLUE_FROM_ULONG(color) * 0x101)
435 /* this extends font backend font */
440 char *name
; /* postscript name, uniquely identifies on NS systems */
441 float width
; /* this and following metrics stored as float rather than int */
448 /* cgfont and synthItal are used only on OS X 10.3+ */
449 #if defined (NS_IMPL_COCOA) && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3)
451 #else /* GNUstep or OS X < 10.3 */
458 char bold
, ital
; /* convenience flags */
460 float voffset
; /* mean of ascender/descender offsets */
461 XCharStruct max_bounds
; /* 23 */
462 /* we compute glyph codes and metrics on-demand in blocks of 256 indexed
464 unsigned short **glyphs
; /* map unicode index to glyph */
465 struct font_metrics
**metrics
;
469 /* init'd in ns_initialize_display_info () */
470 struct ns_display_info
472 /* Chain of all ns_display_info structures. */
473 struct ns_display_info
*next
;
475 /* The generic display parameters corresponding to this NS display. */
476 struct terminal
*terminal
;
478 /* This is a cons cell of the form (NAME . FONT-LIST-CACHE).
479 The same cons cell also appears in ns_display_name_list. */
480 Lisp_Object name_list_element
;
482 /* The number of fonts loaded. */
485 /* Minimum width over all characters in all fonts in font_table. */
486 int smallest_char_width
;
488 /* Minimum font height over all fonts in font_table. */
489 int smallest_font_height
;
492 struct ns_bitmap_record
*bitmaps
;
497 struct image_cache
*image_cache
;
499 struct ns_color_table
*color_table
;
501 /* 23: Dimensions and DPI resolution of this screen */
505 /* 23: Mask of things that cause the mouse to be grabbed */
520 /* 23: The cursor to use for vertical scroll bars. */
521 Cursor vertical_scroll_bar_cursor
;
523 /* 23: most mouse face stuff moved in here (and reasonably so) */
524 int mouse_face_beg_row
, mouse_face_beg_col
;
525 int mouse_face_end_row
, mouse_face_end_col
;
526 int mouse_face_beg_x
, mouse_face_beg_y
;
527 int mouse_face_end_x
, mouse_face_end_y
;
528 int mouse_face_past_end
;
529 Lisp_Object mouse_face_window
;
530 int mouse_face_face_id
;
531 int mouse_face_deferred_gc
;
532 Lisp_Object mouse_face_overlay
;
533 FRAME_PTR mouse_face_mouse_frame
;
534 int mouse_face_mouse_x
, mouse_face_mouse_y
;
535 int mouse_face_defer
;
536 int mouse_face_hidden
;
537 int mouse_face_image_state
;
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 ();
549 /* 23: FIXME: these functions (we defined in nsfns) are used in various
550 places, but no prototypes are provided */
551 struct ns_display_info
*check_x_display_info (Lisp_Object frame
);
552 FRAME_PTR
check_x_frame (Lisp_Object frame
);
560 NSColor
*current_cursor_color
;
561 NSColor
*desired_cursor_color
;
562 NSColor
*foreground_color
;
563 NSColor
*background_color
;
564 EmacsToolbar
*toolbar
;
568 void *current_cursor_color
;
569 void *desired_cursor_color
;
570 void *foreground_color
;
571 void *background_color
;
575 /* 23: NSCursors init'ed in initFrameFromEmacs */
577 Cursor nontext_cursor
;
578 Cursor modeline_cursor
;
580 Cursor hourglass_cursor
;
581 Cursor horizontal_drag_cursor
;
583 /* 23: NS-specific */
584 Cursor current_pointer
;
586 /* 23: lord knows why Emacs needs to know about our Window ids.. */
587 Window window_desc
, parent_desc
;
588 char explicit_parent
;
593 /* If a fontset is specified for this frame instead of font, this
594 value contains an ID of the fontset, else -1. */
595 int fontset
; /* only used with font_backend */
597 Lisp_Object icon_top
;
598 Lisp_Object icon_left
;
599 enum ns_cursor_types current_cursor
, desired_cursor
;
600 unsigned char last_inactive
;
602 /* The size of the extra width currently allotted for vertical
603 scroll bars, in pixels. */
604 int vertical_scroll_bar_extra
;
606 /* The height of the titlebar decoration (included in NSWindow's frame). */
609 /* The height of the toolbar if displayed, else 0. */
612 /* This is the Emacs structure for the NS display this frame is on. */
613 struct ns_display_info
*display_info
;
616 /* 23: this dummy decl now 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)
636 #define FRAME_FOREGROUND_COLOR(f) ((f)->output_data.ns->foreground_color)
637 #define FRAME_BACKGROUND_COLOR(f) ((f)->output_data.ns->background_color)
639 #define FRAME_X_IMAGE_CACHE(F) FRAME_NS_DISPLAY_INFO ((F))->image_cache
641 #define NS_FACE_FOREGROUND(f) ((f)->foreground)
642 #define NS_FACE_BACKGROUND(f) ((f)->background)
643 #define FRAME_NS_TITLEBAR_HEIGHT(f) ((f)->output_data.ns->titlebar_height)
644 #define FRAME_NS_TOOLBAR_HEIGHT(f) ((f)->output_data.ns->toolbar_height)
646 #define FONT_WIDTH(f) ((f)->max_width)
647 #define FONT_HEIGHT(f) ((f)->height)
648 /*#define FONT_BASE(f) ((f)->ascent) */
649 #define FONT_BASE(f) (((struct nsfont_info *)f)->max_bounds.ascent)
650 /*#define FONT_DESCENT(f) ((f)->descent) */
651 #define FONT_DESCENT(f) (((struct nsfont_info *)f)->max_bounds.descent)
653 #define FRAME_DEFAULT_FACE(f) FACE_FROM_ID (f, DEFAULT_FACE_ID)
655 #define FRAME_NS_VIEW(f) ((f)->output_data.ns->view)
656 #define FRAME_CURSOR(f) ((f)->output_data.ns->current_cursor)
657 #define FRAME_CURSOR_COLOR(f) ((f)->output_data.ns->current_cursor_color)
658 #define FRAME_NEW_CURSOR_COLOR(f) ((f)->output_data.ns->desired_cursor_color)
659 #define FRAME_NEW_CURSOR(f) ((f)->output_data.ns->desired_cursor)
660 #define FRAME_POINTER_TYPE(f) ((f)->output_data.ns->current_pointer)
661 #define FRAME_LAST_INACTIVE(f) ((f)->output_data.ns->last_inactive)
663 #define FRAME_FONT(f) ((f)->output_data.ns->font)
666 #define XNS_SCROLL_BAR(vec) ((id) XSAVE_VALUE (vec)->pointer)
668 #define XNS_SCROLL_BAR(vec) XSAVE_VALUE (vec)->pointer
671 /* Compute pixel size for vertical scroll bars */
672 #define NS_SCROLL_BAR_WIDTH(f) \
673 (FRAME_HAS_VERTICAL_SCROLL_BARS (f) \
674 ? rint (FRAME_CONFIG_SCROLL_BAR_WIDTH (f) > 0 \
675 ? FRAME_CONFIG_SCROLL_BAR_WIDTH (f) \
676 : (FRAME_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f))) \
679 /* Difference btwn char-column-calculated and actual SB widths.
680 This is only a concern for rendering when SB on left. */
681 #define NS_SCROLL_BAR_ADJUST(w, f) \
682 (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (w) ? \
683 (FRAME_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f) \
684 - NS_SCROLL_BAR_WIDTH (f)) : 0)
686 /* XXX: fix for GNUstep inconsistent accounting for titlebar */
687 #ifdef NS_IMPL_GNUSTEP
688 #define NS_TOP_POS(f) ((f)->top_pos + 18)
690 #define NS_TOP_POS(f) ((f)->top_pos)
693 #define FRAME_NS_FONT_TABLE(f) (FRAME_NS_DISPLAY_INFO (f)->font_table)
695 #define FRAME_FONTSET(f) ((f)->output_data.ns->fontset)
698 #define FRAME_SMALLEST_CHAR_WIDTH(f) \
699 (FRAME_NS_DISPLAY_INFO (f)->smallest_char_width)
700 #define FRAME_SMALLEST_FONT_HEIGHT(f) \
701 (FRAME_NS_DISPLAY_INFO (f)->smallest_font_height)
702 #define FONT_TYPE_FOR_UNIBYTE(font, ch) 0
703 #define FONT_TYPE_FOR_MULTIBYTE(font, ch) 0
704 #define FRAME_BASELINE_OFFSET(f) ((f)->output_data.ns->baseline_offset)
705 #define BLACK_PIX_DEFAULT(f) 0x000000
706 #define WHITE_PIX_DEFAULT(f) 0xFFFFFF
708 /* First position where characters can be shown (instead of scrollbar, if
710 #define FIRST_CHAR_POSITION(f) \
711 (! (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f)) ? 0 \
712 : FRAME_SCROLL_BAR_COLS (f))
714 extern struct ns_display_info
*ns_term_init ();
715 extern void ns_term_shutdown (int sig
);
717 /* constants for text rendering */
718 #define NS_DUMPGLYPH_NORMAL 0
719 #define NS_DUMPGLYPH_CURSOR 1
720 #define NS_DUMPGLYPH_FOREGROUND 2
721 #define NS_DUMPGLYPH_MOUSEFACE 3
724 EXFUN (Fx_display_grayscale_p
, 1);
725 EXFUN (Fx_display_planes
, 1);
727 /* In nsfont, called from fontset.c */
728 extern void nsfont_make_fontset_for_font (Lisp_Object name
,
729 Lisp_Object font_object
);
731 /* In nsfont, for debugging */
733 void dump_glyphstring (struct glyph_string
*s
);
735 /* Implemented in nsterm, published in or needed from nsfns. */
736 extern Lisp_Object Qfontsize
;
737 extern Lisp_Object
ns_list_fonts (FRAME_PTR f
, Lisp_Object pattern
,
738 int size
, int maxnames
);
739 extern void ns_clear_frame (struct frame
*f
);
741 extern const char *ns_xlfd_to_fontname (const char *xlfd
);
743 extern void check_ns (void);
744 extern Lisp_Object
ns_map_event_to_object ();
745 extern Lisp_Object
ns_string_from_pasteboard ();
746 extern void ns_string_to_pasteboard ();
747 extern void nxatoms_of_nsselect ();
748 extern int ns_lisp_to_cursor_type ();
749 extern Lisp_Object
ns_cursor_type_to_lisp (int arg
);
750 extern Lisp_Object Qnone
;
752 /* XColor defined in dispextern.h (we use color_def->pixel = NSColor id), but
753 this causes an #include snafu, so we can't declare it. */
755 ns_defined_color (struct frame
*f
, char *name
, XColor
*color_def
, int alloc
,
759 extern Lisp_Object
ns_color_to_lisp (NSColor
*col
);
760 extern int ns_lisp_to_color (Lisp_Object color
, NSColor
**col
);
761 extern NSColor
*ns_lookup_indexed_color (unsigned long idx
, struct frame
*f
);
762 extern unsigned long ns_index_color (NSColor
*color
, struct frame
*f
);
763 extern void ns_free_indexed_color (unsigned long idx
, struct frame
*f
);
766 /* C access to ObjC functionality */
767 extern void ns_release_object (void *obj
);
768 extern void ns_retain_object (void *obj
);
769 extern void *ns_alloc_autorelease_pool ();
770 extern void ns_release_autorelease_pool ();
773 extern void update_frame_tool_bar (FRAME_PTR f
);
774 extern void free_frame_tool_bar (FRAME_PTR f
);
775 extern void find_and_call_menu_selection (FRAME_PTR f
,
776 int menu_bar_items_used
, Lisp_Object vector
, void *client_data
);
777 extern Lisp_Object
find_and_return_menu_selection (FRAME_PTR f
,
780 extern Lisp_Object
ns_popup_dialog (Lisp_Object position
, Lisp_Object contents
,
783 /* two more prototypes that should be moved to a more general include file */
784 extern void set_frame_menubar (struct frame
*f
, int first_time
, int deep_p
);
785 extern void x_set_window_size (struct frame
*f
, int change_grav
,
788 /* From nsimage.m, needed in image.c */
790 extern void *ns_image_from_XBM (unsigned char *bits
, int width
, int height
);
791 extern void *ns_image_for_XPM (int width
, int height
, int depth
);
792 extern void *ns_image_from_file (Lisp_Object file
);
793 extern int ns_load_image (struct frame
*f
, struct image
*img
,
794 Lisp_Object spec_file
, Lisp_Object spec_data
);
795 extern int ns_image_width (void *img
);
796 extern int ns_image_height (void *img
);
797 extern unsigned long ns_get_pixel (void *img
, int x
, int y
);
798 extern void ns_put_pixel (void *img
, int x
, int y
, unsigned long argb
);
799 extern void ns_set_alpha (void *img
, int x
, int y
, unsigned char a
);
801 /* This in nsterm.m */
802 extern unsigned long ns_get_rgb_color (struct frame
*f
,
803 float r
, float g
, float b
, float a
);
804 extern NSPoint last_mouse_motion_position
;
806 #ifdef NS_IMPL_GNUSTEP
807 extern char gnustep_base_version
[]; /* version tracking */
813 /* Screen max coordinate
814 Using larger coordinates causes movewindow/placewindow to abort */
815 #define SCREENMAX 16000
817 #define NS_SCROLL_BAR_WIDTH_DEFAULT [EmacsScroller scrollerWidth]
818 /* This is to match emacs on other platforms, ugly though it is. */
819 #define NS_SELECTION_COLOR_DEFAULT @"LightGoldenrod2";
820 #define RESIZE_HANDLE_SIZE 12
822 /* Little utility macros */
823 #define IN_BOUND(min, x, max) (((x) < (min)) \
824 ? (min) : (((x)>(max)) ? (max) : (x)))
825 #define SCREENMAXBOUND(x) (IN_BOUND (-SCREENMAX, x, SCREENMAX))
827 /* 23: needed somewhere... */
828 #define VERTICAL_SCROLL_BAR_WIDTH_TRIM (0)
833 /* arch-tag: 0a28b142-4ac1-4a81-a243-abcd82d9c4e5
834 (do not change this comment) */