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