* nsfns.m (ns-read-file-name): Fix typo in assignment statement.
[bpt/emacs.git] / src / nsterm.h
CommitLineData
edfda783 1/* Definitions and headers for communication with NeXT/Open/GNUstep API.
76b6f707 2 Copyright (C) 1989, 1993, 2005, 2008, 2009 Free Software Foundation, Inc.
edfda783
AR
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}
15034960 39- (void)logNotification: (NSNotification *)notification;
edfda783
AR
40- (void)sendEvent: (NSEvent *)theEvent;
41- (void)showPreferencesWindow: (id)sender;
15034960
AR
42- (BOOL) openFile: (NSString *)fileName;
43- (void)fd_handler: (NSTimer *) fdEntry;
15034960
AR
44- (void)timeout_handler: (NSTimer *)timedEntry;
45- (BOOL)fulfillService: (NSString *)name withArg: (NSString *)arg;
edfda783
AR
46@end
47
48
49/* ==========================================================================
50
51 The main Emacs view
52
53 ========================================================================== */
54
55@class EmacsToolbar;
56
57@interface EmacsView : NSView <NSTextInput>
58 {
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;
68 }
69
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;
78
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;
f2f7f42c
AR
85
86#ifdef NS_IMPL_GNUSTEP
87/* Not declared, but useful. */
88- (void) unlockFocusNeedsFlush: (BOOL)needs;
89#endif
edfda783
AR
90@end
91
92
93/* Small utility used for processing resize events under Cocoa. */
94@interface EmacsWindow : NSWindow
95{
96 NSPoint grabOffset;
97}
98@end
99
100
101/* ==========================================================================
102
103 The main menu implementation
104
105 ========================================================================== */
106
107@interface EmacsMenu : NSMenu
108{
109 struct frame *frame;
110 unsigned long keyEquivModMask;
111}
112
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;
15034960 117- (NSMenuItem *)addItemWithWidgetValue: (void *)wvptr;
edfda783
AR
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
124
125
126/* ==========================================================================
127
128 Toolbar
129
130 ========================================================================== */
131
132@class EmacsImage;
133
134@interface EmacsToolbar : NSToolbar
135 {
136 EmacsView *emacsView;
137 NSMutableDictionary *identifierToItem;
138 NSMutableArray *activeIdentifiers;
139 NSArray *prevIdentifiers;
140 unsigned long enablement, prevEnablement;
141 }
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
155
156
157/* ==========================================================================
158
159 Message / question windows
160
161 ========================================================================== */
162
163@interface EmacsDialogPanel : NSPanel
164 {
165 NSTextField *command;
166 NSTextField *title;
167 NSMatrix *matrix;
168 int rows, cols;
169 }
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
176
177@interface EmacsTooltip : NSObject
178 {
179 NSWindow *win;
180 NSTextField *textField;
181 NSTimer *timer;
182 }
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
190
191
192/* ==========================================================================
193
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.
197
198 ========================================================================== */
199
200@interface EmacsSavePanel : NSSavePanel
201{
202}
203@end
204@interface EmacsOpenPanel : NSOpenPanel
205{
206}
207@end
208
209@interface EmacsFileDelegate : NSObject
210{
211}
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
217
218
219/* ==========================================================================
220
221 Images and stippling
222
223 ========================================================================== */
224
225@interface EmacsImage : NSImage
226{
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;
233}
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
253
254
255/* ==========================================================================
256
257 Scrollbars
258
259 ========================================================================== */
260
261@interface EmacsScroller : NSScroller
262 {
263 Lisp_Object win;
264 struct frame *frame;
265 NSResponder *prevResponder;
266
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;
272
273 BOOL condemned;
274
275 /* optimize against excessive positioning calls generated by emacs */
276 int em_position;
277 int em_portion;
278 int em_whole;
279 }
280
281- initFrame: (NSRect )r window: (Lisp_Object)win;
282- (void)setFrame: (NSRect)r;
283- (void)dealloc;
284
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
296
297
298/* ==========================================================================
299
300 Rendering on Panther and above
301
302 ========================================================================== */
303
304#ifdef NS_IMPL_COCOA
305/* rendering util */
306@interface EmacsGlyphStorage : NSObject <NSGlyphStorage>
307{
308@public
309 NSAttributedString *attrStr;
310 NSMutableDictionary *dict;
311 CGGlyph *cglyphs;
312 unsigned long maxChar, maxGlyph;
313 long i, len;
314}
315- initWithCapacity: (unsigned long) c;
316- (void) setString: (NSString *)str font: (NSFont *)font;
317@end
318#endif /* NS_IMPL_COCOA */
319
320
321/* ==========================================================================
322
323 Running the preferences window
324
325 ========================================================================== */
326
327@interface EmacsPrefsController : NSObject
328{
329 struct frame *frame;
330 IBOutlet NSWindow *prefsWindow;
331 IBOutlet NSPopUpButton *alternateModMenu;
332 IBOutlet NSPopUpButton *commandModMenu;
333#ifdef NS_IMPL_COCOA
334 IBOutlet NSPopUpButton *controlModMenu;
335 IBOutlet NSPopUpButton *functionModMenu;
336#endif
337 IBOutlet NSMatrix *cursorTypeMatrix;
338 IBOutlet NSSlider *cursorBlinkSlider;
339 IBOutlet NSSlider *expandSpaceSlider;
340#ifdef NS_IMPL_COCOA
341 IBOutlet NSButton *smoothFontsCheck;
342 IBOutlet NSButton *useQuickdrawCheck;
343 IBOutlet NSButton *useSysHiliteCheck;
5c976973 344 Lisp_Object prevUseHighlightColor;
edfda783
AR
345#endif
346 float prevExpandSpace;
347 float prevBlinkRate;
348}
349- (IBAction)cancel: (id)sender;
350- (IBAction)ok: (id)sender;
351- (IBAction)resetToDefaults: (id)sender;
352- (IBAction)runHelp: (id)sender;
353- (IBAction)setColors: (id)sender;
354- (IBAction)setDefaultFont: (id)sender;
355
356- (void) showForFrame: (struct frame *)f;
357- (void) setPanelFromValues;
6049d3a0 358- (void) setPanelFromDefaultValues;
edfda783
AR
359- (void) setValuesFromPanel;
360@end
361
362extern NSArray *ns_send_types, *ns_return_types;
4e622592 363extern EmacsMenu *mainMenu, *svcsMenu, *dockMenu;
edfda783
AR
364
365/* Apple removed the declaration, but kept the implementation */
a39e2539 366#if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
edfda783
AR
367@interface NSApplication (EmacsApp)
368- (void)setAppleMenu: (NSMenu *)menu;
369@end
370#endif
371
55737942 372#ifndef NS_HAVE_NSINTEGER
04f33e11
AR
373typedef long NSInteger;
374typedef unsigned long NSUInteger;
55737942 375#endif /* not NS_HAVE_NSINTEGER */
04f33e11 376
edfda783
AR
377#endif /* __OBJC__ */
378
379
380
381/* ==========================================================================
382
383 Non-OO stuff
384
385 ========================================================================== */
386
edfda783
AR
387/* could use list to store these, but rest of emacs has a big infrastructure
388 for managing a table of bitmap "records" */
389struct ns_bitmap_record
390{
391#ifdef __OBJC__
392 EmacsImage *img;
393#else
394 void *img;
395#endif
396 char *file;
397 int refcount;
398 int height, width, depth;
399};
400
401/* this to map between emacs color indices and NSColor objects */
402struct ns_color_table
403{
404 unsigned int size;
405 unsigned int avail;
406#ifdef __OBJC__
407 NSColor **colors;
408 NSMutableSet *empty_indices;
409#else
410 void **items;
411 void *availIndices;
412#endif
413};
414#define NS_COLOR_CAPACITY 256
415
416#define RGB_TO_ULONG(r, g, b) (((r) << 16) | ((g) << 8) | (b))
417#define ARGB_TO_ULONG(a, r, g, b) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))
418
419#define ALPHA_FROM_ULONG(color) ((color) >> 24)
420#define RED_FROM_ULONG(color) (((color) >> 16) & 0xff)
421#define GREEN_FROM_ULONG(color) (((color) >> 8) & 0xff)
422#define BLUE_FROM_ULONG(color) ((color) & 0xff)
423
424/* Do not change `* 0x101' in the following lines to `<< 8'. If
425 changed, image masks in 1-bit depth will not work. */
426#define RED16_FROM_ULONG(color) (RED_FROM_ULONG(color) * 0x101)
427#define GREEN16_FROM_ULONG(color) (GREEN_FROM_ULONG(color) * 0x101)
428#define BLUE16_FROM_ULONG(color) (BLUE_FROM_ULONG(color) * 0x101)
429
430/* this extends font backend font */
431struct nsfont_info
432{
433 struct font font;
434
435 char *name; /* postscript name, uniquely identifies on NS systems */
436 float width; /* this and following metrics stored as float rather than int */
437 float height;
438 float underpos;
439 float underwidth;
440 float size;
441#ifdef __OBJC__
442 NSFont *nsfont;
443 /* cgfont and synthItal are used only on OS X 10.3+ */
444#if defined (NS_IMPL_COCOA) && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3)
445 CGFontRef cgfont;
446#else /* GNUstep or OS X < 10.3 */
447 void *cgfont;
448#endif
449#else /* ! OBJC */
450 void *nsfont;
451 void *cgfont;
452#endif
453 char bold, ital; /* convenience flags */
454 char synthItal;
455 float voffset; /* mean of ascender/descender offsets */
456 XCharStruct max_bounds; /* 23 */
457 /* we compute glyph codes and metrics on-demand in blocks of 256 indexed
458 by hibyte, lobyte */
459 unsigned short **glyphs; /* map unicode index to glyph */
460 struct font_metrics **metrics;
461};
462
463
464/* init'd in ns_initialize_display_info () */
465struct ns_display_info
466{
467 /* Chain of all ns_display_info structures. */
468 struct ns_display_info *next;
469
470 /* The generic display parameters corresponding to this NS display. */
471 struct terminal *terminal;
472
473 /* This is a cons cell of the form (NAME . FONT-LIST-CACHE).
474 The same cons cell also appears in ns_display_name_list. */
475 Lisp_Object name_list_element;
476
477 /* The number of fonts loaded. */
478 int n_fonts;
479
480 /* Minimum width over all characters in all fonts in font_table. */
481 int smallest_char_width;
482
483 /* Minimum font height over all fonts in font_table. */
484 int smallest_font_height;
485
edfda783
AR
486 /*/23 */
487 struct ns_bitmap_record *bitmaps;
488 int bitmaps_size;
489 int bitmaps_last;
490
491 /* 23 */
492 struct image_cache *image_cache;
493
494 struct ns_color_table *color_table;
495
b532986e 496 /* 23: DPI resolution of this screen */
edfda783
AR
497 double resx, resy;
498
499 /* 23: Mask of things that cause the mouse to be grabbed */
500 int grabbed;
501
502 /* 23 */
503 int n_planes;
504
505 /* 23 */
506 int color_p;
507
508 /* 23 */
509 Window root_window;
510
511 /* 23: Xism */
512 XrmDatabase xrdb;
513
514 /* 23: The cursor to use for vertical scroll bars. */
515 Cursor vertical_scroll_bar_cursor;
516
517 /* 23: most mouse face stuff moved in here (and reasonably so) */
518 int mouse_face_beg_row, mouse_face_beg_col;
519 int mouse_face_end_row, mouse_face_end_col;
520 int mouse_face_beg_x, mouse_face_beg_y;
521 int mouse_face_end_x, mouse_face_end_y;
522 int mouse_face_past_end;
523 Lisp_Object mouse_face_window;
524 int mouse_face_face_id;
525 int mouse_face_deferred_gc;
526 Lisp_Object mouse_face_overlay;
527 FRAME_PTR mouse_face_mouse_frame;
528 int mouse_face_mouse_x, mouse_face_mouse_y;
529 int mouse_face_defer;
530 int mouse_face_hidden;
531 int mouse_face_image_state;
532
9e50ff0c
DN
533 struct frame *x_highlight_frame;
534 struct frame *x_focus_frame;
edfda783
AR
535};
536
537/* This is a chain of structures for all the NS displays currently in use. */
9e50ff0c 538extern struct ns_display_info *x_display_list;
edfda783
AR
539
540extern Lisp_Object ns_display_name_list;
541extern struct ns_display_info *ns_display_info_for_name ();
542
6fb5f7da 543/* 23: FIXME: these functions (we defined in nsfns) are used in various
edfda783
AR
544 places, but no prototypes are provided */
545struct ns_display_info *check_x_display_info (Lisp_Object frame);
546FRAME_PTR check_x_frame (Lisp_Object frame);
547
548
549struct ns_output
550{
551#ifdef __OBJC__
552 EmacsView *view;
553 id miniimage;
c8c057de 554 NSColor *cursor_color;
edfda783
AR
555 NSColor *foreground_color;
556 NSColor *background_color;
557 EmacsToolbar *toolbar;
558#else
559 void *view;
560 void *miniimage;
c8c057de 561 void *cursor_color;
edfda783
AR
562 void *foreground_color;
563 void *background_color;
564 void *toolbar;
565#endif
566
567 /* 23: NSCursors init'ed in initFrameFromEmacs */
568 Cursor text_cursor;
569 Cursor nontext_cursor;
570 Cursor modeline_cursor;
571 Cursor hand_cursor;
572 Cursor hourglass_cursor;
573 Cursor horizontal_drag_cursor;
574
575 /* 23: NS-specific */
576 Cursor current_pointer;
577
578 /* 23: lord knows why Emacs needs to know about our Window ids.. */
579 Window window_desc, parent_desc;
580 char explicit_parent;
581
582 struct font *font;
583 int baseline_offset;
584
585 /* If a fontset is specified for this frame instead of font, this
586 value contains an ID of the fontset, else -1. */
587 int fontset; /* only used with font_backend */
588
589 Lisp_Object icon_top;
590 Lisp_Object icon_left;
edfda783
AR
591
592 /* The size of the extra width currently allotted for vertical
593 scroll bars, in pixels. */
594 int vertical_scroll_bar_extra;
595
596 /* The height of the titlebar decoration (included in NSWindow's frame). */
597 int titlebar_height;
598
599 /* The height of the toolbar if displayed, else 0. */
600 int toolbar_height;
601
602 /* This is the Emacs structure for the NS display this frame is on. */
603 struct ns_display_info *display_info;
604};
605
606/* 23: this dummy decl now needed to support TTYs */
607struct x_output
608{
609 unsigned long background_pixel;
610 unsigned long foreground_pixel;
611};
612
613
614/* This gives the ns_display_info structure for the display F is on. */
615#define FRAME_NS_DISPLAY_INFO(f) ((f)->output_data.ns->display_info)
616/* the primacy of X must be constantly worked with... */
617#define FRAME_X_DISPLAY_INFO(f) ((f)->output_data.ns->display_info)
618#define FRAME_X_OUTPUT(f) ((f)->output_data.ns)
619#define FRAME_NS_WINDOW(f) ((f)->output_data.ns->window_desc)
620#define FRAME_X_WINDOW(f) ((f)->output_data.ns->window_desc)
621
622/* This is the `Display *' which frame F is on. */
623#define FRAME_NS_DISPLAY(f) (0)
624#define FRAME_X_DISPLAY(f) (0)
625
626#define FRAME_FOREGROUND_COLOR(f) ((f)->output_data.ns->foreground_color)
627#define FRAME_BACKGROUND_COLOR(f) ((f)->output_data.ns->background_color)
628
629#define FRAME_X_IMAGE_CACHE(F) FRAME_NS_DISPLAY_INFO ((F))->image_cache
630
631#define NS_FACE_FOREGROUND(f) ((f)->foreground)
632#define NS_FACE_BACKGROUND(f) ((f)->background)
633#define FRAME_NS_TITLEBAR_HEIGHT(f) ((f)->output_data.ns->titlebar_height)
634#define FRAME_NS_TOOLBAR_HEIGHT(f) ((f)->output_data.ns->toolbar_height)
635
636#define FONT_WIDTH(f) ((f)->max_width)
637#define FONT_HEIGHT(f) ((f)->height)
638/*#define FONT_BASE(f) ((f)->ascent) */
639#define FONT_BASE(f) (((struct nsfont_info *)f)->max_bounds.ascent)
640/*#define FONT_DESCENT(f) ((f)->descent) */
641#define FONT_DESCENT(f) (((struct nsfont_info *)f)->max_bounds.descent)
642
643#define FRAME_DEFAULT_FACE(f) FACE_FROM_ID (f, DEFAULT_FACE_ID)
644
645#define FRAME_NS_VIEW(f) ((f)->output_data.ns->view)
c8c057de 646#define FRAME_CURSOR_COLOR(f) ((f)->output_data.ns->cursor_color)
edfda783 647#define FRAME_POINTER_TYPE(f) ((f)->output_data.ns->current_pointer)
edfda783
AR
648
649#define FRAME_FONT(f) ((f)->output_data.ns->font)
650
651#ifdef __OBJC__
652#define XNS_SCROLL_BAR(vec) ((id) XSAVE_VALUE (vec)->pointer)
653#else
654#define XNS_SCROLL_BAR(vec) XSAVE_VALUE (vec)->pointer
655#endif
656
657/* Compute pixel size for vertical scroll bars */
658#define NS_SCROLL_BAR_WIDTH(f) \
659(FRAME_HAS_VERTICAL_SCROLL_BARS (f) \
660 ? rint (FRAME_CONFIG_SCROLL_BAR_WIDTH (f) > 0 \
661 ? FRAME_CONFIG_SCROLL_BAR_WIDTH (f) \
662 : (FRAME_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f))) \
663 : 0)
664
665/* Difference btwn char-column-calculated and actual SB widths.
666 This is only a concern for rendering when SB on left. */
667#define NS_SCROLL_BAR_ADJUST(w, f) \
668(WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (w) ? \
669 (FRAME_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f) \
670 - NS_SCROLL_BAR_WIDTH (f)) : 0)
671
6fb5f7da 672/* XXX: fix for GNUstep inconsistent accounting for titlebar */
edfda783
AR
673#ifdef NS_IMPL_GNUSTEP
674#define NS_TOP_POS(f) ((f)->top_pos + 18)
675#else
676#define NS_TOP_POS(f) ((f)->top_pos)
677#endif
678
679#define FRAME_NS_FONT_TABLE(f) (FRAME_NS_DISPLAY_INFO (f)->font_table)
680
681#define FRAME_FONTSET(f) ((f)->output_data.ns->fontset)
682
683/* 23 */
684#define FRAME_SMALLEST_CHAR_WIDTH(f) \
685 (FRAME_NS_DISPLAY_INFO (f)->smallest_char_width)
686#define FRAME_SMALLEST_FONT_HEIGHT(f) \
687 (FRAME_NS_DISPLAY_INFO (f)->smallest_font_height)
688#define FONT_TYPE_FOR_UNIBYTE(font, ch) 0
689#define FONT_TYPE_FOR_MULTIBYTE(font, ch) 0
690#define FRAME_BASELINE_OFFSET(f) ((f)->output_data.ns->baseline_offset)
691#define BLACK_PIX_DEFAULT(f) 0x000000
692#define WHITE_PIX_DEFAULT(f) 0xFFFFFF
693
694/* First position where characters can be shown (instead of scrollbar, if
695 it is on left. */
696#define FIRST_CHAR_POSITION(f) \
697 (! (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f)) ? 0 \
698 : FRAME_SCROLL_BAR_COLS (f))
699
700extern struct ns_display_info *ns_term_init ();
701extern void ns_term_shutdown (int sig);
702
703/* constants for text rendering */
704#define NS_DUMPGLYPH_NORMAL 0
705#define NS_DUMPGLYPH_CURSOR 1
706#define NS_DUMPGLYPH_FOREGROUND 2
707#define NS_DUMPGLYPH_MOUSEFACE 3
708
709
facfbbbd
SM
710EXFUN (Fx_display_grayscale_p, 1);
711EXFUN (Fx_display_planes, 1);
712
edfda783
AR
713/* In nsfont, called from fontset.c */
714extern void nsfont_make_fontset_for_font (Lisp_Object name,
715 Lisp_Object font_object);
716
717/* In nsfont, for debugging */
718struct glyph_string;
719void dump_glyphstring (struct glyph_string *s);
720
721/* Implemented in nsterm, published in or needed from nsfns. */
722extern Lisp_Object Qfontsize;
723extern Lisp_Object ns_list_fonts (FRAME_PTR f, Lisp_Object pattern,
724 int size, int maxnames);
725extern void ns_clear_frame (struct frame *f);
726
edfda783
AR
727extern const char *ns_xlfd_to_fontname (const char *xlfd);
728
729extern void check_ns (void);
730extern Lisp_Object ns_map_event_to_object ();
731extern Lisp_Object ns_string_from_pasteboard ();
732extern void ns_string_to_pasteboard ();
733extern void nxatoms_of_nsselect ();
734extern int ns_lisp_to_cursor_type ();
735extern Lisp_Object ns_cursor_type_to_lisp (int arg);
736extern Lisp_Object Qnone;
737
738/* XColor defined in dispextern.h (we use color_def->pixel = NSColor id), but
facfbbbd
SM
739 this causes an #include snafu, so we can't declare it. */
740extern int
741ns_defined_color (struct frame *f, char *name, XColor *color_def, int alloc,
742 char makeIndex);
edfda783
AR
743
744#ifdef __OBJC__
facfbbbd 745extern Lisp_Object ns_color_to_lisp (NSColor *col);
edfda783
AR
746extern int ns_lisp_to_color (Lisp_Object color, NSColor **col);
747extern NSColor *ns_lookup_indexed_color (unsigned long idx, struct frame *f);
748extern unsigned long ns_index_color (NSColor *color, struct frame *f);
749extern void ns_free_indexed_color (unsigned long idx, struct frame *f);
750#endif
751
752/* C access to ObjC functionality */
753extern void ns_release_object (void *obj);
754extern void ns_retain_object (void *obj);
755extern void *ns_alloc_autorelease_pool ();
756extern void ns_release_autorelease_pool ();
757
758/* in nsmenu */
759extern void update_frame_tool_bar (FRAME_PTR f);
760extern void free_frame_tool_bar (FRAME_PTR f);
761extern void find_and_call_menu_selection (FRAME_PTR f,
faf257a1 762 int menu_bar_items_used, Lisp_Object vector, void *client_data);
edfda783
AR
763extern Lisp_Object find_and_return_menu_selection (FRAME_PTR f,
764 int keymaps,
765 void *client_data);
766extern Lisp_Object ns_popup_dialog (Lisp_Object position, Lisp_Object contents,
767 Lisp_Object header);
768
769/* two more prototypes that should be moved to a more general include file */
770extern void set_frame_menubar (struct frame *f, int first_time, int deep_p);
771extern void x_set_window_size (struct frame *f, int change_grav,
772 int cols, int rows);
773
774/* From nsimage.m, needed in image.c */
775struct image;
776extern void *ns_image_from_XBM (unsigned char *bits, int width, int height);
777extern void *ns_image_for_XPM (int width, int height, int depth);
778extern void *ns_image_from_file (Lisp_Object file);
779extern int ns_load_image (struct frame *f, struct image *img,
780 Lisp_Object spec_file, Lisp_Object spec_data);
781extern int ns_image_width (void *img);
782extern int ns_image_height (void *img);
783extern unsigned long ns_get_pixel (void *img, int x, int y);
784extern void ns_put_pixel (void *img, int x, int y, unsigned long argb);
785extern void ns_set_alpha (void *img, int x, int y, unsigned char a);
786
b532986e
CY
787extern int x_display_pixel_height P_ ((struct ns_display_info *));
788extern int x_display_pixel_width P_ ((struct ns_display_info *));
789
edfda783
AR
790/* This in nsterm.m */
791extern unsigned long ns_get_rgb_color (struct frame *f,
792 float r, float g, float b, float a);
793extern NSPoint last_mouse_motion_position;
794
795#ifdef NS_IMPL_GNUSTEP
796extern char gnustep_base_version[]; /* version tracking */
797#endif
798
799#define MINWIDTH 10
800#define MINHEIGHT 10
801
802/* Screen max coordinate
803 Using larger coordinates causes movewindow/placewindow to abort */
804#define SCREENMAX 16000
805
806#define NS_SCROLL_BAR_WIDTH_DEFAULT [EmacsScroller scrollerWidth]
807/* This is to match emacs on other platforms, ugly though it is. */
808#define NS_SELECTION_COLOR_DEFAULT @"LightGoldenrod2";
809#define RESIZE_HANDLE_SIZE 12
810
811/* Little utility macros */
812#define IN_BOUND(min, x, max) (((x) < (min)) \
813 ? (min) : (((x)>(max)) ? (max) : (x)))
814#define SCREENMAXBOUND(x) (IN_BOUND (-SCREENMAX, x, SCREENMAX))
815
816/* 23: needed somewhere... */
817#define VERTICAL_SCROLL_BAR_WIDTH_TRIM (0)
818
819
820#endif /* HAVE_NS */
0ae1e5e5
MB
821
822/* arch-tag: 0a28b142-4ac1-4a81-a243-abcd82d9c4e5
823 (do not change this comment) */