1 /* Graphical user interface functions for Mac OS.
2 Copyright (C) 2000, 2001, 2004 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 2, or (at your option)
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; see the file COPYING. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
21 /* Contributed by Andrew Choi (akochoi@mac.com). */
37 #include "dispextern.h"
39 #include "intervals.h"
41 #include "blockinput.h"
43 #include "termhooks.h"
47 /* #include "bitmaps/gray.xbm" */
50 static unsigned char gray_bits
[] = {
53 /*#include <commdlg.h>
54 #include <shellapi.h>*/
56 #include <sys/types.h>
58 #include <sys/param.h>
63 /*extern void free_frame_menubar ();
64 extern double atof ();
65 extern int w32_console_toggle_lock_key (int vk_code, Lisp_Object new_state);
66 extern int quit_char;*/
68 extern char *lispy_function_keys
[];
70 /* The gray bitmap `bitmaps/gray'. This is done because macterm.c uses
71 it, and including `bitmaps/gray' more than once is a problem when
72 config.h defines `static' as an empty replacement string. */
74 int gray_bitmap_width
= gray_width
;
75 int gray_bitmap_height
= gray_height
;
76 unsigned char *gray_bitmap_bits
= gray_bits
;
78 /* Non-zero means we're allowed to display an hourglass cursor. */
80 int display_hourglass_p
;
82 /* The background and shape of the mouse pointer, and shape when not
83 over text or in the modeline. */
85 Lisp_Object Vx_pointer_shape
, Vx_nontext_pointer_shape
, Vx_mode_pointer_shape
;
86 Lisp_Object Vx_hourglass_pointer_shape
;
88 /* The shape when over mouse-sensitive text. */
90 Lisp_Object Vx_sensitive_text_pointer_shape
;
92 /* If non-nil, the pointer shape to indicate that windows can be
93 dragged horizontally. */
95 Lisp_Object Vx_window_horizontal_drag_shape
;
97 /* Color of chars displayed in cursor box. */
99 Lisp_Object Vx_cursor_fore_pixel
;
101 /* Nonzero if using Windows. */
103 static int mac_in_use
;
105 /* Non nil if no window manager is in use. */
107 Lisp_Object Vx_no_window_manager
;
109 /* Regexp matching a font name whose width is the same as `PIXEL_SIZE'. */
111 Lisp_Object Vx_pixel_size_width_font_regexp
;
113 /* Evaluate this expression to rebuild the section of syms_of_macfns
114 that initializes and staticpros the symbols declared below. Note
115 that Emacs 18 has a bug that keeps C-x C-e from being able to
116 evaluate this expression.
119 ;; Accumulate a list of the symbols we want to initialize from the
120 ;; declarations at the top of the file.
121 (goto-char (point-min))
122 (search-forward "/\*&&& symbols declared here &&&*\/\n")
124 (while (looking-at "Lisp_Object \\(Q[a-z_]+\\)")
126 (cons (buffer-substring (match-beginning 1) (match-end 1))
129 (setq symbol-list (nreverse symbol-list))
130 ;; Delete the section of syms_of_... where we initialize the symbols.
131 (search-forward "\n /\*&&& init symbols here &&&*\/\n")
132 (let ((start (point)))
133 (while (looking-at "^ Q")
135 (kill-region start (point)))
136 ;; Write a new symbol initialization section.
138 (insert (format " %s = intern (\"" (car symbol-list)))
139 (let ((start (point)))
140 (insert (substring (car symbol-list) 1))
141 (subst-char-in-region start (point) ?_ ?-))
142 (insert (format "\");\n staticpro (&%s);\n" (car symbol-list)))
143 (setq symbol-list (cdr symbol-list)))))
147 /*&&& symbols declared here &&&*/
149 Lisp_Object Qsuppress_icon
;
150 Lisp_Object Qundefined_color
;
151 Lisp_Object Qcancel_timer
;
157 Lisp_Object Qcontrol
;
160 extern Lisp_Object Vwindow_system_version
;
162 #if 0 /* Use xstricmp instead. */
163 /* compare two strings ignoring case */
166 stricmp (const char *s
, const char *t
)
168 for ( ; tolower (*s
) == tolower (*t
); s
++, t
++)
171 return tolower (*s
) - tolower (*t
);
175 /* compare two strings up to n characters, ignoring case */
178 strnicmp (const char *s
, const char *t
, unsigned int n
)
180 for ( ; n
> 0 && tolower (*s
) == tolower (*t
); n
--, s
++, t
++)
183 return n
== 0 ? 0 : tolower (*s
) - tolower (*t
);
187 /* Error if we are not running on Mac OS. */
193 error ("Mac native windows not in use or not initialized");
196 /* Nonzero if we can use mouse menus.
197 You should not call this unless HAVE_MENUS is defined. */
205 /* Extract a frame as a FRAME_PTR, defaulting to the selected frame
206 and checking validity for Mac. */
209 check_x_frame (frame
)
215 frame
= selected_frame
;
216 CHECK_LIVE_FRAME (frame
);
218 if (! FRAME_MAC_P (f
))
219 error ("non-mac frame used");
223 /* Let the user specify a display with a frame.
224 nil stands for the selected frame--or, if that is not a mac frame,
225 the first display on the list. */
227 struct mac_display_info
*
228 check_x_display_info (frame
)
231 struct mac_display_info
*dpyinfo
= NULL
;
235 struct frame
*sf
= XFRAME (selected_frame
);
237 if (FRAME_MAC_P (sf
) && FRAME_LIVE_P (sf
))
238 dpyinfo
= FRAME_MAC_DISPLAY_INFO (sf
);
239 else if (x_display_list
!= 0)
240 dpyinfo
= x_display_list
;
242 error ("Mac native windows are not in use or not initialized");
244 else if (STRINGP (frame
))
245 dpyinfo
= x_display_info_for_name (frame
);
248 FRAME_PTR f
= check_x_frame (frame
);
249 dpyinfo
= FRAME_MAC_DISPLAY_INFO (f
);
255 /* Return the Emacs frame-object corresponding to a mac window.
256 It could be the frame's main window or an icon window. */
258 /* This function can be called during GC, so use GC_xxx type test macros. */
261 x_window_to_frame (dpyinfo
, wdesc
)
262 struct mac_display_info
*dpyinfo
;
265 Lisp_Object tail
, frame
;
268 for (tail
= Vframe_list
; GC_CONSP (tail
); tail
= XCDR (tail
))
271 if (!GC_FRAMEP (frame
))
274 if (!FRAME_W32_P (f
) || FRAME_MAC_DISPLAY_INFO (f
) != dpyinfo
)
276 /*if (f->output_data.w32->hourglass_window == wdesc)
279 /* MAC_TODO: Check tooltips when supported. */
280 if (FRAME_MAC_WINDOW (f
) == wdesc
)
287 static Lisp_Object unwind_create_frame
P_ ((Lisp_Object
));
289 void x_set_foreground_color
P_ ((struct frame
*, Lisp_Object
, Lisp_Object
));
290 void x_set_background_color
P_ ((struct frame
*, Lisp_Object
, Lisp_Object
));
291 void x_set_mouse_color
P_ ((struct frame
*, Lisp_Object
, Lisp_Object
));
292 void x_set_cursor_color
P_ ((struct frame
*, Lisp_Object
, Lisp_Object
));
293 void x_set_border_color
P_ ((struct frame
*, Lisp_Object
, Lisp_Object
));
294 void x_set_cursor_type
P_ ((struct frame
*, Lisp_Object
, Lisp_Object
));
295 void x_set_icon_type
P_ ((struct frame
*, Lisp_Object
, Lisp_Object
));
296 void x_set_icon_name
P_ ((struct frame
*, Lisp_Object
, Lisp_Object
));
297 void x_explicitly_set_name
P_ ((struct frame
*, Lisp_Object
, Lisp_Object
));
298 void x_set_menu_bar_lines
P_ ((struct frame
*, Lisp_Object
, Lisp_Object
));
299 void x_set_title
P_ ((struct frame
*, Lisp_Object
, Lisp_Object
));
300 void x_set_tool_bar_lines
P_ ((struct frame
*, Lisp_Object
, Lisp_Object
));
301 void x_set_scroll_bar_foreground
P_ ((struct frame
*, Lisp_Object
,
303 void x_set_scroll_bar_background
P_ ((struct frame
*, Lisp_Object
,
305 static Lisp_Object x_default_scroll_bar_color_parameter
P_ ((struct frame
*,
311 extern void mac_get_window_bounds
P_ ((struct frame
*, Rect
*, Rect
*));
313 /* Store the screen positions of frame F into XPTR and YPTR.
314 These are the positions of the containing window manager window,
315 not Emacs's own window. */
318 x_real_positions (f
, xptr
, yptr
)
324 mac_get_window_bounds (f
, &inner
, &outer
);
326 f
->x_pixels_diff
= inner
.left
- outer
.left
;
327 f
->y_pixels_diff
= inner
.top
- outer
.top
;
334 /* The default colors for the Mac color map */
335 typedef struct colormap_t
341 colormap_t mac_color_map
[] =
343 { RGB_TO_ULONG(255, 250, 250), "snow" },
344 { RGB_TO_ULONG(248, 248, 255), "ghost white" },
345 { RGB_TO_ULONG(248, 248, 255), "GhostWhite" },
346 { RGB_TO_ULONG(245, 245, 245), "white smoke" },
347 { RGB_TO_ULONG(245, 245, 245), "WhiteSmoke" },
348 { RGB_TO_ULONG(220, 220, 220), "gainsboro" },
349 { RGB_TO_ULONG(255, 250, 240), "floral white" },
350 { RGB_TO_ULONG(255, 250, 240), "FloralWhite" },
351 { RGB_TO_ULONG(253, 245, 230), "old lace" },
352 { RGB_TO_ULONG(253, 245, 230), "OldLace" },
353 { RGB_TO_ULONG(250, 240, 230), "linen" },
354 { RGB_TO_ULONG(250, 235, 215), "antique white" },
355 { RGB_TO_ULONG(250, 235, 215), "AntiqueWhite" },
356 { RGB_TO_ULONG(255, 239, 213), "papaya whip" },
357 { RGB_TO_ULONG(255, 239, 213), "PapayaWhip" },
358 { RGB_TO_ULONG(255, 235, 205), "blanched almond" },
359 { RGB_TO_ULONG(255, 235, 205), "BlanchedAlmond" },
360 { RGB_TO_ULONG(255, 228, 196), "bisque" },
361 { RGB_TO_ULONG(255, 218, 185), "peach puff" },
362 { RGB_TO_ULONG(255, 218, 185), "PeachPuff" },
363 { RGB_TO_ULONG(255, 222, 173), "navajo white" },
364 { RGB_TO_ULONG(255, 222, 173), "NavajoWhite" },
365 { RGB_TO_ULONG(255, 228, 181), "moccasin" },
366 { RGB_TO_ULONG(255, 248, 220), "cornsilk" },
367 { RGB_TO_ULONG(255, 255, 240), "ivory" },
368 { RGB_TO_ULONG(255, 250, 205), "lemon chiffon" },
369 { RGB_TO_ULONG(255, 250, 205), "LemonChiffon" },
370 { RGB_TO_ULONG(255, 245, 238), "seashell" },
371 { RGB_TO_ULONG(240, 255, 240), "honeydew" },
372 { RGB_TO_ULONG(245, 255, 250), "mint cream" },
373 { RGB_TO_ULONG(245, 255, 250), "MintCream" },
374 { RGB_TO_ULONG(240, 255, 255), "azure" },
375 { RGB_TO_ULONG(240, 248, 255), "alice blue" },
376 { RGB_TO_ULONG(240, 248, 255), "AliceBlue" },
377 { RGB_TO_ULONG(230, 230, 250), "lavender" },
378 { RGB_TO_ULONG(255, 240, 245), "lavender blush" },
379 { RGB_TO_ULONG(255, 240, 245), "LavenderBlush" },
380 { RGB_TO_ULONG(255, 228, 225), "misty rose" },
381 { RGB_TO_ULONG(255, 228, 225), "MistyRose" },
382 { RGB_TO_ULONG(255, 255, 255), "white" },
383 { RGB_TO_ULONG(0 , 0 , 0 ), "black" },
384 { RGB_TO_ULONG(47 , 79 , 79 ), "dark slate gray" },
385 { RGB_TO_ULONG(47 , 79 , 79 ), "DarkSlateGray" },
386 { RGB_TO_ULONG(47 , 79 , 79 ), "dark slate grey" },
387 { RGB_TO_ULONG(47 , 79 , 79 ), "DarkSlateGrey" },
388 { RGB_TO_ULONG(105, 105, 105), "dim gray" },
389 { RGB_TO_ULONG(105, 105, 105), "DimGray" },
390 { RGB_TO_ULONG(105, 105, 105), "dim grey" },
391 { RGB_TO_ULONG(105, 105, 105), "DimGrey" },
392 { RGB_TO_ULONG(112, 128, 144), "slate gray" },
393 { RGB_TO_ULONG(112, 128, 144), "SlateGray" },
394 { RGB_TO_ULONG(112, 128, 144), "slate grey" },
395 { RGB_TO_ULONG(112, 128, 144), "SlateGrey" },
396 { RGB_TO_ULONG(119, 136, 153), "light slate gray" },
397 { RGB_TO_ULONG(119, 136, 153), "LightSlateGray" },
398 { RGB_TO_ULONG(119, 136, 153), "light slate grey" },
399 { RGB_TO_ULONG(119, 136, 153), "LightSlateGrey" },
400 { RGB_TO_ULONG(190, 190, 190), "gray" },
401 { RGB_TO_ULONG(190, 190, 190), "grey" },
402 { RGB_TO_ULONG(211, 211, 211), "light grey" },
403 { RGB_TO_ULONG(211, 211, 211), "LightGrey" },
404 { RGB_TO_ULONG(211, 211, 211), "light gray" },
405 { RGB_TO_ULONG(211, 211, 211), "LightGray" },
406 { RGB_TO_ULONG(25 , 25 , 112), "midnight blue" },
407 { RGB_TO_ULONG(25 , 25 , 112), "MidnightBlue" },
408 { RGB_TO_ULONG(0 , 0 , 128), "navy" },
409 { RGB_TO_ULONG(0 , 0 , 128), "navy blue" },
410 { RGB_TO_ULONG(0 , 0 , 128), "NavyBlue" },
411 { RGB_TO_ULONG(100, 149, 237), "cornflower blue" },
412 { RGB_TO_ULONG(100, 149, 237), "CornflowerBlue" },
413 { RGB_TO_ULONG(72 , 61 , 139), "dark slate blue" },
414 { RGB_TO_ULONG(72 , 61 , 139), "DarkSlateBlue" },
415 { RGB_TO_ULONG(106, 90 , 205), "slate blue" },
416 { RGB_TO_ULONG(106, 90 , 205), "SlateBlue" },
417 { RGB_TO_ULONG(123, 104, 238), "medium slate blue" },
418 { RGB_TO_ULONG(123, 104, 238), "MediumSlateBlue" },
419 { RGB_TO_ULONG(132, 112, 255), "light slate blue" },
420 { RGB_TO_ULONG(132, 112, 255), "LightSlateBlue" },
421 { RGB_TO_ULONG(0 , 0 , 205), "medium blue" },
422 { RGB_TO_ULONG(0 , 0 , 205), "MediumBlue" },
423 { RGB_TO_ULONG(65 , 105, 225), "royal blue" },
424 { RGB_TO_ULONG(65 , 105, 225), "RoyalBlue" },
425 { RGB_TO_ULONG(0 , 0 , 255), "blue" },
426 { RGB_TO_ULONG(30 , 144, 255), "dodger blue" },
427 { RGB_TO_ULONG(30 , 144, 255), "DodgerBlue" },
428 { RGB_TO_ULONG(0 , 191, 255), "deep sky blue" },
429 { RGB_TO_ULONG(0 , 191, 255), "DeepSkyBlue" },
430 { RGB_TO_ULONG(135, 206, 235), "sky blue" },
431 { RGB_TO_ULONG(135, 206, 235), "SkyBlue" },
432 { RGB_TO_ULONG(135, 206, 250), "light sky blue" },
433 { RGB_TO_ULONG(135, 206, 250), "LightSkyBlue" },
434 { RGB_TO_ULONG(70 , 130, 180), "steel blue" },
435 { RGB_TO_ULONG(70 , 130, 180), "SteelBlue" },
436 { RGB_TO_ULONG(176, 196, 222), "light steel blue" },
437 { RGB_TO_ULONG(176, 196, 222), "LightSteelBlue" },
438 { RGB_TO_ULONG(173, 216, 230), "light blue" },
439 { RGB_TO_ULONG(173, 216, 230), "LightBlue" },
440 { RGB_TO_ULONG(176, 224, 230), "powder blue" },
441 { RGB_TO_ULONG(176, 224, 230), "PowderBlue" },
442 { RGB_TO_ULONG(175, 238, 238), "pale turquoise" },
443 { RGB_TO_ULONG(175, 238, 238), "PaleTurquoise" },
444 { RGB_TO_ULONG(0 , 206, 209), "dark turquoise" },
445 { RGB_TO_ULONG(0 , 206, 209), "DarkTurquoise" },
446 { RGB_TO_ULONG(72 , 209, 204), "medium turquoise" },
447 { RGB_TO_ULONG(72 , 209, 204), "MediumTurquoise" },
448 { RGB_TO_ULONG(64 , 224, 208), "turquoise" },
449 { RGB_TO_ULONG(0 , 255, 255), "cyan" },
450 { RGB_TO_ULONG(224, 255, 255), "light cyan" },
451 { RGB_TO_ULONG(224, 255, 255), "LightCyan" },
452 { RGB_TO_ULONG(95 , 158, 160), "cadet blue" },
453 { RGB_TO_ULONG(95 , 158, 160), "CadetBlue" },
454 { RGB_TO_ULONG(102, 205, 170), "medium aquamarine" },
455 { RGB_TO_ULONG(102, 205, 170), "MediumAquamarine" },
456 { RGB_TO_ULONG(127, 255, 212), "aquamarine" },
457 { RGB_TO_ULONG(0 , 100, 0 ), "dark green" },
458 { RGB_TO_ULONG(0 , 100, 0 ), "DarkGreen" },
459 { RGB_TO_ULONG(85 , 107, 47 ), "dark olive green" },
460 { RGB_TO_ULONG(85 , 107, 47 ), "DarkOliveGreen" },
461 { RGB_TO_ULONG(143, 188, 143), "dark sea green" },
462 { RGB_TO_ULONG(143, 188, 143), "DarkSeaGreen" },
463 { RGB_TO_ULONG(46 , 139, 87 ), "sea green" },
464 { RGB_TO_ULONG(46 , 139, 87 ), "SeaGreen" },
465 { RGB_TO_ULONG(60 , 179, 113), "medium sea green" },
466 { RGB_TO_ULONG(60 , 179, 113), "MediumSeaGreen" },
467 { RGB_TO_ULONG(32 , 178, 170), "light sea green" },
468 { RGB_TO_ULONG(32 , 178, 170), "LightSeaGreen" },
469 { RGB_TO_ULONG(152, 251, 152), "pale green" },
470 { RGB_TO_ULONG(152, 251, 152), "PaleGreen" },
471 { RGB_TO_ULONG(0 , 255, 127), "spring green" },
472 { RGB_TO_ULONG(0 , 255, 127), "SpringGreen" },
473 { RGB_TO_ULONG(124, 252, 0 ), "lawn green" },
474 { RGB_TO_ULONG(124, 252, 0 ), "LawnGreen" },
475 { RGB_TO_ULONG(0 , 255, 0 ), "green" },
476 { RGB_TO_ULONG(127, 255, 0 ), "chartreuse" },
477 { RGB_TO_ULONG(0 , 250, 154), "medium spring green" },
478 { RGB_TO_ULONG(0 , 250, 154), "MediumSpringGreen" },
479 { RGB_TO_ULONG(173, 255, 47 ), "green yellow" },
480 { RGB_TO_ULONG(173, 255, 47 ), "GreenYellow" },
481 { RGB_TO_ULONG(50 , 205, 50 ), "lime green" },
482 { RGB_TO_ULONG(50 , 205, 50 ), "LimeGreen" },
483 { RGB_TO_ULONG(154, 205, 50 ), "yellow green" },
484 { RGB_TO_ULONG(154, 205, 50 ), "YellowGreen" },
485 { RGB_TO_ULONG(34 , 139, 34 ), "forest green" },
486 { RGB_TO_ULONG(34 , 139, 34 ), "ForestGreen" },
487 { RGB_TO_ULONG(107, 142, 35 ), "olive drab" },
488 { RGB_TO_ULONG(107, 142, 35 ), "OliveDrab" },
489 { RGB_TO_ULONG(189, 183, 107), "dark khaki" },
490 { RGB_TO_ULONG(189, 183, 107), "DarkKhaki" },
491 { RGB_TO_ULONG(240, 230, 140), "khaki" },
492 { RGB_TO_ULONG(238, 232, 170), "pale goldenrod" },
493 { RGB_TO_ULONG(238, 232, 170), "PaleGoldenrod" },
494 { RGB_TO_ULONG(250, 250, 210), "light goldenrod yellow" },
495 { RGB_TO_ULONG(250, 250, 210), "LightGoldenrodYellow" },
496 { RGB_TO_ULONG(255, 255, 224), "light yellow" },
497 { RGB_TO_ULONG(255, 255, 224), "LightYellow" },
498 { RGB_TO_ULONG(255, 255, 0 ), "yellow" },
499 { RGB_TO_ULONG(255, 215, 0 ), "gold" },
500 { RGB_TO_ULONG(238, 221, 130), "light goldenrod" },
501 { RGB_TO_ULONG(238, 221, 130), "LightGoldenrod" },
502 { RGB_TO_ULONG(218, 165, 32 ), "goldenrod" },
503 { RGB_TO_ULONG(184, 134, 11 ), "dark goldenrod" },
504 { RGB_TO_ULONG(184, 134, 11 ), "DarkGoldenrod" },
505 { RGB_TO_ULONG(188, 143, 143), "rosy brown" },
506 { RGB_TO_ULONG(188, 143, 143), "RosyBrown" },
507 { RGB_TO_ULONG(205, 92 , 92 ), "indian red" },
508 { RGB_TO_ULONG(205, 92 , 92 ), "IndianRed" },
509 { RGB_TO_ULONG(139, 69 , 19 ), "saddle brown" },
510 { RGB_TO_ULONG(139, 69 , 19 ), "SaddleBrown" },
511 { RGB_TO_ULONG(160, 82 , 45 ), "sienna" },
512 { RGB_TO_ULONG(205, 133, 63 ), "peru" },
513 { RGB_TO_ULONG(222, 184, 135), "burlywood" },
514 { RGB_TO_ULONG(245, 245, 220), "beige" },
515 { RGB_TO_ULONG(245, 222, 179), "wheat" },
516 { RGB_TO_ULONG(244, 164, 96 ), "sandy brown" },
517 { RGB_TO_ULONG(244, 164, 96 ), "SandyBrown" },
518 { RGB_TO_ULONG(210, 180, 140), "tan" },
519 { RGB_TO_ULONG(210, 105, 30 ), "chocolate" },
520 { RGB_TO_ULONG(178, 34 , 34 ), "firebrick" },
521 { RGB_TO_ULONG(165, 42 , 42 ), "brown" },
522 { RGB_TO_ULONG(233, 150, 122), "dark salmon" },
523 { RGB_TO_ULONG(233, 150, 122), "DarkSalmon" },
524 { RGB_TO_ULONG(250, 128, 114), "salmon" },
525 { RGB_TO_ULONG(255, 160, 122), "light salmon" },
526 { RGB_TO_ULONG(255, 160, 122), "LightSalmon" },
527 { RGB_TO_ULONG(255, 165, 0 ), "orange" },
528 { RGB_TO_ULONG(255, 140, 0 ), "dark orange" },
529 { RGB_TO_ULONG(255, 140, 0 ), "DarkOrange" },
530 { RGB_TO_ULONG(255, 127, 80 ), "coral" },
531 { RGB_TO_ULONG(240, 128, 128), "light coral" },
532 { RGB_TO_ULONG(240, 128, 128), "LightCoral" },
533 { RGB_TO_ULONG(255, 99 , 71 ), "tomato" },
534 { RGB_TO_ULONG(255, 69 , 0 ), "orange red" },
535 { RGB_TO_ULONG(255, 69 , 0 ), "OrangeRed" },
536 { RGB_TO_ULONG(255, 0 , 0 ), "red" },
537 { RGB_TO_ULONG(255, 105, 180), "hot pink" },
538 { RGB_TO_ULONG(255, 105, 180), "HotPink" },
539 { RGB_TO_ULONG(255, 20 , 147), "deep pink" },
540 { RGB_TO_ULONG(255, 20 , 147), "DeepPink" },
541 { RGB_TO_ULONG(255, 192, 203), "pink" },
542 { RGB_TO_ULONG(255, 182, 193), "light pink" },
543 { RGB_TO_ULONG(255, 182, 193), "LightPink" },
544 { RGB_TO_ULONG(219, 112, 147), "pale violet red" },
545 { RGB_TO_ULONG(219, 112, 147), "PaleVioletRed" },
546 { RGB_TO_ULONG(176, 48 , 96 ), "maroon" },
547 { RGB_TO_ULONG(199, 21 , 133), "medium violet red" },
548 { RGB_TO_ULONG(199, 21 , 133), "MediumVioletRed" },
549 { RGB_TO_ULONG(208, 32 , 144), "violet red" },
550 { RGB_TO_ULONG(208, 32 , 144), "VioletRed" },
551 { RGB_TO_ULONG(255, 0 , 255), "magenta" },
552 { RGB_TO_ULONG(238, 130, 238), "violet" },
553 { RGB_TO_ULONG(221, 160, 221), "plum" },
554 { RGB_TO_ULONG(218, 112, 214), "orchid" },
555 { RGB_TO_ULONG(186, 85 , 211), "medium orchid" },
556 { RGB_TO_ULONG(186, 85 , 211), "MediumOrchid" },
557 { RGB_TO_ULONG(153, 50 , 204), "dark orchid" },
558 { RGB_TO_ULONG(153, 50 , 204), "DarkOrchid" },
559 { RGB_TO_ULONG(148, 0 , 211), "dark violet" },
560 { RGB_TO_ULONG(148, 0 , 211), "DarkViolet" },
561 { RGB_TO_ULONG(138, 43 , 226), "blue violet" },
562 { RGB_TO_ULONG(138, 43 , 226), "BlueViolet" },
563 { RGB_TO_ULONG(160, 32 , 240), "purple" },
564 { RGB_TO_ULONG(147, 112, 219), "medium purple" },
565 { RGB_TO_ULONG(147, 112, 219), "MediumPurple" },
566 { RGB_TO_ULONG(216, 191, 216), "thistle" },
567 { RGB_TO_ULONG(255, 250, 250), "snow1" },
568 { RGB_TO_ULONG(238, 233, 233), "snow2" },
569 { RGB_TO_ULONG(205, 201, 201), "snow3" },
570 { RGB_TO_ULONG(139, 137, 137), "snow4" },
571 { RGB_TO_ULONG(255, 245, 238), "seashell1" },
572 { RGB_TO_ULONG(238, 229, 222), "seashell2" },
573 { RGB_TO_ULONG(205, 197, 191), "seashell3" },
574 { RGB_TO_ULONG(139, 134, 130), "seashell4" },
575 { RGB_TO_ULONG(255, 239, 219), "AntiqueWhite1" },
576 { RGB_TO_ULONG(238, 223, 204), "AntiqueWhite2" },
577 { RGB_TO_ULONG(205, 192, 176), "AntiqueWhite3" },
578 { RGB_TO_ULONG(139, 131, 120), "AntiqueWhite4" },
579 { RGB_TO_ULONG(255, 228, 196), "bisque1" },
580 { RGB_TO_ULONG(238, 213, 183), "bisque2" },
581 { RGB_TO_ULONG(205, 183, 158), "bisque3" },
582 { RGB_TO_ULONG(139, 125, 107), "bisque4" },
583 { RGB_TO_ULONG(255, 218, 185), "PeachPuff1" },
584 { RGB_TO_ULONG(238, 203, 173), "PeachPuff2" },
585 { RGB_TO_ULONG(205, 175, 149), "PeachPuff3" },
586 { RGB_TO_ULONG(139, 119, 101), "PeachPuff4" },
587 { RGB_TO_ULONG(255, 222, 173), "NavajoWhite1" },
588 { RGB_TO_ULONG(238, 207, 161), "NavajoWhite2" },
589 { RGB_TO_ULONG(205, 179, 139), "NavajoWhite3" },
590 { RGB_TO_ULONG(139, 121, 94), "NavajoWhite4" },
591 { RGB_TO_ULONG(255, 250, 205), "LemonChiffon1" },
592 { RGB_TO_ULONG(238, 233, 191), "LemonChiffon2" },
593 { RGB_TO_ULONG(205, 201, 165), "LemonChiffon3" },
594 { RGB_TO_ULONG(139, 137, 112), "LemonChiffon4" },
595 { RGB_TO_ULONG(255, 248, 220), "cornsilk1" },
596 { RGB_TO_ULONG(238, 232, 205), "cornsilk2" },
597 { RGB_TO_ULONG(205, 200, 177), "cornsilk3" },
598 { RGB_TO_ULONG(139, 136, 120), "cornsilk4" },
599 { RGB_TO_ULONG(255, 255, 240), "ivory1" },
600 { RGB_TO_ULONG(238, 238, 224), "ivory2" },
601 { RGB_TO_ULONG(205, 205, 193), "ivory3" },
602 { RGB_TO_ULONG(139, 139, 131), "ivory4" },
603 { RGB_TO_ULONG(240, 255, 240), "honeydew1" },
604 { RGB_TO_ULONG(224, 238, 224), "honeydew2" },
605 { RGB_TO_ULONG(193, 205, 193), "honeydew3" },
606 { RGB_TO_ULONG(131, 139, 131), "honeydew4" },
607 { RGB_TO_ULONG(255, 240, 245), "LavenderBlush1" },
608 { RGB_TO_ULONG(238, 224, 229), "LavenderBlush2" },
609 { RGB_TO_ULONG(205, 193, 197), "LavenderBlush3" },
610 { RGB_TO_ULONG(139, 131, 134), "LavenderBlush4" },
611 { RGB_TO_ULONG(255, 228, 225), "MistyRose1" },
612 { RGB_TO_ULONG(238, 213, 210), "MistyRose2" },
613 { RGB_TO_ULONG(205, 183, 181), "MistyRose3" },
614 { RGB_TO_ULONG(139, 125, 123), "MistyRose4" },
615 { RGB_TO_ULONG(240, 255, 255), "azure1" },
616 { RGB_TO_ULONG(224, 238, 238), "azure2" },
617 { RGB_TO_ULONG(193, 205, 205), "azure3" },
618 { RGB_TO_ULONG(131, 139, 139), "azure4" },
619 { RGB_TO_ULONG(131, 111, 255), "SlateBlue1" },
620 { RGB_TO_ULONG(122, 103, 238), "SlateBlue2" },
621 { RGB_TO_ULONG(105, 89 , 205), "SlateBlue3" },
622 { RGB_TO_ULONG(71 , 60 , 139), "SlateBlue4" },
623 { RGB_TO_ULONG(72 , 118, 255), "RoyalBlue1" },
624 { RGB_TO_ULONG(67 , 110, 238), "RoyalBlue2" },
625 { RGB_TO_ULONG(58 , 95 , 205), "RoyalBlue3" },
626 { RGB_TO_ULONG(39 , 64 , 139), "RoyalBlue4" },
627 { RGB_TO_ULONG(0 , 0 , 255), "blue1" },
628 { RGB_TO_ULONG(0 , 0 , 238), "blue2" },
629 { RGB_TO_ULONG(0 , 0 , 205), "blue3" },
630 { RGB_TO_ULONG(0 , 0 , 139), "blue4" },
631 { RGB_TO_ULONG(30 , 144, 255), "DodgerBlue1" },
632 { RGB_TO_ULONG(28 , 134, 238), "DodgerBlue2" },
633 { RGB_TO_ULONG(24 , 116, 205), "DodgerBlue3" },
634 { RGB_TO_ULONG(16 , 78 , 139), "DodgerBlue4" },
635 { RGB_TO_ULONG(99 , 184, 255), "SteelBlue1" },
636 { RGB_TO_ULONG(92 , 172, 238), "SteelBlue2" },
637 { RGB_TO_ULONG(79 , 148, 205), "SteelBlue3" },
638 { RGB_TO_ULONG(54 , 100, 139), "SteelBlue4" },
639 { RGB_TO_ULONG(0 , 191, 255), "DeepSkyBlue1" },
640 { RGB_TO_ULONG(0 , 178, 238), "DeepSkyBlue2" },
641 { RGB_TO_ULONG(0 , 154, 205), "DeepSkyBlue3" },
642 { RGB_TO_ULONG(0 , 104, 139), "DeepSkyBlue4" },
643 { RGB_TO_ULONG(135, 206, 255), "SkyBlue1" },
644 { RGB_TO_ULONG(126, 192, 238), "SkyBlue2" },
645 { RGB_TO_ULONG(108, 166, 205), "SkyBlue3" },
646 { RGB_TO_ULONG(74 , 112, 139), "SkyBlue4" },
647 { RGB_TO_ULONG(176, 226, 255), "LightSkyBlue1" },
648 { RGB_TO_ULONG(164, 211, 238), "LightSkyBlue2" },
649 { RGB_TO_ULONG(141, 182, 205), "LightSkyBlue3" },
650 { RGB_TO_ULONG(96 , 123, 139), "LightSkyBlue4" },
651 { RGB_TO_ULONG(198, 226, 255), "SlateGray1" },
652 { RGB_TO_ULONG(185, 211, 238), "SlateGray2" },
653 { RGB_TO_ULONG(159, 182, 205), "SlateGray3" },
654 { RGB_TO_ULONG(108, 123, 139), "SlateGray4" },
655 { RGB_TO_ULONG(202, 225, 255), "LightSteelBlue1" },
656 { RGB_TO_ULONG(188, 210, 238), "LightSteelBlue2" },
657 { RGB_TO_ULONG(162, 181, 205), "LightSteelBlue3" },
658 { RGB_TO_ULONG(110, 123, 139), "LightSteelBlue4" },
659 { RGB_TO_ULONG(191, 239, 255), "LightBlue1" },
660 { RGB_TO_ULONG(178, 223, 238), "LightBlue2" },
661 { RGB_TO_ULONG(154, 192, 205), "LightBlue3" },
662 { RGB_TO_ULONG(104, 131, 139), "LightBlue4" },
663 { RGB_TO_ULONG(224, 255, 255), "LightCyan1" },
664 { RGB_TO_ULONG(209, 238, 238), "LightCyan2" },
665 { RGB_TO_ULONG(180, 205, 205), "LightCyan3" },
666 { RGB_TO_ULONG(122, 139, 139), "LightCyan4" },
667 { RGB_TO_ULONG(187, 255, 255), "PaleTurquoise1" },
668 { RGB_TO_ULONG(174, 238, 238), "PaleTurquoise2" },
669 { RGB_TO_ULONG(150, 205, 205), "PaleTurquoise3" },
670 { RGB_TO_ULONG(102, 139, 139), "PaleTurquoise4" },
671 { RGB_TO_ULONG(152, 245, 255), "CadetBlue1" },
672 { RGB_TO_ULONG(142, 229, 238), "CadetBlue2" },
673 { RGB_TO_ULONG(122, 197, 205), "CadetBlue3" },
674 { RGB_TO_ULONG(83 , 134, 139), "CadetBlue4" },
675 { RGB_TO_ULONG(0 , 245, 255), "turquoise1" },
676 { RGB_TO_ULONG(0 , 229, 238), "turquoise2" },
677 { RGB_TO_ULONG(0 , 197, 205), "turquoise3" },
678 { RGB_TO_ULONG(0 , 134, 139), "turquoise4" },
679 { RGB_TO_ULONG(0 , 255, 255), "cyan1" },
680 { RGB_TO_ULONG(0 , 238, 238), "cyan2" },
681 { RGB_TO_ULONG(0 , 205, 205), "cyan3" },
682 { RGB_TO_ULONG(0 , 139, 139), "cyan4" },
683 { RGB_TO_ULONG(151, 255, 255), "DarkSlateGray1" },
684 { RGB_TO_ULONG(141, 238, 238), "DarkSlateGray2" },
685 { RGB_TO_ULONG(121, 205, 205), "DarkSlateGray3" },
686 { RGB_TO_ULONG(82 , 139, 139), "DarkSlateGray4" },
687 { RGB_TO_ULONG(127, 255, 212), "aquamarine1" },
688 { RGB_TO_ULONG(118, 238, 198), "aquamarine2" },
689 { RGB_TO_ULONG(102, 205, 170), "aquamarine3" },
690 { RGB_TO_ULONG(69 , 139, 116), "aquamarine4" },
691 { RGB_TO_ULONG(193, 255, 193), "DarkSeaGreen1" },
692 { RGB_TO_ULONG(180, 238, 180), "DarkSeaGreen2" },
693 { RGB_TO_ULONG(155, 205, 155), "DarkSeaGreen3" },
694 { RGB_TO_ULONG(105, 139, 105), "DarkSeaGreen4" },
695 { RGB_TO_ULONG(84 , 255, 159), "SeaGreen1" },
696 { RGB_TO_ULONG(78 , 238, 148), "SeaGreen2" },
697 { RGB_TO_ULONG(67 , 205, 128), "SeaGreen3" },
698 { RGB_TO_ULONG(46 , 139, 87 ), "SeaGreen4" },
699 { RGB_TO_ULONG(154, 255, 154), "PaleGreen1" },
700 { RGB_TO_ULONG(144, 238, 144), "PaleGreen2" },
701 { RGB_TO_ULONG(124, 205, 124), "PaleGreen3" },
702 { RGB_TO_ULONG(84 , 139, 84 ), "PaleGreen4" },
703 { RGB_TO_ULONG(0 , 255, 127), "SpringGreen1" },
704 { RGB_TO_ULONG(0 , 238, 118), "SpringGreen2" },
705 { RGB_TO_ULONG(0 , 205, 102), "SpringGreen3" },
706 { RGB_TO_ULONG(0 , 139, 69 ), "SpringGreen4" },
707 { RGB_TO_ULONG(0 , 255, 0 ), "green1" },
708 { RGB_TO_ULONG(0 , 238, 0 ), "green2" },
709 { RGB_TO_ULONG(0 , 205, 0 ), "green3" },
710 { RGB_TO_ULONG(0 , 139, 0 ), "green4" },
711 { RGB_TO_ULONG(127, 255, 0 ), "chartreuse1" },
712 { RGB_TO_ULONG(118, 238, 0 ), "chartreuse2" },
713 { RGB_TO_ULONG(102, 205, 0 ), "chartreuse3" },
714 { RGB_TO_ULONG(69 , 139, 0 ), "chartreuse4" },
715 { RGB_TO_ULONG(192, 255, 62 ), "OliveDrab1" },
716 { RGB_TO_ULONG(179, 238, 58 ), "OliveDrab2" },
717 { RGB_TO_ULONG(154, 205, 50 ), "OliveDrab3" },
718 { RGB_TO_ULONG(105, 139, 34 ), "OliveDrab4" },
719 { RGB_TO_ULONG(202, 255, 112), "DarkOliveGreen1" },
720 { RGB_TO_ULONG(188, 238, 104), "DarkOliveGreen2" },
721 { RGB_TO_ULONG(162, 205, 90 ), "DarkOliveGreen3" },
722 { RGB_TO_ULONG(110, 139, 61 ), "DarkOliveGreen4" },
723 { RGB_TO_ULONG(255, 246, 143), "khaki1" },
724 { RGB_TO_ULONG(238, 230, 133), "khaki2" },
725 { RGB_TO_ULONG(205, 198, 115), "khaki3" },
726 { RGB_TO_ULONG(139, 134, 78 ), "khaki4" },
727 { RGB_TO_ULONG(255, 236, 139), "LightGoldenrod1" },
728 { RGB_TO_ULONG(238, 220, 130), "LightGoldenrod2" },
729 { RGB_TO_ULONG(205, 190, 112), "LightGoldenrod3" },
730 { RGB_TO_ULONG(139, 129, 76 ), "LightGoldenrod4" },
731 { RGB_TO_ULONG(255, 255, 224), "LightYellow1" },
732 { RGB_TO_ULONG(238, 238, 209), "LightYellow2" },
733 { RGB_TO_ULONG(205, 205, 180), "LightYellow3" },
734 { RGB_TO_ULONG(139, 139, 122), "LightYellow4" },
735 { RGB_TO_ULONG(255, 255, 0 ), "yellow1" },
736 { RGB_TO_ULONG(238, 238, 0 ), "yellow2" },
737 { RGB_TO_ULONG(205, 205, 0 ), "yellow3" },
738 { RGB_TO_ULONG(139, 139, 0 ), "yellow4" },
739 { RGB_TO_ULONG(255, 215, 0 ), "gold1" },
740 { RGB_TO_ULONG(238, 201, 0 ), "gold2" },
741 { RGB_TO_ULONG(205, 173, 0 ), "gold3" },
742 { RGB_TO_ULONG(139, 117, 0 ), "gold4" },
743 { RGB_TO_ULONG(255, 193, 37 ), "goldenrod1" },
744 { RGB_TO_ULONG(238, 180, 34 ), "goldenrod2" },
745 { RGB_TO_ULONG(205, 155, 29 ), "goldenrod3" },
746 { RGB_TO_ULONG(139, 105, 20 ), "goldenrod4" },
747 { RGB_TO_ULONG(255, 185, 15 ), "DarkGoldenrod1" },
748 { RGB_TO_ULONG(238, 173, 14 ), "DarkGoldenrod2" },
749 { RGB_TO_ULONG(205, 149, 12 ), "DarkGoldenrod3" },
750 { RGB_TO_ULONG(139, 101, 8 ), "DarkGoldenrod4" },
751 { RGB_TO_ULONG(255, 193, 193), "RosyBrown1" },
752 { RGB_TO_ULONG(238, 180, 180), "RosyBrown2" },
753 { RGB_TO_ULONG(205, 155, 155), "RosyBrown3" },
754 { RGB_TO_ULONG(139, 105, 105), "RosyBrown4" },
755 { RGB_TO_ULONG(255, 106, 106), "IndianRed1" },
756 { RGB_TO_ULONG(238, 99 , 99 ), "IndianRed2" },
757 { RGB_TO_ULONG(205, 85 , 85 ), "IndianRed3" },
758 { RGB_TO_ULONG(139, 58 , 58 ), "IndianRed4" },
759 { RGB_TO_ULONG(255, 130, 71 ), "sienna1" },
760 { RGB_TO_ULONG(238, 121, 66 ), "sienna2" },
761 { RGB_TO_ULONG(205, 104, 57 ), "sienna3" },
762 { RGB_TO_ULONG(139, 71 , 38 ), "sienna4" },
763 { RGB_TO_ULONG(255, 211, 155), "burlywood1" },
764 { RGB_TO_ULONG(238, 197, 145), "burlywood2" },
765 { RGB_TO_ULONG(205, 170, 125), "burlywood3" },
766 { RGB_TO_ULONG(139, 115, 85 ), "burlywood4" },
767 { RGB_TO_ULONG(255, 231, 186), "wheat1" },
768 { RGB_TO_ULONG(238, 216, 174), "wheat2" },
769 { RGB_TO_ULONG(205, 186, 150), "wheat3" },
770 { RGB_TO_ULONG(139, 126, 102), "wheat4" },
771 { RGB_TO_ULONG(255, 165, 79 ), "tan1" },
772 { RGB_TO_ULONG(238, 154, 73 ), "tan2" },
773 { RGB_TO_ULONG(205, 133, 63 ), "tan3" },
774 { RGB_TO_ULONG(139, 90 , 43 ), "tan4" },
775 { RGB_TO_ULONG(255, 127, 36 ), "chocolate1" },
776 { RGB_TO_ULONG(238, 118, 33 ), "chocolate2" },
777 { RGB_TO_ULONG(205, 102, 29 ), "chocolate3" },
778 { RGB_TO_ULONG(139, 69 , 19 ), "chocolate4" },
779 { RGB_TO_ULONG(255, 48 , 48 ), "firebrick1" },
780 { RGB_TO_ULONG(238, 44 , 44 ), "firebrick2" },
781 { RGB_TO_ULONG(205, 38 , 38 ), "firebrick3" },
782 { RGB_TO_ULONG(139, 26 , 26 ), "firebrick4" },
783 { RGB_TO_ULONG(255, 64 , 64 ), "brown1" },
784 { RGB_TO_ULONG(238, 59 , 59 ), "brown2" },
785 { RGB_TO_ULONG(205, 51 , 51 ), "brown3" },
786 { RGB_TO_ULONG(139, 35 , 35 ), "brown4" },
787 { RGB_TO_ULONG(255, 140, 105), "salmon1" },
788 { RGB_TO_ULONG(238, 130, 98 ), "salmon2" },
789 { RGB_TO_ULONG(205, 112, 84 ), "salmon3" },
790 { RGB_TO_ULONG(139, 76 , 57 ), "salmon4" },
791 { RGB_TO_ULONG(255, 160, 122), "LightSalmon1" },
792 { RGB_TO_ULONG(238, 149, 114), "LightSalmon2" },
793 { RGB_TO_ULONG(205, 129, 98 ), "LightSalmon3" },
794 { RGB_TO_ULONG(139, 87 , 66 ), "LightSalmon4" },
795 { RGB_TO_ULONG(255, 165, 0 ), "orange1" },
796 { RGB_TO_ULONG(238, 154, 0 ), "orange2" },
797 { RGB_TO_ULONG(205, 133, 0 ), "orange3" },
798 { RGB_TO_ULONG(139, 90 , 0 ), "orange4" },
799 { RGB_TO_ULONG(255, 127, 0 ), "DarkOrange1" },
800 { RGB_TO_ULONG(238, 118, 0 ), "DarkOrange2" },
801 { RGB_TO_ULONG(205, 102, 0 ), "DarkOrange3" },
802 { RGB_TO_ULONG(139, 69 , 0 ), "DarkOrange4" },
803 { RGB_TO_ULONG(255, 114, 86 ), "coral1" },
804 { RGB_TO_ULONG(238, 106, 80 ), "coral2" },
805 { RGB_TO_ULONG(205, 91 , 69 ), "coral3" },
806 { RGB_TO_ULONG(139, 62 , 47 ), "coral4" },
807 { RGB_TO_ULONG(255, 99 , 71 ), "tomato1" },
808 { RGB_TO_ULONG(238, 92 , 66 ), "tomato2" },
809 { RGB_TO_ULONG(205, 79 , 57 ), "tomato3" },
810 { RGB_TO_ULONG(139, 54 , 38 ), "tomato4" },
811 { RGB_TO_ULONG(255, 69 , 0 ), "OrangeRed1" },
812 { RGB_TO_ULONG(238, 64 , 0 ), "OrangeRed2" },
813 { RGB_TO_ULONG(205, 55 , 0 ), "OrangeRed3" },
814 { RGB_TO_ULONG(139, 37 , 0 ), "OrangeRed4" },
815 { RGB_TO_ULONG(255, 0 , 0 ), "red1" },
816 { RGB_TO_ULONG(238, 0 , 0 ), "red2" },
817 { RGB_TO_ULONG(205, 0 , 0 ), "red3" },
818 { RGB_TO_ULONG(139, 0 , 0 ), "red4" },
819 { RGB_TO_ULONG(255, 20 , 147), "DeepPink1" },
820 { RGB_TO_ULONG(238, 18 , 137), "DeepPink2" },
821 { RGB_TO_ULONG(205, 16 , 118), "DeepPink3" },
822 { RGB_TO_ULONG(139, 10 , 80 ), "DeepPink4" },
823 { RGB_TO_ULONG(255, 110, 180), "HotPink1" },
824 { RGB_TO_ULONG(238, 106, 167), "HotPink2" },
825 { RGB_TO_ULONG(205, 96 , 144), "HotPink3" },
826 { RGB_TO_ULONG(139, 58 , 98 ), "HotPink4" },
827 { RGB_TO_ULONG(255, 181, 197), "pink1" },
828 { RGB_TO_ULONG(238, 169, 184), "pink2" },
829 { RGB_TO_ULONG(205, 145, 158), "pink3" },
830 { RGB_TO_ULONG(139, 99 , 108), "pink4" },
831 { RGB_TO_ULONG(255, 174, 185), "LightPink1" },
832 { RGB_TO_ULONG(238, 162, 173), "LightPink2" },
833 { RGB_TO_ULONG(205, 140, 149), "LightPink3" },
834 { RGB_TO_ULONG(139, 95 , 101), "LightPink4" },
835 { RGB_TO_ULONG(255, 130, 171), "PaleVioletRed1" },
836 { RGB_TO_ULONG(238, 121, 159), "PaleVioletRed2" },
837 { RGB_TO_ULONG(205, 104, 137), "PaleVioletRed3" },
838 { RGB_TO_ULONG(139, 71 , 93 ), "PaleVioletRed4" },
839 { RGB_TO_ULONG(255, 52 , 179), "maroon1" },
840 { RGB_TO_ULONG(238, 48 , 167), "maroon2" },
841 { RGB_TO_ULONG(205, 41 , 144), "maroon3" },
842 { RGB_TO_ULONG(139, 28 , 98 ), "maroon4" },
843 { RGB_TO_ULONG(255, 62 , 150), "VioletRed1" },
844 { RGB_TO_ULONG(238, 58 , 140), "VioletRed2" },
845 { RGB_TO_ULONG(205, 50 , 120), "VioletRed3" },
846 { RGB_TO_ULONG(139, 34 , 82 ), "VioletRed4" },
847 { RGB_TO_ULONG(255, 0 , 255), "magenta1" },
848 { RGB_TO_ULONG(238, 0 , 238), "magenta2" },
849 { RGB_TO_ULONG(205, 0 , 205), "magenta3" },
850 { RGB_TO_ULONG(139, 0 , 139), "magenta4" },
851 { RGB_TO_ULONG(255, 131, 250), "orchid1" },
852 { RGB_TO_ULONG(238, 122, 233), "orchid2" },
853 { RGB_TO_ULONG(205, 105, 201), "orchid3" },
854 { RGB_TO_ULONG(139, 71 , 137), "orchid4" },
855 { RGB_TO_ULONG(255, 187, 255), "plum1" },
856 { RGB_TO_ULONG(238, 174, 238), "plum2" },
857 { RGB_TO_ULONG(205, 150, 205), "plum3" },
858 { RGB_TO_ULONG(139, 102, 139), "plum4" },
859 { RGB_TO_ULONG(224, 102, 255), "MediumOrchid1" },
860 { RGB_TO_ULONG(209, 95 , 238), "MediumOrchid2" },
861 { RGB_TO_ULONG(180, 82 , 205), "MediumOrchid3" },
862 { RGB_TO_ULONG(122, 55 , 139), "MediumOrchid4" },
863 { RGB_TO_ULONG(191, 62 , 255), "DarkOrchid1" },
864 { RGB_TO_ULONG(178, 58 , 238), "DarkOrchid2" },
865 { RGB_TO_ULONG(154, 50 , 205), "DarkOrchid3" },
866 { RGB_TO_ULONG(104, 34 , 139), "DarkOrchid4" },
867 { RGB_TO_ULONG(155, 48 , 255), "purple1" },
868 { RGB_TO_ULONG(145, 44 , 238), "purple2" },
869 { RGB_TO_ULONG(125, 38 , 205), "purple3" },
870 { RGB_TO_ULONG(85 , 26 , 139), "purple4" },
871 { RGB_TO_ULONG(171, 130, 255), "MediumPurple1" },
872 { RGB_TO_ULONG(159, 121, 238), "MediumPurple2" },
873 { RGB_TO_ULONG(137, 104, 205), "MediumPurple3" },
874 { RGB_TO_ULONG(93 , 71 , 139), "MediumPurple4" },
875 { RGB_TO_ULONG(255, 225, 255), "thistle1" },
876 { RGB_TO_ULONG(238, 210, 238), "thistle2" },
877 { RGB_TO_ULONG(205, 181, 205), "thistle3" },
878 { RGB_TO_ULONG(139, 123, 139), "thistle4" },
879 { RGB_TO_ULONG(0 , 0 , 0 ), "gray0" },
880 { RGB_TO_ULONG(0 , 0 , 0 ), "grey0" },
881 { RGB_TO_ULONG(3 , 3 , 3 ), "gray1" },
882 { RGB_TO_ULONG(3 , 3 , 3 ), "grey1" },
883 { RGB_TO_ULONG(5 , 5 , 5 ), "gray2" },
884 { RGB_TO_ULONG(5 , 5 , 5 ), "grey2" },
885 { RGB_TO_ULONG(8 , 8 , 8 ), "gray3" },
886 { RGB_TO_ULONG(8 , 8 , 8 ), "grey3" },
887 { RGB_TO_ULONG(10 , 10 , 10 ), "gray4" },
888 { RGB_TO_ULONG(10 , 10 , 10 ), "grey4" },
889 { RGB_TO_ULONG(13 , 13 , 13 ), "gray5" },
890 { RGB_TO_ULONG(13 , 13 , 13 ), "grey5" },
891 { RGB_TO_ULONG(15 , 15 , 15 ), "gray6" },
892 { RGB_TO_ULONG(15 , 15 , 15 ), "grey6" },
893 { RGB_TO_ULONG(18 , 18 , 18 ), "gray7" },
894 { RGB_TO_ULONG(18 , 18 , 18 ), "grey7" },
895 { RGB_TO_ULONG(20 , 20 , 20 ), "gray8" },
896 { RGB_TO_ULONG(20 , 20 , 20 ), "grey8" },
897 { RGB_TO_ULONG(23 , 23 , 23 ), "gray9" },
898 { RGB_TO_ULONG(23 , 23 , 23 ), "grey9" },
899 { RGB_TO_ULONG(26 , 26 , 26 ), "gray10" },
900 { RGB_TO_ULONG(26 , 26 , 26 ), "grey10" },
901 { RGB_TO_ULONG(28 , 28 , 28 ), "gray11" },
902 { RGB_TO_ULONG(28 , 28 , 28 ), "grey11" },
903 { RGB_TO_ULONG(31 , 31 , 31 ), "gray12" },
904 { RGB_TO_ULONG(31 , 31 , 31 ), "grey12" },
905 { RGB_TO_ULONG(33 , 33 , 33 ), "gray13" },
906 { RGB_TO_ULONG(33 , 33 , 33 ), "grey13" },
907 { RGB_TO_ULONG(36 , 36 , 36 ), "gray14" },
908 { RGB_TO_ULONG(36 , 36 , 36 ), "grey14" },
909 { RGB_TO_ULONG(38 , 38 , 38 ), "gray15" },
910 { RGB_TO_ULONG(38 , 38 , 38 ), "grey15" },
911 { RGB_TO_ULONG(41 , 41 , 41 ), "gray16" },
912 { RGB_TO_ULONG(41 , 41 , 41 ), "grey16" },
913 { RGB_TO_ULONG(43 , 43 , 43 ), "gray17" },
914 { RGB_TO_ULONG(43 , 43 , 43 ), "grey17" },
915 { RGB_TO_ULONG(46 , 46 , 46 ), "gray18" },
916 { RGB_TO_ULONG(46 , 46 , 46 ), "grey18" },
917 { RGB_TO_ULONG(48 , 48 , 48 ), "gray19" },
918 { RGB_TO_ULONG(48 , 48 , 48 ), "grey19" },
919 { RGB_TO_ULONG(51 , 51 , 51 ), "gray20" },
920 { RGB_TO_ULONG(51 , 51 , 51 ), "grey20" },
921 { RGB_TO_ULONG(54 , 54 , 54 ), "gray21" },
922 { RGB_TO_ULONG(54 , 54 , 54 ), "grey21" },
923 { RGB_TO_ULONG(56 , 56 , 56 ), "gray22" },
924 { RGB_TO_ULONG(56 , 56 , 56 ), "grey22" },
925 { RGB_TO_ULONG(59 , 59 , 59 ), "gray23" },
926 { RGB_TO_ULONG(59 , 59 , 59 ), "grey23" },
927 { RGB_TO_ULONG(61 , 61 , 61 ), "gray24" },
928 { RGB_TO_ULONG(61 , 61 , 61 ), "grey24" },
929 { RGB_TO_ULONG(64 , 64 , 64 ), "gray25" },
930 { RGB_TO_ULONG(64 , 64 , 64 ), "grey25" },
931 { RGB_TO_ULONG(66 , 66 , 66 ), "gray26" },
932 { RGB_TO_ULONG(66 , 66 , 66 ), "grey26" },
933 { RGB_TO_ULONG(69 , 69 , 69 ), "gray27" },
934 { RGB_TO_ULONG(69 , 69 , 69 ), "grey27" },
935 { RGB_TO_ULONG(71 , 71 , 71 ), "gray28" },
936 { RGB_TO_ULONG(71 , 71 , 71 ), "grey28" },
937 { RGB_TO_ULONG(74 , 74 , 74 ), "gray29" },
938 { RGB_TO_ULONG(74 , 74 , 74 ), "grey29" },
939 { RGB_TO_ULONG(77 , 77 , 77 ), "gray30" },
940 { RGB_TO_ULONG(77 , 77 , 77 ), "grey30" },
941 { RGB_TO_ULONG(79 , 79 , 79 ), "gray31" },
942 { RGB_TO_ULONG(79 , 79 , 79 ), "grey31" },
943 { RGB_TO_ULONG(82 , 82 , 82 ), "gray32" },
944 { RGB_TO_ULONG(82 , 82 , 82 ), "grey32" },
945 { RGB_TO_ULONG(84 , 84 , 84 ), "gray33" },
946 { RGB_TO_ULONG(84 , 84 , 84 ), "grey33" },
947 { RGB_TO_ULONG(87 , 87 , 87 ), "gray34" },
948 { RGB_TO_ULONG(87 , 87 , 87 ), "grey34" },
949 { RGB_TO_ULONG(89 , 89 , 89 ), "gray35" },
950 { RGB_TO_ULONG(89 , 89 , 89 ), "grey35" },
951 { RGB_TO_ULONG(92 , 92 , 92 ), "gray36" },
952 { RGB_TO_ULONG(92 , 92 , 92 ), "grey36" },
953 { RGB_TO_ULONG(94 , 94 , 94 ), "gray37" },
954 { RGB_TO_ULONG(94 , 94 , 94 ), "grey37" },
955 { RGB_TO_ULONG(97 , 97 , 97 ), "gray38" },
956 { RGB_TO_ULONG(97 , 97 , 97 ), "grey38" },
957 { RGB_TO_ULONG(99 , 99 , 99 ), "gray39" },
958 { RGB_TO_ULONG(99 , 99 , 99 ), "grey39" },
959 { RGB_TO_ULONG(102, 102, 102), "gray40" },
960 { RGB_TO_ULONG(102, 102, 102), "grey40" },
961 { RGB_TO_ULONG(105, 105, 105), "gray41" },
962 { RGB_TO_ULONG(105, 105, 105), "grey41" },
963 { RGB_TO_ULONG(107, 107, 107), "gray42" },
964 { RGB_TO_ULONG(107, 107, 107), "grey42" },
965 { RGB_TO_ULONG(110, 110, 110), "gray43" },
966 { RGB_TO_ULONG(110, 110, 110), "grey43" },
967 { RGB_TO_ULONG(112, 112, 112), "gray44" },
968 { RGB_TO_ULONG(112, 112, 112), "grey44" },
969 { RGB_TO_ULONG(115, 115, 115), "gray45" },
970 { RGB_TO_ULONG(115, 115, 115), "grey45" },
971 { RGB_TO_ULONG(117, 117, 117), "gray46" },
972 { RGB_TO_ULONG(117, 117, 117), "grey46" },
973 { RGB_TO_ULONG(120, 120, 120), "gray47" },
974 { RGB_TO_ULONG(120, 120, 120), "grey47" },
975 { RGB_TO_ULONG(122, 122, 122), "gray48" },
976 { RGB_TO_ULONG(122, 122, 122), "grey48" },
977 { RGB_TO_ULONG(125, 125, 125), "gray49" },
978 { RGB_TO_ULONG(125, 125, 125), "grey49" },
979 { RGB_TO_ULONG(127, 127, 127), "gray50" },
980 { RGB_TO_ULONG(127, 127, 127), "grey50" },
981 { RGB_TO_ULONG(130, 130, 130), "gray51" },
982 { RGB_TO_ULONG(130, 130, 130), "grey51" },
983 { RGB_TO_ULONG(133, 133, 133), "gray52" },
984 { RGB_TO_ULONG(133, 133, 133), "grey52" },
985 { RGB_TO_ULONG(135, 135, 135), "gray53" },
986 { RGB_TO_ULONG(135, 135, 135), "grey53" },
987 { RGB_TO_ULONG(138, 138, 138), "gray54" },
988 { RGB_TO_ULONG(138, 138, 138), "grey54" },
989 { RGB_TO_ULONG(140, 140, 140), "gray55" },
990 { RGB_TO_ULONG(140, 140, 140), "grey55" },
991 { RGB_TO_ULONG(143, 143, 143), "gray56" },
992 { RGB_TO_ULONG(143, 143, 143), "grey56" },
993 { RGB_TO_ULONG(145, 145, 145), "gray57" },
994 { RGB_TO_ULONG(145, 145, 145), "grey57" },
995 { RGB_TO_ULONG(148, 148, 148), "gray58" },
996 { RGB_TO_ULONG(148, 148, 148), "grey58" },
997 { RGB_TO_ULONG(150, 150, 150), "gray59" },
998 { RGB_TO_ULONG(150, 150, 150), "grey59" },
999 { RGB_TO_ULONG(153, 153, 153), "gray60" },
1000 { RGB_TO_ULONG(153, 153, 153), "grey60" },
1001 { RGB_TO_ULONG(156, 156, 156), "gray61" },
1002 { RGB_TO_ULONG(156, 156, 156), "grey61" },
1003 { RGB_TO_ULONG(158, 158, 158), "gray62" },
1004 { RGB_TO_ULONG(158, 158, 158), "grey62" },
1005 { RGB_TO_ULONG(161, 161, 161), "gray63" },
1006 { RGB_TO_ULONG(161, 161, 161), "grey63" },
1007 { RGB_TO_ULONG(163, 163, 163), "gray64" },
1008 { RGB_TO_ULONG(163, 163, 163), "grey64" },
1009 { RGB_TO_ULONG(166, 166, 166), "gray65" },
1010 { RGB_TO_ULONG(166, 166, 166), "grey65" },
1011 { RGB_TO_ULONG(168, 168, 168), "gray66" },
1012 { RGB_TO_ULONG(168, 168, 168), "grey66" },
1013 { RGB_TO_ULONG(171, 171, 171), "gray67" },
1014 { RGB_TO_ULONG(171, 171, 171), "grey67" },
1015 { RGB_TO_ULONG(173, 173, 173), "gray68" },
1016 { RGB_TO_ULONG(173, 173, 173), "grey68" },
1017 { RGB_TO_ULONG(176, 176, 176), "gray69" },
1018 { RGB_TO_ULONG(176, 176, 176), "grey69" },
1019 { RGB_TO_ULONG(179, 179, 179), "gray70" },
1020 { RGB_TO_ULONG(179, 179, 179), "grey70" },
1021 { RGB_TO_ULONG(181, 181, 181), "gray71" },
1022 { RGB_TO_ULONG(181, 181, 181), "grey71" },
1023 { RGB_TO_ULONG(184, 184, 184), "gray72" },
1024 { RGB_TO_ULONG(184, 184, 184), "grey72" },
1025 { RGB_TO_ULONG(186, 186, 186), "gray73" },
1026 { RGB_TO_ULONG(186, 186, 186), "grey73" },
1027 { RGB_TO_ULONG(189, 189, 189), "gray74" },
1028 { RGB_TO_ULONG(189, 189, 189), "grey74" },
1029 { RGB_TO_ULONG(191, 191, 191), "gray75" },
1030 { RGB_TO_ULONG(191, 191, 191), "grey75" },
1031 { RGB_TO_ULONG(194, 194, 194), "gray76" },
1032 { RGB_TO_ULONG(194, 194, 194), "grey76" },
1033 { RGB_TO_ULONG(196, 196, 196), "gray77" },
1034 { RGB_TO_ULONG(196, 196, 196), "grey77" },
1035 { RGB_TO_ULONG(199, 199, 199), "gray78" },
1036 { RGB_TO_ULONG(199, 199, 199), "grey78" },
1037 { RGB_TO_ULONG(201, 201, 201), "gray79" },
1038 { RGB_TO_ULONG(201, 201, 201), "grey79" },
1039 { RGB_TO_ULONG(204, 204, 204), "gray80" },
1040 { RGB_TO_ULONG(204, 204, 204), "grey80" },
1041 { RGB_TO_ULONG(207, 207, 207), "gray81" },
1042 { RGB_TO_ULONG(207, 207, 207), "grey81" },
1043 { RGB_TO_ULONG(209, 209, 209), "gray82" },
1044 { RGB_TO_ULONG(209, 209, 209), "grey82" },
1045 { RGB_TO_ULONG(212, 212, 212), "gray83" },
1046 { RGB_TO_ULONG(212, 212, 212), "grey83" },
1047 { RGB_TO_ULONG(214, 214, 214), "gray84" },
1048 { RGB_TO_ULONG(214, 214, 214), "grey84" },
1049 { RGB_TO_ULONG(217, 217, 217), "gray85" },
1050 { RGB_TO_ULONG(217, 217, 217), "grey85" },
1051 { RGB_TO_ULONG(219, 219, 219), "gray86" },
1052 { RGB_TO_ULONG(219, 219, 219), "grey86" },
1053 { RGB_TO_ULONG(222, 222, 222), "gray87" },
1054 { RGB_TO_ULONG(222, 222, 222), "grey87" },
1055 { RGB_TO_ULONG(224, 224, 224), "gray88" },
1056 { RGB_TO_ULONG(224, 224, 224), "grey88" },
1057 { RGB_TO_ULONG(227, 227, 227), "gray89" },
1058 { RGB_TO_ULONG(227, 227, 227), "grey89" },
1059 { RGB_TO_ULONG(229, 229, 229), "gray90" },
1060 { RGB_TO_ULONG(229, 229, 229), "grey90" },
1061 { RGB_TO_ULONG(232, 232, 232), "gray91" },
1062 { RGB_TO_ULONG(232, 232, 232), "grey91" },
1063 { RGB_TO_ULONG(235, 235, 235), "gray92" },
1064 { RGB_TO_ULONG(235, 235, 235), "grey92" },
1065 { RGB_TO_ULONG(237, 237, 237), "gray93" },
1066 { RGB_TO_ULONG(237, 237, 237), "grey93" },
1067 { RGB_TO_ULONG(240, 240, 240), "gray94" },
1068 { RGB_TO_ULONG(240, 240, 240), "grey94" },
1069 { RGB_TO_ULONG(242, 242, 242), "gray95" },
1070 { RGB_TO_ULONG(242, 242, 242), "grey95" },
1071 { RGB_TO_ULONG(245, 245, 245), "gray96" },
1072 { RGB_TO_ULONG(245, 245, 245), "grey96" },
1073 { RGB_TO_ULONG(247, 247, 247), "gray97" },
1074 { RGB_TO_ULONG(247, 247, 247), "grey97" },
1075 { RGB_TO_ULONG(250, 250, 250), "gray98" },
1076 { RGB_TO_ULONG(250, 250, 250), "grey98" },
1077 { RGB_TO_ULONG(252, 252, 252), "gray99" },
1078 { RGB_TO_ULONG(252, 252, 252), "grey99" },
1079 { RGB_TO_ULONG(255, 255, 255), "gray100" },
1080 { RGB_TO_ULONG(255, 255, 255), "grey100" },
1081 { RGB_TO_ULONG(169, 169, 169), "dark grey" },
1082 { RGB_TO_ULONG(169, 169, 169), "DarkGrey" },
1083 { RGB_TO_ULONG(169, 169, 169), "dark gray" },
1084 { RGB_TO_ULONG(169, 169, 169), "DarkGray" },
1085 { RGB_TO_ULONG(0 , 0 , 139), "dark blue" },
1086 { RGB_TO_ULONG(0 , 0 , 139), "DarkBlue" },
1087 { RGB_TO_ULONG(0 , 139, 139), "dark cyan" },
1088 { RGB_TO_ULONG(0 , 139, 139), "DarkCyan" },
1089 { RGB_TO_ULONG(139, 0 , 139), "dark magenta" },
1090 { RGB_TO_ULONG(139, 0 , 139), "DarkMagenta" },
1091 { RGB_TO_ULONG(139, 0 , 0 ), "dark red" },
1092 { RGB_TO_ULONG(139, 0 , 0 ), "DarkRed" },
1093 { RGB_TO_ULONG(144, 238, 144), "light green" },
1094 { RGB_TO_ULONG(144, 238, 144), "LightGreen" }
1098 mac_color_map_lookup (colorname
)
1101 Lisp_Object ret
= Qnil
;
1106 for (i
= 0; i
< sizeof (mac_color_map
) / sizeof (mac_color_map
[0]); i
++)
1107 if (xstricmp (colorname
, mac_color_map
[i
].name
) == 0)
1109 ret
= make_number (mac_color_map
[i
].color
);
1119 x_to_mac_color (colorname
)
1122 register Lisp_Object tail
, ret
= Qnil
;
1126 if (colorname
[0] == '#')
1128 /* Could be an old-style RGB Device specification. */
1131 color
= colorname
+ 1;
1133 size
= strlen(color
);
1134 if (size
== 3 || size
== 6 || size
== 9 || size
== 12)
1136 unsigned long colorval
;
1142 for (i
= 0; i
< 3; i
++)
1146 unsigned long value
;
1148 /* The check for 'x' in the following conditional takes into
1149 account the fact that strtol allows a "0x" in front of
1150 our numbers, and we don't. */
1151 if (!isxdigit(color
[0]) || color
[1] == 'x')
1155 value
= strtoul(color
, &end
, 16);
1157 if (errno
== ERANGE
|| end
- color
!= size
)
1162 value
= value
* 0x10;
1173 colorval
|= (value
<< pos
);
1178 return make_number (colorval
);
1184 else if (strnicmp(colorname
, "rgb:", 4) == 0)
1187 unsigned long colorval
;
1192 color
= colorname
+ 4;
1193 for (i
= 0; i
< 3; i
++)
1196 unsigned long value
;
1198 /* The check for 'x' in the following conditional takes into
1199 account the fact that strtol allows a "0x" in front of
1200 our numbers, and we don't. */
1201 if (!isxdigit(color
[0]) || color
[1] == 'x')
1203 value
= strtoul(color
, &end
, 16);
1204 if (errno
== ERANGE
)
1206 switch (end
- color
)
1209 value
= value
* 0x10 + value
;
1222 if (value
== ULONG_MAX
)
1224 colorval
|= (value
<< pos
);
1231 return make_number (colorval
);
1238 else if (strnicmp(colorname
, "rgbi:", 5) == 0)
1240 /* This is an RGB Intensity specification. */
1242 unsigned long colorval
;
1247 color
= colorname
+ 5;
1248 for (i
= 0; i
< 3; i
++)
1254 value
= strtod(color
, &end
);
1255 if (errno
== ERANGE
)
1257 if (value
< 0.0 || value
> 1.0)
1259 val
= (unsigned long)(0x100 * value
);
1260 /* We used 0x100 instead of 0xFF to give a continuous
1261 range between 0.0 and 1.0 inclusive. The next statement
1262 fixes the 1.0 case. */
1265 colorval
|= (val
<< pos
);
1272 return make_number (colorval
);
1280 ret
= mac_color_map_lookup (colorname
);
1286 /* Gamma-correct COLOR on frame F. */
1289 gamma_correct (f
, color
)
1291 unsigned long *color
;
1295 unsigned long red
, green
, blue
;
1297 red
= pow (RED_FROM_ULONG (*color
) / 255.0, f
->gamma
) * 255.0 + 0.5;
1298 green
= pow (GREEN_FROM_ULONG (*color
) / 255.0, f
->gamma
) * 255.0 + 0.5;
1299 blue
= pow (BLUE_FROM_ULONG (*color
) / 255.0, f
->gamma
) * 255.0 + 0.5;
1300 *color
= RGB_TO_ULONG (red
, green
, blue
);
1304 /* Decide if color named COLOR is valid for the display associated
1305 with the selected frame; if so, return the rgb values in COLOR_DEF.
1306 If ALLOC is nonzero, allocate a new colormap cell. */
1309 mac_defined_color (f
, color
, color_def
, alloc
)
1315 register Lisp_Object tem
;
1316 unsigned long mac_color_ref
;
1318 tem
= x_to_mac_color (color
);
1324 /* Apply gamma correction. */
1325 mac_color_ref
= XUINT (tem
);
1326 gamma_correct (f
, &mac_color_ref
);
1327 XSETINT (tem
, mac_color_ref
);
1330 color_def
->pixel
= mac_color_ref
;
1331 color_def
->red
= RED16_FROM_ULONG (mac_color_ref
);
1332 color_def
->green
= GREEN16_FROM_ULONG (mac_color_ref
);
1333 color_def
->blue
= BLUE16_FROM_ULONG (mac_color_ref
);
1343 /* Given a string ARG naming a color, compute a pixel value from it
1344 suitable for screen F.
1345 If F is not a color screen, return DEF (default) regardless of what
1349 x_decode_color (f
, arg
, def
)
1358 if (strcmp (SDATA (arg
), "black") == 0)
1359 return BLACK_PIX_DEFAULT (f
);
1360 else if (strcmp (SDATA (arg
), "white") == 0)
1361 return WHITE_PIX_DEFAULT (f
);
1364 if (FRAME_MAC_DISPLAY_INFO (f
)->n_planes
) == 1)
1368 if (mac_defined_color (f
, SDATA (arg
), &cdef
, 1))
1371 /* defined_color failed; return an ultimate default. */
1375 /* Functions called only from `x_set_frame_param'
1376 to set individual parameters.
1378 If FRAME_MAC_WINDOW (f) is 0,
1379 the frame is being created and its window does not exist yet.
1380 In that case, just record the parameter's new value
1381 in the standard place; do not attempt to change the window. */
1384 x_set_foreground_color (f
, arg
, oldval
)
1386 Lisp_Object arg
, oldval
;
1388 unsigned long fg
, old_fg
;
1390 fg
= x_decode_color (f
, arg
, BLACK_PIX_DEFAULT (f
));
1391 old_fg
= FRAME_FOREGROUND_PIXEL (f
);
1392 FRAME_FOREGROUND_PIXEL (f
) = fg
;
1394 if (FRAME_MAC_WINDOW (f
) != 0)
1396 update_face_from_frame_parameter (f
, Qforeground_color
, arg
);
1397 if (FRAME_VISIBLE_P (f
))
1403 x_set_background_color (f
, arg
, oldval
)
1405 Lisp_Object arg
, oldval
;
1407 FRAME_BACKGROUND_PIXEL (f
)
1408 = x_decode_color (f
, arg
, WHITE_PIX_DEFAULT (f
));
1410 if (FRAME_MAC_WINDOW (f
) != 0)
1412 update_face_from_frame_parameter (f
, Qbackground_color
, arg
);
1414 if (FRAME_VISIBLE_P (f
))
1420 x_set_mouse_color (f
, arg
, oldval
)
1422 Lisp_Object arg
, oldval
;
1424 Cursor cursor
, nontext_cursor
, mode_cursor
, hand_cursor
;
1428 if (!EQ (Qnil
, arg
))
1429 f
->output_data
.mac
->mouse_pixel
1430 = x_decode_color (f
, arg
, BLACK_PIX_DEFAULT (f
));
1431 mask_color
= FRAME_BACKGROUND_PIXEL (f
);
1433 /* Don't let pointers be invisible. */
1434 if (mask_color
== f
->output_data
.mac
->mouse_pixel
1435 && mask_color
== FRAME_BACKGROUND_PIXEL (f
))
1436 f
->output_data
.mac
->mouse_pixel
= FRAME_FOREGROUND_PIXEL (f
);
1438 #if 0 /* MAC_TODO : cursor changes */
1441 /* It's not okay to crash if the user selects a screwy cursor. */
1442 count
= x_catch_errors (FRAME_W32_DISPLAY (f
));
1444 if (!EQ (Qnil
, Vx_pointer_shape
))
1446 CHECK_NUMBER (Vx_pointer_shape
);
1447 cursor
= XCreateFontCursor (FRAME_W32_DISPLAY (f
), XINT (Vx_pointer_shape
));
1450 cursor
= XCreateFontCursor (FRAME_W32_DISPLAY (f
), XC_xterm
);
1451 x_check_errors (FRAME_W32_DISPLAY (f
), "bad text pointer cursor: %s");
1453 if (!EQ (Qnil
, Vx_nontext_pointer_shape
))
1455 CHECK_NUMBER (Vx_nontext_pointer_shape
);
1456 nontext_cursor
= XCreateFontCursor (FRAME_W32_DISPLAY (f
),
1457 XINT (Vx_nontext_pointer_shape
));
1460 nontext_cursor
= XCreateFontCursor (FRAME_W32_DISPLAY (f
), XC_left_ptr
);
1461 x_check_errors (FRAME_W32_DISPLAY (f
), "bad nontext pointer cursor: %s");
1463 if (!EQ (Qnil
, Vx_hourglass_pointer_shape
))
1465 CHECK_NUMBER (Vx_hourglass_pointer_shape
);
1466 hourglass_cursor
= XCreateFontCursor (FRAME_W32_DISPLAY (f
),
1467 XINT (Vx_hourglass_pointer_shape
));
1470 hourglass_cursor
= XCreateFontCursor (FRAME_W32_DISPLAY (f
), XC_watch
);
1471 x_check_errors (FRAME_W32_DISPLAY (f
), "bad busy pointer cursor: %s");
1473 x_check_errors (FRAME_W32_DISPLAY (f
), "bad nontext pointer cursor: %s");
1474 if (!EQ (Qnil
, Vx_mode_pointer_shape
))
1476 CHECK_NUMBER (Vx_mode_pointer_shape
);
1477 mode_cursor
= XCreateFontCursor (FRAME_W32_DISPLAY (f
),
1478 XINT (Vx_mode_pointer_shape
));
1481 mode_cursor
= XCreateFontCursor (FRAME_W32_DISPLAY (f
), XC_xterm
);
1482 x_check_errors (FRAME_W32_DISPLAY (f
), "bad modeline pointer cursor: %s");
1484 if (!EQ (Qnil
, Vx_sensitive_text_pointer_shape
))
1486 CHECK_NUMBER (Vx_sensitive_text_pointer_shape
);
1488 = XCreateFontCursor (FRAME_W32_DISPLAY (f
),
1489 XINT (Vx_sensitive_text_pointer_shape
));
1492 hand_cursor
= XCreateFontCursor (FRAME_W32_DISPLAY (f
), XC_crosshair
);
1494 if (!NILP (Vx_window_horizontal_drag_shape
))
1496 CHECK_NUMBER (Vx_window_horizontal_drag_shape
);
1497 horizontal_drag_cursor
1498 = XCreateFontCursor (FRAME_W32_DISPLAY (f
),
1499 XINT (Vx_window_horizontal_drag_shape
));
1502 horizontal_drag_cursor
1503 = XCreateFontCursor (FRAME_W32_DISPLAY (f
), XC_sb_h_double_arrow
);
1505 /* Check and report errors with the above calls. */
1506 x_check_errors (FRAME_W32_DISPLAY (f
), "can't set cursor shape: %s");
1507 x_uncatch_errors (FRAME_W32_DISPLAY (f
), count
);
1510 XColor fore_color
, back_color
;
1512 fore_color
.pixel
= f
->output_data
.w32
->mouse_pixel
;
1513 back_color
.pixel
= mask_color
;
1514 XQueryColor (FRAME_W32_DISPLAY (f
),
1515 DefaultColormap (FRAME_W32_DISPLAY (f
),
1516 DefaultScreen (FRAME_W32_DISPLAY (f
))),
1518 XQueryColor (FRAME_W32_DISPLAY (f
),
1519 DefaultColormap (FRAME_W32_DISPLAY (f
),
1520 DefaultScreen (FRAME_W32_DISPLAY (f
))),
1522 XRecolorCursor (FRAME_W32_DISPLAY (f
), cursor
,
1523 &fore_color
, &back_color
);
1524 XRecolorCursor (FRAME_W32_DISPLAY (f
), nontext_cursor
,
1525 &fore_color
, &back_color
);
1526 XRecolorCursor (FRAME_W32_DISPLAY (f
), mode_cursor
,
1527 &fore_color
, &back_color
);
1528 XRecolorCursor (FRAME_W32_DISPLAY (f
), hand_cursor
,
1529 &fore_color
, &back_color
);
1530 XRecolorCursor (FRAME_W32_DISPLAY (f
), hourglass_cursor
,
1531 &fore_color
, &back_color
);
1534 if (FRAME_W32_WINDOW (f
) != 0)
1535 XDefineCursor (FRAME_W32_DISPLAY (f
), FRAME_W32_WINDOW (f
), cursor
);
1537 if (cursor
!= f
->output_data
.w32
->text_cursor
&& f
->output_data
.w32
->text_cursor
!= 0)
1538 XFreeCursor (FRAME_W32_DISPLAY (f
), f
->output_data
.w32
->text_cursor
);
1539 f
->output_data
.w32
->text_cursor
= cursor
;
1541 if (nontext_cursor
!= f
->output_data
.w32
->nontext_cursor
1542 && f
->output_data
.w32
->nontext_cursor
!= 0)
1543 XFreeCursor (FRAME_W32_DISPLAY (f
), f
->output_data
.w32
->nontext_cursor
);
1544 f
->output_data
.w32
->nontext_cursor
= nontext_cursor
;
1546 if (hourglass_cursor
!= f
->output_data
.w32
->hourglass_cursor
1547 && f
->output_data
.w32
->hourglass_cursor
!= 0)
1548 XFreeCursor (FRAME_W32_DISPLAY (f
), f
->output_data
.w32
->hourglass_cursor
);
1549 f
->output_data
.w32
->hourglass_cursor
= hourglass_cursor
;
1551 if (mode_cursor
!= f
->output_data
.w32
->modeline_cursor
1552 && f
->output_data
.w32
->modeline_cursor
!= 0)
1553 XFreeCursor (FRAME_W32_DISPLAY (f
), f
->output_data
.w32
->modeline_cursor
);
1554 f
->output_data
.w32
->modeline_cursor
= mode_cursor
;
1556 if (hand_cursor
!= f
->output_data
.w32
->hand_cursor
1557 && f
->output_data
.w32
->hand_cursor
!= 0)
1558 XFreeCursor (FRAME_W32_DISPLAY (f
), f
->output_data
.w32
->hand_cursor
);
1559 f
->output_data
.w32
->hand_cursor
= hand_cursor
;
1561 XFlush (FRAME_W32_DISPLAY (f
));
1564 update_face_from_frame_parameter (f
, Qmouse_color
, arg
);
1565 #endif /* MAC_TODO */
1569 x_set_cursor_color (f
, arg
, oldval
)
1571 Lisp_Object arg
, oldval
;
1573 unsigned long fore_pixel
, pixel
;
1575 if (!NILP (Vx_cursor_fore_pixel
))
1576 fore_pixel
= x_decode_color (f
, Vx_cursor_fore_pixel
,
1577 WHITE_PIX_DEFAULT (f
));
1579 fore_pixel
= FRAME_BACKGROUND_PIXEL (f
);
1581 pixel
= x_decode_color (f
, arg
, BLACK_PIX_DEFAULT (f
));
1583 /* Make sure that the cursor color differs from the background color. */
1584 if (pixel
== FRAME_BACKGROUND_PIXEL (f
))
1586 pixel
= f
->output_data
.mac
->mouse_pixel
;
1587 if (pixel
== fore_pixel
)
1588 fore_pixel
= FRAME_BACKGROUND_PIXEL (f
);
1591 f
->output_data
.mac
->cursor_foreground_pixel
= fore_pixel
;
1592 f
->output_data
.mac
->cursor_pixel
= pixel
;
1594 if (FRAME_MAC_WINDOW (f
) != 0)
1597 /* Update frame's cursor_gc. */
1598 f
->output_data
.mac
->cursor_gc
->foreground
= fore_pixel
;
1599 f
->output_data
.mac
->cursor_gc
->background
= pixel
;
1603 if (FRAME_VISIBLE_P (f
))
1605 x_update_cursor (f
, 0);
1606 x_update_cursor (f
, 1);
1610 update_face_from_frame_parameter (f
, Qcursor_color
, arg
);
1613 /* Set the border-color of frame F to pixel value PIX.
1614 Note that this does not fully take effect if done before
1618 x_set_border_pixel (f
, pix
)
1623 f
->output_data
.mac
->border_pixel
= pix
;
1625 if (FRAME_MAC_WINDOW (f
) != 0 && f
->border_width
> 0)
1627 if (FRAME_VISIBLE_P (f
))
1632 /* Set the border-color of frame F to value described by ARG.
1633 ARG can be a string naming a color.
1634 The border-color is used for the border that is drawn by the server.
1635 Note that this does not fully take effect if done before
1636 F has a window; it must be redone when the window is created. */
1639 x_set_border_color (f
, arg
, oldval
)
1641 Lisp_Object arg
, oldval
;
1646 pix
= x_decode_color (f
, arg
, BLACK_PIX_DEFAULT (f
));
1647 x_set_border_pixel (f
, pix
);
1648 update_face_from_frame_parameter (f
, Qborder_color
, arg
);
1653 x_set_cursor_type (f
, arg
, oldval
)
1655 Lisp_Object arg
, oldval
;
1657 set_frame_cursor_types (f
, arg
);
1659 /* Make sure the cursor gets redrawn. */
1660 cursor_type_changed
= 1;
1663 #if 0 /* MAC_TODO: really no icon for Mac */
1665 x_set_icon_type (f
, arg
, oldval
)
1667 Lisp_Object arg
, oldval
;
1671 if (NILP (arg
) && NILP (oldval
))
1674 if (STRINGP (arg
) && STRINGP (oldval
)
1675 && EQ (Fstring_equal (oldval
, arg
), Qt
))
1678 if (SYMBOLP (arg
) && SYMBOLP (oldval
) && EQ (arg
, oldval
))
1683 result
= x_bitmap_icon (f
, arg
);
1687 error ("No icon window available");
1692 #endif /* MAC_TODO */
1695 x_set_icon_name (f
, arg
, oldval
)
1697 Lisp_Object arg
, oldval
;
1703 if (STRINGP (oldval
) && EQ (Fstring_equal (oldval
, arg
), Qt
))
1706 else if (!STRINGP (oldval
) && EQ (oldval
, Qnil
) == EQ (arg
, Qnil
))
1711 #if 0 /* MAC_TODO */
1712 if (f
->output_data
.w32
->icon_bitmap
!= 0)
1717 result
= x_text_icon (f
,
1718 (char *) SDATA ((!NILP (f
->icon_name
)
1727 error ("No icon window available");
1730 /* If the window was unmapped (and its icon was mapped),
1731 the new icon is not mapped, so map the window in its stead. */
1732 if (FRAME_VISIBLE_P (f
))
1734 #ifdef USE_X_TOOLKIT
1735 XtPopup (f
->output_data
.w32
->widget
, XtGrabNone
);
1737 XMapWindow (FRAME_W32_DISPLAY (f
), FRAME_W32_WINDOW (f
));
1740 XFlush (FRAME_W32_DISPLAY (f
));
1742 #endif /* MAC_TODO */
1747 x_set_menu_bar_lines (f
, value
, oldval
)
1749 Lisp_Object value
, oldval
;
1752 int olines
= FRAME_MENU_BAR_LINES (f
);
1754 /* Right now, menu bars don't work properly in minibuf-only frames;
1755 most of the commands try to apply themselves to the minibuffer
1756 frame itself, and get an error because you can't switch buffers
1757 in or split the minibuffer window. */
1758 if (FRAME_MINIBUF_ONLY_P (f
))
1761 if (INTEGERP (value
))
1762 nlines
= XINT (value
);
1766 FRAME_MENU_BAR_LINES (f
) = 0;
1768 FRAME_EXTERNAL_MENU_BAR (f
) = 1;
1771 if (FRAME_EXTERNAL_MENU_BAR (f
) == 1)
1772 free_frame_menubar (f
);
1773 FRAME_EXTERNAL_MENU_BAR (f
) = 0;
1775 /* Adjust the frame size so that the client (text) dimensions
1776 remain the same. This depends on FRAME_EXTERNAL_MENU_BAR being
1778 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
1779 do_pending_window_change (0);
1785 /* Set the number of lines used for the tool bar of frame F to VALUE.
1786 VALUE not an integer, or < 0 means set the lines to zero. OLDVAL
1787 is the old number of tool bar lines. This function changes the
1788 height of all windows on frame F to match the new tool bar height.
1789 The frame's height doesn't change. */
1792 x_set_tool_bar_lines (f
, value
, oldval
)
1794 Lisp_Object value
, oldval
;
1796 int delta
, nlines
, root_height
;
1797 Lisp_Object root_window
;
1799 /* Treat tool bars like menu bars. */
1800 if (FRAME_MINIBUF_ONLY_P (f
))
1803 /* Use VALUE only if an integer >= 0. */
1804 if (INTEGERP (value
) && XINT (value
) >= 0)
1805 nlines
= XFASTINT (value
);
1809 /* Make sure we redisplay all windows in this frame. */
1810 ++windows_or_buffers_changed
;
1812 delta
= nlines
- FRAME_TOOL_BAR_LINES (f
);
1814 /* Don't resize the tool-bar to more than we have room for. */
1815 root_window
= FRAME_ROOT_WINDOW (f
);
1816 root_height
= WINDOW_TOTAL_LINES (XWINDOW (root_window
));
1817 if (root_height
- delta
< 1)
1819 delta
= root_height
- 1;
1820 nlines
= FRAME_TOOL_BAR_LINES (f
) + delta
;
1823 FRAME_TOOL_BAR_LINES (f
) = nlines
;
1824 change_window_heights (root_window
, delta
);
1827 /* We also have to make sure that the internal border at the top of
1828 the frame, below the menu bar or tool bar, is redrawn when the
1829 tool bar disappears. This is so because the internal border is
1830 below the tool bar if one is displayed, but is below the menu bar
1831 if there isn't a tool bar. The tool bar draws into the area
1832 below the menu bar. */
1833 if (FRAME_MAC_WINDOW (f
) && FRAME_TOOL_BAR_LINES (f
) == 0)
1837 clear_current_matrices (f
);
1838 updating_frame
= NULL
;
1841 /* If the tool bar gets smaller, the internal border below it
1842 has to be cleared. It was formerly part of the display
1843 of the larger tool bar, and updating windows won't clear it. */
1846 int height
= FRAME_INTERNAL_BORDER_WIDTH (f
);
1847 int width
= FRAME_PIXEL_WIDTH (f
);
1848 int y
= nlines
* FRAME_LINE_HEIGHT (f
);
1851 XClearArea (FRAME_MAC_DISPLAY (f
), FRAME_MAC_WINDOW (f
),
1852 0, y
, width
, height
, 0);
1855 if (WINDOWP (f
->tool_bar_window
))
1856 clear_glyph_matrix (XWINDOW (f
->tool_bar_window
)->current_matrix
);
1861 /* Change the name of frame F to NAME. If NAME is nil, set F's name to
1864 If EXPLICIT is non-zero, that indicates that lisp code is setting the
1865 name; if NAME is a string, set F's name to NAME and set
1866 F->explicit_name; if NAME is Qnil, then clear F->explicit_name.
1868 If EXPLICIT is zero, that indicates that Emacs redisplay code is
1869 suggesting a new name, which lisp code should override; if
1870 F->explicit_name is set, ignore the new name; otherwise, set it. */
1873 x_set_name (f
, name
, explicit)
1878 /* Make sure that requests from lisp code override requests from
1879 Emacs redisplay code. */
1882 /* If we're switching from explicit to implicit, we had better
1883 update the mode lines and thereby update the title. */
1884 if (f
->explicit_name
&& NILP (name
))
1885 update_mode_lines
= 1;
1887 f
->explicit_name
= ! NILP (name
);
1889 else if (f
->explicit_name
)
1892 /* If NAME is nil, set the name to the w32_id_name. */
1895 /* Check for no change needed in this very common case
1896 before we do any consing. */
1897 if (!strcmp (FRAME_MAC_DISPLAY_INFO (f
)->mac_id_name
,
1900 name
= build_string (FRAME_MAC_DISPLAY_INFO (f
)->mac_id_name
);
1903 CHECK_STRING (name
);
1905 /* Don't change the name if it's already NAME. */
1906 if (! NILP (Fstring_equal (name
, f
->name
)))
1911 /* For setting the frame title, the title parameter should override
1912 the name parameter. */
1913 if (! NILP (f
->title
))
1916 if (FRAME_MAC_WINDOW (f
))
1918 if (STRING_MULTIBYTE (name
))
1919 #if TARGET_API_MAC_CARBON
1920 name
= ENCODE_UTF_8 (name
);
1928 #if TARGET_API_MAC_CARBON
1929 CFStringRef windowTitle
=
1930 cfstring_create_with_utf8_cstring (SDATA (name
));
1932 SetWindowTitleWithCFString (FRAME_MAC_WINDOW (f
), windowTitle
);
1933 CFRelease (windowTitle
);
1936 if (strlen (SDATA (name
)) < 255)
1938 strcpy (windowTitle
, SDATA (name
));
1939 c2pstr (windowTitle
);
1940 SetWTitle (FRAME_MAC_WINDOW (f
), windowTitle
);
1949 /* This function should be called when the user's lisp code has
1950 specified a name for the frame; the name will override any set by the
1953 x_explicitly_set_name (f
, arg
, oldval
)
1955 Lisp_Object arg
, oldval
;
1957 x_set_name (f
, arg
, 1);
1960 /* This function should be called by Emacs redisplay code to set the
1961 name; names set this way will never override names set by the user's
1964 x_implicitly_set_name (f
, arg
, oldval
)
1966 Lisp_Object arg
, oldval
;
1968 x_set_name (f
, arg
, 0);
1971 /* Change the title of frame F to NAME.
1972 If NAME is nil, use the frame name as the title.
1974 If EXPLICIT is non-zero, that indicates that lisp code is setting the
1975 name; if NAME is a string, set F's name to NAME and set
1976 F->explicit_name; if NAME is Qnil, then clear F->explicit_name.
1978 If EXPLICIT is zero, that indicates that Emacs redisplay code is
1979 suggesting a new name, which lisp code should override; if
1980 F->explicit_name is set, ignore the new name; otherwise, set it. */
1983 x_set_title (f
, name
, old_name
)
1985 Lisp_Object name
, old_name
;
1987 /* Don't change the title if it's already NAME. */
1988 if (EQ (name
, f
->title
))
1991 update_mode_lines
= 1;
1998 if (FRAME_MAC_WINDOW (f
))
2000 if (STRING_MULTIBYTE (name
))
2001 #if TARGET_API_MAC_CARBON
2002 name
= ENCODE_UTF_8 (name
);
2010 #if TARGET_API_MAC_CARBON
2011 CFStringRef windowTitle
=
2012 cfstring_create_with_utf8_cstring (SDATA (name
));
2014 SetWindowTitleWithCFString (FRAME_MAC_WINDOW (f
), windowTitle
);
2015 CFRelease (windowTitle
);
2018 if (strlen (SDATA (name
)) < 255)
2020 strcpy (windowTitle
, SDATA (name
));
2021 c2pstr (windowTitle
);
2022 SetWTitle (FRAME_MAC_WINDOW (f
), windowTitle
);
2032 x_set_scroll_bar_default_width (f
)
2035 /* Imitate X without X Toolkit */
2037 int wid
= FRAME_COLUMN_WIDTH (f
);
2040 FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) = 16; /* Aqua scroll bars. */
2041 FRAME_CONFIG_SCROLL_BAR_COLS (f
) = (FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) +
2043 #else /* not MAC_OSX */
2044 /* Make the actual width at least 14 pixels and a multiple of a
2046 FRAME_CONFIG_SCROLL_BAR_COLS (f
) = (14 + wid
- 1) / wid
;
2048 /* Use all of that space (aside from required margins) for the
2050 FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) = 0;
2051 #endif /* not MAC_OSX */
2055 /* Subroutines of creating a frame. */
2058 mac_get_rdb_resource (rdb
, resource
)
2063 int len
= strlen (resource
);
2067 if ((strncmp (value
, resource
, len
) == 0) && (value
[len
] == ':'))
2068 return xstrdup (&value
[len
+ 1]);
2070 value
= strchr (value
, '\0') + 1;
2076 /* Retrieve the string resource specified by NAME with CLASS from
2080 x_get_string_resource (rdb
, name
, class)
2088 if (resource
= mac_get_rdb_resource (rdb
, name
))
2090 if (resource
= mac_get_rdb_resource (rdb
, class))
2094 /* MAC_TODO: implement resource strings. (Maybe Property Lists?) */
2096 return mac_get_string_resource (name
, class);
2102 /* Return the value of parameter PARAM.
2104 First search ALIST, then Vdefault_frame_alist, then the X defaults
2105 database, using ATTRIBUTE as the attribute name and CLASS as its class.
2107 Convert the resource to the type specified by desired_type.
2109 If no default is specified, return Qunbound. If you call
2110 mac_get_arg, make sure you deal with Qunbound in a reasonable way,
2111 and don't let it get stored in any Lisp-visible variables! */
2114 mac_get_arg (alist
, param
, attribute
, class, type
)
2115 Lisp_Object alist
, param
;
2118 enum resource_types type
;
2120 return x_get_arg (check_x_display_info (Qnil
),
2121 alist
, param
, attribute
, class, type
);
2125 /* XParseGeometry copied from w32xfns.c */
2128 * XParseGeometry parses strings of the form
2129 * "=<width>x<height>{+-}<xoffset>{+-}<yoffset>", where
2130 * width, height, xoffset, and yoffset are unsigned integers.
2131 * Example: "=80x24+300-49"
2132 * The equal sign is optional.
2133 * It returns a bitmask that indicates which of the four values
2134 * were actually found in the string. For each value found,
2135 * the corresponding argument is updated; for each value
2136 * not found, the corresponding argument is left unchanged.
2140 read_integer (string
, NextString
)
2141 register char *string
;
2144 register int Result
= 0;
2149 else if (*string
== '-')
2154 for (; (*string
>= '0') && (*string
<= '9'); string
++)
2156 Result
= (Result
* 10) + (*string
- '0');
2158 *NextString
= string
;
2166 XParseGeometry (string
, x
, y
, width
, height
)
2169 unsigned int *width
, *height
; /* RETURN */
2172 register char *strind
;
2173 unsigned int tempWidth
, tempHeight
;
2175 char *nextCharacter
;
2177 if ((string
== NULL
) || (*string
== '\0')) return (mask
);
2179 string
++; /* ignore possible '=' at beg of geometry spec */
2181 strind
= (char *)string
;
2182 if (*strind
!= '+' && *strind
!= '-' && *strind
!= 'x')
2184 tempWidth
= read_integer (strind
, &nextCharacter
);
2185 if (strind
== nextCharacter
)
2187 strind
= nextCharacter
;
2191 if (*strind
== 'x' || *strind
== 'X')
2194 tempHeight
= read_integer (strind
, &nextCharacter
);
2195 if (strind
== nextCharacter
)
2197 strind
= nextCharacter
;
2198 mask
|= HeightValue
;
2201 if ((*strind
== '+') || (*strind
== '-'))
2206 tempX
= -read_integer (strind
, &nextCharacter
);
2207 if (strind
== nextCharacter
)
2209 strind
= nextCharacter
;
2216 tempX
= read_integer (strind
, &nextCharacter
);
2217 if (strind
== nextCharacter
)
2219 strind
= nextCharacter
;
2222 if ((*strind
== '+') || (*strind
== '-'))
2227 tempY
= -read_integer (strind
, &nextCharacter
);
2228 if (strind
== nextCharacter
)
2230 strind
= nextCharacter
;
2237 tempY
= read_integer (strind
, &nextCharacter
);
2238 if (strind
== nextCharacter
)
2240 strind
= nextCharacter
;
2246 /* If strind isn't at the end of the string the it's an invalid
2247 geometry specification. */
2249 if (*strind
!= '\0') return (0);
2255 if (mask
& WidthValue
)
2257 if (mask
& HeightValue
)
2258 *height
= tempHeight
;
2263 /* Create and set up the Mac window for frame F. */
2265 extern OSErr
install_window_handler (WindowPtr
);
2275 SetRect (&r
, f
->left_pos
, f
->top_pos
,
2276 f
->left_pos
+ FRAME_PIXEL_WIDTH (f
),
2277 f
->top_pos
+ FRAME_PIXEL_HEIGHT (f
));
2278 #if TARGET_API_MAC_CARBON
2279 CreateNewWindow (kDocumentWindowClass
,
2280 kWindowStandardDocumentAttributes
2281 /* | kWindowToolbarButtonAttribute */,
2282 &r
, &FRAME_MAC_WINDOW (f
));
2283 if (FRAME_MAC_WINDOW (f
))
2285 SetWRefCon (FRAME_MAC_WINDOW (f
), (long) f
->output_data
.mac
);
2286 if (install_window_handler (FRAME_MAC_WINDOW (f
)) != noErr
)
2288 DisposeWindow (FRAME_MAC_WINDOW (f
));
2289 FRAME_MAC_WINDOW (f
) = NULL
;
2293 FRAME_MAC_WINDOW (f
)
2294 = NewCWindow (NULL
, &r
, "\p", false, zoomDocProc
,
2295 (WindowPtr
) -1, 1, (long) f
->output_data
.mac
);
2297 /* so that update events can find this mac_output struct */
2298 f
->output_data
.mac
->mFP
= f
; /* point back to emacs frame */
2300 validate_x_resource_name ();
2302 /* x_set_name normally ignores requests to set the name if the
2303 requested name is the same as the current name. This is the one
2304 place where that assumption isn't correct; f->name is set, but
2305 the server hasn't been told. */
2308 int explicit = f
->explicit_name
;
2310 f
->explicit_name
= 0;
2313 x_set_name (f
, name
, explicit);
2318 if (FRAME_MAC_WINDOW (f
) == 0)
2319 error ("Unable to create window");
2322 /* Handle the icon stuff for this window. Perhaps later we might
2323 want an x_set_icon_position which can be called interactively as
2331 Lisp_Object icon_x
, icon_y
;
2333 /* Set the position of the icon. Note that Windows 95 groups all
2334 icons in the tray. */
2335 icon_x
= mac_get_arg (parms
, Qicon_left
, 0, 0, RES_TYPE_NUMBER
);
2336 icon_y
= mac_get_arg (parms
, Qicon_top
, 0, 0, RES_TYPE_NUMBER
);
2337 if (!EQ (icon_x
, Qunbound
) && !EQ (icon_y
, Qunbound
))
2339 CHECK_NUMBER (icon_x
);
2340 CHECK_NUMBER (icon_y
);
2342 else if (!EQ (icon_x
, Qunbound
) || !EQ (icon_y
, Qunbound
))
2343 error ("Both left and top icon corners of icon must be specified");
2347 if (! EQ (icon_x
, Qunbound
))
2348 x_wm_set_icon_position (f
, XINT (icon_x
), XINT (icon_y
));
2351 /* Start up iconic or window? */
2352 x_wm_set_window_state
2353 (f
, (EQ (w32_get_arg (parms
, Qvisibility
, 0, 0, RES_TYPE_SYMBOL
), Qicon
)
2357 x_text_icon (f
, (char *) SDATA ((!NILP (f
->icon_name
)
2370 XGCValues gc_values
;
2374 /* Create the GCs of this frame.
2375 Note that many default values are used. */
2378 gc_values
.font
= FRAME_FONT (f
);
2379 gc_values
.foreground
= FRAME_FOREGROUND_PIXEL (f
);
2380 gc_values
.background
= FRAME_BACKGROUND_PIXEL (f
);
2381 f
->output_data
.mac
->normal_gc
= XCreateGC (FRAME_MAC_DISPLAY (f
),
2382 FRAME_MAC_WINDOW (f
),
2383 GCFont
| GCForeground
| GCBackground
,
2386 /* Reverse video style. */
2387 gc_values
.foreground
= FRAME_BACKGROUND_PIXEL (f
);
2388 gc_values
.background
= FRAME_FOREGROUND_PIXEL (f
);
2389 f
->output_data
.mac
->reverse_gc
= XCreateGC (FRAME_MAC_DISPLAY (f
),
2390 FRAME_MAC_WINDOW (f
),
2391 GCFont
| GCForeground
| GCBackground
,
2394 /* Cursor has cursor-color background, background-color foreground. */
2395 gc_values
.foreground
= FRAME_BACKGROUND_PIXEL (f
);
2396 gc_values
.background
= f
->output_data
.mac
->cursor_pixel
;
2397 f
->output_data
.mac
->cursor_gc
= XCreateGC (FRAME_MAC_DISPLAY (f
),
2398 FRAME_MAC_WINDOW (f
),
2399 GCFont
| GCForeground
| GCBackground
,
2403 f
->output_data
.mac
->white_relief
.gc
= 0;
2404 f
->output_data
.mac
->black_relief
.gc
= 0;
2407 /* Create the gray border tile used when the pointer is not in
2408 the frame. Since this depends on the frame's pixel values,
2409 this must be done on a per-frame basis. */
2410 f
->output_data
.x
->border_tile
2411 = (XCreatePixmapFromBitmapData
2412 (FRAME_X_DISPLAY (f
), FRAME_X_DISPLAY_INFO (f
)->root_window
,
2413 gray_bits
, gray_width
, gray_height
,
2414 f
->output_data
.x
->foreground_pixel
,
2415 f
->output_data
.x
->background_pixel
,
2416 DefaultDepth (FRAME_X_DISPLAY (f
), FRAME_X_SCREEN_NUMBER (f
))));
2423 /* Free what was was allocated in x_make_gc. */
2429 Display
*dpy
= FRAME_MAC_DISPLAY (f
);
2433 if (f
->output_data
.mac
->normal_gc
)
2435 XFreeGC (dpy
, f
->output_data
.mac
->normal_gc
);
2436 f
->output_data
.mac
->normal_gc
= 0;
2439 if (f
->output_data
.mac
->reverse_gc
)
2441 XFreeGC (dpy
, f
->output_data
.mac
->reverse_gc
);
2442 f
->output_data
.mac
->reverse_gc
= 0;
2445 if (f
->output_data
.mac
->cursor_gc
)
2447 XFreeGC (dpy
, f
->output_data
.mac
->cursor_gc
);
2448 f
->output_data
.mac
->cursor_gc
= 0;
2452 if (f
->output_data
.mac
->border_tile
)
2454 XFreePixmap (dpy
, f
->output_data
.mac
->border_tile
);
2455 f
->output_data
.mac
->border_tile
= 0;
2459 if (f
->output_data
.mac
->white_relief
.gc
)
2461 XFreeGC (dpy
, f
->output_data
.mac
->white_relief
.gc
);
2462 f
->output_data
.mac
->white_relief
.gc
= 0;
2465 if (f
->output_data
.mac
->black_relief
.gc
)
2467 XFreeGC (dpy
, f
->output_data
.mac
->black_relief
.gc
);
2468 f
->output_data
.mac
->black_relief
.gc
= 0;
2475 /* Handler for signals raised during x_create_frame and
2476 x_create_top_frame. FRAME is the frame which is partially
2480 unwind_create_frame (frame
)
2483 struct frame
*f
= XFRAME (frame
);
2485 /* If frame is ``official'', nothing to do. */
2486 if (!CONSP (Vframe_list
) || !EQ (XCAR (Vframe_list
), frame
))
2489 struct x_display_info
*dpyinfo
= FRAME_X_DISPLAY_INFO (f
);
2492 x_free_frame_resources (f
);
2494 /* Check that reference counts are indeed correct. */
2495 xassert (dpyinfo
->reference_count
== dpyinfo_refcount
);
2496 xassert (dpyinfo
->image_cache
->refcount
== image_cache_refcount
);
2504 DEFUN ("x-create-frame", Fx_create_frame
, Sx_create_frame
,
2506 doc
: /* Make a new window, which is called a \"frame\" in Emacs terms.
2507 Returns an Emacs frame object.
2508 ALIST is an alist of frame parameters.
2509 If the parameters specify that the frame should not have a minibuffer,
2510 and do not specify a specific minibuffer window to use,
2511 then `default-minibuffer-frame' must be a frame whose minibuffer can
2512 be shared by the new frame.
2514 This function is an internal primitive--use `make-frame' instead. */)
2519 Lisp_Object frame
, tem
;
2521 int minibuffer_only
= 0;
2522 long window_prompting
= 0;
2524 int count
= SPECPDL_INDEX ();
2525 struct gcpro gcpro1
, gcpro2
, gcpro3
, gcpro4
;
2526 Lisp_Object display
;
2527 struct mac_display_info
*dpyinfo
= NULL
;
2530 char x_frame_name
[10];
2531 static int x_frame_count
= 2; /* begins at 2 because terminal frame is F1 */
2535 /* Use this general default value to start with
2536 until we know if this frame has a specified name. */
2537 Vx_resource_name
= Vinvocation_name
;
2539 display
= mac_get_arg (parms
, Qdisplay
, 0, 0, RES_TYPE_STRING
);
2540 if (EQ (display
, Qunbound
))
2542 dpyinfo
= check_x_display_info (display
);
2544 kb
= dpyinfo
->kboard
;
2546 kb
= &the_only_kboard
;
2549 name
= mac_get_arg (parms
, Qname
, "name", "Name", RES_TYPE_STRING
);
2551 && ! EQ (name
, Qunbound
)
2553 error ("Invalid frame name--not a string or nil");
2556 Vx_resource_name
= name
;
2558 /* See if parent window is specified. */
2559 parent
= mac_get_arg (parms
, Qparent_id
, NULL
, NULL
, RES_TYPE_NUMBER
);
2560 if (EQ (parent
, Qunbound
))
2562 if (! NILP (parent
))
2563 CHECK_NUMBER (parent
);
2565 /* make_frame_without_minibuffer can run Lisp code and garbage collect. */
2566 /* No need to protect DISPLAY because that's not used after passing
2567 it to make_frame_without_minibuffer. */
2569 GCPRO4 (parms
, parent
, name
, frame
);
2570 tem
= mac_get_arg (parms
, Qminibuffer
, "minibuffer", "Minibuffer",
2572 if (EQ (tem
, Qnone
) || NILP (tem
))
2573 f
= make_frame_without_minibuffer (Qnil
, kb
, display
);
2574 else if (EQ (tem
, Qonly
))
2576 f
= make_minibuffer_frame ();
2577 minibuffer_only
= 1;
2579 else if (WINDOWP (tem
))
2580 f
= make_frame_without_minibuffer (tem
, kb
, display
);
2584 if (EQ (name
, Qunbound
) || NILP (name
))
2586 sprintf (x_frame_name
, "F%d", x_frame_count
++);
2587 f
->name
= build_string (x_frame_name
);
2588 f
->explicit_name
= 0;
2593 f
->explicit_name
= 1;
2596 XSETFRAME (frame
, f
);
2598 /* Note that X Windows does support scroll bars. */
2599 FRAME_CAN_HAVE_SCROLL_BARS (f
) = 1;
2601 f
->output_method
= output_mac
;
2602 f
->output_data
.mac
= (struct mac_output
*) xmalloc (sizeof (struct mac_output
));
2603 bzero (f
->output_data
.mac
, sizeof (struct mac_output
));
2604 FRAME_FONTSET (f
) = -1;
2605 record_unwind_protect (unwind_create_frame
, frame
);
2608 = mac_get_arg (parms
, Qicon_name
, "iconName", "Title", RES_TYPE_STRING
);
2609 if (! STRINGP (f
->icon_name
))
2610 f
->icon_name
= Qnil
;
2612 /* FRAME_W32_DISPLAY_INFO (f) = dpyinfo; */
2614 FRAME_KBOARD (f
) = kb
;
2617 /* Specify the parent under which to make this window. */
2621 f
->output_data
.mac
->parent_desc
= (Window
) XFASTINT (parent
);
2622 f
->output_data
.mac
->explicit_parent
= 1;
2626 f
->output_data
.mac
->parent_desc
= FRAME_MAC_DISPLAY_INFO (f
)->root_window
;
2627 f
->output_data
.mac
->explicit_parent
= 0;
2630 /* Set the name; the functions to which we pass f expect the name to
2632 if (EQ (name
, Qunbound
) || NILP (name
))
2634 f
->name
= build_string (dpyinfo
->mac_id_name
);
2635 f
->explicit_name
= 0;
2640 f
->explicit_name
= 1;
2641 /* use the frame's title when getting resources for this frame. */
2642 specbind (Qx_resource_name
, name
);
2645 /* Extract the window parameters from the supplied values
2646 that are needed to determine window geometry. */
2650 font
= mac_get_arg (parms
, Qfont
, "font", "Font", RES_TYPE_STRING
);
2653 /* First, try whatever font the caller has specified. */
2656 tem
= Fquery_fontset (font
, Qnil
);
2658 font
= x_new_fontset (f
, SDATA (tem
));
2660 font
= x_new_font (f
, SDATA (font
));
2663 /* Try out a font which we hope has bold and italic variations. */
2664 if (! STRINGP (font
))
2665 font
= x_new_font (f
, "-ETL-fixed-medium-r-*--*-160-*-*-*-*-iso8859-1");
2666 /* If those didn't work, look for something which will at least work. */
2667 if (! STRINGP (font
))
2668 font
= x_new_font (f
, "-*-monaco-*-12-*-mac-roman");
2669 if (! STRINGP (font
))
2670 font
= x_new_font (f
, "-*-courier-*-10-*-mac-roman");
2671 if (! STRINGP (font
))
2672 error ("Cannot find any usable font");
2675 x_default_parameter (f
, parms
, Qfont
, font
,
2676 "font", "Font", RES_TYPE_STRING
);
2679 x_default_parameter (f
, parms
, Qborder_width
, make_number (0),
2680 "borderwidth", "BorderWidth", RES_TYPE_NUMBER
);
2681 /* This defaults to 2 in order to match xterm. We recognize either
2682 internalBorderWidth or internalBorder (which is what xterm calls
2684 if (NILP (Fassq (Qinternal_border_width
, parms
)))
2688 value
= mac_get_arg (parms
, Qinternal_border_width
,
2689 "internalBorder", "InternalBorder", RES_TYPE_NUMBER
);
2690 if (! EQ (value
, Qunbound
))
2691 parms
= Fcons (Fcons (Qinternal_border_width
, value
),
2694 /* Default internalBorderWidth to 0 on Windows to match other programs. */
2695 x_default_parameter (f
, parms
, Qinternal_border_width
, make_number (0),
2696 "internalBorderWidth", "InternalBorder", RES_TYPE_NUMBER
);
2697 x_default_parameter (f
, parms
, Qvertical_scroll_bars
, Qright
,
2698 "verticalScrollBars", "ScrollBars", RES_TYPE_SYMBOL
);
2700 /* Also do the stuff which must be set before the window exists. */
2701 x_default_parameter (f
, parms
, Qforeground_color
, build_string ("black"),
2702 "foreground", "Foreground", RES_TYPE_STRING
);
2703 x_default_parameter (f
, parms
, Qbackground_color
, build_string ("white"),
2704 "background", "Background", RES_TYPE_STRING
);
2705 x_default_parameter (f
, parms
, Qmouse_color
, build_string ("black"),
2706 "pointerColor", "Foreground", RES_TYPE_STRING
);
2707 x_default_parameter (f
, parms
, Qcursor_color
, build_string ("black"),
2708 "cursorColor", "Foreground", RES_TYPE_STRING
);
2709 x_default_parameter (f
, parms
, Qborder_color
, build_string ("black"),
2710 "borderColor", "BorderColor", RES_TYPE_STRING
);
2711 x_default_parameter (f
, parms
, Qscreen_gamma
, Qnil
,
2712 "screenGamma", "ScreenGamma", RES_TYPE_FLOAT
);
2713 x_default_parameter (f
, parms
, Qline_spacing
, Qnil
,
2714 "lineSpacing", "LineSpacing", RES_TYPE_NUMBER
);
2715 x_default_parameter (f
, parms
, Qleft_fringe
, Qnil
,
2716 "leftFringe", "LeftFringe", RES_TYPE_NUMBER
);
2717 x_default_parameter (f
, parms
, Qright_fringe
, Qnil
,
2718 "rightFringe", "RightFringe", RES_TYPE_NUMBER
);
2721 /* Init faces before x_default_parameter is called for scroll-bar
2722 parameters because that function calls x_set_scroll_bar_width,
2723 which calls change_frame_size, which calls Fset_window_buffer,
2724 which runs hooks, which call Fvertical_motion. At the end, we
2725 end up in init_iterator with a null face cache, which should not
2727 init_frame_faces (f
);
2729 x_default_parameter (f
, parms
, Qmenu_bar_lines
, make_number (1),
2730 "menuBar", "MenuBar", RES_TYPE_NUMBER
);
2731 x_default_parameter (f
, parms
, Qtool_bar_lines
, make_number (1),
2732 "toolBar", "ToolBar", RES_TYPE_NUMBER
);
2733 x_default_parameter (f
, parms
, Qbuffer_predicate
, Qnil
,
2734 "bufferPredicate", "BufferPredicate", RES_TYPE_SYMBOL
);
2735 x_default_parameter (f
, parms
, Qtitle
, Qnil
,
2736 "title", "Title", RES_TYPE_STRING
);
2737 x_default_parameter (f
, parms
, Qfullscreen
, Qnil
,
2738 "fullscreen", "Fullscreen", RES_TYPE_SYMBOL
);
2740 f
->output_data
.mac
->parent_desc
= FRAME_MAC_DISPLAY_INFO (f
)->root_window
;
2742 #if TARGET_API_MAC_CARBON
2743 f
->output_data
.mac
->text_cursor
= kThemeIBeamCursor
;
2744 f
->output_data
.mac
->nontext_cursor
= kThemeArrowCursor
;
2745 f
->output_data
.mac
->modeline_cursor
= kThemeArrowCursor
;
2746 f
->output_data
.mac
->hand_cursor
= kThemePointingHandCursor
;
2747 f
->output_data
.mac
->hourglass_cursor
= kThemeWatchCursor
;
2748 f
->output_data
.mac
->horizontal_drag_cursor
= kThemeResizeLeftRightCursor
;
2750 f
->output_data
.mac
->text_cursor
= GetCursor (iBeamCursor
);
2751 f
->output_data
.mac
->nontext_cursor
= &arrow_cursor
;
2752 f
->output_data
.mac
->modeline_cursor
= &arrow_cursor
;
2753 f
->output_data
.mac
->hand_cursor
= &arrow_cursor
;
2754 f
->output_data
.mac
->hourglass_cursor
= GetCursor (watchCursor
);
2755 f
->output_data
.mac
->horizontal_drag_cursor
= &arrow_cursor
;
2758 /* Compute the size of the window. */
2759 window_prompting
= x_figure_window_size (f
, parms
, 1);
2761 tem
= mac_get_arg (parms
, Qunsplittable
, 0, 0, RES_TYPE_BOOLEAN
);
2762 f
->no_split
= minibuffer_only
|| EQ (tem
, Qt
);
2769 /* Now consider the frame official. */
2770 FRAME_MAC_DISPLAY_INFO (f
)->reference_count
++;
2771 Vframe_list
= Fcons (frame
, Vframe_list
);
2773 /* We need to do this after creating the window, so that the
2774 icon-creation functions can say whose icon they're describing. */
2775 x_default_parameter (f
, parms
, Qicon_type
, Qnil
,
2776 "bitmapIcon", "BitmapIcon", RES_TYPE_SYMBOL
);
2778 x_default_parameter (f
, parms
, Qauto_raise
, Qnil
,
2779 "autoRaise", "AutoRaiseLower", RES_TYPE_BOOLEAN
);
2780 x_default_parameter (f
, parms
, Qauto_lower
, Qnil
,
2781 "autoLower", "AutoRaiseLower", RES_TYPE_BOOLEAN
);
2782 x_default_parameter (f
, parms
, Qcursor_type
, Qbox
,
2783 "cursorType", "CursorType", RES_TYPE_SYMBOL
);
2784 x_default_parameter (f
, parms
, Qscroll_bar_width
, Qnil
,
2785 "scrollBarWidth", "ScrollBarWidth",
2788 /* Dimensions, especially FRAME_LINES (f), must be done via change_frame_size.
2789 Change will not be effected unless different from the current
2791 width
= FRAME_COLS (f
);
2792 height
= FRAME_LINES (f
);
2794 SET_FRAME_COLS (f
, 0);
2795 FRAME_LINES (f
) = 0;
2796 change_frame_size (f
, height
, width
, 1, 0, 0);
2798 /* Tell the server what size and position, etc, we want, and how
2799 badly we want them. This should be done after we have the menu
2800 bar so that its size can be taken into account. */
2802 x_wm_set_size_hint (f
, window_prompting
, 0);
2805 /* Make the window appear on the frame and enable display, unless
2806 the caller says not to. However, with explicit parent, Emacs
2807 cannot control visibility, so don't try. */
2808 if (! f
->output_data
.mac
->explicit_parent
)
2810 Lisp_Object visibility
;
2812 visibility
= mac_get_arg (parms
, Qvisibility
, 0, 0, RES_TYPE_SYMBOL
);
2813 if (EQ (visibility
, Qunbound
))
2816 #if 0 /* MAC_TODO: really no iconify on Mac */
2817 if (EQ (visibility
, Qicon
))
2818 x_iconify_frame (f
);
2821 if (! NILP (visibility
))
2822 x_make_frame_visible (f
);
2824 /* Must have been Qnil. */
2829 /* Make sure windows on this frame appear in calls to next-window
2830 and similar functions. */
2831 Vwindow_list
= Qnil
;
2833 return unbind_to (count
, frame
);
2836 /* FRAME is used only to get a handle on the X display. We don't pass the
2837 display info directly because we're called from frame.c, which doesn't
2838 know about that structure. */
2840 x_get_focus_frame (frame
)
2841 struct frame
*frame
;
2843 struct mac_display_info
*dpyinfo
= FRAME_MAC_DISPLAY_INFO (frame
);
2845 if (! dpyinfo
->x_focus_frame
)
2848 XSETFRAME (xfocus
, dpyinfo
->x_focus_frame
);
2852 DEFUN ("xw-color-defined-p", Fxw_color_defined_p
, Sxw_color_defined_p
, 1, 2, 0,
2853 doc
: /* Internal function called by `color-defined-p', which see. */)
2855 Lisp_Object color
, frame
;
2858 FRAME_PTR f
= check_x_frame (frame
);
2860 CHECK_STRING (color
);
2862 if (mac_defined_color (f
, SDATA (color
), &foo
, 0))
2868 DEFUN ("xw-color-values", Fxw_color_values
, Sxw_color_values
, 1, 2, 0,
2869 doc
: /* Internal function called by `color-values', which see. */)
2871 Lisp_Object color
, frame
;
2874 FRAME_PTR f
= check_x_frame (frame
);
2876 CHECK_STRING (color
);
2878 if (mac_defined_color (f
, SDATA (color
), &foo
, 0))
2882 rgb
[0] = make_number (foo
.red
);
2883 rgb
[1] = make_number (foo
.green
);
2884 rgb
[2] = make_number (foo
.blue
);
2885 return Flist (3, rgb
);
2891 DEFUN ("xw-display-color-p", Fxw_display_color_p
, Sxw_display_color_p
, 0, 1, 0,
2892 doc
: /* Internal function called by `display-color-p', which see. */)
2894 Lisp_Object display
;
2896 struct mac_display_info
*dpyinfo
= check_x_display_info (display
);
2898 if (!dpyinfo
->color_p
)
2904 DEFUN ("x-display-grayscale-p", Fx_display_grayscale_p
, Sx_display_grayscale_p
,
2906 doc
: /* Return t if the X display supports shades of gray.
2907 Note that color displays do support shades of gray.
2908 The optional argument DISPLAY specifies which display to ask about.
2909 DISPLAY should be either a frame or a display name (a string).
2910 If omitted or nil, that stands for the selected frame's display. */)
2912 Lisp_Object display
;
2914 struct mac_display_info
*dpyinfo
= check_x_display_info (display
);
2916 if (dpyinfo
->n_planes
<= 1)
2922 DEFUN ("x-display-pixel-width", Fx_display_pixel_width
, Sx_display_pixel_width
,
2924 doc
: /* Returns the width in pixels of the X display DISPLAY.
2925 The optional argument DISPLAY specifies which display to ask about.
2926 DISPLAY should be either a frame or a display name (a string).
2927 If omitted or nil, that stands for the selected frame's display. */)
2929 Lisp_Object display
;
2931 struct mac_display_info
*dpyinfo
= check_x_display_info (display
);
2933 return make_number (dpyinfo
->width
);
2936 DEFUN ("x-display-pixel-height", Fx_display_pixel_height
,
2937 Sx_display_pixel_height
, 0, 1, 0,
2938 doc
: /* Returns the height in pixels of the X display DISPLAY.
2939 The optional argument DISPLAY specifies which display to ask about.
2940 DISPLAY should be either a frame or a display name (a string).
2941 If omitted or nil, that stands for the selected frame's display. */)
2943 Lisp_Object display
;
2945 struct mac_display_info
*dpyinfo
= check_x_display_info (display
);
2947 return make_number (dpyinfo
->height
);
2950 DEFUN ("x-display-planes", Fx_display_planes
, Sx_display_planes
,
2952 doc
: /* Returns the number of bitplanes of the display DISPLAY.
2953 The optional argument DISPLAY specifies which display to ask about.
2954 DISPLAY should be either a frame or a display name (a string).
2955 If omitted or nil, that stands for the selected frame's display. */)
2957 Lisp_Object display
;
2959 struct mac_display_info
*dpyinfo
= check_x_display_info (display
);
2961 return make_number (dpyinfo
->n_planes
);
2964 DEFUN ("x-display-color-cells", Fx_display_color_cells
, Sx_display_color_cells
,
2966 doc
: /* Returns the number of color cells of the display DISPLAY.
2967 The optional argument DISPLAY specifies which display to ask about.
2968 DISPLAY should be either a frame or a display name (a string).
2969 If omitted or nil, that stands for the selected frame's display. */)
2971 Lisp_Object display
;
2973 struct mac_display_info
*dpyinfo
= check_x_display_info (display
);
2975 /* We force 24+ bit depths to 24-bit to prevent an overflow. */
2976 return make_number (1 << min (dpyinfo
->n_planes
, 24));
2979 DEFUN ("x-server-max-request-size", Fx_server_max_request_size
,
2980 Sx_server_max_request_size
,
2982 doc
: /* Returns the maximum request size of the server of display DISPLAY.
2983 The optional argument DISPLAY specifies which display to ask about.
2984 DISPLAY should be either a frame or a display name (a string).
2985 If omitted or nil, that stands for the selected frame's display. */)
2987 Lisp_Object display
;
2989 struct mac_display_info
*dpyinfo
= check_x_display_info (display
);
2991 return make_number (1);
2994 DEFUN ("x-server-vendor", Fx_server_vendor
, Sx_server_vendor
, 0, 1, 0,
2995 doc
: /* Returns the vendor ID string of the Mac OS system (Apple).
2996 The optional argument DISPLAY specifies which display to ask about.
2997 DISPLAY should be either a frame or a display name (a string).
2998 If omitted or nil, that stands for the selected frame's display. */)
3000 Lisp_Object display
;
3002 return build_string ("Apple Computers");
3005 DEFUN ("x-server-version", Fx_server_version
, Sx_server_version
, 0, 1, 0,
3006 doc
: /* Returns the version numbers of the server of display DISPLAY.
3007 The value is a list of three integers: the major and minor
3008 version numbers, and the vendor-specific release
3009 number. See also the function `x-server-vendor'.
3011 The optional argument DISPLAY specifies which display to ask about.
3012 DISPLAY should be either a frame or a display name (a string).
3013 If omitted or nil, that stands for the selected frame's display. */)
3015 Lisp_Object display
;
3017 int mac_major_version
;
3020 if (Gestalt (gestaltSystemVersion
, &response
) != noErr
)
3021 error ("Cannot get Mac OS version");
3023 mac_major_version
= (response
>> 8) & 0xff;
3024 /* convert BCD to int */
3025 mac_major_version
-= (mac_major_version
>> 4) * 6;
3027 return Fcons (make_number (mac_major_version
),
3028 Fcons (make_number ((response
>> 4) & 0xf),
3029 Fcons (make_number (response
& 0xf),
3033 DEFUN ("x-display-screens", Fx_display_screens
, Sx_display_screens
, 0, 1, 0,
3034 doc
: /* Return the number of screens on the server of display DISPLAY.
3035 The optional argument DISPLAY specifies which display to ask about.
3036 DISPLAY should be either a frame or a display name (a string).
3037 If omitted or nil, that stands for the selected frame's display. */)
3039 Lisp_Object display
;
3041 return make_number (1);
3044 DEFUN ("x-display-mm-height", Fx_display_mm_height
, Sx_display_mm_height
, 0, 1, 0,
3045 doc
: /* Return the height in millimeters of the X display DISPLAY.
3046 The optional argument DISPLAY specifies which display to ask about.
3047 DISPLAY should be either a frame or a display name (a string).
3048 If omitted or nil, that stands for the selected frame's display. */)
3050 Lisp_Object display
;
3052 /* MAC_TODO: this is an approximation, and only of the main display */
3054 struct mac_display_info
*dpyinfo
= check_x_display_info (display
);
3056 return make_number ((int) (dpyinfo
->height
* 25.4 / dpyinfo
->resy
));
3059 DEFUN ("x-display-mm-width", Fx_display_mm_width
, Sx_display_mm_width
, 0, 1, 0,
3060 doc
: /* Return the width in millimeters of the X display DISPLAY.
3061 The optional argument DISPLAY specifies which display to ask about.
3062 DISPLAY should be either a frame or a display name (a string).
3063 If omitted or nil, that stands for the selected frame's display. */)
3065 Lisp_Object display
;
3067 /* MAC_TODO: this is an approximation, and only of the main display */
3069 struct mac_display_info
*dpyinfo
= check_x_display_info (display
);
3071 return make_number ((int) (dpyinfo
->width
* 25.4 / dpyinfo
->resx
));
3074 DEFUN ("x-display-backing-store", Fx_display_backing_store
,
3075 Sx_display_backing_store
, 0, 1, 0,
3076 doc
: /* Returns an indication of whether display DISPLAY does backing store.
3077 The value may be `always', `when-mapped', or `not-useful'.
3078 The optional argument DISPLAY specifies which display to ask about.
3079 DISPLAY should be either a frame or a display name (a string).
3080 If omitted or nil, that stands for the selected frame's display. */)
3082 Lisp_Object display
;
3084 return intern ("not-useful");
3087 DEFUN ("x-display-visual-class", Fx_display_visual_class
,
3088 Sx_display_visual_class
, 0, 1, 0,
3089 doc
: /* Returns the visual class of the display DISPLAY.
3090 The value is one of the symbols `static-gray', `gray-scale',
3091 `static-color', `pseudo-color', `true-color', or `direct-color'.
3093 The optional argument DISPLAY specifies which display to ask about.
3094 DISPLAY should be either a frame or a display name (a string).
3095 If omitted or nil, that stands for the selected frame's display. */)
3097 Lisp_Object display
;
3099 struct mac_display_info
*dpyinfo
= check_x_display_info (display
);
3102 switch (dpyinfo
->visual
->class)
3104 case StaticGray
: return (intern ("static-gray"));
3105 case GrayScale
: return (intern ("gray-scale"));
3106 case StaticColor
: return (intern ("static-color"));
3107 case PseudoColor
: return (intern ("pseudo-color"));
3108 case TrueColor
: return (intern ("true-color"));
3109 case DirectColor
: return (intern ("direct-color"));
3111 error ("Display has an unknown visual class");
3115 return (intern ("true-color"));
3118 DEFUN ("x-display-save-under", Fx_display_save_under
,
3119 Sx_display_save_under
, 0, 1, 0,
3120 doc
: /* Returns t if the display DISPLAY supports the save-under feature.
3121 The optional argument DISPLAY specifies which display to ask about.
3122 DISPLAY should be either a frame or a display name (a string).
3123 If omitted or nil, that stands for the selected frame's display. */)
3125 Lisp_Object display
;
3132 register struct frame
*f
;
3134 return FRAME_PIXEL_WIDTH (f
);
3139 register struct frame
*f
;
3141 return FRAME_PIXEL_HEIGHT (f
);
3146 register struct frame
*f
;
3148 return FRAME_COLUMN_WIDTH (f
);
3153 register struct frame
*f
;
3155 return FRAME_LINE_HEIGHT (f
);
3160 register struct frame
*f
;
3162 return FRAME_MAC_DISPLAY_INFO (f
)->n_planes
;
3165 /* Return the display structure for the display named NAME.
3166 Open a new connection if necessary. */
3168 struct mac_display_info
*
3169 x_display_info_for_name (name
)
3173 struct mac_display_info
*dpyinfo
;
3175 CHECK_STRING (name
);
3177 if (! EQ (Vwindow_system
, intern ("mac")))
3178 error ("Not using Mac native windows");
3180 for (dpyinfo
= &one_mac_display_info
, names
= x_display_name_list
;
3182 dpyinfo
= dpyinfo
->next
, names
= XCDR (names
))
3185 tem
= Fstring_equal (XCAR (XCAR (names
)), name
);
3190 /* Use this general default value to start with. */
3191 Vx_resource_name
= Vinvocation_name
;
3193 validate_x_resource_name ();
3195 dpyinfo
= mac_term_init (name
, (unsigned char *) 0,
3196 (char *) SDATA (Vx_resource_name
));
3199 error ("Cannot connect to server %s", SDATA (name
));
3202 XSETFASTINT (Vwindow_system_version
, 3);
3207 DEFUN ("x-open-connection", Fx_open_connection
, Sx_open_connection
,
3209 doc
: /* Open a connection to a server.
3210 DISPLAY is the name of the display to connect to.
3211 Optional second arg XRM-STRING is a string of resources in xrdb format.
3212 If the optional third arg MUST-SUCCEED is non-nil,
3213 terminate Emacs if we can't open the connection. */)
3214 (display
, xrm_string
, must_succeed
)
3215 Lisp_Object display
, xrm_string
, must_succeed
;
3217 unsigned char *xrm_option
;
3218 struct mac_display_info
*dpyinfo
;
3220 CHECK_STRING (display
);
3221 if (! NILP (xrm_string
))
3222 CHECK_STRING (xrm_string
);
3224 if (! EQ (Vwindow_system
, intern ("mac")))
3225 error ("Not using Mac native windows");
3227 if (! NILP (xrm_string
))
3228 xrm_option
= (unsigned char *) SDATA (xrm_string
);
3230 xrm_option
= (unsigned char *) 0;
3232 validate_x_resource_name ();
3234 /* This is what opens the connection and sets x_current_display.
3235 This also initializes many symbols, such as those used for input. */
3236 dpyinfo
= mac_term_init (display
, xrm_option
,
3237 (char *) SDATA (Vx_resource_name
));
3241 if (!NILP (must_succeed
))
3242 fatal ("Cannot connect to server %s.\n",
3245 error ("Cannot connect to server %s", SDATA (display
));
3250 XSETFASTINT (Vwindow_system_version
, 3);
3254 DEFUN ("x-close-connection", Fx_close_connection
,
3255 Sx_close_connection
, 1, 1, 0,
3256 doc
: /* Close the connection to DISPLAY's server.
3257 For DISPLAY, specify either a frame or a display name (a string).
3258 If DISPLAY is nil, that stands for the selected frame's display. */)
3260 Lisp_Object display
;
3262 struct mac_display_info
*dpyinfo
= check_x_display_info (display
);
3265 if (dpyinfo
->reference_count
> 0)
3266 error ("Display still has frames on it");
3269 /* Free the fonts in the font table. */
3270 for (i
= 0; i
< dpyinfo
->n_fonts
; i
++)
3271 if (dpyinfo
->font_table
[i
].name
)
3273 mac_unload_font (dpyinfo
, dpyinfo
->font_table
[i
].font
);
3276 x_destroy_all_bitmaps (dpyinfo
);
3278 x_delete_display (dpyinfo
);
3284 DEFUN ("x-display-list", Fx_display_list
, Sx_display_list
, 0, 0, 0,
3285 doc
: /* Return the list of display names that Emacs has connections to. */)
3288 Lisp_Object tail
, result
;
3291 for (tail
= x_display_name_list
; ! NILP (tail
); tail
= XCDR (tail
))
3292 result
= Fcons (XCAR (XCAR (tail
)), result
);
3297 DEFUN ("x-synchronize", Fx_synchronize
, Sx_synchronize
, 1, 2, 0,
3298 doc
: /* If ON is non-nil, report errors as soon as the erring request is made.
3299 If ON is nil, allow buffering of requests.
3300 This is a noop on Mac OS systems.
3301 The optional second argument DISPLAY specifies which display to act on.
3302 DISPLAY should be either a frame or a display name (a string).
3303 If DISPLAY is omitted or nil, that stands for the selected frame's display. */)
3305 Lisp_Object display
, on
;
3311 /***********************************************************************
3313 ***********************************************************************/
3315 DEFUN ("x-change-window-property", Fx_change_window_property
,
3316 Sx_change_window_property
, 2, 6, 0,
3317 doc
: /* Change window property PROP to VALUE on the X window of FRAME.
3318 VALUE may be a string or a list of conses, numbers and/or strings.
3319 If an element in the list is a string, it is converted to
3320 an Atom and the value of the Atom is used. If an element is a cons,
3321 it is converted to a 32 bit number where the car is the 16 top bits and the
3322 cdr is the lower 16 bits.
3323 FRAME nil or omitted means use the selected frame.
3324 If TYPE is given and non-nil, it is the name of the type of VALUE.
3325 If TYPE is not given or nil, the type is STRING.
3326 FORMAT gives the size in bits of each element if VALUE is a list.
3327 It must be one of 8, 16 or 32.
3328 If VALUE is a string or FORMAT is nil or not given, FORMAT defaults to 8.
3329 If OUTER_P is non-nil, the property is changed for the outer X window of
3330 FRAME. Default is to change on the edit X window.
3333 (prop
, value
, frame
, type
, format
, outer_p
)
3334 Lisp_Object prop
, value
, frame
, type
, format
, outer_p
;
3336 #if 0 /* MAC_TODO : port window properties to Mac */
3337 struct frame
*f
= check_x_frame (frame
);
3340 CHECK_STRING (prop
);
3341 CHECK_STRING (value
);
3344 prop_atom
= XInternAtom (FRAME_W32_DISPLAY (f
), SDATA (prop
), False
);
3345 XChangeProperty (FRAME_W32_DISPLAY (f
), FRAME_W32_WINDOW (f
),
3346 prop_atom
, XA_STRING
, 8, PropModeReplace
,
3347 SDATA (value
), SCHARS (value
));
3349 /* Make sure the property is set when we return. */
3350 XFlush (FRAME_W32_DISPLAY (f
));
3353 #endif /* MAC_TODO */
3359 DEFUN ("x-delete-window-property", Fx_delete_window_property
,
3360 Sx_delete_window_property
, 1, 2, 0,
3361 doc
: /* Remove window property PROP from X window of FRAME.
3362 FRAME nil or omitted means use the selected frame. Value is PROP. */)
3364 Lisp_Object prop
, frame
;
3366 #if 0 /* MAC_TODO : port window properties to Mac */
3368 struct frame
*f
= check_x_frame (frame
);
3371 CHECK_STRING (prop
);
3373 prop_atom
= XInternAtom (FRAME_W32_DISPLAY (f
), SDATA (prop
), False
);
3374 XDeleteProperty (FRAME_W32_DISPLAY (f
), FRAME_W32_WINDOW (f
), prop_atom
);
3376 /* Make sure the property is removed when we return. */
3377 XFlush (FRAME_W32_DISPLAY (f
));
3379 #endif /* MAC_TODO */
3385 DEFUN ("x-window-property", Fx_window_property
, Sx_window_property
,
3387 doc
: /* Value is the value of window property PROP on FRAME.
3388 If FRAME is nil or omitted, use the selected frame. Value is nil
3389 if FRAME hasn't a property with name PROP or if PROP has no string
3392 Lisp_Object prop
, frame
;
3394 #if 0 /* MAC_TODO : port window properties to Mac */
3396 struct frame
*f
= check_x_frame (frame
);
3399 Lisp_Object prop_value
= Qnil
;
3400 char *tmp_data
= NULL
;
3403 unsigned long actual_size
, bytes_remaining
;
3405 CHECK_STRING (prop
);
3407 prop_atom
= XInternAtom (FRAME_W32_DISPLAY (f
), SDATA (prop
), False
);
3408 rc
= XGetWindowProperty (FRAME_W32_DISPLAY (f
), FRAME_W32_WINDOW (f
),
3409 prop_atom
, 0, 0, False
, XA_STRING
,
3410 &actual_type
, &actual_format
, &actual_size
,
3411 &bytes_remaining
, (unsigned char **) &tmp_data
);
3414 int size
= bytes_remaining
;
3419 rc
= XGetWindowProperty (FRAME_W32_DISPLAY (f
), FRAME_W32_WINDOW (f
),
3420 prop_atom
, 0, bytes_remaining
,
3422 &actual_type
, &actual_format
,
3423 &actual_size
, &bytes_remaining
,
3424 (unsigned char **) &tmp_data
);
3426 prop_value
= make_string (tmp_data
, size
);
3435 #endif /* MAC_TODO */
3441 /***********************************************************************
3443 ***********************************************************************/
3445 /* If non-null, an asynchronous timer that, when it expires, displays
3446 an hourglass cursor on all frames. */
3448 static struct atimer
*hourglass_atimer
;
3450 /* Non-zero means an hourglass cursor is currently shown. */
3452 static int hourglass_shown_p
;
3454 /* Number of seconds to wait before displaying an hourglass cursor. */
3456 static Lisp_Object Vhourglass_delay
;
3458 /* Default number of seconds to wait before displaying an hourglass
3461 #define DEFAULT_HOURGLASS_DELAY 1
3463 /* Function prototypes. */
3465 static void show_hourglass
P_ ((struct atimer
*));
3466 static void hide_hourglass
P_ ((void));
3469 /* Cancel a currently active hourglass timer, and start a new one. */
3474 #if 0 /* MAC_TODO: cursor shape changes. */
3476 int secs
, usecs
= 0;
3478 cancel_hourglass ();
3480 if (INTEGERP (Vhourglass_delay
)
3481 && XINT (Vhourglass_delay
) > 0)
3482 secs
= XFASTINT (Vhourglass_delay
);
3483 else if (FLOATP (Vhourglass_delay
)
3484 && XFLOAT_DATA (Vhourglass_delay
) > 0)
3487 tem
= Ftruncate (Vhourglass_delay
, Qnil
);
3488 secs
= XFASTINT (tem
);
3489 usecs
= (XFLOAT_DATA (Vhourglass_delay
) - secs
) * 1000000;
3492 secs
= DEFAULT_HOURGLASS_DELAY
;
3494 EMACS_SET_SECS_USECS (delay
, secs
, usecs
);
3495 hourglass_atimer
= start_atimer (ATIMER_RELATIVE
, delay
,
3496 show_hourglass
, NULL
);
3497 #endif /* MAC_TODO */
3501 /* Cancel the hourglass cursor timer if active, hide an hourglass
3507 if (hourglass_atimer
)
3509 cancel_atimer (hourglass_atimer
);
3510 hourglass_atimer
= NULL
;
3513 if (hourglass_shown_p
)
3518 /* Timer function of hourglass_atimer. TIMER is equal to
3521 Display an hourglass cursor on all frames by mapping the frames'
3522 hourglass_window. Set the hourglass_p flag in the frames'
3523 output_data.x structure to indicate that an hourglass cursor is
3524 shown on the frames. */
3527 show_hourglass (timer
)
3528 struct atimer
*timer
;
3530 #if 0 /* MAC_TODO: cursor shape changes. */
3531 /* The timer implementation will cancel this timer automatically
3532 after this function has run. Set hourglass_atimer to null
3533 so that we know the timer doesn't have to be canceled. */
3534 hourglass_atimer
= NULL
;
3536 if (!hourglass_shown_p
)
3538 Lisp_Object rest
, frame
;
3542 FOR_EACH_FRAME (rest
, frame
)
3543 if (FRAME_W32_P (XFRAME (frame
)))
3545 struct frame
*f
= XFRAME (frame
);
3547 f
->output_data
.w32
->hourglass_p
= 1;
3549 if (!f
->output_data
.w32
->hourglass_window
)
3551 unsigned long mask
= CWCursor
;
3552 XSetWindowAttributes attrs
;
3554 attrs
.cursor
= f
->output_data
.w32
->hourglass_cursor
;
3556 f
->output_data
.w32
->hourglass_window
3557 = XCreateWindow (FRAME_X_DISPLAY (f
),
3558 FRAME_OUTER_WINDOW (f
),
3559 0, 0, 32000, 32000, 0, 0,
3565 XMapRaised (FRAME_X_DISPLAY (f
),
3566 f
->output_data
.w32
->hourglass_window
);
3567 XFlush (FRAME_X_DISPLAY (f
));
3570 hourglass_shown_p
= 1;
3573 #endif /* MAC_TODO */
3577 /* Hide the hourglass cursor on all frames, if it is currently shown. */
3582 #if 0 /* MAC_TODO: cursor shape changes. */
3583 if (hourglass_shown_p
)
3585 Lisp_Object rest
, frame
;
3588 FOR_EACH_FRAME (rest
, frame
)
3590 struct frame
*f
= XFRAME (frame
);
3593 /* Watch out for newly created frames. */
3594 && f
->output_data
.x
->hourglass_window
)
3596 XUnmapWindow (FRAME_X_DISPLAY (f
),
3597 f
->output_data
.x
->hourglass_window
);
3598 /* Sync here because XTread_socket looks at the
3599 hourglass_p flag that is reset to zero below. */
3600 XSync (FRAME_X_DISPLAY (f
), False
);
3601 f
->output_data
.x
->hourglass_p
= 0;
3605 hourglass_shown_p
= 0;
3608 #endif /* MAC_TODO */
3613 /***********************************************************************
3615 ***********************************************************************/
3617 static Lisp_Object x_create_tip_frame
P_ ((struct mac_display_info
*,
3618 Lisp_Object
, Lisp_Object
));
3619 static void compute_tip_xy
P_ ((struct frame
*, Lisp_Object
, Lisp_Object
,
3620 Lisp_Object
, int, int, int *, int *));
3622 /* The frame of a currently visible tooltip. */
3624 Lisp_Object tip_frame
;
3626 /* If non-nil, a timer started that hides the last tooltip when it
3629 Lisp_Object tip_timer
;
3632 /* If non-nil, a vector of 3 elements containing the last args
3633 with which x-show-tip was called. See there. */
3635 Lisp_Object last_show_tip_args
;
3637 /* Maximum size for tooltips; a cons (COLUMNS . ROWS). */
3639 Lisp_Object Vx_max_tooltip_size
;
3643 unwind_create_tip_frame (frame
)
3646 Lisp_Object deleted
;
3648 deleted
= unwind_create_frame (frame
);
3649 if (EQ (deleted
, Qt
))
3659 /* Create a frame for a tooltip on the display described by DPYINFO.
3660 PARMS is a list of frame parameters. TEXT is the string to
3661 display in the tip frame. Value is the frame.
3663 Note that functions called here, esp. x_default_parameter can
3664 signal errors, for instance when a specified color name is
3665 undefined. We have to make sure that we're in a consistent state
3666 when this happens. */
3669 x_create_tip_frame (dpyinfo
, parms
, text
)
3670 struct mac_display_info
*dpyinfo
;
3671 Lisp_Object parms
, text
;
3674 Lisp_Object frame
, tem
;
3676 long window_prompting
= 0;
3678 int count
= SPECPDL_INDEX ();
3679 struct gcpro gcpro1
, gcpro2
, gcpro3
;
3681 int face_change_count_before
= face_change_count
;
3683 struct buffer
*old_buffer
;
3687 /* Use this general default value to start with until we know if
3688 this frame has a specified name. */
3689 Vx_resource_name
= Vinvocation_name
;
3692 kb
= dpyinfo
->kboard
;
3694 kb
= &the_only_kboard
;
3697 /* Get the name of the frame to use for resource lookup. */
3698 name
= mac_get_arg (parms
, Qname
, "name", "Name", RES_TYPE_STRING
);
3700 && !EQ (name
, Qunbound
)
3702 error ("Invalid frame name--not a string or nil");
3703 Vx_resource_name
= name
;
3706 GCPRO3 (parms
, name
, frame
);
3708 XSETFRAME (frame
, f
);
3710 buffer
= Fget_buffer_create (build_string (" *tip*"));
3711 Fset_window_buffer (FRAME_ROOT_WINDOW (f
), buffer
, Qnil
);
3712 old_buffer
= current_buffer
;
3713 set_buffer_internal_1 (XBUFFER (buffer
));
3714 current_buffer
->truncate_lines
= Qnil
;
3715 specbind (Qinhibit_read_only
, Qt
);
3716 specbind (Qinhibit_modification_hooks
, Qt
);
3719 set_buffer_internal_1 (old_buffer
);
3721 FRAME_CAN_HAVE_SCROLL_BARS (f
) = 0;
3722 record_unwind_protect (unwind_create_tip_frame
, frame
);
3724 /* By setting the output method, we're essentially saying that
3725 the frame is live, as per FRAME_LIVE_P. If we get a signal
3726 from this point on, x_destroy_window might screw up reference
3728 f
->output_method
= output_mac
;
3729 f
->output_data
.mac
=
3730 (struct mac_output
*) xmalloc (sizeof (struct mac_output
));
3731 bzero (f
->output_data
.mac
, sizeof (struct mac_output
));
3733 FRAME_FONTSET (f
) = -1;
3734 f
->icon_name
= Qnil
;
3736 #if 0 /* GLYPH_DEBUG TODO: image support. */
3737 image_cache_refcount
= FRAME_X_IMAGE_CACHE (f
)->refcount
;
3738 dpyinfo_refcount
= dpyinfo
->reference_count
;
3739 #endif /* GLYPH_DEBUG */
3741 FRAME_KBOARD (f
) = kb
;
3743 f
->output_data
.mac
->parent_desc
= FRAME_MAC_DISPLAY_INFO (f
)->root_window
;
3744 f
->output_data
.mac
->explicit_parent
= 0;
3746 /* Set the name; the functions to which we pass f expect the name to
3748 if (EQ (name
, Qunbound
) || NILP (name
))
3750 f
->name
= build_string (dpyinfo
->mac_id_name
);
3751 f
->explicit_name
= 0;
3756 f
->explicit_name
= 1;
3757 /* use the frame's title when getting resources for this frame. */
3758 specbind (Qx_resource_name
, name
);
3761 /* Extract the window parameters from the supplied values that are
3762 needed to determine window geometry. */
3766 font
= mac_get_arg (parms
, Qfont
, "font", "Font", RES_TYPE_STRING
);
3769 /* First, try whatever font the caller has specified. */
3772 tem
= Fquery_fontset (font
, Qnil
);
3774 font
= x_new_fontset (f
, SDATA (tem
));
3776 font
= x_new_font (f
, SDATA (font
));
3779 /* Try out a font which we hope has bold and italic variations. */
3780 if (! STRINGP (font
))
3781 font
= x_new_font (f
, "-ETL-fixed-medium-r-*--*-160-*-*-*-*-iso8859-1");
3782 /* If those didn't work, look for something which will at least work. */
3783 if (! STRINGP (font
))
3784 font
= x_new_font (f
, "-*-monaco-*-12-*-mac-roman");
3785 if (! STRINGP (font
))
3786 font
= x_new_font (f
, "-*-courier-*-10-*-mac-roman");
3788 if (! STRINGP (font
))
3789 error ("Cannot find any usable font");
3791 x_default_parameter (f
, parms
, Qfont
, font
,
3792 "font", "Font", RES_TYPE_STRING
);
3795 x_default_parameter (f
, parms
, Qborder_width
, make_number (2),
3796 "borderWidth", "BorderWidth", RES_TYPE_NUMBER
);
3798 /* This defaults to 2 in order to match xterm. We recognize either
3799 internalBorderWidth or internalBorder (which is what xterm calls
3801 if (NILP (Fassq (Qinternal_border_width
, parms
)))
3805 value
= mac_get_arg (parms
, Qinternal_border_width
,
3806 "internalBorder", "internalBorder", RES_TYPE_NUMBER
);
3807 if (! EQ (value
, Qunbound
))
3808 parms
= Fcons (Fcons (Qinternal_border_width
, value
),
3812 x_default_parameter (f
, parms
, Qinternal_border_width
, make_number (1),
3813 "internalBorderWidth", "internalBorderWidth",
3816 /* Also do the stuff which must be set before the window exists. */
3817 x_default_parameter (f
, parms
, Qforeground_color
, build_string ("black"),
3818 "foreground", "Foreground", RES_TYPE_STRING
);
3819 x_default_parameter (f
, parms
, Qbackground_color
, build_string ("white"),
3820 "background", "Background", RES_TYPE_STRING
);
3821 x_default_parameter (f
, parms
, Qmouse_color
, build_string ("black"),
3822 "pointerColor", "Foreground", RES_TYPE_STRING
);
3823 x_default_parameter (f
, parms
, Qcursor_color
, build_string ("black"),
3824 "cursorColor", "Foreground", RES_TYPE_STRING
);
3825 x_default_parameter (f
, parms
, Qborder_color
, build_string ("black"),
3826 "borderColor", "BorderColor", RES_TYPE_STRING
);
3828 /* Init faces before x_default_parameter is called for scroll-bar
3829 parameters because that function calls x_set_scroll_bar_width,
3830 which calls change_frame_size, which calls Fset_window_buffer,
3831 which runs hooks, which call Fvertical_motion. At the end, we
3832 end up in init_iterator with a null face cache, which should not
3834 init_frame_faces (f
);
3836 f
->output_data
.mac
->parent_desc
= FRAME_MAC_DISPLAY_INFO (f
)->root_window
;
3838 window_prompting
= x_figure_window_size (f
, parms
, 0);
3844 SetRect (&r
, 0, 0, 1, 1);
3845 #if TARGET_API_MAC_CARBON
3846 if (CreateNewWindow (kHelpWindowClass
,
3847 #ifdef MAC_OS_X_VERSION_10_2
3848 kWindowIgnoreClicksAttribute
|
3850 kWindowNoUpdatesAttribute
|
3851 kWindowNoActivatesAttribute
,
3852 &r
, &tip_window
) == noErr
)
3854 if (tip_window
= NewCWindow (NULL
, &r
, "\p", false, plainDBox
,
3858 FRAME_MAC_WINDOW (f
) = tip_window
;
3859 SetWRefCon (tip_window
, (long) f
->output_data
.mac
);
3860 /* so that update events can find this mac_output struct */
3861 f
->output_data
.mac
->mFP
= f
;
3868 x_default_parameter (f
, parms
, Qauto_raise
, Qnil
,
3869 "autoRaise", "AutoRaiseLower", RES_TYPE_BOOLEAN
);
3870 x_default_parameter (f
, parms
, Qauto_lower
, Qnil
,
3871 "autoLower", "AutoRaiseLower", RES_TYPE_BOOLEAN
);
3872 x_default_parameter (f
, parms
, Qcursor_type
, Qbox
,
3873 "cursorType", "CursorType", RES_TYPE_SYMBOL
);
3875 /* Dimensions, especially FRAME_LINES (f), must be done via change_frame_size.
3876 Change will not be effected unless different from the current
3878 width
= FRAME_COLS (f
);
3879 height
= FRAME_LINES (f
);
3880 SET_FRAME_COLS (f
, 0);
3881 FRAME_LINES (f
) = 0;
3882 change_frame_size (f
, height
, width
, 1, 0, 0);
3884 /* Add `tooltip' frame parameter's default value. */
3885 if (NILP (Fframe_parameter (frame
, intern ("tooltip"))))
3886 Fmodify_frame_parameters (frame
, Fcons (Fcons (intern ("tooltip"), Qt
),
3889 /* Set up faces after all frame parameters are known. This call
3890 also merges in face attributes specified for new frames.
3892 Frame parameters may be changed if .Xdefaults contains
3893 specifications for the default font. For example, if there is an
3894 `Emacs.default.attributeBackground: pink', the `background-color'
3895 attribute of the frame get's set, which let's the internal border
3896 of the tooltip frame appear in pink. Prevent this. */
3898 Lisp_Object bg
= Fframe_parameter (frame
, Qbackground_color
);
3900 /* Set tip_frame here, so that */
3902 call1 (Qface_set_after_frame_default
, frame
);
3904 if (!EQ (bg
, Fframe_parameter (frame
, Qbackground_color
)))
3905 Fmodify_frame_parameters (frame
, Fcons (Fcons (Qbackground_color
, bg
),
3913 /* It is now ok to make the frame official even if we get an error
3914 below. And the frame needs to be on Vframe_list or making it
3915 visible won't work. */
3916 Vframe_list
= Fcons (frame
, Vframe_list
);
3918 /* Now that the frame is official, it counts as a reference to
3920 FRAME_MAC_DISPLAY_INFO (f
)->reference_count
++;
3922 /* Setting attributes of faces of the tooltip frame from resources
3923 and similar will increment face_change_count, which leads to the
3924 clearing of all current matrices. Since this isn't necessary
3925 here, avoid it by resetting face_change_count to the value it
3926 had before we created the tip frame. */
3927 face_change_count
= face_change_count_before
;
3929 /* Discard the unwind_protect. */
3930 return unbind_to (count
, frame
);
3934 /* Compute where to display tip frame F. PARMS is the list of frame
3935 parameters for F. DX and DY are specified offsets from the current
3936 location of the mouse. WIDTH and HEIGHT are the width and height
3937 of the tooltip. Return coordinates relative to the root window of
3938 the display in *ROOT_X, and *ROOT_Y. */
3941 compute_tip_xy (f
, parms
, dx
, dy
, width
, height
, root_x
, root_y
)
3943 Lisp_Object parms
, dx
, dy
;
3945 int *root_x
, *root_y
;
3947 Lisp_Object left
, top
;
3949 /* User-specified position? */
3950 left
= Fcdr (Fassq (Qleft
, parms
));
3951 top
= Fcdr (Fassq (Qtop
, parms
));
3953 /* Move the tooltip window where the mouse pointer is. Resize and
3955 if (!INTEGERP (left
) || !INTEGERP (top
))
3960 GetMouse (&mouse_pos
);
3961 LocalToGlobal (&mouse_pos
);
3962 *root_x
= mouse_pos
.h
;
3963 *root_y
= mouse_pos
.v
;
3968 *root_y
= XINT (top
);
3969 else if (*root_y
+ XINT (dy
) - height
< 0)
3970 *root_y
-= XINT (dy
);
3974 *root_y
+= XINT (dy
);
3977 if (INTEGERP (left
))
3978 *root_x
= XINT (left
);
3979 else if (*root_x
+ XINT (dx
) + width
<= FRAME_MAC_DISPLAY_INFO (f
)->width
)
3980 /* It fits to the right of the pointer. */
3981 *root_x
+= XINT (dx
);
3982 else if (width
+ XINT (dx
) <= *root_x
)
3983 /* It fits to the left of the pointer. */
3984 *root_x
-= width
+ XINT (dx
);
3986 /* Put it left-justified on the screen -- it ought to fit that way. */
3991 DEFUN ("x-show-tip", Fx_show_tip
, Sx_show_tip
, 1, 6, 0,
3992 doc
: /* Show STRING in a "tooltip" window on frame FRAME.
3993 A tooltip window is a small X window displaying a string.
3995 FRAME nil or omitted means use the selected frame.
3997 PARMS is an optional list of frame parameters which can be used to
3998 change the tooltip's appearance.
4000 Automatically hide the tooltip after TIMEOUT seconds. TIMEOUT nil
4001 means use the default timeout of 5 seconds.
4003 If the list of frame parameters PARAMS contains a `left' parameters,
4004 the tooltip is displayed at that x-position. Otherwise it is
4005 displayed at the mouse position, with offset DX added (default is 5 if
4006 DX isn't specified). Likewise for the y-position; if a `top' frame
4007 parameter is specified, it determines the y-position of the tooltip
4008 window, otherwise it is displayed at the mouse position, with offset
4009 DY added (default is -10).
4011 A tooltip's maximum size is specified by `x-max-tooltip-size'.
4012 Text larger than the specified size is clipped. */)
4013 (string
, frame
, parms
, timeout
, dx
, dy
)
4014 Lisp_Object string
, frame
, parms
, timeout
, dx
, dy
;
4019 struct buffer
*old_buffer
;
4020 struct text_pos pos
;
4021 int i
, width
, height
;
4022 struct gcpro gcpro1
, gcpro2
, gcpro3
, gcpro4
;
4023 int old_windows_or_buffers_changed
= windows_or_buffers_changed
;
4024 int count
= SPECPDL_INDEX ();
4026 specbind (Qinhibit_redisplay
, Qt
);
4028 GCPRO4 (string
, parms
, frame
, timeout
);
4030 CHECK_STRING (string
);
4031 f
= check_x_frame (frame
);
4033 timeout
= make_number (5);
4035 CHECK_NATNUM (timeout
);
4038 dx
= make_number (5);
4043 dy
= make_number (-10);
4047 if (NILP (last_show_tip_args
))
4048 last_show_tip_args
= Fmake_vector (make_number (3), Qnil
);
4050 if (!NILP (tip_frame
))
4052 Lisp_Object last_string
= AREF (last_show_tip_args
, 0);
4053 Lisp_Object last_frame
= AREF (last_show_tip_args
, 1);
4054 Lisp_Object last_parms
= AREF (last_show_tip_args
, 2);
4056 if (EQ (frame
, last_frame
)
4057 && !NILP (Fequal (last_string
, string
))
4058 && !NILP (Fequal (last_parms
, parms
)))
4060 struct frame
*f
= XFRAME (tip_frame
);
4062 /* Only DX and DY have changed. */
4063 if (!NILP (tip_timer
))
4065 Lisp_Object timer
= tip_timer
;
4067 call1 (Qcancel_timer
, timer
);
4071 compute_tip_xy (f
, parms
, dx
, dy
, FRAME_PIXEL_WIDTH (f
),
4072 FRAME_PIXEL_HEIGHT (f
), &root_x
, &root_y
);
4073 MoveWindow (FRAME_MAC_WINDOW (f
), root_x
, root_y
, false);
4079 /* Hide a previous tip, if any. */
4082 ASET (last_show_tip_args
, 0, string
);
4083 ASET (last_show_tip_args
, 1, frame
);
4084 ASET (last_show_tip_args
, 2, parms
);
4086 /* Add default values to frame parameters. */
4087 if (NILP (Fassq (Qname
, parms
)))
4088 parms
= Fcons (Fcons (Qname
, build_string ("tooltip")), parms
);
4089 if (NILP (Fassq (Qinternal_border_width
, parms
)))
4090 parms
= Fcons (Fcons (Qinternal_border_width
, make_number (3)), parms
);
4091 if (NILP (Fassq (Qborder_width
, parms
)))
4092 parms
= Fcons (Fcons (Qborder_width
, make_number (1)), parms
);
4093 if (NILP (Fassq (Qborder_color
, parms
)))
4094 parms
= Fcons (Fcons (Qborder_color
, build_string ("lightyellow")), parms
);
4095 if (NILP (Fassq (Qbackground_color
, parms
)))
4096 parms
= Fcons (Fcons (Qbackground_color
, build_string ("lightyellow")),
4099 /* Create a frame for the tooltip, and record it in the global
4100 variable tip_frame. */
4101 frame
= x_create_tip_frame (FRAME_MAC_DISPLAY_INFO (f
), parms
, string
);
4104 /* Set up the frame's root window. */
4105 w
= XWINDOW (FRAME_ROOT_WINDOW (f
));
4106 w
->left_col
= w
->top_line
= make_number (0);
4108 if (CONSP (Vx_max_tooltip_size
)
4109 && INTEGERP (XCAR (Vx_max_tooltip_size
))
4110 && XINT (XCAR (Vx_max_tooltip_size
)) > 0
4111 && INTEGERP (XCDR (Vx_max_tooltip_size
))
4112 && XINT (XCDR (Vx_max_tooltip_size
)) > 0)
4114 w
->total_cols
= XCAR (Vx_max_tooltip_size
);
4115 w
->total_lines
= XCDR (Vx_max_tooltip_size
);
4119 w
->total_cols
= make_number (80);
4120 w
->total_lines
= make_number (40);
4123 FRAME_TOTAL_COLS (f
) = XINT (w
->total_cols
);
4125 w
->pseudo_window_p
= 1;
4127 /* Display the tooltip text in a temporary buffer. */
4128 old_buffer
= current_buffer
;
4129 set_buffer_internal_1 (XBUFFER (XWINDOW (FRAME_ROOT_WINDOW (f
))->buffer
));
4130 current_buffer
->truncate_lines
= Qnil
;
4131 clear_glyph_matrix (w
->desired_matrix
);
4132 clear_glyph_matrix (w
->current_matrix
);
4133 SET_TEXT_POS (pos
, BEGV
, BEGV_BYTE
);
4134 try_window (FRAME_ROOT_WINDOW (f
), pos
);
4136 /* Compute width and height of the tooltip. */
4138 for (i
= 0; i
< w
->desired_matrix
->nrows
; ++i
)
4140 struct glyph_row
*row
= &w
->desired_matrix
->rows
[i
];
4144 /* Stop at the first empty row at the end. */
4145 if (!row
->enabled_p
|| !row
->displays_text_p
)
4148 /* Let the row go over the full width of the frame. */
4149 row
->full_width_p
= 1;
4151 /* There's a glyph at the end of rows that is used to place
4152 the cursor there. Don't include the width of this glyph. */
4153 if (row
->used
[TEXT_AREA
])
4155 last
= &row
->glyphs
[TEXT_AREA
][row
->used
[TEXT_AREA
] - 1];
4156 row_width
= row
->pixel_width
- last
->pixel_width
;
4159 row_width
= row
->pixel_width
;
4161 height
+= row
->height
;
4162 width
= max (width
, row_width
);
4165 /* Add the frame's internal border to the width and height the X
4166 window should have. */
4167 height
+= 2 * FRAME_INTERNAL_BORDER_WIDTH (f
);
4168 width
+= 2 * FRAME_INTERNAL_BORDER_WIDTH (f
);
4170 /* Move the tooltip window where the mouse pointer is. Resize and
4172 compute_tip_xy (f
, parms
, dx
, dy
, width
, height
, &root_x
, &root_y
);
4175 MoveWindow (FRAME_MAC_WINDOW (f
), root_x
, root_y
, false);
4176 SizeWindow (FRAME_MAC_WINDOW (f
), width
, height
, true);
4177 ShowWindow (FRAME_MAC_WINDOW (f
));
4178 BringToFront (FRAME_MAC_WINDOW (f
));
4181 /* Draw into the window. */
4182 w
->must_be_updated_p
= 1;
4183 update_single_window (w
, 1);
4185 /* Restore original current buffer. */
4186 set_buffer_internal_1 (old_buffer
);
4187 windows_or_buffers_changed
= old_windows_or_buffers_changed
;
4190 /* Let the tip disappear after timeout seconds. */
4191 tip_timer
= call3 (intern ("run-at-time"), timeout
, Qnil
,
4192 intern ("x-hide-tip"));
4195 return unbind_to (count
, Qnil
);
4199 DEFUN ("x-hide-tip", Fx_hide_tip
, Sx_hide_tip
, 0, 0, 0,
4200 doc
: /* Hide the current tooltip window, if there is any.
4201 Value is t if tooltip was open, nil otherwise. */)
4205 Lisp_Object deleted
, frame
, timer
;
4206 struct gcpro gcpro1
, gcpro2
;
4208 /* Return quickly if nothing to do. */
4209 if (NILP (tip_timer
) && NILP (tip_frame
))
4214 GCPRO2 (frame
, timer
);
4215 tip_frame
= tip_timer
= deleted
= Qnil
;
4217 count
= SPECPDL_INDEX ();
4218 specbind (Qinhibit_redisplay
, Qt
);
4219 specbind (Qinhibit_quit
, Qt
);
4222 call1 (Qcancel_timer
, timer
);
4226 Fdelete_frame (frame
, Qnil
);
4231 return unbind_to (count
, deleted
);
4236 #if TARGET_API_MAC_CARBON
4237 /***********************************************************************
4238 File selection dialog
4239 ***********************************************************************/
4241 static pascal void mac_nav_event_callback
P_ ((NavEventCallbackMessage
,
4242 NavCBRecPtr
, void *));
4245 There is a relatively standard way to do this using applescript to run
4246 a (choose file) method. However, this doesn't do "the right thing"
4247 by working only if the find-file occurred during a menu or toolbar
4248 click. So we must do the file dialog by hand, using the navigation
4249 manager. This also has more flexibility in determining the default
4250 directory and whether or not we are going to choose a file.
4253 extern Lisp_Object Qfile_name_history
;
4255 DEFUN ("x-file-dialog", Fx_file_dialog
, Sx_file_dialog
, 2, 5, 0,
4256 doc
: /* Read file name, prompting with PROMPT in directory DIR.
4257 Use a file selection dialog.
4258 Select DEFAULT-FILENAME in the dialog's file selection box, if
4259 specified. Ensure that file exists if MUSTMATCH is non-nil.
4260 If ONLY-DIR-P is non-nil, the user can only select directories. */)
4261 (prompt
, dir
, default_filename
, mustmatch
, only_dir_p
)
4262 Lisp_Object prompt
, dir
, default_filename
, mustmatch
, only_dir_p
;
4264 struct frame
*f
= SELECTED_FRAME ();
4265 Lisp_Object file
= Qnil
;
4266 int count
= SPECPDL_INDEX ();
4267 struct gcpro gcpro1
, gcpro2
, gcpro3
, gcpro4
, gcpro5
, gcpro6
;
4268 char filename
[MAXPATHLEN
];
4269 int default_filter_index
= 1; /* 1: All Files, 2: Directories only */
4270 static NavEventUPP mac_nav_event_callbackUPP
= NULL
;
4272 GCPRO6 (prompt
, dir
, default_filename
, mustmatch
, file
, only_dir_p
);
4273 CHECK_STRING (prompt
);
4276 /* Create the dialog with PROMPT as title, using DIR as initial
4277 directory and using "*" as pattern. */
4278 dir
= Fexpand_file_name (dir
, Qnil
);
4282 NavDialogCreationOptions options
;
4283 NavDialogRef dialogRef
;
4284 NavTypeListHandle fileTypes
= NULL
;
4285 NavUserAction userAction
;
4286 CFStringRef message
=NULL
, saveName
= NULL
;
4289 /* No need for a callback function because we are modal */
4290 NavGetDefaultDialogCreationOptions(&options
);
4291 options
.modality
= kWindowModalityAppModal
;
4292 options
.location
.h
= options
.location
.v
= -1;
4293 options
.optionFlags
= kNavDefaultNavDlogOptions
;
4294 options
.optionFlags
|= kNavAllFilesInPopup
; /* All files allowed */
4295 options
.optionFlags
|= kNavSelectAllReadableItem
;
4299 cfstring_create_with_utf8_cstring (SDATA (ENCODE_UTF_8 (prompt
)));
4300 options
.message
= message
;
4302 /* Don't set the application, let it use default.
4303 options.clientName = CFSTR ("Emacs");
4306 if (mac_nav_event_callbackUPP
== NULL
)
4307 mac_nav_event_callbackUPP
= NewNavEventUPP (mac_nav_event_callback
);
4309 if (!NILP (only_dir_p
))
4310 status
= NavCreateChooseFolderDialog(&options
, mac_nav_event_callbackUPP
,
4311 NULL
, NULL
, &dialogRef
);
4312 else if (NILP (mustmatch
))
4314 /* This is a save dialog */
4315 options
.optionFlags
|= kNavDontConfirmReplacement
;
4316 options
.actionButtonLabel
= CFSTR ("Ok");
4317 options
.windowTitle
= CFSTR ("Enter name");
4319 if (!NILP(default_filename
))
4322 cfstring_create_with_utf8_cstring (SDATA (ENCODE_UTF_8
4323 (default_filename
)));
4324 options
.saveFileName
= saveName
;
4325 options
.optionFlags
|= kNavSelectDefaultLocation
;
4327 status
= NavCreatePutFileDialog(&options
,
4328 'TEXT', kNavGenericSignature
,
4329 mac_nav_event_callbackUPP
, NULL
,
4334 /* This is an open dialog*/
4335 status
= NavCreateChooseFileDialog(&options
, fileTypes
,
4336 mac_nav_event_callbackUPP
, NULL
,
4337 NULL
, NULL
, &dialogRef
);
4340 /* Set the default location and continue*/
4341 if (status
== noErr
) {
4345 status
= FSPathMakeRef(SDATA(ENCODE_FILE(dir
)), &defLoc
, NULL
);
4346 if (status
== noErr
)
4348 AECreateDesc(typeFSRef
, &defLoc
, sizeof(FSRef
), &defLocAed
);
4349 NavCustomControl(dialogRef
, kNavCtlSetLocation
, (void*) &defLocAed
);
4350 AEDisposeDesc(&defLocAed
);
4354 status
= NavDialogRun(dialogRef
);
4357 if (saveName
) CFRelease(saveName
);
4358 if (message
) CFRelease(message
);
4360 if (status
== noErr
) {
4361 userAction
= NavDialogGetUserAction(dialogRef
);
4364 case kNavUserActionNone
:
4365 case kNavUserActionCancel
:
4366 break; /* Treat cancel like C-g */
4367 case kNavUserActionOpen
:
4368 case kNavUserActionChoose
:
4369 case kNavUserActionSaveAs
:
4371 NavReplyRecord reply
;
4374 status
= NavDialogGetReply(dialogRef
, &reply
);
4375 AECoerceDesc(&reply
.selection
, typeFSRef
, &aed
);
4376 AEGetDescData(&aed
, (void *) &fsRef
, sizeof (FSRef
));
4377 FSRefMakePath(&fsRef
, (UInt8
*) filename
, sizeof (filename
));
4378 AEDisposeDesc(&aed
);
4379 if (reply
.saveFileName
)
4381 /* If it was a saved file, we need to add the file name */
4382 int len
= strlen(filename
);
4383 if (len
&& filename
[len
-1] != '/')
4384 filename
[len
++] = '/';
4385 CFStringGetCString(reply
.saveFileName
, filename
+len
,
4386 sizeof (filename
) - len
,
4387 kCFStringEncodingUTF8
);
4389 file
= DECODE_FILE (make_unibyte_string (filename
,
4390 strlen (filename
)));
4391 NavDisposeReply(&reply
);
4395 NavDialogDispose(dialogRef
);
4398 /* Fall back on minibuffer if there was a problem */
4399 file
= Fcompleting_read (prompt
, intern ("read-file-name-internal"),
4400 dir
, mustmatch
, dir
, Qfile_name_history
,
4401 default_filename
, Qnil
);
4408 /* Make "Cancel" equivalent to C-g. */
4410 Fsignal (Qquit
, Qnil
);
4412 return unbind_to (count
, file
);
4416 /* Need to register some event callback function for enabling drag and
4417 drop in Navigation Service dialogs. */
4419 mac_nav_event_callback (selector
, parms
, data
)
4420 NavEventCallbackMessage selector
;
4427 /***********************************************************************
4429 ***********************************************************************/
4431 /* Keep this list in the same order as frame_parms in frame.c.
4432 Use 0 for unsupported frame parameters. */
4434 frame_parm_handler mac_frame_parm_handlers
[] =
4438 x_set_background_color
,
4444 x_set_foreground_color
,
4446 0, /* MAC_TODO: x_set_icon_type, */
4447 x_set_internal_border_width
,
4448 x_set_menu_bar_lines
,
4450 x_explicitly_set_name
,
4451 x_set_scroll_bar_width
,
4454 x_set_vertical_scroll_bars
,
4456 x_set_tool_bar_lines
,
4457 0, /* MAC_TODO: x_set_scroll_bar_foreground, */
4458 0, /* MAC_TODO: x_set_scroll_bar_background, */
4463 0, /* x_set_wait_for_wm, */
4471 /* This is zero if not using Mac native windows. */
4474 /* Certainly running on Mac native windows. */
4478 /* The section below is built by the lisp expression at the top of the file,
4479 just above where these variables are declared. */
4480 /*&&& init symbols here &&&*/
4481 Qnone
= intern ("none");
4483 Qsuppress_icon
= intern ("suppress-icon");
4484 staticpro (&Qsuppress_icon
);
4485 Qundefined_color
= intern ("undefined-color");
4486 staticpro (&Qundefined_color
);
4487 Qcancel_timer
= intern ("cancel-timer");
4488 staticpro (&Qcancel_timer
);
4490 Qhyper
= intern ("hyper");
4491 staticpro (&Qhyper
);
4492 Qsuper
= intern ("super");
4493 staticpro (&Qsuper
);
4494 Qmeta
= intern ("meta");
4496 Qalt
= intern ("alt");
4498 Qctrl
= intern ("ctrl");
4500 Qcontrol
= intern ("control");
4501 staticpro (&Qcontrol
);
4502 Qshift
= intern ("shift");
4503 staticpro (&Qshift
);
4504 /* This is the end of symbol initialization. */
4506 /* Text property `display' should be nonsticky by default. */
4507 Vtext_property_default_nonsticky
4508 = Fcons (Fcons (Qdisplay
, Qt
), Vtext_property_default_nonsticky
);
4510 Qface_set_after_frame_default
= intern ("face-set-after-frame-default");
4511 staticpro (&Qface_set_after_frame_default
);
4513 Fput (Qundefined_color
, Qerror_conditions
,
4514 Fcons (Qundefined_color
, Fcons (Qerror
, Qnil
)));
4515 Fput (Qundefined_color
, Qerror_message
,
4516 build_string ("Undefined color"));
4518 DEFVAR_LISP ("x-pointer-shape", &Vx_pointer_shape
,
4519 doc
: /* The shape of the pointer when over text.
4520 Changing the value does not affect existing frames
4521 unless you set the mouse color. */);
4522 Vx_pointer_shape
= Qnil
;
4524 Vx_nontext_pointer_shape
= Qnil
;
4526 Vx_mode_pointer_shape
= Qnil
;
4528 DEFVAR_LISP ("x-hourglass-pointer-shape", &Vx_hourglass_pointer_shape
,
4529 doc
: /* The shape of the pointer when Emacs is hourglass.
4530 This variable takes effect when you create a new frame
4531 or when you set the mouse color. */);
4532 Vx_hourglass_pointer_shape
= Qnil
;
4534 DEFVAR_BOOL ("display-hourglass", &display_hourglass_p
,
4535 doc
: /* Non-zero means Emacs displays an hourglass pointer on window systems. */);
4536 display_hourglass_p
= 1;
4538 DEFVAR_LISP ("hourglass-delay", &Vhourglass_delay
,
4539 doc
: /* *Seconds to wait before displaying an hourglass pointer.
4540 Value must be an integer or float. */);
4541 Vhourglass_delay
= make_number (DEFAULT_HOURGLASS_DELAY
);
4543 DEFVAR_LISP ("x-sensitive-text-pointer-shape",
4544 &Vx_sensitive_text_pointer_shape
,
4545 doc
: /* The shape of the pointer when over mouse-sensitive text.
4546 This variable takes effect when you create a new frame
4547 or when you set the mouse color. */);
4548 Vx_sensitive_text_pointer_shape
= Qnil
;
4550 DEFVAR_LISP ("x-cursor-fore-pixel", &Vx_cursor_fore_pixel
,
4551 doc
: /* A string indicating the foreground color of the cursor box. */);
4552 Vx_cursor_fore_pixel
= Qnil
;
4554 DEFVAR_LISP ("x-max-tooltip-size", &Vx_max_tooltip_size
,
4555 doc
: /* Maximum size for tooltips. Value is a pair (COLUMNS . ROWS).
4556 Text larger than this is clipped. */);
4557 Vx_max_tooltip_size
= Fcons (make_number (80), make_number (40));
4559 DEFVAR_LISP ("x-no-window-manager", &Vx_no_window_manager
,
4560 doc
: /* Non-nil if no window manager is in use.
4561 Emacs doesn't try to figure this out; this is always nil
4562 unless you set it to something else. */);
4563 /* We don't have any way to find this out, so set it to nil
4564 and maybe the user would like to set it to t. */
4565 Vx_no_window_manager
= Qnil
;
4567 DEFVAR_LISP ("x-pixel-size-width-font-regexp",
4568 &Vx_pixel_size_width_font_regexp
,
4569 doc
: /* Regexp matching a font name whose width is the same as `PIXEL_SIZE'.
4571 Since Emacs gets width of a font matching with this regexp from
4572 PIXEL_SIZE field of the name, font finding mechanism gets faster for
4573 such a font. This is especially effective for such large fonts as
4574 Chinese, Japanese, and Korean. */);
4575 Vx_pixel_size_width_font_regexp
= Qnil
;
4577 /* X window properties. */
4578 defsubr (&Sx_change_window_property
);
4579 defsubr (&Sx_delete_window_property
);
4580 defsubr (&Sx_window_property
);
4582 defsubr (&Sxw_display_color_p
);
4583 defsubr (&Sx_display_grayscale_p
);
4584 defsubr (&Sxw_color_defined_p
);
4585 defsubr (&Sxw_color_values
);
4586 defsubr (&Sx_server_max_request_size
);
4587 defsubr (&Sx_server_vendor
);
4588 defsubr (&Sx_server_version
);
4589 defsubr (&Sx_display_pixel_width
);
4590 defsubr (&Sx_display_pixel_height
);
4591 defsubr (&Sx_display_mm_width
);
4592 defsubr (&Sx_display_mm_height
);
4593 defsubr (&Sx_display_screens
);
4594 defsubr (&Sx_display_planes
);
4595 defsubr (&Sx_display_color_cells
);
4596 defsubr (&Sx_display_visual_class
);
4597 defsubr (&Sx_display_backing_store
);
4598 defsubr (&Sx_display_save_under
);
4599 defsubr (&Sx_create_frame
);
4600 defsubr (&Sx_open_connection
);
4601 defsubr (&Sx_close_connection
);
4602 defsubr (&Sx_display_list
);
4603 defsubr (&Sx_synchronize
);
4605 /* Setting callback functions for fontset handler. */
4606 get_font_info_func
= x_get_font_info
;
4608 #if 0 /* This function pointer doesn't seem to be used anywhere.
4609 And the pointer assigned has the wrong type, anyway. */
4610 list_fonts_func
= x_list_fonts
;
4613 load_font_func
= x_load_font
;
4614 find_ccl_program_func
= x_find_ccl_program
;
4615 query_font_func
= x_query_font
;
4616 set_frame_fontset_func
= x_set_font
;
4617 check_window_system_func
= check_mac
;
4619 hourglass_atimer
= NULL
;
4620 hourglass_shown_p
= 0;
4622 defsubr (&Sx_show_tip
);
4623 defsubr (&Sx_hide_tip
);
4625 staticpro (&tip_timer
);
4627 staticpro (&tip_frame
);
4629 last_show_tip_args
= Qnil
;
4630 staticpro (&last_show_tip_args
);
4632 #if TARGET_API_MAC_CARBON
4633 defsubr (&Sx_file_dialog
);
4637 /* arch-tag: d7591289-f374-4377-b245-12f5dbbb8edc
4638 (do not change this comment) */