1 /* Graphical user interface functions for Mac OS.
2 Copyright (C) 2000, 2001 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"
48 /* #include "bitmaps/gray.xbm" */
51 static unsigned char gray_bits
[] = {
54 /*#include <commdlg.h>
55 #include <shellapi.h>*/
71 /* Macros max and min defined in lisp.h conflict with those in
72 precompiled header Carbon.h. */
76 #include <Carbon/Carbon.h>
78 #define Z (current_buffer->text->z)
80 #define free unexec_free
82 #define malloc unexec_malloc
84 #define realloc unexec_realloc
86 #define min(a, b) ((a) < (b) ? (a) : (b))
88 #define max(a, b) ((a) > (b) ? (a) : (b))
90 #define init_process emacs_init_process
91 #else /* not MAC_OSX */
94 #include <TextUtils.h>
95 #endif /* not MAC_OSX */
97 /*extern void free_frame_menubar ();
98 extern double atof ();
99 extern int w32_console_toggle_lock_key (int vk_code, Lisp_Object new_state);
100 extern int quit_char;*/
102 extern char *lispy_function_keys
[];
104 /* The gray bitmap `bitmaps/gray'. This is done because macterm.c uses
105 it, and including `bitmaps/gray' more than once is a problem when
106 config.h defines `static' as an empty replacement string. */
108 int gray_bitmap_width
= gray_width
;
109 int gray_bitmap_height
= gray_height
;
110 unsigned char *gray_bitmap_bits
= gray_bits
;
112 /* Non-zero means we're allowed to display an hourglass cursor. */
114 int display_hourglass_p
;
116 /* The background and shape of the mouse pointer, and shape when not
117 over text or in the modeline. */
119 Lisp_Object Vx_pointer_shape
, Vx_nontext_pointer_shape
, Vx_mode_pointer_shape
;
120 Lisp_Object Vx_hourglass_pointer_shape
;
122 /* The shape when over mouse-sensitive text. */
124 Lisp_Object Vx_sensitive_text_pointer_shape
;
126 /* If non-nil, the pointer shape to indicate that windows can be
127 dragged horizontally. */
129 Lisp_Object Vx_window_horizontal_drag_shape
;
131 /* Color of chars displayed in cursor box. */
133 Lisp_Object Vx_cursor_fore_pixel
;
135 /* Nonzero if using Windows. */
137 static int mac_in_use
;
139 /* Non nil if no window manager is in use. */
141 Lisp_Object Vx_no_window_manager
;
143 /* Search path for bitmap files. */
145 Lisp_Object Vx_bitmap_file_path
;
147 /* Regexp matching a font name whose width is the same as `PIXEL_SIZE'. */
149 Lisp_Object Vx_pixel_size_width_font_regexp
;
151 /* Evaluate this expression to rebuild the section of syms_of_macfns
152 that initializes and staticpros the symbols declared below. Note
153 that Emacs 18 has a bug that keeps C-x C-e from being able to
154 evaluate this expression.
157 ;; Accumulate a list of the symbols we want to initialize from the
158 ;; declarations at the top of the file.
159 (goto-char (point-min))
160 (search-forward "/\*&&& symbols declared here &&&*\/\n")
162 (while (looking-at "Lisp_Object \\(Q[a-z_]+\\)")
164 (cons (buffer-substring (match-beginning 1) (match-end 1))
167 (setq symbol-list (nreverse symbol-list))
168 ;; Delete the section of syms_of_... where we initialize the symbols.
169 (search-forward "\n /\*&&& init symbols here &&&*\/\n")
170 (let ((start (point)))
171 (while (looking-at "^ Q")
173 (kill-region start (point)))
174 ;; Write a new symbol initialization section.
176 (insert (format " %s = intern (\"" (car symbol-list)))
177 (let ((start (point)))
178 (insert (substring (car symbol-list) 1))
179 (subst-char-in-region start (point) ?_ ?-))
180 (insert (format "\");\n staticpro (&%s);\n" (car symbol-list)))
181 (setq symbol-list (cdr symbol-list)))))
185 /*&&& symbols declared here &&&*/
187 Lisp_Object Qsuppress_icon
;
188 Lisp_Object Qundefined_color
;
190 Lisp_Object Qcancel_timer
;
196 Lisp_Object Qcontrol
;
199 extern Lisp_Object Vwindow_system_version
;
201 extern int mac_initialized
;
203 /* Functions in macterm.c. */
204 extern void x_set_window_size (struct frame
*, int, int, int);
205 extern void x_make_frame_visible (struct frame
*);
206 extern struct mac_display_info
*mac_term_init (Lisp_Object
, char *, char *);
207 extern struct font_info
*x_get_font_info (FRAME_PTR
, int);
208 extern struct font_info
*x_load_font (struct frame
*, char *, int);
209 extern void x_find_ccl_program (struct font_info
*);
210 extern struct font_info
*x_query_font (struct frame
*, char *);
211 extern void mac_initialize ();
213 /* compare two strings ignoring case */
216 stricmp (const char *s
, const char *t
)
218 for ( ; tolower (*s
) == tolower (*t
); s
++, t
++)
221 return tolower (*s
) - tolower (*t
);
224 /* compare two strings up to n characters, ignoring case */
227 strnicmp (const char *s
, const char *t
, unsigned int n
)
229 for ( ; n
-- > 0 && tolower (*s
) == tolower (*t
); s
++, t
++)
232 return n
== 0 ? 0 : tolower (*s
) - tolower (*t
);
236 /* Error if we are not running on Mac OS. */
242 error ("Mac OS not in use or not initialized");
245 /* Nonzero if we can use mouse menus.
246 You should not call this unless HAVE_MENUS is defined. */
254 /* Extract a frame as a FRAME_PTR, defaulting to the selected frame
255 and checking validity for Mac. */
258 check_x_frame (frame
)
264 frame
= selected_frame
;
265 CHECK_LIVE_FRAME (frame
);
267 if (! FRAME_MAC_P (f
))
268 error ("non-mac frame used");
272 /* Let the user specify a display with a frame.
273 nil stands for the selected frame--or, if that is not a mac frame,
274 the first display on the list. */
276 struct mac_display_info
*
277 check_x_display_info (frame
)
280 if (!mac_initialized
)
288 struct frame
*sf
= XFRAME (selected_frame
);
290 if (FRAME_MAC_P (sf
) && FRAME_LIVE_P (sf
))
291 return FRAME_MAC_DISPLAY_INFO (sf
);
293 return &one_mac_display_info
;
295 else if (STRINGP (frame
))
296 return x_display_info_for_name (frame
);
301 CHECK_LIVE_FRAME (frame
);
303 if (! FRAME_MAC_P (f
))
304 error ("non-mac frame used");
305 return FRAME_MAC_DISPLAY_INFO (f
);
309 /* Return the Emacs frame-object corresponding to a mac window.
310 It could be the frame's main window or an icon window. */
312 /* This function can be called during GC, so use GC_xxx type test macros. */
315 x_window_to_frame (dpyinfo
, wdesc
)
316 struct mac_display_info
*dpyinfo
;
319 Lisp_Object tail
, frame
;
322 for (tail
= Vframe_list
; GC_CONSP (tail
); tail
= XCDR (tail
))
325 if (!GC_FRAMEP (frame
))
328 if (!FRAME_W32_P (f
) || FRAME_MAC_DISPLAY_INFO (f
) != dpyinfo
)
330 /*if (f->output_data.w32->hourglass_window == wdesc)
333 /* MAC_TODO: Check tooltips when supported. */
334 if (FRAME_MAC_WINDOW (f
) == wdesc
)
342 /* Code to deal with bitmaps. Bitmaps are referenced by their bitmap
343 id, which is just an int that this section returns. Bitmaps are
344 reference counted so they can be shared among frames.
346 Bitmap indices are guaranteed to be > 0, so a negative number can
347 be used to indicate no bitmap.
349 If you use x_create_bitmap_from_data, then you must keep track of
350 the bitmaps yourself. That is, creating a bitmap from the same
351 data more than once will not be caught. */
354 /* Functions to access the contents of a bitmap, given an id. */
357 x_bitmap_height (f
, id
)
361 return FRAME_MAC_DISPLAY_INFO (f
)->bitmaps
[id
- 1].height
;
365 x_bitmap_width (f
, id
)
369 return FRAME_MAC_DISPLAY_INFO (f
)->bitmaps
[id
- 1].width
;
372 #if 0 /* MAC_TODO : not used anywhere (?) */
374 x_bitmap_pixmap (f
, id
)
378 return (int) FRAME_MAC_DISPLAY_INFO (f
)->bitmaps
[id
- 1].pixmap
;
382 /* Allocate a new bitmap record. Returns index of new record. */
385 x_allocate_bitmap_record (f
)
388 struct mac_display_info
*dpyinfo
= FRAME_MAC_DISPLAY_INFO (f
);
391 if (dpyinfo
->bitmaps
== NULL
)
393 dpyinfo
->bitmaps_size
= 10;
394 dpyinfo
->bitmaps
= (struct mac_bitmap_record
*)
395 xmalloc (dpyinfo
->bitmaps_size
* sizeof (struct mac_bitmap_record
));
396 dpyinfo
->bitmaps_last
= 1;
400 if (dpyinfo
->bitmaps_last
< dpyinfo
->bitmaps_size
)
401 return ++dpyinfo
->bitmaps_last
;
403 for (i
= 0; i
< dpyinfo
->bitmaps_size
; ++i
)
404 if (dpyinfo
->bitmaps
[i
].refcount
== 0)
407 dpyinfo
->bitmaps_size
*= 2;
408 dpyinfo
->bitmaps
= (struct mac_bitmap_record
*)
409 xrealloc (dpyinfo
->bitmaps
,
410 dpyinfo
->bitmaps_size
* sizeof (struct mac_bitmap_record
));
411 return ++dpyinfo
->bitmaps_last
;
414 /* Add one reference to the reference count of the bitmap with id
418 x_reference_bitmap (f
, id
)
422 ++FRAME_MAC_DISPLAY_INFO (f
)->bitmaps
[id
- 1].refcount
;
425 /* Create a bitmap for frame F from a HEIGHT x WIDTH array of bits at
429 x_create_bitmap_from_data (f
, bits
, width
, height
)
432 unsigned int width
, height
;
434 struct x_display_info
*dpyinfo
= FRAME_MAC_DISPLAY_INFO (f
);
437 /* MAC_TODO: for now fail if width is not mod 16 (toolbox requires it) */
439 id
= x_allocate_bitmap_record (f
);
444 dpyinfo
->bitmaps
[id
- 1].bitmap_data
= (char *) xmalloc (height
* width
);
445 if (! dpyinfo
->bitmaps
[id
- 1].bitmap_data
)
448 bcopy (bits
, dpyinfo
->bitmaps
[id
- 1].bitmap_data
, height
* width
);
450 dpyinfo
->bitmaps
[id
- 1].refcount
= 1;
451 dpyinfo
->bitmaps
[id
- 1].height
= height
;
452 dpyinfo
->bitmaps
[id
- 1].width
= width
;
457 /* Create bitmap from file FILE for frame F. */
460 x_create_bitmap_from_file (f
, file
)
465 #if 0 /* MAC_TODO : bitmap support */
466 struct w32_display_info
*dpyinfo
= FRAME_W32_DISPLAY_INFO (f
);
467 unsigned int width
, height
;
469 int xhot
, yhot
, result
, id
;
475 /* Look for an existing bitmap with the same name. */
476 for (id
= 0; id
< dpyinfo
->bitmaps_last
; ++id
)
478 if (dpyinfo
->bitmaps
[id
].refcount
479 && dpyinfo
->bitmaps
[id
].file
480 && !strcmp (dpyinfo
->bitmaps
[id
].file
, (char *) SDATA (file
)))
482 ++dpyinfo
->bitmaps
[id
].refcount
;
487 /* Search bitmap-file-path for the file, if appropriate. */
488 fd
= openp (Vx_bitmap_file_path
, file
, "", &found
, Qnil
);
491 /* LoadLibraryEx won't handle special files handled by Emacs handler. */
496 filename
= (char *) SDATA (found
);
498 hinst
= LoadLibraryEx (filename
, NULL
, LOAD_LIBRARY_AS_DATAFILE
);
504 result
= XReadBitmapFile (FRAME_W32_DISPLAY (f
), FRAME_W32_WINDOW (f
),
505 filename
, &width
, &height
, &bitmap
, &xhot
, &yhot
);
506 if (result
!= BitmapSuccess
)
509 id
= x_allocate_bitmap_record (f
);
510 dpyinfo
->bitmaps
[id
- 1].pixmap
= bitmap
;
511 dpyinfo
->bitmaps
[id
- 1].refcount
= 1;
512 dpyinfo
->bitmaps
[id
- 1].file
= (char *) xmalloc (SCHARS (file
) + 1);
513 dpyinfo
->bitmaps
[id
- 1].depth
= 1;
514 dpyinfo
->bitmaps
[id
- 1].height
= height
;
515 dpyinfo
->bitmaps
[id
- 1].width
= width
;
516 strcpy (dpyinfo
->bitmaps
[id
- 1].file
, SDATA (file
));
519 #endif /* MAC_TODO */
522 /* Remove reference to bitmap with id number ID. */
525 x_destroy_bitmap (f
, id
)
529 struct mac_display_info
*dpyinfo
= FRAME_MAC_DISPLAY_INFO (f
);
533 --dpyinfo
->bitmaps
[id
- 1].refcount
;
534 if (dpyinfo
->bitmaps
[id
- 1].refcount
== 0)
537 dpyinfo
->bitmaps
[id
- 1].bitmap_data
= NULL
;
543 /* Free all the bitmaps for the display specified by DPYINFO. */
546 x_destroy_all_bitmaps (dpyinfo
)
547 struct mac_display_info
*dpyinfo
;
550 for (i
= 0; i
< dpyinfo
->bitmaps_last
; i
++)
551 if (dpyinfo
->bitmaps
[i
].refcount
> 0)
552 xfree (dpyinfo
->bitmaps
[i
].bitmap_data
);
553 dpyinfo
->bitmaps_last
= 0;
556 /* Connect the frame-parameter names for W32 frames
557 to the ways of passing the parameter values to the window system.
559 The name of a parameter, as a Lisp symbol,
560 has an `x-frame-parameter' property which is an integer in Lisp
561 but can be interpreted as an `enum x_frame_parm' in C. */
563 void x_set_foreground_color
P_ ((struct frame
*, Lisp_Object
, Lisp_Object
));
564 void x_set_background_color
P_ ((struct frame
*, Lisp_Object
, Lisp_Object
));
565 void x_set_mouse_color
P_ ((struct frame
*, Lisp_Object
, Lisp_Object
));
566 void x_set_cursor_color
P_ ((struct frame
*, Lisp_Object
, Lisp_Object
));
567 void x_set_border_color
P_ ((struct frame
*, Lisp_Object
, Lisp_Object
));
568 void x_set_cursor_type
P_ ((struct frame
*, Lisp_Object
, Lisp_Object
));
569 void x_set_icon_type
P_ ((struct frame
*, Lisp_Object
, Lisp_Object
));
570 void x_set_icon_name
P_ ((struct frame
*, Lisp_Object
, Lisp_Object
));
571 void x_explicitly_set_name
P_ ((struct frame
*, Lisp_Object
, Lisp_Object
));
572 void x_set_menu_bar_lines
P_ ((struct frame
*, Lisp_Object
, Lisp_Object
));
573 void x_set_title
P_ ((struct frame
*, Lisp_Object
, Lisp_Object
));
574 void x_set_tool_bar_lines
P_ ((struct frame
*, Lisp_Object
, Lisp_Object
));
575 void x_set_scroll_bar_foreground
P_ ((struct frame
*, Lisp_Object
,
577 void x_set_scroll_bar_background
P_ ((struct frame
*, Lisp_Object
,
579 static Lisp_Object x_default_scroll_bar_color_parameter
P_ ((struct frame
*,
585 /* Store the screen positions of frame F into XPTR and YPTR.
586 These are the positions of the containing window manager window,
587 not Emacs's own window. */
590 x_real_positions (f
, xptr
, yptr
)
597 #ifdef TARGET_API_MAC_CARBON
601 GetWindowPortBounds (f
->output_data
.mac
->mWP
, &r
);
602 SetPt (&pt
, r
.left
, r
.top
);
604 #else /* not TARGET_API_MAC_CARBON */
606 f
->output_data
.mac
->mWP
->portRect
.left
,
607 f
->output_data
.mac
->mWP
->portRect
.top
);
608 #endif /* not TARGET_API_MAC_CARBON */
613 /* MAC has no frame pixel diff. */
614 f
->x_pixels_diff
= 0;
615 f
->y_pixels_diff
= 0;
622 /* The default colors for the Mac color map */
623 typedef struct colormap_t
629 colormap_t mac_color_map
[] =
631 { RGB_TO_ULONG(255, 250, 250), "snow" },
632 { RGB_TO_ULONG(248, 248, 255), "ghost white" },
633 { RGB_TO_ULONG(248, 248, 255), "GhostWhite" },
634 { RGB_TO_ULONG(245, 245, 245), "white smoke" },
635 { RGB_TO_ULONG(245, 245, 245), "WhiteSmoke" },
636 { RGB_TO_ULONG(220, 220, 220), "gainsboro" },
637 { RGB_TO_ULONG(255, 250, 240), "floral white" },
638 { RGB_TO_ULONG(255, 250, 240), "FloralWhite" },
639 { RGB_TO_ULONG(253, 245, 230), "old lace" },
640 { RGB_TO_ULONG(253, 245, 230), "OldLace" },
641 { RGB_TO_ULONG(250, 240, 230), "linen" },
642 { RGB_TO_ULONG(250, 235, 215), "antique white" },
643 { RGB_TO_ULONG(250, 235, 215), "AntiqueWhite" },
644 { RGB_TO_ULONG(255, 239, 213), "papaya whip" },
645 { RGB_TO_ULONG(255, 239, 213), "PapayaWhip" },
646 { RGB_TO_ULONG(255, 235, 205), "blanched almond" },
647 { RGB_TO_ULONG(255, 235, 205), "BlanchedAlmond" },
648 { RGB_TO_ULONG(255, 228, 196), "bisque" },
649 { RGB_TO_ULONG(255, 218, 185), "peach puff" },
650 { RGB_TO_ULONG(255, 218, 185), "PeachPuff" },
651 { RGB_TO_ULONG(255, 222, 173), "navajo white" },
652 { RGB_TO_ULONG(255, 222, 173), "NavajoWhite" },
653 { RGB_TO_ULONG(255, 228, 181), "moccasin" },
654 { RGB_TO_ULONG(255, 248, 220), "cornsilk" },
655 { RGB_TO_ULONG(255, 255, 240), "ivory" },
656 { RGB_TO_ULONG(255, 250, 205), "lemon chiffon" },
657 { RGB_TO_ULONG(255, 250, 205), "LemonChiffon" },
658 { RGB_TO_ULONG(255, 245, 238), "seashell" },
659 { RGB_TO_ULONG(240, 255, 240), "honeydew" },
660 { RGB_TO_ULONG(245, 255, 250), "mint cream" },
661 { RGB_TO_ULONG(245, 255, 250), "MintCream" },
662 { RGB_TO_ULONG(240, 255, 255), "azure" },
663 { RGB_TO_ULONG(240, 248, 255), "alice blue" },
664 { RGB_TO_ULONG(240, 248, 255), "AliceBlue" },
665 { RGB_TO_ULONG(230, 230, 250), "lavender" },
666 { RGB_TO_ULONG(255, 240, 245), "lavender blush" },
667 { RGB_TO_ULONG(255, 240, 245), "LavenderBlush" },
668 { RGB_TO_ULONG(255, 228, 225), "misty rose" },
669 { RGB_TO_ULONG(255, 228, 225), "MistyRose" },
670 { RGB_TO_ULONG(255, 255, 255), "white" },
671 { RGB_TO_ULONG(0 , 0 , 0 ), "black" },
672 { RGB_TO_ULONG(47 , 79 , 79 ), "dark slate gray" },
673 { RGB_TO_ULONG(47 , 79 , 79 ), "DarkSlateGray" },
674 { RGB_TO_ULONG(47 , 79 , 79 ), "dark slate grey" },
675 { RGB_TO_ULONG(47 , 79 , 79 ), "DarkSlateGrey" },
676 { RGB_TO_ULONG(105, 105, 105), "dim gray" },
677 { RGB_TO_ULONG(105, 105, 105), "DimGray" },
678 { RGB_TO_ULONG(105, 105, 105), "dim grey" },
679 { RGB_TO_ULONG(105, 105, 105), "DimGrey" },
680 { RGB_TO_ULONG(112, 128, 144), "slate gray" },
681 { RGB_TO_ULONG(112, 128, 144), "SlateGray" },
682 { RGB_TO_ULONG(112, 128, 144), "slate grey" },
683 { RGB_TO_ULONG(112, 128, 144), "SlateGrey" },
684 { RGB_TO_ULONG(119, 136, 153), "light slate gray" },
685 { RGB_TO_ULONG(119, 136, 153), "LightSlateGray" },
686 { RGB_TO_ULONG(119, 136, 153), "light slate grey" },
687 { RGB_TO_ULONG(119, 136, 153), "LightSlateGrey" },
688 { RGB_TO_ULONG(190, 190, 190), "gray" },
689 { RGB_TO_ULONG(190, 190, 190), "grey" },
690 { RGB_TO_ULONG(211, 211, 211), "light grey" },
691 { RGB_TO_ULONG(211, 211, 211), "LightGrey" },
692 { RGB_TO_ULONG(211, 211, 211), "light gray" },
693 { RGB_TO_ULONG(211, 211, 211), "LightGray" },
694 { RGB_TO_ULONG(25 , 25 , 112), "midnight blue" },
695 { RGB_TO_ULONG(25 , 25 , 112), "MidnightBlue" },
696 { RGB_TO_ULONG(0 , 0 , 128), "navy" },
697 { RGB_TO_ULONG(0 , 0 , 128), "navy blue" },
698 { RGB_TO_ULONG(0 , 0 , 128), "NavyBlue" },
699 { RGB_TO_ULONG(100, 149, 237), "cornflower blue" },
700 { RGB_TO_ULONG(100, 149, 237), "CornflowerBlue" },
701 { RGB_TO_ULONG(72 , 61 , 139), "dark slate blue" },
702 { RGB_TO_ULONG(72 , 61 , 139), "DarkSlateBlue" },
703 { RGB_TO_ULONG(106, 90 , 205), "slate blue" },
704 { RGB_TO_ULONG(106, 90 , 205), "SlateBlue" },
705 { RGB_TO_ULONG(123, 104, 238), "medium slate blue" },
706 { RGB_TO_ULONG(123, 104, 238), "MediumSlateBlue" },
707 { RGB_TO_ULONG(132, 112, 255), "light slate blue" },
708 { RGB_TO_ULONG(132, 112, 255), "LightSlateBlue" },
709 { RGB_TO_ULONG(0 , 0 , 205), "medium blue" },
710 { RGB_TO_ULONG(0 , 0 , 205), "MediumBlue" },
711 { RGB_TO_ULONG(65 , 105, 225), "royal blue" },
712 { RGB_TO_ULONG(65 , 105, 225), "RoyalBlue" },
713 { RGB_TO_ULONG(0 , 0 , 255), "blue" },
714 { RGB_TO_ULONG(30 , 144, 255), "dodger blue" },
715 { RGB_TO_ULONG(30 , 144, 255), "DodgerBlue" },
716 { RGB_TO_ULONG(0 , 191, 255), "deep sky blue" },
717 { RGB_TO_ULONG(0 , 191, 255), "DeepSkyBlue" },
718 { RGB_TO_ULONG(135, 206, 235), "sky blue" },
719 { RGB_TO_ULONG(135, 206, 235), "SkyBlue" },
720 { RGB_TO_ULONG(135, 206, 250), "light sky blue" },
721 { RGB_TO_ULONG(135, 206, 250), "LightSkyBlue" },
722 { RGB_TO_ULONG(70 , 130, 180), "steel blue" },
723 { RGB_TO_ULONG(70 , 130, 180), "SteelBlue" },
724 { RGB_TO_ULONG(176, 196, 222), "light steel blue" },
725 { RGB_TO_ULONG(176, 196, 222), "LightSteelBlue" },
726 { RGB_TO_ULONG(173, 216, 230), "light blue" },
727 { RGB_TO_ULONG(173, 216, 230), "LightBlue" },
728 { RGB_TO_ULONG(176, 224, 230), "powder blue" },
729 { RGB_TO_ULONG(176, 224, 230), "PowderBlue" },
730 { RGB_TO_ULONG(175, 238, 238), "pale turquoise" },
731 { RGB_TO_ULONG(175, 238, 238), "PaleTurquoise" },
732 { RGB_TO_ULONG(0 , 206, 209), "dark turquoise" },
733 { RGB_TO_ULONG(0 , 206, 209), "DarkTurquoise" },
734 { RGB_TO_ULONG(72 , 209, 204), "medium turquoise" },
735 { RGB_TO_ULONG(72 , 209, 204), "MediumTurquoise" },
736 { RGB_TO_ULONG(64 , 224, 208), "turquoise" },
737 { RGB_TO_ULONG(0 , 255, 255), "cyan" },
738 { RGB_TO_ULONG(224, 255, 255), "light cyan" },
739 { RGB_TO_ULONG(224, 255, 255), "LightCyan" },
740 { RGB_TO_ULONG(95 , 158, 160), "cadet blue" },
741 { RGB_TO_ULONG(95 , 158, 160), "CadetBlue" },
742 { RGB_TO_ULONG(102, 205, 170), "medium aquamarine" },
743 { RGB_TO_ULONG(102, 205, 170), "MediumAquamarine" },
744 { RGB_TO_ULONG(127, 255, 212), "aquamarine" },
745 { RGB_TO_ULONG(0 , 100, 0 ), "dark green" },
746 { RGB_TO_ULONG(0 , 100, 0 ), "DarkGreen" },
747 { RGB_TO_ULONG(85 , 107, 47 ), "dark olive green" },
748 { RGB_TO_ULONG(85 , 107, 47 ), "DarkOliveGreen" },
749 { RGB_TO_ULONG(143, 188, 143), "dark sea green" },
750 { RGB_TO_ULONG(143, 188, 143), "DarkSeaGreen" },
751 { RGB_TO_ULONG(46 , 139, 87 ), "sea green" },
752 { RGB_TO_ULONG(46 , 139, 87 ), "SeaGreen" },
753 { RGB_TO_ULONG(60 , 179, 113), "medium sea green" },
754 { RGB_TO_ULONG(60 , 179, 113), "MediumSeaGreen" },
755 { RGB_TO_ULONG(32 , 178, 170), "light sea green" },
756 { RGB_TO_ULONG(32 , 178, 170), "LightSeaGreen" },
757 { RGB_TO_ULONG(152, 251, 152), "pale green" },
758 { RGB_TO_ULONG(152, 251, 152), "PaleGreen" },
759 { RGB_TO_ULONG(0 , 255, 127), "spring green" },
760 { RGB_TO_ULONG(0 , 255, 127), "SpringGreen" },
761 { RGB_TO_ULONG(124, 252, 0 ), "lawn green" },
762 { RGB_TO_ULONG(124, 252, 0 ), "LawnGreen" },
763 { RGB_TO_ULONG(0 , 255, 0 ), "green" },
764 { RGB_TO_ULONG(127, 255, 0 ), "chartreuse" },
765 { RGB_TO_ULONG(0 , 250, 154), "medium spring green" },
766 { RGB_TO_ULONG(0 , 250, 154), "MediumSpringGreen" },
767 { RGB_TO_ULONG(173, 255, 47 ), "green yellow" },
768 { RGB_TO_ULONG(173, 255, 47 ), "GreenYellow" },
769 { RGB_TO_ULONG(50 , 205, 50 ), "lime green" },
770 { RGB_TO_ULONG(50 , 205, 50 ), "LimeGreen" },
771 { RGB_TO_ULONG(154, 205, 50 ), "yellow green" },
772 { RGB_TO_ULONG(154, 205, 50 ), "YellowGreen" },
773 { RGB_TO_ULONG(34 , 139, 34 ), "forest green" },
774 { RGB_TO_ULONG(34 , 139, 34 ), "ForestGreen" },
775 { RGB_TO_ULONG(107, 142, 35 ), "olive drab" },
776 { RGB_TO_ULONG(107, 142, 35 ), "OliveDrab" },
777 { RGB_TO_ULONG(189, 183, 107), "dark khaki" },
778 { RGB_TO_ULONG(189, 183, 107), "DarkKhaki" },
779 { RGB_TO_ULONG(240, 230, 140), "khaki" },
780 { RGB_TO_ULONG(238, 232, 170), "pale goldenrod" },
781 { RGB_TO_ULONG(238, 232, 170), "PaleGoldenrod" },
782 { RGB_TO_ULONG(250, 250, 210), "light goldenrod yellow" },
783 { RGB_TO_ULONG(250, 250, 210), "LightGoldenrodYellow" },
784 { RGB_TO_ULONG(255, 255, 224), "light yellow" },
785 { RGB_TO_ULONG(255, 255, 224), "LightYellow" },
786 { RGB_TO_ULONG(255, 255, 0 ), "yellow" },
787 { RGB_TO_ULONG(255, 215, 0 ), "gold" },
788 { RGB_TO_ULONG(238, 221, 130), "light goldenrod" },
789 { RGB_TO_ULONG(238, 221, 130), "LightGoldenrod" },
790 { RGB_TO_ULONG(218, 165, 32 ), "goldenrod" },
791 { RGB_TO_ULONG(184, 134, 11 ), "dark goldenrod" },
792 { RGB_TO_ULONG(184, 134, 11 ), "DarkGoldenrod" },
793 { RGB_TO_ULONG(188, 143, 143), "rosy brown" },
794 { RGB_TO_ULONG(188, 143, 143), "RosyBrown" },
795 { RGB_TO_ULONG(205, 92 , 92 ), "indian red" },
796 { RGB_TO_ULONG(205, 92 , 92 ), "IndianRed" },
797 { RGB_TO_ULONG(139, 69 , 19 ), "saddle brown" },
798 { RGB_TO_ULONG(139, 69 , 19 ), "SaddleBrown" },
799 { RGB_TO_ULONG(160, 82 , 45 ), "sienna" },
800 { RGB_TO_ULONG(205, 133, 63 ), "peru" },
801 { RGB_TO_ULONG(222, 184, 135), "burlywood" },
802 { RGB_TO_ULONG(245, 245, 220), "beige" },
803 { RGB_TO_ULONG(245, 222, 179), "wheat" },
804 { RGB_TO_ULONG(244, 164, 96 ), "sandy brown" },
805 { RGB_TO_ULONG(244, 164, 96 ), "SandyBrown" },
806 { RGB_TO_ULONG(210, 180, 140), "tan" },
807 { RGB_TO_ULONG(210, 105, 30 ), "chocolate" },
808 { RGB_TO_ULONG(178, 34 , 34 ), "firebrick" },
809 { RGB_TO_ULONG(165, 42 , 42 ), "brown" },
810 { RGB_TO_ULONG(233, 150, 122), "dark salmon" },
811 { RGB_TO_ULONG(233, 150, 122), "DarkSalmon" },
812 { RGB_TO_ULONG(250, 128, 114), "salmon" },
813 { RGB_TO_ULONG(255, 160, 122), "light salmon" },
814 { RGB_TO_ULONG(255, 160, 122), "LightSalmon" },
815 { RGB_TO_ULONG(255, 165, 0 ), "orange" },
816 { RGB_TO_ULONG(255, 140, 0 ), "dark orange" },
817 { RGB_TO_ULONG(255, 140, 0 ), "DarkOrange" },
818 { RGB_TO_ULONG(255, 127, 80 ), "coral" },
819 { RGB_TO_ULONG(240, 128, 128), "light coral" },
820 { RGB_TO_ULONG(240, 128, 128), "LightCoral" },
821 { RGB_TO_ULONG(255, 99 , 71 ), "tomato" },
822 { RGB_TO_ULONG(255, 69 , 0 ), "orange red" },
823 { RGB_TO_ULONG(255, 69 , 0 ), "OrangeRed" },
824 { RGB_TO_ULONG(255, 0 , 0 ), "red" },
825 { RGB_TO_ULONG(255, 105, 180), "hot pink" },
826 { RGB_TO_ULONG(255, 105, 180), "HotPink" },
827 { RGB_TO_ULONG(255, 20 , 147), "deep pink" },
828 { RGB_TO_ULONG(255, 20 , 147), "DeepPink" },
829 { RGB_TO_ULONG(255, 192, 203), "pink" },
830 { RGB_TO_ULONG(255, 182, 193), "light pink" },
831 { RGB_TO_ULONG(255, 182, 193), "LightPink" },
832 { RGB_TO_ULONG(219, 112, 147), "pale violet red" },
833 { RGB_TO_ULONG(219, 112, 147), "PaleVioletRed" },
834 { RGB_TO_ULONG(176, 48 , 96 ), "maroon" },
835 { RGB_TO_ULONG(199, 21 , 133), "medium violet red" },
836 { RGB_TO_ULONG(199, 21 , 133), "MediumVioletRed" },
837 { RGB_TO_ULONG(208, 32 , 144), "violet red" },
838 { RGB_TO_ULONG(208, 32 , 144), "VioletRed" },
839 { RGB_TO_ULONG(255, 0 , 255), "magenta" },
840 { RGB_TO_ULONG(238, 130, 238), "violet" },
841 { RGB_TO_ULONG(221, 160, 221), "plum" },
842 { RGB_TO_ULONG(218, 112, 214), "orchid" },
843 { RGB_TO_ULONG(186, 85 , 211), "medium orchid" },
844 { RGB_TO_ULONG(186, 85 , 211), "MediumOrchid" },
845 { RGB_TO_ULONG(153, 50 , 204), "dark orchid" },
846 { RGB_TO_ULONG(153, 50 , 204), "DarkOrchid" },
847 { RGB_TO_ULONG(148, 0 , 211), "dark violet" },
848 { RGB_TO_ULONG(148, 0 , 211), "DarkViolet" },
849 { RGB_TO_ULONG(138, 43 , 226), "blue violet" },
850 { RGB_TO_ULONG(138, 43 , 226), "BlueViolet" },
851 { RGB_TO_ULONG(160, 32 , 240), "purple" },
852 { RGB_TO_ULONG(147, 112, 219), "medium purple" },
853 { RGB_TO_ULONG(147, 112, 219), "MediumPurple" },
854 { RGB_TO_ULONG(216, 191, 216), "thistle" },
855 { RGB_TO_ULONG(255, 250, 250), "snow1" },
856 { RGB_TO_ULONG(238, 233, 233), "snow2" },
857 { RGB_TO_ULONG(205, 201, 201), "snow3" },
858 { RGB_TO_ULONG(139, 137, 137), "snow4" },
859 { RGB_TO_ULONG(255, 245, 238), "seashell1" },
860 { RGB_TO_ULONG(238, 229, 222), "seashell2" },
861 { RGB_TO_ULONG(205, 197, 191), "seashell3" },
862 { RGB_TO_ULONG(139, 134, 130), "seashell4" },
863 { RGB_TO_ULONG(255, 239, 219), "AntiqueWhite1" },
864 { RGB_TO_ULONG(238, 223, 204), "AntiqueWhite2" },
865 { RGB_TO_ULONG(205, 192, 176), "AntiqueWhite3" },
866 { RGB_TO_ULONG(139, 131, 120), "AntiqueWhite4" },
867 { RGB_TO_ULONG(255, 228, 196), "bisque1" },
868 { RGB_TO_ULONG(238, 213, 183), "bisque2" },
869 { RGB_TO_ULONG(205, 183, 158), "bisque3" },
870 { RGB_TO_ULONG(139, 125, 107), "bisque4" },
871 { RGB_TO_ULONG(255, 218, 185), "PeachPuff1" },
872 { RGB_TO_ULONG(238, 203, 173), "PeachPuff2" },
873 { RGB_TO_ULONG(205, 175, 149), "PeachPuff3" },
874 { RGB_TO_ULONG(139, 119, 101), "PeachPuff4" },
875 { RGB_TO_ULONG(255, 222, 173), "NavajoWhite1" },
876 { RGB_TO_ULONG(238, 207, 161), "NavajoWhite2" },
877 { RGB_TO_ULONG(205, 179, 139), "NavajoWhite3" },
878 { RGB_TO_ULONG(139, 121, 94), "NavajoWhite4" },
879 { RGB_TO_ULONG(255, 250, 205), "LemonChiffon1" },
880 { RGB_TO_ULONG(238, 233, 191), "LemonChiffon2" },
881 { RGB_TO_ULONG(205, 201, 165), "LemonChiffon3" },
882 { RGB_TO_ULONG(139, 137, 112), "LemonChiffon4" },
883 { RGB_TO_ULONG(255, 248, 220), "cornsilk1" },
884 { RGB_TO_ULONG(238, 232, 205), "cornsilk2" },
885 { RGB_TO_ULONG(205, 200, 177), "cornsilk3" },
886 { RGB_TO_ULONG(139, 136, 120), "cornsilk4" },
887 { RGB_TO_ULONG(255, 255, 240), "ivory1" },
888 { RGB_TO_ULONG(238, 238, 224), "ivory2" },
889 { RGB_TO_ULONG(205, 205, 193), "ivory3" },
890 { RGB_TO_ULONG(139, 139, 131), "ivory4" },
891 { RGB_TO_ULONG(240, 255, 240), "honeydew1" },
892 { RGB_TO_ULONG(224, 238, 224), "honeydew2" },
893 { RGB_TO_ULONG(193, 205, 193), "honeydew3" },
894 { RGB_TO_ULONG(131, 139, 131), "honeydew4" },
895 { RGB_TO_ULONG(255, 240, 245), "LavenderBlush1" },
896 { RGB_TO_ULONG(238, 224, 229), "LavenderBlush2" },
897 { RGB_TO_ULONG(205, 193, 197), "LavenderBlush3" },
898 { RGB_TO_ULONG(139, 131, 134), "LavenderBlush4" },
899 { RGB_TO_ULONG(255, 228, 225), "MistyRose1" },
900 { RGB_TO_ULONG(238, 213, 210), "MistyRose2" },
901 { RGB_TO_ULONG(205, 183, 181), "MistyRose3" },
902 { RGB_TO_ULONG(139, 125, 123), "MistyRose4" },
903 { RGB_TO_ULONG(240, 255, 255), "azure1" },
904 { RGB_TO_ULONG(224, 238, 238), "azure2" },
905 { RGB_TO_ULONG(193, 205, 205), "azure3" },
906 { RGB_TO_ULONG(131, 139, 139), "azure4" },
907 { RGB_TO_ULONG(131, 111, 255), "SlateBlue1" },
908 { RGB_TO_ULONG(122, 103, 238), "SlateBlue2" },
909 { RGB_TO_ULONG(105, 89 , 205), "SlateBlue3" },
910 { RGB_TO_ULONG(71 , 60 , 139), "SlateBlue4" },
911 { RGB_TO_ULONG(72 , 118, 255), "RoyalBlue1" },
912 { RGB_TO_ULONG(67 , 110, 238), "RoyalBlue2" },
913 { RGB_TO_ULONG(58 , 95 , 205), "RoyalBlue3" },
914 { RGB_TO_ULONG(39 , 64 , 139), "RoyalBlue4" },
915 { RGB_TO_ULONG(0 , 0 , 255), "blue1" },
916 { RGB_TO_ULONG(0 , 0 , 238), "blue2" },
917 { RGB_TO_ULONG(0 , 0 , 205), "blue3" },
918 { RGB_TO_ULONG(0 , 0 , 139), "blue4" },
919 { RGB_TO_ULONG(30 , 144, 255), "DodgerBlue1" },
920 { RGB_TO_ULONG(28 , 134, 238), "DodgerBlue2" },
921 { RGB_TO_ULONG(24 , 116, 205), "DodgerBlue3" },
922 { RGB_TO_ULONG(16 , 78 , 139), "DodgerBlue4" },
923 { RGB_TO_ULONG(99 , 184, 255), "SteelBlue1" },
924 { RGB_TO_ULONG(92 , 172, 238), "SteelBlue2" },
925 { RGB_TO_ULONG(79 , 148, 205), "SteelBlue3" },
926 { RGB_TO_ULONG(54 , 100, 139), "SteelBlue4" },
927 { RGB_TO_ULONG(0 , 191, 255), "DeepSkyBlue1" },
928 { RGB_TO_ULONG(0 , 178, 238), "DeepSkyBlue2" },
929 { RGB_TO_ULONG(0 , 154, 205), "DeepSkyBlue3" },
930 { RGB_TO_ULONG(0 , 104, 139), "DeepSkyBlue4" },
931 { RGB_TO_ULONG(135, 206, 255), "SkyBlue1" },
932 { RGB_TO_ULONG(126, 192, 238), "SkyBlue2" },
933 { RGB_TO_ULONG(108, 166, 205), "SkyBlue3" },
934 { RGB_TO_ULONG(74 , 112, 139), "SkyBlue4" },
935 { RGB_TO_ULONG(176, 226, 255), "LightSkyBlue1" },
936 { RGB_TO_ULONG(164, 211, 238), "LightSkyBlue2" },
937 { RGB_TO_ULONG(141, 182, 205), "LightSkyBlue3" },
938 { RGB_TO_ULONG(96 , 123, 139), "LightSkyBlue4" },
939 { RGB_TO_ULONG(198, 226, 255), "SlateGray1" },
940 { RGB_TO_ULONG(185, 211, 238), "SlateGray2" },
941 { RGB_TO_ULONG(159, 182, 205), "SlateGray3" },
942 { RGB_TO_ULONG(108, 123, 139), "SlateGray4" },
943 { RGB_TO_ULONG(202, 225, 255), "LightSteelBlue1" },
944 { RGB_TO_ULONG(188, 210, 238), "LightSteelBlue2" },
945 { RGB_TO_ULONG(162, 181, 205), "LightSteelBlue3" },
946 { RGB_TO_ULONG(110, 123, 139), "LightSteelBlue4" },
947 { RGB_TO_ULONG(191, 239, 255), "LightBlue1" },
948 { RGB_TO_ULONG(178, 223, 238), "LightBlue2" },
949 { RGB_TO_ULONG(154, 192, 205), "LightBlue3" },
950 { RGB_TO_ULONG(104, 131, 139), "LightBlue4" },
951 { RGB_TO_ULONG(224, 255, 255), "LightCyan1" },
952 { RGB_TO_ULONG(209, 238, 238), "LightCyan2" },
953 { RGB_TO_ULONG(180, 205, 205), "LightCyan3" },
954 { RGB_TO_ULONG(122, 139, 139), "LightCyan4" },
955 { RGB_TO_ULONG(187, 255, 255), "PaleTurquoise1" },
956 { RGB_TO_ULONG(174, 238, 238), "PaleTurquoise2" },
957 { RGB_TO_ULONG(150, 205, 205), "PaleTurquoise3" },
958 { RGB_TO_ULONG(102, 139, 139), "PaleTurquoise4" },
959 { RGB_TO_ULONG(152, 245, 255), "CadetBlue1" },
960 { RGB_TO_ULONG(142, 229, 238), "CadetBlue2" },
961 { RGB_TO_ULONG(122, 197, 205), "CadetBlue3" },
962 { RGB_TO_ULONG(83 , 134, 139), "CadetBlue4" },
963 { RGB_TO_ULONG(0 , 245, 255), "turquoise1" },
964 { RGB_TO_ULONG(0 , 229, 238), "turquoise2" },
965 { RGB_TO_ULONG(0 , 197, 205), "turquoise3" },
966 { RGB_TO_ULONG(0 , 134, 139), "turquoise4" },
967 { RGB_TO_ULONG(0 , 255, 255), "cyan1" },
968 { RGB_TO_ULONG(0 , 238, 238), "cyan2" },
969 { RGB_TO_ULONG(0 , 205, 205), "cyan3" },
970 { RGB_TO_ULONG(0 , 139, 139), "cyan4" },
971 { RGB_TO_ULONG(151, 255, 255), "DarkSlateGray1" },
972 { RGB_TO_ULONG(141, 238, 238), "DarkSlateGray2" },
973 { RGB_TO_ULONG(121, 205, 205), "DarkSlateGray3" },
974 { RGB_TO_ULONG(82 , 139, 139), "DarkSlateGray4" },
975 { RGB_TO_ULONG(127, 255, 212), "aquamarine1" },
976 { RGB_TO_ULONG(118, 238, 198), "aquamarine2" },
977 { RGB_TO_ULONG(102, 205, 170), "aquamarine3" },
978 { RGB_TO_ULONG(69 , 139, 116), "aquamarine4" },
979 { RGB_TO_ULONG(193, 255, 193), "DarkSeaGreen1" },
980 { RGB_TO_ULONG(180, 238, 180), "DarkSeaGreen2" },
981 { RGB_TO_ULONG(155, 205, 155), "DarkSeaGreen3" },
982 { RGB_TO_ULONG(105, 139, 105), "DarkSeaGreen4" },
983 { RGB_TO_ULONG(84 , 255, 159), "SeaGreen1" },
984 { RGB_TO_ULONG(78 , 238, 148), "SeaGreen2" },
985 { RGB_TO_ULONG(67 , 205, 128), "SeaGreen3" },
986 { RGB_TO_ULONG(46 , 139, 87 ), "SeaGreen4" },
987 { RGB_TO_ULONG(154, 255, 154), "PaleGreen1" },
988 { RGB_TO_ULONG(144, 238, 144), "PaleGreen2" },
989 { RGB_TO_ULONG(124, 205, 124), "PaleGreen3" },
990 { RGB_TO_ULONG(84 , 139, 84 ), "PaleGreen4" },
991 { RGB_TO_ULONG(0 , 255, 127), "SpringGreen1" },
992 { RGB_TO_ULONG(0 , 238, 118), "SpringGreen2" },
993 { RGB_TO_ULONG(0 , 205, 102), "SpringGreen3" },
994 { RGB_TO_ULONG(0 , 139, 69 ), "SpringGreen4" },
995 { RGB_TO_ULONG(0 , 255, 0 ), "green1" },
996 { RGB_TO_ULONG(0 , 238, 0 ), "green2" },
997 { RGB_TO_ULONG(0 , 205, 0 ), "green3" },
998 { RGB_TO_ULONG(0 , 139, 0 ), "green4" },
999 { RGB_TO_ULONG(127, 255, 0 ), "chartreuse1" },
1000 { RGB_TO_ULONG(118, 238, 0 ), "chartreuse2" },
1001 { RGB_TO_ULONG(102, 205, 0 ), "chartreuse3" },
1002 { RGB_TO_ULONG(69 , 139, 0 ), "chartreuse4" },
1003 { RGB_TO_ULONG(192, 255, 62 ), "OliveDrab1" },
1004 { RGB_TO_ULONG(179, 238, 58 ), "OliveDrab2" },
1005 { RGB_TO_ULONG(154, 205, 50 ), "OliveDrab3" },
1006 { RGB_TO_ULONG(105, 139, 34 ), "OliveDrab4" },
1007 { RGB_TO_ULONG(202, 255, 112), "DarkOliveGreen1" },
1008 { RGB_TO_ULONG(188, 238, 104), "DarkOliveGreen2" },
1009 { RGB_TO_ULONG(162, 205, 90 ), "DarkOliveGreen3" },
1010 { RGB_TO_ULONG(110, 139, 61 ), "DarkOliveGreen4" },
1011 { RGB_TO_ULONG(255, 246, 143), "khaki1" },
1012 { RGB_TO_ULONG(238, 230, 133), "khaki2" },
1013 { RGB_TO_ULONG(205, 198, 115), "khaki3" },
1014 { RGB_TO_ULONG(139, 134, 78 ), "khaki4" },
1015 { RGB_TO_ULONG(255, 236, 139), "LightGoldenrod1" },
1016 { RGB_TO_ULONG(238, 220, 130), "LightGoldenrod2" },
1017 { RGB_TO_ULONG(205, 190, 112), "LightGoldenrod3" },
1018 { RGB_TO_ULONG(139, 129, 76 ), "LightGoldenrod4" },
1019 { RGB_TO_ULONG(255, 255, 224), "LightYellow1" },
1020 { RGB_TO_ULONG(238, 238, 209), "LightYellow2" },
1021 { RGB_TO_ULONG(205, 205, 180), "LightYellow3" },
1022 { RGB_TO_ULONG(139, 139, 122), "LightYellow4" },
1023 { RGB_TO_ULONG(255, 255, 0 ), "yellow1" },
1024 { RGB_TO_ULONG(238, 238, 0 ), "yellow2" },
1025 { RGB_TO_ULONG(205, 205, 0 ), "yellow3" },
1026 { RGB_TO_ULONG(139, 139, 0 ), "yellow4" },
1027 { RGB_TO_ULONG(255, 215, 0 ), "gold1" },
1028 { RGB_TO_ULONG(238, 201, 0 ), "gold2" },
1029 { RGB_TO_ULONG(205, 173, 0 ), "gold3" },
1030 { RGB_TO_ULONG(139, 117, 0 ), "gold4" },
1031 { RGB_TO_ULONG(255, 193, 37 ), "goldenrod1" },
1032 { RGB_TO_ULONG(238, 180, 34 ), "goldenrod2" },
1033 { RGB_TO_ULONG(205, 155, 29 ), "goldenrod3" },
1034 { RGB_TO_ULONG(139, 105, 20 ), "goldenrod4" },
1035 { RGB_TO_ULONG(255, 185, 15 ), "DarkGoldenrod1" },
1036 { RGB_TO_ULONG(238, 173, 14 ), "DarkGoldenrod2" },
1037 { RGB_TO_ULONG(205, 149, 12 ), "DarkGoldenrod3" },
1038 { RGB_TO_ULONG(139, 101, 8 ), "DarkGoldenrod4" },
1039 { RGB_TO_ULONG(255, 193, 193), "RosyBrown1" },
1040 { RGB_TO_ULONG(238, 180, 180), "RosyBrown2" },
1041 { RGB_TO_ULONG(205, 155, 155), "RosyBrown3" },
1042 { RGB_TO_ULONG(139, 105, 105), "RosyBrown4" },
1043 { RGB_TO_ULONG(255, 106, 106), "IndianRed1" },
1044 { RGB_TO_ULONG(238, 99 , 99 ), "IndianRed2" },
1045 { RGB_TO_ULONG(205, 85 , 85 ), "IndianRed3" },
1046 { RGB_TO_ULONG(139, 58 , 58 ), "IndianRed4" },
1047 { RGB_TO_ULONG(255, 130, 71 ), "sienna1" },
1048 { RGB_TO_ULONG(238, 121, 66 ), "sienna2" },
1049 { RGB_TO_ULONG(205, 104, 57 ), "sienna3" },
1050 { RGB_TO_ULONG(139, 71 , 38 ), "sienna4" },
1051 { RGB_TO_ULONG(255, 211, 155), "burlywood1" },
1052 { RGB_TO_ULONG(238, 197, 145), "burlywood2" },
1053 { RGB_TO_ULONG(205, 170, 125), "burlywood3" },
1054 { RGB_TO_ULONG(139, 115, 85 ), "burlywood4" },
1055 { RGB_TO_ULONG(255, 231, 186), "wheat1" },
1056 { RGB_TO_ULONG(238, 216, 174), "wheat2" },
1057 { RGB_TO_ULONG(205, 186, 150), "wheat3" },
1058 { RGB_TO_ULONG(139, 126, 102), "wheat4" },
1059 { RGB_TO_ULONG(255, 165, 79 ), "tan1" },
1060 { RGB_TO_ULONG(238, 154, 73 ), "tan2" },
1061 { RGB_TO_ULONG(205, 133, 63 ), "tan3" },
1062 { RGB_TO_ULONG(139, 90 , 43 ), "tan4" },
1063 { RGB_TO_ULONG(255, 127, 36 ), "chocolate1" },
1064 { RGB_TO_ULONG(238, 118, 33 ), "chocolate2" },
1065 { RGB_TO_ULONG(205, 102, 29 ), "chocolate3" },
1066 { RGB_TO_ULONG(139, 69 , 19 ), "chocolate4" },
1067 { RGB_TO_ULONG(255, 48 , 48 ), "firebrick1" },
1068 { RGB_TO_ULONG(238, 44 , 44 ), "firebrick2" },
1069 { RGB_TO_ULONG(205, 38 , 38 ), "firebrick3" },
1070 { RGB_TO_ULONG(139, 26 , 26 ), "firebrick4" },
1071 { RGB_TO_ULONG(255, 64 , 64 ), "brown1" },
1072 { RGB_TO_ULONG(238, 59 , 59 ), "brown2" },
1073 { RGB_TO_ULONG(205, 51 , 51 ), "brown3" },
1074 { RGB_TO_ULONG(139, 35 , 35 ), "brown4" },
1075 { RGB_TO_ULONG(255, 140, 105), "salmon1" },
1076 { RGB_TO_ULONG(238, 130, 98 ), "salmon2" },
1077 { RGB_TO_ULONG(205, 112, 84 ), "salmon3" },
1078 { RGB_TO_ULONG(139, 76 , 57 ), "salmon4" },
1079 { RGB_TO_ULONG(255, 160, 122), "LightSalmon1" },
1080 { RGB_TO_ULONG(238, 149, 114), "LightSalmon2" },
1081 { RGB_TO_ULONG(205, 129, 98 ), "LightSalmon3" },
1082 { RGB_TO_ULONG(139, 87 , 66 ), "LightSalmon4" },
1083 { RGB_TO_ULONG(255, 165, 0 ), "orange1" },
1084 { RGB_TO_ULONG(238, 154, 0 ), "orange2" },
1085 { RGB_TO_ULONG(205, 133, 0 ), "orange3" },
1086 { RGB_TO_ULONG(139, 90 , 0 ), "orange4" },
1087 { RGB_TO_ULONG(255, 127, 0 ), "DarkOrange1" },
1088 { RGB_TO_ULONG(238, 118, 0 ), "DarkOrange2" },
1089 { RGB_TO_ULONG(205, 102, 0 ), "DarkOrange3" },
1090 { RGB_TO_ULONG(139, 69 , 0 ), "DarkOrange4" },
1091 { RGB_TO_ULONG(255, 114, 86 ), "coral1" },
1092 { RGB_TO_ULONG(238, 106, 80 ), "coral2" },
1093 { RGB_TO_ULONG(205, 91 , 69 ), "coral3" },
1094 { RGB_TO_ULONG(139, 62 , 47 ), "coral4" },
1095 { RGB_TO_ULONG(255, 99 , 71 ), "tomato1" },
1096 { RGB_TO_ULONG(238, 92 , 66 ), "tomato2" },
1097 { RGB_TO_ULONG(205, 79 , 57 ), "tomato3" },
1098 { RGB_TO_ULONG(139, 54 , 38 ), "tomato4" },
1099 { RGB_TO_ULONG(255, 69 , 0 ), "OrangeRed1" },
1100 { RGB_TO_ULONG(238, 64 , 0 ), "OrangeRed2" },
1101 { RGB_TO_ULONG(205, 55 , 0 ), "OrangeRed3" },
1102 { RGB_TO_ULONG(139, 37 , 0 ), "OrangeRed4" },
1103 { RGB_TO_ULONG(255, 0 , 0 ), "red1" },
1104 { RGB_TO_ULONG(238, 0 , 0 ), "red2" },
1105 { RGB_TO_ULONG(205, 0 , 0 ), "red3" },
1106 { RGB_TO_ULONG(139, 0 , 0 ), "red4" },
1107 { RGB_TO_ULONG(255, 20 , 147), "DeepPink1" },
1108 { RGB_TO_ULONG(238, 18 , 137), "DeepPink2" },
1109 { RGB_TO_ULONG(205, 16 , 118), "DeepPink3" },
1110 { RGB_TO_ULONG(139, 10 , 80 ), "DeepPink4" },
1111 { RGB_TO_ULONG(255, 110, 180), "HotPink1" },
1112 { RGB_TO_ULONG(238, 106, 167), "HotPink2" },
1113 { RGB_TO_ULONG(205, 96 , 144), "HotPink3" },
1114 { RGB_TO_ULONG(139, 58 , 98 ), "HotPink4" },
1115 { RGB_TO_ULONG(255, 181, 197), "pink1" },
1116 { RGB_TO_ULONG(238, 169, 184), "pink2" },
1117 { RGB_TO_ULONG(205, 145, 158), "pink3" },
1118 { RGB_TO_ULONG(139, 99 , 108), "pink4" },
1119 { RGB_TO_ULONG(255, 174, 185), "LightPink1" },
1120 { RGB_TO_ULONG(238, 162, 173), "LightPink2" },
1121 { RGB_TO_ULONG(205, 140, 149), "LightPink3" },
1122 { RGB_TO_ULONG(139, 95 , 101), "LightPink4" },
1123 { RGB_TO_ULONG(255, 130, 171), "PaleVioletRed1" },
1124 { RGB_TO_ULONG(238, 121, 159), "PaleVioletRed2" },
1125 { RGB_TO_ULONG(205, 104, 137), "PaleVioletRed3" },
1126 { RGB_TO_ULONG(139, 71 , 93 ), "PaleVioletRed4" },
1127 { RGB_TO_ULONG(255, 52 , 179), "maroon1" },
1128 { RGB_TO_ULONG(238, 48 , 167), "maroon2" },
1129 { RGB_TO_ULONG(205, 41 , 144), "maroon3" },
1130 { RGB_TO_ULONG(139, 28 , 98 ), "maroon4" },
1131 { RGB_TO_ULONG(255, 62 , 150), "VioletRed1" },
1132 { RGB_TO_ULONG(238, 58 , 140), "VioletRed2" },
1133 { RGB_TO_ULONG(205, 50 , 120), "VioletRed3" },
1134 { RGB_TO_ULONG(139, 34 , 82 ), "VioletRed4" },
1135 { RGB_TO_ULONG(255, 0 , 255), "magenta1" },
1136 { RGB_TO_ULONG(238, 0 , 238), "magenta2" },
1137 { RGB_TO_ULONG(205, 0 , 205), "magenta3" },
1138 { RGB_TO_ULONG(139, 0 , 139), "magenta4" },
1139 { RGB_TO_ULONG(255, 131, 250), "orchid1" },
1140 { RGB_TO_ULONG(238, 122, 233), "orchid2" },
1141 { RGB_TO_ULONG(205, 105, 201), "orchid3" },
1142 { RGB_TO_ULONG(139, 71 , 137), "orchid4" },
1143 { RGB_TO_ULONG(255, 187, 255), "plum1" },
1144 { RGB_TO_ULONG(238, 174, 238), "plum2" },
1145 { RGB_TO_ULONG(205, 150, 205), "plum3" },
1146 { RGB_TO_ULONG(139, 102, 139), "plum4" },
1147 { RGB_TO_ULONG(224, 102, 255), "MediumOrchid1" },
1148 { RGB_TO_ULONG(209, 95 , 238), "MediumOrchid2" },
1149 { RGB_TO_ULONG(180, 82 , 205), "MediumOrchid3" },
1150 { RGB_TO_ULONG(122, 55 , 139), "MediumOrchid4" },
1151 { RGB_TO_ULONG(191, 62 , 255), "DarkOrchid1" },
1152 { RGB_TO_ULONG(178, 58 , 238), "DarkOrchid2" },
1153 { RGB_TO_ULONG(154, 50 , 205), "DarkOrchid3" },
1154 { RGB_TO_ULONG(104, 34 , 139), "DarkOrchid4" },
1155 { RGB_TO_ULONG(155, 48 , 255), "purple1" },
1156 { RGB_TO_ULONG(145, 44 , 238), "purple2" },
1157 { RGB_TO_ULONG(125, 38 , 205), "purple3" },
1158 { RGB_TO_ULONG(85 , 26 , 139), "purple4" },
1159 { RGB_TO_ULONG(171, 130, 255), "MediumPurple1" },
1160 { RGB_TO_ULONG(159, 121, 238), "MediumPurple2" },
1161 { RGB_TO_ULONG(137, 104, 205), "MediumPurple3" },
1162 { RGB_TO_ULONG(93 , 71 , 139), "MediumPurple4" },
1163 { RGB_TO_ULONG(255, 225, 255), "thistle1" },
1164 { RGB_TO_ULONG(238, 210, 238), "thistle2" },
1165 { RGB_TO_ULONG(205, 181, 205), "thistle3" },
1166 { RGB_TO_ULONG(139, 123, 139), "thistle4" },
1167 { RGB_TO_ULONG(0 , 0 , 0 ), "gray0" },
1168 { RGB_TO_ULONG(0 , 0 , 0 ), "grey0" },
1169 { RGB_TO_ULONG(3 , 3 , 3 ), "gray1" },
1170 { RGB_TO_ULONG(3 , 3 , 3 ), "grey1" },
1171 { RGB_TO_ULONG(5 , 5 , 5 ), "gray2" },
1172 { RGB_TO_ULONG(5 , 5 , 5 ), "grey2" },
1173 { RGB_TO_ULONG(8 , 8 , 8 ), "gray3" },
1174 { RGB_TO_ULONG(8 , 8 , 8 ), "grey3" },
1175 { RGB_TO_ULONG(10 , 10 , 10 ), "gray4" },
1176 { RGB_TO_ULONG(10 , 10 , 10 ), "grey4" },
1177 { RGB_TO_ULONG(13 , 13 , 13 ), "gray5" },
1178 { RGB_TO_ULONG(13 , 13 , 13 ), "grey5" },
1179 { RGB_TO_ULONG(15 , 15 , 15 ), "gray6" },
1180 { RGB_TO_ULONG(15 , 15 , 15 ), "grey6" },
1181 { RGB_TO_ULONG(18 , 18 , 18 ), "gray7" },
1182 { RGB_TO_ULONG(18 , 18 , 18 ), "grey7" },
1183 { RGB_TO_ULONG(20 , 20 , 20 ), "gray8" },
1184 { RGB_TO_ULONG(20 , 20 , 20 ), "grey8" },
1185 { RGB_TO_ULONG(23 , 23 , 23 ), "gray9" },
1186 { RGB_TO_ULONG(23 , 23 , 23 ), "grey9" },
1187 { RGB_TO_ULONG(26 , 26 , 26 ), "gray10" },
1188 { RGB_TO_ULONG(26 , 26 , 26 ), "grey10" },
1189 { RGB_TO_ULONG(28 , 28 , 28 ), "gray11" },
1190 { RGB_TO_ULONG(28 , 28 , 28 ), "grey11" },
1191 { RGB_TO_ULONG(31 , 31 , 31 ), "gray12" },
1192 { RGB_TO_ULONG(31 , 31 , 31 ), "grey12" },
1193 { RGB_TO_ULONG(33 , 33 , 33 ), "gray13" },
1194 { RGB_TO_ULONG(33 , 33 , 33 ), "grey13" },
1195 { RGB_TO_ULONG(36 , 36 , 36 ), "gray14" },
1196 { RGB_TO_ULONG(36 , 36 , 36 ), "grey14" },
1197 { RGB_TO_ULONG(38 , 38 , 38 ), "gray15" },
1198 { RGB_TO_ULONG(38 , 38 , 38 ), "grey15" },
1199 { RGB_TO_ULONG(41 , 41 , 41 ), "gray16" },
1200 { RGB_TO_ULONG(41 , 41 , 41 ), "grey16" },
1201 { RGB_TO_ULONG(43 , 43 , 43 ), "gray17" },
1202 { RGB_TO_ULONG(43 , 43 , 43 ), "grey17" },
1203 { RGB_TO_ULONG(46 , 46 , 46 ), "gray18" },
1204 { RGB_TO_ULONG(46 , 46 , 46 ), "grey18" },
1205 { RGB_TO_ULONG(48 , 48 , 48 ), "gray19" },
1206 { RGB_TO_ULONG(48 , 48 , 48 ), "grey19" },
1207 { RGB_TO_ULONG(51 , 51 , 51 ), "gray20" },
1208 { RGB_TO_ULONG(51 , 51 , 51 ), "grey20" },
1209 { RGB_TO_ULONG(54 , 54 , 54 ), "gray21" },
1210 { RGB_TO_ULONG(54 , 54 , 54 ), "grey21" },
1211 { RGB_TO_ULONG(56 , 56 , 56 ), "gray22" },
1212 { RGB_TO_ULONG(56 , 56 , 56 ), "grey22" },
1213 { RGB_TO_ULONG(59 , 59 , 59 ), "gray23" },
1214 { RGB_TO_ULONG(59 , 59 , 59 ), "grey23" },
1215 { RGB_TO_ULONG(61 , 61 , 61 ), "gray24" },
1216 { RGB_TO_ULONG(61 , 61 , 61 ), "grey24" },
1217 { RGB_TO_ULONG(64 , 64 , 64 ), "gray25" },
1218 { RGB_TO_ULONG(64 , 64 , 64 ), "grey25" },
1219 { RGB_TO_ULONG(66 , 66 , 66 ), "gray26" },
1220 { RGB_TO_ULONG(66 , 66 , 66 ), "grey26" },
1221 { RGB_TO_ULONG(69 , 69 , 69 ), "gray27" },
1222 { RGB_TO_ULONG(69 , 69 , 69 ), "grey27" },
1223 { RGB_TO_ULONG(71 , 71 , 71 ), "gray28" },
1224 { RGB_TO_ULONG(71 , 71 , 71 ), "grey28" },
1225 { RGB_TO_ULONG(74 , 74 , 74 ), "gray29" },
1226 { RGB_TO_ULONG(74 , 74 , 74 ), "grey29" },
1227 { RGB_TO_ULONG(77 , 77 , 77 ), "gray30" },
1228 { RGB_TO_ULONG(77 , 77 , 77 ), "grey30" },
1229 { RGB_TO_ULONG(79 , 79 , 79 ), "gray31" },
1230 { RGB_TO_ULONG(79 , 79 , 79 ), "grey31" },
1231 { RGB_TO_ULONG(82 , 82 , 82 ), "gray32" },
1232 { RGB_TO_ULONG(82 , 82 , 82 ), "grey32" },
1233 { RGB_TO_ULONG(84 , 84 , 84 ), "gray33" },
1234 { RGB_TO_ULONG(84 , 84 , 84 ), "grey33" },
1235 { RGB_TO_ULONG(87 , 87 , 87 ), "gray34" },
1236 { RGB_TO_ULONG(87 , 87 , 87 ), "grey34" },
1237 { RGB_TO_ULONG(89 , 89 , 89 ), "gray35" },
1238 { RGB_TO_ULONG(89 , 89 , 89 ), "grey35" },
1239 { RGB_TO_ULONG(92 , 92 , 92 ), "gray36" },
1240 { RGB_TO_ULONG(92 , 92 , 92 ), "grey36" },
1241 { RGB_TO_ULONG(94 , 94 , 94 ), "gray37" },
1242 { RGB_TO_ULONG(94 , 94 , 94 ), "grey37" },
1243 { RGB_TO_ULONG(97 , 97 , 97 ), "gray38" },
1244 { RGB_TO_ULONG(97 , 97 , 97 ), "grey38" },
1245 { RGB_TO_ULONG(99 , 99 , 99 ), "gray39" },
1246 { RGB_TO_ULONG(99 , 99 , 99 ), "grey39" },
1247 { RGB_TO_ULONG(102, 102, 102), "gray40" },
1248 { RGB_TO_ULONG(102, 102, 102), "grey40" },
1249 { RGB_TO_ULONG(105, 105, 105), "gray41" },
1250 { RGB_TO_ULONG(105, 105, 105), "grey41" },
1251 { RGB_TO_ULONG(107, 107, 107), "gray42" },
1252 { RGB_TO_ULONG(107, 107, 107), "grey42" },
1253 { RGB_TO_ULONG(110, 110, 110), "gray43" },
1254 { RGB_TO_ULONG(110, 110, 110), "grey43" },
1255 { RGB_TO_ULONG(112, 112, 112), "gray44" },
1256 { RGB_TO_ULONG(112, 112, 112), "grey44" },
1257 { RGB_TO_ULONG(115, 115, 115), "gray45" },
1258 { RGB_TO_ULONG(115, 115, 115), "grey45" },
1259 { RGB_TO_ULONG(117, 117, 117), "gray46" },
1260 { RGB_TO_ULONG(117, 117, 117), "grey46" },
1261 { RGB_TO_ULONG(120, 120, 120), "gray47" },
1262 { RGB_TO_ULONG(120, 120, 120), "grey47" },
1263 { RGB_TO_ULONG(122, 122, 122), "gray48" },
1264 { RGB_TO_ULONG(122, 122, 122), "grey48" },
1265 { RGB_TO_ULONG(125, 125, 125), "gray49" },
1266 { RGB_TO_ULONG(125, 125, 125), "grey49" },
1267 { RGB_TO_ULONG(127, 127, 127), "gray50" },
1268 { RGB_TO_ULONG(127, 127, 127), "grey50" },
1269 { RGB_TO_ULONG(130, 130, 130), "gray51" },
1270 { RGB_TO_ULONG(130, 130, 130), "grey51" },
1271 { RGB_TO_ULONG(133, 133, 133), "gray52" },
1272 { RGB_TO_ULONG(133, 133, 133), "grey52" },
1273 { RGB_TO_ULONG(135, 135, 135), "gray53" },
1274 { RGB_TO_ULONG(135, 135, 135), "grey53" },
1275 { RGB_TO_ULONG(138, 138, 138), "gray54" },
1276 { RGB_TO_ULONG(138, 138, 138), "grey54" },
1277 { RGB_TO_ULONG(140, 140, 140), "gray55" },
1278 { RGB_TO_ULONG(140, 140, 140), "grey55" },
1279 { RGB_TO_ULONG(143, 143, 143), "gray56" },
1280 { RGB_TO_ULONG(143, 143, 143), "grey56" },
1281 { RGB_TO_ULONG(145, 145, 145), "gray57" },
1282 { RGB_TO_ULONG(145, 145, 145), "grey57" },
1283 { RGB_TO_ULONG(148, 148, 148), "gray58" },
1284 { RGB_TO_ULONG(148, 148, 148), "grey58" },
1285 { RGB_TO_ULONG(150, 150, 150), "gray59" },
1286 { RGB_TO_ULONG(150, 150, 150), "grey59" },
1287 { RGB_TO_ULONG(153, 153, 153), "gray60" },
1288 { RGB_TO_ULONG(153, 153, 153), "grey60" },
1289 { RGB_TO_ULONG(156, 156, 156), "gray61" },
1290 { RGB_TO_ULONG(156, 156, 156), "grey61" },
1291 { RGB_TO_ULONG(158, 158, 158), "gray62" },
1292 { RGB_TO_ULONG(158, 158, 158), "grey62" },
1293 { RGB_TO_ULONG(161, 161, 161), "gray63" },
1294 { RGB_TO_ULONG(161, 161, 161), "grey63" },
1295 { RGB_TO_ULONG(163, 163, 163), "gray64" },
1296 { RGB_TO_ULONG(163, 163, 163), "grey64" },
1297 { RGB_TO_ULONG(166, 166, 166), "gray65" },
1298 { RGB_TO_ULONG(166, 166, 166), "grey65" },
1299 { RGB_TO_ULONG(168, 168, 168), "gray66" },
1300 { RGB_TO_ULONG(168, 168, 168), "grey66" },
1301 { RGB_TO_ULONG(171, 171, 171), "gray67" },
1302 { RGB_TO_ULONG(171, 171, 171), "grey67" },
1303 { RGB_TO_ULONG(173, 173, 173), "gray68" },
1304 { RGB_TO_ULONG(173, 173, 173), "grey68" },
1305 { RGB_TO_ULONG(176, 176, 176), "gray69" },
1306 { RGB_TO_ULONG(176, 176, 176), "grey69" },
1307 { RGB_TO_ULONG(179, 179, 179), "gray70" },
1308 { RGB_TO_ULONG(179, 179, 179), "grey70" },
1309 { RGB_TO_ULONG(181, 181, 181), "gray71" },
1310 { RGB_TO_ULONG(181, 181, 181), "grey71" },
1311 { RGB_TO_ULONG(184, 184, 184), "gray72" },
1312 { RGB_TO_ULONG(184, 184, 184), "grey72" },
1313 { RGB_TO_ULONG(186, 186, 186), "gray73" },
1314 { RGB_TO_ULONG(186, 186, 186), "grey73" },
1315 { RGB_TO_ULONG(189, 189, 189), "gray74" },
1316 { RGB_TO_ULONG(189, 189, 189), "grey74" },
1317 { RGB_TO_ULONG(191, 191, 191), "gray75" },
1318 { RGB_TO_ULONG(191, 191, 191), "grey75" },
1319 { RGB_TO_ULONG(194, 194, 194), "gray76" },
1320 { RGB_TO_ULONG(194, 194, 194), "grey76" },
1321 { RGB_TO_ULONG(196, 196, 196), "gray77" },
1322 { RGB_TO_ULONG(196, 196, 196), "grey77" },
1323 { RGB_TO_ULONG(199, 199, 199), "gray78" },
1324 { RGB_TO_ULONG(199, 199, 199), "grey78" },
1325 { RGB_TO_ULONG(201, 201, 201), "gray79" },
1326 { RGB_TO_ULONG(201, 201, 201), "grey79" },
1327 { RGB_TO_ULONG(204, 204, 204), "gray80" },
1328 { RGB_TO_ULONG(204, 204, 204), "grey80" },
1329 { RGB_TO_ULONG(207, 207, 207), "gray81" },
1330 { RGB_TO_ULONG(207, 207, 207), "grey81" },
1331 { RGB_TO_ULONG(209, 209, 209), "gray82" },
1332 { RGB_TO_ULONG(209, 209, 209), "grey82" },
1333 { RGB_TO_ULONG(212, 212, 212), "gray83" },
1334 { RGB_TO_ULONG(212, 212, 212), "grey83" },
1335 { RGB_TO_ULONG(214, 214, 214), "gray84" },
1336 { RGB_TO_ULONG(214, 214, 214), "grey84" },
1337 { RGB_TO_ULONG(217, 217, 217), "gray85" },
1338 { RGB_TO_ULONG(217, 217, 217), "grey85" },
1339 { RGB_TO_ULONG(219, 219, 219), "gray86" },
1340 { RGB_TO_ULONG(219, 219, 219), "grey86" },
1341 { RGB_TO_ULONG(222, 222, 222), "gray87" },
1342 { RGB_TO_ULONG(222, 222, 222), "grey87" },
1343 { RGB_TO_ULONG(224, 224, 224), "gray88" },
1344 { RGB_TO_ULONG(224, 224, 224), "grey88" },
1345 { RGB_TO_ULONG(227, 227, 227), "gray89" },
1346 { RGB_TO_ULONG(227, 227, 227), "grey89" },
1347 { RGB_TO_ULONG(229, 229, 229), "gray90" },
1348 { RGB_TO_ULONG(229, 229, 229), "grey90" },
1349 { RGB_TO_ULONG(232, 232, 232), "gray91" },
1350 { RGB_TO_ULONG(232, 232, 232), "grey91" },
1351 { RGB_TO_ULONG(235, 235, 235), "gray92" },
1352 { RGB_TO_ULONG(235, 235, 235), "grey92" },
1353 { RGB_TO_ULONG(237, 237, 237), "gray93" },
1354 { RGB_TO_ULONG(237, 237, 237), "grey93" },
1355 { RGB_TO_ULONG(240, 240, 240), "gray94" },
1356 { RGB_TO_ULONG(240, 240, 240), "grey94" },
1357 { RGB_TO_ULONG(242, 242, 242), "gray95" },
1358 { RGB_TO_ULONG(242, 242, 242), "grey95" },
1359 { RGB_TO_ULONG(245, 245, 245), "gray96" },
1360 { RGB_TO_ULONG(245, 245, 245), "grey96" },
1361 { RGB_TO_ULONG(247, 247, 247), "gray97" },
1362 { RGB_TO_ULONG(247, 247, 247), "grey97" },
1363 { RGB_TO_ULONG(250, 250, 250), "gray98" },
1364 { RGB_TO_ULONG(250, 250, 250), "grey98" },
1365 { RGB_TO_ULONG(252, 252, 252), "gray99" },
1366 { RGB_TO_ULONG(252, 252, 252), "grey99" },
1367 { RGB_TO_ULONG(255, 255, 255), "gray100" },
1368 { RGB_TO_ULONG(255, 255, 255), "grey100" },
1369 { RGB_TO_ULONG(169, 169, 169), "dark grey" },
1370 { RGB_TO_ULONG(169, 169, 169), "DarkGrey" },
1371 { RGB_TO_ULONG(169, 169, 169), "dark gray" },
1372 { RGB_TO_ULONG(169, 169, 169), "DarkGray" },
1373 { RGB_TO_ULONG(0 , 0 , 139), "dark blue" },
1374 { RGB_TO_ULONG(0 , 0 , 139), "DarkBlue" },
1375 { RGB_TO_ULONG(0 , 139, 139), "dark cyan" },
1376 { RGB_TO_ULONG(0 , 139, 139), "DarkCyan" },
1377 { RGB_TO_ULONG(139, 0 , 139), "dark magenta" },
1378 { RGB_TO_ULONG(139, 0 , 139), "DarkMagenta" },
1379 { RGB_TO_ULONG(139, 0 , 0 ), "dark red" },
1380 { RGB_TO_ULONG(139, 0 , 0 ), "DarkRed" },
1381 { RGB_TO_ULONG(144, 238, 144), "light green" },
1382 { RGB_TO_ULONG(144, 238, 144), "LightGreen" }
1386 mac_color_map_lookup (colorname
)
1389 Lisp_Object ret
= Qnil
;
1394 for (i
= 0; i
< sizeof (mac_color_map
) / sizeof (mac_color_map
[0]); i
++)
1395 if (stricmp (colorname
, mac_color_map
[i
].name
) == 0)
1397 ret
= mac_color_map
[i
].color
;
1407 x_to_mac_color (colorname
)
1410 register Lisp_Object tail
, ret
= Qnil
;
1414 if (colorname
[0] == '#')
1416 /* Could be an old-style RGB Device specification. */
1419 color
= colorname
+ 1;
1421 size
= strlen(color
);
1422 if (size
== 3 || size
== 6 || size
== 9 || size
== 12)
1424 unsigned long colorval
;
1430 for (i
= 0; i
< 3; i
++)
1434 unsigned long value
;
1436 /* The check for 'x' in the following conditional takes into
1437 account the fact that strtol allows a "0x" in front of
1438 our numbers, and we don't. */
1439 if (!isxdigit(color
[0]) || color
[1] == 'x')
1443 value
= strtoul(color
, &end
, 16);
1445 if (errno
== ERANGE
|| end
- color
!= size
)
1450 value
= value
* 0x10;
1461 colorval
|= (value
<< pos
);
1472 else if (strnicmp(colorname
, "rgb:", 4) == 0)
1475 unsigned long colorval
;
1480 color
= colorname
+ 4;
1481 for (i
= 0; i
< 3; i
++)
1484 unsigned long value
;
1486 /* The check for 'x' in the following conditional takes into
1487 account the fact that strtol allows a "0x" in front of
1488 our numbers, and we don't. */
1489 if (!isxdigit(color
[0]) || color
[1] == 'x')
1491 value
= strtoul(color
, &end
, 16);
1492 if (errno
== ERANGE
)
1494 switch (end
- color
)
1497 value
= value
* 0x10 + value
;
1510 if (value
== ULONG_MAX
)
1512 colorval
|= (value
<< pos
);
1526 else if (strnicmp(colorname
, "rgbi:", 5) == 0)
1528 /* This is an RGB Intensity specification. */
1530 unsigned long colorval
;
1535 color
= colorname
+ 5;
1536 for (i
= 0; i
< 3; i
++)
1542 value
= strtod(color
, &end
);
1543 if (errno
== ERANGE
)
1545 if (value
< 0.0 || value
> 1.0)
1547 val
= (unsigned long)(0x100 * value
);
1548 /* We used 0x100 instead of 0xFF to give a continuous
1549 range between 0.0 and 1.0 inclusive. The next statement
1550 fixes the 1.0 case. */
1553 colorval
|= (val
<< pos
);
1568 ret
= mac_color_map_lookup (colorname
);
1574 /* Gamma-correct COLOR on frame F. */
1577 gamma_correct (f
, color
)
1579 unsigned long *color
;
1583 unsigned long red
, green
, blue
;
1585 red
= pow (RED_FROM_ULONG (*color
) / 255.0, f
->gamma
) * 255.0 + 0.5;
1586 green
= pow (GREEN_FROM_ULONG (*color
) / 255.0, f
->gamma
) * 255.0 + 0.5;
1587 blue
= pow (BLUE_FROM_ULONG (*color
) / 255.0, f
->gamma
) * 255.0 + 0.5;
1588 *color
= RGB_TO_ULONG (red
, green
, blue
);
1592 /* Decide if color named COLOR is valid for the display associated
1593 with the selected frame; if so, return the rgb values in COLOR_DEF.
1594 If ALLOC is nonzero, allocate a new colormap cell. */
1597 mac_defined_color (f
, color
, color_def
, alloc
)
1603 register Lisp_Object tem
;
1604 unsigned long mac_color_ref
;
1606 tem
= x_to_mac_color (color
);
1612 /* Apply gamma correction. */
1613 mac_color_ref
= XUINT (tem
);
1614 gamma_correct (f
, &mac_color_ref
);
1615 XSETINT (tem
, mac_color_ref
);
1618 color_def
->pixel
= mac_color_ref
;
1619 color_def
->red
= RED_FROM_ULONG (mac_color_ref
);
1620 color_def
->green
= GREEN_FROM_ULONG (mac_color_ref
);
1621 color_def
->blue
= BLUE_FROM_ULONG (mac_color_ref
);
1631 /* Given a string ARG naming a color, compute a pixel value from it
1632 suitable for screen F.
1633 If F is not a color screen, return DEF (default) regardless of what
1637 x_decode_color (f
, arg
, def
)
1646 if (strcmp (SDATA (arg
), "black") == 0)
1647 return BLACK_PIX_DEFAULT (f
);
1648 else if (strcmp (SDATA (arg
), "white") == 0)
1649 return WHITE_PIX_DEFAULT (f
);
1652 if ((FRAME_MAC_DISPLAY_INFO (f
)->n_planes
1653 * FRAME_MAC_DISPLAY_INFO (f
)->n_cbits
) == 1)
1657 if (mac_defined_color (f
, SDATA (arg
), &cdef
, 1))
1660 /* defined_color failed; return an ultimate default. */
1664 /* Functions called only from `x_set_frame_param'
1665 to set individual parameters.
1667 If FRAME_MAC_WINDOW (f) is 0,
1668 the frame is being created and its window does not exist yet.
1669 In that case, just record the parameter's new value
1670 in the standard place; do not attempt to change the window. */
1673 x_set_foreground_color (f
, arg
, oldval
)
1675 Lisp_Object arg
, oldval
;
1677 FRAME_FOREGROUND_PIXEL (f
)
1678 = x_decode_color (f
, arg
, BLACK_PIX_DEFAULT (f
));
1680 if (FRAME_MAC_WINDOW (f
) != 0)
1682 update_face_from_frame_parameter (f
, Qforeground_color
, arg
);
1683 if (FRAME_VISIBLE_P (f
))
1689 x_set_background_color (f
, arg
, oldval
)
1691 Lisp_Object arg
, oldval
;
1693 FRAME_BACKGROUND_PIXEL (f
)
1694 = x_decode_color (f
, arg
, WHITE_PIX_DEFAULT (f
));
1696 if (FRAME_MAC_WINDOW (f
) != 0)
1698 update_face_from_frame_parameter (f
, Qbackground_color
, arg
);
1700 if (FRAME_VISIBLE_P (f
))
1706 x_set_mouse_color (f
, arg
, oldval
)
1708 Lisp_Object arg
, oldval
;
1710 Cursor cursor
, nontext_cursor
, mode_cursor
, hand_cursor
;
1714 if (!EQ (Qnil
, arg
))
1715 f
->output_data
.mac
->mouse_pixel
1716 = x_decode_color (f
, arg
, BLACK_PIX_DEFAULT (f
));
1717 mask_color
= FRAME_BACKGROUND_PIXEL (f
);
1719 /* Don't let pointers be invisible. */
1720 if (mask_color
== f
->output_data
.mac
->mouse_pixel
1721 && mask_color
== FRAME_BACKGROUND_PIXEL (f
))
1722 f
->output_data
.mac
->mouse_pixel
= FRAME_FOREGROUND_PIXEL (f
);
1724 #if 0 /* MAC_TODO : cursor changes */
1727 /* It's not okay to crash if the user selects a screwy cursor. */
1728 count
= x_catch_errors (FRAME_W32_DISPLAY (f
));
1730 if (!EQ (Qnil
, Vx_pointer_shape
))
1732 CHECK_NUMBER (Vx_pointer_shape
);
1733 cursor
= XCreateFontCursor (FRAME_W32_DISPLAY (f
), XINT (Vx_pointer_shape
));
1736 cursor
= XCreateFontCursor (FRAME_W32_DISPLAY (f
), XC_xterm
);
1737 x_check_errors (FRAME_W32_DISPLAY (f
), "bad text pointer cursor: %s");
1739 if (!EQ (Qnil
, Vx_nontext_pointer_shape
))
1741 CHECK_NUMBER (Vx_nontext_pointer_shape
);
1742 nontext_cursor
= XCreateFontCursor (FRAME_W32_DISPLAY (f
),
1743 XINT (Vx_nontext_pointer_shape
));
1746 nontext_cursor
= XCreateFontCursor (FRAME_W32_DISPLAY (f
), XC_left_ptr
);
1747 x_check_errors (FRAME_W32_DISPLAY (f
), "bad nontext pointer cursor: %s");
1749 if (!EQ (Qnil
, Vx_hourglass_pointer_shape
))
1751 CHECK_NUMBER (Vx_hourglass_pointer_shape
);
1752 hourglass_cursor
= XCreateFontCursor (FRAME_W32_DISPLAY (f
),
1753 XINT (Vx_hourglass_pointer_shape
));
1756 hourglass_cursor
= XCreateFontCursor (FRAME_W32_DISPLAY (f
), XC_watch
);
1757 x_check_errors (FRAME_W32_DISPLAY (f
), "bad busy pointer cursor: %s");
1759 x_check_errors (FRAME_W32_DISPLAY (f
), "bad nontext pointer cursor: %s");
1760 if (!EQ (Qnil
, Vx_mode_pointer_shape
))
1762 CHECK_NUMBER (Vx_mode_pointer_shape
);
1763 mode_cursor
= XCreateFontCursor (FRAME_W32_DISPLAY (f
),
1764 XINT (Vx_mode_pointer_shape
));
1767 mode_cursor
= XCreateFontCursor (FRAME_W32_DISPLAY (f
), XC_xterm
);
1768 x_check_errors (FRAME_W32_DISPLAY (f
), "bad modeline pointer cursor: %s");
1770 if (!EQ (Qnil
, Vx_sensitive_text_pointer_shape
))
1772 CHECK_NUMBER (Vx_sensitive_text_pointer_shape
);
1774 = XCreateFontCursor (FRAME_W32_DISPLAY (f
),
1775 XINT (Vx_sensitive_text_pointer_shape
));
1778 hand_cursor
= XCreateFontCursor (FRAME_W32_DISPLAY (f
), XC_crosshair
);
1780 if (!NILP (Vx_window_horizontal_drag_shape
))
1782 CHECK_NUMBER (Vx_window_horizontal_drag_shape
);
1783 horizontal_drag_cursor
1784 = XCreateFontCursor (FRAME_W32_DISPLAY (f
),
1785 XINT (Vx_window_horizontal_drag_shape
));
1788 horizontal_drag_cursor
1789 = XCreateFontCursor (FRAME_W32_DISPLAY (f
), XC_sb_h_double_arrow
);
1791 /* Check and report errors with the above calls. */
1792 x_check_errors (FRAME_W32_DISPLAY (f
), "can't set cursor shape: %s");
1793 x_uncatch_errors (FRAME_W32_DISPLAY (f
), count
);
1796 XColor fore_color
, back_color
;
1798 fore_color
.pixel
= f
->output_data
.w32
->mouse_pixel
;
1799 back_color
.pixel
= mask_color
;
1800 XQueryColor (FRAME_W32_DISPLAY (f
),
1801 DefaultColormap (FRAME_W32_DISPLAY (f
),
1802 DefaultScreen (FRAME_W32_DISPLAY (f
))),
1804 XQueryColor (FRAME_W32_DISPLAY (f
),
1805 DefaultColormap (FRAME_W32_DISPLAY (f
),
1806 DefaultScreen (FRAME_W32_DISPLAY (f
))),
1808 XRecolorCursor (FRAME_W32_DISPLAY (f
), cursor
,
1809 &fore_color
, &back_color
);
1810 XRecolorCursor (FRAME_W32_DISPLAY (f
), nontext_cursor
,
1811 &fore_color
, &back_color
);
1812 XRecolorCursor (FRAME_W32_DISPLAY (f
), mode_cursor
,
1813 &fore_color
, &back_color
);
1814 XRecolorCursor (FRAME_W32_DISPLAY (f
), hand_cursor
,
1815 &fore_color
, &back_color
);
1816 XRecolorCursor (FRAME_W32_DISPLAY (f
), hourglass_cursor
,
1817 &fore_color
, &back_color
);
1820 if (FRAME_W32_WINDOW (f
) != 0)
1821 XDefineCursor (FRAME_W32_DISPLAY (f
), FRAME_W32_WINDOW (f
), cursor
);
1823 if (cursor
!= f
->output_data
.w32
->text_cursor
&& f
->output_data
.w32
->text_cursor
!= 0)
1824 XFreeCursor (FRAME_W32_DISPLAY (f
), f
->output_data
.w32
->text_cursor
);
1825 f
->output_data
.w32
->text_cursor
= cursor
;
1827 if (nontext_cursor
!= f
->output_data
.w32
->nontext_cursor
1828 && f
->output_data
.w32
->nontext_cursor
!= 0)
1829 XFreeCursor (FRAME_W32_DISPLAY (f
), f
->output_data
.w32
->nontext_cursor
);
1830 f
->output_data
.w32
->nontext_cursor
= nontext_cursor
;
1832 if (hourglass_cursor
!= f
->output_data
.w32
->hourglass_cursor
1833 && f
->output_data
.w32
->hourglass_cursor
!= 0)
1834 XFreeCursor (FRAME_W32_DISPLAY (f
), f
->output_data
.w32
->hourglass_cursor
);
1835 f
->output_data
.w32
->hourglass_cursor
= hourglass_cursor
;
1837 if (mode_cursor
!= f
->output_data
.w32
->modeline_cursor
1838 && f
->output_data
.w32
->modeline_cursor
!= 0)
1839 XFreeCursor (FRAME_W32_DISPLAY (f
), f
->output_data
.w32
->modeline_cursor
);
1840 f
->output_data
.w32
->modeline_cursor
= mode_cursor
;
1842 if (hand_cursor
!= f
->output_data
.w32
->hand_cursor
1843 && f
->output_data
.w32
->hand_cursor
!= 0)
1844 XFreeCursor (FRAME_W32_DISPLAY (f
), f
->output_data
.w32
->hand_cursor
);
1845 f
->output_data
.w32
->hand_cursor
= hand_cursor
;
1847 XFlush (FRAME_W32_DISPLAY (f
));
1850 update_face_from_frame_parameter (f
, Qmouse_color
, arg
);
1851 #endif /* MAC_TODO */
1855 x_set_cursor_color (f
, arg
, oldval
)
1857 Lisp_Object arg
, oldval
;
1859 unsigned long fore_pixel
;
1861 if (!NILP (Vx_cursor_fore_pixel
))
1862 fore_pixel
= x_decode_color (f
, Vx_cursor_fore_pixel
,
1863 WHITE_PIX_DEFAULT (f
));
1865 fore_pixel
= FRAME_BACKGROUND_PIXEL (f
);
1866 f
->output_data
.mac
->cursor_pixel
= x_decode_color (f
, arg
, BLACK_PIX_DEFAULT (f
));
1868 /* Make sure that the cursor color differs from the background color. */
1869 if (f
->output_data
.mac
->cursor_pixel
== FRAME_BACKGROUND_PIXEL (f
))
1871 f
->output_data
.mac
->cursor_pixel
= f
->output_data
.mac
->mouse_pixel
;
1872 if (f
->output_data
.mac
->cursor_pixel
== fore_pixel
)
1873 fore_pixel
= FRAME_BACKGROUND_PIXEL (f
);
1875 FRAME_FOREGROUND_PIXEL (f
) = fore_pixel
;
1877 #if 0 /* MAC_TODO: cannot figure out what to do (wrong number of params) */
1878 if (FRAME_MAC_WINDOW (f
) != 0)
1880 if (FRAME_VISIBLE_P (f
))
1883 display_and_set_cursor (f
, 0);
1884 display_and_set_cursor (f
, 1);
1890 update_face_from_frame_parameter (f
, Qcursor_color
, arg
);
1893 /* Set the border-color of frame F to pixel value PIX.
1894 Note that this does not fully take effect if done before
1897 x_set_border_pixel (f
, pix
)
1901 f
->output_data
.mac
->border_pixel
= pix
;
1903 if (FRAME_MAC_WINDOW (f
) != 0 && f
->border_width
> 0)
1905 if (FRAME_VISIBLE_P (f
))
1910 /* Set the border-color of frame F to value described by ARG.
1911 ARG can be a string naming a color.
1912 The border-color is used for the border that is drawn by the server.
1913 Note that this does not fully take effect if done before
1914 F has a window; it must be redone when the window is created. */
1917 x_set_border_color (f
, arg
, oldval
)
1919 Lisp_Object arg
, oldval
;
1924 pix
= x_decode_color (f
, arg
, BLACK_PIX_DEFAULT (f
));
1925 x_set_border_pixel (f
, pix
);
1926 update_face_from_frame_parameter (f
, Qborder_color
, arg
);
1930 x_set_cursor_type (f
, arg
, oldval
)
1932 Lisp_Object arg
, oldval
;
1934 set_frame_cursor_types (f
, arg
);
1936 /* Make sure the cursor gets redrawn. This is overkill, but how
1937 often do people change cursor types? */
1938 update_mode_lines
++;
1941 #if 0 /* MAC_TODO: really no icon for Mac */
1943 x_set_icon_type (f
, arg
, oldval
)
1945 Lisp_Object arg
, oldval
;
1949 if (NILP (arg
) && NILP (oldval
))
1952 if (STRINGP (arg
) && STRINGP (oldval
)
1953 && EQ (Fstring_equal (oldval
, arg
), Qt
))
1956 if (SYMBOLP (arg
) && SYMBOLP (oldval
) && EQ (arg
, oldval
))
1961 result
= x_bitmap_icon (f
, arg
);
1965 error ("No icon window available");
1970 #endif /* MAC_TODO */
1973 x_set_icon_name (f
, arg
, oldval
)
1975 Lisp_Object arg
, oldval
;
1981 if (STRINGP (oldval
) && EQ (Fstring_equal (oldval
, arg
), Qt
))
1984 else if (!STRINGP (oldval
) && EQ (oldval
, Qnil
) == EQ (arg
, Qnil
))
1989 #if 0 /* MAC_TODO */
1990 if (f
->output_data
.w32
->icon_bitmap
!= 0)
1995 result
= x_text_icon (f
,
1996 (char *) SDATA ((!NILP (f
->icon_name
)
2005 error ("No icon window available");
2008 /* If the window was unmapped (and its icon was mapped),
2009 the new icon is not mapped, so map the window in its stead. */
2010 if (FRAME_VISIBLE_P (f
))
2012 #ifdef USE_X_TOOLKIT
2013 XtPopup (f
->output_data
.w32
->widget
, XtGrabNone
);
2015 XMapWindow (FRAME_W32_DISPLAY (f
), FRAME_W32_WINDOW (f
));
2018 XFlush (FRAME_W32_DISPLAY (f
));
2020 #endif /* MAC_TODO */
2025 x_set_menu_bar_lines (f
, value
, oldval
)
2027 Lisp_Object value
, oldval
;
2030 int olines
= FRAME_MENU_BAR_LINES (f
);
2032 /* Right now, menu bars don't work properly in minibuf-only frames;
2033 most of the commands try to apply themselves to the minibuffer
2034 frame itself, and get an error because you can't switch buffers
2035 in or split the minibuffer window. */
2036 if (FRAME_MINIBUF_ONLY_P (f
))
2039 if (INTEGERP (value
))
2040 nlines
= XINT (value
);
2044 FRAME_MENU_BAR_LINES (f
) = 0;
2046 FRAME_EXTERNAL_MENU_BAR (f
) = 1;
2049 if (FRAME_EXTERNAL_MENU_BAR (f
) == 1)
2050 free_frame_menubar (f
);
2051 FRAME_EXTERNAL_MENU_BAR (f
) = 0;
2053 /* Adjust the frame size so that the client (text) dimensions
2054 remain the same. This depends on FRAME_EXTERNAL_MENU_BAR being
2056 x_set_window_size (f
, 0, FRAME_COLS (f
), FRAME_LINES (f
));
2057 do_pending_window_change (0);
2063 /* Set the number of lines used for the tool bar of frame F to VALUE.
2064 VALUE not an integer, or < 0 means set the lines to zero. OLDVAL
2065 is the old number of tool bar lines. This function changes the
2066 height of all windows on frame F to match the new tool bar height.
2067 The frame's height doesn't change. */
2070 x_set_tool_bar_lines (f
, value
, oldval
)
2072 Lisp_Object value
, oldval
;
2074 int delta
, nlines
, root_height
;
2075 Lisp_Object root_window
;
2077 /* Treat tool bars like menu bars. */
2078 if (FRAME_MINIBUF_ONLY_P (f
))
2081 /* Use VALUE only if an integer >= 0. */
2082 if (INTEGERP (value
) && XINT (value
) >= 0)
2083 nlines
= XFASTINT (value
);
2087 /* Make sure we redisplay all windows in this frame. */
2088 ++windows_or_buffers_changed
;
2090 delta
= nlines
- FRAME_TOOL_BAR_LINES (f
);
2092 /* Don't resize the tool-bar to more than we have room for. */
2093 root_window
= FRAME_ROOT_WINDOW (f
);
2094 root_height
= WINDOW_TOTAL_LINES (XWINDOW (root_window
));
2095 if (root_height
- delta
< 1)
2097 delta
= root_height
- 1;
2098 nlines
= FRAME_TOOL_BAR_LINES (f
) + delta
;
2101 FRAME_TOOL_BAR_LINES (f
) = nlines
;
2102 change_window_heights (root_window
, delta
);
2105 /* We also have to make sure that the internal border at the top of
2106 the frame, below the menu bar or tool bar, is redrawn when the
2107 tool bar disappears. This is so because the internal border is
2108 below the tool bar if one is displayed, but is below the menu bar
2109 if there isn't a tool bar. The tool bar draws into the area
2110 below the menu bar. */
2111 if (FRAME_MAC_WINDOW (f
) && FRAME_TOOL_BAR_LINES (f
) == 0)
2115 clear_current_matrices (f
);
2116 updating_frame
= NULL
;
2119 /* If the tool bar gets smaller, the internal border below it
2120 has to be cleared. It was formerly part of the display
2121 of the larger tool bar, and updating windows won't clear it. */
2124 int height
= FRAME_INTERNAL_BORDER_WIDTH (f
);
2125 int width
= FRAME_PIXEL_WIDTH (f
);
2126 int y
= nlines
* FRAME_LINE_HEIGHT (f
);
2129 XClearArea (FRAME_MAC_DISPLAY (f
), FRAME_MAC_WINDOW (f
),
2130 0, y
, width
, height
, 0);
2133 if (WINDOWP (f
->tool_bar_window
))
2134 clear_glyph_matrix (XWINDOW (f
->tool_bar_window
)->current_matrix
);
2139 /* Change the name of frame F to NAME. If NAME is nil, set F's name to
2142 If EXPLICIT is non-zero, that indicates that lisp code is setting the
2143 name; if NAME is a string, set F's name to NAME and set
2144 F->explicit_name; if NAME is Qnil, then clear F->explicit_name.
2146 If EXPLICIT is zero, that indicates that Emacs redisplay code is
2147 suggesting a new name, which lisp code should override; if
2148 F->explicit_name is set, ignore the new name; otherwise, set it. */
2151 x_set_name (f
, name
, explicit)
2156 /* Make sure that requests from lisp code override requests from
2157 Emacs redisplay code. */
2160 /* If we're switching from explicit to implicit, we had better
2161 update the mode lines and thereby update the title. */
2162 if (f
->explicit_name
&& NILP (name
))
2163 update_mode_lines
= 1;
2165 f
->explicit_name
= ! NILP (name
);
2167 else if (f
->explicit_name
)
2170 /* If NAME is nil, set the name to the w32_id_name. */
2173 /* Check for no change needed in this very common case
2174 before we do any consing. */
2175 if (!strcmp (FRAME_MAC_DISPLAY_INFO (f
)->mac_id_name
,
2178 name
= build_string (FRAME_MAC_DISPLAY_INFO (f
)->mac_id_name
);
2181 CHECK_STRING (name
);
2183 /* Don't change the name if it's already NAME. */
2184 if (! NILP (Fstring_equal (name
, f
->name
)))
2189 /* For setting the frame title, the title parameter should override
2190 the name parameter. */
2191 if (! NILP (f
->title
))
2194 if (FRAME_MAC_WINDOW (f
))
2196 if (STRING_MULTIBYTE (name
))
2197 #if 0 /* MAC_TODO: encoding title string */
2198 name
= ENCODE_SYSTEM (name
);
2207 if (strlen (SDATA (name
)) < 255)
2209 strcpy (windowTitle
, SDATA (name
));
2210 c2pstr (windowTitle
);
2211 SetWTitle (FRAME_MAC_WINDOW (f
), windowTitle
);
2219 /* This function should be called when the user's lisp code has
2220 specified a name for the frame; the name will override any set by the
2223 x_explicitly_set_name (f
, arg
, oldval
)
2225 Lisp_Object arg
, oldval
;
2227 x_set_name (f
, arg
, 1);
2230 /* This function should be called by Emacs redisplay code to set the
2231 name; names set this way will never override names set by the user's
2234 x_implicitly_set_name (f
, arg
, oldval
)
2236 Lisp_Object arg
, oldval
;
2238 x_set_name (f
, arg
, 0);
2241 /* Change the title of frame F to NAME.
2242 If NAME is nil, use the frame name as the title.
2244 If EXPLICIT is non-zero, that indicates that lisp code is setting the
2245 name; if NAME is a string, set F's name to NAME and set
2246 F->explicit_name; if NAME is Qnil, then clear F->explicit_name.
2248 If EXPLICIT is zero, that indicates that Emacs redisplay code is
2249 suggesting a new name, which lisp code should override; if
2250 F->explicit_name is set, ignore the new name; otherwise, set it. */
2253 x_set_title (f
, name
, old_name
)
2255 Lisp_Object name
, old_name
;
2257 /* Don't change the title if it's already NAME. */
2258 if (EQ (name
, f
->title
))
2261 update_mode_lines
= 1;
2268 if (FRAME_MAC_WINDOW (f
))
2270 if (STRING_MULTIBYTE (name
))
2271 #if 0 /* MAC_TODO: encoding title string */
2272 name
= ENCODE_SYSTEM (name
);
2281 if (strlen (SDATA (name
)) < 255)
2283 strcpy (windowTitle
, SDATA (name
));
2284 c2pstr (windowTitle
);
2285 SetWTitle (FRAME_MAC_WINDOW (f
), windowTitle
);
2294 x_set_scroll_bar_default_width (f
)
2297 /* Imitate X without X Toolkit */
2299 int wid
= FRAME_COLUMN_WIDTH (f
);
2302 FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) = 16; /* Aqua scroll bars. */
2303 FRAME_CONFIG_SCROLL_BAR_COLS (f
) = (FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) +
2305 #else /* not MAC_OSX */
2306 /* Make the actual width at least 14 pixels and a multiple of a
2308 FRAME_CONFIG_SCROLL_BAR_COLS (f
) = (14 + wid
- 1) / wid
;
2310 /* Use all of that space (aside from required margins) for the
2312 FRAME_CONFIG_SCROLL_BAR_WIDTH (f
) = 0;
2313 #endif /* not MAC_OSX */
2317 /* Subroutines of creating a frame. */
2320 x_get_string_resource (rdb
, name
, class)
2324 /* MAC_TODO: implement resource strings */
2328 /* Return the value of parameter PARAM.
2330 First search ALIST, then Vdefault_frame_alist, then the X defaults
2331 database, using ATTRIBUTE as the attribute name and CLASS as its class.
2333 Convert the resource to the type specified by desired_type.
2335 If no default is specified, return Qunbound. If you call
2336 mac_get_arg, make sure you deal with Qunbound in a reasonable way,
2337 and don't let it get stored in any Lisp-visible variables! */
2340 mac_get_arg (alist
, param
, attribute
, class, type
)
2341 Lisp_Object alist
, param
;
2344 enum resource_types type
;
2346 return x_get_arg (check_x_display_info (Qnil
),
2347 alist
, param
, attribute
, class, type
);
2351 /* XParseGeometry copied from w32xfns.c */
2354 * XParseGeometry parses strings of the form
2355 * "=<width>x<height>{+-}<xoffset>{+-}<yoffset>", where
2356 * width, height, xoffset, and yoffset are unsigned integers.
2357 * Example: "=80x24+300-49"
2358 * The equal sign is optional.
2359 * It returns a bitmask that indicates which of the four values
2360 * were actually found in the string. For each value found,
2361 * the corresponding argument is updated; for each value
2362 * not found, the corresponding argument is left unchanged.
2366 read_integer (string
, NextString
)
2367 register char *string
;
2370 register int Result
= 0;
2375 else if (*string
== '-')
2380 for (; (*string
>= '0') && (*string
<= '9'); string
++)
2382 Result
= (Result
* 10) + (*string
- '0');
2384 *NextString
= string
;
2392 XParseGeometry (string
, x
, y
, width
, height
)
2395 unsigned int *width
, *height
; /* RETURN */
2398 register char *strind
;
2399 unsigned int tempWidth
, tempHeight
;
2401 char *nextCharacter
;
2403 if ((string
== NULL
) || (*string
== '\0')) return (mask
);
2405 string
++; /* ignore possible '=' at beg of geometry spec */
2407 strind
= (char *)string
;
2408 if (*strind
!= '+' && *strind
!= '-' && *strind
!= 'x')
2410 tempWidth
= read_integer (strind
, &nextCharacter
);
2411 if (strind
== nextCharacter
)
2413 strind
= nextCharacter
;
2417 if (*strind
== 'x' || *strind
== 'X')
2420 tempHeight
= read_integer (strind
, &nextCharacter
);
2421 if (strind
== nextCharacter
)
2423 strind
= nextCharacter
;
2424 mask
|= HeightValue
;
2427 if ((*strind
== '+') || (*strind
== '-'))
2432 tempX
= -read_integer (strind
, &nextCharacter
);
2433 if (strind
== nextCharacter
)
2435 strind
= nextCharacter
;
2442 tempX
= read_integer (strind
, &nextCharacter
);
2443 if (strind
== nextCharacter
)
2445 strind
= nextCharacter
;
2448 if ((*strind
== '+') || (*strind
== '-'))
2453 tempY
= -read_integer (strind
, &nextCharacter
);
2454 if (strind
== nextCharacter
)
2456 strind
= nextCharacter
;
2463 tempY
= read_integer (strind
, &nextCharacter
);
2464 if (strind
== nextCharacter
)
2466 strind
= nextCharacter
;
2472 /* If strind isn't at the end of the string the it's an invalid
2473 geometry specification. */
2475 if (*strind
!= '\0') return (0);
2481 if (mask
& WidthValue
)
2483 if (mask
& HeightValue
)
2484 *height
= tempHeight
;
2489 #if 0 /* MAC_TODO */
2490 /* Create and set up the Mac window for frame F. */
2493 mac_window (f
, window_prompting
, minibuffer_only
)
2495 long window_prompting
;
2496 int minibuffer_only
;
2502 /* Use the resource name as the top-level window name
2503 for looking up resources. Make a non-Lisp copy
2504 for the window manager, so GC relocation won't bother it.
2506 Elsewhere we specify the window name for the window manager. */
2509 char *str
= (char *) SDATA (Vx_resource_name
);
2510 f
->namebuf
= (char *) xmalloc (strlen (str
) + 1);
2511 strcpy (f
->namebuf
, str
);
2514 SetRect (&r
, f
->left_pos
, f
->top_pos
,
2515 f
->left_pos
+ FRAME_PIXEL_WIDTH (f
),
2516 f
->top_pos
+ FRAME_PIXEL_HEIGHT (f
));
2517 FRAME_MAC_WINDOW (f
)
2518 = NewCWindow (NULL
, &r
, "\p", 1, zoomDocProc
, (WindowPtr
) -1, 1, (long) f
->output_data
.mac
);
2520 validate_x_resource_name ();
2522 /* x_set_name normally ignores requests to set the name if the
2523 requested name is the same as the current name. This is the one
2524 place where that assumption isn't correct; f->name is set, but
2525 the server hasn't been told. */
2528 int explicit = f
->explicit_name
;
2530 f
->explicit_name
= 0;
2533 x_set_name (f
, name
, explicit);
2536 ShowWindow (FRAME_MAC_WINDOW (f
));
2540 if (!minibuffer_only
&& FRAME_EXTERNAL_MENU_BAR (f
))
2541 initialize_frame_menubar (f
);
2543 if (FRAME_MAC_WINDOW (f
) == 0)
2544 error ("Unable to create window");
2546 #endif /* MAC_TODO */
2548 /* Handle the icon stuff for this window. Perhaps later we might
2549 want an x_set_icon_position which can be called interactively as
2557 Lisp_Object icon_x
, icon_y
;
2559 /* Set the position of the icon. Note that Windows 95 groups all
2560 icons in the tray. */
2561 icon_x
= mac_get_arg (parms
, Qicon_left
, 0, 0, RES_TYPE_NUMBER
);
2562 icon_y
= mac_get_arg (parms
, Qicon_top
, 0, 0, RES_TYPE_NUMBER
);
2563 if (!EQ (icon_x
, Qunbound
) && !EQ (icon_y
, Qunbound
))
2565 CHECK_NUMBER (icon_x
);
2566 CHECK_NUMBER (icon_y
);
2568 else if (!EQ (icon_x
, Qunbound
) || !EQ (icon_y
, Qunbound
))
2569 error ("Both left and top icon corners of icon must be specified");
2573 if (! EQ (icon_x
, Qunbound
))
2574 x_wm_set_icon_position (f
, XINT (icon_x
), XINT (icon_y
));
2577 /* Start up iconic or window? */
2578 x_wm_set_window_state
2579 (f
, (EQ (w32_get_arg (parms
, Qvisibility
, 0, 0, RES_TYPE_SYMBOL
), Qicon
)
2583 x_text_icon (f
, (char *) SDATA ((!NILP (f
->icon_name
)
2596 XGCValues gc_values
;
2600 /* Create the GC's of this frame.
2601 Note that many default values are used. */
2604 gc_values
.font
= FRAME_FONT (f
);
2605 gc_values
.foreground
= FRAME_FOREGROUND_PIXEL (f
);
2606 gc_values
.background
= FRAME_BACKGROUND_PIXEL (f
);
2607 f
->output_data
.mac
->normal_gc
= XCreateGC (FRAME_MAC_DISPLAY (f
),
2608 FRAME_MAC_WINDOW (f
),
2609 GCFont
| GCForeground
| GCBackground
,
2612 /* Reverse video style. */
2613 gc_values
.foreground
= FRAME_BACKGROUND_PIXEL (f
);
2614 gc_values
.background
= FRAME_FOREGROUND_PIXEL (f
);
2615 f
->output_data
.mac
->reverse_gc
= XCreateGC (FRAME_MAC_DISPLAY (f
),
2616 FRAME_MAC_WINDOW (f
),
2617 GCFont
| GCForeground
| GCBackground
,
2620 /* Cursor has cursor-color background, background-color foreground. */
2621 gc_values
.foreground
= FRAME_BACKGROUND_PIXEL (f
);
2622 gc_values
.background
= f
->output_data
.mac
->cursor_pixel
;
2623 f
->output_data
.mac
->cursor_gc
= XCreateGC (FRAME_MAC_DISPLAY (f
),
2624 FRAME_MAC_WINDOW (f
),
2625 GCFont
| GCForeground
| GCBackground
,
2629 f
->output_data
.mac
->white_relief
.gc
= 0;
2630 f
->output_data
.mac
->black_relief
.gc
= 0;
2636 DEFUN ("x-create-frame", Fx_create_frame
, Sx_create_frame
,
2638 doc
: /* Make a new window, which is called a \"frame\" in Emacs terms.
2639 Returns an Emacs frame object.
2640 ALIST is an alist of frame parameters.
2641 If the parameters specify that the frame should not have a minibuffer,
2642 and do not specify a specific minibuffer window to use,
2643 then `default-minibuffer-frame' must be a frame whose minibuffer can
2644 be shared by the new frame.
2646 This function is an internal primitive--use `make-frame' instead. */)
2651 Lisp_Object frame
, tem
;
2653 int minibuffer_only
= 0;
2654 long window_prompting
= 0;
2656 int count
= SPECPDL_INDEX ();
2657 struct gcpro gcpro1
, gcpro2
, gcpro3
, gcpro4
;
2658 Lisp_Object display
;
2659 struct mac_display_info
*dpyinfo
= NULL
;
2662 char x_frame_name
[10];
2663 static int x_frame_count
= 2; /* begins at 2 because terminal frame is F1 */
2667 /* Use this general default value to start with
2668 until we know if this frame has a specified name. */
2669 Vx_resource_name
= Vinvocation_name
;
2671 display
= mac_get_arg (parms
, Qdisplay
, 0, 0, RES_TYPE_STRING
);
2672 if (EQ (display
, Qunbound
))
2674 dpyinfo
= check_x_display_info (display
);
2676 kb
= dpyinfo
->kboard
;
2678 kb
= &the_only_kboard
;
2681 name
= mac_get_arg (parms
, Qname
, "name", "Name", RES_TYPE_STRING
);
2683 && ! EQ (name
, Qunbound
)
2685 error ("Invalid frame name--not a string or nil");
2688 Vx_resource_name
= name
;
2690 /* See if parent window is specified. */
2691 parent
= mac_get_arg (parms
, Qparent_id
, NULL
, NULL
, RES_TYPE_NUMBER
);
2692 if (EQ (parent
, Qunbound
))
2694 if (! NILP (parent
))
2695 CHECK_NUMBER (parent
);
2697 /* make_frame_without_minibuffer can run Lisp code and garbage collect. */
2698 /* No need to protect DISPLAY because that's not used after passing
2699 it to make_frame_without_minibuffer. */
2701 GCPRO4 (parms
, parent
, name
, frame
);
2702 tem
= mac_get_arg (parms
, Qminibuffer
, "minibuffer", "Minibuffer",
2704 if (EQ (tem
, Qnone
) || NILP (tem
))
2705 f
= make_frame_without_minibuffer (Qnil
, kb
, display
);
2706 else if (EQ (tem
, Qonly
))
2708 f
= make_minibuffer_frame ();
2709 minibuffer_only
= 1;
2711 else if (WINDOWP (tem
))
2712 f
= make_frame_without_minibuffer (tem
, kb
, display
);
2716 if (EQ (name
, Qunbound
) || NILP (name
))
2718 sprintf (x_frame_name
, "F%d", x_frame_count
++);
2719 f
->name
= build_string (x_frame_name
);
2720 f
->explicit_name
= 0;
2725 f
->explicit_name
= 1;
2728 XSETFRAME (frame
, f
);
2730 /* Note that X Windows does support scroll bars. */
2731 FRAME_CAN_HAVE_SCROLL_BARS (f
) = 1;
2733 f
->output_method
= output_mac
;
2734 f
->output_data
.mac
= (struct mac_output
*) xmalloc (sizeof (struct mac_output
));
2735 bzero (f
->output_data
.mac
, sizeof (struct mac_output
));
2736 FRAME_FONTSET (f
) = -1;
2737 f
->output_data
.mac
->scroll_bar_foreground_pixel
= -1;
2738 f
->output_data
.mac
->scroll_bar_background_pixel
= -1;
2741 FRAME_FONTSET (f
) = -1;
2745 = mac_get_arg (parms
, Qicon_name
, "iconName", "Title", RES_TYPE_STRING
);
2746 if (! STRINGP (f
->icon_name
))
2747 f
->icon_name
= Qnil
;
2749 /* FRAME_W32_DISPLAY_INFO (f) = dpyinfo; */
2751 FRAME_KBOARD (f
) = kb
;
2754 /* Specify the parent under which to make this window. */
2758 f
->output_data
.mac
->parent_desc
= (Window
) parent
;
2759 f
->output_data
.mac
->explicit_parent
= 1;
2763 f
->output_data
.mac
->parent_desc
= FRAME_MAC_DISPLAY_INFO (f
)->root_window
;
2764 f
->output_data
.mac
->explicit_parent
= 0;
2767 /* Set the name; the functions to which we pass f expect the name to
2769 if (EQ (name
, Qunbound
) || NILP (name
))
2771 f
->name
= build_string (dpyinfo
->mac_id_name
);
2772 f
->explicit_name
= 0;
2777 f
->explicit_name
= 1;
2778 /* use the frame's title when getting resources for this frame. */
2779 specbind (Qx_resource_name
, name
);
2782 /* Extract the window parameters from the supplied values
2783 that are needed to determine window geometry. */
2787 font
= mac_get_arg (parms
, Qfont
, "font", "Font", RES_TYPE_STRING
);
2790 /* First, try whatever font the caller has specified. */
2793 tem
= Fquery_fontset (font
, Qnil
);
2795 font
= x_new_fontset (f
, SDATA (tem
));
2797 font
= x_new_font (f
, SDATA (font
));
2799 /* Try out a font which we hope has bold and italic variations. */
2800 if (! STRINGP (font
))
2801 font
= x_new_font (f
, "-ETL-fixed-medium-r-*--*-160-*-*-*-*-iso8859-1");
2802 /* If those didn't work, look for something which will at least work. */
2803 if (!STRINGP (font
))
2804 font
= x_new_font (f
, "-*-monaco-*-12-*-mac-roman");
2805 if (! STRINGP (font
))
2806 font
= x_new_font (f
, "-*-courier-*-10-*-mac-roman");
2807 if (! STRINGP (font
))
2808 error ("Cannot find any usable font");
2811 x_default_parameter (f
, parms
, Qfont
, font
,
2812 "font", "Font", RES_TYPE_STRING
);
2815 x_default_parameter (f
, parms
, Qborder_width
, make_number (0),
2816 "borderwidth", "BorderWidth", RES_TYPE_NUMBER
);
2817 /* This defaults to 2 in order to match xterm. We recognize either
2818 internalBorderWidth or internalBorder (which is what xterm calls
2820 if (NILP (Fassq (Qinternal_border_width
, parms
)))
2824 value
= mac_get_arg (parms
, Qinternal_border_width
,
2825 "internalBorder", "InternalBorder", RES_TYPE_NUMBER
);
2826 if (! EQ (value
, Qunbound
))
2827 parms
= Fcons (Fcons (Qinternal_border_width
, value
),
2830 /* Default internalBorderWidth to 0 on Windows to match other programs. */
2831 x_default_parameter (f
, parms
, Qinternal_border_width
, make_number (0),
2832 "internalBorderWidth", "InternalBorder", RES_TYPE_NUMBER
);
2833 x_default_parameter (f
, parms
, Qvertical_scroll_bars
, Qright
,
2834 "verticalScrollBars", "ScrollBars", RES_TYPE_SYMBOL
);
2836 /* Also do the stuff which must be set before the window exists. */
2837 x_default_parameter (f
, parms
, Qforeground_color
, build_string ("black"),
2838 "foreground", "Foreground", RES_TYPE_STRING
);
2839 x_default_parameter (f
, parms
, Qbackground_color
, build_string ("white"),
2840 "background", "Background", RES_TYPE_STRING
);
2841 x_default_parameter (f
, parms
, Qmouse_color
, build_string ("black"),
2842 "pointerColor", "Foreground", RES_TYPE_STRING
);
2843 x_default_parameter (f
, parms
, Qcursor_color
, build_string ("black"),
2844 "cursorColor", "Foreground", RES_TYPE_STRING
);
2845 x_default_parameter (f
, parms
, Qborder_color
, build_string ("black"),
2846 "borderColor", "BorderColor", RES_TYPE_STRING
);
2847 x_default_parameter (f
, parms
, Qscreen_gamma
, Qnil
,
2848 "screenGamma", "ScreenGamma", RES_TYPE_FLOAT
);
2849 x_default_parameter (f
, parms
, Qline_spacing
, Qnil
,
2850 "lineSpacing", "LineSpacing", RES_TYPE_NUMBER
);
2851 x_default_parameter (f
, parms
, Qleft_fringe
, Qnil
,
2852 "leftFringe", "LeftFringe", RES_TYPE_NUMBER
);
2853 x_default_parameter (f
, parms
, Qright_fringe
, Qnil
,
2854 "rightFringe", "RightFringe", RES_TYPE_NUMBER
);
2857 /* Init faces before x_default_parameter is called for scroll-bar
2858 parameters because that function calls x_set_scroll_bar_width,
2859 which calls change_frame_size, which calls Fset_window_buffer,
2860 which runs hooks, which call Fvertical_motion. At the end, we
2861 end up in init_iterator with a null face cache, which should not
2863 init_frame_faces (f
);
2865 x_default_parameter (f
, parms
, Qmenu_bar_lines
, make_number (1),
2866 "menuBar", "MenuBar", RES_TYPE_NUMBER
);
2867 x_default_parameter (f
, parms
, Qtool_bar_lines
, make_number (0),
2868 "toolBar", "ToolBar", RES_TYPE_NUMBER
);
2869 x_default_parameter (f
, parms
, Qbuffer_predicate
, Qnil
,
2870 "bufferPredicate", "BufferPredicate", RES_TYPE_SYMBOL
);
2871 x_default_parameter (f
, parms
, Qtitle
, Qnil
,
2872 "title", "Title", RES_TYPE_STRING
);
2874 f
->output_data
.mac
->parent_desc
= FRAME_MAC_DISPLAY_INFO (f
)->root_window
;
2876 /* MAC_TODO: specify 1 below when toolbars are implemented. */
2877 window_prompting
= x_figure_window_size (f
, parms
, 0);
2879 tem
= mac_get_arg (parms
, Qunsplittable
, 0, 0, RES_TYPE_BOOLEAN
);
2880 f
->no_split
= minibuffer_only
|| EQ (tem
, Qt
);
2882 /* Create the window. Add the tool-bar height to the initial frame
2883 height so that the user gets a text display area of the size he
2884 specified with -g or via the registry. Later changes of the
2885 tool-bar height don't change the frame size. This is done so that
2886 users can create tall Emacs frames without having to guess how
2887 tall the tool-bar will get. */
2888 FRAME_LINES (f
) += FRAME_TOOL_BAR_LINES (f
);
2890 /* mac_window (f, window_prompting, minibuffer_only); */
2897 /* Now consider the frame official. */
2898 FRAME_MAC_DISPLAY_INFO (f
)->reference_count
++;
2899 Vframe_list
= Fcons (frame
, Vframe_list
);
2901 /* We need to do this after creating the window, so that the
2902 icon-creation functions can say whose icon they're describing. */
2903 x_default_parameter (f
, parms
, Qicon_type
, Qnil
,
2904 "bitmapIcon", "BitmapIcon", RES_TYPE_SYMBOL
);
2906 x_default_parameter (f
, parms
, Qauto_raise
, Qnil
,
2907 "autoRaise", "AutoRaiseLower", RES_TYPE_BOOLEAN
);
2908 x_default_parameter (f
, parms
, Qauto_lower
, Qnil
,
2909 "autoLower", "AutoRaiseLower", RES_TYPE_BOOLEAN
);
2910 x_default_parameter (f
, parms
, Qcursor_type
, Qbox
,
2911 "cursorType", "CursorType", RES_TYPE_SYMBOL
);
2912 x_default_parameter (f
, parms
, Qscroll_bar_width
, Qnil
,
2913 "scrollBarWidth", "ScrollBarWidth", RES_TYPE_NUMBER
);
2915 /* Dimensions, especially FRAME_LINES (f), must be done via change_frame_size.
2916 Change will not be effected unless different from the current
2918 width
= FRAME_COLS (f
);
2919 height
= FRAME_LINES (f
);
2921 FRAME_LINES (f
) = 0;
2922 SET_FRAME_COLS (f
, 0);
2923 change_frame_size (f
, height
, width
, 1, 0, 0);
2925 /* Set up faces after all frame parameters are known. */
2926 call1 (Qface_set_after_frame_default
, frame
);
2928 #if 0 /* MAC_TODO: when we have window manager hints */
2929 /* Tell the server what size and position, etc, we want, and how
2930 badly we want them. This should be done after we have the menu
2931 bar so that its size can be taken into account. */
2933 x_wm_set_size_hint (f
, window_prompting
, 0);
2937 /* Make the window appear on the frame and enable display, unless
2938 the caller says not to. However, with explicit parent, Emacs
2939 cannot control visibility, so don't try. */
2940 if (! f
->output_data
.mac
->explicit_parent
)
2942 Lisp_Object visibility
;
2944 visibility
= mac_get_arg (parms
, Qvisibility
, 0, 0, RES_TYPE_SYMBOL
);
2945 if (EQ (visibility
, Qunbound
))
2948 #if 0 /* MAC_TODO: really no iconify on Mac */
2949 if (EQ (visibility
, Qicon
))
2950 x_iconify_frame (f
);
2953 if (! NILP (visibility
))
2954 x_make_frame_visible (f
);
2956 /* Must have been Qnil. */
2961 /* Make sure windows on this frame appear in calls to next-window
2962 and similar functions. */
2963 Vwindow_list
= Qnil
;
2965 return unbind_to (count
, frame
);
2968 /* FRAME is used only to get a handle on the X display. We don't pass the
2969 display info directly because we're called from frame.c, which doesn't
2970 know about that structure. */
2972 x_get_focus_frame (frame
)
2973 struct frame
*frame
;
2975 struct mac_display_info
*dpyinfo
= FRAME_MAC_DISPLAY_INFO (frame
);
2977 if (! dpyinfo
->x_focus_frame
)
2980 XSETFRAME (xfocus
, dpyinfo
->x_focus_frame
);
2984 DEFUN ("xw-color-defined-p", Fxw_color_defined_p
, Sxw_color_defined_p
, 1, 2, 0,
2985 doc
: /* Internal function called by `color-defined-p', which see. */)
2987 Lisp_Object color
, frame
;
2990 FRAME_PTR f
= check_x_frame (frame
);
2992 CHECK_STRING (color
);
2994 if (mac_defined_color (f
, SDATA (color
), &foo
, 0))
3000 DEFUN ("xw-color-values", Fxw_color_values
, Sxw_color_values
, 1, 2, 0,
3001 doc
: /* Internal function called by `color-values', which see. */)
3003 Lisp_Object color
, frame
;
3006 FRAME_PTR f
= check_x_frame (frame
);
3008 CHECK_STRING (color
);
3010 if (mac_defined_color (f
, SDATA (color
), &foo
, 0))
3014 rgb
[0] = make_number ((RED_FROM_ULONG (foo
.pixel
) << 8)
3015 | RED_FROM_ULONG (foo
.pixel
));
3016 rgb
[1] = make_number ((GREEN_FROM_ULONG (foo
.pixel
) << 8)
3017 | GREEN_FROM_ULONG (foo
.pixel
));
3018 rgb
[2] = make_number ((BLUE_FROM_ULONG (foo
.pixel
) << 8)
3019 | BLUE_FROM_ULONG (foo
.pixel
));
3020 return Flist (3, rgb
);
3026 DEFUN ("xw-display-color-p", Fxw_display_color_p
, Sxw_display_color_p
, 0, 1, 0,
3027 doc
: /* Internal function called by `display-color-p', which see. */)
3029 Lisp_Object display
;
3031 struct mac_display_info
*dpyinfo
= check_x_display_info (display
);
3033 if ((dpyinfo
->n_planes
* dpyinfo
->n_cbits
) <= 2)
3039 DEFUN ("x-display-grayscale-p", Fx_display_grayscale_p
, Sx_display_grayscale_p
,
3041 doc
: /* Return t if the X display supports shades of gray.
3042 Note that color displays do support shades of gray.
3043 The optional argument DISPLAY specifies which display to ask about.
3044 DISPLAY should be either a frame or a display name (a string).
3045 If omitted or nil, that stands for the selected frame's display. */)
3047 Lisp_Object display
;
3049 struct mac_display_info
*dpyinfo
= check_x_display_info (display
);
3051 if ((dpyinfo
->n_planes
* dpyinfo
->n_cbits
) <= 1)
3057 DEFUN ("x-display-pixel-width", Fx_display_pixel_width
, Sx_display_pixel_width
,
3059 doc
: /* Returns the width in pixels of the X display DISPLAY.
3060 The optional argument DISPLAY specifies which display to ask about.
3061 DISPLAY should be either a frame or a display name (a string).
3062 If omitted or nil, that stands for the selected frame's display. */)
3064 Lisp_Object display
;
3066 struct mac_display_info
*dpyinfo
= check_x_display_info (display
);
3068 return make_number (dpyinfo
->width
);
3071 DEFUN ("x-display-pixel-height", Fx_display_pixel_height
,
3072 Sx_display_pixel_height
, 0, 1, 0,
3073 doc
: /* Returns the height in pixels of the X display DISPLAY.
3074 The optional argument DISPLAY specifies which display to ask about.
3075 DISPLAY should be either a frame or a display name (a string).
3076 If omitted or nil, that stands for the selected frame's display. */)
3078 Lisp_Object display
;
3080 struct mac_display_info
*dpyinfo
= check_x_display_info (display
);
3082 return make_number (dpyinfo
->height
);
3085 DEFUN ("x-display-planes", Fx_display_planes
, Sx_display_planes
,
3087 doc
: /* Returns the number of bitplanes of the display DISPLAY.
3088 The optional argument DISPLAY specifies which display to ask about.
3089 DISPLAY should be either a frame or a display name (a string).
3090 If omitted or nil, that stands for the selected frame's display. */)
3092 Lisp_Object display
;
3094 struct mac_display_info
*dpyinfo
= check_x_display_info (display
);
3096 return make_number (dpyinfo
->n_planes
* dpyinfo
->n_cbits
);
3099 DEFUN ("x-display-color-cells", Fx_display_color_cells
, Sx_display_color_cells
,
3101 doc
: /* Returns the number of color cells of the display DISPLAY.
3102 The optional argument DISPLAY specifies which display to ask about.
3103 DISPLAY should be either a frame or a display name (a string).
3104 If omitted or nil, that stands for the selected frame's display. */)
3106 Lisp_Object display
;
3108 struct mac_display_info
*dpyinfo
= check_x_display_info (display
);
3110 /* MAC_TODO: check whether this is right */
3111 return make_number ((unsigned long) (pow (2, dpyinfo
->n_cbits
)));
3114 DEFUN ("x-server-max-request-size", Fx_server_max_request_size
,
3115 Sx_server_max_request_size
,
3117 doc
: /* Returns the maximum request size of the server of display DISPLAY.
3118 The optional argument DISPLAY specifies which display to ask about.
3119 DISPLAY should be either a frame or a display name (a string).
3120 If omitted or nil, that stands for the selected frame's display. */)
3122 Lisp_Object display
;
3124 struct mac_display_info
*dpyinfo
= check_x_display_info (display
);
3126 return make_number (1);
3129 DEFUN ("x-server-vendor", Fx_server_vendor
, Sx_server_vendor
, 0, 1, 0,
3130 doc
: /* Returns the vendor ID string of the Mac OS system (Apple).
3131 The optional argument DISPLAY specifies which display to ask about.
3132 DISPLAY should be either a frame or a display name (a string).
3133 If omitted or nil, that stands for the selected frame's display. */)
3135 Lisp_Object display
;
3137 return build_string ("Apple Computers");
3140 DEFUN ("x-server-version", Fx_server_version
, Sx_server_version
, 0, 1, 0,
3141 doc
: /* Returns the version numbers of the server of display DISPLAY.
3142 The value is a list of three integers: the major and minor
3143 version numbers, and the vendor-specific release
3144 number. See also the function `x-server-vendor'.
3146 The optional argument DISPLAY specifies which display to ask about.
3147 DISPLAY should be either a frame or a display name (a string).
3148 If omitted or nil, that stands for the selected frame's display. */)
3150 Lisp_Object display
;
3152 int mac_major_version
, mac_minor_version
;
3155 if (Gestalt (gestaltSystemVersion
, &response
) != noErr
)
3156 error ("Cannot get Mac OS version");
3158 mac_major_version
= (response
>> 8) & 0xf;
3159 mac_minor_version
= (response
>> 4) & 0xf;
3161 return Fcons (make_number (mac_major_version
),
3162 Fcons (make_number (mac_minor_version
), Qnil
));
3165 DEFUN ("x-display-screens", Fx_display_screens
, Sx_display_screens
, 0, 1, 0,
3166 doc
: /* Return the number of screens on the server of display DISPLAY.
3167 The optional argument DISPLAY specifies which display to ask about.
3168 DISPLAY should be either a frame or a display name (a string).
3169 If omitted or nil, that stands for the selected frame's display. */)
3171 Lisp_Object display
;
3173 return make_number (1);
3176 DEFUN ("x-display-mm-height", Fx_display_mm_height
, Sx_display_mm_height
, 0, 1, 0,
3177 doc
: /* Return the height in millimeters of the X display DISPLAY.
3178 The optional argument DISPLAY specifies which display to ask about.
3179 DISPLAY should be either a frame or a display name (a string).
3180 If omitted or nil, that stands for the selected frame's display. */)
3182 Lisp_Object display
;
3184 /* MAC_TODO: this is an approximation, and only of the main display */
3186 struct mac_display_info
*dpyinfo
= check_x_display_info (display
);
3191 return make_number ((int) (v
/ 72.0 * 25.4));
3194 DEFUN ("x-display-mm-width", Fx_display_mm_width
, Sx_display_mm_width
, 0, 1, 0,
3195 doc
: /* Return the width in millimeters of the X display DISPLAY.
3196 The optional argument DISPLAY specifies which display to ask about.
3197 DISPLAY should be either a frame or a display name (a string).
3198 If omitted or nil, that stands for the selected frame's display. */)
3200 Lisp_Object display
;
3202 /* MAC_TODO: this is an approximation, and only of the main display */
3204 struct mac_display_info
*dpyinfo
= check_x_display_info (display
);
3209 return make_number ((int) (h
/ 72.0 * 25.4));
3212 DEFUN ("x-display-backing-store", Fx_display_backing_store
,
3213 Sx_display_backing_store
, 0, 1, 0,
3214 doc
: /* Returns an indication of whether display DISPLAY does backing store.
3215 The value may be `always', `when-mapped', or `not-useful'.
3216 The optional argument DISPLAY specifies which display to ask about.
3217 DISPLAY should be either a frame or a display name (a string).
3218 If omitted or nil, that stands for the selected frame's display. */)
3220 Lisp_Object display
;
3222 return intern ("not-useful");
3225 DEFUN ("x-display-visual-class", Fx_display_visual_class
,
3226 Sx_display_visual_class
, 0, 1, 0,
3227 doc
: /* Returns the visual class of the display DISPLAY.
3228 The value is one of the symbols `static-gray', `gray-scale',
3229 `static-color', `pseudo-color', `true-color', or `direct-color'.
3231 The optional argument DISPLAY specifies which display to ask about.
3232 DISPLAY should be either a frame or a display name (a string).
3233 If omitted or nil, that stands for the selected frame's display. */)
3235 Lisp_Object display
;
3237 struct mac_display_info
*dpyinfo
= check_x_display_info (display
);
3240 switch (dpyinfo
->visual
->class)
3242 case StaticGray
: return (intern ("static-gray"));
3243 case GrayScale
: return (intern ("gray-scale"));
3244 case StaticColor
: return (intern ("static-color"));
3245 case PseudoColor
: return (intern ("pseudo-color"));
3246 case TrueColor
: return (intern ("true-color"));
3247 case DirectColor
: return (intern ("direct-color"));
3249 error ("Display has an unknown visual class");
3253 return (intern ("true-color"));
3256 DEFUN ("x-display-save-under", Fx_display_save_under
,
3257 Sx_display_save_under
, 0, 1, 0,
3258 doc
: /* Returns t if the display DISPLAY supports the save-under feature.
3259 The optional argument DISPLAY specifies which display to ask about.
3260 DISPLAY should be either a frame or a display name (a string).
3261 If omitted or nil, that stands for the selected frame's display. */)
3263 Lisp_Object display
;
3270 register struct frame
*f
;
3272 return FRAME_PIXEL_WIDTH (f
);
3277 register struct frame
*f
;
3279 return FRAME_PIXEL_HEIGHT (f
);
3284 register struct frame
*f
;
3286 return FRAME_COLUMN_WIDTH (f
);
3291 register struct frame
*f
;
3293 return FRAME_LINE_HEIGHT (f
);
3298 register struct frame
*f
;
3300 return FRAME_MAC_DISPLAY_INFO (f
)->n_planes
;
3303 /* Return the display structure for the display named NAME.
3304 Open a new connection if necessary. */
3306 struct mac_display_info
*
3307 x_display_info_for_name (name
)
3311 struct mac_display_info
*dpyinfo
;
3313 CHECK_STRING (name
);
3315 for (dpyinfo
= &one_mac_display_info
, names
= x_display_name_list
;
3317 dpyinfo
= dpyinfo
->next
, names
= XCDR (names
))
3320 tem
= Fstring_equal (XCAR (XCAR (names
)), name
);
3325 /* Use this general default value to start with. */
3326 Vx_resource_name
= Vinvocation_name
;
3328 validate_x_resource_name ();
3330 dpyinfo
= mac_term_init (name
, (unsigned char *) 0,
3331 (char *) SDATA (Vx_resource_name
));
3334 error ("Cannot connect to server %s", SDATA (name
));
3337 XSETFASTINT (Vwindow_system_version
, 3);
3342 #if 0 /* MAC_TODO: implement network support */
3343 DEFUN ("x-open-connection", Fx_open_connection
, Sx_open_connection
,
3345 doc
: /* Open a connection to a server.
3346 DISPLAY is the name of the display to connect to.
3347 Optional second arg XRM-STRING is a string of resources in xrdb format.
3348 If the optional third arg MUST-SUCCEED is non-nil,
3349 terminate Emacs if we can't open the connection. */)
3350 (display
, xrm_string
, must_succeed
)
3351 Lisp_Object display
, xrm_string
, must_succeed
;
3353 unsigned char *xrm_option
;
3354 struct mac_display_info
*dpyinfo
;
3356 CHECK_STRING (display
);
3357 if (! NILP (xrm_string
))
3358 CHECK_STRING (xrm_string
);
3360 if (! EQ (Vwindow_system
, intern ("mac")))
3361 error ("Not using Mac OS");
3363 if (! NILP (xrm_string
))
3364 xrm_option
= (unsigned char *) SDATA (xrm_string
);
3366 xrm_option
= (unsigned char *) 0;
3368 validate_x_resource_name ();
3370 /* This is what opens the connection and sets x_current_display.
3371 This also initializes many symbols, such as those used for input. */
3372 dpyinfo
= mac_term_init (display
, xrm_option
,
3373 (char *) SDATA (Vx_resource_name
));
3377 if (!NILP (must_succeed
))
3378 fatal ("Cannot connect to server %s.\n",
3381 error ("Cannot connect to server %s", SDATA (display
));
3386 XSETFASTINT (Vwindow_system_version
, 3);
3390 DEFUN ("x-close-connection", Fx_close_connection
,
3391 Sx_close_connection
, 1, 1, 0,
3392 doc
: /* Close the connection to DISPLAY's server.
3393 For DISPLAY, specify either a frame or a display name (a string).
3394 If DISPLAY is nil, that stands for the selected frame's display. */)
3396 Lisp_Object display
;
3398 struct mac_display_info
*dpyinfo
= check_x_display_info (display
);
3401 if (dpyinfo
->reference_count
> 0)
3402 error ("Display still has frames on it");
3405 /* Free the fonts in the font table. */
3406 for (i
= 0; i
< dpyinfo
->n_fonts
; i
++)
3407 if (dpyinfo
->font_table
[i
].name
)
3409 if (dpyinfo
->font_table
[i
].name
!= dpyinfo
->font_table
[i
].full_name
)
3410 xfree (dpyinfo
->font_table
[i
].full_name
);
3411 xfree (dpyinfo
->font_table
[i
].name
);
3412 x_unload_font (dpyinfo
, dpyinfo
->font_table
[i
].font
);
3414 x_destroy_all_bitmaps (dpyinfo
);
3416 x_delete_display (dpyinfo
);
3423 DEFUN ("x-display-list", Fx_display_list
, Sx_display_list
, 0, 0, 0,
3424 doc
: /* Return the list of display names that Emacs has connections to. */)
3427 Lisp_Object tail
, result
;
3430 for (tail
= x_display_name_list
; ! NILP (tail
); tail
= XCDR (tail
))
3431 result
= Fcons (XCAR (XCAR (tail
)), result
);
3436 DEFUN ("x-synchronize", Fx_synchronize
, Sx_synchronize
, 1, 2, 0,
3437 doc
: /* If ON is non-nil, report errors as soon as the erring request is made.
3438 If ON is nil, allow buffering of requests.
3439 This is a noop on Mac OS systems.
3440 The optional second argument DISPLAY specifies which display to act on.
3441 DISPLAY should be either a frame or a display name (a string).
3442 If DISPLAY is omitted or nil, that stands for the selected frame's display. */)
3444 Lisp_Object display
, on
;
3450 /***********************************************************************
3452 ***********************************************************************/
3454 /* Value is the number of elements of vector VECTOR. */
3456 #define DIM(VECTOR) (sizeof (VECTOR) / sizeof *(VECTOR))
3458 /* List of supported image types. Use define_image_type to add new
3459 types. Use lookup_image_type to find a type for a given symbol. */
3461 static struct image_type
*image_types
;
3463 /* The symbol `image' which is the car of the lists used to represent
3466 extern Lisp_Object Qimage
;
3468 /* The symbol `xbm' which is used as the type symbol for XBM images. */
3474 extern Lisp_Object QCwidth
, QCheight
, QCforeground
, QCbackground
, QCfile
;
3475 extern Lisp_Object QCdata
, QCtype
;
3476 Lisp_Object QCascent
, QCmargin
, QCrelief
;
3477 Lisp_Object QCconversion
, QCcolor_symbols
, QCheuristic_mask
;
3478 Lisp_Object QCindex
;
3480 /* Other symbols. */
3482 Lisp_Object Qlaplace
;
3484 /* Time in seconds after which images should be removed from the cache
3485 if not displayed. */
3487 Lisp_Object Vimage_cache_eviction_delay
;
3489 /* Function prototypes. */
3491 static void define_image_type
P_ ((struct image_type
*type
));
3492 static struct image_type
*lookup_image_type
P_ ((Lisp_Object symbol
));
3493 static void image_error
P_ ((char *format
, Lisp_Object
, Lisp_Object
));
3494 static void x_laplace
P_ ((struct frame
*, struct image
*));
3495 static int x_build_heuristic_mask
P_ ((struct frame
*, struct image
*,
3499 /* Define a new image type from TYPE. This adds a copy of TYPE to
3500 image_types and adds the symbol *TYPE->type to Vimage_types. */
3503 define_image_type (type
)
3504 struct image_type
*type
;
3506 /* Make a copy of TYPE to avoid a bus error in a dumped Emacs.
3507 The initialized data segment is read-only. */
3508 struct image_type
*p
= (struct image_type
*) xmalloc (sizeof *p
);
3509 bcopy (type
, p
, sizeof *p
);
3510 p
->next
= image_types
;
3512 Vimage_types
= Fcons (*p
->type
, Vimage_types
);
3516 /* Look up image type SYMBOL, and return a pointer to its image_type
3517 structure. Value is null if SYMBOL is not a known image type. */
3519 static INLINE
struct image_type
*
3520 lookup_image_type (symbol
)
3523 struct image_type
*type
;
3525 for (type
= image_types
; type
; type
= type
->next
)
3526 if (EQ (symbol
, *type
->type
))
3533 /* Value is non-zero if OBJECT is a valid Lisp image specification. A
3534 valid image specification is a list whose car is the symbol
3535 `image', and whose rest is a property list. The property list must
3536 contain a value for key `:type'. That value must be the name of a
3537 supported image type. The rest of the property list depends on the
3541 valid_image_p (object
)
3546 if (CONSP (object
) && EQ (XCAR (object
), Qimage
))
3548 Lisp_Object symbol
= Fplist_get (XCDR (object
), QCtype
);
3549 struct image_type
*type
= lookup_image_type (symbol
);
3552 valid_p
= type
->valid_p (object
);
3559 /* Log error message with format string FORMAT and argument ARG.
3560 Signaling an error, e.g. when an image cannot be loaded, is not a
3561 good idea because this would interrupt redisplay, and the error
3562 message display would lead to another redisplay. This function
3563 therefore simply displays a message. */
3566 image_error (format
, arg1
, arg2
)
3568 Lisp_Object arg1
, arg2
;
3570 add_to_log (format
, arg1
, arg2
);
3575 /***********************************************************************
3576 Image specifications
3577 ***********************************************************************/
3579 enum image_value_type
3581 IMAGE_DONT_CHECK_VALUE_TYPE
,
3584 IMAGE_POSITIVE_INTEGER_VALUE
,
3585 IMAGE_POSITIVE_INTEGER_VALUE_OR_PAIR
,
3586 IMAGE_NON_NEGATIVE_INTEGER_VALUE
,
3588 IMAGE_INTEGER_VALUE
,
3589 IMAGE_FUNCTION_VALUE
,
3594 /* Structure used when parsing image specifications. */
3596 struct image_keyword
3598 /* Name of keyword. */
3601 /* The type of value allowed. */
3602 enum image_value_type type
;
3604 /* Non-zero means key must be present. */
3607 /* Used to recognize duplicate keywords in a property list. */
3610 /* The value that was found. */
3615 static int parse_image_spec
P_ ((Lisp_Object
, struct image_keyword
*,
3617 static Lisp_Object image_spec_value
P_ ((Lisp_Object
, Lisp_Object
, int *));
3620 /* Parse image spec SPEC according to KEYWORDS. A valid image spec
3621 has the format (image KEYWORD VALUE ...). One of the keyword/
3622 value pairs must be `:type TYPE'. KEYWORDS is a vector of
3623 image_keywords structures of size NKEYWORDS describing other
3624 allowed keyword/value pairs. Value is non-zero if SPEC is valid. */
3627 parse_image_spec (spec
, keywords
, nkeywords
, type
)
3629 struct image_keyword
*keywords
;
3636 if (!CONSP (spec
) || !EQ (XCAR (spec
), Qimage
))
3639 plist
= XCDR (spec
);
3640 while (CONSP (plist
))
3642 Lisp_Object key
, value
;
3644 /* First element of a pair must be a symbol. */
3646 plist
= XCDR (plist
);
3650 /* There must follow a value. */
3653 value
= XCAR (plist
);
3654 plist
= XCDR (plist
);
3656 /* Find key in KEYWORDS. Error if not found. */
3657 for (i
= 0; i
< nkeywords
; ++i
)
3658 if (strcmp (keywords
[i
].name
, SDATA (SYMBOL_NAME (key
))) == 0)
3664 /* Record that we recognized the keyword. If a keywords
3665 was found more than once, it's an error. */
3666 keywords
[i
].value
= value
;
3667 ++keywords
[i
].count
;
3669 if (keywords
[i
].count
> 1)
3672 /* Check type of value against allowed type. */
3673 switch (keywords
[i
].type
)
3675 case IMAGE_STRING_VALUE
:
3676 if (!STRINGP (value
))
3680 case IMAGE_SYMBOL_VALUE
:
3681 if (!SYMBOLP (value
))
3685 case IMAGE_POSITIVE_INTEGER_VALUE
:
3686 if (!INTEGERP (value
) || XINT (value
) <= 0)
3690 case IMAGE_POSITIVE_INTEGER_VALUE_OR_PAIR
:
3691 if (INTEGERP (value
) && XINT (value
) >= 0)
3694 && INTEGERP (XCAR (value
)) && INTEGERP (XCDR (value
))
3695 && XINT (XCAR (value
)) >= 0 && XINT (XCDR (value
)) >= 0)
3699 case IMAGE_ASCENT_VALUE
:
3700 if (SYMBOLP (value
) && EQ (value
, Qcenter
))
3702 else if (INTEGERP (value
)
3703 && XINT (value
) >= 0
3704 && XINT (value
) <= 100)
3708 case IMAGE_NON_NEGATIVE_INTEGER_VALUE
:
3709 if (!INTEGERP (value
) || XINT (value
) < 0)
3713 case IMAGE_DONT_CHECK_VALUE_TYPE
:
3716 case IMAGE_FUNCTION_VALUE
:
3717 value
= indirect_function (value
);
3719 || COMPILEDP (value
)
3720 || (CONSP (value
) && EQ (XCAR (value
), Qlambda
)))
3724 case IMAGE_NUMBER_VALUE
:
3725 if (!INTEGERP (value
) && !FLOATP (value
))
3729 case IMAGE_INTEGER_VALUE
:
3730 if (!INTEGERP (value
))
3734 case IMAGE_BOOL_VALUE
:
3735 if (!NILP (value
) && !EQ (value
, Qt
))
3744 if (EQ (key
, QCtype
) && !EQ (type
, value
))
3748 /* Check that all mandatory fields are present. */
3749 for (i
= 0; i
< nkeywords
; ++i
)
3750 if (keywords
[i
].mandatory_p
&& keywords
[i
].count
== 0)
3753 return NILP (plist
);
3757 /* Return the value of KEY in image specification SPEC. Value is nil
3758 if KEY is not present in SPEC. if FOUND is not null, set *FOUND
3759 to 1 if KEY was found in SPEC, set it to 0 otherwise. */
3762 image_spec_value (spec
, key
, found
)
3763 Lisp_Object spec
, key
;
3768 xassert (valid_image_p (spec
));
3770 for (tail
= XCDR (spec
);
3771 CONSP (tail
) && CONSP (XCDR (tail
));
3772 tail
= XCDR (XCDR (tail
)))
3774 if (EQ (XCAR (tail
), key
))
3778 return XCAR (XCDR (tail
));
3790 /***********************************************************************
3791 Image type independent image structures
3792 ***********************************************************************/
3794 static struct image
*make_image
P_ ((Lisp_Object spec
, unsigned hash
));
3795 static void free_image
P_ ((struct frame
*f
, struct image
*img
));
3798 /* Allocate and return a new image structure for image specification
3799 SPEC. SPEC has a hash value of HASH. */
3801 static struct image
*
3802 make_image (spec
, hash
)
3806 struct image
*img
= (struct image
*) xmalloc (sizeof *img
);
3808 xassert (valid_image_p (spec
));
3809 bzero (img
, sizeof *img
);
3810 img
->type
= lookup_image_type (image_spec_value (spec
, QCtype
, NULL
));
3811 xassert (img
->type
!= NULL
);
3813 img
->data
.lisp_val
= Qnil
;
3814 img
->ascent
= DEFAULT_IMAGE_ASCENT
;
3820 /* Free image IMG which was used on frame F, including its resources. */
3829 struct image_cache
*c
= FRAME_X_IMAGE_CACHE (f
);
3831 /* Remove IMG from the hash table of its cache. */
3833 img
->prev
->next
= img
->next
;
3835 c
->buckets
[img
->hash
% IMAGE_CACHE_BUCKETS_SIZE
] = img
->next
;
3838 img
->next
->prev
= img
->prev
;
3840 c
->images
[img
->id
] = NULL
;
3842 /* Free resources, then free IMG. */
3843 img
->type
->free (f
, img
);
3849 /* Prepare image IMG for display on frame F. Must be called before
3850 drawing an image. */
3853 prepare_image_for_display (f
, img
)
3859 /* We're about to display IMG, so set its timestamp to `now'. */
3861 img
->timestamp
= EMACS_SECS (t
);
3863 /* If IMG doesn't have a pixmap yet, load it now, using the image
3864 type dependent loader function. */
3865 if (img
->pixmap
== 0 && !img
->load_failed_p
)
3866 img
->load_failed_p
= img
->type
->load (f
, img
) == 0;
3870 /* Value is the number of pixels for the ascent of image IMG when
3871 drawn in face FACE. */
3874 image_ascent (img
, face
)
3878 int height
= img
->height
+ img
->vmargin
;
3881 if (img
->ascent
== CENTERED_IMAGE_ASCENT
)
3884 ascent
= height
/ 2 - (FONT_DESCENT(face
->font
)
3885 - FONT_BASE(face
->font
)) / 2;
3887 ascent
= height
/ 2;
3890 ascent
= height
* img
->ascent
/ 100.0;
3897 /***********************************************************************
3898 Helper functions for X image types
3899 ***********************************************************************/
3901 static void x_clear_image
P_ ((struct frame
*f
, struct image
*img
));
3902 static unsigned long x_alloc_image_color
P_ ((struct frame
*f
,
3904 Lisp_Object color_name
,
3905 unsigned long dflt
));
3907 /* Free X resources of image IMG which is used on frame F. */
3910 x_clear_image (f
, img
)
3914 #if 0 /* MAC_TODO: W32 image support */
3919 XFreePixmap (NULL
, img
->pixmap
);
3926 int class = FRAME_W32_DISPLAY_INFO (f
)->visual
->class;
3928 /* If display has an immutable color map, freeing colors is not
3929 necessary and some servers don't allow it. So don't do it. */
3930 if (class != StaticColor
3931 && class != StaticGray
3932 && class != TrueColor
)
3936 cmap
= DefaultColormapOfScreen (FRAME_W32_DISPLAY_INFO (f
)->screen
);
3937 XFreeColors (FRAME_W32_DISPLAY (f
), cmap
, img
->colors
,
3942 xfree (img
->colors
);
3946 #endif /* MAC_TODO */
3950 /* Allocate color COLOR_NAME for image IMG on frame F. If color
3951 cannot be allocated, use DFLT. Add a newly allocated color to
3952 IMG->colors, so that it can be freed again. Value is the pixel
3955 static unsigned long
3956 x_alloc_image_color (f
, img
, color_name
, dflt
)
3959 Lisp_Object color_name
;
3962 #if 0 /* MAC_TODO: allocing colors. */
3964 unsigned long result
;
3966 xassert (STRINGP (color_name
));
3968 if (w32_defined_color (f
, SDATA (color_name
), &color
, 1))
3970 /* This isn't called frequently so we get away with simply
3971 reallocating the color vector to the needed size, here. */
3974 (unsigned long *) xrealloc (img
->colors
,
3975 img
->ncolors
* sizeof *img
->colors
);
3976 img
->colors
[img
->ncolors
- 1] = color
.pixel
;
3977 result
= color
.pixel
;
3982 #endif /* MAC_TODO */
3988 /***********************************************************************
3990 ***********************************************************************/
3992 static void cache_image
P_ ((struct frame
*f
, struct image
*img
));
3995 /* Return a new, initialized image cache that is allocated from the
3996 heap. Call free_image_cache to free an image cache. */
3998 struct image_cache
*
4001 struct image_cache
*c
= (struct image_cache
*) xmalloc (sizeof *c
);
4004 bzero (c
, sizeof *c
);
4006 c
->images
= (struct image
**) xmalloc (c
->size
* sizeof *c
->images
);
4007 size
= IMAGE_CACHE_BUCKETS_SIZE
* sizeof *c
->buckets
;
4008 c
->buckets
= (struct image
**) xmalloc (size
);
4009 bzero (c
->buckets
, size
);
4014 /* Free image cache of frame F. Be aware that X frames share images
4018 free_image_cache (f
)
4021 struct image_cache
*c
= FRAME_X_IMAGE_CACHE (f
);
4026 /* Cache should not be referenced by any frame when freed. */
4027 xassert (c
->refcount
== 0);
4029 for (i
= 0; i
< c
->used
; ++i
)
4030 free_image (f
, c
->images
[i
]);
4034 FRAME_X_IMAGE_CACHE (f
) = NULL
;
4039 /* Clear image cache of frame F. FORCE_P non-zero means free all
4040 images. FORCE_P zero means clear only images that haven't been
4041 displayed for some time. Should be called from time to time to
4042 reduce the number of loaded images. If image-eviction-seconds is
4043 non-nil, this frees images in the cache which weren't displayed for
4044 at least that many seconds. */
4047 clear_image_cache (f
, force_p
)
4051 struct image_cache
*c
= FRAME_X_IMAGE_CACHE (f
);
4053 if (c
&& INTEGERP (Vimage_cache_eviction_delay
))
4057 int i
, any_freed_p
= 0;
4060 old
= EMACS_SECS (t
) - XFASTINT (Vimage_cache_eviction_delay
);
4062 for (i
= 0; i
< c
->used
; ++i
)
4064 struct image
*img
= c
->images
[i
];
4067 || (img
->timestamp
> old
)))
4069 free_image (f
, img
);
4074 /* We may be clearing the image cache because, for example,
4075 Emacs was iconified for a longer period of time. In that
4076 case, current matrices may still contain references to
4077 images freed above. So, clear these matrices. */
4080 clear_current_matrices (f
);
4081 ++windows_or_buffers_changed
;
4087 DEFUN ("clear-image-cache", Fclear_image_cache
, Sclear_image_cache
,
4089 doc
: /* Clear the image cache of FRAME.
4090 FRAME nil or omitted means use the selected frame.
4091 FRAME t means clear the image caches of all frames. */)
4099 FOR_EACH_FRAME (tail
, frame
)
4100 if (FRAME_MAC_P (XFRAME (frame
)))
4101 clear_image_cache (XFRAME (frame
), 1);
4104 clear_image_cache (check_x_frame (frame
), 1);
4110 /* Return the id of image with Lisp specification SPEC on frame F.
4111 SPEC must be a valid Lisp image specification (see valid_image_p). */
4114 lookup_image (f
, spec
)
4118 struct image_cache
*c
= FRAME_X_IMAGE_CACHE (f
);
4122 struct gcpro gcpro1
;
4125 /* F must be a window-system frame, and SPEC must be a valid image
4127 xassert (FRAME_WINDOW_P (f
));
4128 xassert (valid_image_p (spec
));
4132 /* Look up SPEC in the hash table of the image cache. */
4133 hash
= sxhash (spec
, 0);
4134 i
= hash
% IMAGE_CACHE_BUCKETS_SIZE
;
4136 for (img
= c
->buckets
[i
]; img
; img
= img
->next
)
4137 if (img
->hash
== hash
&& !NILP (Fequal (img
->spec
, spec
)))
4140 /* If not found, create a new image and cache it. */
4144 img
= make_image (spec
, hash
);
4145 cache_image (f
, img
);
4146 img
->load_failed_p
= img
->type
->load (f
, img
) == 0;
4147 xassert (!interrupt_input_blocked
);
4149 /* If we can't load the image, and we don't have a width and
4150 height, use some arbitrary width and height so that we can
4151 draw a rectangle for it. */
4152 if (img
->load_failed_p
)
4156 value
= image_spec_value (spec
, QCwidth
, NULL
);
4157 img
->width
= (INTEGERP (value
)
4158 ? XFASTINT (value
) : DEFAULT_IMAGE_WIDTH
);
4159 value
= image_spec_value (spec
, QCheight
, NULL
);
4160 img
->height
= (INTEGERP (value
)
4161 ? XFASTINT (value
) : DEFAULT_IMAGE_HEIGHT
);
4165 /* Handle image type independent image attributes
4166 `:ascent PERCENT', `:margin MARGIN', `:relief RELIEF'. */
4167 Lisp_Object ascent
, margin
, relief
;
4169 ascent
= image_spec_value (spec
, QCascent
, NULL
);
4170 if (INTEGERP (ascent
))
4171 img
->ascent
= XFASTINT (ascent
);
4172 else if (EQ (ascent
, Qcenter
))
4173 img
->ascent
= CENTERED_IMAGE_ASCENT
;
4175 margin
= image_spec_value (spec
, QCmargin
, NULL
);
4176 if (INTEGERP (margin
) && XINT (margin
) >= 0)
4177 img
->vmargin
= img
->hmargin
= XFASTINT (margin
);
4178 else if (CONSP (margin
) && INTEGERP (XCAR (margin
))
4179 && INTEGERP (XCDR (margin
)))
4181 if (XINT (XCAR (margin
)) > 0)
4182 img
->hmargin
= XFASTINT (XCAR (margin
));
4183 if (XINT (XCDR (margin
)) > 0)
4184 img
->vmargin
= XFASTINT (XCDR (margin
));
4187 relief
= image_spec_value (spec
, QCrelief
, NULL
);
4188 if (INTEGERP (relief
))
4190 img
->relief
= XINT (relief
);
4191 img
->hmargin
+= abs (img
->relief
);
4192 img
->vmargin
+= abs (img
->relief
);
4197 /* We're using IMG, so set its timestamp to `now'. */
4198 EMACS_GET_TIME (now
);
4199 img
->timestamp
= EMACS_SECS (now
);
4203 /* Value is the image id. */
4208 /* Cache image IMG in the image cache of frame F. */
4211 cache_image (f
, img
)
4215 struct image_cache
*c
= FRAME_X_IMAGE_CACHE (f
);
4218 /* Find a free slot in c->images. */
4219 for (i
= 0; i
< c
->used
; ++i
)
4220 if (c
->images
[i
] == NULL
)
4223 /* If no free slot found, maybe enlarge c->images. */
4224 if (i
== c
->used
&& c
->used
== c
->size
)
4227 c
->images
= (struct image
**) xrealloc (c
->images
,
4228 c
->size
* sizeof *c
->images
);
4231 /* Add IMG to c->images, and assign IMG an id. */
4237 /* Add IMG to the cache's hash table. */
4238 i
= img
->hash
% IMAGE_CACHE_BUCKETS_SIZE
;
4239 img
->next
= c
->buckets
[i
];
4241 img
->next
->prev
= img
;
4243 c
->buckets
[i
] = img
;
4247 /* Call FN on every image in the image cache of frame F. Used to mark
4248 Lisp Objects in the image cache. */
4251 forall_images_in_image_cache (f
, fn
)
4253 void (*fn
) P_ ((struct image
*img
));
4255 if (FRAME_LIVE_P (f
) && FRAME_MAC_P (f
))
4257 struct image_cache
*c
= FRAME_X_IMAGE_CACHE (f
);
4261 for (i
= 0; i
< c
->used
; ++i
)
4270 /***********************************************************************
4272 ***********************************************************************/
4274 #if 0 /* MAC_TODO: Mac specific image code. */
4276 static int x_create_x_image_and_pixmap
P_ ((struct frame
*, int, int, int,
4277 XImage
**, Pixmap
*));
4278 static void x_destroy_x_image
P_ ((XImage
*));
4279 static void x_put_x_image
P_ ((struct frame
*, XImage
*, Pixmap
, int, int));
4282 /* Create an XImage and a pixmap of size WIDTH x HEIGHT for use on
4283 frame F. Set *XIMG and *PIXMAP to the XImage and Pixmap created.
4284 Set (*XIMG)->data to a raster of WIDTH x HEIGHT pixels allocated
4285 via xmalloc. Print error messages via image_error if an error
4286 occurs. Value is non-zero if successful. */
4289 x_create_x_image_and_pixmap (f
, width
, height
, depth
, ximg
, pixmap
)
4291 int width
, height
, depth
;
4295 #if 0 /* MAC_TODO: Image support for Mac */
4296 Display
*display
= FRAME_W32_DISPLAY (f
);
4297 Screen
*screen
= FRAME_X_SCREEN (f
);
4298 Window window
= FRAME_W32_WINDOW (f
);
4300 xassert (interrupt_input_blocked
);
4303 depth
= DefaultDepthOfScreen (screen
);
4304 *ximg
= XCreateImage (display
, DefaultVisualOfScreen (screen
),
4305 depth
, ZPixmap
, 0, NULL
, width
, height
,
4306 depth
> 16 ? 32 : depth
> 8 ? 16 : 8, 0);
4309 image_error ("Unable to allocate X image", Qnil
, Qnil
);
4313 /* Allocate image raster. */
4314 (*ximg
)->data
= (char *) xmalloc ((*ximg
)->bytes_per_line
* height
);
4316 /* Allocate a pixmap of the same size. */
4317 *pixmap
= XCreatePixmap (display
, window
, width
, height
, depth
);
4320 x_destroy_x_image (*ximg
);
4322 image_error ("Unable to create X pixmap", Qnil
, Qnil
);
4325 #endif /* MAC_TODO */
4330 /* Destroy XImage XIMG. Free XIMG->data. */
4333 x_destroy_x_image (ximg
)
4336 xassert (interrupt_input_blocked
);
4341 XDestroyImage (ximg
);
4346 /* Put XImage XIMG into pixmap PIXMAP on frame F. WIDTH and HEIGHT
4347 are width and height of both the image and pixmap. */
4350 x_put_x_image (f
, ximg
, pixmap
, width
, height
)
4357 xassert (interrupt_input_blocked
);
4358 gc
= XCreateGC (NULL
, pixmap
, 0, NULL
);
4359 XPutImage (NULL
, pixmap
, gc
, ximg
, 0, 0, 0, 0, width
, height
);
4363 #endif /* MAC_TODO */
4366 /***********************************************************************
4368 ***********************************************************************/
4370 static Lisp_Object x_find_image_file
P_ ((Lisp_Object
));
4372 /* Find image file FILE. Look in data-directory, then
4373 x-bitmap-file-path. Value is the full name of the file found, or
4374 nil if not found. */
4377 x_find_image_file (file
)
4380 Lisp_Object file_found
, search_path
;
4381 struct gcpro gcpro1
, gcpro2
;
4385 search_path
= Fcons (Vdata_directory
, Vx_bitmap_file_path
);
4386 GCPRO2 (file_found
, search_path
);
4388 /* Try to find FILE in data-directory, then x-bitmap-file-path. */
4389 fd
= openp (search_path
, file
, Qnil
, &file_found
, Qnil
);
4401 /***********************************************************************
4403 ***********************************************************************/
4405 static int xbm_load
P_ ((struct frame
*f
, struct image
*img
));
4406 static int xbm_load_image_from_file
P_ ((struct frame
*f
, struct image
*img
,
4408 static int xbm_image_p
P_ ((Lisp_Object object
));
4409 static int xbm_read_bitmap_file_data
P_ ((char *, int *, int *,
4413 /* Indices of image specification fields in xbm_format, below. */
4415 enum xbm_keyword_index
4432 /* Vector of image_keyword structures describing the format
4433 of valid XBM image specifications. */
4435 static struct image_keyword xbm_format
[XBM_LAST
] =
4437 {":type", IMAGE_SYMBOL_VALUE
, 1},
4438 {":file", IMAGE_STRING_VALUE
, 0},
4439 {":width", IMAGE_POSITIVE_INTEGER_VALUE
, 0},
4440 {":height", IMAGE_POSITIVE_INTEGER_VALUE
, 0},
4441 {":data", IMAGE_DONT_CHECK_VALUE_TYPE
, 0},
4442 {":foreground", IMAGE_STRING_VALUE
, 0},
4443 {":background", IMAGE_STRING_VALUE
, 0},
4444 {":ascent", IMAGE_NON_NEGATIVE_INTEGER_VALUE
, 0},
4445 {":margin", IMAGE_POSITIVE_INTEGER_VALUE_OR_PAIR
, 0},
4446 {":relief", IMAGE_INTEGER_VALUE
, 0},
4447 {":conversion", IMAGE_DONT_CHECK_VALUE_TYPE
, 0},
4448 {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE
, 0}
4451 /* Structure describing the image type XBM. */
4453 static struct image_type xbm_type
=
4462 /* Tokens returned from xbm_scan. */
4471 /* Return non-zero if OBJECT is a valid XBM-type image specification.
4472 A valid specification is a list starting with the symbol `image'
4473 The rest of the list is a property list which must contain an
4476 If the specification specifies a file to load, it must contain
4477 an entry `:file FILENAME' where FILENAME is a string.
4479 If the specification is for a bitmap loaded from memory it must
4480 contain `:width WIDTH', `:height HEIGHT', and `:data DATA', where
4481 WIDTH and HEIGHT are integers > 0. DATA may be:
4483 1. a string large enough to hold the bitmap data, i.e. it must
4484 have a size >= (WIDTH + 7) / 8 * HEIGHT
4486 2. a bool-vector of size >= WIDTH * HEIGHT
4488 3. a vector of strings or bool-vectors, one for each line of the
4491 Both the file and data forms may contain the additional entries
4492 `:background COLOR' and `:foreground COLOR'. If not present,
4493 foreground and background of the frame on which the image is
4494 displayed, is used. */
4497 xbm_image_p (object
)
4500 struct image_keyword kw
[XBM_LAST
];
4502 bcopy (xbm_format
, kw
, sizeof kw
);
4503 if (!parse_image_spec (object
, kw
, XBM_LAST
, Qxbm
))
4506 xassert (EQ (kw
[XBM_TYPE
].value
, Qxbm
));
4508 if (kw
[XBM_FILE
].count
)
4510 if (kw
[XBM_WIDTH
].count
|| kw
[XBM_HEIGHT
].count
|| kw
[XBM_DATA
].count
)
4518 /* Entries for `:width', `:height' and `:data' must be present. */
4519 if (!kw
[XBM_WIDTH
].count
4520 || !kw
[XBM_HEIGHT
].count
4521 || !kw
[XBM_DATA
].count
)
4524 data
= kw
[XBM_DATA
].value
;
4525 width
= XFASTINT (kw
[XBM_WIDTH
].value
);
4526 height
= XFASTINT (kw
[XBM_HEIGHT
].value
);
4528 /* Check type of data, and width and height against contents of
4534 /* Number of elements of the vector must be >= height. */
4535 if (XVECTOR (data
)->size
< height
)
4538 /* Each string or bool-vector in data must be large enough
4539 for one line of the image. */
4540 for (i
= 0; i
< height
; ++i
)
4542 Lisp_Object elt
= XVECTOR (data
)->contents
[i
];
4547 < (width
+ BITS_PER_CHAR
- 1) / BITS_PER_CHAR
)
4550 else if (BOOL_VECTOR_P (elt
))
4552 if (XBOOL_VECTOR (elt
)->size
< width
)
4559 else if (STRINGP (data
))
4562 < (width
+ BITS_PER_CHAR
- 1) / BITS_PER_CHAR
* height
)
4565 else if (BOOL_VECTOR_P (data
))
4567 if (XBOOL_VECTOR (data
)->size
< width
* height
)
4574 /* Baseline must be a value between 0 and 100 (a percentage). */
4575 if (kw
[XBM_ASCENT
].count
4576 && XFASTINT (kw
[XBM_ASCENT
].value
) > 100)
4583 /* Scan a bitmap file. FP is the stream to read from. Value is
4584 either an enumerator from enum xbm_token, or a character for a
4585 single-character token, or 0 at end of file. If scanning an
4586 identifier, store the lexeme of the identifier in SVAL. If
4587 scanning a number, store its value in *IVAL. */
4590 xbm_scan (fp
, sval
, ival
)
4597 /* Skip white space. */
4598 while ((c
= fgetc (fp
)) != EOF
&& isspace (c
))
4603 else if (isdigit (c
))
4605 int value
= 0, digit
;
4610 if (c
== 'x' || c
== 'X')
4612 while ((c
= fgetc (fp
)) != EOF
)
4616 else if (c
>= 'a' && c
<= 'f')
4617 digit
= c
- 'a' + 10;
4618 else if (c
>= 'A' && c
<= 'F')
4619 digit
= c
- 'A' + 10;
4622 value
= 16 * value
+ digit
;
4625 else if (isdigit (c
))
4628 while ((c
= fgetc (fp
)) != EOF
4630 value
= 8 * value
+ c
- '0';
4636 while ((c
= fgetc (fp
)) != EOF
4638 value
= 10 * value
+ c
- '0';
4646 else if (isalpha (c
) || c
== '_')
4649 while ((c
= fgetc (fp
)) != EOF
4650 && (isalnum (c
) || c
== '_'))
4662 /* Replacement for XReadBitmapFileData which isn't available under old
4663 X versions. FILE is the name of the bitmap file to read. Set
4664 *WIDTH and *HEIGHT to the width and height of the image. Return in
4665 *DATA the bitmap data allocated with xmalloc. Value is non-zero if
4669 xbm_read_bitmap_file_data (file
, width
, height
, data
)
4671 int *width
, *height
;
4672 unsigned char **data
;
4675 char buffer
[BUFSIZ
];
4678 int bytes_per_line
, i
, nbytes
;
4684 LA1 = xbm_scan (fp, buffer, &value)
4686 #define expect(TOKEN) \
4687 if (LA1 != (TOKEN)) \
4692 #define expect_ident(IDENT) \
4693 if (LA1 == XBM_TK_IDENT && strcmp (buffer, (IDENT)) == 0) \
4698 fp
= fopen (file
, "r");
4702 *width
= *height
= -1;
4704 LA1
= xbm_scan (fp
, buffer
, &value
);
4706 /* Parse defines for width, height and hot-spots. */
4710 expect_ident ("define");
4711 expect (XBM_TK_IDENT
);
4713 if (LA1
== XBM_TK_NUMBER
);
4715 char *p
= strrchr (buffer
, '_');
4716 p
= p
? p
+ 1 : buffer
;
4717 if (strcmp (p
, "width") == 0)
4719 else if (strcmp (p
, "height") == 0)
4722 expect (XBM_TK_NUMBER
);
4725 if (*width
< 0 || *height
< 0)
4728 /* Parse bits. Must start with `static'. */
4729 expect_ident ("static");
4730 if (LA1
== XBM_TK_IDENT
)
4732 if (strcmp (buffer
, "unsigned") == 0)
4735 expect_ident ("char");
4737 else if (strcmp (buffer
, "short") == 0)
4741 if (*width
% 16 && *width
% 16 < 9)
4744 else if (strcmp (buffer
, "char") == 0)
4752 expect (XBM_TK_IDENT
);
4758 bytes_per_line
= (*width
+ 7) / 8 + padding_p
;
4759 nbytes
= bytes_per_line
* *height
;
4760 p
= *data
= (char *) xmalloc (nbytes
);
4765 for (i
= 0; i
< nbytes
; i
+= 2)
4768 expect (XBM_TK_NUMBER
);
4771 if (!padding_p
|| ((i
+ 2) % bytes_per_line
))
4774 if (LA1
== ',' || LA1
== '}')
4782 for (i
= 0; i
< nbytes
; ++i
)
4785 expect (XBM_TK_NUMBER
);
4789 if (LA1
== ',' || LA1
== '}')
4815 /* Load XBM image IMG which will be displayed on frame F from file
4816 SPECIFIED_FILE. Value is non-zero if successful. */
4819 xbm_load_image_from_file (f
, img
, specified_file
)
4822 Lisp_Object specified_file
;
4825 unsigned char *data
;
4828 struct gcpro gcpro1
;
4830 xassert (STRINGP (specified_file
));
4834 file
= x_find_image_file (specified_file
);
4835 if (!STRINGP (file
))
4837 image_error ("Cannot find image file `%s'", specified_file
, Qnil
);
4842 rc
= xbm_read_bitmap_file_data (SDATA (file
), &img
->width
,
4843 &img
->height
, &data
);
4846 int depth
= one_mac_display_info
.n_cbits
;
4847 unsigned long foreground
= FRAME_FOREGROUND_PIXEL (f
);
4848 unsigned long background
= FRAME_BACKGROUND_PIXEL (f
);
4851 xassert (img
->width
> 0 && img
->height
> 0);
4853 /* Get foreground and background colors, maybe allocate colors. */
4854 value
= image_spec_value (img
->spec
, QCforeground
, NULL
);
4856 foreground
= x_alloc_image_color (f
, img
, value
, foreground
);
4858 value
= image_spec_value (img
->spec
, QCbackground
, NULL
);
4860 background
= x_alloc_image_color (f
, img
, value
, background
);
4862 #if 0 /* MAC_TODO : Port image display to Mac */
4865 = XCreatePixmapFromBitmapData (FRAME_W32_DISPLAY (f
),
4866 FRAME_W32_WINDOW (f
),
4868 img
->width
, img
->height
,
4869 foreground
, background
,
4873 if (img
->pixmap
== 0)
4875 x_clear_image (f
, img
);
4876 image_error ("Unable to create X pixmap for `%s'", file
, Qnil
);
4882 #endif /* MAC_TODO */
4885 image_error ("Error loading XBM image `%s'", img
->spec
, Qnil
);
4892 /* Fill image IMG which is used on frame F with pixmap data. Value is
4893 non-zero if successful. */
4901 Lisp_Object file_name
;
4903 xassert (xbm_image_p (img
->spec
));
4905 /* If IMG->spec specifies a file name, create a non-file spec from it. */
4906 file_name
= image_spec_value (img
->spec
, QCfile
, NULL
);
4907 if (STRINGP (file_name
))
4908 success_p
= xbm_load_image_from_file (f
, img
, file_name
);
4911 struct image_keyword fmt
[XBM_LAST
];
4914 unsigned long foreground
= FRAME_FOREGROUND_PIXEL (f
);
4915 unsigned long background
= FRAME_BACKGROUND_PIXEL (f
);
4919 /* Parse the list specification. */
4920 bcopy (xbm_format
, fmt
, sizeof fmt
);
4921 parsed_p
= parse_image_spec (img
->spec
, fmt
, XBM_LAST
, Qxbm
);
4924 /* Get specified width, and height. */
4925 img
->width
= XFASTINT (fmt
[XBM_WIDTH
].value
);
4926 img
->height
= XFASTINT (fmt
[XBM_HEIGHT
].value
);
4927 xassert (img
->width
> 0 && img
->height
> 0);
4931 if (fmt
[XBM_ASCENT
].count
)
4932 img
->ascent
= XFASTINT (fmt
[XBM_ASCENT
].value
);
4934 /* Get foreground and background colors, maybe allocate colors. */
4935 if (fmt
[XBM_FOREGROUND
].count
)
4936 foreground
= x_alloc_image_color (f
, img
, fmt
[XBM_FOREGROUND
].value
,
4938 if (fmt
[XBM_BACKGROUND
].count
)
4939 background
= x_alloc_image_color (f
, img
, fmt
[XBM_BACKGROUND
].value
,
4942 /* Set bits to the bitmap image data. */
4943 data
= fmt
[XBM_DATA
].value
;
4948 int nbytes
= (img
->width
+ BITS_PER_CHAR
- 1) / BITS_PER_CHAR
;
4950 p
= bits
= (char *) alloca (nbytes
* img
->height
);
4951 for (i
= 0; i
< img
->height
; ++i
, p
+= nbytes
)
4953 Lisp_Object line
= XVECTOR (data
)->contents
[i
];
4955 bcopy (SDATA (line
), p
, nbytes
);
4957 bcopy (XBOOL_VECTOR (line
)->data
, p
, nbytes
);
4960 else if (STRINGP (data
))
4961 bits
= SDATA (data
);
4963 bits
= XBOOL_VECTOR (data
)->data
;
4965 #if 0 /* MAC_TODO : port Mac display code */
4966 /* Create the pixmap. */
4967 depth
= DefaultDepthOfScreen (FRAME_X_SCREEN (f
));
4969 = XCreatePixmapFromBitmapData (FRAME_W32_DISPLAY (f
),
4970 FRAME_W32_WINDOW (f
),
4972 img
->width
, img
->height
,
4973 foreground
, background
,
4975 #endif /* MAC_TODO */
4981 image_error ("Unable to create pixmap for XBM image `%s'",
4983 x_clear_image (f
, img
);
4994 /***********************************************************************
4996 ***********************************************************************/
5000 static int xpm_image_p
P_ ((Lisp_Object object
));
5001 static int xpm_load
P_ ((struct frame
*f
, struct image
*img
));
5002 static int xpm_valid_color_symbols_p
P_ ((Lisp_Object
));
5004 #include "X11/xpm.h"
5006 /* The symbol `xpm' identifying XPM-format images. */
5010 /* Indices of image specification fields in xpm_format, below. */
5012 enum xpm_keyword_index
5026 /* Vector of image_keyword structures describing the format
5027 of valid XPM image specifications. */
5029 static struct image_keyword xpm_format
[XPM_LAST
] =
5031 {":type", IMAGE_SYMBOL_VALUE
, 1},
5032 {":file", IMAGE_STRING_VALUE
, 0},
5033 {":data", IMAGE_STRING_VALUE
, 0},
5034 {":ascent", IMAGE_NON_NEGATIVE_INTEGER_VALUE
, 0},
5035 {":margin", IMAGE_POSITIVE_INTEGER_VALUE_OR_PAIR
, 0},
5036 {":relief", IMAGE_INTEGER_VALUE
, 0},
5037 {":conversion", IMAGE_DONT_CHECK_VALUE_TYPE
, 0},
5038 {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE
, 0},
5039 {":color-symbols", IMAGE_DONT_CHECK_VALUE_TYPE
, 0}
5042 /* Structure describing the image type XBM. */
5044 static struct image_type xpm_type
=
5054 /* Value is non-zero if COLOR_SYMBOLS is a valid color symbols list
5055 for XPM images. Such a list must consist of conses whose car and
5059 xpm_valid_color_symbols_p (color_symbols
)
5060 Lisp_Object color_symbols
;
5062 while (CONSP (color_symbols
))
5064 Lisp_Object sym
= XCAR (color_symbols
);
5066 || !STRINGP (XCAR (sym
))
5067 || !STRINGP (XCDR (sym
)))
5069 color_symbols
= XCDR (color_symbols
);
5072 return NILP (color_symbols
);
5076 /* Value is non-zero if OBJECT is a valid XPM image specification. */
5079 xpm_image_p (object
)
5082 struct image_keyword fmt
[XPM_LAST
];
5083 bcopy (xpm_format
, fmt
, sizeof fmt
);
5084 return (parse_image_spec (object
, fmt
, XPM_LAST
, Qxpm
)
5085 /* Either `:file' or `:data' must be present. */
5086 && fmt
[XPM_FILE
].count
+ fmt
[XPM_DATA
].count
== 1
5087 /* Either no `:color-symbols' or it's a list of conses
5088 whose car and cdr are strings. */
5089 && (fmt
[XPM_COLOR_SYMBOLS
].count
== 0
5090 || xpm_valid_color_symbols_p (fmt
[XPM_COLOR_SYMBOLS
].value
))
5091 && (fmt
[XPM_ASCENT
].count
== 0
5092 || XFASTINT (fmt
[XPM_ASCENT
].value
) < 100));
5096 /* Load image IMG which will be displayed on frame F. Value is
5097 non-zero if successful. */
5105 XpmAttributes attrs
;
5106 Lisp_Object specified_file
, color_symbols
;
5108 /* Configure the XPM lib. Use the visual of frame F. Allocate
5109 close colors. Return colors allocated. */
5110 bzero (&attrs
, sizeof attrs
);
5111 attrs
.visual
= FRAME_X_VISUAL (f
);
5112 attrs
.colormap
= FRAME_X_COLORMAP (f
);
5113 attrs
.valuemask
|= XpmVisual
;
5114 attrs
.valuemask
|= XpmColormap
;
5115 attrs
.valuemask
|= XpmReturnAllocPixels
;
5116 #ifdef XpmAllocCloseColors
5117 attrs
.alloc_close_colors
= 1;
5118 attrs
.valuemask
|= XpmAllocCloseColors
;
5120 attrs
.closeness
= 600;
5121 attrs
.valuemask
|= XpmCloseness
;
5124 /* If image specification contains symbolic color definitions, add
5125 these to `attrs'. */
5126 color_symbols
= image_spec_value (img
->spec
, QCcolor_symbols
, NULL
);
5127 if (CONSP (color_symbols
))
5130 XpmColorSymbol
*xpm_syms
;
5133 attrs
.valuemask
|= XpmColorSymbols
;
5135 /* Count number of symbols. */
5136 attrs
.numsymbols
= 0;
5137 for (tail
= color_symbols
; CONSP (tail
); tail
= XCDR (tail
))
5140 /* Allocate an XpmColorSymbol array. */
5141 size
= attrs
.numsymbols
* sizeof *xpm_syms
;
5142 xpm_syms
= (XpmColorSymbol
*) alloca (size
);
5143 bzero (xpm_syms
, size
);
5144 attrs
.colorsymbols
= xpm_syms
;
5146 /* Fill the color symbol array. */
5147 for (tail
= color_symbols
, i
= 0;
5149 ++i
, tail
= XCDR (tail
))
5151 Lisp_Object name
= XCAR (XCAR (tail
));
5152 Lisp_Object color
= XCDR (XCAR (tail
));
5153 xpm_syms
[i
].name
= (char *) alloca (SCHARS (name
) + 1);
5154 strcpy (xpm_syms
[i
].name
, SDATA (name
));
5155 xpm_syms
[i
].value
= (char *) alloca (SCHARS (color
) + 1);
5156 strcpy (xpm_syms
[i
].value
, SDATA (color
));
5160 /* Create a pixmap for the image, either from a file, or from a
5161 string buffer containing data in the same format as an XPM file. */
5163 specified_file
= image_spec_value (img
->spec
, QCfile
, NULL
);
5164 if (STRINGP (specified_file
))
5166 Lisp_Object file
= x_find_image_file (specified_file
);
5167 if (!STRINGP (file
))
5169 image_error ("Cannot find image file `%s'", specified_file
, Qnil
);
5174 rc
= XpmReadFileToPixmap (NULL
, FRAME_W32_WINDOW (f
),
5175 SDATA (file
), &img
->pixmap
, &img
->mask
,
5180 Lisp_Object buffer
= image_spec_value (img
->spec
, QCdata
, NULL
);
5181 rc
= XpmCreatePixmapFromBuffer (NULL
, FRAME_W32_WINDOW (f
),
5183 &img
->pixmap
, &img
->mask
,
5188 if (rc
== XpmSuccess
)
5190 /* Remember allocated colors. */
5191 img
->ncolors
= attrs
.nalloc_pixels
;
5192 img
->colors
= (unsigned long *) xmalloc (img
->ncolors
5193 * sizeof *img
->colors
);
5194 for (i
= 0; i
< attrs
.nalloc_pixels
; ++i
)
5195 img
->colors
[i
] = attrs
.alloc_pixels
[i
];
5197 img
->width
= attrs
.width
;
5198 img
->height
= attrs
.height
;
5199 xassert (img
->width
> 0 && img
->height
> 0);
5201 /* The call to XpmFreeAttributes below frees attrs.alloc_pixels. */
5203 XpmFreeAttributes (&attrs
);
5211 image_error ("Error opening XPM file (%s)", img
->spec
, Qnil
);
5214 case XpmFileInvalid
:
5215 image_error ("Invalid XPM file (%s)", img
->spec
, Qnil
);
5219 image_error ("Out of memory (%s)", img
->spec
, Qnil
);
5222 case XpmColorFailed
:
5223 image_error ("Color allocation error (%s)", img
->spec
, Qnil
);
5227 image_error ("Unknown error (%s)", img
->spec
, Qnil
);
5232 return rc
== XpmSuccess
;
5235 #endif /* HAVE_XPM != 0 */
5238 #if 0 /* MAC_TODO : Color tables on Mac. */
5239 /***********************************************************************
5241 ***********************************************************************/
5243 /* An entry in the color table mapping an RGB color to a pixel color. */
5248 unsigned long pixel
;
5250 /* Next in color table collision list. */
5251 struct ct_color
*next
;
5254 /* The bucket vector size to use. Must be prime. */
5258 /* Value is a hash of the RGB color given by R, G, and B. */
5260 #define CT_HASH_RGB(R, G, B) (((R) << 16) ^ ((G) << 8) ^ (B))
5262 /* The color hash table. */
5264 struct ct_color
**ct_table
;
5266 /* Number of entries in the color table. */
5268 int ct_colors_allocated
;
5270 /* Function prototypes. */
5272 static void init_color_table
P_ ((void));
5273 static void free_color_table
P_ ((void));
5274 static unsigned long *colors_in_color_table
P_ ((int *n
));
5275 static unsigned long lookup_rgb_color
P_ ((struct frame
*f
, int r
, int g
, int b
));
5276 static unsigned long lookup_pixel_color
P_ ((struct frame
*f
, unsigned long p
));
5279 /* Initialize the color table. */
5284 int size
= CT_SIZE
* sizeof (*ct_table
);
5285 ct_table
= (struct ct_color
**) xmalloc (size
);
5286 bzero (ct_table
, size
);
5287 ct_colors_allocated
= 0;
5291 /* Free memory associated with the color table. */
5297 struct ct_color
*p
, *next
;
5299 for (i
= 0; i
< CT_SIZE
; ++i
)
5300 for (p
= ct_table
[i
]; p
; p
= next
)
5311 /* Value is a pixel color for RGB color R, G, B on frame F. If an
5312 entry for that color already is in the color table, return the
5313 pixel color of that entry. Otherwise, allocate a new color for R,
5314 G, B, and make an entry in the color table. */
5316 static unsigned long
5317 lookup_rgb_color (f
, r
, g
, b
)
5321 unsigned hash
= CT_HASH_RGB (r
, g
, b
);
5322 int i
= hash
% CT_SIZE
;
5325 for (p
= ct_table
[i
]; p
; p
= p
->next
)
5326 if (p
->r
== r
&& p
->g
== g
&& p
->b
== b
)
5335 color
= RGB_TO_ULONG (r
, g
, b
);
5337 ++ct_colors_allocated
;
5339 p
= (struct ct_color
*) xmalloc (sizeof *p
);
5344 p
->next
= ct_table
[i
];
5352 /* Look up pixel color PIXEL which is used on frame F in the color
5353 table. If not already present, allocate it. Value is PIXEL. */
5355 static unsigned long
5356 lookup_pixel_color (f
, pixel
)
5358 unsigned long pixel
;
5360 int i
= pixel
% CT_SIZE
;
5363 for (p
= ct_table
[i
]; p
; p
= p
->next
)
5364 if (p
->pixel
== pixel
)
5375 cmap
= DefaultColormapOfScreen (FRAME_X_SCREEN (f
));
5376 color
.pixel
= pixel
;
5377 XQueryColor (NULL
, cmap
, &color
);
5378 rc
= x_alloc_nearest_color (f
, cmap
, &color
);
5383 ++ct_colors_allocated
;
5385 p
= (struct ct_color
*) xmalloc (sizeof *p
);
5390 p
->next
= ct_table
[i
];
5394 return FRAME_FOREGROUND_PIXEL (f
);
5400 /* Value is a vector of all pixel colors contained in the color table,
5401 allocated via xmalloc. Set *N to the number of colors. */
5403 static unsigned long *
5404 colors_in_color_table (n
)
5409 unsigned long *colors
;
5411 if (ct_colors_allocated
== 0)
5418 colors
= (unsigned long *) xmalloc (ct_colors_allocated
5420 *n
= ct_colors_allocated
;
5422 for (i
= j
= 0; i
< CT_SIZE
; ++i
)
5423 for (p
= ct_table
[i
]; p
; p
= p
->next
)
5424 colors
[j
++] = p
->pixel
;
5430 #endif /* MAC_TODO */
5433 /***********************************************************************
5435 ***********************************************************************/
5437 #if 0 /* MAC_TODO : Mac versions of low level algorithms */
5438 static void x_laplace_write_row
P_ ((struct frame
*, long *,
5439 int, XImage
*, int));
5440 static void x_laplace_read_row
P_ ((struct frame
*, Colormap
,
5441 XColor
*, int, XImage
*, int));
5444 /* Fill COLORS with RGB colors from row Y of image XIMG. F is the
5445 frame we operate on, CMAP is the color-map in effect, and WIDTH is
5446 the width of one row in the image. */
5449 x_laplace_read_row (f
, cmap
, colors
, width
, ximg
, y
)
5459 for (x
= 0; x
< width
; ++x
)
5460 colors
[x
].pixel
= XGetPixel (ximg
, x
, y
);
5462 XQueryColors (NULL
, cmap
, colors
, width
);
5466 /* Write row Y of image XIMG. PIXELS is an array of WIDTH longs
5467 containing the pixel colors to write. F is the frame we are
5471 x_laplace_write_row (f
, pixels
, width
, ximg
, y
)
5480 for (x
= 0; x
< width
; ++x
)
5481 XPutPixel (ximg
, x
, y
, pixels
[x
]);
5483 #endif /* MAC_TODO */
5485 /* Transform image IMG which is used on frame F with a Laplace
5486 edge-detection algorithm. The result is an image that can be used
5487 to draw disabled buttons, for example. */
5494 #if 0 /* MAC_TODO : Mac version */
5495 Colormap cmap
= DefaultColormapOfScreen (FRAME_X_SCREEN (f
));
5496 XImage
*ximg
, *oimg
;
5502 int in_y
, out_y
, rc
;
5507 /* Get the X image IMG->pixmap. */
5508 ximg
= XGetImage (NULL
, img
->pixmap
,
5509 0, 0, img
->width
, img
->height
, ~0, ZPixmap
);
5511 /* Allocate 3 input rows, and one output row of colors. */
5512 for (i
= 0; i
< 3; ++i
)
5513 in
[i
] = (XColor
*) alloca (img
->width
* sizeof (XColor
));
5514 out
= (long *) alloca (img
->width
* sizeof (long));
5516 /* Create an X image for output. */
5517 rc
= x_create_x_image_and_pixmap (f
, img
->width
, img
->height
, 0,
5520 /* Fill first two rows. */
5521 x_laplace_read_row (f
, cmap
, in
[0], img
->width
, ximg
, 0);
5522 x_laplace_read_row (f
, cmap
, in
[1], img
->width
, ximg
, 1);
5525 /* Write first row, all zeros. */
5526 init_color_table ();
5527 pixel
= lookup_rgb_color (f
, 0, 0, 0);
5528 for (x
= 0; x
< img
->width
; ++x
)
5530 x_laplace_write_row (f
, out
, img
->width
, oimg
, 0);
5533 for (y
= 2; y
< img
->height
; ++y
)
5536 int rowb
= (y
+ 2) % 3;
5538 x_laplace_read_row (f
, cmap
, in
[rowa
], img
->width
, ximg
, in_y
++);
5540 for (x
= 0; x
< img
->width
- 2; ++x
)
5542 int r
= in
[rowa
][x
].red
+ mv2
- in
[rowb
][x
+ 2].red
;
5543 int g
= in
[rowa
][x
].green
+ mv2
- in
[rowb
][x
+ 2].green
;
5544 int b
= in
[rowa
][x
].blue
+ mv2
- in
[rowb
][x
+ 2].blue
;
5546 out
[x
+ 1] = lookup_rgb_color (f
, r
& 0xffff, g
& 0xffff,
5550 x_laplace_write_row (f
, out
, img
->width
, oimg
, out_y
++);
5553 /* Write last line, all zeros. */
5554 for (x
= 0; x
< img
->width
; ++x
)
5556 x_laplace_write_row (f
, out
, img
->width
, oimg
, out_y
);
5558 /* Free the input image, and free resources of IMG. */
5559 XDestroyImage (ximg
);
5560 x_clear_image (f
, img
);
5562 /* Put the output image into pixmap, and destroy it. */
5563 x_put_x_image (f
, oimg
, pixmap
, img
->width
, img
->height
);
5564 x_destroy_x_image (oimg
);
5566 /* Remember new pixmap and colors in IMG. */
5567 img
->pixmap
= pixmap
;
5568 img
->colors
= colors_in_color_table (&img
->ncolors
);
5569 free_color_table ();
5572 #endif /* MAC_TODO */
5576 /* Build a mask for image IMG which is used on frame F. FILE is the
5577 name of an image file, for error messages. HOW determines how to
5578 determine the background color of IMG. If it is a list '(R G B)',
5579 with R, G, and B being integers >= 0, take that as the color of the
5580 background. Otherwise, determine the background color of IMG
5581 heuristically. Value is non-zero if successful. */
5584 x_build_heuristic_mask (f
, img
, how
)
5589 #if 0 /* MAC_TODO : Mac version */
5590 Display
*dpy
= FRAME_W32_DISPLAY (f
);
5591 XImage
*ximg
, *mask_img
;
5592 int x
, y
, rc
, look_at_corners_p
;
5597 /* Create an image and pixmap serving as mask. */
5598 rc
= x_create_x_image_and_pixmap (f
, img
->width
, img
->height
, 1,
5599 &mask_img
, &img
->mask
);
5606 /* Get the X image of IMG->pixmap. */
5607 ximg
= XGetImage (dpy
, img
->pixmap
, 0, 0, img
->width
, img
->height
,
5610 /* Determine the background color of ximg. If HOW is `(R G B)'
5611 take that as color. Otherwise, try to determine the color
5613 look_at_corners_p
= 1;
5621 && NATNUMP (XCAR (how
)))
5623 rgb
[i
] = XFASTINT (XCAR (how
)) & 0xffff;
5627 if (i
== 3 && NILP (how
))
5629 char color_name
[30];
5630 XColor exact
, color
;
5633 sprintf (color_name
, "#%04x%04x%04x", rgb
[0], rgb
[1], rgb
[2]);
5635 cmap
= DefaultColormapOfScreen (FRAME_X_SCREEN (f
));
5636 if (XLookupColor (dpy
, cmap
, color_name
, &exact
, &color
))
5639 look_at_corners_p
= 0;
5644 if (look_at_corners_p
)
5646 unsigned long corners
[4];
5649 /* Get the colors at the corners of ximg. */
5650 corners
[0] = XGetPixel (ximg
, 0, 0);
5651 corners
[1] = XGetPixel (ximg
, img
->width
- 1, 0);
5652 corners
[2] = XGetPixel (ximg
, img
->width
- 1, img
->height
- 1);
5653 corners
[3] = XGetPixel (ximg
, 0, img
->height
- 1);
5655 /* Choose the most frequently found color as background. */
5656 for (i
= best_count
= 0; i
< 4; ++i
)
5660 for (j
= n
= 0; j
< 4; ++j
)
5661 if (corners
[i
] == corners
[j
])
5665 bg
= corners
[i
], best_count
= n
;
5669 /* Set all bits in mask_img to 1 whose color in ximg is different
5670 from the background color bg. */
5671 for (y
= 0; y
< img
->height
; ++y
)
5672 for (x
= 0; x
< img
->width
; ++x
)
5673 XPutPixel (mask_img
, x
, y
, XGetPixel (ximg
, x
, y
) != bg
);
5675 /* Put mask_img into img->mask. */
5676 x_put_x_image (f
, mask_img
, img
->mask
, img
->width
, img
->height
);
5677 x_destroy_x_image (mask_img
);
5678 XDestroyImage (ximg
);
5681 #endif /* MAC_TODO */
5688 /***********************************************************************
5689 PBM (mono, gray, color)
5690 ***********************************************************************/
5693 static int pbm_image_p
P_ ((Lisp_Object object
));
5694 static int pbm_load
P_ ((struct frame
*f
, struct image
*img
));
5695 static int pbm_scan_number
P_ ((unsigned char **, unsigned char *));
5697 /* The symbol `pbm' identifying images of this type. */
5701 /* Indices of image specification fields in gs_format, below. */
5703 enum pbm_keyword_index
5716 /* Vector of image_keyword structures describing the format
5717 of valid user-defined image specifications. */
5719 static struct image_keyword pbm_format
[PBM_LAST
] =
5721 {":type", IMAGE_SYMBOL_VALUE
, 1},
5722 {":file", IMAGE_STRING_VALUE
, 0},
5723 {":data", IMAGE_STRING_VALUE
, 0},
5724 {":ascent", IMAGE_NON_NEGATIVE_INTEGER_VALUE
, 0},
5725 {":margin", IMAGE_POSITIVE_INTEGER_VALUE_OR_PAIR
, 0},
5726 {":relief", IMAGE_INTEGER_VALUE
, 0},
5727 {":conversion", IMAGE_DONT_CHECK_VALUE_TYPE
, 0},
5728 {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE
, 0}
5731 /* Structure describing the image type `pbm'. */
5733 static struct image_type pbm_type
=
5743 /* Return non-zero if OBJECT is a valid PBM image specification. */
5746 pbm_image_p (object
)
5749 struct image_keyword fmt
[PBM_LAST
];
5751 bcopy (pbm_format
, fmt
, sizeof fmt
);
5753 if (!parse_image_spec (object
, fmt
, PBM_LAST
, Qpbm
)
5754 || (fmt
[PBM_ASCENT
].count
5755 && XFASTINT (fmt
[PBM_ASCENT
].value
) > 100))
5758 /* Must specify either :data or :file. */
5759 return fmt
[PBM_DATA
].count
+ fmt
[PBM_FILE
].count
== 1;
5763 /* Scan a decimal number from *S and return it. Advance *S while
5764 reading the number. END is the end of the string. Value is -1 at
5768 pbm_scan_number (s
, end
)
5769 unsigned char **s
, *end
;
5775 /* Skip white-space. */
5776 while (*s
< end
&& (c
= *(*s
)++, isspace (c
)))
5781 /* Skip comment to end of line. */
5782 while (*s
< end
&& (c
= *(*s
)++, c
!= '\n'))
5785 else if (isdigit (c
))
5787 /* Read decimal number. */
5789 while (*s
< end
&& (c
= *(*s
)++, isdigit (c
)))
5790 val
= 10 * val
+ c
- '0';
5801 /* Read FILE into memory. Value is a pointer to a buffer allocated
5802 with xmalloc holding FILE's contents. Value is null if an error
5803 occurred. *SIZE is set to the size of the file. */
5806 pbm_read_file (file
, size
)
5814 if (stat (SDATA (file
), &st
) == 0
5815 && (fp
= fopen (SDATA (file
), "r")) != NULL
5816 && (buf
= (char *) xmalloc (st
.st_size
),
5817 fread (buf
, 1, st
.st_size
, fp
) == st
.st_size
))
5837 /* Load PBM image IMG for use on frame F. */
5845 int width
, height
, max_color_idx
= 0;
5847 Lisp_Object file
, specified_file
;
5848 enum {PBM_MONO
, PBM_GRAY
, PBM_COLOR
} type
;
5849 struct gcpro gcpro1
;
5850 unsigned char *contents
= NULL
;
5851 unsigned char *end
, *p
;
5854 specified_file
= image_spec_value (img
->spec
, QCfile
, NULL
);
5858 if (STRINGP (specified_file
))
5860 file
= x_find_image_file (specified_file
);
5861 if (!STRINGP (file
))
5863 image_error ("Cannot find image file `%s'", specified_file
, Qnil
);
5868 contents
= pbm_read_file (file
, &size
);
5869 if (contents
== NULL
)
5871 image_error ("Error reading `%s'", file
, Qnil
);
5877 end
= contents
+ size
;
5882 data
= image_spec_value (img
->spec
, QCdata
, NULL
);
5884 end
= p
+ SBYTES (data
);
5887 /* Check magic number. */
5888 if (end
- p
< 2 || *p
++ != 'P')
5890 image_error ("Not a PBM image: `%s'", img
->spec
, Qnil
);
5900 raw_p
= 0, type
= PBM_MONO
;
5904 raw_p
= 0, type
= PBM_GRAY
;
5908 raw_p
= 0, type
= PBM_COLOR
;
5912 raw_p
= 1, type
= PBM_MONO
;
5916 raw_p
= 1, type
= PBM_GRAY
;
5920 raw_p
= 1, type
= PBM_COLOR
;
5924 image_error ("Not a PBM image: `%s'", img
->spec
, Qnil
);
5928 /* Read width, height, maximum color-component. Characters
5929 starting with `#' up to the end of a line are ignored. */
5930 width
= pbm_scan_number (&p
, end
);
5931 height
= pbm_scan_number (&p
, end
);
5933 if (type
!= PBM_MONO
)
5935 max_color_idx
= pbm_scan_number (&p
, end
);
5936 if (raw_p
&& max_color_idx
> 255)
5937 max_color_idx
= 255;
5942 || (type
!= PBM_MONO
&& max_color_idx
< 0))
5946 if (!x_create_x_image_and_pixmap (f
, width
, height
, 0,
5947 &ximg
, &img
->pixmap
))
5953 /* Initialize the color hash table. */
5954 init_color_table ();
5956 if (type
== PBM_MONO
)
5960 for (y
= 0; y
< height
; ++y
)
5961 for (x
= 0; x
< width
; ++x
)
5971 g
= pbm_scan_number (&p
, end
);
5973 XPutPixel (ximg
, x
, y
, (g
5974 ? FRAME_FOREGROUND_PIXEL (f
)
5975 : FRAME_BACKGROUND_PIXEL (f
)));
5980 for (y
= 0; y
< height
; ++y
)
5981 for (x
= 0; x
< width
; ++x
)
5985 if (type
== PBM_GRAY
)
5986 r
= g
= b
= raw_p
? *p
++ : pbm_scan_number (&p
, end
);
5995 r
= pbm_scan_number (&p
, end
);
5996 g
= pbm_scan_number (&p
, end
);
5997 b
= pbm_scan_number (&p
, end
);
6000 if (r
< 0 || g
< 0 || b
< 0)
6004 XDestroyImage (ximg
);
6006 image_error ("Invalid pixel value in image `%s'",
6011 /* RGB values are now in the range 0..max_color_idx.
6012 Scale this to the range 0..0xffff supported by X. */
6013 r
= (double) r
* 65535 / max_color_idx
;
6014 g
= (double) g
* 65535 / max_color_idx
;
6015 b
= (double) b
* 65535 / max_color_idx
;
6016 XPutPixel (ximg
, x
, y
, lookup_rgb_color (f
, r
, g
, b
));
6020 /* Store in IMG->colors the colors allocated for the image, and
6021 free the color table. */
6022 img
->colors
= colors_in_color_table (&img
->ncolors
);
6023 free_color_table ();
6025 /* Put the image into a pixmap. */
6026 x_put_x_image (f
, ximg
, img
->pixmap
, width
, height
);
6027 x_destroy_x_image (ximg
);
6031 img
->height
= height
;
6037 #endif /* HAVE_PBM */
6040 /***********************************************************************
6042 ***********************************************************************/
6048 /* Function prototypes. */
6050 static int png_image_p
P_ ((Lisp_Object object
));
6051 static int png_load
P_ ((struct frame
*f
, struct image
*img
));
6053 /* The symbol `png' identifying images of this type. */
6057 /* Indices of image specification fields in png_format, below. */
6059 enum png_keyword_index
6072 /* Vector of image_keyword structures describing the format
6073 of valid user-defined image specifications. */
6075 static struct image_keyword png_format
[PNG_LAST
] =
6077 {":type", IMAGE_SYMBOL_VALUE
, 1},
6078 {":data", IMAGE_STRING_VALUE
, 0},
6079 {":file", IMAGE_STRING_VALUE
, 0},
6080 {":ascent", IMAGE_NON_NEGATIVE_INTEGER_VALUE
, 0},
6081 {":margin", IMAGE_POSITIVE_INTEGER_VALUE_OR_PAIR
, 0},
6082 {":relief", IMAGE_INTEGER_VALUE
, 0},
6083 {":conversion", IMAGE_DONT_CHECK_VALUE_TYPE
, 0},
6084 {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE
, 0}
6087 /* Structure describing the image type `png'. */
6089 static struct image_type png_type
=
6099 /* Return non-zero if OBJECT is a valid PNG image specification. */
6102 png_image_p (object
)
6105 struct image_keyword fmt
[PNG_LAST
];
6106 bcopy (png_format
, fmt
, sizeof fmt
);
6108 if (!parse_image_spec (object
, fmt
, PNG_LAST
, Qpng
)
6109 || (fmt
[PNG_ASCENT
].count
6110 && XFASTINT (fmt
[PNG_ASCENT
].value
) > 100))
6113 /* Must specify either the :data or :file keyword. */
6114 return fmt
[PNG_FILE
].count
+ fmt
[PNG_DATA
].count
== 1;
6118 /* Error and warning handlers installed when the PNG library
6122 my_png_error (png_ptr
, msg
)
6123 png_struct
*png_ptr
;
6126 xassert (png_ptr
!= NULL
);
6127 image_error ("PNG error: %s", build_string (msg
), Qnil
);
6128 longjmp (png_ptr
->jmpbuf
, 1);
6133 my_png_warning (png_ptr
, msg
)
6134 png_struct
*png_ptr
;
6137 xassert (png_ptr
!= NULL
);
6138 image_error ("PNG warning: %s", build_string (msg
), Qnil
);
6141 /* Memory source for PNG decoding. */
6143 struct png_memory_storage
6145 unsigned char *bytes
; /* The data */
6146 size_t len
; /* How big is it? */
6147 int index
; /* Where are we? */
6151 /* Function set as reader function when reading PNG image from memory.
6152 PNG_PTR is a pointer to the PNG control structure. Copy LENGTH
6153 bytes from the input to DATA. */
6156 png_read_from_memory (png_ptr
, data
, length
)
6157 png_structp png_ptr
;
6161 struct png_memory_storage
*tbr
6162 = (struct png_memory_storage
*) png_get_io_ptr (png_ptr
);
6164 if (length
> tbr
->len
- tbr
->index
)
6165 png_error (png_ptr
, "Read error");
6167 bcopy (tbr
->bytes
+ tbr
->index
, data
, length
);
6168 tbr
->index
= tbr
->index
+ length
;
6171 /* Load PNG image IMG for use on frame F. Value is non-zero if
6179 Lisp_Object file
, specified_file
;
6180 Lisp_Object specified_data
;
6182 XImage
*ximg
, *mask_img
= NULL
;
6183 struct gcpro gcpro1
;
6184 png_struct
*png_ptr
= NULL
;
6185 png_info
*info_ptr
= NULL
, *end_info
= NULL
;
6188 png_byte
*pixels
= NULL
;
6189 png_byte
**rows
= NULL
;
6190 png_uint_32 width
, height
;
6191 int bit_depth
, color_type
, interlace_type
;
6193 png_uint_32 row_bytes
;
6196 double screen_gamma
, image_gamma
;
6198 struct png_memory_storage tbr
; /* Data to be read */
6200 /* Find out what file to load. */
6201 specified_file
= image_spec_value (img
->spec
, QCfile
, NULL
);
6202 specified_data
= image_spec_value (img
->spec
, QCdata
, NULL
);
6206 if (NILP (specified_data
))
6208 file
= x_find_image_file (specified_file
);
6209 if (!STRINGP (file
))
6211 image_error ("Cannot find image file `%s'", specified_file
, Qnil
);
6216 /* Open the image file. */
6217 fp
= fopen (SDATA (file
), "rb");
6220 image_error ("Cannot open image file `%s'", file
, Qnil
);
6226 /* Check PNG signature. */
6227 if (fread (sig
, 1, sizeof sig
, fp
) != sizeof sig
6228 || !png_check_sig (sig
, sizeof sig
))
6230 image_error ("Not a PNG file:` %s'", file
, Qnil
);
6238 /* Read from memory. */
6239 tbr
.bytes
= SDATA (specified_data
);
6240 tbr
.len
= SBYTES (specified_data
);
6243 /* Check PNG signature. */
6244 if (tbr
.len
< sizeof sig
6245 || !png_check_sig (tbr
.bytes
, sizeof sig
))
6247 image_error ("Not a PNG image: `%s'", img
->spec
, Qnil
);
6252 /* Need to skip past the signature. */
6253 tbr
.bytes
+= sizeof (sig
);
6256 /* Initialize read and info structs for PNG lib. */
6257 png_ptr
= png_create_read_struct (PNG_LIBPNG_VER_STRING
, NULL
,
6258 my_png_error
, my_png_warning
);
6261 if (fp
) fclose (fp
);
6266 info_ptr
= png_create_info_struct (png_ptr
);
6269 png_destroy_read_struct (&png_ptr
, NULL
, NULL
);
6270 if (fp
) fclose (fp
);
6275 end_info
= png_create_info_struct (png_ptr
);
6278 png_destroy_read_struct (&png_ptr
, &info_ptr
, NULL
);
6279 if (fp
) fclose (fp
);
6284 /* Set error jump-back. We come back here when the PNG library
6285 detects an error. */
6286 if (setjmp (png_ptr
->jmpbuf
))
6290 png_destroy_read_struct (&png_ptr
, &info_ptr
, &end_info
);
6293 if (fp
) fclose (fp
);
6298 /* Read image info. */
6299 if (!NILP (specified_data
))
6300 png_set_read_fn (png_ptr
, (void *) &tbr
, png_read_from_memory
);
6302 png_init_io (png_ptr
, fp
);
6304 png_set_sig_bytes (png_ptr
, sizeof sig
);
6305 png_read_info (png_ptr
, info_ptr
);
6306 png_get_IHDR (png_ptr
, info_ptr
, &width
, &height
, &bit_depth
, &color_type
,
6307 &interlace_type
, NULL
, NULL
);
6309 /* If image contains simply transparency data, we prefer to
6310 construct a clipping mask. */
6311 if (png_get_valid (png_ptr
, info_ptr
, PNG_INFO_tRNS
))
6316 /* This function is easier to write if we only have to handle
6317 one data format: RGB or RGBA with 8 bits per channel. Let's
6318 transform other formats into that format. */
6320 /* Strip more than 8 bits per channel. */
6321 if (bit_depth
== 16)
6322 png_set_strip_16 (png_ptr
);
6324 /* Expand data to 24 bit RGB, or 8 bit grayscale, with alpha channel
6326 png_set_expand (png_ptr
);
6328 /* Convert grayscale images to RGB. */
6329 if (color_type
== PNG_COLOR_TYPE_GRAY
6330 || color_type
== PNG_COLOR_TYPE_GRAY_ALPHA
)
6331 png_set_gray_to_rgb (png_ptr
);
6333 /* The value 2.2 is a guess for PC monitors from PNG example.c. */
6334 gamma_str
= getenv ("SCREEN_GAMMA");
6335 screen_gamma
= gamma_str
? atof (gamma_str
) : 2.2;
6337 /* Tell the PNG lib to handle gamma correction for us. */
6339 #if defined(PNG_READ_sRGB_SUPPORTED) || defined(PNG_WRITE_sRGB_SUPPORTED)
6340 if (png_get_sRGB (png_ptr
, info_ptr
, &intent
))
6341 /* There is a special chunk in the image specifying the gamma. */
6342 png_set_sRGB (png_ptr
, info_ptr
, intent
);
6345 if (png_get_gAMA (png_ptr
, info_ptr
, &image_gamma
))
6346 /* Image contains gamma information. */
6347 png_set_gamma (png_ptr
, screen_gamma
, image_gamma
);
6349 /* Use a default of 0.5 for the image gamma. */
6350 png_set_gamma (png_ptr
, screen_gamma
, 0.5);
6352 /* Handle alpha channel by combining the image with a background
6353 color. Do this only if a real alpha channel is supplied. For
6354 simple transparency, we prefer a clipping mask. */
6357 png_color_16
*image_background
;
6359 if (png_get_bKGD (png_ptr
, info_ptr
, &image_background
))
6360 /* Image contains a background color with which to
6361 combine the image. */
6362 png_set_background (png_ptr
, image_background
,
6363 PNG_BACKGROUND_GAMMA_FILE
, 1, 1.0);
6366 /* Image does not contain a background color with which
6367 to combine the image data via an alpha channel. Use
6368 the frame's background instead. */
6371 png_color_16 frame_background
;
6374 cmap
= DefaultColormapOfScreen (FRAME_X_SCREEN (f
));
6375 color
.pixel
= FRAME_BACKGROUND_PIXEL (f
);
6376 XQueryColor (FRAME_W32_DISPLAY (f
), cmap
, &color
);
6379 bzero (&frame_background
, sizeof frame_background
);
6380 frame_background
.red
= color
.red
;
6381 frame_background
.green
= color
.green
;
6382 frame_background
.blue
= color
.blue
;
6384 png_set_background (png_ptr
, &frame_background
,
6385 PNG_BACKGROUND_GAMMA_SCREEN
, 0, 1.0);
6389 /* Update info structure. */
6390 png_read_update_info (png_ptr
, info_ptr
);
6392 /* Get number of channels. Valid values are 1 for grayscale images
6393 and images with a palette, 2 for grayscale images with transparency
6394 information (alpha channel), 3 for RGB images, and 4 for RGB
6395 images with alpha channel, i.e. RGBA. If conversions above were
6396 sufficient we should only have 3 or 4 channels here. */
6397 channels
= png_get_channels (png_ptr
, info_ptr
);
6398 xassert (channels
== 3 || channels
== 4);
6400 /* Number of bytes needed for one row of the image. */
6401 row_bytes
= png_get_rowbytes (png_ptr
, info_ptr
);
6403 /* Allocate memory for the image. */
6404 pixels
= (png_byte
*) xmalloc (row_bytes
* height
* sizeof *pixels
);
6405 rows
= (png_byte
**) xmalloc (height
* sizeof *rows
);
6406 for (i
= 0; i
< height
; ++i
)
6407 rows
[i
] = pixels
+ i
* row_bytes
;
6409 /* Read the entire image. */
6410 png_read_image (png_ptr
, rows
);
6411 png_read_end (png_ptr
, info_ptr
);
6420 /* Create the X image and pixmap. */
6421 if (!x_create_x_image_and_pixmap (f
, width
, height
, 0, &ximg
,
6428 /* Create an image and pixmap serving as mask if the PNG image
6429 contains an alpha channel. */
6432 && !x_create_x_image_and_pixmap (f
, width
, height
, 1,
6433 &mask_img
, &img
->mask
))
6435 x_destroy_x_image (ximg
);
6436 XFreePixmap (FRAME_W32_DISPLAY (f
), img
->pixmap
);
6442 /* Fill the X image and mask from PNG data. */
6443 init_color_table ();
6445 for (y
= 0; y
< height
; ++y
)
6447 png_byte
*p
= rows
[y
];
6449 for (x
= 0; x
< width
; ++x
)
6456 XPutPixel (ximg
, x
, y
, lookup_rgb_color (f
, r
, g
, b
));
6458 /* An alpha channel, aka mask channel, associates variable
6459 transparency with an image. Where other image formats
6460 support binary transparency---fully transparent or fully
6461 opaque---PNG allows up to 254 levels of partial transparency.
6462 The PNG library implements partial transparency by combining
6463 the image with a specified background color.
6465 I'm not sure how to handle this here nicely: because the
6466 background on which the image is displayed may change, for
6467 real alpha channel support, it would be necessary to create
6468 a new image for each possible background.
6470 What I'm doing now is that a mask is created if we have
6471 boolean transparency information. Otherwise I'm using
6472 the frame's background color to combine the image with. */
6477 XPutPixel (mask_img
, x
, y
, *p
> 0);
6483 /* Remember colors allocated for this image. */
6484 img
->colors
= colors_in_color_table (&img
->ncolors
);
6485 free_color_table ();
6488 png_destroy_read_struct (&png_ptr
, &info_ptr
, &end_info
);
6493 img
->height
= height
;
6495 /* Put the image into the pixmap, then free the X image and its buffer. */
6496 x_put_x_image (f
, ximg
, img
->pixmap
, width
, height
);
6497 x_destroy_x_image (ximg
);
6499 /* Same for the mask. */
6502 x_put_x_image (f
, mask_img
, img
->mask
, img
->width
, img
->height
);
6503 x_destroy_x_image (mask_img
);
6511 #endif /* HAVE_PNG != 0 */
6515 /***********************************************************************
6517 ***********************************************************************/
6521 /* Work around a warning about HAVE_STDLIB_H being redefined in
6523 #ifdef HAVE_STDLIB_H
6524 #define HAVE_STDLIB_H_1
6525 #undef HAVE_STDLIB_H
6526 #endif /* HAVE_STLIB_H */
6528 #include <jpeglib.h>
6532 #ifdef HAVE_STLIB_H_1
6533 #define HAVE_STDLIB_H 1
6536 static int jpeg_image_p
P_ ((Lisp_Object object
));
6537 static int jpeg_load
P_ ((struct frame
*f
, struct image
*img
));
6539 /* The symbol `jpeg' identifying images of this type. */
6543 /* Indices of image specification fields in gs_format, below. */
6545 enum jpeg_keyword_index
6554 JPEG_HEURISTIC_MASK
,
6558 /* Vector of image_keyword structures describing the format
6559 of valid user-defined image specifications. */
6561 static struct image_keyword jpeg_format
[JPEG_LAST
] =
6563 {":type", IMAGE_SYMBOL_VALUE
, 1},
6564 {":data", IMAGE_STRING_VALUE
, 0},
6565 {":file", IMAGE_STRING_VALUE
, 0},
6566 {":ascent", IMAGE_NON_NEGATIVE_INTEGER_VALUE
, 0},
6567 {":margin", IMAGE_POSITIVE_INTEGER_VALUE_OR_PAIR
, 0},
6568 {":relief", IMAGE_INTEGER_VALUE
, 0},
6569 {":conversion", IMAGE_DONT_CHECK_VALUE_TYPE
, 0},
6570 {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE
, 0}
6573 /* Structure describing the image type `jpeg'. */
6575 static struct image_type jpeg_type
=
6585 /* Return non-zero if OBJECT is a valid JPEG image specification. */
6588 jpeg_image_p (object
)
6591 struct image_keyword fmt
[JPEG_LAST
];
6593 bcopy (jpeg_format
, fmt
, sizeof fmt
);
6595 if (!parse_image_spec (object
, fmt
, JPEG_LAST
, Qjpeg
)
6596 || (fmt
[JPEG_ASCENT
].count
6597 && XFASTINT (fmt
[JPEG_ASCENT
].value
) > 100))
6600 /* Must specify either the :data or :file keyword. */
6601 return fmt
[JPEG_FILE
].count
+ fmt
[JPEG_DATA
].count
== 1;
6605 struct my_jpeg_error_mgr
6607 struct jpeg_error_mgr pub
;
6608 jmp_buf setjmp_buffer
;
6612 my_error_exit (cinfo
)
6615 struct my_jpeg_error_mgr
*mgr
= (struct my_jpeg_error_mgr
*) cinfo
->err
;
6616 longjmp (mgr
->setjmp_buffer
, 1);
6619 /* Init source method for JPEG data source manager. Called by
6620 jpeg_read_header() before any data is actually read. See
6621 libjpeg.doc from the JPEG lib distribution. */
6624 our_init_source (cinfo
)
6625 j_decompress_ptr cinfo
;
6630 /* Fill input buffer method for JPEG data source manager. Called
6631 whenever more data is needed. We read the whole image in one step,
6632 so this only adds a fake end of input marker at the end. */
6635 our_fill_input_buffer (cinfo
)
6636 j_decompress_ptr cinfo
;
6638 /* Insert a fake EOI marker. */
6639 struct jpeg_source_mgr
*src
= cinfo
->src
;
6640 static JOCTET buffer
[2];
6642 buffer
[0] = (JOCTET
) 0xFF;
6643 buffer
[1] = (JOCTET
) JPEG_EOI
;
6645 src
->next_input_byte
= buffer
;
6646 src
->bytes_in_buffer
= 2;
6651 /* Method to skip over NUM_BYTES bytes in the image data. CINFO->src
6652 is the JPEG data source manager. */
6655 our_skip_input_data (cinfo
, num_bytes
)
6656 j_decompress_ptr cinfo
;
6659 struct jpeg_source_mgr
*src
= (struct jpeg_source_mgr
*) cinfo
->src
;
6663 if (num_bytes
> src
->bytes_in_buffer
)
6664 ERREXIT (cinfo
, JERR_INPUT_EOF
);
6666 src
->bytes_in_buffer
-= num_bytes
;
6667 src
->next_input_byte
+= num_bytes
;
6672 /* Method to terminate data source. Called by
6673 jpeg_finish_decompress() after all data has been processed. */
6676 our_term_source (cinfo
)
6677 j_decompress_ptr cinfo
;
6682 /* Set up the JPEG lib for reading an image from DATA which contains
6683 LEN bytes. CINFO is the decompression info structure created for
6684 reading the image. */
6687 jpeg_memory_src (cinfo
, data
, len
)
6688 j_decompress_ptr cinfo
;
6692 struct jpeg_source_mgr
*src
;
6694 if (cinfo
->src
== NULL
)
6696 /* First time for this JPEG object? */
6697 cinfo
->src
= (struct jpeg_source_mgr
*)
6698 (*cinfo
->mem
->alloc_small
) ((j_common_ptr
) cinfo
, JPOOL_PERMANENT
,
6699 sizeof (struct jpeg_source_mgr
));
6700 src
= (struct jpeg_source_mgr
*) cinfo
->src
;
6701 src
->next_input_byte
= data
;
6704 src
= (struct jpeg_source_mgr
*) cinfo
->src
;
6705 src
->init_source
= our_init_source
;
6706 src
->fill_input_buffer
= our_fill_input_buffer
;
6707 src
->skip_input_data
= our_skip_input_data
;
6708 src
->resync_to_restart
= jpeg_resync_to_restart
; /* Use default method. */
6709 src
->term_source
= our_term_source
;
6710 src
->bytes_in_buffer
= len
;
6711 src
->next_input_byte
= data
;
6715 /* Load image IMG for use on frame F. Patterned after example.c
6716 from the JPEG lib. */
6723 struct jpeg_decompress_struct cinfo
;
6724 struct my_jpeg_error_mgr mgr
;
6725 Lisp_Object file
, specified_file
;
6726 Lisp_Object specified_data
;
6729 int row_stride
, x
, y
;
6730 XImage
*ximg
= NULL
;
6732 unsigned long *colors
;
6734 struct gcpro gcpro1
;
6736 /* Open the JPEG file. */
6737 specified_file
= image_spec_value (img
->spec
, QCfile
, NULL
);
6738 specified_data
= image_spec_value (img
->spec
, QCdata
, NULL
);
6742 if (NILP (specified_data
))
6744 file
= x_find_image_file (specified_file
);
6745 if (!STRINGP (file
))
6747 image_error ("Cannot find image file `%s'", specified_file
, Qnil
);
6752 fp
= fopen (SDATA (file
), "r");
6755 image_error ("Cannot open `%s'", file
, Qnil
);
6761 /* Customize libjpeg's error handling to call my_error_exit when an
6762 error is detected. This function will perform a longjmp. */
6763 mgr
.pub
.error_exit
= my_error_exit
;
6764 cinfo
.err
= jpeg_std_error (&mgr
.pub
);
6766 if ((rc
= setjmp (mgr
.setjmp_buffer
)) != 0)
6770 /* Called from my_error_exit. Display a JPEG error. */
6771 char buffer
[JMSG_LENGTH_MAX
];
6772 cinfo
.err
->format_message ((j_common_ptr
) &cinfo
, buffer
);
6773 image_error ("Error reading JPEG image `%s': %s", img
->spec
,
6774 build_string (buffer
));
6777 /* Close the input file and destroy the JPEG object. */
6780 jpeg_destroy_decompress (&cinfo
);
6784 /* If we already have an XImage, free that. */
6785 x_destroy_x_image (ximg
);
6787 /* Free pixmap and colors. */
6788 x_clear_image (f
, img
);
6795 /* Create the JPEG decompression object. Let it read from fp.
6796 Read the JPEG image header. */
6797 jpeg_create_decompress (&cinfo
);
6799 if (NILP (specified_data
))
6800 jpeg_stdio_src (&cinfo
, fp
);
6802 jpeg_memory_src (&cinfo
, SDATA (specified_data
),
6803 SBYTES (specified_data
));
6805 jpeg_read_header (&cinfo
, TRUE
);
6807 /* Customize decompression so that color quantization will be used.
6808 Start decompression. */
6809 cinfo
.quantize_colors
= TRUE
;
6810 jpeg_start_decompress (&cinfo
);
6811 width
= img
->width
= cinfo
.output_width
;
6812 height
= img
->height
= cinfo
.output_height
;
6816 /* Create X image and pixmap. */
6817 if (!x_create_x_image_and_pixmap (f
, width
, height
, 0, &ximg
,
6821 longjmp (mgr
.setjmp_buffer
, 2);
6824 /* Allocate colors. When color quantization is used,
6825 cinfo.actual_number_of_colors has been set with the number of
6826 colors generated, and cinfo.colormap is a two-dimensional array
6827 of color indices in the range 0..cinfo.actual_number_of_colors.
6828 No more than 255 colors will be generated. */
6832 if (cinfo
.out_color_components
> 2)
6833 ir
= 0, ig
= 1, ib
= 2;
6834 else if (cinfo
.out_color_components
> 1)
6835 ir
= 0, ig
= 1, ib
= 0;
6837 ir
= 0, ig
= 0, ib
= 0;
6839 /* Use the color table mechanism because it handles colors that
6840 cannot be allocated nicely. Such colors will be replaced with
6841 a default color, and we don't have to care about which colors
6842 can be freed safely, and which can't. */
6843 init_color_table ();
6844 colors
= (unsigned long *) alloca (cinfo
.actual_number_of_colors
6847 for (i
= 0; i
< cinfo
.actual_number_of_colors
; ++i
)
6849 /* Multiply RGB values with 255 because X expects RGB values
6850 in the range 0..0xffff. */
6851 int r
= cinfo
.colormap
[ir
][i
] << 8;
6852 int g
= cinfo
.colormap
[ig
][i
] << 8;
6853 int b
= cinfo
.colormap
[ib
][i
] << 8;
6854 colors
[i
] = lookup_rgb_color (f
, r
, g
, b
);
6857 /* Remember those colors actually allocated. */
6858 img
->colors
= colors_in_color_table (&img
->ncolors
);
6859 free_color_table ();
6863 row_stride
= width
* cinfo
.output_components
;
6864 buffer
= cinfo
.mem
->alloc_sarray ((j_common_ptr
) &cinfo
, JPOOL_IMAGE
,
6866 for (y
= 0; y
< height
; ++y
)
6868 jpeg_read_scanlines (&cinfo
, buffer
, 1);
6869 for (x
= 0; x
< cinfo
.output_width
; ++x
)
6870 XPutPixel (ximg
, x
, y
, colors
[buffer
[0][x
]]);
6874 jpeg_finish_decompress (&cinfo
);
6875 jpeg_destroy_decompress (&cinfo
);
6879 /* Put the image into the pixmap. */
6880 x_put_x_image (f
, ximg
, img
->pixmap
, width
, height
);
6881 x_destroy_x_image (ximg
);
6887 #endif /* HAVE_JPEG */
6891 /***********************************************************************
6893 ***********************************************************************/
6899 static int tiff_image_p
P_ ((Lisp_Object object
));
6900 static int tiff_load
P_ ((struct frame
*f
, struct image
*img
));
6902 /* The symbol `tiff' identifying images of this type. */
6906 /* Indices of image specification fields in tiff_format, below. */
6908 enum tiff_keyword_index
6917 TIFF_HEURISTIC_MASK
,
6921 /* Vector of image_keyword structures describing the format
6922 of valid user-defined image specifications. */
6924 static struct image_keyword tiff_format
[TIFF_LAST
] =
6926 {":type", IMAGE_SYMBOL_VALUE
, 1},
6927 {":data", IMAGE_STRING_VALUE
, 0},
6928 {":file", IMAGE_STRING_VALUE
, 0},
6929 {":ascent", IMAGE_NON_NEGATIVE_INTEGER_VALUE
, 0},
6930 {":margin", IMAGE_POSITIVE_INTEGER_VALUE_OR_PAIR
, 0},
6931 {":relief", IMAGE_INTEGER_VALUE
, 0},
6932 {":conversion", IMAGE_DONT_CHECK_VALUE_TYPE
, 0},
6933 {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE
, 0}
6936 /* Structure describing the image type `tiff'. */
6938 static struct image_type tiff_type
=
6948 /* Return non-zero if OBJECT is a valid TIFF image specification. */
6951 tiff_image_p (object
)
6954 struct image_keyword fmt
[TIFF_LAST
];
6955 bcopy (tiff_format
, fmt
, sizeof fmt
);
6957 if (!parse_image_spec (object
, fmt
, TIFF_LAST
, Qtiff
)
6958 || (fmt
[TIFF_ASCENT
].count
6959 && XFASTINT (fmt
[TIFF_ASCENT
].value
) > 100))
6962 /* Must specify either the :data or :file keyword. */
6963 return fmt
[TIFF_FILE
].count
+ fmt
[TIFF_DATA
].count
== 1;
6967 /* Reading from a memory buffer for TIFF images Based on the PNG
6968 memory source, but we have to provide a lot of extra functions.
6971 We really only need to implement read and seek, but I am not
6972 convinced that the TIFF library is smart enough not to destroy
6973 itself if we only hand it the function pointers we need to
6978 unsigned char *bytes
;
6985 tiff_read_from_memory (data
, buf
, size
)
6990 tiff_memory_source
*src
= (tiff_memory_source
*) data
;
6992 if (size
> src
->len
- src
->index
)
6994 bcopy (src
->bytes
+ src
->index
, buf
, size
);
7000 tiff_write_from_memory (data
, buf
, size
)
7009 tiff_seek_in_memory (data
, off
, whence
)
7014 tiff_memory_source
*src
= (tiff_memory_source
*) data
;
7019 case SEEK_SET
: /* Go from beginning of source. */
7023 case SEEK_END
: /* Go from end of source. */
7024 idx
= src
->len
+ off
;
7027 case SEEK_CUR
: /* Go from current position. */
7028 idx
= src
->index
+ off
;
7031 default: /* Invalid `whence'. */
7035 if (idx
> src
->len
|| idx
< 0)
7043 tiff_close_memory (data
)
7051 tiff_mmap_memory (data
, pbase
, psize
)
7056 /* It is already _IN_ memory. */
7061 tiff_unmap_memory (data
, base
, size
)
7066 /* We don't need to do this. */
7070 tiff_size_of_memory (data
)
7073 return ((tiff_memory_source
*) data
)->len
;
7076 /* Load TIFF image IMG for use on frame F. Value is non-zero if
7084 Lisp_Object file
, specified_file
;
7085 Lisp_Object specified_data
;
7087 int width
, height
, x
, y
;
7091 struct gcpro gcpro1
;
7092 tiff_memory_source memsrc
;
7094 specified_file
= image_spec_value (img
->spec
, QCfile
, NULL
);
7095 specified_data
= image_spec_value (img
->spec
, QCdata
, NULL
);
7099 if (NILP (specified_data
))
7101 /* Read from a file */
7102 file
= x_find_image_file (specified_file
);
7103 if (!STRINGP (file
))
7105 image_error ("Cannot find image file `%s'", file
, Qnil
);
7110 /* Try to open the image file. */
7111 tiff
= TIFFOpen (SDATA (file
), "r");
7114 image_error ("Cannot open `%s'", file
, Qnil
);
7121 /* Memory source! */
7122 memsrc
.bytes
= SDATA (specified_data
);
7123 memsrc
.len
= SBYTES (specified_data
);
7126 tiff
= TIFFClientOpen ("memory_source", "r", &memsrc
,
7127 (TIFFReadWriteProc
) tiff_read_from_memory
,
7128 (TIFFReadWriteProc
) tiff_write_from_memory
,
7129 tiff_seek_in_memory
,
7131 tiff_size_of_memory
,
7137 image_error ("Cannot open memory source for `%s'", img
->spec
, Qnil
);
7143 /* Get width and height of the image, and allocate a raster buffer
7144 of width x height 32-bit values. */
7145 TIFFGetField (tiff
, TIFFTAG_IMAGEWIDTH
, &width
);
7146 TIFFGetField (tiff
, TIFFTAG_IMAGELENGTH
, &height
);
7147 buf
= (uint32
*) xmalloc (width
* height
* sizeof *buf
);
7149 rc
= TIFFReadRGBAImage (tiff
, width
, height
, buf
, 0);
7153 image_error ("Error reading TIFF image `%s'", img
->spec
, Qnil
);
7161 /* Create the X image and pixmap. */
7162 if (!x_create_x_image_and_pixmap (f
, width
, height
, 0, &ximg
, &img
->pixmap
))
7170 /* Initialize the color table. */
7171 init_color_table ();
7173 /* Process the pixel raster. Origin is in the lower-left corner. */
7174 for (y
= 0; y
< height
; ++y
)
7176 uint32
*row
= buf
+ y
* width
;
7178 for (x
= 0; x
< width
; ++x
)
7180 uint32 abgr
= row
[x
];
7181 int r
= TIFFGetR (abgr
) << 8;
7182 int g
= TIFFGetG (abgr
) << 8;
7183 int b
= TIFFGetB (abgr
) << 8;
7184 XPutPixel (ximg
, x
, height
- 1 - y
, lookup_rgb_color (f
, r
, g
, b
));
7188 /* Remember the colors allocated for the image. Free the color table. */
7189 img
->colors
= colors_in_color_table (&img
->ncolors
);
7190 free_color_table ();
7192 /* Put the image into the pixmap, then free the X image and its buffer. */
7193 x_put_x_image (f
, ximg
, img
->pixmap
, width
, height
);
7194 x_destroy_x_image (ximg
);
7199 img
->height
= height
;
7205 #endif /* HAVE_TIFF != 0 */
7209 /***********************************************************************
7211 ***********************************************************************/
7215 #include <gif_lib.h>
7217 static int gif_image_p
P_ ((Lisp_Object object
));
7218 static int gif_load
P_ ((struct frame
*f
, struct image
*img
));
7220 /* The symbol `gif' identifying images of this type. */
7224 /* Indices of image specification fields in gif_format, below. */
7226 enum gif_keyword_index
7240 /* Vector of image_keyword structures describing the format
7241 of valid user-defined image specifications. */
7243 static struct image_keyword gif_format
[GIF_LAST
] =
7245 {":type", IMAGE_SYMBOL_VALUE
, 1},
7246 {":data", IMAGE_STRING_VALUE
, 0},
7247 {":file", IMAGE_STRING_VALUE
, 0},
7248 {":ascent", IMAGE_NON_NEGATIVE_INTEGER_VALUE
, 0},
7249 {":margin", IMAGE_POSITIVE_INTEGER_VALUE_OR_PAIR
, 0},
7250 {":relief", IMAGE_INTEGER_VALUE
, 0},
7251 {":conversion", IMAGE_DONT_CHECK_VALUE_TYPE
, 0},
7252 {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE
, 0},
7253 {":image", IMAGE_NON_NEGATIVE_INTEGER_VALUE
, 0}
7256 /* Structure describing the image type `gif'. */
7258 static struct image_type gif_type
=
7267 /* Return non-zero if OBJECT is a valid GIF image specification. */
7270 gif_image_p (object
)
7273 struct image_keyword fmt
[GIF_LAST
];
7274 bcopy (gif_format
, fmt
, sizeof fmt
);
7276 if (!parse_image_spec (object
, fmt
, GIF_LAST
, Qgif
)
7277 || (fmt
[GIF_ASCENT
].count
7278 && XFASTINT (fmt
[GIF_ASCENT
].value
) > 100))
7281 /* Must specify either the :data or :file keyword. */
7282 return fmt
[GIF_FILE
].count
+ fmt
[GIF_DATA
].count
== 1;
7285 /* Reading a GIF image from memory
7286 Based on the PNG memory stuff to a certain extent. */
7290 unsigned char *bytes
;
7296 /* Make the current memory source available to gif_read_from_memory.
7297 It's done this way because not all versions of libungif support
7298 a UserData field in the GifFileType structure. */
7299 static gif_memory_source
*current_gif_memory_src
;
7302 gif_read_from_memory (file
, buf
, len
)
7307 gif_memory_source
*src
= current_gif_memory_src
;
7309 if (len
> src
->len
- src
->index
)
7312 bcopy (src
->bytes
+ src
->index
, buf
, len
);
7318 /* Load GIF image IMG for use on frame F. Value is non-zero if
7326 Lisp_Object file
, specified_file
;
7327 Lisp_Object specified_data
;
7328 int rc
, width
, height
, x
, y
, i
;
7330 ColorMapObject
*gif_color_map
;
7331 unsigned long pixel_colors
[256];
7333 struct gcpro gcpro1
;
7335 int ino
, image_left
, image_top
, image_width
, image_height
;
7336 gif_memory_source memsrc
;
7337 unsigned char *raster
;
7339 specified_file
= image_spec_value (img
->spec
, QCfile
, NULL
);
7340 specified_data
= image_spec_value (img
->spec
, QCdata
, NULL
);
7344 if (NILP (specified_data
))
7346 file
= x_find_image_file (specified_file
);
7347 if (!STRINGP (file
))
7349 image_error ("Cannot find image file `%s'", specified_file
, Qnil
);
7354 /* Open the GIF file. */
7355 gif
= DGifOpenFileName (SDATA (file
));
7358 image_error ("Cannot open `%s'", file
, Qnil
);
7365 /* Read from memory! */
7366 current_gif_memory_src
= &memsrc
;
7367 memsrc
.bytes
= SDATA (specified_data
);
7368 memsrc
.len
= SBYTES (specified_data
);
7371 gif
= DGifOpen(&memsrc
, gif_read_from_memory
);
7374 image_error ("Cannot open memory source `%s'", img
->spec
, Qnil
);
7380 /* Read entire contents. */
7381 rc
= DGifSlurp (gif
);
7382 if (rc
== GIF_ERROR
)
7384 image_error ("Error reading `%s'", img
->spec
, Qnil
);
7385 DGifCloseFile (gif
);
7390 image
= image_spec_value (img
->spec
, QCindex
, NULL
);
7391 ino
= INTEGERP (image
) ? XFASTINT (image
) : 0;
7392 if (ino
>= gif
->ImageCount
)
7394 image_error ("Invalid image number `%s' in image `%s'",
7396 DGifCloseFile (gif
);
7401 width
= img
->width
= gif
->SWidth
;
7402 height
= img
->height
= gif
->SHeight
;
7406 /* Create the X image and pixmap. */
7407 if (!x_create_x_image_and_pixmap (f
, width
, height
, 0, &ximg
, &img
->pixmap
))
7410 DGifCloseFile (gif
);
7415 /* Allocate colors. */
7416 gif_color_map
= gif
->SavedImages
[ino
].ImageDesc
.ColorMap
;
7418 gif_color_map
= gif
->SColorMap
;
7419 init_color_table ();
7420 bzero (pixel_colors
, sizeof pixel_colors
);
7422 for (i
= 0; i
< gif_color_map
->ColorCount
; ++i
)
7424 int r
= gif_color_map
->Colors
[i
].Red
<< 8;
7425 int g
= gif_color_map
->Colors
[i
].Green
<< 8;
7426 int b
= gif_color_map
->Colors
[i
].Blue
<< 8;
7427 pixel_colors
[i
] = lookup_rgb_color (f
, r
, g
, b
);
7430 img
->colors
= colors_in_color_table (&img
->ncolors
);
7431 free_color_table ();
7433 /* Clear the part of the screen image that are not covered by
7434 the image from the GIF file. Full animated GIF support
7435 requires more than can be done here (see the gif89 spec,
7436 disposal methods). Let's simply assume that the part
7437 not covered by a sub-image is in the frame's background color. */
7438 image_top
= gif
->SavedImages
[ino
].ImageDesc
.Top
;
7439 image_left
= gif
->SavedImages
[ino
].ImageDesc
.Left
;
7440 image_width
= gif
->SavedImages
[ino
].ImageDesc
.Width
;
7441 image_height
= gif
->SavedImages
[ino
].ImageDesc
.Height
;
7443 for (y
= 0; y
< image_top
; ++y
)
7444 for (x
= 0; x
< width
; ++x
)
7445 XPutPixel (ximg
, x
, y
, FRAME_BACKGROUND_PIXEL (f
));
7447 for (y
= image_top
+ image_height
; y
< height
; ++y
)
7448 for (x
= 0; x
< width
; ++x
)
7449 XPutPixel (ximg
, x
, y
, FRAME_BACKGROUND_PIXEL (f
));
7451 for (y
= image_top
; y
< image_top
+ image_height
; ++y
)
7453 for (x
= 0; x
< image_left
; ++x
)
7454 XPutPixel (ximg
, x
, y
, FRAME_BACKGROUND_PIXEL (f
));
7455 for (x
= image_left
+ image_width
; x
< width
; ++x
)
7456 XPutPixel (ximg
, x
, y
, FRAME_BACKGROUND_PIXEL (f
));
7459 /* Read the GIF image into the X image. We use a local variable
7460 `raster' here because RasterBits below is a char *, and invites
7461 problems with bytes >= 0x80. */
7462 raster
= (unsigned char *) gif
->SavedImages
[ino
].RasterBits
;
7464 if (gif
->SavedImages
[ino
].ImageDesc
.Interlace
)
7466 static int interlace_start
[] = {0, 4, 2, 1};
7467 static int interlace_increment
[] = {8, 8, 4, 2};
7469 int row
= interlace_start
[0];
7473 for (y
= 0; y
< image_height
; y
++)
7475 if (row
>= image_height
)
7477 row
= interlace_start
[++pass
];
7478 while (row
>= image_height
)
7479 row
= interlace_start
[++pass
];
7482 for (x
= 0; x
< image_width
; x
++)
7484 int i
= raster
[(y
* image_width
) + x
];
7485 XPutPixel (ximg
, x
+ image_left
, row
+ image_top
,
7489 row
+= interlace_increment
[pass
];
7494 for (y
= 0; y
< image_height
; ++y
)
7495 for (x
= 0; x
< image_width
; ++x
)
7497 int i
= raster
[y
* image_width
+ x
];
7498 XPutPixel (ximg
, x
+ image_left
, y
+ image_top
, pixel_colors
[i
]);
7502 DGifCloseFile (gif
);
7504 /* Put the image into the pixmap, then free the X image and its buffer. */
7505 x_put_x_image (f
, ximg
, img
->pixmap
, width
, height
);
7506 x_destroy_x_image (ximg
);
7513 #endif /* HAVE_GIF != 0 */
7517 /***********************************************************************
7519 ***********************************************************************/
7521 #ifdef HAVE_GHOSTSCRIPT
7522 static int gs_image_p
P_ ((Lisp_Object object
));
7523 static int gs_load
P_ ((struct frame
*f
, struct image
*img
));
7524 static void gs_clear_image
P_ ((struct frame
*f
, struct image
*img
));
7526 /* The symbol `postscript' identifying images of this type. */
7528 Lisp_Object Qpostscript
;
7530 /* Keyword symbols. */
7532 Lisp_Object QCloader
, QCbounding_box
, QCpt_width
, QCpt_height
;
7534 /* Indices of image specification fields in gs_format, below. */
7536 enum gs_keyword_index
7552 /* Vector of image_keyword structures describing the format
7553 of valid user-defined image specifications. */
7555 static struct image_keyword gs_format
[GS_LAST
] =
7557 {":type", IMAGE_SYMBOL_VALUE
, 1},
7558 {":pt-width", IMAGE_POSITIVE_INTEGER_VALUE
, 1},
7559 {":pt-height", IMAGE_POSITIVE_INTEGER_VALUE
, 1},
7560 {":file", IMAGE_STRING_VALUE
, 1},
7561 {":loader", IMAGE_FUNCTION_VALUE
, 0},
7562 {":bounding-box", IMAGE_DONT_CHECK_VALUE_TYPE
, 1},
7563 {":ascent", IMAGE_NON_NEGATIVE_INTEGER_VALUE
, 0},
7564 {":margin", IMAGE_POSITIVE_INTEGER_VALUE_OR_PAIR
, 0},
7565 {":relief", IMAGE_INTEGER_VALUE
, 0},
7566 {":conversion", IMAGE_DONT_CHECK_VALUE_TYPE
, 0},
7567 {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE
, 0}
7570 /* Structure describing the image type `ghostscript'. */
7572 static struct image_type gs_type
=
7582 /* Free X resources of Ghostscript image IMG which is used on frame F. */
7585 gs_clear_image (f
, img
)
7589 /* IMG->data.ptr_val may contain a recorded colormap. */
7590 xfree (img
->data
.ptr_val
);
7591 x_clear_image (f
, img
);
7595 /* Return non-zero if OBJECT is a valid Ghostscript image
7602 struct image_keyword fmt
[GS_LAST
];
7606 bcopy (gs_format
, fmt
, sizeof fmt
);
7608 if (!parse_image_spec (object
, fmt
, GS_LAST
, Qpostscript
)
7609 || (fmt
[GS_ASCENT
].count
7610 && XFASTINT (fmt
[GS_ASCENT
].value
) > 100))
7613 /* Bounding box must be a list or vector containing 4 integers. */
7614 tem
= fmt
[GS_BOUNDING_BOX
].value
;
7617 for (i
= 0; i
< 4; ++i
, tem
= XCDR (tem
))
7618 if (!CONSP (tem
) || !INTEGERP (XCAR (tem
)))
7623 else if (VECTORP (tem
))
7625 if (XVECTOR (tem
)->size
!= 4)
7627 for (i
= 0; i
< 4; ++i
)
7628 if (!INTEGERP (XVECTOR (tem
)->contents
[i
]))
7638 /* Load Ghostscript image IMG for use on frame F. Value is non-zero
7647 Lisp_Object window_and_pixmap_id
= Qnil
, loader
, pt_height
, pt_width
;
7648 struct gcpro gcpro1
, gcpro2
;
7650 double in_width
, in_height
;
7651 Lisp_Object pixel_colors
= Qnil
;
7653 /* Compute pixel size of pixmap needed from the given size in the
7654 image specification. Sizes in the specification are in pt. 1 pt
7655 = 1/72 in, xdpi and ydpi are stored in the frame's X display
7657 pt_width
= image_spec_value (img
->spec
, QCpt_width
, NULL
);
7658 in_width
= XFASTINT (pt_width
) / 72.0;
7659 img
->width
= in_width
* FRAME_W32_DISPLAY_INFO (f
)->resx
;
7660 pt_height
= image_spec_value (img
->spec
, QCpt_height
, NULL
);
7661 in_height
= XFASTINT (pt_height
) / 72.0;
7662 img
->height
= in_height
* FRAME_W32_DISPLAY_INFO (f
)->resy
;
7664 /* Create the pixmap. */
7666 xassert (img
->pixmap
== 0);
7667 img
->pixmap
= XCreatePixmap (FRAME_W32_DISPLAY (f
), FRAME_W32_WINDOW (f
),
7668 img
->width
, img
->height
,
7669 DefaultDepthOfScreen (FRAME_X_SCREEN (f
)));
7674 image_error ("Unable to create pixmap for `%s'", img
->spec
, Qnil
);
7678 /* Call the loader to fill the pixmap. It returns a process object
7679 if successful. We do not record_unwind_protect here because
7680 other places in redisplay like calling window scroll functions
7681 don't either. Let the Lisp loader use `unwind-protect' instead. */
7682 GCPRO2 (window_and_pixmap_id
, pixel_colors
);
7684 sprintf (buffer
, "%lu %lu",
7685 (unsigned long) FRAME_W32_WINDOW (f
),
7686 (unsigned long) img
->pixmap
);
7687 window_and_pixmap_id
= build_string (buffer
);
7689 sprintf (buffer
, "%lu %lu",
7690 FRAME_FOREGROUND_PIXEL (f
),
7691 FRAME_BACKGROUND_PIXEL (f
));
7692 pixel_colors
= build_string (buffer
);
7694 XSETFRAME (frame
, f
);
7695 loader
= image_spec_value (img
->spec
, QCloader
, NULL
);
7697 loader
= intern ("gs-load-image");
7699 img
->data
.lisp_val
= call6 (loader
, frame
, img
->spec
,
7700 make_number (img
->width
),
7701 make_number (img
->height
),
7702 window_and_pixmap_id
,
7705 return PROCESSP (img
->data
.lisp_val
);
7709 /* Kill the Ghostscript process that was started to fill PIXMAP on
7710 frame F. Called from XTread_socket when receiving an event
7711 telling Emacs that Ghostscript has finished drawing. */
7714 x_kill_gs_process (pixmap
, f
)
7718 struct image_cache
*c
= FRAME_X_IMAGE_CACHE (f
);
7722 /* Find the image containing PIXMAP. */
7723 for (i
= 0; i
< c
->used
; ++i
)
7724 if (c
->images
[i
]->pixmap
== pixmap
)
7727 /* Kill the GS process. We should have found PIXMAP in the image
7728 cache and its image should contain a process object. */
7729 xassert (i
< c
->used
);
7731 xassert (PROCESSP (img
->data
.lisp_val
));
7732 Fkill_process (img
->data
.lisp_val
, Qnil
);
7733 img
->data
.lisp_val
= Qnil
;
7735 /* On displays with a mutable colormap, figure out the colors
7736 allocated for the image by looking at the pixels of an XImage for
7738 class = FRAME_W32_DISPLAY_INFO (f
)->visual
->class;
7739 if (class != StaticColor
&& class != StaticGray
&& class != TrueColor
)
7745 /* Try to get an XImage for img->pixmep. */
7746 ximg
= XGetImage (FRAME_W32_DISPLAY (f
), img
->pixmap
,
7747 0, 0, img
->width
, img
->height
, ~0, ZPixmap
);
7752 /* Initialize the color table. */
7753 init_color_table ();
7755 /* For each pixel of the image, look its color up in the
7756 color table. After having done so, the color table will
7757 contain an entry for each color used by the image. */
7758 for (y
= 0; y
< img
->height
; ++y
)
7759 for (x
= 0; x
< img
->width
; ++x
)
7761 unsigned long pixel
= XGetPixel (ximg
, x
, y
);
7762 lookup_pixel_color (f
, pixel
);
7765 /* Record colors in the image. Free color table and XImage. */
7766 img
->colors
= colors_in_color_table (&img
->ncolors
);
7767 free_color_table ();
7768 XDestroyImage (ximg
);
7770 #if 0 /* This doesn't seem to be the case. If we free the colors
7771 here, we get a BadAccess later in x_clear_image when
7772 freeing the colors. */
7773 /* We have allocated colors once, but Ghostscript has also
7774 allocated colors on behalf of us. So, to get the
7775 reference counts right, free them once. */
7778 Colormap cmap
= DefaultColormapOfScreen (FRAME_X_SCREEN (f
));
7779 XFreeColors (FRAME_W32_DISPLAY (f
), cmap
,
7780 img
->colors
, img
->ncolors
, 0);
7785 image_error ("Cannot get X image of `%s'; colors will not be freed",
7792 #endif /* HAVE_GHOSTSCRIPT */
7795 /***********************************************************************
7797 ***********************************************************************/
7799 DEFUN ("x-change-window-property", Fx_change_window_property
,
7800 Sx_change_window_property
, 2, 3, 0,
7801 doc
: /* Change window property PROP to VALUE on the X window of FRAME.
7802 PROP and VALUE must be strings. FRAME nil or omitted means use the
7803 selected frame. Value is VALUE. */)
7804 (prop
, value
, frame
)
7805 Lisp_Object frame
, prop
, value
;
7807 #if 0 /* MAC_TODO : port window properties to Mac */
7808 struct frame
*f
= check_x_frame (frame
);
7811 CHECK_STRING (prop
);
7812 CHECK_STRING (value
);
7815 prop_atom
= XInternAtom (FRAME_W32_DISPLAY (f
), SDATA (prop
), False
);
7816 XChangeProperty (FRAME_W32_DISPLAY (f
), FRAME_W32_WINDOW (f
),
7817 prop_atom
, XA_STRING
, 8, PropModeReplace
,
7818 SDATA (value
), SCHARS (value
));
7820 /* Make sure the property is set when we return. */
7821 XFlush (FRAME_W32_DISPLAY (f
));
7824 #endif /* MAC_TODO */
7830 DEFUN ("x-delete-window-property", Fx_delete_window_property
,
7831 Sx_delete_window_property
, 1, 2, 0,
7832 doc
: /* Remove window property PROP from X window of FRAME.
7833 FRAME nil or omitted means use the selected frame. Value is PROP. */)
7835 Lisp_Object prop
, frame
;
7837 #if 0 /* MAC_TODO : port window properties to Mac */
7839 struct frame
*f
= check_x_frame (frame
);
7842 CHECK_STRING (prop
);
7844 prop_atom
= XInternAtom (FRAME_W32_DISPLAY (f
), SDATA (prop
), False
);
7845 XDeleteProperty (FRAME_W32_DISPLAY (f
), FRAME_W32_WINDOW (f
), prop_atom
);
7847 /* Make sure the property is removed when we return. */
7848 XFlush (FRAME_W32_DISPLAY (f
));
7850 #endif /* MAC_TODO */
7856 DEFUN ("x-window-property", Fx_window_property
, Sx_window_property
,
7858 doc
: /* Value is the value of window property PROP on FRAME.
7859 If FRAME is nil or omitted, use the selected frame. Value is nil
7860 if FRAME hasn't a property with name PROP or if PROP has no string
7863 Lisp_Object prop
, frame
;
7865 #if 0 /* MAC_TODO : port window properties to Mac */
7867 struct frame
*f
= check_x_frame (frame
);
7870 Lisp_Object prop_value
= Qnil
;
7871 char *tmp_data
= NULL
;
7874 unsigned long actual_size
, bytes_remaining
;
7876 CHECK_STRING (prop
);
7878 prop_atom
= XInternAtom (FRAME_W32_DISPLAY (f
), SDATA (prop
), False
);
7879 rc
= XGetWindowProperty (FRAME_W32_DISPLAY (f
), FRAME_W32_WINDOW (f
),
7880 prop_atom
, 0, 0, False
, XA_STRING
,
7881 &actual_type
, &actual_format
, &actual_size
,
7882 &bytes_remaining
, (unsigned char **) &tmp_data
);
7885 int size
= bytes_remaining
;
7890 rc
= XGetWindowProperty (FRAME_W32_DISPLAY (f
), FRAME_W32_WINDOW (f
),
7891 prop_atom
, 0, bytes_remaining
,
7893 &actual_type
, &actual_format
,
7894 &actual_size
, &bytes_remaining
,
7895 (unsigned char **) &tmp_data
);
7897 prop_value
= make_string (tmp_data
, size
);
7906 #endif /* MAC_TODO */
7912 /***********************************************************************
7914 ***********************************************************************/
7916 /* If non-null, an asynchronous timer that, when it expires, displays
7917 an hourglass cursor on all frames. */
7919 static struct atimer
*hourglass_atimer
;
7921 /* Non-zero means an hourglass cursor is currently shown. */
7923 static int hourglass_shown_p
;
7925 /* Number of seconds to wait before displaying an hourglass cursor. */
7927 static Lisp_Object Vhourglass_delay
;
7929 /* Default number of seconds to wait before displaying an hourglass
7932 #define DEFAULT_HOURGLASS_DELAY 1
7934 /* Function prototypes. */
7936 static void show_hourglass
P_ ((struct atimer
*));
7937 static void hide_hourglass
P_ ((void));
7940 /* Cancel a currently active hourglass timer, and start a new one. */
7945 #if 0 /* MAC_TODO: cursor shape changes. */
7947 int secs
, usecs
= 0;
7949 cancel_hourglass ();
7951 if (INTEGERP (Vhourglass_delay
)
7952 && XINT (Vhourglass_delay
) > 0)
7953 secs
= XFASTINT (Vhourglass_delay
);
7954 else if (FLOATP (Vhourglass_delay
)
7955 && XFLOAT_DATA (Vhourglass_delay
) > 0)
7958 tem
= Ftruncate (Vhourglass_delay
, Qnil
);
7959 secs
= XFASTINT (tem
);
7960 usecs
= (XFLOAT_DATA (Vhourglass_delay
) - secs
) * 1000000;
7963 secs
= DEFAULT_HOURGLASS_DELAY
;
7965 EMACS_SET_SECS_USECS (delay
, secs
, usecs
);
7966 hourglass_atimer
= start_atimer (ATIMER_RELATIVE
, delay
,
7967 show_hourglass
, NULL
);
7968 #endif /* MAC_TODO */
7972 /* Cancel the hourglass cursor timer if active, hide an hourglass
7978 if (hourglass_atimer
)
7980 cancel_atimer (hourglass_atimer
);
7981 hourglass_atimer
= NULL
;
7984 if (hourglass_shown_p
)
7989 /* Timer function of hourglass_atimer. TIMER is equal to
7992 Display an hourglass cursor on all frames by mapping the frames'
7993 hourglass_window. Set the hourglass_p flag in the frames'
7994 output_data.x structure to indicate that an hourglass cursor is
7995 shown on the frames. */
7998 show_hourglass (timer
)
7999 struct atimer
*timer
;
8001 #if 0 /* MAC_TODO: cursor shape changes. */
8002 /* The timer implementation will cancel this timer automatically
8003 after this function has run. Set hourglass_atimer to null
8004 so that we know the timer doesn't have to be canceled. */
8005 hourglass_atimer
= NULL
;
8007 if (!hourglass_shown_p
)
8009 Lisp_Object rest
, frame
;
8013 FOR_EACH_FRAME (rest
, frame
)
8014 if (FRAME_W32_P (XFRAME (frame
)))
8016 struct frame
*f
= XFRAME (frame
);
8018 f
->output_data
.w32
->hourglass_p
= 1;
8020 if (!f
->output_data
.w32
->hourglass_window
)
8022 unsigned long mask
= CWCursor
;
8023 XSetWindowAttributes attrs
;
8025 attrs
.cursor
= f
->output_data
.w32
->hourglass_cursor
;
8027 f
->output_data
.w32
->hourglass_window
8028 = XCreateWindow (FRAME_X_DISPLAY (f
),
8029 FRAME_OUTER_WINDOW (f
),
8030 0, 0, 32000, 32000, 0, 0,
8036 XMapRaised (FRAME_X_DISPLAY (f
),
8037 f
->output_data
.w32
->hourglass_window
);
8038 XFlush (FRAME_X_DISPLAY (f
));
8041 hourglass_shown_p
= 1;
8044 #endif /* MAC_TODO */
8048 /* Hide the hourglass cursor on all frames, if it is currently shown. */
8053 #if 0 /* MAC_TODO: cursor shape changes. */
8054 if (hourglass_shown_p
)
8056 Lisp_Object rest
, frame
;
8059 FOR_EACH_FRAME (rest
, frame
)
8061 struct frame
*f
= XFRAME (frame
);
8064 /* Watch out for newly created frames. */
8065 && f
->output_data
.x
->hourglass_window
)
8067 XUnmapWindow (FRAME_X_DISPLAY (f
),
8068 f
->output_data
.x
->hourglass_window
);
8069 /* Sync here because XTread_socket looks at the
8070 hourglass_p flag that is reset to zero below. */
8071 XSync (FRAME_X_DISPLAY (f
), False
);
8072 f
->output_data
.x
->hourglass_p
= 0;
8076 hourglass_shown_p
= 0;
8079 #endif /* MAC_TODO */
8084 /***********************************************************************
8086 ***********************************************************************/
8088 static Lisp_Object x_create_tip_frame
P_ ((struct mac_display_info
*,
8091 /* The frame of a currently visible tooltip, or null. */
8093 Lisp_Object tip_frame
;
8095 /* If non-nil, a timer started that hides the last tooltip when it
8098 Lisp_Object tip_timer
;
8101 /* If non-nil, a vector of 3 elements containing the last args
8102 with which x-show-tip was called. See there. */
8104 Lisp_Object last_show_tip_args
;
8106 /* Create a frame for a tooltip on the display described by DPYINFO.
8107 PARMS is a list of frame parameters. Value is the frame. */
8110 x_create_tip_frame (dpyinfo
, parms
)
8111 struct mac_display_info
*dpyinfo
;
8114 #if 0 /* MAC_TODO : Mac version */
8116 Lisp_Object frame
, tem
;
8118 long window_prompting
= 0;
8120 int count
= SPECPDL_INDEX ();
8121 struct gcpro gcpro1
, gcpro2
, gcpro3
;
8126 /* Use this general default value to start with until we know if
8127 this frame has a specified name. */
8128 Vx_resource_name
= Vinvocation_name
;
8131 kb
= dpyinfo
->kboard
;
8133 kb
= &the_only_kboard
;
8136 /* Get the name of the frame to use for resource lookup. */
8137 name
= w32_get_arg (parms
, Qname
, "name", "Name", RES_TYPE_STRING
);
8139 && !EQ (name
, Qunbound
)
8141 error ("Invalid frame name--not a string or nil");
8142 Vx_resource_name
= name
;
8145 GCPRO3 (parms
, name
, frame
);
8146 tip_frame
= f
= make_frame (1);
8147 XSETFRAME (frame
, f
);
8148 FRAME_CAN_HAVE_SCROLL_BARS (f
) = 0;
8150 f
->output_method
= output_w32
;
8151 f
->output_data
.w32
=
8152 (struct w32_output
*) xmalloc (sizeof (struct w32_output
));
8153 bzero (f
->output_data
.w32
, sizeof (struct w32_output
));
8155 f
->output_data
.w32
->icon_bitmap
= -1;
8157 FRAME_FONTSET (f
) = -1;
8158 f
->icon_name
= Qnil
;
8161 FRAME_KBOARD (f
) = kb
;
8163 f
->output_data
.w32
->parent_desc
= FRAME_W32_DISPLAY_INFO (f
)->root_window
;
8164 f
->output_data
.w32
->explicit_parent
= 0;
8166 /* Set the name; the functions to which we pass f expect the name to
8168 if (EQ (name
, Qunbound
) || NILP (name
))
8170 f
->name
= build_string (dpyinfo
->x_id_name
);
8171 f
->explicit_name
= 0;
8176 f
->explicit_name
= 1;
8177 /* use the frame's title when getting resources for this frame. */
8178 specbind (Qx_resource_name
, name
);
8181 /* Extract the window parameters from the supplied values
8182 that are needed to determine window geometry. */
8186 font
= w32_get_arg (parms
, Qfont
, "font", "Font", RES_TYPE_STRING
);
8189 /* First, try whatever font the caller has specified. */
8192 tem
= Fquery_fontset (font
, Qnil
);
8194 font
= x_new_fontset (f
, SDATA (tem
));
8196 font
= x_new_font (f
, SDATA (font
));
8199 /* Try out a font which we hope has bold and italic variations. */
8200 if (!STRINGP (font
))
8201 font
= x_new_font (f
, "-adobe-courier-medium-r-*-*-*-120-*-*-*-*-iso8859-1");
8202 if (!STRINGP (font
))
8203 font
= x_new_font (f
, "-misc-fixed-medium-r-normal-*-*-140-*-*-c-*-iso8859-1");
8204 if (! STRINGP (font
))
8205 font
= x_new_font (f
, "-*-*-medium-r-normal-*-*-140-*-*-c-*-iso8859-1");
8206 if (! STRINGP (font
))
8207 /* This was formerly the first thing tried, but it finds too many fonts
8208 and takes too long. */
8209 font
= x_new_font (f
, "-*-*-medium-r-*-*-*-*-*-*-c-*-iso8859-1");
8210 /* If those didn't work, look for something which will at least work. */
8211 if (! STRINGP (font
))
8212 font
= x_new_font (f
, "-*-fixed-*-*-*-*-*-140-*-*-c-*-iso8859-1");
8214 if (! STRINGP (font
))
8215 font
= build_string ("fixed");
8217 x_default_parameter (f
, parms
, Qfont
, font
,
8218 "font", "Font", RES_TYPE_STRING
);
8221 x_default_parameter (f
, parms
, Qborder_width
, make_number (2),
8222 "borderWidth", "BorderWidth", RES_TYPE_NUMBER
);
8224 /* This defaults to 2 in order to match xterm. We recognize either
8225 internalBorderWidth or internalBorder (which is what xterm calls
8227 if (NILP (Fassq (Qinternal_border_width
, parms
)))
8231 value
= w32_get_arg (parms
, Qinternal_border_width
,
8232 "internalBorder", "internalBorder", RES_TYPE_NUMBER
);
8233 if (! EQ (value
, Qunbound
))
8234 parms
= Fcons (Fcons (Qinternal_border_width
, value
),
8238 x_default_parameter (f
, parms
, Qinternal_border_width
, make_number (1),
8239 "internalBorderWidth", "internalBorderWidth",
8242 /* Also do the stuff which must be set before the window exists. */
8243 x_default_parameter (f
, parms
, Qforeground_color
, build_string ("black"),
8244 "foreground", "Foreground", RES_TYPE_STRING
);
8245 x_default_parameter (f
, parms
, Qbackground_color
, build_string ("white"),
8246 "background", "Background", RES_TYPE_STRING
);
8247 x_default_parameter (f
, parms
, Qmouse_color
, build_string ("black"),
8248 "pointerColor", "Foreground", RES_TYPE_STRING
);
8249 x_default_parameter (f
, parms
, Qcursor_color
, build_string ("black"),
8250 "cursorColor", "Foreground", RES_TYPE_STRING
);
8251 x_default_parameter (f
, parms
, Qborder_color
, build_string ("black"),
8252 "borderColor", "BorderColor", RES_TYPE_STRING
);
8254 /* Init faces before x_default_parameter is called for scroll-bar
8255 parameters because that function calls x_set_scroll_bar_width,
8256 which calls change_frame_size, which calls Fset_window_buffer,
8257 which runs hooks, which call Fvertical_motion. At the end, we
8258 end up in init_iterator with a null face cache, which should not
8260 init_frame_faces (f
);
8262 f
->output_data
.w32
->parent_desc
= FRAME_W32_DISPLAY_INFO (f
)->root_window
;
8264 window_prompting
= x_figure_window_size (f
, parms
, 0);
8267 XSetWindowAttributes attrs
;
8271 mask
= CWBackPixel
| CWOverrideRedirect
| CWSaveUnder
| CWEventMask
;
8272 /* Window managers looks at the override-redirect flag to
8273 determine whether or net to give windows a decoration (Xlib
8275 attrs
.override_redirect
= True
;
8276 attrs
.save_under
= True
;
8277 attrs
.background_pixel
= FRAME_BACKGROUND_PIXEL (f
);
8278 /* Arrange for getting MapNotify and UnmapNotify events. */
8279 attrs
.event_mask
= StructureNotifyMask
;
8281 = FRAME_W32_WINDOW (f
)
8282 = XCreateWindow (FRAME_W32_DISPLAY (f
),
8283 FRAME_W32_DISPLAY_INFO (f
)->root_window
,
8284 /* x, y, width, height */
8288 CopyFromParent
, InputOutput
, CopyFromParent
,
8295 x_default_parameter (f
, parms
, Qauto_raise
, Qnil
,
8296 "autoRaise", "AutoRaiseLower", RES_TYPE_BOOLEAN
);
8297 x_default_parameter (f
, parms
, Qauto_lower
, Qnil
,
8298 "autoLower", "AutoRaiseLower", RES_TYPE_BOOLEAN
);
8299 x_default_parameter (f
, parms
, Qcursor_type
, Qbox
,
8300 "cursorType", "CursorType", RES_TYPE_SYMBOL
);
8302 /* Dimensions, especially FRAME_LINES (f), must be done via change_frame_size.
8303 Change will not be effected unless different from the current
8305 width
= FRAME_COLS (f
);
8306 height
= FRAME_LINES (f
);
8307 FRAME_LINES (f
) = 0;
8308 SET_FRAME_COLS (f
, 0);
8309 change_frame_size (f
, height
, width
, 1, 0, 0);
8311 /* Add `tooltip' frame parameter's default value. */
8312 if (NILP (Fframe_parameter (frame
, intern ("tooltip"))))
8313 Fmodify_frame_parameters (frame
, Fcons (Fcons (intern ("tooltip"), Qt
),
8320 /* It is now ok to make the frame official even if we get an error
8321 below. And the frame needs to be on Vframe_list or making it
8322 visible won't work. */
8323 Vframe_list
= Fcons (frame
, Vframe_list
);
8325 /* Now that the frame is official, it counts as a reference to
8327 FRAME_W32_DISPLAY_INFO (f
)->reference_count
++;
8329 return unbind_to (count
, frame
);
8330 #endif /* MAC_TODO */
8335 DEFUN ("x-show-tip", Fx_show_tip
, Sx_show_tip
, 1, 6, 0,
8336 doc
: /* Show STRING in a "tooltip" window on frame FRAME.
8337 A tooltip window is a small window displaying a string.
8339 FRAME nil or omitted means use the selected frame.
8341 PARMS is an optional list of frame parameters which can be used to
8342 change the tooltip's appearance.
8344 Automatically hide the tooltip after TIMEOUT seconds. TIMEOUT nil
8345 means use the default timeout of 5 seconds.
8347 If the list of frame parameters PARAMS contains a `left' parameters,
8348 the tooltip is displayed at that x-position. Otherwise it is
8349 displayed at the mouse position, with offset DX added (default is 5 if
8350 DX isn't specified). Likewise for the y-position; if a `top' frame
8351 parameter is specified, it determines the y-position of the tooltip
8352 window, otherwise it is displayed at the mouse position, with offset
8353 DY added (default is 10). */)
8354 (string
, frame
, parms
, timeout
, dx
, dy
)
8355 Lisp_Object string
, frame
, parms
, timeout
, dx
, dy
;
8360 Lisp_Object buffer
, top
, left
;
8361 struct buffer
*old_buffer
;
8362 struct text_pos pos
;
8363 int i
, width
, height
;
8364 int root_x
, root_y
, win_x
, win_y
;
8366 struct gcpro gcpro1
, gcpro2
, gcpro3
, gcpro4
;
8367 int old_windows_or_buffers_changed
= windows_or_buffers_changed
;
8368 int count
= SPECPDL_INDEX ();
8370 specbind (Qinhibit_redisplay
, Qt
);
8372 GCPRO4 (string
, parms
, frame
, timeout
);
8374 CHECK_STRING (string
);
8375 f
= check_x_frame (frame
);
8377 timeout
= make_number (5);
8379 CHECK_NATNUM (timeout
);
8382 dx
= make_number (5);
8387 dy
= make_number (-10);
8391 if (NILP (last_show_tip_args
))
8392 last_show_tip_args
= Fmake_vector (make_number (3), Qnil
);
8394 if (!NILP (tip_frame
))
8396 Lisp_Object last_string
= AREF (last_show_tip_args
, 0);
8397 Lisp_Object last_frame
= AREF (last_show_tip_args
, 1);
8398 Lisp_Object last_parms
= AREF (last_show_tip_args
, 2);
8400 if (EQ (frame
, last_frame
)
8401 && !NILP (Fequal (last_string
, string
))
8402 && !NILP (Fequal (last_parms
, parms
)))
8404 struct frame
*f
= XFRAME (tip_frame
);
8406 /* Only DX and DY have changed. */
8407 if (!NILP (tip_timer
))
8409 Lisp_Object timer
= tip_timer
;
8411 call1 (Qcancel_timer
, timer
);
8414 #if 0 /* MAC_TODO : Mac specifics */
8416 compute_tip_xy (f
, parms
, dx
, dy
, &root_x
, &root_y
);
8417 XMoveWindow (FRAME_X_DISPLAY (f
), FRAME_X_WINDOW (f
),
8418 root_x
, root_y
- FRAME_PIXEL_HEIGHT (f
));
8420 #endif /* MAC_TODO */
8425 /* Hide a previous tip, if any. */
8428 ASET (last_show_tip_args
, 0, string
);
8429 ASET (last_show_tip_args
, 1, frame
);
8430 ASET (last_show_tip_args
, 2, parms
);
8432 /* Add default values to frame parameters. */
8433 if (NILP (Fassq (Qname
, parms
)))
8434 parms
= Fcons (Fcons (Qname
, build_string ("tooltip")), parms
);
8435 if (NILP (Fassq (Qinternal_border_width
, parms
)))
8436 parms
= Fcons (Fcons (Qinternal_border_width
, make_number (3)), parms
);
8437 if (NILP (Fassq (Qborder_width
, parms
)))
8438 parms
= Fcons (Fcons (Qborder_width
, make_number (1)), parms
);
8439 if (NILP (Fassq (Qborder_color
, parms
)))
8440 parms
= Fcons (Fcons (Qborder_color
, build_string ("lightyellow")), parms
);
8441 if (NILP (Fassq (Qbackground_color
, parms
)))
8442 parms
= Fcons (Fcons (Qbackground_color
, build_string ("lightyellow")),
8445 /* Create a frame for the tooltip, and record it in the global
8446 variable tip_frame. */
8447 frame
= x_create_tip_frame (FRAME_MAC_DISPLAY_INFO (f
), parms
);
8450 /* Set up the frame's root window. Currently we use a size of 80
8451 columns x 40 lines. If someone wants to show a larger tip, he
8452 will loose. I don't think this is a realistic case. */
8453 w
= XWINDOW (FRAME_ROOT_WINDOW (f
));
8454 w
->left_col
= w
->top_line
= make_number (0);
8455 w
->total_cols
= make_number (80);
8456 w
->total_lines
= make_number (40);
8458 w
->pseudo_window_p
= 1;
8460 /* Display the tooltip text in a temporary buffer. */
8461 buffer
= Fget_buffer_create (build_string (" *tip*"));
8462 Fset_window_buffer (FRAME_ROOT_WINDOW (f
), buffer
, Qnil
);
8463 old_buffer
= current_buffer
;
8464 set_buffer_internal_1 (XBUFFER (buffer
));
8466 Finsert (1, &string
);
8467 clear_glyph_matrix (w
->desired_matrix
);
8468 clear_glyph_matrix (w
->current_matrix
);
8469 SET_TEXT_POS (pos
, BEGV
, BEGV_BYTE
);
8470 try_window (FRAME_ROOT_WINDOW (f
), pos
);
8472 /* Compute width and height of the tooltip. */
8474 for (i
= 0; i
< w
->desired_matrix
->nrows
; ++i
)
8476 struct glyph_row
*row
= &w
->desired_matrix
->rows
[i
];
8480 /* Stop at the first empty row at the end. */
8481 if (!row
->enabled_p
|| !row
->displays_text_p
)
8484 /* Let the row go over the full width of the frame. */
8485 row
->full_width_p
= 1;
8487 /* There's a glyph at the end of rows that is use to place
8488 the cursor there. Don't include the width of this glyph. */
8489 if (row
->used
[TEXT_AREA
])
8491 last
= &row
->glyphs
[TEXT_AREA
][row
->used
[TEXT_AREA
] - 1];
8492 row_width
= row
->pixel_width
- last
->pixel_width
;
8495 row_width
= row
->pixel_width
;
8497 height
+= row
->height
;
8498 width
= max (width
, row_width
);
8501 /* Add the frame's internal border to the width and height the X
8502 window should have. */
8503 height
+= 2 * FRAME_INTERNAL_BORDER_WIDTH (f
);
8504 width
+= 2 * FRAME_INTERNAL_BORDER_WIDTH (f
);
8506 /* Move the tooltip window where the mouse pointer is. Resize and
8508 #if 0 /* TODO : Mac specifics */
8509 compute_tip_xy (f
, parms
, dx
, dy
, &root_x
, &root_y
);
8512 XQueryPointer (FRAME_W32_DISPLAY (f
), FRAME_W32_DISPLAY_INFO (f
)->root_window
,
8513 &root
, &child
, &root_x
, &root_y
, &win_x
, &win_y
, &pmask
);
8514 XMoveResizeWindow (FRAME_W32_DISPLAY (f
), FRAME_W32_WINDOW (f
),
8515 root_x
+ 5, root_y
- height
- 5, width
, height
);
8516 XMapRaised (FRAME_W32_DISPLAY (f
), FRAME_W32_WINDOW (f
));
8518 #endif /* MAC_TODO */
8520 /* Draw into the window. */
8521 w
->must_be_updated_p
= 1;
8522 update_single_window (w
, 1);
8524 /* Restore original current buffer. */
8525 set_buffer_internal_1 (old_buffer
);
8526 windows_or_buffers_changed
= old_windows_or_buffers_changed
;
8529 /* Let the tip disappear after timeout seconds. */
8530 tip_timer
= call3 (intern ("run-at-time"), timeout
, Qnil
,
8531 intern ("x-hide-tip"));
8534 return unbind_to (count
, Qnil
);
8538 DEFUN ("x-hide-tip", Fx_hide_tip
, Sx_hide_tip
, 0, 0, 0,
8539 doc
: /* Hide the current tooltip window, if there is any.
8540 Value is t is tooltip was open, nil otherwise. */)
8544 Lisp_Object deleted
, frame
, timer
;
8545 struct gcpro gcpro1
, gcpro2
;
8547 /* Return quickly if nothing to do. */
8548 if (NILP (tip_timer
) && NILP (tip_frame
))
8553 GCPRO2 (frame
, timer
);
8554 tip_frame
= tip_timer
= deleted
= Qnil
;
8556 count
= SPECPDL_INDEX ();
8557 specbind (Qinhibit_redisplay
, Qt
);
8558 specbind (Qinhibit_quit
, Qt
);
8561 call1 (Qcancel_timer
, timer
);
8565 Fdelete_frame (frame
, Qnil
);
8570 return unbind_to (count
, deleted
);
8575 /***********************************************************************
8576 File selection dialog
8577 ***********************************************************************/
8579 #if 0 /* MAC_TODO: can standard file dialog */
8580 extern Lisp_Object Qfile_name_history
;
8582 DEFUN ("x-file-dialog", Fx_file_dialog
, Sx_file_dialog
, 2, 4, 0,
8583 doc
: /* Read file name, prompting with PROMPT in directory DIR.
8584 Use a file selection dialog.
8585 Select DEFAULT-FILENAME in the dialog's file selection box, if
8586 specified. Don't let the user enter a file name in the file
8587 selection dialog's entry field, if MUSTMATCH is non-nil. */)
8588 (prompt
, dir
, default_filename
, mustmatch
)
8589 Lisp_Object prompt
, dir
, default_filename
, mustmatch
;
8591 struct frame
*f
= SELECTED_FRAME ();
8592 Lisp_Object file
= Qnil
;
8593 int count
= SPECPDL_INDEX ();
8594 struct gcpro gcpro1
, gcpro2
, gcpro3
, gcpro4
, gcpro5
;
8595 char filename
[MAX_PATH
+ 1];
8596 char init_dir
[MAX_PATH
+ 1];
8597 int use_dialog_p
= 1;
8599 GCPRO5 (prompt
, dir
, default_filename
, mustmatch
, file
);
8600 CHECK_STRING (prompt
);
8603 /* Create the dialog with PROMPT as title, using DIR as initial
8604 directory and using "*" as pattern. */
8605 dir
= Fexpand_file_name (dir
, Qnil
);
8606 strncpy (init_dir
, SDATA (dir
), MAX_PATH
);
8607 init_dir
[MAX_PATH
] = '\0';
8608 unixtodos_filename (init_dir
);
8610 if (STRINGP (default_filename
))
8612 char *file_name_only
;
8613 char *full_path_name
= SDATA (default_filename
);
8615 unixtodos_filename (full_path_name
);
8617 file_name_only
= strrchr (full_path_name
, '\\');
8618 if (!file_name_only
)
8619 file_name_only
= full_path_name
;
8624 /* If default_file_name is a directory, don't use the open
8625 file dialog, as it does not support selecting
8627 if (!(*file_name_only
))
8631 strncpy (filename
, file_name_only
, MAX_PATH
);
8632 filename
[MAX_PATH
] = '\0';
8639 OPENFILENAME file_details
;
8640 char *filename_file
;
8642 /* Prevent redisplay. */
8643 specbind (Qinhibit_redisplay
, Qt
);
8646 bzero (&file_details
, sizeof (file_details
));
8647 file_details
.lStructSize
= sizeof (file_details
);
8648 file_details
.hwndOwner
= FRAME_W32_WINDOW (f
);
8649 file_details
.lpstrFile
= filename
;
8650 file_details
.nMaxFile
= sizeof (filename
);
8651 file_details
.lpstrInitialDir
= init_dir
;
8652 file_details
.lpstrTitle
= SDATA (prompt
);
8653 file_details
.Flags
= OFN_HIDEREADONLY
| OFN_NOCHANGEDIR
;
8655 if (!NILP (mustmatch
))
8656 file_details
.Flags
|= OFN_FILEMUSTEXIST
| OFN_PATHMUSTEXIST
;
8658 if (GetOpenFileName (&file_details
))
8660 dostounix_filename (filename
);
8661 file
= build_string (filename
);
8667 file
= unbind_to (count
, file
);
8669 /* Open File dialog will not allow folders to be selected, so resort
8670 to minibuffer completing reads for directories. */
8672 file
= Fcompleting_read (prompt
, intern ("read-file-name-internal"),
8673 dir
, mustmatch
, dir
, Qfile_name_history
,
8674 default_filename
, Qnil
);
8678 /* Make "Cancel" equivalent to C-g. */
8680 Fsignal (Qquit
, Qnil
);
8682 return unbind_to (count
, file
);
8684 #endif /* MAC_TODO */
8688 /***********************************************************************
8690 ***********************************************************************/
8694 DEFUN ("imagep", Fimagep
, Simagep
, 1, 1, 0,
8695 doc
: /* Value is non-nil if SPEC is a valid image specification. */)
8699 return valid_image_p (spec
) ? Qt
: Qnil
;
8703 DEFUN ("lookup-image", Flookup_image
, Slookup_image
, 1, 1, 0, "")
8709 if (valid_image_p (spec
))
8710 id
= lookup_image (SELECTED_FRAME (), spec
);
8713 return make_number (id
);
8716 #endif /* GLYPH_DEBUG != 0 */
8720 /***********************************************************************
8722 ***********************************************************************/
8724 /* Keep this list in the same order as frame_parms in frame.c.
8725 Use 0 for unsupported frame parameters. */
8727 frame_parm_handler mac_frame_parm_handlers
[] =
8731 x_set_background_color
,
8737 x_set_foreground_color
,
8739 0, /* MAC_TODO: x_set_icon_type, */
8740 x_set_internal_border_width
,
8741 x_set_menu_bar_lines
,
8743 x_explicitly_set_name
,
8744 x_set_scroll_bar_width
,
8747 x_set_vertical_scroll_bars
,
8749 x_set_tool_bar_lines
,
8750 0, /* MAC_TODO: x_set_scroll_bar_foreground, */
8751 0, /* MAC_TODO: x_set_scroll_bar_background, */
8754 0, /* MAC_TODO: x_set_fringe_width, */
8755 0, /* MAC_TODO: x_set_fringe_width, */
8756 0, /* x_set_wait_for_wm, */
8757 0, /* MAC_TODO: x_set_fullscreen, */
8763 /* Certainly running on Mac. */
8766 /* The section below is built by the lisp expression at the top of the file,
8767 just above where these variables are declared. */
8768 /*&&& init symbols here &&&*/
8769 Qnone
= intern ("none");
8771 Qsuppress_icon
= intern ("suppress-icon");
8772 staticpro (&Qsuppress_icon
);
8773 Qundefined_color
= intern ("undefined-color");
8774 staticpro (&Qundefined_color
);
8775 Qcenter
= intern ("center");
8776 staticpro (&Qcenter
);
8777 /* This is the end of symbol initialization. */
8779 Qhyper
= intern ("hyper");
8780 staticpro (&Qhyper
);
8781 Qsuper
= intern ("super");
8782 staticpro (&Qsuper
);
8783 Qmeta
= intern ("meta");
8785 Qalt
= intern ("alt");
8787 Qctrl
= intern ("ctrl");
8789 Qcontrol
= intern ("control");
8790 staticpro (&Qcontrol
);
8791 Qshift
= intern ("shift");
8792 staticpro (&Qshift
);
8794 /* Text property `display' should be nonsticky by default. */
8795 Vtext_property_default_nonsticky
8796 = Fcons (Fcons (Qdisplay
, Qt
), Vtext_property_default_nonsticky
);
8799 Qlaplace
= intern ("laplace");
8800 staticpro (&Qlaplace
);
8802 Qface_set_after_frame_default
= intern ("face-set-after-frame-default");
8803 staticpro (&Qface_set_after_frame_default
);
8805 Fput (Qundefined_color
, Qerror_conditions
,
8806 Fcons (Qundefined_color
, Fcons (Qerror
, Qnil
)));
8807 Fput (Qundefined_color
, Qerror_message
,
8808 build_string ("Undefined color"));
8810 DEFVAR_LISP ("x-bitmap-file-path", &Vx_bitmap_file_path
,
8811 doc
: /* List of directories to search for window system bitmap files. */);
8812 Vx_bitmap_file_path
= decode_env_path ((char *) 0, "PATH");
8814 DEFVAR_LISP ("x-pointer-shape", &Vx_pointer_shape
,
8815 doc
: /* The shape of the pointer when over text.
8816 Changing the value does not affect existing frames
8817 unless you set the mouse color. */);
8818 Vx_pointer_shape
= Qnil
;
8820 Vx_nontext_pointer_shape
= Qnil
;
8822 Vx_mode_pointer_shape
= Qnil
;
8824 DEFVAR_LISP ("x-hourglass-pointer-shape", &Vx_hourglass_pointer_shape
,
8825 doc
: /* The shape of the pointer when Emacs is hourglass.
8826 This variable takes effect when you create a new frame
8827 or when you set the mouse color. */);
8828 Vx_hourglass_pointer_shape
= Qnil
;
8830 DEFVAR_BOOL ("display-hourglass", &display_hourglass_p
,
8831 doc
: /* Non-zero means Emacs displays an hourglass pointer on window systems. */);
8832 display_hourglass_p
= 1;
8834 DEFVAR_LISP ("hourglass-delay", &Vhourglass_delay
,
8835 doc
: /* *Seconds to wait before displaying an hourglass pointer.
8836 Value must be an integer or float. */);
8837 Vhourglass_delay
= make_number (DEFAULT_HOURGLASS_DELAY
);
8839 DEFVAR_LISP ("x-sensitive-text-pointer-shape",
8840 &Vx_sensitive_text_pointer_shape
,
8841 doc
: /* The shape of the pointer when over mouse-sensitive text.
8842 This variable takes effect when you create a new frame
8843 or when you set the mouse color. */);
8844 Vx_sensitive_text_pointer_shape
= Qnil
;
8846 DEFVAR_LISP ("x-cursor-fore-pixel", &Vx_cursor_fore_pixel
,
8847 doc
: /* A string indicating the foreground color of the cursor box. */);
8848 Vx_cursor_fore_pixel
= Qnil
;
8850 DEFVAR_LISP ("x-no-window-manager", &Vx_no_window_manager
,
8851 doc
: /* Non-nil if no window manager is in use.
8852 Emacs doesn't try to figure this out; this is always nil
8853 unless you set it to something else. */);
8854 /* We don't have any way to find this out, so set it to nil
8855 and maybe the user would like to set it to t. */
8856 Vx_no_window_manager
= Qnil
;
8858 DEFVAR_LISP ("x-pixel-size-width-font-regexp",
8859 &Vx_pixel_size_width_font_regexp
,
8860 doc
: /* Regexp matching a font name whose width is the same as `PIXEL_SIZE'.
8862 Since Emacs gets width of a font matching with this regexp from
8863 PIXEL_SIZE field of the name, font finding mechanism gets faster for
8864 such a font. This is especially effective for such large fonts as
8865 Chinese, Japanese, and Korean. */);
8866 Vx_pixel_size_width_font_regexp
= Qnil
;
8868 DEFVAR_LISP ("image-cache-eviction-delay", &Vimage_cache_eviction_delay
,
8869 doc
: /* Time after which cached images are removed from the cache.
8870 When an image has not been displayed this many seconds, remove it
8871 from the image cache. Value must be an integer or nil with nil
8872 meaning don't clear the cache. */);
8873 Vimage_cache_eviction_delay
= make_number (30 * 60);
8875 defsubr (&Sx_change_window_property
);
8876 defsubr (&Sx_delete_window_property
);
8877 defsubr (&Sx_window_property
);
8878 defsubr (&Sxw_display_color_p
);
8879 defsubr (&Sx_display_grayscale_p
);
8880 defsubr (&Sxw_color_defined_p
);
8881 defsubr (&Sxw_color_values
);
8882 defsubr (&Sx_server_max_request_size
);
8883 defsubr (&Sx_server_vendor
);
8884 defsubr (&Sx_server_version
);
8885 defsubr (&Sx_display_pixel_width
);
8886 defsubr (&Sx_display_pixel_height
);
8887 defsubr (&Sx_display_mm_width
);
8888 defsubr (&Sx_display_mm_height
);
8889 defsubr (&Sx_display_screens
);
8890 defsubr (&Sx_display_planes
);
8891 defsubr (&Sx_display_color_cells
);
8892 defsubr (&Sx_display_visual_class
);
8893 defsubr (&Sx_display_backing_store
);
8894 defsubr (&Sx_display_save_under
);
8895 defsubr (&Sx_create_frame
);
8896 #if 0 /* MAC_TODO: implement network support */
8897 defsubr (&Sx_open_connection
);
8898 defsubr (&Sx_close_connection
);
8900 defsubr (&Sx_display_list
);
8901 defsubr (&Sx_synchronize
);
8903 /* Setting callback functions for fontset handler. */
8904 get_font_info_func
= x_get_font_info
;
8906 #if 0 /* This function pointer doesn't seem to be used anywhere.
8907 And the pointer assigned has the wrong type, anyway. */
8908 list_fonts_func
= x_list_fonts
;
8911 load_font_func
= x_load_font
;
8912 find_ccl_program_func
= x_find_ccl_program
;
8913 query_font_func
= x_query_font
;
8915 set_frame_fontset_func
= x_set_font
;
8916 check_window_system_func
= check_mac
;
8918 #if 0 /* MAC_TODO: Image support for Mac Images. */
8919 Qxbm
= intern ("xbm");
8921 QCtype
= intern (":type");
8922 staticpro (&QCtype
);
8923 QCconversion
= intern (":conversion");
8924 staticpro (&QCconversion
);
8925 QCheuristic_mask
= intern (":heuristic-mask");
8926 staticpro (&QCheuristic_mask
);
8927 QCcolor_symbols
= intern (":color-symbols");
8928 staticpro (&QCcolor_symbols
);
8929 QCascent
= intern (":ascent");
8930 staticpro (&QCascent
);
8931 QCmargin
= intern (":margin");
8932 staticpro (&QCmargin
);
8933 QCrelief
= intern (":relief");
8934 staticpro (&QCrelief
);
8935 Qpostscript
= intern ("postscript");
8936 staticpro (&Qpostscript
);
8937 QCloader
= intern (":loader");
8938 staticpro (&QCloader
);
8939 QCbounding_box
= intern (":bounding-box");
8940 staticpro (&QCbounding_box
);
8941 QCpt_width
= intern (":pt-width");
8942 staticpro (&QCpt_width
);
8943 QCpt_height
= intern (":pt-height");
8944 staticpro (&QCpt_height
);
8945 QCindex
= intern (":index");
8946 staticpro (&QCindex
);
8947 Qpbm
= intern ("pbm");
8951 Qxpm
= intern ("xpm");
8956 Qjpeg
= intern ("jpeg");
8961 Qtiff
= intern ("tiff");
8966 Qgif
= intern ("gif");
8971 Qpng
= intern ("png");
8975 defsubr (&Sclear_image_cache
);
8979 defsubr (&Slookup_image
);
8981 #endif /* MAC_TODO */
8983 hourglass_atimer
= NULL
;
8984 hourglass_shown_p
= 0;
8986 defsubr (&Sx_show_tip
);
8987 defsubr (&Sx_hide_tip
);
8988 staticpro (&tip_timer
);
8991 #if 0 /* MAC_TODO */
8992 defsubr (&Sx_file_dialog
);
9001 Vimage_types
= Qnil
;
9003 define_image_type (&xbm_type
);
9004 #if 0 /* NTEMACS_TODO : Image support for W32 */
9005 define_image_type (&gs_type
);
9006 define_image_type (&pbm_type
);
9009 define_image_type (&xpm_type
);
9013 define_image_type (&jpeg_type
);
9017 define_image_type (&tiff_type
);
9021 define_image_type (&gif_type
);
9025 define_image_type (&png_type
);
9027 #endif /* NTEMACS_TODO */