Fix the previous entry.
[emacs.git] / src / nsterm.h
blob7375e3c9fc4049529deb70993dc83aaf48879dc2
1 /* Definitions and headers for communication with NeXT/Open/GNUstep API.
2 Copyright (C) 1989, 1993, 2005, 2008, 2009 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"
25 #ifdef HAVE_NS
27 #ifdef __OBJC__
29 /* ==========================================================================
31 The Emacs application
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;
46 @end
49 /* ==========================================================================
51 The main Emacs view
53 ========================================================================== */
55 @class EmacsToolbar;
57 @interface EmacsView : NSView <NSTextInput>
59 char *old_title;
60 BOOL windowClosing;
61 NSString *workingText;
62 BOOL processingCompose;
63 @public
64 struct frame *emacsframe;
65 int rows, cols;
66 int scrollbarsNeedingUpdate;
67 EmacsToolbar *toolbar;
70 /* AppKit-side interface */
71 - menuDown: sender;
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;
89 #endif
90 @end
93 /* Small utility used for processing resize events under Cocoa. */
94 @interface EmacsWindow : NSWindow
96 NSPoint grabOffset;
98 @end
101 /* ==========================================================================
103 The main menu implementation
105 ========================================================================== */
107 @interface EmacsMenu : NSMenu
109 struct frame *frame;
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;
120 - (void) clear;
121 - (Lisp_Object)runMenuAt: (NSPoint)p forFrame: (struct frame *)f
122 keymaps: (int)keymaps;
123 @end
126 /* ==========================================================================
128 Toolbar
130 ========================================================================== */
132 @class EmacsImage;
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;
144 - (BOOL) changed;
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;
154 @end
157 /* ==========================================================================
159 Message / question windows
161 ========================================================================== */
163 @interface EmacsDialogPanel : NSPanel
165 NSTextField *command;
166 NSTextField *title;
167 NSMatrix *matrix;
168 int rows, cols;
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;
173 - addSplit;
174 - (Lisp_Object)runDialogAt: (NSPoint)p;
175 @end
177 @interface EmacsTooltip : NSObject
179 NSWindow *win;
180 NSTextField *textField;
181 NSTimer *timer;
183 - init;
184 - (void) setText: (char *)text;
185 - (void) showAtX: (int)x Y: (int)y for: (int)seconds;
186 - (void) hide;
187 - (BOOL) isActive;
188 - (NSRect) frame;
189 @end
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
203 @end
204 @interface EmacsOpenPanel : NSOpenPanel
207 @end
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;
216 @end
219 /* ==========================================================================
221 Images and stippling
223 ========================================================================== */
225 @interface EmacsImage : NSImage
227 id imageListNext;
228 int refCount;
229 NSBitmapImageRep *bmRep; /* used for accessing pixel data */
230 unsigned char *pixmapData[5]; /* shortcut to access pixel data */
231 BOOL onTiger;
232 NSColor *stippleMask;
234 + allocInitFromFile: (Lisp_Object)file;
235 - reference;
236 - imageListSetNext: (id)arg;
237 - imageListNext;
238 - (void)dealloc;
239 - initFromXBM: (unsigned char *)bits width: (int)w height: (int)h
240 flip: (BOOL)flip;
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;
252 @end
255 /* ==========================================================================
257 Scrollbars
259 ========================================================================== */
261 @interface EmacsScroller : NSScroller
263 Lisp_Object win;
264 struct frame *frame;
265 NSResponder *prevResponder;
267 /* offset to the bottom of knob of last mouse down */
268 float last_mouse_offset;
269 float min_portion;
270 int pixel_height;
271 int last_hit_part;
273 BOOL condemned;
275 /* optimize against excessive positioning calls generated by emacs */
276 int em_position;
277 int em_portion;
278 int em_whole;
281 - initFrame: (NSRect )r window: (Lisp_Object)win;
282 - (void)setFrame: (NSRect)r;
283 - (void)dealloc;
285 - setPosition: (int) position portion: (int) portion whole: (int) whole;
286 - (int) checkSamePosition: (int)position portion: (int)portion
287 whole: (int)whole;
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;
292 - condemn;
293 - reprieve;
294 - judge;
295 @end
298 /* ==========================================================================
300 Rendering on Panther and above
302 ========================================================================== */
304 #ifdef NS_IMPL_COCOA
305 /* rendering util */
306 @interface EmacsGlyphStorage : NSObject <NSGlyphStorage>
308 @public
309 NSAttributedString *attrStr;
310 NSMutableDictionary *dict;
311 CGGlyph *cglyphs;
312 unsigned long maxChar, maxGlyph;
313 long i, len;
315 - initWithCapacity: (unsigned long) c;
316 - (void) setString: (NSString *)str font: (NSFont *)font;
317 @end
318 #endif /* NS_IMPL_COCOA */
320 extern NSArray *ns_send_types, *ns_return_types;
321 extern EmacsMenu *mainMenu, *svcsMenu, *dockMenu;
323 /* Apple removed the declaration, but kept the implementation */
324 #if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
325 @interface NSApplication (EmacsApp)
326 - (void)setAppleMenu: (NSMenu *)menu;
327 @end
328 #endif
330 #ifndef NS_HAVE_NSINTEGER
331 typedef long NSInteger;
332 typedef unsigned long NSUInteger;
333 #endif /* not NS_HAVE_NSINTEGER */
335 #endif /* __OBJC__ */
339 /* ==========================================================================
341 Non-OO stuff
343 ========================================================================== */
345 /* Special keycodes that we pass down the event chain */
346 #define KEY_NS_POWER_OFF ((1<<28)|(0<<16)|1)
347 #define KEY_NS_OPEN_FILE ((1<<28)|(0<<16)|2)
348 #define KEY_NS_OPEN_TEMP_FILE ((1<<28)|(0<<16)|3)
349 #define KEY_NS_DRAG_FILE ((1<<28)|(0<<16)|4)
350 #define KEY_NS_DRAG_COLOR ((1<<28)|(0<<16)|5)
351 #define KEY_NS_DRAG_TEXT ((1<<28)|(0<<16)|6)
352 #define KEY_NS_CHANGE_FONT ((1<<28)|(0<<16)|7)
353 #define KEY_NS_OPEN_FILE_LINE ((1<<28)|(0<<16)|8)
354 #define KEY_NS_PUT_WORKING_TEXT ((1<<28)|(0<<16)|9)
355 #define KEY_NS_UNPUT_WORKING_TEXT ((1<<28)|(0<<16)|10)
356 #define KEY_NS_SPI_SERVICE_CALL ((1<<28)|(0<<16)|11)
357 #define KEY_NS_NEW_FRAME ((1<<28)|(0<<16)|12)
358 #define KEY_NS_TOGGLE_TOOLBAR ((1<<28)|(0<<16)|13)
359 #define KEY_NS_SHOW_PREFS ((1<<28)|(0<<16)|14)
361 /* could use list to store these, but rest of emacs has a big infrastructure
362 for managing a table of bitmap "records" */
363 struct ns_bitmap_record
365 #ifdef __OBJC__
366 EmacsImage *img;
367 #else
368 void *img;
369 #endif
370 char *file;
371 int refcount;
372 int height, width, depth;
375 /* this to map between emacs color indices and NSColor objects */
376 struct ns_color_table
378 unsigned int size;
379 unsigned int avail;
380 #ifdef __OBJC__
381 NSColor **colors;
382 NSMutableSet *empty_indices;
383 #else
384 void **items;
385 void *availIndices;
386 #endif
388 #define NS_COLOR_CAPACITY 256
390 #define RGB_TO_ULONG(r, g, b) (((r) << 16) | ((g) << 8) | (b))
391 #define ARGB_TO_ULONG(a, r, g, b) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))
393 #define ALPHA_FROM_ULONG(color) ((color) >> 24)
394 #define RED_FROM_ULONG(color) (((color) >> 16) & 0xff)
395 #define GREEN_FROM_ULONG(color) (((color) >> 8) & 0xff)
396 #define BLUE_FROM_ULONG(color) ((color) & 0xff)
398 /* Do not change `* 0x101' in the following lines to `<< 8'. If
399 changed, image masks in 1-bit depth will not work. */
400 #define RED16_FROM_ULONG(color) (RED_FROM_ULONG(color) * 0x101)
401 #define GREEN16_FROM_ULONG(color) (GREEN_FROM_ULONG(color) * 0x101)
402 #define BLUE16_FROM_ULONG(color) (BLUE_FROM_ULONG(color) * 0x101)
404 /* this extends font backend font */
405 struct nsfont_info
407 struct font font;
409 char *name; /* postscript name, uniquely identifies on NS systems */
410 float width; /* this and following metrics stored as float rather than int */
411 float height;
412 float underpos;
413 float underwidth;
414 float size;
415 #ifdef __OBJC__
416 NSFont *nsfont;
417 /* cgfont and synthItal are used only on OS X 10.3+ */
418 #if defined (NS_IMPL_COCOA) && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3)
419 CGFontRef cgfont;
420 #else /* GNUstep or OS X < 10.3 */
421 void *cgfont;
422 #endif
423 #else /* ! OBJC */
424 void *nsfont;
425 void *cgfont;
426 #endif
427 char bold, ital; /* convenience flags */
428 char synthItal;
429 float voffset; /* mean of ascender/descender offsets */
430 XCharStruct max_bounds;
431 /* we compute glyph codes and metrics on-demand in blocks of 256 indexed
432 by hibyte, lobyte */
433 unsigned short **glyphs; /* map unicode index to glyph */
434 struct font_metrics **metrics;
438 /* init'd in ns_initialize_display_info () */
439 struct ns_display_info
441 /* Chain of all ns_display_info structures. */
442 struct ns_display_info *next;
444 /* The generic display parameters corresponding to this NS display. */
445 struct terminal *terminal;
447 /* This is a cons cell of the form (NAME . FONT-LIST-CACHE).
448 The same cons cell also appears in ns_display_name_list. */
449 Lisp_Object name_list_element;
451 /* The number of fonts loaded. */
452 int n_fonts;
454 /* Minimum width over all characters in all fonts in font_table. */
455 int smallest_char_width;
457 /* Minimum font height over all fonts in font_table. */
458 int smallest_font_height;
460 struct ns_bitmap_record *bitmaps;
461 int bitmaps_size;
462 int bitmaps_last;
464 struct image_cache *image_cache;
466 struct ns_color_table *color_table;
468 /* DPI resolution of this screen */
469 double resx, resy;
471 /* Mask of things that cause the mouse to be grabbed */
472 int grabbed;
474 int n_planes;
476 int color_p;
478 Window root_window;
480 /* Xism */
481 XrmDatabase xrdb;
483 /* The cursor to use for vertical scroll bars. */
484 Cursor vertical_scroll_bar_cursor;
486 /* most mouse face stuff moved in here as of 21+ (and reasonably so) */
487 int mouse_face_beg_row, mouse_face_beg_col;
488 int mouse_face_end_row, mouse_face_end_col;
489 int mouse_face_beg_x, mouse_face_beg_y;
490 int mouse_face_end_x, mouse_face_end_y;
491 int mouse_face_past_end;
492 Lisp_Object mouse_face_window;
493 int mouse_face_face_id;
494 int mouse_face_deferred_gc;
495 Lisp_Object mouse_face_overlay;
496 FRAME_PTR mouse_face_mouse_frame;
497 int mouse_face_mouse_x, mouse_face_mouse_y;
498 int mouse_face_defer;
499 int mouse_face_hidden;
500 int mouse_face_image_state;
502 struct frame *x_highlight_frame;
503 struct frame *x_focus_frame;
506 /* This is a chain of structures for all the NS displays currently in use. */
507 extern struct ns_display_info *x_display_list;
509 extern Lisp_Object ns_display_name_list;
510 extern struct ns_display_info *ns_display_info_for_name ();
512 struct ns_display_info *check_x_display_info (Lisp_Object frame);
513 FRAME_PTR check_x_frame (Lisp_Object frame);
516 struct ns_output
518 #ifdef __OBJC__
519 EmacsView *view;
520 id miniimage;
521 NSColor *cursor_color;
522 NSColor *foreground_color;
523 NSColor *background_color;
524 EmacsToolbar *toolbar;
525 #else
526 void *view;
527 void *miniimage;
528 void *cursor_color;
529 void *foreground_color;
530 void *background_color;
531 void *toolbar;
532 #endif
534 /* NSCursors init'ed in initFrameFromEmacs */
535 Cursor text_cursor;
536 Cursor nontext_cursor;
537 Cursor modeline_cursor;
538 Cursor hand_cursor;
539 Cursor hourglass_cursor;
540 Cursor horizontal_drag_cursor;
542 /* NS-specific */
543 Cursor current_pointer;
545 /* lord knows why Emacs needs to know about our Window ids.. */
546 Window window_desc, parent_desc;
547 char explicit_parent;
549 struct font *font;
550 int baseline_offset;
552 /* If a fontset is specified for this frame instead of font, this
553 value contains an ID of the fontset, else -1. */
554 int fontset; /* only used with font_backend */
556 Lisp_Object icon_top;
557 Lisp_Object icon_left;
559 /* The size of the extra width currently allotted for vertical
560 scroll bars, in pixels. */
561 int vertical_scroll_bar_extra;
563 /* The height of the titlebar decoration (included in NSWindow's frame). */
564 int titlebar_height;
566 /* The height of the toolbar if displayed, else 0. */
567 int toolbar_height;
569 /* This is the Emacs structure for the NS display this frame is on. */
570 struct ns_display_info *display_info;
573 /* this dummy decl needed to support TTYs */
574 struct x_output
576 unsigned long background_pixel;
577 unsigned long foreground_pixel;
581 /* This gives the ns_display_info structure for the display F is on. */
582 #define FRAME_NS_DISPLAY_INFO(f) ((f)->output_data.ns->display_info)
583 /* the primacy of X must be constantly worked with... */
584 #define FRAME_X_DISPLAY_INFO(f) ((f)->output_data.ns->display_info)
585 #define FRAME_X_OUTPUT(f) ((f)->output_data.ns)
586 #define FRAME_NS_WINDOW(f) ((f)->output_data.ns->window_desc)
587 #define FRAME_X_WINDOW(f) ((f)->output_data.ns->window_desc)
589 /* This is the `Display *' which frame F is on. */
590 #define FRAME_NS_DISPLAY(f) (0)
591 #define FRAME_X_DISPLAY(f) (0)
593 #define FRAME_FOREGROUND_COLOR(f) ((f)->output_data.ns->foreground_color)
594 #define FRAME_BACKGROUND_COLOR(f) ((f)->output_data.ns->background_color)
596 #define FRAME_X_IMAGE_CACHE(F) FRAME_NS_DISPLAY_INFO ((F))->image_cache
598 #define NS_FACE_FOREGROUND(f) ((f)->foreground)
599 #define NS_FACE_BACKGROUND(f) ((f)->background)
600 #define FRAME_NS_TITLEBAR_HEIGHT(f) ((f)->output_data.ns->titlebar_height)
601 #define FRAME_NS_TOOLBAR_HEIGHT(f) ((f)->output_data.ns->toolbar_height)
603 #define FONT_WIDTH(f) ((f)->max_width)
604 #define FONT_HEIGHT(f) ((f)->height)
605 /*#define FONT_BASE(f) ((f)->ascent) */
606 #define FONT_BASE(f) (((struct nsfont_info *)f)->max_bounds.ascent)
607 /*#define FONT_DESCENT(f) ((f)->descent) */
608 #define FONT_DESCENT(f) (((struct nsfont_info *)f)->max_bounds.descent)
610 #define FRAME_DEFAULT_FACE(f) FACE_FROM_ID (f, DEFAULT_FACE_ID)
612 #define FRAME_NS_VIEW(f) ((f)->output_data.ns->view)
613 #define FRAME_CURSOR_COLOR(f) ((f)->output_data.ns->cursor_color)
614 #define FRAME_POINTER_TYPE(f) ((f)->output_data.ns->current_pointer)
616 #define FRAME_FONT(f) ((f)->output_data.ns->font)
618 #ifdef __OBJC__
619 #define XNS_SCROLL_BAR(vec) ((id) XSAVE_VALUE (vec)->pointer)
620 #else
621 #define XNS_SCROLL_BAR(vec) XSAVE_VALUE (vec)->pointer
622 #endif
624 /* Compute pixel size for vertical scroll bars */
625 #define NS_SCROLL_BAR_WIDTH(f) \
626 (FRAME_HAS_VERTICAL_SCROLL_BARS (f) \
627 ? rint (FRAME_CONFIG_SCROLL_BAR_WIDTH (f) > 0 \
628 ? FRAME_CONFIG_SCROLL_BAR_WIDTH (f) \
629 : (FRAME_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f))) \
630 : 0)
632 /* Difference btwn char-column-calculated and actual SB widths.
633 This is only a concern for rendering when SB on left. */
634 #define NS_SCROLL_BAR_ADJUST(w, f) \
635 (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (w) ? \
636 (FRAME_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f) \
637 - NS_SCROLL_BAR_WIDTH (f)) : 0)
639 /* XXX: fix for GNUstep inconsistent accounting for titlebar */
640 #ifdef NS_IMPL_GNUSTEP
641 #define NS_TOP_POS(f) ((f)->top_pos + 18)
642 #else
643 #define NS_TOP_POS(f) ((f)->top_pos)
644 #endif
646 #define FRAME_NS_FONT_TABLE(f) (FRAME_NS_DISPLAY_INFO (f)->font_table)
648 #define FRAME_FONTSET(f) ((f)->output_data.ns->fontset)
650 #define FRAME_SMALLEST_CHAR_WIDTH(f) \
651 (FRAME_NS_DISPLAY_INFO (f)->smallest_char_width)
652 #define FRAME_SMALLEST_FONT_HEIGHT(f) \
653 (FRAME_NS_DISPLAY_INFO (f)->smallest_font_height)
654 #define FONT_TYPE_FOR_UNIBYTE(font, ch) 0
655 #define FONT_TYPE_FOR_MULTIBYTE(font, ch) 0
656 #define FRAME_BASELINE_OFFSET(f) ((f)->output_data.ns->baseline_offset)
657 #define BLACK_PIX_DEFAULT(f) 0x000000
658 #define WHITE_PIX_DEFAULT(f) 0xFFFFFF
660 /* First position where characters can be shown (instead of scrollbar, if
661 it is on left. */
662 #define FIRST_CHAR_POSITION(f) \
663 (! (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f)) ? 0 \
664 : FRAME_SCROLL_BAR_COLS (f))
666 extern struct ns_display_info *ns_term_init ();
667 extern void ns_term_shutdown (int sig);
669 /* constants for text rendering */
670 #define NS_DUMPGLYPH_NORMAL 0
671 #define NS_DUMPGLYPH_CURSOR 1
672 #define NS_DUMPGLYPH_FOREGROUND 2
673 #define NS_DUMPGLYPH_MOUSEFACE 3
676 EXFUN (Fx_display_grayscale_p, 1);
677 EXFUN (Fx_display_planes, 1);
679 /* In nsfont, called from fontset.c */
680 extern void nsfont_make_fontset_for_font (Lisp_Object name,
681 Lisp_Object font_object);
683 /* In nsfont, for debugging */
684 struct glyph_string;
685 void ns_dump_glyphstring (struct glyph_string *s);
687 /* Implemented in nsterm, published in or needed from nsfns. */
688 extern Lisp_Object Qfontsize;
689 extern Lisp_Object ns_list_fonts (FRAME_PTR f, Lisp_Object pattern,
690 int size, int maxnames);
691 extern void ns_clear_frame (struct frame *f);
693 extern const char *ns_xlfd_to_fontname (const char *xlfd);
695 extern void check_ns (void);
696 extern Lisp_Object ns_map_event_to_object ();
697 extern Lisp_Object ns_string_from_pasteboard ();
698 extern void ns_string_to_pasteboard ();
699 extern void nxatoms_of_nsselect ();
700 extern int ns_lisp_to_cursor_type ();
701 extern Lisp_Object ns_cursor_type_to_lisp (int arg);
702 extern Lisp_Object Qnone;
703 extern char ns_no_defaults;
705 extern int
706 ns_defined_color (struct frame *f, char *name, 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 /* two 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);
741 /* From nsimage.m, needed in image.c */
742 struct image;
743 extern void *ns_image_from_XBM (unsigned char *bits, int width, int height);
744 extern void *ns_image_for_XPM (int width, int height, int depth);
745 extern void *ns_image_from_file (Lisp_Object file);
746 extern int ns_load_image (struct frame *f, struct image *img,
747 Lisp_Object spec_file, Lisp_Object spec_data);
748 extern int ns_image_width (void *img);
749 extern int ns_image_height (void *img);
750 extern unsigned long ns_get_pixel (void *img, int x, int y);
751 extern void ns_put_pixel (void *img, int x, int y, unsigned long argb);
752 extern void ns_set_alpha (void *img, int x, int y, unsigned char a);
754 extern int x_display_pixel_height P_ ((struct ns_display_info *));
755 extern int x_display_pixel_width P_ ((struct ns_display_info *));
757 /* This in nsterm.m */
758 extern unsigned long ns_get_rgb_color (struct frame *f,
759 float r, float g, float b, float a);
760 extern NSPoint last_mouse_motion_position;
762 #ifdef NS_IMPL_GNUSTEP
763 extern char gnustep_base_version[]; /* version tracking */
764 #endif
766 #define MINWIDTH 10
767 #define MINHEIGHT 10
769 /* Screen max coordinate
770 Using larger coordinates causes movewindow/placewindow to abort */
771 #define SCREENMAX 16000
773 #define NS_SCROLL_BAR_WIDTH_DEFAULT [EmacsScroller scrollerWidth]
774 /* This is to match emacs on other platforms, ugly though it is. */
775 #define NS_SELECTION_COLOR_DEFAULT @"LightGoldenrod2";
776 #define RESIZE_HANDLE_SIZE 12
778 /* Little utility macros */
779 #define IN_BOUND(min, x, max) (((x) < (min)) \
780 ? (min) : (((x)>(max)) ? (max) : (x)))
781 #define SCREENMAXBOUND(x) (IN_BOUND (-SCREENMAX, x, SCREENMAX))
783 /* needed somewhere... */
784 #define VERTICAL_SCROLL_BAR_WIDTH_TRIM (0)
787 #endif /* HAVE_NS */
789 /* arch-tag: 0a28b142-4ac1-4a81-a243-abcd82d9c4e5
790 (do not change this comment) */