* lisp/emacs-lisp/checkdoc.el (checkdoc-syntax-table): Fix last change.
[emacs.git] / src / nsterm.h
blob7ee960bd7a649efb3ee33ac77d706068ae2a17fe
1 /* Definitions and headers for communication with NeXT/Open/GNUstep API.
2 Copyright (C) 1989, 1993, 2005, 2008, 2009, 2010 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"
21 #include "frame.h"
22 #include "character.h"
23 #include "font.h"
24 #include "sysselect.h"
26 #ifdef HAVE_NS
28 #ifdef __OBJC__
30 /* ==========================================================================
32 The Emacs application
34 ========================================================================== */
36 /* We override sendEvent: as a means to stop/start the event loop */
37 @interface EmacsApp : NSApplication
40 - (void)logNotification: (NSNotification *)notification;
41 - (void)sendEvent: (NSEvent *)theEvent;
42 - (void)showPreferencesWindow: (id)sender;
43 - (BOOL) openFile: (NSString *)fileName;
44 - (void)fd_handler: (NSTimer *) fdEntry;
45 - (void)timeout_handler: (NSTimer *)timedEntry;
46 - (BOOL)fulfillService: (NSString *)name withArg: (NSString *)arg;
47 @end
50 /* ==========================================================================
52 The main Emacs view
54 ========================================================================== */
56 @class EmacsToolbar;
58 @interface EmacsView : NSView <NSTextInput> /* 10.6+: NSWindowDelegate */
60 char *old_title;
61 BOOL windowClosing;
62 NSString *workingText;
63 BOOL processingCompose;
64 @public
65 struct frame *emacsframe;
66 int rows, cols;
67 int scrollbarsNeedingUpdate;
68 EmacsToolbar *toolbar;
71 /* AppKit-side interface */
72 - menuDown: sender;
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;
87 #ifdef NS_IMPL_GNUSTEP
88 /* Not declared, but useful. */
89 - (void) unlockFocusNeedsFlush: (BOOL)needs;
90 #endif
91 @end
94 /* Small utility used for processing resize events under Cocoa. */
95 @interface EmacsWindow : NSWindow
97 NSPoint grabOffset;
99 @end
102 /* ==========================================================================
104 The main menu implementation
106 ========================================================================== */
108 @interface EmacsMenu : NSMenu /* 10.6+: <NSMenuDelegate> */
110 struct frame *frame;
111 unsigned long keyEquivModMask;
114 - initWithTitle: (NSString *)title frame: (struct frame *)f;
115 - (void)setFrame: (struct frame *)f;
116 - (void)menuNeedsUpdate: (NSMenu *)menu; /* (delegate method) */
117 - (NSString *)parseKeyEquiv: (const char *)key;
118 - (NSMenuItem *)addItemWithWidgetValue: (void *)wvptr;
119 - (void)fillWithWidgetValue: (void *)wvptr;
120 - (EmacsMenu *)addSubmenuWithTitle: (const char *)title forFrame: (struct frame *)f;
121 - (void) clear;
122 - (Lisp_Object)runMenuAt: (NSPoint)p forFrame: (struct frame *)f
123 keymaps: (int)keymaps;
124 @end
127 /* ==========================================================================
129 Toolbar
131 ========================================================================== */
133 @class EmacsImage;
135 @interface EmacsToolbar : NSToolbar /* 10.6+: <NSToolbarDelegate> */
137 EmacsView *emacsView;
138 NSMutableDictionary *identifierToItem;
139 NSMutableArray *activeIdentifiers;
140 NSArray *prevIdentifiers;
141 unsigned long enablement, prevEnablement;
143 - initForView: (EmacsView *)view withIdentifier: (NSString *)identifier;
144 - (void) clearActive;
145 - (BOOL) changed;
146 - (void) addDisplayItemWithImage: (EmacsImage *)img idx: (int)idx
147 helpText: (const char *)help
148 enabled: (BOOL)enabled;
149 /* delegate methods */
150 - (NSToolbarItem *)toolbar: (NSToolbar *)toolbar
151 itemForItemIdentifier: (NSString *)itemIdentifier
152 willBeInsertedIntoToolbar: (BOOL)flag;
153 - (NSArray *)toolbarDefaultItemIdentifiers: (NSToolbar *)toolbar;
154 - (NSArray *)toolbarAllowedItemIdentifiers: (NSToolbar *)toolbar;
155 @end
158 /* ==========================================================================
160 Message / question windows
162 ========================================================================== */
164 @interface EmacsDialogPanel : NSPanel
166 NSTextField *command;
167 NSTextField *title;
168 NSMatrix *matrix;
169 int rows, cols;
171 - initFromContents: (Lisp_Object)menu isQuestion: (BOOL)isQ;
172 - addButton: (char *)str value: (Lisp_Object)val row: (int)row;
173 - addString: (char *)str row: (int)row;
174 - addSplit;
175 - (Lisp_Object)runDialogAt: (NSPoint)p;
176 @end
178 @interface EmacsTooltip : NSObject /* 10.6+: <NSWindowDelegate> */
180 NSWindow *win;
181 NSTextField *textField;
182 NSTimer *timer;
184 - init;
185 - (void) setText: (char *)text;
186 - (void) showAtX: (int)x Y: (int)y for: (int)seconds;
187 - (void) hide;
188 - (BOOL) isActive;
189 - (NSRect) frame;
190 @end
193 /* ==========================================================================
195 File open/save panels
196 This and next override methods to work around OS X behavior of
197 restarting application loop when user dismisses panel.
199 ========================================================================== */
201 @interface EmacsSavePanel : NSSavePanel
204 @end
205 @interface EmacsOpenPanel : NSOpenPanel
208 @end
210 @interface EmacsFileDelegate : NSObject
213 - (BOOL)panel: (id)sender isValidFilename: (NSString *)filename;
214 - (BOOL)panel: (id)sender shouldShowFilename: (NSString *)filename;
215 - (NSString *)panel: (id)sender userEnteredFilename: (NSString *)filename
216 confirmed: (BOOL)okFlag;
217 @end
220 /* ==========================================================================
222 Images and stippling
224 ========================================================================== */
226 @interface EmacsImage : NSImage
228 id imageListNext;
229 int refCount;
230 NSBitmapImageRep *bmRep; /* used for accessing pixel data */
231 unsigned char *pixmapData[5]; /* shortcut to access pixel data */
232 BOOL onTiger;
233 NSColor *stippleMask;
235 + allocInitFromFile: (Lisp_Object)file;
236 - reference;
237 - imageListSetNext: (id)arg;
238 - imageListNext;
239 - (void)dealloc;
240 - initFromXBM: (unsigned char *)bits width: (int)w height: (int)h
241 flip: (BOOL)flip;
242 - initFromSkipXBM: (unsigned char *)bits width: (int)w height: (int)h
243 flip: (BOOL)flip length: (int)length;
244 - setXBMColor: (NSColor *)color;
245 - initForXPMWithDepth: (int)depth width: (int)width height: (int)height;
246 - (void)setPixmapData;
247 - (unsigned long)getPixelAtX: (int)x Y: (int)y;
248 - (void)setPixelAtX: (int)x Y: (int)y toRed: (unsigned char)r
249 green: (unsigned char)g blue: (unsigned char)b
250 alpha:(unsigned char)a;
251 - (void)setAlphaAtX: (int)x Y: (int)y to: (unsigned char)a;
252 - (NSColor *)stippleMask;
253 @end
256 /* ==========================================================================
258 Scrollbars
260 ========================================================================== */
262 @interface EmacsScroller : NSScroller
264 Lisp_Object win;
265 struct frame *frame;
266 NSResponder *prevResponder;
268 /* offset to the bottom of knob of last mouse down */
269 float last_mouse_offset;
270 float min_portion;
271 int pixel_height;
272 int last_hit_part;
274 BOOL condemned;
276 /* optimize against excessive positioning calls generated by emacs */
277 int em_position;
278 int em_portion;
279 int em_whole;
282 - initFrame: (NSRect )r window: (Lisp_Object)win;
283 - (void)setFrame: (NSRect)r;
284 - (void)dealloc;
286 - setPosition: (int) position portion: (int) portion whole: (int) whole;
287 - (int) checkSamePosition: (int)position portion: (int)portion
288 whole: (int)whole;
289 - (void) getMouseMotionPart: (int *)part window: (Lisp_Object *)window
290 x: (Lisp_Object *)x y: ( Lisp_Object *)y;
291 - (void) sendScrollEventAtLoc: (float)loc fromEvent: (NSEvent *)e;
292 - repeatScroll: (NSTimer *)sender;
293 - condemn;
294 - reprieve;
295 - judge;
296 @end
299 /* ==========================================================================
301 Rendering on Panther and above
303 ========================================================================== */
305 #ifdef NS_IMPL_COCOA
306 /* rendering util */
307 @interface EmacsGlyphStorage : NSObject <NSGlyphStorage>
309 @public
310 NSAttributedString *attrStr;
311 NSMutableDictionary *dict;
312 CGGlyph *cglyphs;
313 unsigned long maxChar, maxGlyph;
314 long i, len;
316 - initWithCapacity: (unsigned long) c;
317 - (void) setString: (NSString *)str font: (NSFont *)font;
318 @end
319 #endif /* NS_IMPL_COCOA */
321 extern NSArray *ns_send_types, *ns_return_types;
322 extern NSString *ns_app_name;
323 extern EmacsMenu *mainMenu, *svcsMenu, *dockMenu;
325 /* Apple removed the declaration, but kept the implementation */
326 #if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
327 @interface NSApplication (EmacsApp)
328 - (void)setAppleMenu: (NSMenu *)menu;
329 @end
330 #endif
332 #ifndef NS_HAVE_NSINTEGER
333 #if defined(__LP64__) && __LP64__
334 typedef double CGFloat;
335 typedef long NSInteger;
336 typedef unsigned long NSUInteger;
337 #else
338 typedef float CGFloat;
339 typedef int NSInteger;
340 typedef unsigned int NSUInteger;
341 #endif /* not LP64 */
342 #endif /* not NS_HAVE_NSINTEGER */
344 #endif /* __OBJC__ */
348 /* ==========================================================================
350 Non-OO stuff
352 ========================================================================== */
354 /* Special keycodes that we pass down the event chain */
355 #define KEY_NS_POWER_OFF ((1<<28)|(0<<16)|1)
356 #define KEY_NS_OPEN_FILE ((1<<28)|(0<<16)|2)
357 #define KEY_NS_OPEN_TEMP_FILE ((1<<28)|(0<<16)|3)
358 #define KEY_NS_DRAG_FILE ((1<<28)|(0<<16)|4)
359 #define KEY_NS_DRAG_COLOR ((1<<28)|(0<<16)|5)
360 #define KEY_NS_DRAG_TEXT ((1<<28)|(0<<16)|6)
361 #define KEY_NS_CHANGE_FONT ((1<<28)|(0<<16)|7)
362 #define KEY_NS_OPEN_FILE_LINE ((1<<28)|(0<<16)|8)
363 #define KEY_NS_PUT_WORKING_TEXT ((1<<28)|(0<<16)|9)
364 #define KEY_NS_UNPUT_WORKING_TEXT ((1<<28)|(0<<16)|10)
365 #define KEY_NS_SPI_SERVICE_CALL ((1<<28)|(0<<16)|11)
366 #define KEY_NS_NEW_FRAME ((1<<28)|(0<<16)|12)
367 #define KEY_NS_TOGGLE_TOOLBAR ((1<<28)|(0<<16)|13)
368 #define KEY_NS_SHOW_PREFS ((1<<28)|(0<<16)|14)
370 /* could use list to store these, but rest of emacs has a big infrastructure
371 for managing a table of bitmap "records" */
372 struct ns_bitmap_record
374 #ifdef __OBJC__
375 EmacsImage *img;
376 #else
377 void *img;
378 #endif
379 char *file;
380 int refcount;
381 int height, width, depth;
384 /* this to map between emacs color indices and NSColor objects */
385 struct ns_color_table
387 unsigned int size;
388 unsigned int avail;
389 #ifdef __OBJC__
390 NSColor **colors;
391 NSMutableSet *empty_indices;
392 #else
393 void **items;
394 void *availIndices;
395 #endif
397 #define NS_COLOR_CAPACITY 256
399 #define RGB_TO_ULONG(r, g, b) (((r) << 16) | ((g) << 8) | (b))
400 #define ARGB_TO_ULONG(a, r, g, b) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))
402 #define ALPHA_FROM_ULONG(color) ((color) >> 24)
403 #define RED_FROM_ULONG(color) (((color) >> 16) & 0xff)
404 #define GREEN_FROM_ULONG(color) (((color) >> 8) & 0xff)
405 #define BLUE_FROM_ULONG(color) ((color) & 0xff)
407 /* Do not change `* 0x101' in the following lines to `<< 8'. If
408 changed, image masks in 1-bit depth will not work. */
409 #define RED16_FROM_ULONG(color) (RED_FROM_ULONG(color) * 0x101)
410 #define GREEN16_FROM_ULONG(color) (GREEN_FROM_ULONG(color) * 0x101)
411 #define BLUE16_FROM_ULONG(color) (BLUE_FROM_ULONG(color) * 0x101)
413 /* this extends font backend font */
414 struct nsfont_info
416 struct font font;
418 char *name; /* postscript name, uniquely identifies on NS systems */
419 float width; /* this and following metrics stored as float rather than int */
420 float height;
421 float underpos;
422 float underwidth;
423 float size;
424 #ifdef __OBJC__
425 NSFont *nsfont;
426 /* cgfont and synthItal are used only on OS X 10.3+ */
427 #if defined (NS_IMPL_COCOA) && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3)
428 CGFontRef cgfont;
429 #else /* GNUstep or OS X < 10.3 */
430 void *cgfont;
431 #endif
432 #else /* ! OBJC */
433 void *nsfont;
434 void *cgfont;
435 #endif
436 char bold, ital; /* convenience flags */
437 char synthItal;
438 float voffset; /* mean of ascender/descender offsets */
439 XCharStruct max_bounds;
440 /* we compute glyph codes and metrics on-demand in blocks of 256 indexed
441 by hibyte, lobyte */
442 unsigned short **glyphs; /* map unicode index to glyph */
443 struct font_metrics **metrics;
447 /* init'd in ns_initialize_display_info () */
448 struct ns_display_info
450 /* Chain of all ns_display_info structures. */
451 struct ns_display_info *next;
453 /* The generic display parameters corresponding to this NS display. */
454 struct terminal *terminal;
456 /* This is a cons cell of the form (NAME . FONT-LIST-CACHE).
457 The same cons cell also appears in ns_display_name_list. */
458 Lisp_Object name_list_element;
460 /* The number of fonts loaded. */
461 int n_fonts;
463 /* Minimum width over all characters in all fonts in font_table. */
464 int smallest_char_width;
466 /* Minimum font height over all fonts in font_table. */
467 int smallest_font_height;
469 struct ns_bitmap_record *bitmaps;
470 int bitmaps_size;
471 int bitmaps_last;
473 struct image_cache *image_cache;
475 struct ns_color_table *color_table;
477 /* DPI resolution of this screen */
478 double resx, resy;
480 /* Mask of things that cause the mouse to be grabbed */
481 int grabbed;
483 int n_planes;
485 int color_p;
487 Window root_window;
489 /* Xism */
490 XrmDatabase xrdb;
492 /* The cursor to use for vertical scroll bars. */
493 Cursor vertical_scroll_bar_cursor;
495 /* Information about the range of text currently shown in
496 mouse-face. */
497 Mouse_HLInfo mouse_highlight;
499 struct frame *x_highlight_frame;
500 struct frame *x_focus_frame;
503 /* This is a chain of structures for all the NS displays currently in use. */
504 extern struct ns_display_info *x_display_list;
506 extern Lisp_Object ns_display_name_list;
507 extern struct ns_display_info *ns_display_info_for_name ();
509 struct ns_display_info *check_x_display_info (Lisp_Object frame);
510 FRAME_PTR check_x_frame (Lisp_Object frame);
513 struct ns_output
515 #ifdef __OBJC__
516 EmacsView *view;
517 id miniimage;
518 NSColor *cursor_color;
519 NSColor *foreground_color;
520 NSColor *background_color;
521 EmacsToolbar *toolbar;
522 #else
523 void *view;
524 void *miniimage;
525 void *cursor_color;
526 void *foreground_color;
527 void *background_color;
528 void *toolbar;
529 #endif
531 /* NSCursors init'ed in initFrameFromEmacs */
532 Cursor text_cursor;
533 Cursor nontext_cursor;
534 Cursor modeline_cursor;
535 Cursor hand_cursor;
536 Cursor hourglass_cursor;
537 Cursor horizontal_drag_cursor;
539 /* NS-specific */
540 Cursor current_pointer;
542 /* lord knows why Emacs needs to know about our Window ids.. */
543 Window window_desc, parent_desc;
544 char explicit_parent;
546 struct font *font;
547 int baseline_offset;
549 /* If a fontset is specified for this frame instead of font, this
550 value contains an ID of the fontset, else -1. */
551 int fontset; /* only used with font_backend */
553 Lisp_Object icon_top;
554 Lisp_Object icon_left;
556 /* The size of the extra width currently allotted for vertical
557 scroll bars, in pixels. */
558 int vertical_scroll_bar_extra;
560 /* The height of the titlebar decoration (included in NSWindow's frame). */
561 int titlebar_height;
563 /* The height of the toolbar if displayed, else 0. */
564 int toolbar_height;
566 /* This is the Emacs structure for the NS display this frame is on. */
567 struct ns_display_info *display_info;
570 /* this dummy decl needed to support TTYs */
571 struct x_output
573 unsigned long background_pixel;
574 unsigned long foreground_pixel;
578 /* This gives the ns_display_info structure for the display F is on. */
579 #define FRAME_NS_DISPLAY_INFO(f) ((f)->output_data.ns->display_info)
580 /* the primacy of X must be constantly worked with... */
581 #define FRAME_X_DISPLAY_INFO(f) ((f)->output_data.ns->display_info)
582 #define FRAME_X_OUTPUT(f) ((f)->output_data.ns)
583 #define FRAME_NS_WINDOW(f) ((f)->output_data.ns->window_desc)
584 #define FRAME_X_WINDOW(f) ((f)->output_data.ns->window_desc)
586 /* This is the `Display *' which frame F is on. */
587 #define FRAME_NS_DISPLAY(f) (0)
588 #define FRAME_X_DISPLAY(f) (0)
590 #define FRAME_FOREGROUND_COLOR(f) ((f)->output_data.ns->foreground_color)
591 #define FRAME_BACKGROUND_COLOR(f) ((f)->output_data.ns->background_color)
593 #define FRAME_X_IMAGE_CACHE(F) FRAME_NS_DISPLAY_INFO ((F))->image_cache
595 #define NS_FACE_FOREGROUND(f) ((f)->foreground)
596 #define NS_FACE_BACKGROUND(f) ((f)->background)
597 #define FRAME_NS_TITLEBAR_HEIGHT(f) ((f)->output_data.ns->titlebar_height)
598 #define FRAME_TOOLBAR_HEIGHT(f) ((f)->output_data.ns->toolbar_height)
600 #define FONT_WIDTH(f) ((f)->max_width)
601 #define FONT_HEIGHT(f) ((f)->height)
602 /*#define FONT_BASE(f) ((f)->ascent) */
603 #define FONT_BASE(f) (((struct nsfont_info *)f)->max_bounds.ascent)
604 /*#define FONT_DESCENT(f) ((f)->descent) */
605 #define FONT_DESCENT(f) (((struct nsfont_info *)f)->max_bounds.descent)
607 #define FRAME_DEFAULT_FACE(f) FACE_FROM_ID (f, DEFAULT_FACE_ID)
609 #define FRAME_NS_VIEW(f) ((f)->output_data.ns->view)
610 #define FRAME_CURSOR_COLOR(f) ((f)->output_data.ns->cursor_color)
611 #define FRAME_POINTER_TYPE(f) ((f)->output_data.ns->current_pointer)
613 #define FRAME_FONT(f) ((f)->output_data.ns->font)
615 #ifdef __OBJC__
616 #define XNS_SCROLL_BAR(vec) ((id) XSAVE_VALUE (vec)->pointer)
617 #else
618 #define XNS_SCROLL_BAR(vec) XSAVE_VALUE (vec)->pointer
619 #endif
621 /* Compute pixel size for vertical scroll bars */
622 #define NS_SCROLL_BAR_WIDTH(f) \
623 (FRAME_HAS_VERTICAL_SCROLL_BARS (f) \
624 ? rint (FRAME_CONFIG_SCROLL_BAR_WIDTH (f) > 0 \
625 ? FRAME_CONFIG_SCROLL_BAR_WIDTH (f) \
626 : (FRAME_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f))) \
627 : 0)
629 /* Difference btwn char-column-calculated and actual SB widths.
630 This is only a concern for rendering when SB on left. */
631 #define NS_SCROLL_BAR_ADJUST(w, f) \
632 (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (w) ? \
633 (FRAME_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f) \
634 - NS_SCROLL_BAR_WIDTH (f)) : 0)
636 /* XXX: fix for GNUstep inconsistent accounting for titlebar */
637 #ifdef NS_IMPL_GNUSTEP
638 #define NS_TOP_POS(f) ((f)->top_pos + 18)
639 #else
640 #define NS_TOP_POS(f) ((f)->top_pos)
641 #endif
643 #define FRAME_NS_FONT_TABLE(f) (FRAME_NS_DISPLAY_INFO (f)->font_table)
645 #define FRAME_FONTSET(f) ((f)->output_data.ns->fontset)
647 #define FRAME_SMALLEST_CHAR_WIDTH(f) \
648 (FRAME_NS_DISPLAY_INFO (f)->smallest_char_width)
649 #define FRAME_SMALLEST_FONT_HEIGHT(f) \
650 (FRAME_NS_DISPLAY_INFO (f)->smallest_font_height)
651 #define FONT_TYPE_FOR_UNIBYTE(font, ch) 0
652 #define FONT_TYPE_FOR_MULTIBYTE(font, ch) 0
653 #define FRAME_BASELINE_OFFSET(f) ((f)->output_data.ns->baseline_offset)
654 #define BLACK_PIX_DEFAULT(f) 0x000000
655 #define WHITE_PIX_DEFAULT(f) 0xFFFFFF
657 /* First position where characters can be shown (instead of scrollbar, if
658 it is on left. */
659 #define FIRST_CHAR_POSITION(f) \
660 (! (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f)) ? 0 \
661 : FRAME_SCROLL_BAR_COLS (f))
663 extern struct ns_display_info *ns_term_init ();
664 extern void ns_term_shutdown (int sig);
666 /* constants for text rendering */
667 #define NS_DUMPGLYPH_NORMAL 0
668 #define NS_DUMPGLYPH_CURSOR 1
669 #define NS_DUMPGLYPH_FOREGROUND 2
670 #define NS_DUMPGLYPH_MOUSEFACE 3
673 EXFUN (Fx_display_grayscale_p, 1);
674 EXFUN (Fx_display_planes, 1);
676 /* In nsfont, called from fontset.c */
677 extern void nsfont_make_fontset_for_font (Lisp_Object name,
678 Lisp_Object font_object);
680 /* In nsfont, for debugging */
681 struct glyph_string;
682 void ns_dump_glyphstring (struct glyph_string *s);
684 /* Implemented in nsterm, published in or needed from nsfns. */
685 extern Lisp_Object Qfontsize;
686 extern Lisp_Object ns_list_fonts (FRAME_PTR f, Lisp_Object pattern,
687 int size, int maxnames);
688 extern void ns_clear_frame (struct frame *f);
690 extern const char *ns_xlfd_to_fontname (const char *xlfd);
692 extern void check_ns (void);
693 extern Lisp_Object ns_map_event_to_object ();
694 extern Lisp_Object ns_string_from_pasteboard ();
695 extern void ns_string_to_pasteboard ();
696 extern void nxatoms_of_nsselect ();
697 extern int ns_lisp_to_cursor_type ();
698 extern Lisp_Object ns_cursor_type_to_lisp (int arg);
699 extern Lisp_Object Qnone;
700 extern void ns_set_name_as_filename (struct frame *f);
701 extern void ns_set_doc_edited (struct frame *f, Lisp_Object arg);
703 extern int
704 ns_defined_color (struct frame *f,
705 const char *name,
706 XColor *color_def, int alloc,
707 char makeIndex);
708 extern void
709 ns_query_color (void *col, XColor *color_def, int setPixel);
711 #ifdef __OBJC__
712 extern Lisp_Object ns_color_to_lisp (NSColor *col);
713 extern int ns_lisp_to_color (Lisp_Object color, NSColor **col);
714 extern NSColor *ns_lookup_indexed_color (unsigned long idx, struct frame *f);
715 extern unsigned long ns_index_color (NSColor *color, struct frame *f);
716 extern void ns_free_indexed_color (unsigned long idx, struct frame *f);
717 #endif
719 /* C access to ObjC functionality */
720 extern void ns_release_object (void *obj);
721 extern void ns_retain_object (void *obj);
722 extern void *ns_alloc_autorelease_pool ();
723 extern void ns_release_autorelease_pool ();
725 /* in nsmenu */
726 extern void update_frame_tool_bar (FRAME_PTR f);
727 extern void free_frame_tool_bar (FRAME_PTR f);
728 extern void find_and_call_menu_selection (FRAME_PTR f,
729 int menu_bar_items_used, Lisp_Object vector, void *client_data);
730 extern Lisp_Object find_and_return_menu_selection (FRAME_PTR f,
731 int keymaps,
732 void *client_data);
733 extern Lisp_Object ns_popup_dialog (Lisp_Object position, Lisp_Object contents,
734 Lisp_Object header);
736 /* More prototypes that should be moved to a more general include file */
737 extern void set_frame_menubar (struct frame *f, int first_time, int deep_p);
738 extern void x_set_window_size (struct frame *f, int change_grav,
739 int cols, int rows);
740 extern void x_sync (struct frame *);
741 extern Lisp_Object x_get_focus_frame (struct frame *);
742 extern void x_set_mouse_position (struct frame *f, int h, int v);
743 extern void x_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y);
744 extern void x_make_frame_visible (struct frame *f);
745 extern void x_make_frame_invisible (struct frame *f);
746 extern void x_iconify_frame (struct frame *f);
747 extern int x_char_width (struct frame *f);
748 extern int x_char_height (struct frame *f);
749 extern int x_pixel_width (struct frame *f);
750 extern int x_pixel_height (struct frame *f);
751 extern void x_set_frame_alpha (struct frame *f);
752 extern void x_set_menu_bar_lines (struct frame *, Lisp_Object, Lisp_Object);
753 extern void x_set_tool_bar_lines (struct frame *f,
754 Lisp_Object value,
755 Lisp_Object oldval);
756 extern void x_activate_menubar (struct frame *);
757 extern void free_frame_menubar (struct frame *);
759 extern void ns_init_paths (void);
760 extern void syms_of_nsterm (void);
761 extern void syms_of_nsfns (void);
762 extern void syms_of_nsmenu (void);
763 extern void syms_of_nsselect (void);
765 /* From nsimage.m, needed in image.c */
766 struct image;
767 extern void *ns_image_from_XBM (unsigned char *bits, int width, int height);
768 extern void *ns_image_for_XPM (int width, int height, int depth);
769 extern void *ns_image_from_file (Lisp_Object file);
770 extern int ns_load_image (struct frame *f, struct image *img,
771 Lisp_Object spec_file, Lisp_Object spec_data);
772 extern int ns_image_width (void *img);
773 extern int ns_image_height (void *img);
774 extern unsigned long ns_get_pixel (void *img, int x, int y);
775 extern void ns_put_pixel (void *img, int x, int y, unsigned long argb);
776 extern void ns_set_alpha (void *img, int x, int y, unsigned char a);
778 extern int x_display_pixel_height (struct ns_display_info *);
779 extern int x_display_pixel_width (struct ns_display_info *);
781 /* This in nsterm.m */
782 extern int ns_select (int nfds, fd_set *readfds, fd_set *writefds,
783 fd_set *exceptfds, struct timeval *timeout);
784 extern unsigned long ns_get_rgb_color (struct frame *f,
785 float r, float g, float b, float a);
786 extern NSPoint last_mouse_motion_position;
788 #ifdef NS_IMPL_GNUSTEP
789 extern char gnustep_base_version[]; /* version tracking */
790 #endif
792 #define MINWIDTH 10
793 #define MINHEIGHT 10
795 /* Screen max coordinate
796 Using larger coordinates causes movewindow/placewindow to abort */
797 #define SCREENMAX 16000
799 #define NS_SCROLL_BAR_WIDTH_DEFAULT [EmacsScroller scrollerWidth]
800 /* This is to match emacs on other platforms, ugly though it is. */
801 #define NS_SELECTION_COLOR_DEFAULT @"LightGoldenrod2";
802 #define RESIZE_HANDLE_SIZE 12
804 /* Little utility macros */
805 #define IN_BOUND(min, x, max) (((x) < (min)) \
806 ? (min) : (((x)>(max)) ? (max) : (x)))
807 #define SCREENMAXBOUND(x) (IN_BOUND (-SCREENMAX, x, SCREENMAX))
809 /* needed somewhere... */
810 #define VERTICAL_SCROLL_BAR_WIDTH_TRIM (0)
813 #endif /* HAVE_NS */
815 /* arch-tag: 0a28b142-4ac1-4a81-a243-abcd82d9c4e5
816 (do not change this comment) */