Fix previous change that removed BSD_TERMIOS. Add
[bpt/emacs.git] / src / nsterm.h
CommitLineData
edfda783
AR
1/* Definitions and headers for communication with NeXT/Open/GNUstep API.
2 Copyright (C) 1989, 1993, 2005, 2008 Free Software Foundation, Inc.
3
4This file is part of GNU Emacs.
5
32d235f8 6GNU Emacs is free software: you can redistribute it and/or modify
edfda783 7it under the terms of the GNU General Public License as published by
32d235f8
GM
8the Free Software Foundation, either version 3 of the License, or
9(at your option) any later version.
edfda783
AR
10
11GNU Emacs is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
32d235f8
GM
17along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
18
edfda783
AR
19
20#include "dispextern.h"
21#include "frame.h"
22#include "character.h"
23#include "font.h"
24
25#ifdef HAVE_NS
26
27#ifdef __OBJC__
28
29/* ==========================================================================
30
31 The Emacs application
32
33 ========================================================================== */
34
35/* We override sendEvent: as a means to stop/start the event loop */
36@interface EmacsApp : NSApplication
37{
38}
39- (void)sendEvent: (NSEvent *)theEvent;
40- (void)showPreferencesWindow: (id)sender;
41@end
42
43
44/* ==========================================================================
45
46 The main Emacs view
47
48 ========================================================================== */
49
50@class EmacsToolbar;
51
52@interface EmacsView : NSView <NSTextInput>
53 {
54 char *old_title;
55 BOOL windowClosing;
56 NSString *workingText;
57 BOOL processingCompose;
58@public
59 struct frame *emacsframe;
60 int rows, cols;
61 int scrollbarsNeedingUpdate;
62 EmacsToolbar *toolbar;
63 }
64
65/* AppKit-side interface */
66- menuDown: sender;
67- toolbarClicked: (id)item;
68- toggleToolbar: (id)sender;
69- (void)keyDown: (NSEvent *)theEvent;
70- (void)mouseDown: (NSEvent *)theEvent;
71- (void)mouseUp: (NSEvent *)theEvent;
72- setMiniwindowImage: (BOOL)setMini;
73
74/* Emacs-side interface */
75- initFrameFromEmacs: (struct frame *) f;
76- (void) setRows: (int) r andColumns: (int) c;
77- (void) setWindowClosing: (BOOL)closing;
78- (EmacsToolbar *) toolbar;
79- (void) deleteWorkingText;
80@end
81
82
83/* Small utility used for processing resize events under Cocoa. */
84@interface EmacsWindow : NSWindow
85{
86 NSPoint grabOffset;
87}
88@end
89
90
91/* ==========================================================================
92
93 The main menu implementation
94
95 ========================================================================== */
96
97@interface EmacsMenu : NSMenu
98{
99 struct frame *frame;
100 unsigned long keyEquivModMask;
101}
102
103- initWithTitle: (NSString *)title frame: (struct frame *)f;
104- (void)setFrame: (struct frame *)f;
105- (void)menuNeedsUpdate: (NSMenu *)menu; /* (delegate method) */
106- (NSString *)parseKeyEquiv: (char *)key;
107- (id <NSMenuItem>)addItemWithWidgetValue: (void *)wvptr;
108- (void)fillWithWidgetValue: (void *)wvptr;
109- (EmacsMenu *)addSubmenuWithTitle: (char *)title forFrame: (struct frame *)f;
110- (void) clear;
111- (Lisp_Object)runMenuAt: (NSPoint)p forFrame: (struct frame *)f
112 keymaps: (int)keymaps;
113@end
114
115
116/* ==========================================================================
117
118 Toolbar
119
120 ========================================================================== */
121
122@class EmacsImage;
123
124@interface EmacsToolbar : NSToolbar
125 {
126 EmacsView *emacsView;
127 NSMutableDictionary *identifierToItem;
128 NSMutableArray *activeIdentifiers;
129 NSArray *prevIdentifiers;
130 unsigned long enablement, prevEnablement;
131 }
132- initForView: (EmacsView *)view withIdentifier: (NSString *)identifier;
133- (void) clearActive;
134- (BOOL) changed;
135- (void) addDisplayItemWithImage: (EmacsImage *)img idx: (int)idx
136 helpText: (char *)help
137 enabled: (BOOL)enabled;
138/* delegate methods */
139- (NSToolbarItem *)toolbar: (NSToolbar *)toolbar
140 itemForItemIdentifier: (NSString *)itemIdentifier
141 willBeInsertedIntoToolbar: (BOOL)flag;
142- (NSArray *)toolbarDefaultItemIdentifiers: (NSToolbar *)toolbar;
143- (NSArray *)toolbarAllowedItemIdentifiers: (NSToolbar *)toolbar;
144@end
145
146
147/* ==========================================================================
148
149 Message / question windows
150
151 ========================================================================== */
152
153@interface EmacsDialogPanel : NSPanel
154 {
155 NSTextField *command;
156 NSTextField *title;
157 NSMatrix *matrix;
158 int rows, cols;
159 }
160- initFromContents: (Lisp_Object)menu isQuestion: (BOOL)isQ;
161- addButton: (char *)str value: (Lisp_Object)val row: (int)row;
162- addString: (char *)str row: (int)row;
163- addSplit;
164- (Lisp_Object)runDialogAt: (NSPoint)p;
165@end
166
167@interface EmacsTooltip : NSObject
168 {
169 NSWindow *win;
170 NSTextField *textField;
171 NSTimer *timer;
172 }
173- init;
174- (void) setText: (char *)text;
175- (void) showAtX: (int)x Y: (int)y for: (int)seconds;
176- (void) hide;
177- (BOOL) isActive;
178- (NSRect) frame;
179@end
180
181
182/* ==========================================================================
183
184 File open/save panels
185 This and next override methods to work around OS X behavior of
186 restarting application loop when user dismisses panel.
187
188 ========================================================================== */
189
190@interface EmacsSavePanel : NSSavePanel
191{
192}
193@end
194@interface EmacsOpenPanel : NSOpenPanel
195{
196}
197@end
198
199@interface EmacsFileDelegate : NSObject
200{
201}
202- (BOOL)panel: (id)sender isValidFilename: (NSString *)filename;
203- (BOOL)panel: (id)sender shouldShowFilename: (NSString *)filename;
204- (NSString *)panel: (id)sender userEnteredFilename: (NSString *)filename
205 confirmed: (BOOL)okFlag;
206@end
207
208
209/* ==========================================================================
210
211 Images and stippling
212
213 ========================================================================== */
214
215@interface EmacsImage : NSImage
216{
217 id imageListNext;
218 int refCount;
219 NSBitmapImageRep *bmRep; /* used for accessing pixel data */
220 unsigned char *pixmapData[5]; /* shortcut to access pixel data */
221 BOOL onTiger;
222 NSColor *stippleMask;
223}
224+ allocInitFromFile: (Lisp_Object)file;
225- reference;
226- imageListSetNext: (id)arg;
227- imageListNext;
228- (void)dealloc;
229- initFromXBM: (unsigned char *)bits width: (int)w height: (int)h
230 flip: (BOOL)flip;
231- initFromSkipXBM: (unsigned char *)bits width: (int)w height: (int)h
232 flip: (BOOL)flip length: (int)length;
233- setXBMColor: (NSColor *)color;
234- initForXPMWithDepth: (int)depth width: (int)width height: (int)height;
235- (void)setPixmapData;
236- (unsigned long)getPixelAtX: (int)x Y: (int)y;
237- (void)setPixelAtX: (int)x Y: (int)y toRed: (unsigned char)r
238 green: (unsigned char)g blue: (unsigned char)b
239 alpha:(unsigned char)a;
240- (void)setAlphaAtX: (int)x Y: (int)y to: (unsigned char)a;
241- (NSColor *)stippleMask;
242@end
243
244
245/* ==========================================================================
246
247 Scrollbars
248
249 ========================================================================== */
250
251@interface EmacsScroller : NSScroller
252 {
253 Lisp_Object win;
254 struct frame *frame;
255 NSResponder *prevResponder;
256
257 /* offset to the bottom of knob of last mouse down */
258 float last_mouse_offset;
259 float min_portion;
260 int pixel_height;
261 int last_hit_part;
262
263 BOOL condemned;
264
265 /* optimize against excessive positioning calls generated by emacs */
266 int em_position;
267 int em_portion;
268 int em_whole;
269 }
270
271- initFrame: (NSRect )r window: (Lisp_Object)win;
272- (void)setFrame: (NSRect)r;
273- (void)dealloc;
274
275- setPosition: (int) position portion: (int) portion whole: (int) whole;
276- (int) checkSamePosition: (int)position portion: (int)portion
277 whole: (int)whole;
278- (void) getMouseMotionPart: (int *)part window: (Lisp_Object *)window
279 x: (Lisp_Object *)x y: ( Lisp_Object *)y;
280- (void) sendScrollEventAtLoc: (float)loc fromEvent: (NSEvent *)e;
281- repeatScroll: (NSTimer *)sender;
282- condemn;
283- reprieve;
284- judge;
285@end
286
287
288/* ==========================================================================
289
290 Rendering on Panther and above
291
292 ========================================================================== */
293
294#ifdef NS_IMPL_COCOA
295/* rendering util */
296@interface EmacsGlyphStorage : NSObject <NSGlyphStorage>
297{
298@public
299 NSAttributedString *attrStr;
300 NSMutableDictionary *dict;
301 CGGlyph *cglyphs;
302 unsigned long maxChar, maxGlyph;
303 long i, len;
304}
305- initWithCapacity: (unsigned long) c;
306- (void) setString: (NSString *)str font: (NSFont *)font;
307@end
308#endif /* NS_IMPL_COCOA */
309
310
311/* ==========================================================================
312
313 Running the preferences window
314
315 ========================================================================== */
316
317@interface EmacsPrefsController : NSObject
318{
319 struct frame *frame;
320 IBOutlet NSWindow *prefsWindow;
321 IBOutlet NSPopUpButton *alternateModMenu;
322 IBOutlet NSPopUpButton *commandModMenu;
323#ifdef NS_IMPL_COCOA
324 IBOutlet NSPopUpButton *controlModMenu;
325 IBOutlet NSPopUpButton *functionModMenu;
326#endif
327 IBOutlet NSMatrix *cursorTypeMatrix;
328 IBOutlet NSSlider *cursorBlinkSlider;
329 IBOutlet NSSlider *expandSpaceSlider;
330#ifdef NS_IMPL_COCOA
331 IBOutlet NSButton *smoothFontsCheck;
332 IBOutlet NSButton *useQuickdrawCheck;
333 IBOutlet NSButton *useSysHiliteCheck;
5c976973 334 Lisp_Object prevUseHighlightColor;
edfda783
AR
335#endif
336 float prevExpandSpace;
337 float prevBlinkRate;
338}
339- (IBAction)cancel: (id)sender;
340- (IBAction)ok: (id)sender;
341- (IBAction)resetToDefaults: (id)sender;
342- (IBAction)runHelp: (id)sender;
343- (IBAction)setColors: (id)sender;
344- (IBAction)setDefaultFont: (id)sender;
345
346- (void) showForFrame: (struct frame *)f;
347- (void) setPanelFromValues;
348- (void) setValuesFromPanel;
349@end
350
351extern NSArray *ns_send_types, *ns_return_types;
352extern EmacsMenu *mainMenu, *svcsMenu;
353
354/* Apple removed the declaration, but kept the implementation */
355#if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_4
356@interface NSApplication (EmacsApp)
357- (void)setAppleMenu: (NSMenu *)menu;
358@end
359#endif
360
361#endif /* __OBJC__ */
362
363
364
365/* ==========================================================================
366
367 Non-OO stuff
368
369 ========================================================================== */
370
371enum ns_cursor_types
372{
373 no_highlight =0,
374 filled_box,
375 hollow_box,
376 underscore,
377 bar
378};
379
380
381/* could use list to store these, but rest of emacs has a big infrastructure
382 for managing a table of bitmap "records" */
383struct ns_bitmap_record
384{
385#ifdef __OBJC__
386 EmacsImage *img;
387#else
388 void *img;
389#endif
390 char *file;
391 int refcount;
392 int height, width, depth;
393};
394
395/* this to map between emacs color indices and NSColor objects */
396struct ns_color_table
397{
398 unsigned int size;
399 unsigned int avail;
400#ifdef __OBJC__
401 NSColor **colors;
402 NSMutableSet *empty_indices;
403#else
404 void **items;
405 void *availIndices;
406#endif
407};
408#define NS_COLOR_CAPACITY 256
409
410#define RGB_TO_ULONG(r, g, b) (((r) << 16) | ((g) << 8) | (b))
411#define ARGB_TO_ULONG(a, r, g, b) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))
412
413#define ALPHA_FROM_ULONG(color) ((color) >> 24)
414#define RED_FROM_ULONG(color) (((color) >> 16) & 0xff)
415#define GREEN_FROM_ULONG(color) (((color) >> 8) & 0xff)
416#define BLUE_FROM_ULONG(color) ((color) & 0xff)
417
418/* Do not change `* 0x101' in the following lines to `<< 8'. If
419 changed, image masks in 1-bit depth will not work. */
420#define RED16_FROM_ULONG(color) (RED_FROM_ULONG(color) * 0x101)
421#define GREEN16_FROM_ULONG(color) (GREEN_FROM_ULONG(color) * 0x101)
422#define BLUE16_FROM_ULONG(color) (BLUE_FROM_ULONG(color) * 0x101)
423
424/* this extends font backend font */
425struct nsfont_info
426{
427 struct font font;
428
429 char *name; /* postscript name, uniquely identifies on NS systems */
430 float width; /* this and following metrics stored as float rather than int */
431 float height;
432 float underpos;
433 float underwidth;
434 float size;
435#ifdef __OBJC__
436 NSFont *nsfont;
437 /* cgfont and synthItal are used only on OS X 10.3+ */
438#if defined (NS_IMPL_COCOA) && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3)
439 CGFontRef cgfont;
440#else /* GNUstep or OS X < 10.3 */
441 void *cgfont;
442#endif
443#else /* ! OBJC */
444 void *nsfont;
445 void *cgfont;
446#endif
447 char bold, ital; /* convenience flags */
448 char synthItal;
449 float voffset; /* mean of ascender/descender offsets */
450 XCharStruct max_bounds; /* 23 */
451 /* we compute glyph codes and metrics on-demand in blocks of 256 indexed
452 by hibyte, lobyte */
453 unsigned short **glyphs; /* map unicode index to glyph */
454 struct font_metrics **metrics;
455};
456
457
458/* init'd in ns_initialize_display_info () */
459struct ns_display_info
460{
461 /* Chain of all ns_display_info structures. */
462 struct ns_display_info *next;
463
464 /* The generic display parameters corresponding to this NS display. */
465 struct terminal *terminal;
466
467 /* This is a cons cell of the form (NAME . FONT-LIST-CACHE).
468 The same cons cell also appears in ns_display_name_list. */
469 Lisp_Object name_list_element;
470
471 /* The number of fonts loaded. */
472 int n_fonts;
473
474 /* Minimum width over all characters in all fonts in font_table. */
475 int smallest_char_width;
476
477 /* Minimum font height over all fonts in font_table. */
478 int smallest_font_height;
479
edfda783
AR
480 /*/23 */
481 struct ns_bitmap_record *bitmaps;
482 int bitmaps_size;
483 int bitmaps_last;
484
485 /* 23 */
486 struct image_cache *image_cache;
487
488 struct ns_color_table *color_table;
489
490 /* 23: Dimensions and DPI resolution of this screen */
491 int height, width;
492 double resx, resy;
493
494 /* 23: Mask of things that cause the mouse to be grabbed */
495 int grabbed;
496
497 /* 23 */
498 int n_planes;
499
500 /* 23 */
501 int color_p;
502
503 /* 23 */
504 Window root_window;
505
506 /* 23: Xism */
507 XrmDatabase xrdb;
508
509 /* 23: The cursor to use for vertical scroll bars. */
510 Cursor vertical_scroll_bar_cursor;
511
512 /* 23: most mouse face stuff moved in here (and reasonably so) */
513 int mouse_face_beg_row, mouse_face_beg_col;
514 int mouse_face_end_row, mouse_face_end_col;
515 int mouse_face_beg_x, mouse_face_beg_y;
516 int mouse_face_end_x, mouse_face_end_y;
517 int mouse_face_past_end;
518 Lisp_Object mouse_face_window;
519 int mouse_face_face_id;
520 int mouse_face_deferred_gc;
521 Lisp_Object mouse_face_overlay;
522 FRAME_PTR mouse_face_mouse_frame;
523 int mouse_face_mouse_x, mouse_face_mouse_y;
524 int mouse_face_defer;
525 int mouse_face_hidden;
526 int mouse_face_image_state;
527
9e50ff0c
DN
528 struct frame *x_highlight_frame;
529 struct frame *x_focus_frame;
edfda783
AR
530};
531
532/* This is a chain of structures for all the NS displays currently in use. */
9e50ff0c 533extern struct ns_display_info *x_display_list;
edfda783
AR
534
535extern Lisp_Object ns_display_name_list;
536extern struct ns_display_info *ns_display_info_for_name ();
537
6fb5f7da 538/* 23: FIXME: these functions (we defined in nsfns) are used in various
edfda783
AR
539 places, but no prototypes are provided */
540struct ns_display_info *check_x_display_info (Lisp_Object frame);
541FRAME_PTR check_x_frame (Lisp_Object frame);
542
543
544struct ns_output
545{
546#ifdef __OBJC__
547 EmacsView *view;
548 id miniimage;
549 NSColor *current_cursor_color;
550 NSColor *desired_cursor_color;
551 NSColor *foreground_color;
552 NSColor *background_color;
553 EmacsToolbar *toolbar;
554#else
555 void *view;
556 void *miniimage;
557 void *current_cursor_color;
558 void *desired_cursor_color;
559 void *foreground_color;
560 void *background_color;
561 void *toolbar;
562#endif
563
564 /* 23: NSCursors init'ed in initFrameFromEmacs */
565 Cursor text_cursor;
566 Cursor nontext_cursor;
567 Cursor modeline_cursor;
568 Cursor hand_cursor;
569 Cursor hourglass_cursor;
570 Cursor horizontal_drag_cursor;
571
572 /* 23: NS-specific */
573 Cursor current_pointer;
574
575 /* 23: lord knows why Emacs needs to know about our Window ids.. */
576 Window window_desc, parent_desc;
577 char explicit_parent;
578
579 struct font *font;
580 int baseline_offset;
581
582 /* If a fontset is specified for this frame instead of font, this
583 value contains an ID of the fontset, else -1. */
584 int fontset; /* only used with font_backend */
585
586 Lisp_Object icon_top;
587 Lisp_Object icon_left;
588 enum ns_cursor_types current_cursor, desired_cursor;
589 unsigned char last_inactive;
590
591 /* The size of the extra width currently allotted for vertical
592 scroll bars, in pixels. */
593 int vertical_scroll_bar_extra;
594
595 /* The height of the titlebar decoration (included in NSWindow's frame). */
596 int titlebar_height;
597
598 /* The height of the toolbar if displayed, else 0. */
599 int toolbar_height;
600
601 /* This is the Emacs structure for the NS display this frame is on. */
602 struct ns_display_info *display_info;
603};
604
605/* 23: this dummy decl now needed to support TTYs */
606struct x_output
607{
608 unsigned long background_pixel;
609 unsigned long foreground_pixel;
610};
611
612
613/* This gives the ns_display_info structure for the display F is on. */
614#define FRAME_NS_DISPLAY_INFO(f) ((f)->output_data.ns->display_info)
615/* the primacy of X must be constantly worked with... */
616#define FRAME_X_DISPLAY_INFO(f) ((f)->output_data.ns->display_info)
617#define FRAME_X_OUTPUT(f) ((f)->output_data.ns)
618#define FRAME_NS_WINDOW(f) ((f)->output_data.ns->window_desc)
619#define FRAME_X_WINDOW(f) ((f)->output_data.ns->window_desc)
620
621/* This is the `Display *' which frame F is on. */
622#define FRAME_NS_DISPLAY(f) (0)
623#define FRAME_X_DISPLAY(f) (0)
624
625#define FRAME_FOREGROUND_COLOR(f) ((f)->output_data.ns->foreground_color)
626#define FRAME_BACKGROUND_COLOR(f) ((f)->output_data.ns->background_color)
627
628#define FRAME_X_IMAGE_CACHE(F) FRAME_NS_DISPLAY_INFO ((F))->image_cache
629
630#define NS_FACE_FOREGROUND(f) ((f)->foreground)
631#define NS_FACE_BACKGROUND(f) ((f)->background)
632#define FRAME_NS_TITLEBAR_HEIGHT(f) ((f)->output_data.ns->titlebar_height)
633#define FRAME_NS_TOOLBAR_HEIGHT(f) ((f)->output_data.ns->toolbar_height)
634
635#define FONT_WIDTH(f) ((f)->max_width)
636#define FONT_HEIGHT(f) ((f)->height)
637/*#define FONT_BASE(f) ((f)->ascent) */
638#define FONT_BASE(f) (((struct nsfont_info *)f)->max_bounds.ascent)
639/*#define FONT_DESCENT(f) ((f)->descent) */
640#define FONT_DESCENT(f) (((struct nsfont_info *)f)->max_bounds.descent)
641
642#define FRAME_DEFAULT_FACE(f) FACE_FROM_ID (f, DEFAULT_FACE_ID)
643
644#define FRAME_NS_VIEW(f) ((f)->output_data.ns->view)
645#define FRAME_CURSOR(f) ((f)->output_data.ns->current_cursor)
646#define FRAME_CURSOR_COLOR(f) ((f)->output_data.ns->current_cursor_color)
647#define FRAME_NEW_CURSOR_COLOR(f) ((f)->output_data.ns->desired_cursor_color)
648#define FRAME_NEW_CURSOR(f) ((f)->output_data.ns->desired_cursor)
649#define FRAME_POINTER_TYPE(f) ((f)->output_data.ns->current_pointer)
650#define FRAME_LAST_INACTIVE(f) ((f)->output_data.ns->last_inactive)
651
652#define FRAME_FONT(f) ((f)->output_data.ns->font)
653
654#ifdef __OBJC__
655#define XNS_SCROLL_BAR(vec) ((id) XSAVE_VALUE (vec)->pointer)
656#else
657#define XNS_SCROLL_BAR(vec) XSAVE_VALUE (vec)->pointer
658#endif
659
660/* Compute pixel size for vertical scroll bars */
661#define NS_SCROLL_BAR_WIDTH(f) \
662(FRAME_HAS_VERTICAL_SCROLL_BARS (f) \
663 ? rint (FRAME_CONFIG_SCROLL_BAR_WIDTH (f) > 0 \
664 ? FRAME_CONFIG_SCROLL_BAR_WIDTH (f) \
665 : (FRAME_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f))) \
666 : 0)
667
668/* Difference btwn char-column-calculated and actual SB widths.
669 This is only a concern for rendering when SB on left. */
670#define NS_SCROLL_BAR_ADJUST(w, f) \
671(WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (w) ? \
672 (FRAME_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f) \
673 - NS_SCROLL_BAR_WIDTH (f)) : 0)
674
6fb5f7da 675/* XXX: fix for GNUstep inconsistent accounting for titlebar */
edfda783
AR
676#ifdef NS_IMPL_GNUSTEP
677#define NS_TOP_POS(f) ((f)->top_pos + 18)
678#else
679#define NS_TOP_POS(f) ((f)->top_pos)
680#endif
681
682#define FRAME_NS_FONT_TABLE(f) (FRAME_NS_DISPLAY_INFO (f)->font_table)
683
684#define FRAME_FONTSET(f) ((f)->output_data.ns->fontset)
685
686/* 23 */
687#define FRAME_SMALLEST_CHAR_WIDTH(f) \
688 (FRAME_NS_DISPLAY_INFO (f)->smallest_char_width)
689#define FRAME_SMALLEST_FONT_HEIGHT(f) \
690 (FRAME_NS_DISPLAY_INFO (f)->smallest_font_height)
691#define FONT_TYPE_FOR_UNIBYTE(font, ch) 0
692#define FONT_TYPE_FOR_MULTIBYTE(font, ch) 0
693#define FRAME_BASELINE_OFFSET(f) ((f)->output_data.ns->baseline_offset)
694#define BLACK_PIX_DEFAULT(f) 0x000000
695#define WHITE_PIX_DEFAULT(f) 0xFFFFFF
696
697/* First position where characters can be shown (instead of scrollbar, if
698 it is on left. */
699#define FIRST_CHAR_POSITION(f) \
700 (! (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f)) ? 0 \
701 : FRAME_SCROLL_BAR_COLS (f))
702
703extern struct ns_display_info *ns_term_init ();
704extern void ns_term_shutdown (int sig);
705
706/* constants for text rendering */
707#define NS_DUMPGLYPH_NORMAL 0
708#define NS_DUMPGLYPH_CURSOR 1
709#define NS_DUMPGLYPH_FOREGROUND 2
710#define NS_DUMPGLYPH_MOUSEFACE 3
711
712
facfbbbd
SM
713EXFUN (Fx_display_grayscale_p, 1);
714EXFUN (Fx_display_planes, 1);
715
edfda783
AR
716/* In nsfont, called from fontset.c */
717extern void nsfont_make_fontset_for_font (Lisp_Object name,
718 Lisp_Object font_object);
719
720/* In nsfont, for debugging */
721struct glyph_string;
722void dump_glyphstring (struct glyph_string *s);
723
724/* Implemented in nsterm, published in or needed from nsfns. */
725extern Lisp_Object Qfontsize;
726extern Lisp_Object ns_list_fonts (FRAME_PTR f, Lisp_Object pattern,
727 int size, int maxnames);
728extern void ns_clear_frame (struct frame *f);
729
730#ifdef __OBJC__
731extern const char *ns_font_to_xlfd (NSFont *font);
732#endif
733extern const char *ns_fontname_to_xlfd (const char *name);
734extern const char *ns_xlfd_to_fontname (const char *xlfd);
735
736extern void check_ns (void);
737extern Lisp_Object ns_map_event_to_object ();
738extern Lisp_Object ns_string_from_pasteboard ();
739extern void ns_string_to_pasteboard ();
740extern void nxatoms_of_nsselect ();
741extern int ns_lisp_to_cursor_type ();
742extern Lisp_Object ns_cursor_type_to_lisp (int arg);
743extern Lisp_Object Qnone;
744
745/* XColor defined in dispextern.h (we use color_def->pixel = NSColor id), but
facfbbbd
SM
746 this causes an #include snafu, so we can't declare it. */
747extern int
748ns_defined_color (struct frame *f, char *name, XColor *color_def, int alloc,
749 char makeIndex);
edfda783
AR
750
751#ifdef __OBJC__
facfbbbd 752extern Lisp_Object ns_color_to_lisp (NSColor *col);
edfda783
AR
753extern int ns_lisp_to_color (Lisp_Object color, NSColor **col);
754extern NSColor *ns_lookup_indexed_color (unsigned long idx, struct frame *f);
755extern unsigned long ns_index_color (NSColor *color, struct frame *f);
756extern void ns_free_indexed_color (unsigned long idx, struct frame *f);
757#endif
758
759/* C access to ObjC functionality */
760extern void ns_release_object (void *obj);
761extern void ns_retain_object (void *obj);
762extern void *ns_alloc_autorelease_pool ();
763extern void ns_release_autorelease_pool ();
764
765/* in nsmenu */
766extern void update_frame_tool_bar (FRAME_PTR f);
767extern void free_frame_tool_bar (FRAME_PTR f);
768extern void find_and_call_menu_selection (FRAME_PTR f,
769 EMACS_INT menu_bar_items_used, Lisp_Object vector, void *client_data);
770extern Lisp_Object find_and_return_menu_selection (FRAME_PTR f,
771 int keymaps,
772 void *client_data);
773extern Lisp_Object ns_popup_dialog (Lisp_Object position, Lisp_Object contents,
774 Lisp_Object header);
775
776/* two more prototypes that should be moved to a more general include file */
777extern void set_frame_menubar (struct frame *f, int first_time, int deep_p);
778extern void x_set_window_size (struct frame *f, int change_grav,
779 int cols, int rows);
780
781/* From nsimage.m, needed in image.c */
782struct image;
783extern void *ns_image_from_XBM (unsigned char *bits, int width, int height);
784extern void *ns_image_for_XPM (int width, int height, int depth);
785extern void *ns_image_from_file (Lisp_Object file);
786extern int ns_load_image (struct frame *f, struct image *img,
787 Lisp_Object spec_file, Lisp_Object spec_data);
788extern int ns_image_width (void *img);
789extern int ns_image_height (void *img);
790extern unsigned long ns_get_pixel (void *img, int x, int y);
791extern void ns_put_pixel (void *img, int x, int y, unsigned long argb);
792extern void ns_set_alpha (void *img, int x, int y, unsigned char a);
793
794/* This in nsterm.m */
795extern unsigned long ns_get_rgb_color (struct frame *f,
796 float r, float g, float b, float a);
797extern NSPoint last_mouse_motion_position;
798
799#ifdef NS_IMPL_GNUSTEP
800extern char gnustep_base_version[]; /* version tracking */
801#endif
802
803#define MINWIDTH 10
804#define MINHEIGHT 10
805
806/* Screen max coordinate
807 Using larger coordinates causes movewindow/placewindow to abort */
808#define SCREENMAX 16000
809
810#define NS_SCROLL_BAR_WIDTH_DEFAULT [EmacsScroller scrollerWidth]
811/* This is to match emacs on other platforms, ugly though it is. */
812#define NS_SELECTION_COLOR_DEFAULT @"LightGoldenrod2";
813#define RESIZE_HANDLE_SIZE 12
814
815/* Little utility macros */
816#define IN_BOUND(min, x, max) (((x) < (min)) \
817 ? (min) : (((x)>(max)) ? (max) : (x)))
818#define SCREENMAXBOUND(x) (IN_BOUND (-SCREENMAX, x, SCREENMAX))
819
820/* 23: needed somewhere... */
821#define VERTICAL_SCROLL_BAR_WIDTH_TRIM (0)
822
823
824#endif /* HAVE_NS */
0ae1e5e5
MB
825
826/* arch-tag: 0a28b142-4ac1-4a81-a243-abcd82d9c4e5
827 (do not change this comment) */