Merge from trunk
[emacs.git] / src / nsterm.h
blob21b18f15cae567c711291b6f47ffdf7c7bb55c92
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 /* most mouse face stuff moved in here as of 21+ (and reasonably so) */
496 int mouse_face_beg_row, mouse_face_beg_col;
497 int mouse_face_end_row, mouse_face_end_col;
498 int mouse_face_beg_x, mouse_face_beg_y;
499 int mouse_face_end_x, mouse_face_end_y;
500 int mouse_face_past_end;
501 Lisp_Object mouse_face_window;
502 int mouse_face_face_id;
503 int mouse_face_deferred_gc;
504 Lisp_Object mouse_face_overlay;
505 FRAME_PTR mouse_face_mouse_frame;
506 int mouse_face_mouse_x, mouse_face_mouse_y;
507 int mouse_face_defer;
508 int mouse_face_hidden;
509 int mouse_face_image_state;
511 struct frame *x_highlight_frame;
512 struct frame *x_focus_frame;
515 /* This is a chain of structures for all the NS displays currently in use. */
516 extern struct ns_display_info *x_display_list;
518 extern Lisp_Object ns_display_name_list;
519 extern struct ns_display_info *ns_display_info_for_name ();
521 struct ns_display_info *check_x_display_info (Lisp_Object frame);
522 FRAME_PTR check_x_frame (Lisp_Object frame);
525 struct ns_output
527 #ifdef __OBJC__
528 EmacsView *view;
529 id miniimage;
530 NSColor *cursor_color;
531 NSColor *foreground_color;
532 NSColor *background_color;
533 EmacsToolbar *toolbar;
534 #else
535 void *view;
536 void *miniimage;
537 void *cursor_color;
538 void *foreground_color;
539 void *background_color;
540 void *toolbar;
541 #endif
543 /* NSCursors init'ed in initFrameFromEmacs */
544 Cursor text_cursor;
545 Cursor nontext_cursor;
546 Cursor modeline_cursor;
547 Cursor hand_cursor;
548 Cursor hourglass_cursor;
549 Cursor horizontal_drag_cursor;
551 /* NS-specific */
552 Cursor current_pointer;
554 /* lord knows why Emacs needs to know about our Window ids.. */
555 Window window_desc, parent_desc;
556 char explicit_parent;
558 struct font *font;
559 int baseline_offset;
561 /* If a fontset is specified for this frame instead of font, this
562 value contains an ID of the fontset, else -1. */
563 int fontset; /* only used with font_backend */
565 Lisp_Object icon_top;
566 Lisp_Object icon_left;
568 /* The size of the extra width currently allotted for vertical
569 scroll bars, in pixels. */
570 int vertical_scroll_bar_extra;
572 /* The height of the titlebar decoration (included in NSWindow's frame). */
573 int titlebar_height;
575 /* The height of the toolbar if displayed, else 0. */
576 int toolbar_height;
578 /* This is the Emacs structure for the NS display this frame is on. */
579 struct ns_display_info *display_info;
582 /* this dummy decl needed to support TTYs */
583 struct x_output
585 unsigned long background_pixel;
586 unsigned long foreground_pixel;
590 /* This gives the ns_display_info structure for the display F is on. */
591 #define FRAME_NS_DISPLAY_INFO(f) ((f)->output_data.ns->display_info)
592 /* the primacy of X must be constantly worked with... */
593 #define FRAME_X_DISPLAY_INFO(f) ((f)->output_data.ns->display_info)
594 #define FRAME_X_OUTPUT(f) ((f)->output_data.ns)
595 #define FRAME_NS_WINDOW(f) ((f)->output_data.ns->window_desc)
596 #define FRAME_X_WINDOW(f) ((f)->output_data.ns->window_desc)
598 /* This is the `Display *' which frame F is on. */
599 #define FRAME_NS_DISPLAY(f) (0)
600 #define FRAME_X_DISPLAY(f) (0)
602 #define FRAME_FOREGROUND_COLOR(f) ((f)->output_data.ns->foreground_color)
603 #define FRAME_BACKGROUND_COLOR(f) ((f)->output_data.ns->background_color)
605 #define FRAME_X_IMAGE_CACHE(F) FRAME_NS_DISPLAY_INFO ((F))->image_cache
607 #define NS_FACE_FOREGROUND(f) ((f)->foreground)
608 #define NS_FACE_BACKGROUND(f) ((f)->background)
609 #define FRAME_NS_TITLEBAR_HEIGHT(f) ((f)->output_data.ns->titlebar_height)
610 #define FRAME_TOOLBAR_HEIGHT(f) ((f)->output_data.ns->toolbar_height)
612 #define FONT_WIDTH(f) ((f)->max_width)
613 #define FONT_HEIGHT(f) ((f)->height)
614 /*#define FONT_BASE(f) ((f)->ascent) */
615 #define FONT_BASE(f) (((struct nsfont_info *)f)->max_bounds.ascent)
616 /*#define FONT_DESCENT(f) ((f)->descent) */
617 #define FONT_DESCENT(f) (((struct nsfont_info *)f)->max_bounds.descent)
619 #define FRAME_DEFAULT_FACE(f) FACE_FROM_ID (f, DEFAULT_FACE_ID)
621 #define FRAME_NS_VIEW(f) ((f)->output_data.ns->view)
622 #define FRAME_CURSOR_COLOR(f) ((f)->output_data.ns->cursor_color)
623 #define FRAME_POINTER_TYPE(f) ((f)->output_data.ns->current_pointer)
625 #define FRAME_FONT(f) ((f)->output_data.ns->font)
627 #ifdef __OBJC__
628 #define XNS_SCROLL_BAR(vec) ((id) XSAVE_VALUE (vec)->pointer)
629 #else
630 #define XNS_SCROLL_BAR(vec) XSAVE_VALUE (vec)->pointer
631 #endif
633 /* Compute pixel size for vertical scroll bars */
634 #define NS_SCROLL_BAR_WIDTH(f) \
635 (FRAME_HAS_VERTICAL_SCROLL_BARS (f) \
636 ? rint (FRAME_CONFIG_SCROLL_BAR_WIDTH (f) > 0 \
637 ? FRAME_CONFIG_SCROLL_BAR_WIDTH (f) \
638 : (FRAME_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f))) \
639 : 0)
641 /* Difference btwn char-column-calculated and actual SB widths.
642 This is only a concern for rendering when SB on left. */
643 #define NS_SCROLL_BAR_ADJUST(w, f) \
644 (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (w) ? \
645 (FRAME_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f) \
646 - NS_SCROLL_BAR_WIDTH (f)) : 0)
648 /* XXX: fix for GNUstep inconsistent accounting for titlebar */
649 #ifdef NS_IMPL_GNUSTEP
650 #define NS_TOP_POS(f) ((f)->top_pos + 18)
651 #else
652 #define NS_TOP_POS(f) ((f)->top_pos)
653 #endif
655 #define FRAME_NS_FONT_TABLE(f) (FRAME_NS_DISPLAY_INFO (f)->font_table)
657 #define FRAME_FONTSET(f) ((f)->output_data.ns->fontset)
659 #define FRAME_SMALLEST_CHAR_WIDTH(f) \
660 (FRAME_NS_DISPLAY_INFO (f)->smallest_char_width)
661 #define FRAME_SMALLEST_FONT_HEIGHT(f) \
662 (FRAME_NS_DISPLAY_INFO (f)->smallest_font_height)
663 #define FONT_TYPE_FOR_UNIBYTE(font, ch) 0
664 #define FONT_TYPE_FOR_MULTIBYTE(font, ch) 0
665 #define FRAME_BASELINE_OFFSET(f) ((f)->output_data.ns->baseline_offset)
666 #define BLACK_PIX_DEFAULT(f) 0x000000
667 #define WHITE_PIX_DEFAULT(f) 0xFFFFFF
669 /* First position where characters can be shown (instead of scrollbar, if
670 it is on left. */
671 #define FIRST_CHAR_POSITION(f) \
672 (! (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f)) ? 0 \
673 : FRAME_SCROLL_BAR_COLS (f))
675 extern struct ns_display_info *ns_term_init ();
676 extern void ns_term_shutdown (int sig);
678 /* constants for text rendering */
679 #define NS_DUMPGLYPH_NORMAL 0
680 #define NS_DUMPGLYPH_CURSOR 1
681 #define NS_DUMPGLYPH_FOREGROUND 2
682 #define NS_DUMPGLYPH_MOUSEFACE 3
685 EXFUN (Fx_display_grayscale_p, 1);
686 EXFUN (Fx_display_planes, 1);
688 /* In nsfont, called from fontset.c */
689 extern void nsfont_make_fontset_for_font (Lisp_Object name,
690 Lisp_Object font_object);
692 /* In nsfont, for debugging */
693 struct glyph_string;
694 void ns_dump_glyphstring (struct glyph_string *s);
696 /* Implemented in nsterm, published in or needed from nsfns. */
697 extern Lisp_Object Qfontsize;
698 extern Lisp_Object ns_list_fonts (FRAME_PTR f, Lisp_Object pattern,
699 int size, int maxnames);
700 extern void ns_clear_frame (struct frame *f);
702 extern const char *ns_xlfd_to_fontname (const char *xlfd);
704 extern void check_ns (void);
705 extern Lisp_Object ns_map_event_to_object ();
706 extern Lisp_Object ns_string_from_pasteboard ();
707 extern void ns_string_to_pasteboard ();
708 extern void nxatoms_of_nsselect ();
709 extern int ns_lisp_to_cursor_type ();
710 extern Lisp_Object ns_cursor_type_to_lisp (int arg);
711 extern Lisp_Object Qnone;
712 extern void ns_set_name_as_filename (struct frame *f);
713 extern void ns_set_doc_edited (struct frame *f, Lisp_Object arg);
715 extern int
716 ns_defined_color (struct frame *f,
717 const char *name,
718 XColor *color_def, int alloc,
719 char makeIndex);
720 extern void
721 ns_query_color (void *col, XColor *color_def, int setPixel);
723 #ifdef __OBJC__
724 extern Lisp_Object ns_color_to_lisp (NSColor *col);
725 extern int ns_lisp_to_color (Lisp_Object color, NSColor **col);
726 extern NSColor *ns_lookup_indexed_color (unsigned long idx, struct frame *f);
727 extern unsigned long ns_index_color (NSColor *color, struct frame *f);
728 extern void ns_free_indexed_color (unsigned long idx, struct frame *f);
729 #endif
731 /* C access to ObjC functionality */
732 extern void ns_release_object (void *obj);
733 extern void ns_retain_object (void *obj);
734 extern void *ns_alloc_autorelease_pool ();
735 extern void ns_release_autorelease_pool ();
737 /* in nsmenu */
738 extern void update_frame_tool_bar (FRAME_PTR f);
739 extern void free_frame_tool_bar (FRAME_PTR f);
740 extern void find_and_call_menu_selection (FRAME_PTR f,
741 int menu_bar_items_used, Lisp_Object vector, void *client_data);
742 extern Lisp_Object find_and_return_menu_selection (FRAME_PTR f,
743 int keymaps,
744 void *client_data);
745 extern Lisp_Object ns_popup_dialog (Lisp_Object position, Lisp_Object contents,
746 Lisp_Object header);
748 /* More prototypes that should be moved to a more general include file */
749 extern void set_frame_menubar (struct frame *f, int first_time, int deep_p);
750 extern void x_set_window_size (struct frame *f, int change_grav,
751 int cols, int rows);
752 extern void x_sync (struct frame *);
753 extern Lisp_Object x_get_focus_frame (struct frame *);
754 extern void x_set_mouse_position (struct frame *f, int h, int v);
755 extern void x_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y);
756 extern void x_make_frame_visible (struct frame *f);
757 extern void x_make_frame_invisible (struct frame *f);
758 extern void x_iconify_frame (struct frame *f);
759 extern int x_char_width (struct frame *f);
760 extern int x_char_height (struct frame *f);
761 extern int x_pixel_width (struct frame *f);
762 extern int x_pixel_height (struct frame *f);
763 extern void x_set_frame_alpha (struct frame *f);
764 extern void x_set_menu_bar_lines (struct frame *, Lisp_Object, Lisp_Object);
765 extern void x_set_tool_bar_lines (struct frame *f,
766 Lisp_Object value,
767 Lisp_Object oldval);
768 extern void x_activate_menubar (struct frame *);
769 extern void free_frame_menubar (struct frame *);
771 extern void ns_init_paths (void);
772 extern void syms_of_nsterm (void);
773 extern void syms_of_nsfns (void);
774 extern void syms_of_nsmenu (void);
775 extern void syms_of_nsselect (void);
777 /* From nsimage.m, needed in image.c */
778 struct image;
779 extern void *ns_image_from_XBM (unsigned char *bits, int width, int height);
780 extern void *ns_image_for_XPM (int width, int height, int depth);
781 extern void *ns_image_from_file (Lisp_Object file);
782 extern int ns_load_image (struct frame *f, struct image *img,
783 Lisp_Object spec_file, Lisp_Object spec_data);
784 extern int ns_image_width (void *img);
785 extern int ns_image_height (void *img);
786 extern unsigned long ns_get_pixel (void *img, int x, int y);
787 extern void ns_put_pixel (void *img, int x, int y, unsigned long argb);
788 extern void ns_set_alpha (void *img, int x, int y, unsigned char a);
790 extern int x_display_pixel_height (struct ns_display_info *);
791 extern int x_display_pixel_width (struct ns_display_info *);
793 /* This in nsterm.m */
794 extern int ns_select (int nfds, fd_set *readfds, fd_set *writefds,
795 fd_set *exceptfds, struct timeval *timeout);
796 extern unsigned long ns_get_rgb_color (struct frame *f,
797 float r, float g, float b, float a);
798 extern NSPoint last_mouse_motion_position;
800 #ifdef NS_IMPL_GNUSTEP
801 extern char gnustep_base_version[]; /* version tracking */
802 #endif
804 #define MINWIDTH 10
805 #define MINHEIGHT 10
807 /* Screen max coordinate
808 Using larger coordinates causes movewindow/placewindow to abort */
809 #define SCREENMAX 16000
811 #define NS_SCROLL_BAR_WIDTH_DEFAULT [EmacsScroller scrollerWidth]
812 /* This is to match emacs on other platforms, ugly though it is. */
813 #define NS_SELECTION_COLOR_DEFAULT @"LightGoldenrod2";
814 #define RESIZE_HANDLE_SIZE 12
816 /* Little utility macros */
817 #define IN_BOUND(min, x, max) (((x) < (min)) \
818 ? (min) : (((x)>(max)) ? (max) : (x)))
819 #define SCREENMAXBOUND(x) (IN_BOUND (-SCREENMAX, x, SCREENMAX))
821 /* needed somewhere... */
822 #define VERTICAL_SCROLL_BAR_WIDTH_TRIM (0)
825 #endif /* HAVE_NS */
827 /* arch-tag: 0a28b142-4ac1-4a81-a243-abcd82d9c4e5
828 (do not change this comment) */