*** empty log message ***
[bpt/emacs.git] / src / macfns.c
1 /* Graphical user interface functions for Mac OS.
2 Copyright (C) 2000, 2001 Free Software Foundation, Inc.
3
4 This file is part of GNU Emacs.
5
6 GNU Emacs is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
10
11 GNU Emacs is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with GNU Emacs; see the file COPYING. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
20
21 /* Contributed by Andrew Choi (akochoi@mac.com). */
22
23 #include <config.h>
24
25 #include <signal.h>
26 #include <stdio.h>
27 #include <math.h>
28 #include <limits.h>
29 #include <errno.h>
30
31 #include "lisp.h"
32 #include "charset.h"
33 #include "macterm.h"
34 #include "frame.h"
35 #include "window.h"
36 #include "buffer.h"
37 #include "dispextern.h"
38 #include "fontset.h"
39 #include "intervals.h"
40 #include "keyboard.h"
41 #include "blockinput.h"
42 #include "epaths.h"
43 #include "termhooks.h"
44 #include "coding.h"
45 #include "ccl.h"
46 #include "systime.h"
47
48 /* #include "bitmaps/gray.xbm" */
49 #define gray_width 2
50 #define gray_height 2
51 static unsigned char gray_bits[] = {
52 0x01, 0x02};
53
54 /*#include <commdlg.h>
55 #include <shellapi.h>*/
56 #include <ctype.h>
57 #include <sys/types.h>
58 #include <sys/stat.h>
59
60 #include <stdlib.h>
61 #include <string.h>
62 #ifndef MAC_OSX
63 #include <alloca.h>
64 #endif
65
66 #ifdef MAC_OSX
67 #include <QuickTime/QuickTime.h>
68 #else /* not MAC_OSX */
69 #include <Windows.h>
70 #include <Gestalt.h>
71 #include <TextUtils.h>
72 #endif /* not MAC_OSX */
73
74 /*extern void free_frame_menubar ();
75 extern double atof ();
76 extern int w32_console_toggle_lock_key (int vk_code, Lisp_Object new_state);
77 extern int quit_char;*/
78
79 extern char *lispy_function_keys[];
80
81 /* The gray bitmap `bitmaps/gray'. This is done because macterm.c uses
82 it, and including `bitmaps/gray' more than once is a problem when
83 config.h defines `static' as an empty replacement string. */
84
85 int gray_bitmap_width = gray_width;
86 int gray_bitmap_height = gray_height;
87 unsigned char *gray_bitmap_bits = gray_bits;
88
89 /* Non-zero means we're allowed to display an hourglass cursor. */
90
91 int display_hourglass_p;
92
93 /* The background and shape of the mouse pointer, and shape when not
94 over text or in the modeline. */
95
96 Lisp_Object Vx_pointer_shape, Vx_nontext_pointer_shape, Vx_mode_pointer_shape;
97 Lisp_Object Vx_hourglass_pointer_shape;
98
99 /* The shape when over mouse-sensitive text. */
100
101 Lisp_Object Vx_sensitive_text_pointer_shape;
102
103 /* If non-nil, the pointer shape to indicate that windows can be
104 dragged horizontally. */
105
106 Lisp_Object Vx_window_horizontal_drag_shape;
107
108 /* Color of chars displayed in cursor box. */
109
110 Lisp_Object Vx_cursor_fore_pixel;
111
112 /* Nonzero if using Windows. */
113
114 static int mac_in_use;
115
116 /* Non nil if no window manager is in use. */
117
118 Lisp_Object Vx_no_window_manager;
119
120 /* Regexp matching a font name whose width is the same as `PIXEL_SIZE'. */
121
122 Lisp_Object Vx_pixel_size_width_font_regexp;
123
124 /* Evaluate this expression to rebuild the section of syms_of_macfns
125 that initializes and staticpros the symbols declared below. Note
126 that Emacs 18 has a bug that keeps C-x C-e from being able to
127 evaluate this expression.
128
129 (progn
130 ;; Accumulate a list of the symbols we want to initialize from the
131 ;; declarations at the top of the file.
132 (goto-char (point-min))
133 (search-forward "/\*&&& symbols declared here &&&*\/\n")
134 (let (symbol-list)
135 (while (looking-at "Lisp_Object \\(Q[a-z_]+\\)")
136 (setq symbol-list
137 (cons (buffer-substring (match-beginning 1) (match-end 1))
138 symbol-list))
139 (forward-line 1))
140 (setq symbol-list (nreverse symbol-list))
141 ;; Delete the section of syms_of_... where we initialize the symbols.
142 (search-forward "\n /\*&&& init symbols here &&&*\/\n")
143 (let ((start (point)))
144 (while (looking-at "^ Q")
145 (forward-line 2))
146 (kill-region start (point)))
147 ;; Write a new symbol initialization section.
148 (while symbol-list
149 (insert (format " %s = intern (\"" (car symbol-list)))
150 (let ((start (point)))
151 (insert (substring (car symbol-list) 1))
152 (subst-char-in-region start (point) ?_ ?-))
153 (insert (format "\");\n staticpro (&%s);\n" (car symbol-list)))
154 (setq symbol-list (cdr symbol-list)))))
155
156 */
157
158 /*&&& symbols declared here &&&*/
159 Lisp_Object Qnone;
160 Lisp_Object Qsuppress_icon;
161 Lisp_Object Qundefined_color;
162 Lisp_Object Qcancel_timer;
163 Lisp_Object Qhyper;
164 Lisp_Object Qsuper;
165 Lisp_Object Qmeta;
166 Lisp_Object Qalt;
167 Lisp_Object Qctrl;
168 Lisp_Object Qcontrol;
169 Lisp_Object Qshift;
170
171 extern Lisp_Object Vwindow_system_version;
172
173 extern int mac_initialized;
174
175
176 /* compare two strings ignoring case */
177
178 static int
179 stricmp (const char *s, const char *t)
180 {
181 for ( ; tolower (*s) == tolower (*t); s++, t++)
182 if (*s == '\0')
183 return 0;
184 return tolower (*s) - tolower (*t);
185 }
186
187 /* compare two strings up to n characters, ignoring case */
188
189 static int
190 strnicmp (const char *s, const char *t, unsigned int n)
191 {
192 for ( ; n-- > 0 && tolower (*s) == tolower (*t); s++, t++)
193 if (*s == '\0')
194 return 0;
195 return n == 0 ? 0 : tolower (*s) - tolower (*t);
196 }
197
198 \f
199 /* Error if we are not running on Mac OS. */
200
201 void
202 check_mac ()
203 {
204 if (! mac_in_use)
205 error ("Mac OS not in use or not initialized");
206 }
207
208 /* Nonzero if we can use mouse menus.
209 You should not call this unless HAVE_MENUS is defined. */
210
211 int
212 have_menus_p ()
213 {
214 return mac_in_use;
215 }
216
217 /* Extract a frame as a FRAME_PTR, defaulting to the selected frame
218 and checking validity for Mac. */
219
220 FRAME_PTR
221 check_x_frame (frame)
222 Lisp_Object frame;
223 {
224 FRAME_PTR f;
225
226 if (NILP (frame))
227 frame = selected_frame;
228 CHECK_LIVE_FRAME (frame);
229 f = XFRAME (frame);
230 if (! FRAME_MAC_P (f))
231 error ("non-mac frame used");
232 return f;
233 }
234
235 /* Let the user specify a display with a frame.
236 nil stands for the selected frame--or, if that is not a mac frame,
237 the first display on the list. */
238
239 struct mac_display_info *
240 check_x_display_info (frame)
241 Lisp_Object frame;
242 {
243 if (!mac_initialized)
244 {
245 mac_initialize ();
246 mac_initialized = 1;
247 }
248
249 if (NILP (frame))
250 {
251 struct frame *sf = XFRAME (selected_frame);
252
253 if (FRAME_MAC_P (sf) && FRAME_LIVE_P (sf))
254 return FRAME_MAC_DISPLAY_INFO (sf);
255 else
256 return &one_mac_display_info;
257 }
258 else if (STRINGP (frame))
259 return x_display_info_for_name (frame);
260 else
261 {
262 FRAME_PTR f;
263
264 CHECK_LIVE_FRAME (frame);
265 f = XFRAME (frame);
266 if (! FRAME_MAC_P (f))
267 error ("non-mac frame used");
268 return FRAME_MAC_DISPLAY_INFO (f);
269 }
270 }
271 \f
272 /* Return the Emacs frame-object corresponding to a mac window.
273 It could be the frame's main window or an icon window. */
274
275 /* This function can be called during GC, so use GC_xxx type test macros. */
276
277 struct frame *
278 x_window_to_frame (dpyinfo, wdesc)
279 struct mac_display_info *dpyinfo;
280 WindowPtr wdesc;
281 {
282 Lisp_Object tail, frame;
283 struct frame *f;
284
285 for (tail = Vframe_list; GC_CONSP (tail); tail = XCDR (tail))
286 {
287 frame = XCAR (tail);
288 if (!GC_FRAMEP (frame))
289 continue;
290 f = XFRAME (frame);
291 if (!FRAME_W32_P (f) || FRAME_MAC_DISPLAY_INFO (f) != dpyinfo)
292 continue;
293 /*if (f->output_data.w32->hourglass_window == wdesc)
294 return f;*/
295
296 /* MAC_TODO: Check tooltips when supported. */
297 if (FRAME_MAC_WINDOW (f) == wdesc)
298 return f;
299 }
300 return 0;
301 }
302
303 \f
304 static Lisp_Object unwind_create_frame P_ ((Lisp_Object));
305
306 void x_set_foreground_color P_ ((struct frame *, Lisp_Object, Lisp_Object));
307 void x_set_background_color P_ ((struct frame *, Lisp_Object, Lisp_Object));
308 void x_set_mouse_color P_ ((struct frame *, Lisp_Object, Lisp_Object));
309 void x_set_cursor_color P_ ((struct frame *, Lisp_Object, Lisp_Object));
310 void x_set_border_color P_ ((struct frame *, Lisp_Object, Lisp_Object));
311 void x_set_cursor_type P_ ((struct frame *, Lisp_Object, Lisp_Object));
312 void x_set_icon_type P_ ((struct frame *, Lisp_Object, Lisp_Object));
313 void x_set_icon_name P_ ((struct frame *, Lisp_Object, Lisp_Object));
314 void x_explicitly_set_name P_ ((struct frame *, Lisp_Object, Lisp_Object));
315 void x_set_menu_bar_lines P_ ((struct frame *, Lisp_Object, Lisp_Object));
316 void x_set_title P_ ((struct frame *, Lisp_Object, Lisp_Object));
317 void x_set_tool_bar_lines P_ ((struct frame *, Lisp_Object, Lisp_Object));
318 void x_set_scroll_bar_foreground P_ ((struct frame *, Lisp_Object,
319 Lisp_Object));
320 void x_set_scroll_bar_background P_ ((struct frame *, Lisp_Object,
321 Lisp_Object));
322 static Lisp_Object x_default_scroll_bar_color_parameter P_ ((struct frame *,
323 Lisp_Object,
324 Lisp_Object,
325 char *, char *,
326 int));
327 /* Store the screen positions of frame F into XPTR and YPTR.
328 These are the positions of the containing window manager window,
329 not Emacs's own window. */
330
331 void
332 x_real_positions (f, xptr, yptr)
333 FRAME_PTR f;
334 int *xptr, *yptr;
335 {
336 Point pt;
337 GrafPtr oldport;
338
339 #ifdef TARGET_API_MAC_CARBON
340 {
341 Rect r;
342
343 GetWindowPortBounds (f->output_data.mac->mWP, &r);
344 SetPt (&pt, r.left, r.top);
345 }
346 #else /* not TARGET_API_MAC_CARBON */
347 SetPt (&pt,
348 f->output_data.mac->mWP->portRect.left,
349 f->output_data.mac->mWP->portRect.top);
350 #endif /* not TARGET_API_MAC_CARBON */
351 GetPort (&oldport);
352 LocalToGlobal (&pt);
353 SetPort (oldport);
354
355 /* MAC has no frame pixel diff. */
356 f->x_pixels_diff = 0;
357 f->y_pixels_diff = 0;
358
359 *xptr = pt.h;
360 *yptr = pt.v;
361 }
362
363 \f
364 /* The default colors for the Mac color map */
365 typedef struct colormap_t
366 {
367 unsigned long color;
368 char *name;
369 } colormap_t;
370
371 colormap_t mac_color_map[] =
372 {
373 { RGB_TO_ULONG(255, 250, 250), "snow" },
374 { RGB_TO_ULONG(248, 248, 255), "ghost white" },
375 { RGB_TO_ULONG(248, 248, 255), "GhostWhite" },
376 { RGB_TO_ULONG(245, 245, 245), "white smoke" },
377 { RGB_TO_ULONG(245, 245, 245), "WhiteSmoke" },
378 { RGB_TO_ULONG(220, 220, 220), "gainsboro" },
379 { RGB_TO_ULONG(255, 250, 240), "floral white" },
380 { RGB_TO_ULONG(255, 250, 240), "FloralWhite" },
381 { RGB_TO_ULONG(253, 245, 230), "old lace" },
382 { RGB_TO_ULONG(253, 245, 230), "OldLace" },
383 { RGB_TO_ULONG(250, 240, 230), "linen" },
384 { RGB_TO_ULONG(250, 235, 215), "antique white" },
385 { RGB_TO_ULONG(250, 235, 215), "AntiqueWhite" },
386 { RGB_TO_ULONG(255, 239, 213), "papaya whip" },
387 { RGB_TO_ULONG(255, 239, 213), "PapayaWhip" },
388 { RGB_TO_ULONG(255, 235, 205), "blanched almond" },
389 { RGB_TO_ULONG(255, 235, 205), "BlanchedAlmond" },
390 { RGB_TO_ULONG(255, 228, 196), "bisque" },
391 { RGB_TO_ULONG(255, 218, 185), "peach puff" },
392 { RGB_TO_ULONG(255, 218, 185), "PeachPuff" },
393 { RGB_TO_ULONG(255, 222, 173), "navajo white" },
394 { RGB_TO_ULONG(255, 222, 173), "NavajoWhite" },
395 { RGB_TO_ULONG(255, 228, 181), "moccasin" },
396 { RGB_TO_ULONG(255, 248, 220), "cornsilk" },
397 { RGB_TO_ULONG(255, 255, 240), "ivory" },
398 { RGB_TO_ULONG(255, 250, 205), "lemon chiffon" },
399 { RGB_TO_ULONG(255, 250, 205), "LemonChiffon" },
400 { RGB_TO_ULONG(255, 245, 238), "seashell" },
401 { RGB_TO_ULONG(240, 255, 240), "honeydew" },
402 { RGB_TO_ULONG(245, 255, 250), "mint cream" },
403 { RGB_TO_ULONG(245, 255, 250), "MintCream" },
404 { RGB_TO_ULONG(240, 255, 255), "azure" },
405 { RGB_TO_ULONG(240, 248, 255), "alice blue" },
406 { RGB_TO_ULONG(240, 248, 255), "AliceBlue" },
407 { RGB_TO_ULONG(230, 230, 250), "lavender" },
408 { RGB_TO_ULONG(255, 240, 245), "lavender blush" },
409 { RGB_TO_ULONG(255, 240, 245), "LavenderBlush" },
410 { RGB_TO_ULONG(255, 228, 225), "misty rose" },
411 { RGB_TO_ULONG(255, 228, 225), "MistyRose" },
412 { RGB_TO_ULONG(255, 255, 255), "white" },
413 { RGB_TO_ULONG(0 , 0 , 0 ), "black" },
414 { RGB_TO_ULONG(47 , 79 , 79 ), "dark slate gray" },
415 { RGB_TO_ULONG(47 , 79 , 79 ), "DarkSlateGray" },
416 { RGB_TO_ULONG(47 , 79 , 79 ), "dark slate grey" },
417 { RGB_TO_ULONG(47 , 79 , 79 ), "DarkSlateGrey" },
418 { RGB_TO_ULONG(105, 105, 105), "dim gray" },
419 { RGB_TO_ULONG(105, 105, 105), "DimGray" },
420 { RGB_TO_ULONG(105, 105, 105), "dim grey" },
421 { RGB_TO_ULONG(105, 105, 105), "DimGrey" },
422 { RGB_TO_ULONG(112, 128, 144), "slate gray" },
423 { RGB_TO_ULONG(112, 128, 144), "SlateGray" },
424 { RGB_TO_ULONG(112, 128, 144), "slate grey" },
425 { RGB_TO_ULONG(112, 128, 144), "SlateGrey" },
426 { RGB_TO_ULONG(119, 136, 153), "light slate gray" },
427 { RGB_TO_ULONG(119, 136, 153), "LightSlateGray" },
428 { RGB_TO_ULONG(119, 136, 153), "light slate grey" },
429 { RGB_TO_ULONG(119, 136, 153), "LightSlateGrey" },
430 { RGB_TO_ULONG(190, 190, 190), "gray" },
431 { RGB_TO_ULONG(190, 190, 190), "grey" },
432 { RGB_TO_ULONG(211, 211, 211), "light grey" },
433 { RGB_TO_ULONG(211, 211, 211), "LightGrey" },
434 { RGB_TO_ULONG(211, 211, 211), "light gray" },
435 { RGB_TO_ULONG(211, 211, 211), "LightGray" },
436 { RGB_TO_ULONG(25 , 25 , 112), "midnight blue" },
437 { RGB_TO_ULONG(25 , 25 , 112), "MidnightBlue" },
438 { RGB_TO_ULONG(0 , 0 , 128), "navy" },
439 { RGB_TO_ULONG(0 , 0 , 128), "navy blue" },
440 { RGB_TO_ULONG(0 , 0 , 128), "NavyBlue" },
441 { RGB_TO_ULONG(100, 149, 237), "cornflower blue" },
442 { RGB_TO_ULONG(100, 149, 237), "CornflowerBlue" },
443 { RGB_TO_ULONG(72 , 61 , 139), "dark slate blue" },
444 { RGB_TO_ULONG(72 , 61 , 139), "DarkSlateBlue" },
445 { RGB_TO_ULONG(106, 90 , 205), "slate blue" },
446 { RGB_TO_ULONG(106, 90 , 205), "SlateBlue" },
447 { RGB_TO_ULONG(123, 104, 238), "medium slate blue" },
448 { RGB_TO_ULONG(123, 104, 238), "MediumSlateBlue" },
449 { RGB_TO_ULONG(132, 112, 255), "light slate blue" },
450 { RGB_TO_ULONG(132, 112, 255), "LightSlateBlue" },
451 { RGB_TO_ULONG(0 , 0 , 205), "medium blue" },
452 { RGB_TO_ULONG(0 , 0 , 205), "MediumBlue" },
453 { RGB_TO_ULONG(65 , 105, 225), "royal blue" },
454 { RGB_TO_ULONG(65 , 105, 225), "RoyalBlue" },
455 { RGB_TO_ULONG(0 , 0 , 255), "blue" },
456 { RGB_TO_ULONG(30 , 144, 255), "dodger blue" },
457 { RGB_TO_ULONG(30 , 144, 255), "DodgerBlue" },
458 { RGB_TO_ULONG(0 , 191, 255), "deep sky blue" },
459 { RGB_TO_ULONG(0 , 191, 255), "DeepSkyBlue" },
460 { RGB_TO_ULONG(135, 206, 235), "sky blue" },
461 { RGB_TO_ULONG(135, 206, 235), "SkyBlue" },
462 { RGB_TO_ULONG(135, 206, 250), "light sky blue" },
463 { RGB_TO_ULONG(135, 206, 250), "LightSkyBlue" },
464 { RGB_TO_ULONG(70 , 130, 180), "steel blue" },
465 { RGB_TO_ULONG(70 , 130, 180), "SteelBlue" },
466 { RGB_TO_ULONG(176, 196, 222), "light steel blue" },
467 { RGB_TO_ULONG(176, 196, 222), "LightSteelBlue" },
468 { RGB_TO_ULONG(173, 216, 230), "light blue" },
469 { RGB_TO_ULONG(173, 216, 230), "LightBlue" },
470 { RGB_TO_ULONG(176, 224, 230), "powder blue" },
471 { RGB_TO_ULONG(176, 224, 230), "PowderBlue" },
472 { RGB_TO_ULONG(175, 238, 238), "pale turquoise" },
473 { RGB_TO_ULONG(175, 238, 238), "PaleTurquoise" },
474 { RGB_TO_ULONG(0 , 206, 209), "dark turquoise" },
475 { RGB_TO_ULONG(0 , 206, 209), "DarkTurquoise" },
476 { RGB_TO_ULONG(72 , 209, 204), "medium turquoise" },
477 { RGB_TO_ULONG(72 , 209, 204), "MediumTurquoise" },
478 { RGB_TO_ULONG(64 , 224, 208), "turquoise" },
479 { RGB_TO_ULONG(0 , 255, 255), "cyan" },
480 { RGB_TO_ULONG(224, 255, 255), "light cyan" },
481 { RGB_TO_ULONG(224, 255, 255), "LightCyan" },
482 { RGB_TO_ULONG(95 , 158, 160), "cadet blue" },
483 { RGB_TO_ULONG(95 , 158, 160), "CadetBlue" },
484 { RGB_TO_ULONG(102, 205, 170), "medium aquamarine" },
485 { RGB_TO_ULONG(102, 205, 170), "MediumAquamarine" },
486 { RGB_TO_ULONG(127, 255, 212), "aquamarine" },
487 { RGB_TO_ULONG(0 , 100, 0 ), "dark green" },
488 { RGB_TO_ULONG(0 , 100, 0 ), "DarkGreen" },
489 { RGB_TO_ULONG(85 , 107, 47 ), "dark olive green" },
490 { RGB_TO_ULONG(85 , 107, 47 ), "DarkOliveGreen" },
491 { RGB_TO_ULONG(143, 188, 143), "dark sea green" },
492 { RGB_TO_ULONG(143, 188, 143), "DarkSeaGreen" },
493 { RGB_TO_ULONG(46 , 139, 87 ), "sea green" },
494 { RGB_TO_ULONG(46 , 139, 87 ), "SeaGreen" },
495 { RGB_TO_ULONG(60 , 179, 113), "medium sea green" },
496 { RGB_TO_ULONG(60 , 179, 113), "MediumSeaGreen" },
497 { RGB_TO_ULONG(32 , 178, 170), "light sea green" },
498 { RGB_TO_ULONG(32 , 178, 170), "LightSeaGreen" },
499 { RGB_TO_ULONG(152, 251, 152), "pale green" },
500 { RGB_TO_ULONG(152, 251, 152), "PaleGreen" },
501 { RGB_TO_ULONG(0 , 255, 127), "spring green" },
502 { RGB_TO_ULONG(0 , 255, 127), "SpringGreen" },
503 { RGB_TO_ULONG(124, 252, 0 ), "lawn green" },
504 { RGB_TO_ULONG(124, 252, 0 ), "LawnGreen" },
505 { RGB_TO_ULONG(0 , 255, 0 ), "green" },
506 { RGB_TO_ULONG(127, 255, 0 ), "chartreuse" },
507 { RGB_TO_ULONG(0 , 250, 154), "medium spring green" },
508 { RGB_TO_ULONG(0 , 250, 154), "MediumSpringGreen" },
509 { RGB_TO_ULONG(173, 255, 47 ), "green yellow" },
510 { RGB_TO_ULONG(173, 255, 47 ), "GreenYellow" },
511 { RGB_TO_ULONG(50 , 205, 50 ), "lime green" },
512 { RGB_TO_ULONG(50 , 205, 50 ), "LimeGreen" },
513 { RGB_TO_ULONG(154, 205, 50 ), "yellow green" },
514 { RGB_TO_ULONG(154, 205, 50 ), "YellowGreen" },
515 { RGB_TO_ULONG(34 , 139, 34 ), "forest green" },
516 { RGB_TO_ULONG(34 , 139, 34 ), "ForestGreen" },
517 { RGB_TO_ULONG(107, 142, 35 ), "olive drab" },
518 { RGB_TO_ULONG(107, 142, 35 ), "OliveDrab" },
519 { RGB_TO_ULONG(189, 183, 107), "dark khaki" },
520 { RGB_TO_ULONG(189, 183, 107), "DarkKhaki" },
521 { RGB_TO_ULONG(240, 230, 140), "khaki" },
522 { RGB_TO_ULONG(238, 232, 170), "pale goldenrod" },
523 { RGB_TO_ULONG(238, 232, 170), "PaleGoldenrod" },
524 { RGB_TO_ULONG(250, 250, 210), "light goldenrod yellow" },
525 { RGB_TO_ULONG(250, 250, 210), "LightGoldenrodYellow" },
526 { RGB_TO_ULONG(255, 255, 224), "light yellow" },
527 { RGB_TO_ULONG(255, 255, 224), "LightYellow" },
528 { RGB_TO_ULONG(255, 255, 0 ), "yellow" },
529 { RGB_TO_ULONG(255, 215, 0 ), "gold" },
530 { RGB_TO_ULONG(238, 221, 130), "light goldenrod" },
531 { RGB_TO_ULONG(238, 221, 130), "LightGoldenrod" },
532 { RGB_TO_ULONG(218, 165, 32 ), "goldenrod" },
533 { RGB_TO_ULONG(184, 134, 11 ), "dark goldenrod" },
534 { RGB_TO_ULONG(184, 134, 11 ), "DarkGoldenrod" },
535 { RGB_TO_ULONG(188, 143, 143), "rosy brown" },
536 { RGB_TO_ULONG(188, 143, 143), "RosyBrown" },
537 { RGB_TO_ULONG(205, 92 , 92 ), "indian red" },
538 { RGB_TO_ULONG(205, 92 , 92 ), "IndianRed" },
539 { RGB_TO_ULONG(139, 69 , 19 ), "saddle brown" },
540 { RGB_TO_ULONG(139, 69 , 19 ), "SaddleBrown" },
541 { RGB_TO_ULONG(160, 82 , 45 ), "sienna" },
542 { RGB_TO_ULONG(205, 133, 63 ), "peru" },
543 { RGB_TO_ULONG(222, 184, 135), "burlywood" },
544 { RGB_TO_ULONG(245, 245, 220), "beige" },
545 { RGB_TO_ULONG(245, 222, 179), "wheat" },
546 { RGB_TO_ULONG(244, 164, 96 ), "sandy brown" },
547 { RGB_TO_ULONG(244, 164, 96 ), "SandyBrown" },
548 { RGB_TO_ULONG(210, 180, 140), "tan" },
549 { RGB_TO_ULONG(210, 105, 30 ), "chocolate" },
550 { RGB_TO_ULONG(178, 34 , 34 ), "firebrick" },
551 { RGB_TO_ULONG(165, 42 , 42 ), "brown" },
552 { RGB_TO_ULONG(233, 150, 122), "dark salmon" },
553 { RGB_TO_ULONG(233, 150, 122), "DarkSalmon" },
554 { RGB_TO_ULONG(250, 128, 114), "salmon" },
555 { RGB_TO_ULONG(255, 160, 122), "light salmon" },
556 { RGB_TO_ULONG(255, 160, 122), "LightSalmon" },
557 { RGB_TO_ULONG(255, 165, 0 ), "orange" },
558 { RGB_TO_ULONG(255, 140, 0 ), "dark orange" },
559 { RGB_TO_ULONG(255, 140, 0 ), "DarkOrange" },
560 { RGB_TO_ULONG(255, 127, 80 ), "coral" },
561 { RGB_TO_ULONG(240, 128, 128), "light coral" },
562 { RGB_TO_ULONG(240, 128, 128), "LightCoral" },
563 { RGB_TO_ULONG(255, 99 , 71 ), "tomato" },
564 { RGB_TO_ULONG(255, 69 , 0 ), "orange red" },
565 { RGB_TO_ULONG(255, 69 , 0 ), "OrangeRed" },
566 { RGB_TO_ULONG(255, 0 , 0 ), "red" },
567 { RGB_TO_ULONG(255, 105, 180), "hot pink" },
568 { RGB_TO_ULONG(255, 105, 180), "HotPink" },
569 { RGB_TO_ULONG(255, 20 , 147), "deep pink" },
570 { RGB_TO_ULONG(255, 20 , 147), "DeepPink" },
571 { RGB_TO_ULONG(255, 192, 203), "pink" },
572 { RGB_TO_ULONG(255, 182, 193), "light pink" },
573 { RGB_TO_ULONG(255, 182, 193), "LightPink" },
574 { RGB_TO_ULONG(219, 112, 147), "pale violet red" },
575 { RGB_TO_ULONG(219, 112, 147), "PaleVioletRed" },
576 { RGB_TO_ULONG(176, 48 , 96 ), "maroon" },
577 { RGB_TO_ULONG(199, 21 , 133), "medium violet red" },
578 { RGB_TO_ULONG(199, 21 , 133), "MediumVioletRed" },
579 { RGB_TO_ULONG(208, 32 , 144), "violet red" },
580 { RGB_TO_ULONG(208, 32 , 144), "VioletRed" },
581 { RGB_TO_ULONG(255, 0 , 255), "magenta" },
582 { RGB_TO_ULONG(238, 130, 238), "violet" },
583 { RGB_TO_ULONG(221, 160, 221), "plum" },
584 { RGB_TO_ULONG(218, 112, 214), "orchid" },
585 { RGB_TO_ULONG(186, 85 , 211), "medium orchid" },
586 { RGB_TO_ULONG(186, 85 , 211), "MediumOrchid" },
587 { RGB_TO_ULONG(153, 50 , 204), "dark orchid" },
588 { RGB_TO_ULONG(153, 50 , 204), "DarkOrchid" },
589 { RGB_TO_ULONG(148, 0 , 211), "dark violet" },
590 { RGB_TO_ULONG(148, 0 , 211), "DarkViolet" },
591 { RGB_TO_ULONG(138, 43 , 226), "blue violet" },
592 { RGB_TO_ULONG(138, 43 , 226), "BlueViolet" },
593 { RGB_TO_ULONG(160, 32 , 240), "purple" },
594 { RGB_TO_ULONG(147, 112, 219), "medium purple" },
595 { RGB_TO_ULONG(147, 112, 219), "MediumPurple" },
596 { RGB_TO_ULONG(216, 191, 216), "thistle" },
597 { RGB_TO_ULONG(255, 250, 250), "snow1" },
598 { RGB_TO_ULONG(238, 233, 233), "snow2" },
599 { RGB_TO_ULONG(205, 201, 201), "snow3" },
600 { RGB_TO_ULONG(139, 137, 137), "snow4" },
601 { RGB_TO_ULONG(255, 245, 238), "seashell1" },
602 { RGB_TO_ULONG(238, 229, 222), "seashell2" },
603 { RGB_TO_ULONG(205, 197, 191), "seashell3" },
604 { RGB_TO_ULONG(139, 134, 130), "seashell4" },
605 { RGB_TO_ULONG(255, 239, 219), "AntiqueWhite1" },
606 { RGB_TO_ULONG(238, 223, 204), "AntiqueWhite2" },
607 { RGB_TO_ULONG(205, 192, 176), "AntiqueWhite3" },
608 { RGB_TO_ULONG(139, 131, 120), "AntiqueWhite4" },
609 { RGB_TO_ULONG(255, 228, 196), "bisque1" },
610 { RGB_TO_ULONG(238, 213, 183), "bisque2" },
611 { RGB_TO_ULONG(205, 183, 158), "bisque3" },
612 { RGB_TO_ULONG(139, 125, 107), "bisque4" },
613 { RGB_TO_ULONG(255, 218, 185), "PeachPuff1" },
614 { RGB_TO_ULONG(238, 203, 173), "PeachPuff2" },
615 { RGB_TO_ULONG(205, 175, 149), "PeachPuff3" },
616 { RGB_TO_ULONG(139, 119, 101), "PeachPuff4" },
617 { RGB_TO_ULONG(255, 222, 173), "NavajoWhite1" },
618 { RGB_TO_ULONG(238, 207, 161), "NavajoWhite2" },
619 { RGB_TO_ULONG(205, 179, 139), "NavajoWhite3" },
620 { RGB_TO_ULONG(139, 121, 94), "NavajoWhite4" },
621 { RGB_TO_ULONG(255, 250, 205), "LemonChiffon1" },
622 { RGB_TO_ULONG(238, 233, 191), "LemonChiffon2" },
623 { RGB_TO_ULONG(205, 201, 165), "LemonChiffon3" },
624 { RGB_TO_ULONG(139, 137, 112), "LemonChiffon4" },
625 { RGB_TO_ULONG(255, 248, 220), "cornsilk1" },
626 { RGB_TO_ULONG(238, 232, 205), "cornsilk2" },
627 { RGB_TO_ULONG(205, 200, 177), "cornsilk3" },
628 { RGB_TO_ULONG(139, 136, 120), "cornsilk4" },
629 { RGB_TO_ULONG(255, 255, 240), "ivory1" },
630 { RGB_TO_ULONG(238, 238, 224), "ivory2" },
631 { RGB_TO_ULONG(205, 205, 193), "ivory3" },
632 { RGB_TO_ULONG(139, 139, 131), "ivory4" },
633 { RGB_TO_ULONG(240, 255, 240), "honeydew1" },
634 { RGB_TO_ULONG(224, 238, 224), "honeydew2" },
635 { RGB_TO_ULONG(193, 205, 193), "honeydew3" },
636 { RGB_TO_ULONG(131, 139, 131), "honeydew4" },
637 { RGB_TO_ULONG(255, 240, 245), "LavenderBlush1" },
638 { RGB_TO_ULONG(238, 224, 229), "LavenderBlush2" },
639 { RGB_TO_ULONG(205, 193, 197), "LavenderBlush3" },
640 { RGB_TO_ULONG(139, 131, 134), "LavenderBlush4" },
641 { RGB_TO_ULONG(255, 228, 225), "MistyRose1" },
642 { RGB_TO_ULONG(238, 213, 210), "MistyRose2" },
643 { RGB_TO_ULONG(205, 183, 181), "MistyRose3" },
644 { RGB_TO_ULONG(139, 125, 123), "MistyRose4" },
645 { RGB_TO_ULONG(240, 255, 255), "azure1" },
646 { RGB_TO_ULONG(224, 238, 238), "azure2" },
647 { RGB_TO_ULONG(193, 205, 205), "azure3" },
648 { RGB_TO_ULONG(131, 139, 139), "azure4" },
649 { RGB_TO_ULONG(131, 111, 255), "SlateBlue1" },
650 { RGB_TO_ULONG(122, 103, 238), "SlateBlue2" },
651 { RGB_TO_ULONG(105, 89 , 205), "SlateBlue3" },
652 { RGB_TO_ULONG(71 , 60 , 139), "SlateBlue4" },
653 { RGB_TO_ULONG(72 , 118, 255), "RoyalBlue1" },
654 { RGB_TO_ULONG(67 , 110, 238), "RoyalBlue2" },
655 { RGB_TO_ULONG(58 , 95 , 205), "RoyalBlue3" },
656 { RGB_TO_ULONG(39 , 64 , 139), "RoyalBlue4" },
657 { RGB_TO_ULONG(0 , 0 , 255), "blue1" },
658 { RGB_TO_ULONG(0 , 0 , 238), "blue2" },
659 { RGB_TO_ULONG(0 , 0 , 205), "blue3" },
660 { RGB_TO_ULONG(0 , 0 , 139), "blue4" },
661 { RGB_TO_ULONG(30 , 144, 255), "DodgerBlue1" },
662 { RGB_TO_ULONG(28 , 134, 238), "DodgerBlue2" },
663 { RGB_TO_ULONG(24 , 116, 205), "DodgerBlue3" },
664 { RGB_TO_ULONG(16 , 78 , 139), "DodgerBlue4" },
665 { RGB_TO_ULONG(99 , 184, 255), "SteelBlue1" },
666 { RGB_TO_ULONG(92 , 172, 238), "SteelBlue2" },
667 { RGB_TO_ULONG(79 , 148, 205), "SteelBlue3" },
668 { RGB_TO_ULONG(54 , 100, 139), "SteelBlue4" },
669 { RGB_TO_ULONG(0 , 191, 255), "DeepSkyBlue1" },
670 { RGB_TO_ULONG(0 , 178, 238), "DeepSkyBlue2" },
671 { RGB_TO_ULONG(0 , 154, 205), "DeepSkyBlue3" },
672 { RGB_TO_ULONG(0 , 104, 139), "DeepSkyBlue4" },
673 { RGB_TO_ULONG(135, 206, 255), "SkyBlue1" },
674 { RGB_TO_ULONG(126, 192, 238), "SkyBlue2" },
675 { RGB_TO_ULONG(108, 166, 205), "SkyBlue3" },
676 { RGB_TO_ULONG(74 , 112, 139), "SkyBlue4" },
677 { RGB_TO_ULONG(176, 226, 255), "LightSkyBlue1" },
678 { RGB_TO_ULONG(164, 211, 238), "LightSkyBlue2" },
679 { RGB_TO_ULONG(141, 182, 205), "LightSkyBlue3" },
680 { RGB_TO_ULONG(96 , 123, 139), "LightSkyBlue4" },
681 { RGB_TO_ULONG(198, 226, 255), "SlateGray1" },
682 { RGB_TO_ULONG(185, 211, 238), "SlateGray2" },
683 { RGB_TO_ULONG(159, 182, 205), "SlateGray3" },
684 { RGB_TO_ULONG(108, 123, 139), "SlateGray4" },
685 { RGB_TO_ULONG(202, 225, 255), "LightSteelBlue1" },
686 { RGB_TO_ULONG(188, 210, 238), "LightSteelBlue2" },
687 { RGB_TO_ULONG(162, 181, 205), "LightSteelBlue3" },
688 { RGB_TO_ULONG(110, 123, 139), "LightSteelBlue4" },
689 { RGB_TO_ULONG(191, 239, 255), "LightBlue1" },
690 { RGB_TO_ULONG(178, 223, 238), "LightBlue2" },
691 { RGB_TO_ULONG(154, 192, 205), "LightBlue3" },
692 { RGB_TO_ULONG(104, 131, 139), "LightBlue4" },
693 { RGB_TO_ULONG(224, 255, 255), "LightCyan1" },
694 { RGB_TO_ULONG(209, 238, 238), "LightCyan2" },
695 { RGB_TO_ULONG(180, 205, 205), "LightCyan3" },
696 { RGB_TO_ULONG(122, 139, 139), "LightCyan4" },
697 { RGB_TO_ULONG(187, 255, 255), "PaleTurquoise1" },
698 { RGB_TO_ULONG(174, 238, 238), "PaleTurquoise2" },
699 { RGB_TO_ULONG(150, 205, 205), "PaleTurquoise3" },
700 { RGB_TO_ULONG(102, 139, 139), "PaleTurquoise4" },
701 { RGB_TO_ULONG(152, 245, 255), "CadetBlue1" },
702 { RGB_TO_ULONG(142, 229, 238), "CadetBlue2" },
703 { RGB_TO_ULONG(122, 197, 205), "CadetBlue3" },
704 { RGB_TO_ULONG(83 , 134, 139), "CadetBlue4" },
705 { RGB_TO_ULONG(0 , 245, 255), "turquoise1" },
706 { RGB_TO_ULONG(0 , 229, 238), "turquoise2" },
707 { RGB_TO_ULONG(0 , 197, 205), "turquoise3" },
708 { RGB_TO_ULONG(0 , 134, 139), "turquoise4" },
709 { RGB_TO_ULONG(0 , 255, 255), "cyan1" },
710 { RGB_TO_ULONG(0 , 238, 238), "cyan2" },
711 { RGB_TO_ULONG(0 , 205, 205), "cyan3" },
712 { RGB_TO_ULONG(0 , 139, 139), "cyan4" },
713 { RGB_TO_ULONG(151, 255, 255), "DarkSlateGray1" },
714 { RGB_TO_ULONG(141, 238, 238), "DarkSlateGray2" },
715 { RGB_TO_ULONG(121, 205, 205), "DarkSlateGray3" },
716 { RGB_TO_ULONG(82 , 139, 139), "DarkSlateGray4" },
717 { RGB_TO_ULONG(127, 255, 212), "aquamarine1" },
718 { RGB_TO_ULONG(118, 238, 198), "aquamarine2" },
719 { RGB_TO_ULONG(102, 205, 170), "aquamarine3" },
720 { RGB_TO_ULONG(69 , 139, 116), "aquamarine4" },
721 { RGB_TO_ULONG(193, 255, 193), "DarkSeaGreen1" },
722 { RGB_TO_ULONG(180, 238, 180), "DarkSeaGreen2" },
723 { RGB_TO_ULONG(155, 205, 155), "DarkSeaGreen3" },
724 { RGB_TO_ULONG(105, 139, 105), "DarkSeaGreen4" },
725 { RGB_TO_ULONG(84 , 255, 159), "SeaGreen1" },
726 { RGB_TO_ULONG(78 , 238, 148), "SeaGreen2" },
727 { RGB_TO_ULONG(67 , 205, 128), "SeaGreen3" },
728 { RGB_TO_ULONG(46 , 139, 87 ), "SeaGreen4" },
729 { RGB_TO_ULONG(154, 255, 154), "PaleGreen1" },
730 { RGB_TO_ULONG(144, 238, 144), "PaleGreen2" },
731 { RGB_TO_ULONG(124, 205, 124), "PaleGreen3" },
732 { RGB_TO_ULONG(84 , 139, 84 ), "PaleGreen4" },
733 { RGB_TO_ULONG(0 , 255, 127), "SpringGreen1" },
734 { RGB_TO_ULONG(0 , 238, 118), "SpringGreen2" },
735 { RGB_TO_ULONG(0 , 205, 102), "SpringGreen3" },
736 { RGB_TO_ULONG(0 , 139, 69 ), "SpringGreen4" },
737 { RGB_TO_ULONG(0 , 255, 0 ), "green1" },
738 { RGB_TO_ULONG(0 , 238, 0 ), "green2" },
739 { RGB_TO_ULONG(0 , 205, 0 ), "green3" },
740 { RGB_TO_ULONG(0 , 139, 0 ), "green4" },
741 { RGB_TO_ULONG(127, 255, 0 ), "chartreuse1" },
742 { RGB_TO_ULONG(118, 238, 0 ), "chartreuse2" },
743 { RGB_TO_ULONG(102, 205, 0 ), "chartreuse3" },
744 { RGB_TO_ULONG(69 , 139, 0 ), "chartreuse4" },
745 { RGB_TO_ULONG(192, 255, 62 ), "OliveDrab1" },
746 { RGB_TO_ULONG(179, 238, 58 ), "OliveDrab2" },
747 { RGB_TO_ULONG(154, 205, 50 ), "OliveDrab3" },
748 { RGB_TO_ULONG(105, 139, 34 ), "OliveDrab4" },
749 { RGB_TO_ULONG(202, 255, 112), "DarkOliveGreen1" },
750 { RGB_TO_ULONG(188, 238, 104), "DarkOliveGreen2" },
751 { RGB_TO_ULONG(162, 205, 90 ), "DarkOliveGreen3" },
752 { RGB_TO_ULONG(110, 139, 61 ), "DarkOliveGreen4" },
753 { RGB_TO_ULONG(255, 246, 143), "khaki1" },
754 { RGB_TO_ULONG(238, 230, 133), "khaki2" },
755 { RGB_TO_ULONG(205, 198, 115), "khaki3" },
756 { RGB_TO_ULONG(139, 134, 78 ), "khaki4" },
757 { RGB_TO_ULONG(255, 236, 139), "LightGoldenrod1" },
758 { RGB_TO_ULONG(238, 220, 130), "LightGoldenrod2" },
759 { RGB_TO_ULONG(205, 190, 112), "LightGoldenrod3" },
760 { RGB_TO_ULONG(139, 129, 76 ), "LightGoldenrod4" },
761 { RGB_TO_ULONG(255, 255, 224), "LightYellow1" },
762 { RGB_TO_ULONG(238, 238, 209), "LightYellow2" },
763 { RGB_TO_ULONG(205, 205, 180), "LightYellow3" },
764 { RGB_TO_ULONG(139, 139, 122), "LightYellow4" },
765 { RGB_TO_ULONG(255, 255, 0 ), "yellow1" },
766 { RGB_TO_ULONG(238, 238, 0 ), "yellow2" },
767 { RGB_TO_ULONG(205, 205, 0 ), "yellow3" },
768 { RGB_TO_ULONG(139, 139, 0 ), "yellow4" },
769 { RGB_TO_ULONG(255, 215, 0 ), "gold1" },
770 { RGB_TO_ULONG(238, 201, 0 ), "gold2" },
771 { RGB_TO_ULONG(205, 173, 0 ), "gold3" },
772 { RGB_TO_ULONG(139, 117, 0 ), "gold4" },
773 { RGB_TO_ULONG(255, 193, 37 ), "goldenrod1" },
774 { RGB_TO_ULONG(238, 180, 34 ), "goldenrod2" },
775 { RGB_TO_ULONG(205, 155, 29 ), "goldenrod3" },
776 { RGB_TO_ULONG(139, 105, 20 ), "goldenrod4" },
777 { RGB_TO_ULONG(255, 185, 15 ), "DarkGoldenrod1" },
778 { RGB_TO_ULONG(238, 173, 14 ), "DarkGoldenrod2" },
779 { RGB_TO_ULONG(205, 149, 12 ), "DarkGoldenrod3" },
780 { RGB_TO_ULONG(139, 101, 8 ), "DarkGoldenrod4" },
781 { RGB_TO_ULONG(255, 193, 193), "RosyBrown1" },
782 { RGB_TO_ULONG(238, 180, 180), "RosyBrown2" },
783 { RGB_TO_ULONG(205, 155, 155), "RosyBrown3" },
784 { RGB_TO_ULONG(139, 105, 105), "RosyBrown4" },
785 { RGB_TO_ULONG(255, 106, 106), "IndianRed1" },
786 { RGB_TO_ULONG(238, 99 , 99 ), "IndianRed2" },
787 { RGB_TO_ULONG(205, 85 , 85 ), "IndianRed3" },
788 { RGB_TO_ULONG(139, 58 , 58 ), "IndianRed4" },
789 { RGB_TO_ULONG(255, 130, 71 ), "sienna1" },
790 { RGB_TO_ULONG(238, 121, 66 ), "sienna2" },
791 { RGB_TO_ULONG(205, 104, 57 ), "sienna3" },
792 { RGB_TO_ULONG(139, 71 , 38 ), "sienna4" },
793 { RGB_TO_ULONG(255, 211, 155), "burlywood1" },
794 { RGB_TO_ULONG(238, 197, 145), "burlywood2" },
795 { RGB_TO_ULONG(205, 170, 125), "burlywood3" },
796 { RGB_TO_ULONG(139, 115, 85 ), "burlywood4" },
797 { RGB_TO_ULONG(255, 231, 186), "wheat1" },
798 { RGB_TO_ULONG(238, 216, 174), "wheat2" },
799 { RGB_TO_ULONG(205, 186, 150), "wheat3" },
800 { RGB_TO_ULONG(139, 126, 102), "wheat4" },
801 { RGB_TO_ULONG(255, 165, 79 ), "tan1" },
802 { RGB_TO_ULONG(238, 154, 73 ), "tan2" },
803 { RGB_TO_ULONG(205, 133, 63 ), "tan3" },
804 { RGB_TO_ULONG(139, 90 , 43 ), "tan4" },
805 { RGB_TO_ULONG(255, 127, 36 ), "chocolate1" },
806 { RGB_TO_ULONG(238, 118, 33 ), "chocolate2" },
807 { RGB_TO_ULONG(205, 102, 29 ), "chocolate3" },
808 { RGB_TO_ULONG(139, 69 , 19 ), "chocolate4" },
809 { RGB_TO_ULONG(255, 48 , 48 ), "firebrick1" },
810 { RGB_TO_ULONG(238, 44 , 44 ), "firebrick2" },
811 { RGB_TO_ULONG(205, 38 , 38 ), "firebrick3" },
812 { RGB_TO_ULONG(139, 26 , 26 ), "firebrick4" },
813 { RGB_TO_ULONG(255, 64 , 64 ), "brown1" },
814 { RGB_TO_ULONG(238, 59 , 59 ), "brown2" },
815 { RGB_TO_ULONG(205, 51 , 51 ), "brown3" },
816 { RGB_TO_ULONG(139, 35 , 35 ), "brown4" },
817 { RGB_TO_ULONG(255, 140, 105), "salmon1" },
818 { RGB_TO_ULONG(238, 130, 98 ), "salmon2" },
819 { RGB_TO_ULONG(205, 112, 84 ), "salmon3" },
820 { RGB_TO_ULONG(139, 76 , 57 ), "salmon4" },
821 { RGB_TO_ULONG(255, 160, 122), "LightSalmon1" },
822 { RGB_TO_ULONG(238, 149, 114), "LightSalmon2" },
823 { RGB_TO_ULONG(205, 129, 98 ), "LightSalmon3" },
824 { RGB_TO_ULONG(139, 87 , 66 ), "LightSalmon4" },
825 { RGB_TO_ULONG(255, 165, 0 ), "orange1" },
826 { RGB_TO_ULONG(238, 154, 0 ), "orange2" },
827 { RGB_TO_ULONG(205, 133, 0 ), "orange3" },
828 { RGB_TO_ULONG(139, 90 , 0 ), "orange4" },
829 { RGB_TO_ULONG(255, 127, 0 ), "DarkOrange1" },
830 { RGB_TO_ULONG(238, 118, 0 ), "DarkOrange2" },
831 { RGB_TO_ULONG(205, 102, 0 ), "DarkOrange3" },
832 { RGB_TO_ULONG(139, 69 , 0 ), "DarkOrange4" },
833 { RGB_TO_ULONG(255, 114, 86 ), "coral1" },
834 { RGB_TO_ULONG(238, 106, 80 ), "coral2" },
835 { RGB_TO_ULONG(205, 91 , 69 ), "coral3" },
836 { RGB_TO_ULONG(139, 62 , 47 ), "coral4" },
837 { RGB_TO_ULONG(255, 99 , 71 ), "tomato1" },
838 { RGB_TO_ULONG(238, 92 , 66 ), "tomato2" },
839 { RGB_TO_ULONG(205, 79 , 57 ), "tomato3" },
840 { RGB_TO_ULONG(139, 54 , 38 ), "tomato4" },
841 { RGB_TO_ULONG(255, 69 , 0 ), "OrangeRed1" },
842 { RGB_TO_ULONG(238, 64 , 0 ), "OrangeRed2" },
843 { RGB_TO_ULONG(205, 55 , 0 ), "OrangeRed3" },
844 { RGB_TO_ULONG(139, 37 , 0 ), "OrangeRed4" },
845 { RGB_TO_ULONG(255, 0 , 0 ), "red1" },
846 { RGB_TO_ULONG(238, 0 , 0 ), "red2" },
847 { RGB_TO_ULONG(205, 0 , 0 ), "red3" },
848 { RGB_TO_ULONG(139, 0 , 0 ), "red4" },
849 { RGB_TO_ULONG(255, 20 , 147), "DeepPink1" },
850 { RGB_TO_ULONG(238, 18 , 137), "DeepPink2" },
851 { RGB_TO_ULONG(205, 16 , 118), "DeepPink3" },
852 { RGB_TO_ULONG(139, 10 , 80 ), "DeepPink4" },
853 { RGB_TO_ULONG(255, 110, 180), "HotPink1" },
854 { RGB_TO_ULONG(238, 106, 167), "HotPink2" },
855 { RGB_TO_ULONG(205, 96 , 144), "HotPink3" },
856 { RGB_TO_ULONG(139, 58 , 98 ), "HotPink4" },
857 { RGB_TO_ULONG(255, 181, 197), "pink1" },
858 { RGB_TO_ULONG(238, 169, 184), "pink2" },
859 { RGB_TO_ULONG(205, 145, 158), "pink3" },
860 { RGB_TO_ULONG(139, 99 , 108), "pink4" },
861 { RGB_TO_ULONG(255, 174, 185), "LightPink1" },
862 { RGB_TO_ULONG(238, 162, 173), "LightPink2" },
863 { RGB_TO_ULONG(205, 140, 149), "LightPink3" },
864 { RGB_TO_ULONG(139, 95 , 101), "LightPink4" },
865 { RGB_TO_ULONG(255, 130, 171), "PaleVioletRed1" },
866 { RGB_TO_ULONG(238, 121, 159), "PaleVioletRed2" },
867 { RGB_TO_ULONG(205, 104, 137), "PaleVioletRed3" },
868 { RGB_TO_ULONG(139, 71 , 93 ), "PaleVioletRed4" },
869 { RGB_TO_ULONG(255, 52 , 179), "maroon1" },
870 { RGB_TO_ULONG(238, 48 , 167), "maroon2" },
871 { RGB_TO_ULONG(205, 41 , 144), "maroon3" },
872 { RGB_TO_ULONG(139, 28 , 98 ), "maroon4" },
873 { RGB_TO_ULONG(255, 62 , 150), "VioletRed1" },
874 { RGB_TO_ULONG(238, 58 , 140), "VioletRed2" },
875 { RGB_TO_ULONG(205, 50 , 120), "VioletRed3" },
876 { RGB_TO_ULONG(139, 34 , 82 ), "VioletRed4" },
877 { RGB_TO_ULONG(255, 0 , 255), "magenta1" },
878 { RGB_TO_ULONG(238, 0 , 238), "magenta2" },
879 { RGB_TO_ULONG(205, 0 , 205), "magenta3" },
880 { RGB_TO_ULONG(139, 0 , 139), "magenta4" },
881 { RGB_TO_ULONG(255, 131, 250), "orchid1" },
882 { RGB_TO_ULONG(238, 122, 233), "orchid2" },
883 { RGB_TO_ULONG(205, 105, 201), "orchid3" },
884 { RGB_TO_ULONG(139, 71 , 137), "orchid4" },
885 { RGB_TO_ULONG(255, 187, 255), "plum1" },
886 { RGB_TO_ULONG(238, 174, 238), "plum2" },
887 { RGB_TO_ULONG(205, 150, 205), "plum3" },
888 { RGB_TO_ULONG(139, 102, 139), "plum4" },
889 { RGB_TO_ULONG(224, 102, 255), "MediumOrchid1" },
890 { RGB_TO_ULONG(209, 95 , 238), "MediumOrchid2" },
891 { RGB_TO_ULONG(180, 82 , 205), "MediumOrchid3" },
892 { RGB_TO_ULONG(122, 55 , 139), "MediumOrchid4" },
893 { RGB_TO_ULONG(191, 62 , 255), "DarkOrchid1" },
894 { RGB_TO_ULONG(178, 58 , 238), "DarkOrchid2" },
895 { RGB_TO_ULONG(154, 50 , 205), "DarkOrchid3" },
896 { RGB_TO_ULONG(104, 34 , 139), "DarkOrchid4" },
897 { RGB_TO_ULONG(155, 48 , 255), "purple1" },
898 { RGB_TO_ULONG(145, 44 , 238), "purple2" },
899 { RGB_TO_ULONG(125, 38 , 205), "purple3" },
900 { RGB_TO_ULONG(85 , 26 , 139), "purple4" },
901 { RGB_TO_ULONG(171, 130, 255), "MediumPurple1" },
902 { RGB_TO_ULONG(159, 121, 238), "MediumPurple2" },
903 { RGB_TO_ULONG(137, 104, 205), "MediumPurple3" },
904 { RGB_TO_ULONG(93 , 71 , 139), "MediumPurple4" },
905 { RGB_TO_ULONG(255, 225, 255), "thistle1" },
906 { RGB_TO_ULONG(238, 210, 238), "thistle2" },
907 { RGB_TO_ULONG(205, 181, 205), "thistle3" },
908 { RGB_TO_ULONG(139, 123, 139), "thistle4" },
909 { RGB_TO_ULONG(0 , 0 , 0 ), "gray0" },
910 { RGB_TO_ULONG(0 , 0 , 0 ), "grey0" },
911 { RGB_TO_ULONG(3 , 3 , 3 ), "gray1" },
912 { RGB_TO_ULONG(3 , 3 , 3 ), "grey1" },
913 { RGB_TO_ULONG(5 , 5 , 5 ), "gray2" },
914 { RGB_TO_ULONG(5 , 5 , 5 ), "grey2" },
915 { RGB_TO_ULONG(8 , 8 , 8 ), "gray3" },
916 { RGB_TO_ULONG(8 , 8 , 8 ), "grey3" },
917 { RGB_TO_ULONG(10 , 10 , 10 ), "gray4" },
918 { RGB_TO_ULONG(10 , 10 , 10 ), "grey4" },
919 { RGB_TO_ULONG(13 , 13 , 13 ), "gray5" },
920 { RGB_TO_ULONG(13 , 13 , 13 ), "grey5" },
921 { RGB_TO_ULONG(15 , 15 , 15 ), "gray6" },
922 { RGB_TO_ULONG(15 , 15 , 15 ), "grey6" },
923 { RGB_TO_ULONG(18 , 18 , 18 ), "gray7" },
924 { RGB_TO_ULONG(18 , 18 , 18 ), "grey7" },
925 { RGB_TO_ULONG(20 , 20 , 20 ), "gray8" },
926 { RGB_TO_ULONG(20 , 20 , 20 ), "grey8" },
927 { RGB_TO_ULONG(23 , 23 , 23 ), "gray9" },
928 { RGB_TO_ULONG(23 , 23 , 23 ), "grey9" },
929 { RGB_TO_ULONG(26 , 26 , 26 ), "gray10" },
930 { RGB_TO_ULONG(26 , 26 , 26 ), "grey10" },
931 { RGB_TO_ULONG(28 , 28 , 28 ), "gray11" },
932 { RGB_TO_ULONG(28 , 28 , 28 ), "grey11" },
933 { RGB_TO_ULONG(31 , 31 , 31 ), "gray12" },
934 { RGB_TO_ULONG(31 , 31 , 31 ), "grey12" },
935 { RGB_TO_ULONG(33 , 33 , 33 ), "gray13" },
936 { RGB_TO_ULONG(33 , 33 , 33 ), "grey13" },
937 { RGB_TO_ULONG(36 , 36 , 36 ), "gray14" },
938 { RGB_TO_ULONG(36 , 36 , 36 ), "grey14" },
939 { RGB_TO_ULONG(38 , 38 , 38 ), "gray15" },
940 { RGB_TO_ULONG(38 , 38 , 38 ), "grey15" },
941 { RGB_TO_ULONG(41 , 41 , 41 ), "gray16" },
942 { RGB_TO_ULONG(41 , 41 , 41 ), "grey16" },
943 { RGB_TO_ULONG(43 , 43 , 43 ), "gray17" },
944 { RGB_TO_ULONG(43 , 43 , 43 ), "grey17" },
945 { RGB_TO_ULONG(46 , 46 , 46 ), "gray18" },
946 { RGB_TO_ULONG(46 , 46 , 46 ), "grey18" },
947 { RGB_TO_ULONG(48 , 48 , 48 ), "gray19" },
948 { RGB_TO_ULONG(48 , 48 , 48 ), "grey19" },
949 { RGB_TO_ULONG(51 , 51 , 51 ), "gray20" },
950 { RGB_TO_ULONG(51 , 51 , 51 ), "grey20" },
951 { RGB_TO_ULONG(54 , 54 , 54 ), "gray21" },
952 { RGB_TO_ULONG(54 , 54 , 54 ), "grey21" },
953 { RGB_TO_ULONG(56 , 56 , 56 ), "gray22" },
954 { RGB_TO_ULONG(56 , 56 , 56 ), "grey22" },
955 { RGB_TO_ULONG(59 , 59 , 59 ), "gray23" },
956 { RGB_TO_ULONG(59 , 59 , 59 ), "grey23" },
957 { RGB_TO_ULONG(61 , 61 , 61 ), "gray24" },
958 { RGB_TO_ULONG(61 , 61 , 61 ), "grey24" },
959 { RGB_TO_ULONG(64 , 64 , 64 ), "gray25" },
960 { RGB_TO_ULONG(64 , 64 , 64 ), "grey25" },
961 { RGB_TO_ULONG(66 , 66 , 66 ), "gray26" },
962 { RGB_TO_ULONG(66 , 66 , 66 ), "grey26" },
963 { RGB_TO_ULONG(69 , 69 , 69 ), "gray27" },
964 { RGB_TO_ULONG(69 , 69 , 69 ), "grey27" },
965 { RGB_TO_ULONG(71 , 71 , 71 ), "gray28" },
966 { RGB_TO_ULONG(71 , 71 , 71 ), "grey28" },
967 { RGB_TO_ULONG(74 , 74 , 74 ), "gray29" },
968 { RGB_TO_ULONG(74 , 74 , 74 ), "grey29" },
969 { RGB_TO_ULONG(77 , 77 , 77 ), "gray30" },
970 { RGB_TO_ULONG(77 , 77 , 77 ), "grey30" },
971 { RGB_TO_ULONG(79 , 79 , 79 ), "gray31" },
972 { RGB_TO_ULONG(79 , 79 , 79 ), "grey31" },
973 { RGB_TO_ULONG(82 , 82 , 82 ), "gray32" },
974 { RGB_TO_ULONG(82 , 82 , 82 ), "grey32" },
975 { RGB_TO_ULONG(84 , 84 , 84 ), "gray33" },
976 { RGB_TO_ULONG(84 , 84 , 84 ), "grey33" },
977 { RGB_TO_ULONG(87 , 87 , 87 ), "gray34" },
978 { RGB_TO_ULONG(87 , 87 , 87 ), "grey34" },
979 { RGB_TO_ULONG(89 , 89 , 89 ), "gray35" },
980 { RGB_TO_ULONG(89 , 89 , 89 ), "grey35" },
981 { RGB_TO_ULONG(92 , 92 , 92 ), "gray36" },
982 { RGB_TO_ULONG(92 , 92 , 92 ), "grey36" },
983 { RGB_TO_ULONG(94 , 94 , 94 ), "gray37" },
984 { RGB_TO_ULONG(94 , 94 , 94 ), "grey37" },
985 { RGB_TO_ULONG(97 , 97 , 97 ), "gray38" },
986 { RGB_TO_ULONG(97 , 97 , 97 ), "grey38" },
987 { RGB_TO_ULONG(99 , 99 , 99 ), "gray39" },
988 { RGB_TO_ULONG(99 , 99 , 99 ), "grey39" },
989 { RGB_TO_ULONG(102, 102, 102), "gray40" },
990 { RGB_TO_ULONG(102, 102, 102), "grey40" },
991 { RGB_TO_ULONG(105, 105, 105), "gray41" },
992 { RGB_TO_ULONG(105, 105, 105), "grey41" },
993 { RGB_TO_ULONG(107, 107, 107), "gray42" },
994 { RGB_TO_ULONG(107, 107, 107), "grey42" },
995 { RGB_TO_ULONG(110, 110, 110), "gray43" },
996 { RGB_TO_ULONG(110, 110, 110), "grey43" },
997 { RGB_TO_ULONG(112, 112, 112), "gray44" },
998 { RGB_TO_ULONG(112, 112, 112), "grey44" },
999 { RGB_TO_ULONG(115, 115, 115), "gray45" },
1000 { RGB_TO_ULONG(115, 115, 115), "grey45" },
1001 { RGB_TO_ULONG(117, 117, 117), "gray46" },
1002 { RGB_TO_ULONG(117, 117, 117), "grey46" },
1003 { RGB_TO_ULONG(120, 120, 120), "gray47" },
1004 { RGB_TO_ULONG(120, 120, 120), "grey47" },
1005 { RGB_TO_ULONG(122, 122, 122), "gray48" },
1006 { RGB_TO_ULONG(122, 122, 122), "grey48" },
1007 { RGB_TO_ULONG(125, 125, 125), "gray49" },
1008 { RGB_TO_ULONG(125, 125, 125), "grey49" },
1009 { RGB_TO_ULONG(127, 127, 127), "gray50" },
1010 { RGB_TO_ULONG(127, 127, 127), "grey50" },
1011 { RGB_TO_ULONG(130, 130, 130), "gray51" },
1012 { RGB_TO_ULONG(130, 130, 130), "grey51" },
1013 { RGB_TO_ULONG(133, 133, 133), "gray52" },
1014 { RGB_TO_ULONG(133, 133, 133), "grey52" },
1015 { RGB_TO_ULONG(135, 135, 135), "gray53" },
1016 { RGB_TO_ULONG(135, 135, 135), "grey53" },
1017 { RGB_TO_ULONG(138, 138, 138), "gray54" },
1018 { RGB_TO_ULONG(138, 138, 138), "grey54" },
1019 { RGB_TO_ULONG(140, 140, 140), "gray55" },
1020 { RGB_TO_ULONG(140, 140, 140), "grey55" },
1021 { RGB_TO_ULONG(143, 143, 143), "gray56" },
1022 { RGB_TO_ULONG(143, 143, 143), "grey56" },
1023 { RGB_TO_ULONG(145, 145, 145), "gray57" },
1024 { RGB_TO_ULONG(145, 145, 145), "grey57" },
1025 { RGB_TO_ULONG(148, 148, 148), "gray58" },
1026 { RGB_TO_ULONG(148, 148, 148), "grey58" },
1027 { RGB_TO_ULONG(150, 150, 150), "gray59" },
1028 { RGB_TO_ULONG(150, 150, 150), "grey59" },
1029 { RGB_TO_ULONG(153, 153, 153), "gray60" },
1030 { RGB_TO_ULONG(153, 153, 153), "grey60" },
1031 { RGB_TO_ULONG(156, 156, 156), "gray61" },
1032 { RGB_TO_ULONG(156, 156, 156), "grey61" },
1033 { RGB_TO_ULONG(158, 158, 158), "gray62" },
1034 { RGB_TO_ULONG(158, 158, 158), "grey62" },
1035 { RGB_TO_ULONG(161, 161, 161), "gray63" },
1036 { RGB_TO_ULONG(161, 161, 161), "grey63" },
1037 { RGB_TO_ULONG(163, 163, 163), "gray64" },
1038 { RGB_TO_ULONG(163, 163, 163), "grey64" },
1039 { RGB_TO_ULONG(166, 166, 166), "gray65" },
1040 { RGB_TO_ULONG(166, 166, 166), "grey65" },
1041 { RGB_TO_ULONG(168, 168, 168), "gray66" },
1042 { RGB_TO_ULONG(168, 168, 168), "grey66" },
1043 { RGB_TO_ULONG(171, 171, 171), "gray67" },
1044 { RGB_TO_ULONG(171, 171, 171), "grey67" },
1045 { RGB_TO_ULONG(173, 173, 173), "gray68" },
1046 { RGB_TO_ULONG(173, 173, 173), "grey68" },
1047 { RGB_TO_ULONG(176, 176, 176), "gray69" },
1048 { RGB_TO_ULONG(176, 176, 176), "grey69" },
1049 { RGB_TO_ULONG(179, 179, 179), "gray70" },
1050 { RGB_TO_ULONG(179, 179, 179), "grey70" },
1051 { RGB_TO_ULONG(181, 181, 181), "gray71" },
1052 { RGB_TO_ULONG(181, 181, 181), "grey71" },
1053 { RGB_TO_ULONG(184, 184, 184), "gray72" },
1054 { RGB_TO_ULONG(184, 184, 184), "grey72" },
1055 { RGB_TO_ULONG(186, 186, 186), "gray73" },
1056 { RGB_TO_ULONG(186, 186, 186), "grey73" },
1057 { RGB_TO_ULONG(189, 189, 189), "gray74" },
1058 { RGB_TO_ULONG(189, 189, 189), "grey74" },
1059 { RGB_TO_ULONG(191, 191, 191), "gray75" },
1060 { RGB_TO_ULONG(191, 191, 191), "grey75" },
1061 { RGB_TO_ULONG(194, 194, 194), "gray76" },
1062 { RGB_TO_ULONG(194, 194, 194), "grey76" },
1063 { RGB_TO_ULONG(196, 196, 196), "gray77" },
1064 { RGB_TO_ULONG(196, 196, 196), "grey77" },
1065 { RGB_TO_ULONG(199, 199, 199), "gray78" },
1066 { RGB_TO_ULONG(199, 199, 199), "grey78" },
1067 { RGB_TO_ULONG(201, 201, 201), "gray79" },
1068 { RGB_TO_ULONG(201, 201, 201), "grey79" },
1069 { RGB_TO_ULONG(204, 204, 204), "gray80" },
1070 { RGB_TO_ULONG(204, 204, 204), "grey80" },
1071 { RGB_TO_ULONG(207, 207, 207), "gray81" },
1072 { RGB_TO_ULONG(207, 207, 207), "grey81" },
1073 { RGB_TO_ULONG(209, 209, 209), "gray82" },
1074 { RGB_TO_ULONG(209, 209, 209), "grey82" },
1075 { RGB_TO_ULONG(212, 212, 212), "gray83" },
1076 { RGB_TO_ULONG(212, 212, 212), "grey83" },
1077 { RGB_TO_ULONG(214, 214, 214), "gray84" },
1078 { RGB_TO_ULONG(214, 214, 214), "grey84" },
1079 { RGB_TO_ULONG(217, 217, 217), "gray85" },
1080 { RGB_TO_ULONG(217, 217, 217), "grey85" },
1081 { RGB_TO_ULONG(219, 219, 219), "gray86" },
1082 { RGB_TO_ULONG(219, 219, 219), "grey86" },
1083 { RGB_TO_ULONG(222, 222, 222), "gray87" },
1084 { RGB_TO_ULONG(222, 222, 222), "grey87" },
1085 { RGB_TO_ULONG(224, 224, 224), "gray88" },
1086 { RGB_TO_ULONG(224, 224, 224), "grey88" },
1087 { RGB_TO_ULONG(227, 227, 227), "gray89" },
1088 { RGB_TO_ULONG(227, 227, 227), "grey89" },
1089 { RGB_TO_ULONG(229, 229, 229), "gray90" },
1090 { RGB_TO_ULONG(229, 229, 229), "grey90" },
1091 { RGB_TO_ULONG(232, 232, 232), "gray91" },
1092 { RGB_TO_ULONG(232, 232, 232), "grey91" },
1093 { RGB_TO_ULONG(235, 235, 235), "gray92" },
1094 { RGB_TO_ULONG(235, 235, 235), "grey92" },
1095 { RGB_TO_ULONG(237, 237, 237), "gray93" },
1096 { RGB_TO_ULONG(237, 237, 237), "grey93" },
1097 { RGB_TO_ULONG(240, 240, 240), "gray94" },
1098 { RGB_TO_ULONG(240, 240, 240), "grey94" },
1099 { RGB_TO_ULONG(242, 242, 242), "gray95" },
1100 { RGB_TO_ULONG(242, 242, 242), "grey95" },
1101 { RGB_TO_ULONG(245, 245, 245), "gray96" },
1102 { RGB_TO_ULONG(245, 245, 245), "grey96" },
1103 { RGB_TO_ULONG(247, 247, 247), "gray97" },
1104 { RGB_TO_ULONG(247, 247, 247), "grey97" },
1105 { RGB_TO_ULONG(250, 250, 250), "gray98" },
1106 { RGB_TO_ULONG(250, 250, 250), "grey98" },
1107 { RGB_TO_ULONG(252, 252, 252), "gray99" },
1108 { RGB_TO_ULONG(252, 252, 252), "grey99" },
1109 { RGB_TO_ULONG(255, 255, 255), "gray100" },
1110 { RGB_TO_ULONG(255, 255, 255), "grey100" },
1111 { RGB_TO_ULONG(169, 169, 169), "dark grey" },
1112 { RGB_TO_ULONG(169, 169, 169), "DarkGrey" },
1113 { RGB_TO_ULONG(169, 169, 169), "dark gray" },
1114 { RGB_TO_ULONG(169, 169, 169), "DarkGray" },
1115 { RGB_TO_ULONG(0 , 0 , 139), "dark blue" },
1116 { RGB_TO_ULONG(0 , 0 , 139), "DarkBlue" },
1117 { RGB_TO_ULONG(0 , 139, 139), "dark cyan" },
1118 { RGB_TO_ULONG(0 , 139, 139), "DarkCyan" },
1119 { RGB_TO_ULONG(139, 0 , 139), "dark magenta" },
1120 { RGB_TO_ULONG(139, 0 , 139), "DarkMagenta" },
1121 { RGB_TO_ULONG(139, 0 , 0 ), "dark red" },
1122 { RGB_TO_ULONG(139, 0 , 0 ), "DarkRed" },
1123 { RGB_TO_ULONG(144, 238, 144), "light green" },
1124 { RGB_TO_ULONG(144, 238, 144), "LightGreen" }
1125 };
1126
1127 Lisp_Object
1128 mac_color_map_lookup (colorname)
1129 char *colorname;
1130 {
1131 Lisp_Object ret = Qnil;
1132 int i;
1133
1134 BLOCK_INPUT;
1135
1136 for (i = 0; i < sizeof (mac_color_map) / sizeof (mac_color_map[0]); i++)
1137 if (stricmp (colorname, mac_color_map[i].name) == 0)
1138 {
1139 ret = make_number (mac_color_map[i].color);
1140 break;
1141 }
1142
1143 UNBLOCK_INPUT;
1144
1145 return ret;
1146 }
1147
1148 Lisp_Object
1149 x_to_mac_color (colorname)
1150 char * colorname;
1151 {
1152 register Lisp_Object tail, ret = Qnil;
1153
1154 BLOCK_INPUT;
1155
1156 if (colorname[0] == '#')
1157 {
1158 /* Could be an old-style RGB Device specification. */
1159 char *color;
1160 int size;
1161 color = colorname + 1;
1162
1163 size = strlen(color);
1164 if (size == 3 || size == 6 || size == 9 || size == 12)
1165 {
1166 unsigned long colorval;
1167 int i, pos;
1168 pos = 16;
1169 size /= 3;
1170 colorval = 0;
1171
1172 for (i = 0; i < 3; i++)
1173 {
1174 char *end;
1175 char t;
1176 unsigned long value;
1177
1178 /* The check for 'x' in the following conditional takes into
1179 account the fact that strtol allows a "0x" in front of
1180 our numbers, and we don't. */
1181 if (!isxdigit(color[0]) || color[1] == 'x')
1182 break;
1183 t = color[size];
1184 color[size] = '\0';
1185 value = strtoul(color, &end, 16);
1186 color[size] = t;
1187 if (errno == ERANGE || end - color != size)
1188 break;
1189 switch (size)
1190 {
1191 case 1:
1192 value = value * 0x10;
1193 break;
1194 case 2:
1195 break;
1196 case 3:
1197 value /= 0x10;
1198 break;
1199 case 4:
1200 value /= 0x100;
1201 break;
1202 }
1203 colorval |= (value << pos);
1204 pos -= 8;
1205 if (i == 2)
1206 {
1207 UNBLOCK_INPUT;
1208 return make_number (colorval);
1209 }
1210 color = end;
1211 }
1212 }
1213 }
1214 else if (strnicmp(colorname, "rgb:", 4) == 0)
1215 {
1216 char *color;
1217 unsigned long colorval;
1218 int i, pos;
1219 pos = 0;
1220
1221 colorval = 0;
1222 color = colorname + 4;
1223 for (i = 0; i < 3; i++)
1224 {
1225 char *end;
1226 unsigned long value;
1227
1228 /* The check for 'x' in the following conditional takes into
1229 account the fact that strtol allows a "0x" in front of
1230 our numbers, and we don't. */
1231 if (!isxdigit(color[0]) || color[1] == 'x')
1232 break;
1233 value = strtoul(color, &end, 16);
1234 if (errno == ERANGE)
1235 break;
1236 switch (end - color)
1237 {
1238 case 1:
1239 value = value * 0x10 + value;
1240 break;
1241 case 2:
1242 break;
1243 case 3:
1244 value /= 0x10;
1245 break;
1246 case 4:
1247 value /= 0x100;
1248 break;
1249 default:
1250 value = ULONG_MAX;
1251 }
1252 if (value == ULONG_MAX)
1253 break;
1254 colorval |= (value << pos);
1255 pos += 0x8;
1256 if (i == 2)
1257 {
1258 if (*end != '\0')
1259 break;
1260 UNBLOCK_INPUT;
1261 return make_number (colorval);
1262 }
1263 if (*end != '/')
1264 break;
1265 color = end + 1;
1266 }
1267 }
1268 else if (strnicmp(colorname, "rgbi:", 5) == 0)
1269 {
1270 /* This is an RGB Intensity specification. */
1271 char *color;
1272 unsigned long colorval;
1273 int i, pos;
1274 pos = 0;
1275
1276 colorval = 0;
1277 color = colorname + 5;
1278 for (i = 0; i < 3; i++)
1279 {
1280 char *end;
1281 double value;
1282 unsigned long val;
1283
1284 value = strtod(color, &end);
1285 if (errno == ERANGE)
1286 break;
1287 if (value < 0.0 || value > 1.0)
1288 break;
1289 val = (unsigned long)(0x100 * value);
1290 /* We used 0x100 instead of 0xFF to give a continuous
1291 range between 0.0 and 1.0 inclusive. The next statement
1292 fixes the 1.0 case. */
1293 if (val == 0x100)
1294 val = 0xFF;
1295 colorval |= (val << pos);
1296 pos += 0x8;
1297 if (i == 2)
1298 {
1299 if (*end != '\0')
1300 break;
1301 UNBLOCK_INPUT;
1302 return make_number (colorval);
1303 }
1304 if (*end != '/')
1305 break;
1306 color = end + 1;
1307 }
1308 }
1309
1310 ret = mac_color_map_lookup (colorname);
1311
1312 UNBLOCK_INPUT;
1313 return ret;
1314 }
1315
1316 /* Gamma-correct COLOR on frame F. */
1317
1318 void
1319 gamma_correct (f, color)
1320 struct frame *f;
1321 unsigned long *color;
1322 {
1323 if (f->gamma)
1324 {
1325 unsigned long red, green, blue;
1326
1327 red = pow (RED_FROM_ULONG (*color) / 255.0, f->gamma) * 255.0 + 0.5;
1328 green = pow (GREEN_FROM_ULONG (*color) / 255.0, f->gamma) * 255.0 + 0.5;
1329 blue = pow (BLUE_FROM_ULONG (*color) / 255.0, f->gamma) * 255.0 + 0.5;
1330 *color = RGB_TO_ULONG (red, green, blue);
1331 }
1332 }
1333
1334 /* Decide if color named COLOR is valid for the display associated
1335 with the selected frame; if so, return the rgb values in COLOR_DEF.
1336 If ALLOC is nonzero, allocate a new colormap cell. */
1337
1338 int
1339 mac_defined_color (f, color, color_def, alloc)
1340 FRAME_PTR f;
1341 char *color;
1342 XColor *color_def;
1343 int alloc;
1344 {
1345 register Lisp_Object tem;
1346 unsigned long mac_color_ref;
1347
1348 tem = x_to_mac_color (color);
1349
1350 if (!NILP (tem))
1351 {
1352 if (f)
1353 {
1354 /* Apply gamma correction. */
1355 mac_color_ref = XUINT (tem);
1356 gamma_correct (f, &mac_color_ref);
1357 XSETINT (tem, mac_color_ref);
1358 }
1359
1360 color_def->pixel = mac_color_ref;
1361 color_def->red = RED16_FROM_ULONG (mac_color_ref);
1362 color_def->green = GREEN16_FROM_ULONG (mac_color_ref);
1363 color_def->blue = BLUE16_FROM_ULONG (mac_color_ref);
1364
1365 return 1;
1366 }
1367 else
1368 {
1369 return 0;
1370 }
1371 }
1372
1373 /* Given a string ARG naming a color, compute a pixel value from it
1374 suitable for screen F.
1375 If F is not a color screen, return DEF (default) regardless of what
1376 ARG says. */
1377
1378 int
1379 x_decode_color (f, arg, def)
1380 FRAME_PTR f;
1381 Lisp_Object arg;
1382 int def;
1383 {
1384 XColor cdef;
1385
1386 CHECK_STRING (arg);
1387
1388 if (strcmp (SDATA (arg), "black") == 0)
1389 return BLACK_PIX_DEFAULT (f);
1390 else if (strcmp (SDATA (arg), "white") == 0)
1391 return WHITE_PIX_DEFAULT (f);
1392
1393 #if 0
1394 if (FRAME_MAC_DISPLAY_INFO (f)->n_planes) == 1)
1395 return def;
1396 #endif
1397
1398 if (mac_defined_color (f, SDATA (arg), &cdef, 1))
1399 return cdef.pixel;
1400
1401 /* defined_color failed; return an ultimate default. */
1402 return def;
1403 }
1404 \f
1405 /* Functions called only from `x_set_frame_param'
1406 to set individual parameters.
1407
1408 If FRAME_MAC_WINDOW (f) is 0,
1409 the frame is being created and its window does not exist yet.
1410 In that case, just record the parameter's new value
1411 in the standard place; do not attempt to change the window. */
1412
1413 void
1414 x_set_foreground_color (f, arg, oldval)
1415 struct frame *f;
1416 Lisp_Object arg, oldval;
1417 {
1418 unsigned long fg, old_fg;
1419
1420 fg = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f));
1421 old_fg = FRAME_FOREGROUND_PIXEL (f);
1422 FRAME_FOREGROUND_PIXEL (f) = fg;
1423
1424 if (FRAME_MAC_WINDOW (f) != 0)
1425 {
1426 update_face_from_frame_parameter (f, Qforeground_color, arg);
1427 if (FRAME_VISIBLE_P (f))
1428 redraw_frame (f);
1429 }
1430 }
1431
1432 void
1433 x_set_background_color (f, arg, oldval)
1434 struct frame *f;
1435 Lisp_Object arg, oldval;
1436 {
1437 FRAME_BACKGROUND_PIXEL (f)
1438 = x_decode_color (f, arg, WHITE_PIX_DEFAULT (f));
1439
1440 if (FRAME_MAC_WINDOW (f) != 0)
1441 {
1442 update_face_from_frame_parameter (f, Qbackground_color, arg);
1443
1444 if (FRAME_VISIBLE_P (f))
1445 redraw_frame (f);
1446 }
1447 }
1448
1449 void
1450 x_set_mouse_color (f, arg, oldval)
1451 struct frame *f;
1452 Lisp_Object arg, oldval;
1453 {
1454 Cursor cursor, nontext_cursor, mode_cursor, hand_cursor;
1455 int count;
1456 int mask_color;
1457
1458 if (!EQ (Qnil, arg))
1459 f->output_data.mac->mouse_pixel
1460 = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f));
1461 mask_color = FRAME_BACKGROUND_PIXEL (f);
1462
1463 /* Don't let pointers be invisible. */
1464 if (mask_color == f->output_data.mac->mouse_pixel
1465 && mask_color == FRAME_BACKGROUND_PIXEL (f))
1466 f->output_data.mac->mouse_pixel = FRAME_FOREGROUND_PIXEL (f);
1467
1468 #if 0 /* MAC_TODO : cursor changes */
1469 BLOCK_INPUT;
1470
1471 /* It's not okay to crash if the user selects a screwy cursor. */
1472 count = x_catch_errors (FRAME_W32_DISPLAY (f));
1473
1474 if (!EQ (Qnil, Vx_pointer_shape))
1475 {
1476 CHECK_NUMBER (Vx_pointer_shape);
1477 cursor = XCreateFontCursor (FRAME_W32_DISPLAY (f), XINT (Vx_pointer_shape));
1478 }
1479 else
1480 cursor = XCreateFontCursor (FRAME_W32_DISPLAY (f), XC_xterm);
1481 x_check_errors (FRAME_W32_DISPLAY (f), "bad text pointer cursor: %s");
1482
1483 if (!EQ (Qnil, Vx_nontext_pointer_shape))
1484 {
1485 CHECK_NUMBER (Vx_nontext_pointer_shape);
1486 nontext_cursor = XCreateFontCursor (FRAME_W32_DISPLAY (f),
1487 XINT (Vx_nontext_pointer_shape));
1488 }
1489 else
1490 nontext_cursor = XCreateFontCursor (FRAME_W32_DISPLAY (f), XC_left_ptr);
1491 x_check_errors (FRAME_W32_DISPLAY (f), "bad nontext pointer cursor: %s");
1492
1493 if (!EQ (Qnil, Vx_hourglass_pointer_shape))
1494 {
1495 CHECK_NUMBER (Vx_hourglass_pointer_shape);
1496 hourglass_cursor = XCreateFontCursor (FRAME_W32_DISPLAY (f),
1497 XINT (Vx_hourglass_pointer_shape));
1498 }
1499 else
1500 hourglass_cursor = XCreateFontCursor (FRAME_W32_DISPLAY (f), XC_watch);
1501 x_check_errors (FRAME_W32_DISPLAY (f), "bad busy pointer cursor: %s");
1502
1503 x_check_errors (FRAME_W32_DISPLAY (f), "bad nontext pointer cursor: %s");
1504 if (!EQ (Qnil, Vx_mode_pointer_shape))
1505 {
1506 CHECK_NUMBER (Vx_mode_pointer_shape);
1507 mode_cursor = XCreateFontCursor (FRAME_W32_DISPLAY (f),
1508 XINT (Vx_mode_pointer_shape));
1509 }
1510 else
1511 mode_cursor = XCreateFontCursor (FRAME_W32_DISPLAY (f), XC_xterm);
1512 x_check_errors (FRAME_W32_DISPLAY (f), "bad modeline pointer cursor: %s");
1513
1514 if (!EQ (Qnil, Vx_sensitive_text_pointer_shape))
1515 {
1516 CHECK_NUMBER (Vx_sensitive_text_pointer_shape);
1517 hand_cursor
1518 = XCreateFontCursor (FRAME_W32_DISPLAY (f),
1519 XINT (Vx_sensitive_text_pointer_shape));
1520 }
1521 else
1522 hand_cursor = XCreateFontCursor (FRAME_W32_DISPLAY (f), XC_crosshair);
1523
1524 if (!NILP (Vx_window_horizontal_drag_shape))
1525 {
1526 CHECK_NUMBER (Vx_window_horizontal_drag_shape);
1527 horizontal_drag_cursor
1528 = XCreateFontCursor (FRAME_W32_DISPLAY (f),
1529 XINT (Vx_window_horizontal_drag_shape));
1530 }
1531 else
1532 horizontal_drag_cursor
1533 = XCreateFontCursor (FRAME_W32_DISPLAY (f), XC_sb_h_double_arrow);
1534
1535 /* Check and report errors with the above calls. */
1536 x_check_errors (FRAME_W32_DISPLAY (f), "can't set cursor shape: %s");
1537 x_uncatch_errors (FRAME_W32_DISPLAY (f), count);
1538
1539 {
1540 XColor fore_color, back_color;
1541
1542 fore_color.pixel = f->output_data.w32->mouse_pixel;
1543 back_color.pixel = mask_color;
1544 XQueryColor (FRAME_W32_DISPLAY (f),
1545 DefaultColormap (FRAME_W32_DISPLAY (f),
1546 DefaultScreen (FRAME_W32_DISPLAY (f))),
1547 &fore_color);
1548 XQueryColor (FRAME_W32_DISPLAY (f),
1549 DefaultColormap (FRAME_W32_DISPLAY (f),
1550 DefaultScreen (FRAME_W32_DISPLAY (f))),
1551 &back_color);
1552 XRecolorCursor (FRAME_W32_DISPLAY (f), cursor,
1553 &fore_color, &back_color);
1554 XRecolorCursor (FRAME_W32_DISPLAY (f), nontext_cursor,
1555 &fore_color, &back_color);
1556 XRecolorCursor (FRAME_W32_DISPLAY (f), mode_cursor,
1557 &fore_color, &back_color);
1558 XRecolorCursor (FRAME_W32_DISPLAY (f), hand_cursor,
1559 &fore_color, &back_color);
1560 XRecolorCursor (FRAME_W32_DISPLAY (f), hourglass_cursor,
1561 &fore_color, &back_color);
1562 }
1563
1564 if (FRAME_W32_WINDOW (f) != 0)
1565 XDefineCursor (FRAME_W32_DISPLAY (f), FRAME_W32_WINDOW (f), cursor);
1566
1567 if (cursor != f->output_data.w32->text_cursor && f->output_data.w32->text_cursor != 0)
1568 XFreeCursor (FRAME_W32_DISPLAY (f), f->output_data.w32->text_cursor);
1569 f->output_data.w32->text_cursor = cursor;
1570
1571 if (nontext_cursor != f->output_data.w32->nontext_cursor
1572 && f->output_data.w32->nontext_cursor != 0)
1573 XFreeCursor (FRAME_W32_DISPLAY (f), f->output_data.w32->nontext_cursor);
1574 f->output_data.w32->nontext_cursor = nontext_cursor;
1575
1576 if (hourglass_cursor != f->output_data.w32->hourglass_cursor
1577 && f->output_data.w32->hourglass_cursor != 0)
1578 XFreeCursor (FRAME_W32_DISPLAY (f), f->output_data.w32->hourglass_cursor);
1579 f->output_data.w32->hourglass_cursor = hourglass_cursor;
1580
1581 if (mode_cursor != f->output_data.w32->modeline_cursor
1582 && f->output_data.w32->modeline_cursor != 0)
1583 XFreeCursor (FRAME_W32_DISPLAY (f), f->output_data.w32->modeline_cursor);
1584 f->output_data.w32->modeline_cursor = mode_cursor;
1585
1586 if (hand_cursor != f->output_data.w32->hand_cursor
1587 && f->output_data.w32->hand_cursor != 0)
1588 XFreeCursor (FRAME_W32_DISPLAY (f), f->output_data.w32->hand_cursor);
1589 f->output_data.w32->hand_cursor = hand_cursor;
1590
1591 XFlush (FRAME_W32_DISPLAY (f));
1592 UNBLOCK_INPUT;
1593
1594 update_face_from_frame_parameter (f, Qmouse_color, arg);
1595 #endif /* MAC_TODO */
1596 }
1597
1598 void
1599 x_set_cursor_color (f, arg, oldval)
1600 struct frame *f;
1601 Lisp_Object arg, oldval;
1602 {
1603 unsigned long fore_pixel, pixel;
1604
1605 if (!NILP (Vx_cursor_fore_pixel))
1606 fore_pixel = x_decode_color (f, Vx_cursor_fore_pixel,
1607 WHITE_PIX_DEFAULT (f));
1608 else
1609 fore_pixel = FRAME_BACKGROUND_PIXEL (f);
1610
1611 pixel = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f));
1612
1613 /* Make sure that the cursor color differs from the background color. */
1614 if (pixel == FRAME_BACKGROUND_PIXEL (f))
1615 {
1616 pixel = f->output_data.mac->mouse_pixel;
1617 if (pixel == fore_pixel)
1618 fore_pixel = FRAME_BACKGROUND_PIXEL (f);
1619 }
1620
1621 f->output_data.mac->cursor_foreground_pixel = fore_pixel;
1622 f->output_data.mac->cursor_pixel = pixel;
1623
1624 if (FRAME_MAC_WINDOW (f) != 0)
1625 {
1626 BLOCK_INPUT;
1627 /* Update frame's cursor_gc. */
1628 f->output_data.mac->cursor_gc->foreground = fore_pixel;
1629 f->output_data.mac->cursor_gc->background = pixel;
1630
1631 UNBLOCK_INPUT;
1632
1633 if (FRAME_VISIBLE_P (f))
1634 {
1635 x_update_cursor (f, 0);
1636 x_update_cursor (f, 1);
1637 }
1638 }
1639
1640 update_face_from_frame_parameter (f, Qcursor_color, arg);
1641 }
1642
1643 /* Set the border-color of frame F to pixel value PIX.
1644 Note that this does not fully take effect if done before
1645 F has a window. */
1646
1647 void
1648 x_set_border_pixel (f, pix)
1649 struct frame *f;
1650 int pix;
1651 {
1652
1653 f->output_data.mac->border_pixel = pix;
1654
1655 if (FRAME_MAC_WINDOW (f) != 0 && f->border_width > 0)
1656 {
1657 if (FRAME_VISIBLE_P (f))
1658 redraw_frame (f);
1659 }
1660 }
1661
1662 /* Set the border-color of frame F to value described by ARG.
1663 ARG can be a string naming a color.
1664 The border-color is used for the border that is drawn by the server.
1665 Note that this does not fully take effect if done before
1666 F has a window; it must be redone when the window is created. */
1667
1668 void
1669 x_set_border_color (f, arg, oldval)
1670 struct frame *f;
1671 Lisp_Object arg, oldval;
1672 {
1673 int pix;
1674
1675 CHECK_STRING (arg);
1676 pix = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f));
1677 x_set_border_pixel (f, pix);
1678 update_face_from_frame_parameter (f, Qborder_color, arg);
1679 }
1680
1681
1682 void
1683 x_set_cursor_type (f, arg, oldval)
1684 FRAME_PTR f;
1685 Lisp_Object arg, oldval;
1686 {
1687 set_frame_cursor_types (f, arg);
1688
1689 /* Make sure the cursor gets redrawn. */
1690 cursor_type_changed = 1;
1691 }
1692 \f
1693 #if 0 /* MAC_TODO: really no icon for Mac */
1694 void
1695 x_set_icon_type (f, arg, oldval)
1696 struct frame *f;
1697 Lisp_Object arg, oldval;
1698 {
1699 int result;
1700
1701 if (NILP (arg) && NILP (oldval))
1702 return;
1703
1704 if (STRINGP (arg) && STRINGP (oldval)
1705 && EQ (Fstring_equal (oldval, arg), Qt))
1706 return;
1707
1708 if (SYMBOLP (arg) && SYMBOLP (oldval) && EQ (arg, oldval))
1709 return;
1710
1711 BLOCK_INPUT;
1712
1713 result = x_bitmap_icon (f, arg);
1714 if (result)
1715 {
1716 UNBLOCK_INPUT;
1717 error ("No icon window available");
1718 }
1719
1720 UNBLOCK_INPUT;
1721 }
1722 #endif /* MAC_TODO */
1723
1724 void
1725 x_set_icon_name (f, arg, oldval)
1726 struct frame *f;
1727 Lisp_Object arg, oldval;
1728 {
1729 int result;
1730
1731 if (STRINGP (arg))
1732 {
1733 if (STRINGP (oldval) && EQ (Fstring_equal (oldval, arg), Qt))
1734 return;
1735 }
1736 else if (!STRINGP (oldval) && EQ (oldval, Qnil) == EQ (arg, Qnil))
1737 return;
1738
1739 f->icon_name = arg;
1740
1741 #if 0 /* MAC_TODO */
1742 if (f->output_data.w32->icon_bitmap != 0)
1743 return;
1744
1745 BLOCK_INPUT;
1746
1747 result = x_text_icon (f,
1748 (char *) SDATA ((!NILP (f->icon_name)
1749 ? f->icon_name
1750 : !NILP (f->title)
1751 ? f->title
1752 : f->name)));
1753
1754 if (result)
1755 {
1756 UNBLOCK_INPUT;
1757 error ("No icon window available");
1758 }
1759
1760 /* If the window was unmapped (and its icon was mapped),
1761 the new icon is not mapped, so map the window in its stead. */
1762 if (FRAME_VISIBLE_P (f))
1763 {
1764 #ifdef USE_X_TOOLKIT
1765 XtPopup (f->output_data.w32->widget, XtGrabNone);
1766 #endif
1767 XMapWindow (FRAME_W32_DISPLAY (f), FRAME_W32_WINDOW (f));
1768 }
1769
1770 XFlush (FRAME_W32_DISPLAY (f));
1771 UNBLOCK_INPUT;
1772 #endif /* MAC_TODO */
1773 }
1774
1775 \f
1776 void
1777 x_set_menu_bar_lines (f, value, oldval)
1778 struct frame *f;
1779 Lisp_Object value, oldval;
1780 {
1781 int nlines;
1782 int olines = FRAME_MENU_BAR_LINES (f);
1783
1784 /* Right now, menu bars don't work properly in minibuf-only frames;
1785 most of the commands try to apply themselves to the minibuffer
1786 frame itself, and get an error because you can't switch buffers
1787 in or split the minibuffer window. */
1788 if (FRAME_MINIBUF_ONLY_P (f))
1789 return;
1790
1791 if (INTEGERP (value))
1792 nlines = XINT (value);
1793 else
1794 nlines = 0;
1795
1796 FRAME_MENU_BAR_LINES (f) = 0;
1797 if (nlines)
1798 FRAME_EXTERNAL_MENU_BAR (f) = 1;
1799 else
1800 {
1801 if (FRAME_EXTERNAL_MENU_BAR (f) == 1)
1802 free_frame_menubar (f);
1803 FRAME_EXTERNAL_MENU_BAR (f) = 0;
1804
1805 /* Adjust the frame size so that the client (text) dimensions
1806 remain the same. This depends on FRAME_EXTERNAL_MENU_BAR being
1807 set correctly. */
1808 x_set_window_size (f, 0, FRAME_COLS (f), FRAME_LINES (f));
1809 do_pending_window_change (0);
1810 }
1811 adjust_glyphs (f);
1812 }
1813
1814
1815 /* Set the number of lines used for the tool bar of frame F to VALUE.
1816 VALUE not an integer, or < 0 means set the lines to zero. OLDVAL
1817 is the old number of tool bar lines. This function changes the
1818 height of all windows on frame F to match the new tool bar height.
1819 The frame's height doesn't change. */
1820
1821 void
1822 x_set_tool_bar_lines (f, value, oldval)
1823 struct frame *f;
1824 Lisp_Object value, oldval;
1825 {
1826 int delta, nlines, root_height;
1827 Lisp_Object root_window;
1828
1829 /* Treat tool bars like menu bars. */
1830 if (FRAME_MINIBUF_ONLY_P (f))
1831 return;
1832
1833 /* Use VALUE only if an integer >= 0. */
1834 if (INTEGERP (value) && XINT (value) >= 0)
1835 nlines = XFASTINT (value);
1836 else
1837 nlines = 0;
1838
1839 /* Make sure we redisplay all windows in this frame. */
1840 ++windows_or_buffers_changed;
1841
1842 delta = nlines - FRAME_TOOL_BAR_LINES (f);
1843
1844 /* Don't resize the tool-bar to more than we have room for. */
1845 root_window = FRAME_ROOT_WINDOW (f);
1846 root_height = WINDOW_TOTAL_LINES (XWINDOW (root_window));
1847 if (root_height - delta < 1)
1848 {
1849 delta = root_height - 1;
1850 nlines = FRAME_TOOL_BAR_LINES (f) + delta;
1851 }
1852
1853 FRAME_TOOL_BAR_LINES (f) = nlines;
1854 change_window_heights (root_window, delta);
1855 adjust_glyphs (f);
1856
1857 /* We also have to make sure that the internal border at the top of
1858 the frame, below the menu bar or tool bar, is redrawn when the
1859 tool bar disappears. This is so because the internal border is
1860 below the tool bar if one is displayed, but is below the menu bar
1861 if there isn't a tool bar. The tool bar draws into the area
1862 below the menu bar. */
1863 if (FRAME_MAC_WINDOW (f) && FRAME_TOOL_BAR_LINES (f) == 0)
1864 {
1865 updating_frame = f;
1866 clear_frame ();
1867 clear_current_matrices (f);
1868 updating_frame = NULL;
1869 }
1870
1871 /* If the tool bar gets smaller, the internal border below it
1872 has to be cleared. It was formerly part of the display
1873 of the larger tool bar, and updating windows won't clear it. */
1874 if (delta < 0)
1875 {
1876 int height = FRAME_INTERNAL_BORDER_WIDTH (f);
1877 int width = FRAME_PIXEL_WIDTH (f);
1878 int y = nlines * FRAME_LINE_HEIGHT (f);
1879
1880 BLOCK_INPUT;
1881 XClearArea (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
1882 0, y, width, height, 0);
1883 UNBLOCK_INPUT;
1884
1885 if (WINDOWP (f->tool_bar_window))
1886 clear_glyph_matrix (XWINDOW (f->tool_bar_window)->current_matrix);
1887 }
1888 }
1889
1890
1891 /* Change the name of frame F to NAME. If NAME is nil, set F's name to
1892 w32_id_name.
1893
1894 If EXPLICIT is non-zero, that indicates that lisp code is setting the
1895 name; if NAME is a string, set F's name to NAME and set
1896 F->explicit_name; if NAME is Qnil, then clear F->explicit_name.
1897
1898 If EXPLICIT is zero, that indicates that Emacs redisplay code is
1899 suggesting a new name, which lisp code should override; if
1900 F->explicit_name is set, ignore the new name; otherwise, set it. */
1901
1902 void
1903 x_set_name (f, name, explicit)
1904 struct frame *f;
1905 Lisp_Object name;
1906 int explicit;
1907 {
1908 /* Make sure that requests from lisp code override requests from
1909 Emacs redisplay code. */
1910 if (explicit)
1911 {
1912 /* If we're switching from explicit to implicit, we had better
1913 update the mode lines and thereby update the title. */
1914 if (f->explicit_name && NILP (name))
1915 update_mode_lines = 1;
1916
1917 f->explicit_name = ! NILP (name);
1918 }
1919 else if (f->explicit_name)
1920 return;
1921
1922 /* If NAME is nil, set the name to the w32_id_name. */
1923 if (NILP (name))
1924 {
1925 /* Check for no change needed in this very common case
1926 before we do any consing. */
1927 if (!strcmp (FRAME_MAC_DISPLAY_INFO (f)->mac_id_name,
1928 SDATA (f->name)))
1929 return;
1930 name = build_string (FRAME_MAC_DISPLAY_INFO (f)->mac_id_name);
1931 }
1932 else
1933 CHECK_STRING (name);
1934
1935 /* Don't change the name if it's already NAME. */
1936 if (! NILP (Fstring_equal (name, f->name)))
1937 return;
1938
1939 f->name = name;
1940
1941 /* For setting the frame title, the title parameter should override
1942 the name parameter. */
1943 if (! NILP (f->title))
1944 name = f->title;
1945
1946 if (FRAME_MAC_WINDOW (f))
1947 {
1948 if (STRING_MULTIBYTE (name))
1949 #if 0 /* MAC_TODO: encoding title string */
1950 name = ENCODE_SYSTEM (name);
1951 #else
1952 return;
1953 #endif
1954
1955 BLOCK_INPUT;
1956
1957 {
1958 Str255 windowTitle;
1959 if (strlen (SDATA (name)) < 255)
1960 {
1961 strcpy (windowTitle, SDATA (name));
1962 c2pstr (windowTitle);
1963 SetWTitle (FRAME_MAC_WINDOW (f), windowTitle);
1964 }
1965 }
1966
1967 UNBLOCK_INPUT;
1968 }
1969 }
1970
1971 /* This function should be called when the user's lisp code has
1972 specified a name for the frame; the name will override any set by the
1973 redisplay code. */
1974 void
1975 x_explicitly_set_name (f, arg, oldval)
1976 FRAME_PTR f;
1977 Lisp_Object arg, oldval;
1978 {
1979 x_set_name (f, arg, 1);
1980 }
1981
1982 /* This function should be called by Emacs redisplay code to set the
1983 name; names set this way will never override names set by the user's
1984 lisp code. */
1985 void
1986 x_implicitly_set_name (f, arg, oldval)
1987 FRAME_PTR f;
1988 Lisp_Object arg, oldval;
1989 {
1990 x_set_name (f, arg, 0);
1991 }
1992 \f
1993 /* Change the title of frame F to NAME.
1994 If NAME is nil, use the frame name as the title.
1995
1996 If EXPLICIT is non-zero, that indicates that lisp code is setting the
1997 name; if NAME is a string, set F's name to NAME and set
1998 F->explicit_name; if NAME is Qnil, then clear F->explicit_name.
1999
2000 If EXPLICIT is zero, that indicates that Emacs redisplay code is
2001 suggesting a new name, which lisp code should override; if
2002 F->explicit_name is set, ignore the new name; otherwise, set it. */
2003
2004 void
2005 x_set_title (f, name, old_name)
2006 struct frame *f;
2007 Lisp_Object name, old_name;
2008 {
2009 /* Don't change the title if it's already NAME. */
2010 if (EQ (name, f->title))
2011 return;
2012
2013 update_mode_lines = 1;
2014
2015 f->title = name;
2016
2017 if (NILP (name))
2018 name = f->name;
2019
2020 if (FRAME_MAC_WINDOW (f))
2021 {
2022 if (STRING_MULTIBYTE (name))
2023 #if 0 /* MAC_TODO: encoding title string */
2024 name = ENCODE_SYSTEM (name);
2025 #else
2026 return;
2027 #endif
2028
2029 BLOCK_INPUT;
2030
2031 {
2032 Str255 windowTitle;
2033 if (strlen (SDATA (name)) < 255)
2034 {
2035 strcpy (windowTitle, SDATA (name));
2036 c2pstr (windowTitle);
2037 SetWTitle (FRAME_MAC_WINDOW (f), windowTitle);
2038 }
2039 }
2040
2041 UNBLOCK_INPUT;
2042 }
2043 }
2044
2045 void
2046 x_set_scroll_bar_default_width (f)
2047 struct frame *f;
2048 {
2049 /* Imitate X without X Toolkit */
2050
2051 int wid = FRAME_COLUMN_WIDTH (f);
2052
2053 #ifdef MAC_OSX
2054 FRAME_CONFIG_SCROLL_BAR_WIDTH (f) = 16; /* Aqua scroll bars. */
2055 FRAME_CONFIG_SCROLL_BAR_COLS (f) = (FRAME_CONFIG_SCROLL_BAR_WIDTH (f) +
2056 wid - 1) / wid;
2057 #else /* not MAC_OSX */
2058 /* Make the actual width at least 14 pixels and a multiple of a
2059 character width. */
2060 FRAME_CONFIG_SCROLL_BAR_COLS (f) = (14 + wid - 1) / wid;
2061
2062 /* Use all of that space (aside from required margins) for the
2063 scroll bar. */
2064 FRAME_CONFIG_SCROLL_BAR_WIDTH (f) = 0;
2065 #endif /* not MAC_OSX */
2066 }
2067
2068 \f
2069 /* Subroutines of creating a frame. */
2070
2071 char *
2072 x_get_string_resource (rdb, name, class)
2073 XrmDatabase rdb;
2074 char *name, *class;
2075 {
2076 /* MAC_TODO: implement resource strings */
2077 return (char *)0;
2078 }
2079
2080 /* Return the value of parameter PARAM.
2081
2082 First search ALIST, then Vdefault_frame_alist, then the X defaults
2083 database, using ATTRIBUTE as the attribute name and CLASS as its class.
2084
2085 Convert the resource to the type specified by desired_type.
2086
2087 If no default is specified, return Qunbound. If you call
2088 mac_get_arg, make sure you deal with Qunbound in a reasonable way,
2089 and don't let it get stored in any Lisp-visible variables! */
2090
2091 static Lisp_Object
2092 mac_get_arg (alist, param, attribute, class, type)
2093 Lisp_Object alist, param;
2094 char *attribute;
2095 char *class;
2096 enum resource_types type;
2097 {
2098 return x_get_arg (check_x_display_info (Qnil),
2099 alist, param, attribute, class, type);
2100 }
2101
2102 \f
2103 /* XParseGeometry copied from w32xfns.c */
2104
2105 /*
2106 * XParseGeometry parses strings of the form
2107 * "=<width>x<height>{+-}<xoffset>{+-}<yoffset>", where
2108 * width, height, xoffset, and yoffset are unsigned integers.
2109 * Example: "=80x24+300-49"
2110 * The equal sign is optional.
2111 * It returns a bitmask that indicates which of the four values
2112 * were actually found in the string. For each value found,
2113 * the corresponding argument is updated; for each value
2114 * not found, the corresponding argument is left unchanged.
2115 */
2116
2117 static int
2118 read_integer (string, NextString)
2119 register char *string;
2120 char **NextString;
2121 {
2122 register int Result = 0;
2123 int Sign = 1;
2124
2125 if (*string == '+')
2126 string++;
2127 else if (*string == '-')
2128 {
2129 string++;
2130 Sign = -1;
2131 }
2132 for (; (*string >= '0') && (*string <= '9'); string++)
2133 {
2134 Result = (Result * 10) + (*string - '0');
2135 }
2136 *NextString = string;
2137 if (Sign >= 0)
2138 return (Result);
2139 else
2140 return (-Result);
2141 }
2142
2143 int
2144 XParseGeometry (string, x, y, width, height)
2145 char *string;
2146 int *x, *y;
2147 unsigned int *width, *height; /* RETURN */
2148 {
2149 int mask = NoValue;
2150 register char *strind;
2151 unsigned int tempWidth, tempHeight;
2152 int tempX, tempY;
2153 char *nextCharacter;
2154
2155 if ((string == NULL) || (*string == '\0')) return (mask);
2156 if (*string == '=')
2157 string++; /* ignore possible '=' at beg of geometry spec */
2158
2159 strind = (char *)string;
2160 if (*strind != '+' && *strind != '-' && *strind != 'x')
2161 {
2162 tempWidth = read_integer (strind, &nextCharacter);
2163 if (strind == nextCharacter)
2164 return (0);
2165 strind = nextCharacter;
2166 mask |= WidthValue;
2167 }
2168
2169 if (*strind == 'x' || *strind == 'X')
2170 {
2171 strind++;
2172 tempHeight = read_integer (strind, &nextCharacter);
2173 if (strind == nextCharacter)
2174 return (0);
2175 strind = nextCharacter;
2176 mask |= HeightValue;
2177 }
2178
2179 if ((*strind == '+') || (*strind == '-'))
2180 {
2181 if (*strind == '-')
2182 {
2183 strind++;
2184 tempX = -read_integer (strind, &nextCharacter);
2185 if (strind == nextCharacter)
2186 return (0);
2187 strind = nextCharacter;
2188 mask |= XNegative;
2189
2190 }
2191 else
2192 {
2193 strind++;
2194 tempX = read_integer (strind, &nextCharacter);
2195 if (strind == nextCharacter)
2196 return (0);
2197 strind = nextCharacter;
2198 }
2199 mask |= XValue;
2200 if ((*strind == '+') || (*strind == '-'))
2201 {
2202 if (*strind == '-')
2203 {
2204 strind++;
2205 tempY = -read_integer (strind, &nextCharacter);
2206 if (strind == nextCharacter)
2207 return (0);
2208 strind = nextCharacter;
2209 mask |= YNegative;
2210
2211 }
2212 else
2213 {
2214 strind++;
2215 tempY = read_integer (strind, &nextCharacter);
2216 if (strind == nextCharacter)
2217 return (0);
2218 strind = nextCharacter;
2219 }
2220 mask |= YValue;
2221 }
2222 }
2223
2224 /* If strind isn't at the end of the string the it's an invalid
2225 geometry specification. */
2226
2227 if (*strind != '\0') return (0);
2228
2229 if (mask & XValue)
2230 *x = tempX;
2231 if (mask & YValue)
2232 *y = tempY;
2233 if (mask & WidthValue)
2234 *width = tempWidth;
2235 if (mask & HeightValue)
2236 *height = tempHeight;
2237 return (mask);
2238 }
2239
2240 \f
2241 #if 0 /* MAC_TODO */
2242 /* Create and set up the Mac window for frame F. */
2243
2244 static void
2245 mac_window (f, window_prompting, minibuffer_only)
2246 struct frame *f;
2247 long window_prompting;
2248 int minibuffer_only;
2249 {
2250 Rect r;
2251
2252 BLOCK_INPUT;
2253
2254 /* Use the resource name as the top-level window name
2255 for looking up resources. Make a non-Lisp copy
2256 for the window manager, so GC relocation won't bother it.
2257
2258 Elsewhere we specify the window name for the window manager. */
2259
2260 {
2261 char *str = (char *) SDATA (Vx_resource_name);
2262 f->namebuf = (char *) xmalloc (strlen (str) + 1);
2263 strcpy (f->namebuf, str);
2264 }
2265
2266 SetRect (&r, f->left_pos, f->top_pos,
2267 f->left_pos + FRAME_PIXEL_WIDTH (f),
2268 f->top_pos + FRAME_PIXEL_HEIGHT (f));
2269 FRAME_MAC_WINDOW (f)
2270 = NewCWindow (NULL, &r, "\p", 1, zoomDocProc, (WindowPtr) -1, 1, (long) f->output_data.mac);
2271
2272 validate_x_resource_name ();
2273
2274 /* x_set_name normally ignores requests to set the name if the
2275 requested name is the same as the current name. This is the one
2276 place where that assumption isn't correct; f->name is set, but
2277 the server hasn't been told. */
2278 {
2279 Lisp_Object name;
2280 int explicit = f->explicit_name;
2281
2282 f->explicit_name = 0;
2283 name = f->name;
2284 f->name = Qnil;
2285 x_set_name (f, name, explicit);
2286 }
2287
2288 ShowWindow (FRAME_MAC_WINDOW (f));
2289
2290 UNBLOCK_INPUT;
2291
2292 if (!minibuffer_only && FRAME_EXTERNAL_MENU_BAR (f))
2293 initialize_frame_menubar (f);
2294
2295 if (FRAME_MAC_WINDOW (f) == 0)
2296 error ("Unable to create window");
2297 }
2298 #endif /* MAC_TODO */
2299
2300 /* Handle the icon stuff for this window. Perhaps later we might
2301 want an x_set_icon_position which can be called interactively as
2302 well. */
2303
2304 static void
2305 x_icon (f, parms)
2306 struct frame *f;
2307 Lisp_Object parms;
2308 {
2309 Lisp_Object icon_x, icon_y;
2310
2311 /* Set the position of the icon. Note that Windows 95 groups all
2312 icons in the tray. */
2313 icon_x = mac_get_arg (parms, Qicon_left, 0, 0, RES_TYPE_NUMBER);
2314 icon_y = mac_get_arg (parms, Qicon_top, 0, 0, RES_TYPE_NUMBER);
2315 if (!EQ (icon_x, Qunbound) && !EQ (icon_y, Qunbound))
2316 {
2317 CHECK_NUMBER (icon_x);
2318 CHECK_NUMBER (icon_y);
2319 }
2320 else if (!EQ (icon_x, Qunbound) || !EQ (icon_y, Qunbound))
2321 error ("Both left and top icon corners of icon must be specified");
2322
2323 BLOCK_INPUT;
2324
2325 if (! EQ (icon_x, Qunbound))
2326 x_wm_set_icon_position (f, XINT (icon_x), XINT (icon_y));
2327
2328 #if 0 /* TODO */
2329 /* Start up iconic or window? */
2330 x_wm_set_window_state
2331 (f, (EQ (w32_get_arg (parms, Qvisibility, 0, 0, RES_TYPE_SYMBOL), Qicon)
2332 ? IconicState
2333 : NormalState));
2334
2335 x_text_icon (f, (char *) SDATA ((!NILP (f->icon_name)
2336 ? f->icon_name
2337 : f->name)));
2338 #endif
2339
2340 UNBLOCK_INPUT;
2341 }
2342
2343
2344 void
2345 x_make_gc (f)
2346 struct frame *f;
2347 {
2348 XGCValues gc_values;
2349
2350 BLOCK_INPUT;
2351
2352 /* Create the GCs of this frame.
2353 Note that many default values are used. */
2354
2355 /* Normal video */
2356 gc_values.font = FRAME_FONT (f);
2357 gc_values.foreground = FRAME_FOREGROUND_PIXEL (f);
2358 gc_values.background = FRAME_BACKGROUND_PIXEL (f);
2359 f->output_data.mac->normal_gc = XCreateGC (FRAME_MAC_DISPLAY (f),
2360 FRAME_MAC_WINDOW (f),
2361 GCFont | GCForeground | GCBackground,
2362 &gc_values);
2363
2364 /* Reverse video style. */
2365 gc_values.foreground = FRAME_BACKGROUND_PIXEL (f);
2366 gc_values.background = FRAME_FOREGROUND_PIXEL (f);
2367 f->output_data.mac->reverse_gc = XCreateGC (FRAME_MAC_DISPLAY (f),
2368 FRAME_MAC_WINDOW (f),
2369 GCFont | GCForeground | GCBackground,
2370 &gc_values);
2371
2372 /* Cursor has cursor-color background, background-color foreground. */
2373 gc_values.foreground = FRAME_BACKGROUND_PIXEL (f);
2374 gc_values.background = f->output_data.mac->cursor_pixel;
2375 f->output_data.mac->cursor_gc = XCreateGC (FRAME_MAC_DISPLAY (f),
2376 FRAME_MAC_WINDOW (f),
2377 GCFont | GCForeground | GCBackground,
2378 &gc_values);
2379
2380 /* Reliefs. */
2381 f->output_data.mac->white_relief.gc = 0;
2382 f->output_data.mac->black_relief.gc = 0;
2383
2384 #if 0
2385 /* Create the gray border tile used when the pointer is not in
2386 the frame. Since this depends on the frame's pixel values,
2387 this must be done on a per-frame basis. */
2388 f->output_data.x->border_tile
2389 = (XCreatePixmapFromBitmapData
2390 (FRAME_X_DISPLAY (f), FRAME_X_DISPLAY_INFO (f)->root_window,
2391 gray_bits, gray_width, gray_height,
2392 f->output_data.x->foreground_pixel,
2393 f->output_data.x->background_pixel,
2394 DefaultDepth (FRAME_X_DISPLAY (f), FRAME_X_SCREEN_NUMBER (f))));
2395 #endif
2396
2397 UNBLOCK_INPUT;
2398 }
2399
2400
2401 /* Free what was was allocated in x_make_gc. */
2402
2403 void
2404 x_free_gcs (f)
2405 struct frame *f;
2406 {
2407 Display *dpy = FRAME_MAC_DISPLAY (f);
2408
2409 BLOCK_INPUT;
2410
2411 if (f->output_data.mac->normal_gc)
2412 {
2413 XFreeGC (dpy, f->output_data.mac->normal_gc);
2414 f->output_data.mac->normal_gc = 0;
2415 }
2416
2417 if (f->output_data.mac->reverse_gc)
2418 {
2419 XFreeGC (dpy, f->output_data.mac->reverse_gc);
2420 f->output_data.mac->reverse_gc = 0;
2421 }
2422
2423 if (f->output_data.mac->cursor_gc)
2424 {
2425 XFreeGC (dpy, f->output_data.mac->cursor_gc);
2426 f->output_data.mac->cursor_gc = 0;
2427 }
2428
2429 #if 0
2430 if (f->output_data.mac->border_tile)
2431 {
2432 XFreePixmap (dpy, f->output_data.mac->border_tile);
2433 f->output_data.mac->border_tile = 0;
2434 }
2435 #endif
2436
2437 if (f->output_data.mac->white_relief.gc)
2438 {
2439 XFreeGC (dpy, f->output_data.mac->white_relief.gc);
2440 f->output_data.mac->white_relief.gc = 0;
2441 }
2442
2443 if (f->output_data.mac->black_relief.gc)
2444 {
2445 XFreeGC (dpy, f->output_data.mac->black_relief.gc);
2446 f->output_data.mac->black_relief.gc = 0;
2447 }
2448
2449 UNBLOCK_INPUT;
2450 }
2451
2452
2453 /* Handler for signals raised during x_create_frame and
2454 x_create_top_frame. FRAME is the frame which is partially
2455 constructed. */
2456
2457 static Lisp_Object
2458 unwind_create_frame (frame)
2459 Lisp_Object frame;
2460 {
2461 struct frame *f = XFRAME (frame);
2462
2463 /* If frame is ``official'', nothing to do. */
2464 if (!CONSP (Vframe_list) || !EQ (XCAR (Vframe_list), frame))
2465 {
2466 #if GLYPH_DEBUG
2467 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
2468 #endif
2469
2470 x_free_frame_resources (f);
2471
2472 /* Check that reference counts are indeed correct. */
2473 xassert (dpyinfo->reference_count == dpyinfo_refcount);
2474 xassert (dpyinfo->image_cache->refcount == image_cache_refcount);
2475 return Qt;
2476 }
2477
2478 return Qnil;
2479 }
2480
2481
2482 DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
2483 1, 1, 0,
2484 doc: /* Make a new window, which is called a \"frame\" in Emacs terms.
2485 Returns an Emacs frame object.
2486 ALIST is an alist of frame parameters.
2487 If the parameters specify that the frame should not have a minibuffer,
2488 and do not specify a specific minibuffer window to use,
2489 then `default-minibuffer-frame' must be a frame whose minibuffer can
2490 be shared by the new frame.
2491
2492 This function is an internal primitive--use `make-frame' instead. */)
2493 (parms)
2494 Lisp_Object parms;
2495 {
2496 struct frame *f;
2497 Lisp_Object frame, tem;
2498 Lisp_Object name;
2499 int minibuffer_only = 0;
2500 long window_prompting = 0;
2501 int width, height;
2502 int count = SPECPDL_INDEX ();
2503 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
2504 Lisp_Object display;
2505 struct mac_display_info *dpyinfo = NULL;
2506 Lisp_Object parent;
2507 struct kboard *kb;
2508 char x_frame_name[10];
2509 static int x_frame_count = 2; /* begins at 2 because terminal frame is F1 */
2510
2511 check_mac ();
2512
2513 /* Use this general default value to start with
2514 until we know if this frame has a specified name. */
2515 Vx_resource_name = Vinvocation_name;
2516
2517 display = mac_get_arg (parms, Qdisplay, 0, 0, RES_TYPE_STRING);
2518 if (EQ (display, Qunbound))
2519 display = Qnil;
2520 dpyinfo = check_x_display_info (display);
2521 #ifdef MULTI_KBOARD
2522 kb = dpyinfo->kboard;
2523 #else
2524 kb = &the_only_kboard;
2525 #endif
2526
2527 name = mac_get_arg (parms, Qname, "name", "Name", RES_TYPE_STRING);
2528 if (!STRINGP (name)
2529 && ! EQ (name, Qunbound)
2530 && ! NILP (name))
2531 error ("Invalid frame name--not a string or nil");
2532
2533 if (STRINGP (name))
2534 Vx_resource_name = name;
2535
2536 /* See if parent window is specified. */
2537 parent = mac_get_arg (parms, Qparent_id, NULL, NULL, RES_TYPE_NUMBER);
2538 if (EQ (parent, Qunbound))
2539 parent = Qnil;
2540 if (! NILP (parent))
2541 CHECK_NUMBER (parent);
2542
2543 /* make_frame_without_minibuffer can run Lisp code and garbage collect. */
2544 /* No need to protect DISPLAY because that's not used after passing
2545 it to make_frame_without_minibuffer. */
2546 frame = Qnil;
2547 GCPRO4 (parms, parent, name, frame);
2548 tem = mac_get_arg (parms, Qminibuffer, "minibuffer", "Minibuffer",
2549 RES_TYPE_SYMBOL);
2550 if (EQ (tem, Qnone) || NILP (tem))
2551 f = make_frame_without_minibuffer (Qnil, kb, display);
2552 else if (EQ (tem, Qonly))
2553 {
2554 f = make_minibuffer_frame ();
2555 minibuffer_only = 1;
2556 }
2557 else if (WINDOWP (tem))
2558 f = make_frame_without_minibuffer (tem, kb, display);
2559 else
2560 f = make_frame (1);
2561
2562 if (EQ (name, Qunbound) || NILP (name))
2563 {
2564 sprintf (x_frame_name, "F%d", x_frame_count++);
2565 f->name = build_string (x_frame_name);
2566 f->explicit_name = 0;
2567 }
2568 else
2569 {
2570 f->name = name;
2571 f->explicit_name = 1;
2572 }
2573
2574 XSETFRAME (frame, f);
2575
2576 /* Note that X Windows does support scroll bars. */
2577 FRAME_CAN_HAVE_SCROLL_BARS (f) = 1;
2578
2579 f->output_method = output_mac;
2580 f->output_data.mac = (struct mac_output *) xmalloc (sizeof (struct mac_output));
2581 bzero (f->output_data.mac, sizeof (struct mac_output));
2582 FRAME_FONTSET (f) = -1;
2583 f->output_data.mac->scroll_bar_foreground_pixel = -1;
2584 f->output_data.mac->scroll_bar_background_pixel = -1;
2585 record_unwind_protect (unwind_create_frame, frame);
2586
2587 f->icon_name
2588 = mac_get_arg (parms, Qicon_name, "iconName", "Title", RES_TYPE_STRING);
2589 if (! STRINGP (f->icon_name))
2590 f->icon_name = Qnil;
2591
2592 /* FRAME_W32_DISPLAY_INFO (f) = dpyinfo; */
2593 #ifdef MULTI_KBOARD
2594 FRAME_KBOARD (f) = kb;
2595 #endif
2596
2597 /* Specify the parent under which to make this window. */
2598
2599 if (!NILP (parent))
2600 {
2601 f->output_data.mac->parent_desc = (Window) parent;
2602 f->output_data.mac->explicit_parent = 1;
2603 }
2604 else
2605 {
2606 f->output_data.mac->parent_desc = FRAME_MAC_DISPLAY_INFO (f)->root_window;
2607 f->output_data.mac->explicit_parent = 0;
2608 }
2609
2610 /* Set the name; the functions to which we pass f expect the name to
2611 be set. */
2612 if (EQ (name, Qunbound) || NILP (name))
2613 {
2614 f->name = build_string (dpyinfo->mac_id_name);
2615 f->explicit_name = 0;
2616 }
2617 else
2618 {
2619 f->name = name;
2620 f->explicit_name = 1;
2621 /* use the frame's title when getting resources for this frame. */
2622 specbind (Qx_resource_name, name);
2623 }
2624
2625 /* Extract the window parameters from the supplied values
2626 that are needed to determine window geometry. */
2627 {
2628 Lisp_Object font;
2629
2630 font = mac_get_arg (parms, Qfont, "font", "Font", RES_TYPE_STRING);
2631
2632 BLOCK_INPUT;
2633 /* First, try whatever font the caller has specified. */
2634 if (STRINGP (font))
2635 {
2636 tem = Fquery_fontset (font, Qnil);
2637 if (STRINGP (tem))
2638 font = x_new_fontset (f, SDATA (tem));
2639 else
2640 font = x_new_font (f, SDATA (font));
2641 }
2642
2643 /* Try out a font which we hope has bold and italic variations. */
2644 if (! STRINGP (font))
2645 font = x_new_font (f, "-ETL-fixed-medium-r-*--*-160-*-*-*-*-iso8859-1");
2646 /* If those didn't work, look for something which will at least work. */
2647 if (! STRINGP (font))
2648 font = x_new_font (f, "-*-monaco-*-12-*-mac-roman");
2649 if (! STRINGP (font))
2650 font = x_new_font (f, "-*-courier-*-10-*-mac-roman");
2651 if (! STRINGP (font))
2652 error ("Cannot find any usable font");
2653 UNBLOCK_INPUT;
2654
2655 x_default_parameter (f, parms, Qfont, font,
2656 "font", "Font", RES_TYPE_STRING);
2657 }
2658
2659 x_default_parameter (f, parms, Qborder_width, make_number (0),
2660 "borderwidth", "BorderWidth", RES_TYPE_NUMBER);
2661 /* This defaults to 2 in order to match xterm. We recognize either
2662 internalBorderWidth or internalBorder (which is what xterm calls
2663 it). */
2664 if (NILP (Fassq (Qinternal_border_width, parms)))
2665 {
2666 Lisp_Object value;
2667
2668 value = mac_get_arg (parms, Qinternal_border_width,
2669 "internalBorder", "InternalBorder", RES_TYPE_NUMBER);
2670 if (! EQ (value, Qunbound))
2671 parms = Fcons (Fcons (Qinternal_border_width, value),
2672 parms);
2673 }
2674 /* Default internalBorderWidth to 0 on Windows to match other programs. */
2675 x_default_parameter (f, parms, Qinternal_border_width, make_number (0),
2676 "internalBorderWidth", "InternalBorder", RES_TYPE_NUMBER);
2677 x_default_parameter (f, parms, Qvertical_scroll_bars, Qright,
2678 "verticalScrollBars", "ScrollBars", RES_TYPE_SYMBOL);
2679
2680 /* Also do the stuff which must be set before the window exists. */
2681 x_default_parameter (f, parms, Qforeground_color, build_string ("black"),
2682 "foreground", "Foreground", RES_TYPE_STRING);
2683 x_default_parameter (f, parms, Qbackground_color, build_string ("white"),
2684 "background", "Background", RES_TYPE_STRING);
2685 x_default_parameter (f, parms, Qmouse_color, build_string ("black"),
2686 "pointerColor", "Foreground", RES_TYPE_STRING);
2687 x_default_parameter (f, parms, Qcursor_color, build_string ("black"),
2688 "cursorColor", "Foreground", RES_TYPE_STRING);
2689 x_default_parameter (f, parms, Qborder_color, build_string ("black"),
2690 "borderColor", "BorderColor", RES_TYPE_STRING);
2691 x_default_parameter (f, parms, Qscreen_gamma, Qnil,
2692 "screenGamma", "ScreenGamma", RES_TYPE_FLOAT);
2693 x_default_parameter (f, parms, Qline_spacing, Qnil,
2694 "lineSpacing", "LineSpacing", RES_TYPE_NUMBER);
2695 x_default_parameter (f, parms, Qleft_fringe, Qnil,
2696 "leftFringe", "LeftFringe", RES_TYPE_NUMBER);
2697 x_default_parameter (f, parms, Qright_fringe, Qnil,
2698 "rightFringe", "RightFringe", RES_TYPE_NUMBER);
2699
2700
2701 /* Init faces before x_default_parameter is called for scroll-bar
2702 parameters because that function calls x_set_scroll_bar_width,
2703 which calls change_frame_size, which calls Fset_window_buffer,
2704 which runs hooks, which call Fvertical_motion. At the end, we
2705 end up in init_iterator with a null face cache, which should not
2706 happen. */
2707 init_frame_faces (f);
2708
2709 x_default_parameter (f, parms, Qmenu_bar_lines, make_number (1),
2710 "menuBar", "MenuBar", RES_TYPE_NUMBER);
2711 x_default_parameter (f, parms, Qtool_bar_lines, make_number (0),
2712 "toolBar", "ToolBar", RES_TYPE_NUMBER);
2713 x_default_parameter (f, parms, Qbuffer_predicate, Qnil,
2714 "bufferPredicate", "BufferPredicate", RES_TYPE_SYMBOL);
2715 x_default_parameter (f, parms, Qtitle, Qnil,
2716 "title", "Title", RES_TYPE_STRING);
2717
2718 f->output_data.mac->parent_desc = FRAME_MAC_DISPLAY_INFO (f)->root_window;
2719
2720 /* MAC_TODO: specify 1 below when toolbars are implemented. */
2721 window_prompting = x_figure_window_size (f, parms, 0);
2722
2723 tem = mac_get_arg (parms, Qunsplittable, 0, 0, RES_TYPE_BOOLEAN);
2724 f->no_split = minibuffer_only || EQ (tem, Qt);
2725
2726 /* Create the window. Add the tool-bar height to the initial frame
2727 height so that the user gets a text display area of the size he
2728 specified with -g or via the registry. Later changes of the
2729 tool-bar height don't change the frame size. This is done so that
2730 users can create tall Emacs frames without having to guess how
2731 tall the tool-bar will get. */
2732 FRAME_LINES (f) += FRAME_TOOL_BAR_LINES (f);
2733
2734 /* mac_window (f, window_prompting, minibuffer_only); */
2735 make_mac_frame (f);
2736
2737 x_icon (f, parms);
2738
2739 x_make_gc (f);
2740
2741 /* Now consider the frame official. */
2742 FRAME_MAC_DISPLAY_INFO (f)->reference_count++;
2743 Vframe_list = Fcons (frame, Vframe_list);
2744
2745 /* We need to do this after creating the window, so that the
2746 icon-creation functions can say whose icon they're describing. */
2747 x_default_parameter (f, parms, Qicon_type, Qnil,
2748 "bitmapIcon", "BitmapIcon", RES_TYPE_SYMBOL);
2749
2750 x_default_parameter (f, parms, Qauto_raise, Qnil,
2751 "autoRaise", "AutoRaiseLower", RES_TYPE_BOOLEAN);
2752 x_default_parameter (f, parms, Qauto_lower, Qnil,
2753 "autoLower", "AutoRaiseLower", RES_TYPE_BOOLEAN);
2754 x_default_parameter (f, parms, Qcursor_type, Qbox,
2755 "cursorType", "CursorType", RES_TYPE_SYMBOL);
2756 x_default_parameter (f, parms, Qscroll_bar_width, Qnil,
2757 "scrollBarWidth", "ScrollBarWidth", RES_TYPE_NUMBER);
2758
2759 /* Dimensions, especially FRAME_LINES (f), must be done via change_frame_size.
2760 Change will not be effected unless different from the current
2761 FRAME_LINES (f). */
2762 width = FRAME_COLS (f);
2763 height = FRAME_LINES (f);
2764
2765 FRAME_LINES (f) = 0;
2766 SET_FRAME_COLS (f, 0);
2767 change_frame_size (f, height, width, 1, 0, 0);
2768
2769 /* Set up faces after all frame parameters are known. */
2770 call1 (Qface_set_after_frame_default, frame);
2771
2772 #if 0 /* MAC_TODO: when we have window manager hints */
2773 /* Tell the server what size and position, etc, we want, and how
2774 badly we want them. This should be done after we have the menu
2775 bar so that its size can be taken into account. */
2776 BLOCK_INPUT;
2777 x_wm_set_size_hint (f, window_prompting, 0);
2778 UNBLOCK_INPUT;
2779 #endif
2780
2781 /* Make the window appear on the frame and enable display, unless
2782 the caller says not to. However, with explicit parent, Emacs
2783 cannot control visibility, so don't try. */
2784 if (! f->output_data.mac->explicit_parent)
2785 {
2786 Lisp_Object visibility;
2787
2788 visibility = mac_get_arg (parms, Qvisibility, 0, 0, RES_TYPE_SYMBOL);
2789 if (EQ (visibility, Qunbound))
2790 visibility = Qt;
2791
2792 #if 0 /* MAC_TODO: really no iconify on Mac */
2793 if (EQ (visibility, Qicon))
2794 x_iconify_frame (f);
2795 else
2796 #endif
2797 if (! NILP (visibility))
2798 x_make_frame_visible (f);
2799 else
2800 /* Must have been Qnil. */
2801 ;
2802 }
2803 UNGCPRO;
2804
2805 /* Make sure windows on this frame appear in calls to next-window
2806 and similar functions. */
2807 Vwindow_list = Qnil;
2808
2809 return unbind_to (count, frame);
2810 }
2811
2812 /* FRAME is used only to get a handle on the X display. We don't pass the
2813 display info directly because we're called from frame.c, which doesn't
2814 know about that structure. */
2815 Lisp_Object
2816 x_get_focus_frame (frame)
2817 struct frame *frame;
2818 {
2819 struct mac_display_info *dpyinfo = FRAME_MAC_DISPLAY_INFO (frame);
2820 Lisp_Object xfocus;
2821 if (! dpyinfo->x_focus_frame)
2822 return Qnil;
2823
2824 XSETFRAME (xfocus, dpyinfo->x_focus_frame);
2825 return xfocus;
2826 }
2827 \f
2828 DEFUN ("xw-color-defined-p", Fxw_color_defined_p, Sxw_color_defined_p, 1, 2, 0,
2829 doc: /* Internal function called by `color-defined-p', which see. */)
2830 (color, frame)
2831 Lisp_Object color, frame;
2832 {
2833 XColor foo;
2834 FRAME_PTR f = check_x_frame (frame);
2835
2836 CHECK_STRING (color);
2837
2838 if (mac_defined_color (f, SDATA (color), &foo, 0))
2839 return Qt;
2840 else
2841 return Qnil;
2842 }
2843
2844 DEFUN ("xw-color-values", Fxw_color_values, Sxw_color_values, 1, 2, 0,
2845 doc: /* Internal function called by `color-values', which see. */)
2846 (color, frame)
2847 Lisp_Object color, frame;
2848 {
2849 XColor foo;
2850 FRAME_PTR f = check_x_frame (frame);
2851
2852 CHECK_STRING (color);
2853
2854 if (mac_defined_color (f, SDATA (color), &foo, 0))
2855 {
2856 Lisp_Object rgb[3];
2857
2858 rgb[0] = make_number (foo.red);
2859 rgb[1] = make_number (foo.green);
2860 rgb[2] = make_number (foo.blue);
2861 return Flist (3, rgb);
2862 }
2863 else
2864 return Qnil;
2865 }
2866
2867 DEFUN ("xw-display-color-p", Fxw_display_color_p, Sxw_display_color_p, 0, 1, 0,
2868 doc: /* Internal function called by `display-color-p', which see. */)
2869 (display)
2870 Lisp_Object display;
2871 {
2872 struct mac_display_info *dpyinfo = check_x_display_info (display);
2873
2874 if (!dpyinfo->color_p)
2875 return Qnil;
2876
2877 return Qt;
2878 }
2879
2880 DEFUN ("x-display-grayscale-p", Fx_display_grayscale_p, Sx_display_grayscale_p,
2881 0, 1, 0,
2882 doc: /* Return t if the X display supports shades of gray.
2883 Note that color displays do support shades of gray.
2884 The optional argument DISPLAY specifies which display to ask about.
2885 DISPLAY should be either a frame or a display name (a string).
2886 If omitted or nil, that stands for the selected frame's display. */)
2887 (display)
2888 Lisp_Object display;
2889 {
2890 struct mac_display_info *dpyinfo = check_x_display_info (display);
2891
2892 if (dpyinfo->n_planes <= 1)
2893 return Qnil;
2894
2895 return Qt;
2896 }
2897
2898 DEFUN ("x-display-pixel-width", Fx_display_pixel_width, Sx_display_pixel_width,
2899 0, 1, 0,
2900 doc: /* Returns the width in pixels of the X display DISPLAY.
2901 The optional argument DISPLAY specifies which display to ask about.
2902 DISPLAY should be either a frame or a display name (a string).
2903 If omitted or nil, that stands for the selected frame's display. */)
2904 (display)
2905 Lisp_Object display;
2906 {
2907 struct mac_display_info *dpyinfo = check_x_display_info (display);
2908
2909 return make_number (dpyinfo->width);
2910 }
2911
2912 DEFUN ("x-display-pixel-height", Fx_display_pixel_height,
2913 Sx_display_pixel_height, 0, 1, 0,
2914 doc: /* Returns the height in pixels of the X display DISPLAY.
2915 The optional argument DISPLAY specifies which display to ask about.
2916 DISPLAY should be either a frame or a display name (a string).
2917 If omitted or nil, that stands for the selected frame's display. */)
2918 (display)
2919 Lisp_Object display;
2920 {
2921 struct mac_display_info *dpyinfo = check_x_display_info (display);
2922
2923 return make_number (dpyinfo->height);
2924 }
2925
2926 DEFUN ("x-display-planes", Fx_display_planes, Sx_display_planes,
2927 0, 1, 0,
2928 doc: /* Returns the number of bitplanes of the display DISPLAY.
2929 The optional argument DISPLAY specifies which display to ask about.
2930 DISPLAY should be either a frame or a display name (a string).
2931 If omitted or nil, that stands for the selected frame's display. */)
2932 (display)
2933 Lisp_Object display;
2934 {
2935 struct mac_display_info *dpyinfo = check_x_display_info (display);
2936
2937 return make_number (dpyinfo->n_planes);
2938 }
2939
2940 DEFUN ("x-display-color-cells", Fx_display_color_cells, Sx_display_color_cells,
2941 0, 1, 0,
2942 doc: /* Returns the number of color cells of the display DISPLAY.
2943 The optional argument DISPLAY specifies which display to ask about.
2944 DISPLAY should be either a frame or a display name (a string).
2945 If omitted or nil, that stands for the selected frame's display. */)
2946 (display)
2947 Lisp_Object display;
2948 {
2949 struct mac_display_info *dpyinfo = check_x_display_info (display);
2950
2951 /* MAC_TODO: check whether this is right */
2952 return make_number (dpyinfo->n_planes >= 8 ? 256 : 1 << dpyinfo->n_planes - 1);
2953 }
2954
2955 DEFUN ("x-server-max-request-size", Fx_server_max_request_size,
2956 Sx_server_max_request_size,
2957 0, 1, 0,
2958 doc: /* Returns the maximum request size of the server of display DISPLAY.
2959 The optional argument DISPLAY specifies which display to ask about.
2960 DISPLAY should be either a frame or a display name (a string).
2961 If omitted or nil, that stands for the selected frame's display. */)
2962 (display)
2963 Lisp_Object display;
2964 {
2965 struct mac_display_info *dpyinfo = check_x_display_info (display);
2966
2967 return make_number (1);
2968 }
2969
2970 DEFUN ("x-server-vendor", Fx_server_vendor, Sx_server_vendor, 0, 1, 0,
2971 doc: /* Returns the vendor ID string of the Mac OS system (Apple).
2972 The optional argument DISPLAY specifies which display to ask about.
2973 DISPLAY should be either a frame or a display name (a string).
2974 If omitted or nil, that stands for the selected frame's display. */)
2975 (display)
2976 Lisp_Object display;
2977 {
2978 return build_string ("Apple Computers");
2979 }
2980
2981 DEFUN ("x-server-version", Fx_server_version, Sx_server_version, 0, 1, 0,
2982 doc: /* Returns the version numbers of the server of display DISPLAY.
2983 The value is a list of three integers: the major and minor
2984 version numbers, and the vendor-specific release
2985 number. See also the function `x-server-vendor'.
2986
2987 The optional argument DISPLAY specifies which display to ask about.
2988 DISPLAY should be either a frame or a display name (a string).
2989 If omitted or nil, that stands for the selected frame's display. */)
2990 (display)
2991 Lisp_Object display;
2992 {
2993 int mac_major_version, mac_minor_version;
2994 SInt32 response;
2995
2996 if (Gestalt (gestaltSystemVersion, &response) != noErr)
2997 error ("Cannot get Mac OS version");
2998
2999 mac_major_version = (response >> 8) & 0xf;
3000 mac_minor_version = (response >> 4) & 0xf;
3001
3002 return Fcons (make_number (mac_major_version),
3003 Fcons (make_number (mac_minor_version), Qnil));
3004 }
3005
3006 DEFUN ("x-display-screens", Fx_display_screens, Sx_display_screens, 0, 1, 0,
3007 doc: /* Return the number of screens on the server of display DISPLAY.
3008 The optional argument DISPLAY specifies which display to ask about.
3009 DISPLAY should be either a frame or a display name (a string).
3010 If omitted or nil, that stands for the selected frame's display. */)
3011 (display)
3012 Lisp_Object display;
3013 {
3014 return make_number (1);
3015 }
3016
3017 DEFUN ("x-display-mm-height", Fx_display_mm_height, Sx_display_mm_height, 0, 1, 0,
3018 doc: /* Return the height in millimeters of the X display DISPLAY.
3019 The optional argument DISPLAY specifies which display to ask about.
3020 DISPLAY should be either a frame or a display name (a string).
3021 If omitted or nil, that stands for the selected frame's display. */)
3022 (display)
3023 Lisp_Object display;
3024 {
3025 /* MAC_TODO: this is an approximation, and only of the main display */
3026
3027 struct mac_display_info *dpyinfo = check_x_display_info (display);
3028 short h, v;
3029
3030 ScreenRes (&h, &v);
3031
3032 return make_number ((int) (v / 72.0 * 25.4));
3033 }
3034
3035 DEFUN ("x-display-mm-width", Fx_display_mm_width, Sx_display_mm_width, 0, 1, 0,
3036 doc: /* Return the width in millimeters of the X display DISPLAY.
3037 The optional argument DISPLAY specifies which display to ask about.
3038 DISPLAY should be either a frame or a display name (a string).
3039 If omitted or nil, that stands for the selected frame's display. */)
3040 (display)
3041 Lisp_Object display;
3042 {
3043 /* MAC_TODO: this is an approximation, and only of the main display */
3044
3045 struct mac_display_info *dpyinfo = check_x_display_info (display);
3046 short h, v;
3047
3048 ScreenRes (&h, &v);
3049
3050 return make_number ((int) (h / 72.0 * 25.4));
3051 }
3052
3053 DEFUN ("x-display-backing-store", Fx_display_backing_store,
3054 Sx_display_backing_store, 0, 1, 0,
3055 doc: /* Returns an indication of whether display DISPLAY does backing store.
3056 The value may be `always', `when-mapped', or `not-useful'.
3057 The optional argument DISPLAY specifies which display to ask about.
3058 DISPLAY should be either a frame or a display name (a string).
3059 If omitted or nil, that stands for the selected frame's display. */)
3060 (display)
3061 Lisp_Object display;
3062 {
3063 return intern ("not-useful");
3064 }
3065
3066 DEFUN ("x-display-visual-class", Fx_display_visual_class,
3067 Sx_display_visual_class, 0, 1, 0,
3068 doc: /* Returns the visual class of the display DISPLAY.
3069 The value is one of the symbols `static-gray', `gray-scale',
3070 `static-color', `pseudo-color', `true-color', or `direct-color'.
3071
3072 The optional argument DISPLAY specifies which display to ask about.
3073 DISPLAY should be either a frame or a display name (a string).
3074 If omitted or nil, that stands for the selected frame's display. */)
3075 (display)
3076 Lisp_Object display;
3077 {
3078 struct mac_display_info *dpyinfo = check_x_display_info (display);
3079
3080 #if 0
3081 switch (dpyinfo->visual->class)
3082 {
3083 case StaticGray: return (intern ("static-gray"));
3084 case GrayScale: return (intern ("gray-scale"));
3085 case StaticColor: return (intern ("static-color"));
3086 case PseudoColor: return (intern ("pseudo-color"));
3087 case TrueColor: return (intern ("true-color"));
3088 case DirectColor: return (intern ("direct-color"));
3089 default:
3090 error ("Display has an unknown visual class");
3091 }
3092 #endif /* 0 */
3093
3094 return (intern ("true-color"));
3095 }
3096
3097 DEFUN ("x-display-save-under", Fx_display_save_under,
3098 Sx_display_save_under, 0, 1, 0,
3099 doc: /* Returns t if the display DISPLAY supports the save-under feature.
3100 The optional argument DISPLAY specifies which display to ask about.
3101 DISPLAY should be either a frame or a display name (a string).
3102 If omitted or nil, that stands for the selected frame's display. */)
3103 (display)
3104 Lisp_Object display;
3105 {
3106 return Qnil;
3107 }
3108 \f
3109 int
3110 x_pixel_width (f)
3111 register struct frame *f;
3112 {
3113 return FRAME_PIXEL_WIDTH (f);
3114 }
3115
3116 int
3117 x_pixel_height (f)
3118 register struct frame *f;
3119 {
3120 return FRAME_PIXEL_HEIGHT (f);
3121 }
3122
3123 int
3124 x_char_width (f)
3125 register struct frame *f;
3126 {
3127 return FRAME_COLUMN_WIDTH (f);
3128 }
3129
3130 int
3131 x_char_height (f)
3132 register struct frame *f;
3133 {
3134 return FRAME_LINE_HEIGHT (f);
3135 }
3136
3137 int
3138 x_screen_planes (f)
3139 register struct frame *f;
3140 {
3141 return FRAME_MAC_DISPLAY_INFO (f)->n_planes;
3142 }
3143 \f
3144 /* Return the display structure for the display named NAME.
3145 Open a new connection if necessary. */
3146
3147 struct mac_display_info *
3148 x_display_info_for_name (name)
3149 Lisp_Object name;
3150 {
3151 Lisp_Object names;
3152 struct mac_display_info *dpyinfo;
3153
3154 CHECK_STRING (name);
3155
3156 for (dpyinfo = &one_mac_display_info, names = x_display_name_list;
3157 dpyinfo;
3158 dpyinfo = dpyinfo->next, names = XCDR (names))
3159 {
3160 Lisp_Object tem;
3161 tem = Fstring_equal (XCAR (XCAR (names)), name);
3162 if (!NILP (tem))
3163 return dpyinfo;
3164 }
3165
3166 /* Use this general default value to start with. */
3167 Vx_resource_name = Vinvocation_name;
3168
3169 validate_x_resource_name ();
3170
3171 dpyinfo = mac_term_init (name, (unsigned char *) 0,
3172 (char *) SDATA (Vx_resource_name));
3173
3174 if (dpyinfo == 0)
3175 error ("Cannot connect to server %s", SDATA (name));
3176
3177 mac_in_use = 1;
3178 XSETFASTINT (Vwindow_system_version, 3);
3179
3180 return dpyinfo;
3181 }
3182
3183 #if 0 /* MAC_TODO: implement network support */
3184 DEFUN ("x-open-connection", Fx_open_connection, Sx_open_connection,
3185 1, 3, 0,
3186 doc: /* Open a connection to a server.
3187 DISPLAY is the name of the display to connect to.
3188 Optional second arg XRM-STRING is a string of resources in xrdb format.
3189 If the optional third arg MUST-SUCCEED is non-nil,
3190 terminate Emacs if we can't open the connection. */)
3191 (display, xrm_string, must_succeed)
3192 Lisp_Object display, xrm_string, must_succeed;
3193 {
3194 unsigned char *xrm_option;
3195 struct mac_display_info *dpyinfo;
3196
3197 CHECK_STRING (display);
3198 if (! NILP (xrm_string))
3199 CHECK_STRING (xrm_string);
3200
3201 if (! EQ (Vwindow_system, intern ("mac")))
3202 error ("Not using Mac OS");
3203
3204 if (! NILP (xrm_string))
3205 xrm_option = (unsigned char *) SDATA (xrm_string);
3206 else
3207 xrm_option = (unsigned char *) 0;
3208
3209 validate_x_resource_name ();
3210
3211 /* This is what opens the connection and sets x_current_display.
3212 This also initializes many symbols, such as those used for input. */
3213 dpyinfo = mac_term_init (display, xrm_option,
3214 (char *) SDATA (Vx_resource_name));
3215
3216 if (dpyinfo == 0)
3217 {
3218 if (!NILP (must_succeed))
3219 fatal ("Cannot connect to server %s.\n",
3220 SDATA (display));
3221 else
3222 error ("Cannot connect to server %s", SDATA (display));
3223 }
3224
3225 mac_in_use = 1;
3226
3227 XSETFASTINT (Vwindow_system_version, 3);
3228 return Qnil;
3229 }
3230
3231 DEFUN ("x-close-connection", Fx_close_connection,
3232 Sx_close_connection, 1, 1, 0,
3233 doc: /* Close the connection to DISPLAY's server.
3234 For DISPLAY, specify either a frame or a display name (a string).
3235 If DISPLAY is nil, that stands for the selected frame's display. */)
3236 (display)
3237 Lisp_Object display;
3238 {
3239 struct mac_display_info *dpyinfo = check_x_display_info (display);
3240 int i;
3241
3242 if (dpyinfo->reference_count > 0)
3243 error ("Display still has frames on it");
3244
3245 BLOCK_INPUT;
3246 /* Free the fonts in the font table. */
3247 for (i = 0; i < dpyinfo->n_fonts; i++)
3248 if (dpyinfo->font_table[i].name)
3249 {
3250 if (dpyinfo->font_table[i].name != dpyinfo->font_table[i].full_name)
3251 xfree (dpyinfo->font_table[i].full_name);
3252 xfree (dpyinfo->font_table[i].name);
3253 x_unload_font (dpyinfo, dpyinfo->font_table[i].font);
3254 }
3255 x_destroy_all_bitmaps (dpyinfo);
3256
3257 x_delete_display (dpyinfo);
3258 UNBLOCK_INPUT;
3259
3260 return Qnil;
3261 }
3262 #endif /* 0 */
3263
3264 DEFUN ("x-display-list", Fx_display_list, Sx_display_list, 0, 0, 0,
3265 doc: /* Return the list of display names that Emacs has connections to. */)
3266 ()
3267 {
3268 Lisp_Object tail, result;
3269
3270 result = Qnil;
3271 for (tail = x_display_name_list; ! NILP (tail); tail = XCDR (tail))
3272 result = Fcons (XCAR (XCAR (tail)), result);
3273
3274 return result;
3275 }
3276
3277 DEFUN ("x-synchronize", Fx_synchronize, Sx_synchronize, 1, 2, 0,
3278 doc: /* If ON is non-nil, report errors as soon as the erring request is made.
3279 If ON is nil, allow buffering of requests.
3280 This is a noop on Mac OS systems.
3281 The optional second argument DISPLAY specifies which display to act on.
3282 DISPLAY should be either a frame or a display name (a string).
3283 If DISPLAY is omitted or nil, that stands for the selected frame's display. */)
3284 (on, display)
3285 Lisp_Object display, on;
3286 {
3287 return Qnil;
3288 }
3289
3290 \f
3291 /***********************************************************************
3292 Window properties
3293 ***********************************************************************/
3294
3295 DEFUN ("x-change-window-property", Fx_change_window_property,
3296 Sx_change_window_property, 2, 6, 0,
3297 doc: /* Change window property PROP to VALUE on the X window of FRAME.
3298 VALUE may be a string or a list of conses, numbers and/or strings.
3299 If an element in the list is a string, it is converted to
3300 an Atom and the value of the Atom is used. If an element is a cons,
3301 it is converted to a 32 bit number where the car is the 16 top bits and the
3302 cdr is the lower 16 bits.
3303 FRAME nil or omitted means use the selected frame.
3304 If TYPE is given and non-nil, it is the name of the type of VALUE.
3305 If TYPE is not given or nil, the type is STRING.
3306 FORMAT gives the size in bits of each element if VALUE is a list.
3307 It must be one of 8, 16 or 32.
3308 If VALUE is a string or FORMAT is nil or not given, FORMAT defaults to 8.
3309 If OUTER_P is non-nil, the property is changed for the outer X window of
3310 FRAME. Default is to change on the edit X window.
3311
3312 Value is VALUE. */)
3313 (prop, value, frame, type, format, outer_p)
3314 Lisp_Object prop, value, frame, type, format, outer_p;
3315 {
3316 #if 0 /* MAC_TODO : port window properties to Mac */
3317 struct frame *f = check_x_frame (frame);
3318 Atom prop_atom;
3319
3320 CHECK_STRING (prop);
3321 CHECK_STRING (value);
3322
3323 BLOCK_INPUT;
3324 prop_atom = XInternAtom (FRAME_W32_DISPLAY (f), SDATA (prop), False);
3325 XChangeProperty (FRAME_W32_DISPLAY (f), FRAME_W32_WINDOW (f),
3326 prop_atom, XA_STRING, 8, PropModeReplace,
3327 SDATA (value), SCHARS (value));
3328
3329 /* Make sure the property is set when we return. */
3330 XFlush (FRAME_W32_DISPLAY (f));
3331 UNBLOCK_INPUT;
3332
3333 #endif /* MAC_TODO */
3334
3335 return value;
3336 }
3337
3338
3339 DEFUN ("x-delete-window-property", Fx_delete_window_property,
3340 Sx_delete_window_property, 1, 2, 0,
3341 doc: /* Remove window property PROP from X window of FRAME.
3342 FRAME nil or omitted means use the selected frame. Value is PROP. */)
3343 (prop, frame)
3344 Lisp_Object prop, frame;
3345 {
3346 #if 0 /* MAC_TODO : port window properties to Mac */
3347
3348 struct frame *f = check_x_frame (frame);
3349 Atom prop_atom;
3350
3351 CHECK_STRING (prop);
3352 BLOCK_INPUT;
3353 prop_atom = XInternAtom (FRAME_W32_DISPLAY (f), SDATA (prop), False);
3354 XDeleteProperty (FRAME_W32_DISPLAY (f), FRAME_W32_WINDOW (f), prop_atom);
3355
3356 /* Make sure the property is removed when we return. */
3357 XFlush (FRAME_W32_DISPLAY (f));
3358 UNBLOCK_INPUT;
3359 #endif /* MAC_TODO */
3360
3361 return prop;
3362 }
3363
3364
3365 DEFUN ("x-window-property", Fx_window_property, Sx_window_property,
3366 1, 2, 0,
3367 doc: /* Value is the value of window property PROP on FRAME.
3368 If FRAME is nil or omitted, use the selected frame. Value is nil
3369 if FRAME hasn't a property with name PROP or if PROP has no string
3370 value. */)
3371 (prop, frame)
3372 Lisp_Object prop, frame;
3373 {
3374 #if 0 /* MAC_TODO : port window properties to Mac */
3375
3376 struct frame *f = check_x_frame (frame);
3377 Atom prop_atom;
3378 int rc;
3379 Lisp_Object prop_value = Qnil;
3380 char *tmp_data = NULL;
3381 Atom actual_type;
3382 int actual_format;
3383 unsigned long actual_size, bytes_remaining;
3384
3385 CHECK_STRING (prop);
3386 BLOCK_INPUT;
3387 prop_atom = XInternAtom (FRAME_W32_DISPLAY (f), SDATA (prop), False);
3388 rc = XGetWindowProperty (FRAME_W32_DISPLAY (f), FRAME_W32_WINDOW (f),
3389 prop_atom, 0, 0, False, XA_STRING,
3390 &actual_type, &actual_format, &actual_size,
3391 &bytes_remaining, (unsigned char **) &tmp_data);
3392 if (rc == Success)
3393 {
3394 int size = bytes_remaining;
3395
3396 XFree (tmp_data);
3397 tmp_data = NULL;
3398
3399 rc = XGetWindowProperty (FRAME_W32_DISPLAY (f), FRAME_W32_WINDOW (f),
3400 prop_atom, 0, bytes_remaining,
3401 False, XA_STRING,
3402 &actual_type, &actual_format,
3403 &actual_size, &bytes_remaining,
3404 (unsigned char **) &tmp_data);
3405 if (rc == Success)
3406 prop_value = make_string (tmp_data, size);
3407
3408 XFree (tmp_data);
3409 }
3410
3411 UNBLOCK_INPUT;
3412
3413 return prop_value;
3414
3415 #endif /* MAC_TODO */
3416 return Qnil;
3417 }
3418
3419
3420 \f
3421 /***********************************************************************
3422 Hourglass cursor
3423 ***********************************************************************/
3424
3425 /* If non-null, an asynchronous timer that, when it expires, displays
3426 an hourglass cursor on all frames. */
3427
3428 static struct atimer *hourglass_atimer;
3429
3430 /* Non-zero means an hourglass cursor is currently shown. */
3431
3432 static int hourglass_shown_p;
3433
3434 /* Number of seconds to wait before displaying an hourglass cursor. */
3435
3436 static Lisp_Object Vhourglass_delay;
3437
3438 /* Default number of seconds to wait before displaying an hourglass
3439 cursor. */
3440
3441 #define DEFAULT_HOURGLASS_DELAY 1
3442
3443 /* Function prototypes. */
3444
3445 static void show_hourglass P_ ((struct atimer *));
3446 static void hide_hourglass P_ ((void));
3447
3448
3449 /* Cancel a currently active hourglass timer, and start a new one. */
3450
3451 void
3452 start_hourglass ()
3453 {
3454 #if 0 /* MAC_TODO: cursor shape changes. */
3455 EMACS_TIME delay;
3456 int secs, usecs = 0;
3457
3458 cancel_hourglass ();
3459
3460 if (INTEGERP (Vhourglass_delay)
3461 && XINT (Vhourglass_delay) > 0)
3462 secs = XFASTINT (Vhourglass_delay);
3463 else if (FLOATP (Vhourglass_delay)
3464 && XFLOAT_DATA (Vhourglass_delay) > 0)
3465 {
3466 Lisp_Object tem;
3467 tem = Ftruncate (Vhourglass_delay, Qnil);
3468 secs = XFASTINT (tem);
3469 usecs = (XFLOAT_DATA (Vhourglass_delay) - secs) * 1000000;
3470 }
3471 else
3472 secs = DEFAULT_HOURGLASS_DELAY;
3473
3474 EMACS_SET_SECS_USECS (delay, secs, usecs);
3475 hourglass_atimer = start_atimer (ATIMER_RELATIVE, delay,
3476 show_hourglass, NULL);
3477 #endif /* MAC_TODO */
3478 }
3479
3480
3481 /* Cancel the hourglass cursor timer if active, hide an hourglass
3482 cursor if shown. */
3483
3484 void
3485 cancel_hourglass ()
3486 {
3487 if (hourglass_atimer)
3488 {
3489 cancel_atimer (hourglass_atimer);
3490 hourglass_atimer = NULL;
3491 }
3492
3493 if (hourglass_shown_p)
3494 hide_hourglass ();
3495 }
3496
3497
3498 /* Timer function of hourglass_atimer. TIMER is equal to
3499 hourglass_atimer.
3500
3501 Display an hourglass cursor on all frames by mapping the frames'
3502 hourglass_window. Set the hourglass_p flag in the frames'
3503 output_data.x structure to indicate that an hourglass cursor is
3504 shown on the frames. */
3505
3506 static void
3507 show_hourglass (timer)
3508 struct atimer *timer;
3509 {
3510 #if 0 /* MAC_TODO: cursor shape changes. */
3511 /* The timer implementation will cancel this timer automatically
3512 after this function has run. Set hourglass_atimer to null
3513 so that we know the timer doesn't have to be canceled. */
3514 hourglass_atimer = NULL;
3515
3516 if (!hourglass_shown_p)
3517 {
3518 Lisp_Object rest, frame;
3519
3520 BLOCK_INPUT;
3521
3522 FOR_EACH_FRAME (rest, frame)
3523 if (FRAME_W32_P (XFRAME (frame)))
3524 {
3525 struct frame *f = XFRAME (frame);
3526
3527 f->output_data.w32->hourglass_p = 1;
3528
3529 if (!f->output_data.w32->hourglass_window)
3530 {
3531 unsigned long mask = CWCursor;
3532 XSetWindowAttributes attrs;
3533
3534 attrs.cursor = f->output_data.w32->hourglass_cursor;
3535
3536 f->output_data.w32->hourglass_window
3537 = XCreateWindow (FRAME_X_DISPLAY (f),
3538 FRAME_OUTER_WINDOW (f),
3539 0, 0, 32000, 32000, 0, 0,
3540 InputOnly,
3541 CopyFromParent,
3542 mask, &attrs);
3543 }
3544
3545 XMapRaised (FRAME_X_DISPLAY (f),
3546 f->output_data.w32->hourglass_window);
3547 XFlush (FRAME_X_DISPLAY (f));
3548 }
3549
3550 hourglass_shown_p = 1;
3551 UNBLOCK_INPUT;
3552 }
3553 #endif /* MAC_TODO */
3554 }
3555
3556
3557 /* Hide the hourglass cursor on all frames, if it is currently shown. */
3558
3559 static void
3560 hide_hourglass ()
3561 {
3562 #if 0 /* MAC_TODO: cursor shape changes. */
3563 if (hourglass_shown_p)
3564 {
3565 Lisp_Object rest, frame;
3566
3567 BLOCK_INPUT;
3568 FOR_EACH_FRAME (rest, frame)
3569 {
3570 struct frame *f = XFRAME (frame);
3571
3572 if (FRAME_W32_P (f)
3573 /* Watch out for newly created frames. */
3574 && f->output_data.x->hourglass_window)
3575 {
3576 XUnmapWindow (FRAME_X_DISPLAY (f),
3577 f->output_data.x->hourglass_window);
3578 /* Sync here because XTread_socket looks at the
3579 hourglass_p flag that is reset to zero below. */
3580 XSync (FRAME_X_DISPLAY (f), False);
3581 f->output_data.x->hourglass_p = 0;
3582 }
3583 }
3584
3585 hourglass_shown_p = 0;
3586 UNBLOCK_INPUT;
3587 }
3588 #endif /* MAC_TODO */
3589 }
3590
3591
3592 \f
3593 /***********************************************************************
3594 Tool tips
3595 ***********************************************************************/
3596
3597 static Lisp_Object x_create_tip_frame P_ ((struct mac_display_info *,
3598 Lisp_Object));
3599
3600 /* The frame of a currently visible tooltip, or null. */
3601
3602 Lisp_Object tip_frame;
3603
3604 /* If non-nil, a timer started that hides the last tooltip when it
3605 fires. */
3606
3607 Lisp_Object tip_timer;
3608 Window tip_window;
3609
3610 /* If non-nil, a vector of 3 elements containing the last args
3611 with which x-show-tip was called. See there. */
3612
3613 Lisp_Object last_show_tip_args;
3614
3615 /* Create a frame for a tooltip on the display described by DPYINFO.
3616 PARMS is a list of frame parameters. Value is the frame. */
3617
3618 static Lisp_Object
3619 x_create_tip_frame (dpyinfo, parms)
3620 struct mac_display_info *dpyinfo;
3621 Lisp_Object parms;
3622 {
3623 #if 0 /* MAC_TODO : Mac version */
3624 struct frame *f;
3625 Lisp_Object frame, tem;
3626 Lisp_Object name;
3627 long window_prompting = 0;
3628 int width, height;
3629 int count = SPECPDL_INDEX ();
3630 struct gcpro gcpro1, gcpro2, gcpro3;
3631 struct kboard *kb;
3632
3633 check_x ();
3634
3635 /* Use this general default value to start with until we know if
3636 this frame has a specified name. */
3637 Vx_resource_name = Vinvocation_name;
3638
3639 #ifdef MULTI_KBOARD
3640 kb = dpyinfo->kboard;
3641 #else
3642 kb = &the_only_kboard;
3643 #endif
3644
3645 /* Get the name of the frame to use for resource lookup. */
3646 name = w32_get_arg (parms, Qname, "name", "Name", RES_TYPE_STRING);
3647 if (!STRINGP (name)
3648 && !EQ (name, Qunbound)
3649 && !NILP (name))
3650 error ("Invalid frame name--not a string or nil");
3651 Vx_resource_name = name;
3652
3653 frame = Qnil;
3654 GCPRO3 (parms, name, frame);
3655 tip_frame = f = make_frame (1);
3656 XSETFRAME (frame, f);
3657 FRAME_CAN_HAVE_SCROLL_BARS (f) = 0;
3658
3659 f->output_method = output_w32;
3660 f->output_data.w32 =
3661 (struct w32_output *) xmalloc (sizeof (struct w32_output));
3662 bzero (f->output_data.w32, sizeof (struct w32_output));
3663 #if 0
3664 f->output_data.w32->icon_bitmap = -1;
3665 #endif
3666 FRAME_FONTSET (f) = -1;
3667 f->icon_name = Qnil;
3668
3669 #ifdef MULTI_KBOARD
3670 FRAME_KBOARD (f) = kb;
3671 #endif
3672 f->output_data.w32->parent_desc = FRAME_W32_DISPLAY_INFO (f)->root_window;
3673 f->output_data.w32->explicit_parent = 0;
3674
3675 /* Set the name; the functions to which we pass f expect the name to
3676 be set. */
3677 if (EQ (name, Qunbound) || NILP (name))
3678 {
3679 f->name = build_string (dpyinfo->x_id_name);
3680 f->explicit_name = 0;
3681 }
3682 else
3683 {
3684 f->name = name;
3685 f->explicit_name = 1;
3686 /* use the frame's title when getting resources for this frame. */
3687 specbind (Qx_resource_name, name);
3688 }
3689
3690 /* Extract the window parameters from the supplied values
3691 that are needed to determine window geometry. */
3692 {
3693 Lisp_Object font;
3694
3695 font = w32_get_arg (parms, Qfont, "font", "Font", RES_TYPE_STRING);
3696
3697 BLOCK_INPUT;
3698 /* First, try whatever font the caller has specified. */
3699 if (STRINGP (font))
3700 {
3701 tem = Fquery_fontset (font, Qnil);
3702 if (STRINGP (tem))
3703 font = x_new_fontset (f, SDATA (tem));
3704 else
3705 font = x_new_font (f, SDATA (font));
3706 }
3707
3708 /* Try out a font which we hope has bold and italic variations. */
3709 if (!STRINGP (font))
3710 font = x_new_font (f, "-adobe-courier-medium-r-*-*-*-120-*-*-*-*-iso8859-1");
3711 if (!STRINGP (font))
3712 font = x_new_font (f, "-misc-fixed-medium-r-normal-*-*-140-*-*-c-*-iso8859-1");
3713 if (! STRINGP (font))
3714 font = x_new_font (f, "-*-*-medium-r-normal-*-*-140-*-*-c-*-iso8859-1");
3715 if (! STRINGP (font))
3716 /* This was formerly the first thing tried, but it finds too many fonts
3717 and takes too long. */
3718 font = x_new_font (f, "-*-*-medium-r-*-*-*-*-*-*-c-*-iso8859-1");
3719 /* If those didn't work, look for something which will at least work. */
3720 if (! STRINGP (font))
3721 font = x_new_font (f, "-*-fixed-*-*-*-*-*-140-*-*-c-*-iso8859-1");
3722 UNBLOCK_INPUT;
3723 if (! STRINGP (font))
3724 font = build_string ("fixed");
3725
3726 x_default_parameter (f, parms, Qfont, font,
3727 "font", "Font", RES_TYPE_STRING);
3728 }
3729
3730 x_default_parameter (f, parms, Qborder_width, make_number (2),
3731 "borderWidth", "BorderWidth", RES_TYPE_NUMBER);
3732
3733 /* This defaults to 2 in order to match xterm. We recognize either
3734 internalBorderWidth or internalBorder (which is what xterm calls
3735 it). */
3736 if (NILP (Fassq (Qinternal_border_width, parms)))
3737 {
3738 Lisp_Object value;
3739
3740 value = w32_get_arg (parms, Qinternal_border_width,
3741 "internalBorder", "internalBorder", RES_TYPE_NUMBER);
3742 if (! EQ (value, Qunbound))
3743 parms = Fcons (Fcons (Qinternal_border_width, value),
3744 parms);
3745 }
3746
3747 x_default_parameter (f, parms, Qinternal_border_width, make_number (1),
3748 "internalBorderWidth", "internalBorderWidth",
3749 RES_TYPE_NUMBER);
3750
3751 /* Also do the stuff which must be set before the window exists. */
3752 x_default_parameter (f, parms, Qforeground_color, build_string ("black"),
3753 "foreground", "Foreground", RES_TYPE_STRING);
3754 x_default_parameter (f, parms, Qbackground_color, build_string ("white"),
3755 "background", "Background", RES_TYPE_STRING);
3756 x_default_parameter (f, parms, Qmouse_color, build_string ("black"),
3757 "pointerColor", "Foreground", RES_TYPE_STRING);
3758 x_default_parameter (f, parms, Qcursor_color, build_string ("black"),
3759 "cursorColor", "Foreground", RES_TYPE_STRING);
3760 x_default_parameter (f, parms, Qborder_color, build_string ("black"),
3761 "borderColor", "BorderColor", RES_TYPE_STRING);
3762
3763 /* Init faces before x_default_parameter is called for scroll-bar
3764 parameters because that function calls x_set_scroll_bar_width,
3765 which calls change_frame_size, which calls Fset_window_buffer,
3766 which runs hooks, which call Fvertical_motion. At the end, we
3767 end up in init_iterator with a null face cache, which should not
3768 happen. */
3769 init_frame_faces (f);
3770
3771 f->output_data.w32->parent_desc = FRAME_W32_DISPLAY_INFO (f)->root_window;
3772
3773 window_prompting = x_figure_window_size (f, parms, 0);
3774
3775 {
3776 XSetWindowAttributes attrs;
3777 unsigned long mask;
3778
3779 BLOCK_INPUT;
3780 mask = CWBackPixel | CWOverrideRedirect | CWSaveUnder | CWEventMask;
3781 /* Window managers looks at the override-redirect flag to
3782 determine whether or net to give windows a decoration (Xlib
3783 3.2.8). */
3784 attrs.override_redirect = True;
3785 attrs.save_under = True;
3786 attrs.background_pixel = FRAME_BACKGROUND_PIXEL (f);
3787 /* Arrange for getting MapNotify and UnmapNotify events. */
3788 attrs.event_mask = StructureNotifyMask;
3789 tip_window
3790 = FRAME_W32_WINDOW (f)
3791 = XCreateWindow (FRAME_W32_DISPLAY (f),
3792 FRAME_W32_DISPLAY_INFO (f)->root_window,
3793 /* x, y, width, height */
3794 0, 0, 1, 1,
3795 /* Border. */
3796 1,
3797 CopyFromParent, InputOutput, CopyFromParent,
3798 mask, &attrs);
3799 UNBLOCK_INPUT;
3800 }
3801
3802 x_make_gc (f);
3803
3804 x_default_parameter (f, parms, Qauto_raise, Qnil,
3805 "autoRaise", "AutoRaiseLower", RES_TYPE_BOOLEAN);
3806 x_default_parameter (f, parms, Qauto_lower, Qnil,
3807 "autoLower", "AutoRaiseLower", RES_TYPE_BOOLEAN);
3808 x_default_parameter (f, parms, Qcursor_type, Qbox,
3809 "cursorType", "CursorType", RES_TYPE_SYMBOL);
3810
3811 /* Dimensions, especially FRAME_LINES (f), must be done via change_frame_size.
3812 Change will not be effected unless different from the current
3813 FRAME_LINES (f). */
3814 width = FRAME_COLS (f);
3815 height = FRAME_LINES (f);
3816 FRAME_LINES (f) = 0;
3817 SET_FRAME_COLS (f, 0);
3818 change_frame_size (f, height, width, 1, 0, 0);
3819
3820 /* Add `tooltip' frame parameter's default value. */
3821 if (NILP (Fframe_parameter (frame, intern ("tooltip"))))
3822 Fmodify_frame_parameters (frame, Fcons (Fcons (intern ("tooltip"), Qt),
3823 Qnil));
3824
3825 f->no_split = 1;
3826
3827 UNGCPRO;
3828
3829 /* It is now ok to make the frame official even if we get an error
3830 below. And the frame needs to be on Vframe_list or making it
3831 visible won't work. */
3832 Vframe_list = Fcons (frame, Vframe_list);
3833
3834 /* Now that the frame is official, it counts as a reference to
3835 its display. */
3836 FRAME_W32_DISPLAY_INFO (f)->reference_count++;
3837
3838 return unbind_to (count, frame);
3839 #endif /* MAC_TODO */
3840 return Qnil;
3841 }
3842
3843
3844 DEFUN ("x-show-tip", Fx_show_tip, Sx_show_tip, 1, 6, 0,
3845 doc : /* Show STRING in a "tooltip" window on frame FRAME.
3846 A tooltip window is a small window displaying a string.
3847
3848 FRAME nil or omitted means use the selected frame.
3849
3850 PARMS is an optional list of frame parameters which can be used to
3851 change the tooltip's appearance.
3852
3853 Automatically hide the tooltip after TIMEOUT seconds. TIMEOUT nil
3854 means use the default timeout of 5 seconds.
3855
3856 If the list of frame parameters PARAMS contains a `left' parameters,
3857 the tooltip is displayed at that x-position. Otherwise it is
3858 displayed at the mouse position, with offset DX added (default is 5 if
3859 DX isn't specified). Likewise for the y-position; if a `top' frame
3860 parameter is specified, it determines the y-position of the tooltip
3861 window, otherwise it is displayed at the mouse position, with offset
3862 DY added (default is 10). */)
3863 (string, frame, parms, timeout, dx, dy)
3864 Lisp_Object string, frame, parms, timeout, dx, dy;
3865 {
3866 struct frame *f;
3867 struct window *w;
3868 Window root, child;
3869 Lisp_Object buffer, top, left;
3870 struct buffer *old_buffer;
3871 struct text_pos pos;
3872 int i, width, height;
3873 int root_x, root_y, win_x, win_y;
3874 unsigned pmask;
3875 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
3876 int old_windows_or_buffers_changed = windows_or_buffers_changed;
3877 int count = SPECPDL_INDEX ();
3878
3879 specbind (Qinhibit_redisplay, Qt);
3880
3881 GCPRO4 (string, parms, frame, timeout);
3882
3883 CHECK_STRING (string);
3884 f = check_x_frame (frame);
3885 if (NILP (timeout))
3886 timeout = make_number (5);
3887 else
3888 CHECK_NATNUM (timeout);
3889
3890 if (NILP (dx))
3891 dx = make_number (5);
3892 else
3893 CHECK_NUMBER (dx);
3894
3895 if (NILP (dy))
3896 dy = make_number (-10);
3897 else
3898 CHECK_NUMBER (dy);
3899
3900 if (NILP (last_show_tip_args))
3901 last_show_tip_args = Fmake_vector (make_number (3), Qnil);
3902
3903 if (!NILP (tip_frame))
3904 {
3905 Lisp_Object last_string = AREF (last_show_tip_args, 0);
3906 Lisp_Object last_frame = AREF (last_show_tip_args, 1);
3907 Lisp_Object last_parms = AREF (last_show_tip_args, 2);
3908
3909 if (EQ (frame, last_frame)
3910 && !NILP (Fequal (last_string, string))
3911 && !NILP (Fequal (last_parms, parms)))
3912 {
3913 struct frame *f = XFRAME (tip_frame);
3914
3915 /* Only DX and DY have changed. */
3916 if (!NILP (tip_timer))
3917 {
3918 Lisp_Object timer = tip_timer;
3919 tip_timer = Qnil;
3920 call1 (Qcancel_timer, timer);
3921 }
3922
3923 #if 0 /* MAC_TODO : Mac specifics */
3924 BLOCK_INPUT;
3925 compute_tip_xy (f, parms, dx, dy, &root_x, &root_y);
3926 XMoveWindow (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
3927 root_x, root_y - FRAME_PIXEL_HEIGHT (f));
3928 UNBLOCK_INPUT;
3929 #endif /* MAC_TODO */
3930 goto start_timer;
3931 }
3932 }
3933
3934 /* Hide a previous tip, if any. */
3935 Fx_hide_tip ();
3936
3937 ASET (last_show_tip_args, 0, string);
3938 ASET (last_show_tip_args, 1, frame);
3939 ASET (last_show_tip_args, 2, parms);
3940
3941 /* Add default values to frame parameters. */
3942 if (NILP (Fassq (Qname, parms)))
3943 parms = Fcons (Fcons (Qname, build_string ("tooltip")), parms);
3944 if (NILP (Fassq (Qinternal_border_width, parms)))
3945 parms = Fcons (Fcons (Qinternal_border_width, make_number (3)), parms);
3946 if (NILP (Fassq (Qborder_width, parms)))
3947 parms = Fcons (Fcons (Qborder_width, make_number (1)), parms);
3948 if (NILP (Fassq (Qborder_color, parms)))
3949 parms = Fcons (Fcons (Qborder_color, build_string ("lightyellow")), parms);
3950 if (NILP (Fassq (Qbackground_color, parms)))
3951 parms = Fcons (Fcons (Qbackground_color, build_string ("lightyellow")),
3952 parms);
3953
3954 /* Create a frame for the tooltip, and record it in the global
3955 variable tip_frame. */
3956 frame = x_create_tip_frame (FRAME_MAC_DISPLAY_INFO (f), parms);
3957 f = XFRAME (frame);
3958
3959 /* Set up the frame's root window. Currently we use a size of 80
3960 columns x 40 lines. If someone wants to show a larger tip, he
3961 will loose. I don't think this is a realistic case. */
3962 w = XWINDOW (FRAME_ROOT_WINDOW (f));
3963 w->left_col = w->top_line = make_number (0);
3964 w->total_cols = make_number (80);
3965 w->total_lines = make_number (40);
3966 adjust_glyphs (f);
3967 w->pseudo_window_p = 1;
3968
3969 /* Display the tooltip text in a temporary buffer. */
3970 buffer = Fget_buffer_create (build_string (" *tip*"));
3971 Fset_window_buffer (FRAME_ROOT_WINDOW (f), buffer, Qnil);
3972 old_buffer = current_buffer;
3973 set_buffer_internal_1 (XBUFFER (buffer));
3974 Ferase_buffer ();
3975 Finsert (1, &string);
3976 clear_glyph_matrix (w->desired_matrix);
3977 clear_glyph_matrix (w->current_matrix);
3978 SET_TEXT_POS (pos, BEGV, BEGV_BYTE);
3979 try_window (FRAME_ROOT_WINDOW (f), pos);
3980
3981 /* Compute width and height of the tooltip. */
3982 width = height = 0;
3983 for (i = 0; i < w->desired_matrix->nrows; ++i)
3984 {
3985 struct glyph_row *row = &w->desired_matrix->rows[i];
3986 struct glyph *last;
3987 int row_width;
3988
3989 /* Stop at the first empty row at the end. */
3990 if (!row->enabled_p || !row->displays_text_p)
3991 break;
3992
3993 /* Let the row go over the full width of the frame. */
3994 row->full_width_p = 1;
3995
3996 /* There's a glyph at the end of rows that is use to place
3997 the cursor there. Don't include the width of this glyph. */
3998 if (row->used[TEXT_AREA])
3999 {
4000 last = &row->glyphs[TEXT_AREA][row->used[TEXT_AREA] - 1];
4001 row_width = row->pixel_width - last->pixel_width;
4002 }
4003 else
4004 row_width = row->pixel_width;
4005
4006 height += row->height;
4007 width = max (width, row_width);
4008 }
4009
4010 /* Add the frame's internal border to the width and height the X
4011 window should have. */
4012 height += 2 * FRAME_INTERNAL_BORDER_WIDTH (f);
4013 width += 2 * FRAME_INTERNAL_BORDER_WIDTH (f);
4014
4015 /* Move the tooltip window where the mouse pointer is. Resize and
4016 show it. */
4017 #if 0 /* TODO : Mac specifics */
4018 compute_tip_xy (f, parms, dx, dy, &root_x, &root_y);
4019
4020 BLOCK_INPUT;
4021 XQueryPointer (FRAME_W32_DISPLAY (f), FRAME_W32_DISPLAY_INFO (f)->root_window,
4022 &root, &child, &root_x, &root_y, &win_x, &win_y, &pmask);
4023 XMoveResizeWindow (FRAME_W32_DISPLAY (f), FRAME_W32_WINDOW (f),
4024 root_x + 5, root_y - height - 5, width, height);
4025 XMapRaised (FRAME_W32_DISPLAY (f), FRAME_W32_WINDOW (f));
4026 UNBLOCK_INPUT;
4027 #endif /* MAC_TODO */
4028
4029 /* Draw into the window. */
4030 w->must_be_updated_p = 1;
4031 update_single_window (w, 1);
4032
4033 /* Restore original current buffer. */
4034 set_buffer_internal_1 (old_buffer);
4035 windows_or_buffers_changed = old_windows_or_buffers_changed;
4036
4037 start_timer:
4038 /* Let the tip disappear after timeout seconds. */
4039 tip_timer = call3 (intern ("run-at-time"), timeout, Qnil,
4040 intern ("x-hide-tip"));
4041
4042 UNGCPRO;
4043 return unbind_to (count, Qnil);
4044 }
4045
4046
4047 DEFUN ("x-hide-tip", Fx_hide_tip, Sx_hide_tip, 0, 0, 0,
4048 doc: /* Hide the current tooltip window, if there is any.
4049 Value is t is tooltip was open, nil otherwise. */)
4050 ()
4051 {
4052 int count;
4053 Lisp_Object deleted, frame, timer;
4054 struct gcpro gcpro1, gcpro2;
4055
4056 /* Return quickly if nothing to do. */
4057 if (NILP (tip_timer) && NILP (tip_frame))
4058 return Qnil;
4059
4060 frame = tip_frame;
4061 timer = tip_timer;
4062 GCPRO2 (frame, timer);
4063 tip_frame = tip_timer = deleted = Qnil;
4064
4065 count = SPECPDL_INDEX ();
4066 specbind (Qinhibit_redisplay, Qt);
4067 specbind (Qinhibit_quit, Qt);
4068
4069 if (!NILP (timer))
4070 call1 (Qcancel_timer, timer);
4071
4072 if (FRAMEP (frame))
4073 {
4074 Fdelete_frame (frame, Qnil);
4075 deleted = Qt;
4076 }
4077
4078 UNGCPRO;
4079 return unbind_to (count, deleted);
4080 }
4081
4082
4083 \f
4084 /***********************************************************************
4085 File selection dialog
4086 ***********************************************************************/
4087
4088 #if 0 /* MAC_TODO: can standard file dialog */
4089 extern Lisp_Object Qfile_name_history;
4090
4091 DEFUN ("x-file-dialog", Fx_file_dialog, Sx_file_dialog, 2, 4, 0,
4092 doc: /* Read file name, prompting with PROMPT in directory DIR.
4093 Use a file selection dialog.
4094 Select DEFAULT-FILENAME in the dialog's file selection box, if
4095 specified. Don't let the user enter a file name in the file
4096 selection dialog's entry field, if MUSTMATCH is non-nil. */)
4097 (prompt, dir, default_filename, mustmatch)
4098 Lisp_Object prompt, dir, default_filename, mustmatch;
4099 {
4100 struct frame *f = SELECTED_FRAME ();
4101 Lisp_Object file = Qnil;
4102 int count = SPECPDL_INDEX ();
4103 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
4104 char filename[MAX_PATH + 1];
4105 char init_dir[MAX_PATH + 1];
4106 int use_dialog_p = 1;
4107
4108 GCPRO5 (prompt, dir, default_filename, mustmatch, file);
4109 CHECK_STRING (prompt);
4110 CHECK_STRING (dir);
4111
4112 /* Create the dialog with PROMPT as title, using DIR as initial
4113 directory and using "*" as pattern. */
4114 dir = Fexpand_file_name (dir, Qnil);
4115 strncpy (init_dir, SDATA (dir), MAX_PATH);
4116 init_dir[MAX_PATH] = '\0';
4117 unixtodos_filename (init_dir);
4118
4119 if (STRINGP (default_filename))
4120 {
4121 char *file_name_only;
4122 char *full_path_name = SDATA (default_filename);
4123
4124 unixtodos_filename (full_path_name);
4125
4126 file_name_only = strrchr (full_path_name, '\\');
4127 if (!file_name_only)
4128 file_name_only = full_path_name;
4129 else
4130 {
4131 file_name_only++;
4132
4133 /* If default_file_name is a directory, don't use the open
4134 file dialog, as it does not support selecting
4135 directories. */
4136 if (!(*file_name_only))
4137 use_dialog_p = 0;
4138 }
4139
4140 strncpy (filename, file_name_only, MAX_PATH);
4141 filename[MAX_PATH] = '\0';
4142 }
4143 else
4144 filename[0] = '\0';
4145
4146 if (use_dialog_p)
4147 {
4148 OPENFILENAME file_details;
4149 char *filename_file;
4150
4151 /* Prevent redisplay. */
4152 specbind (Qinhibit_redisplay, Qt);
4153 BLOCK_INPUT;
4154
4155 bzero (&file_details, sizeof (file_details));
4156 file_details.lStructSize = sizeof (file_details);
4157 file_details.hwndOwner = FRAME_W32_WINDOW (f);
4158 file_details.lpstrFile = filename;
4159 file_details.nMaxFile = sizeof (filename);
4160 file_details.lpstrInitialDir = init_dir;
4161 file_details.lpstrTitle = SDATA (prompt);
4162 file_details.Flags = OFN_HIDEREADONLY | OFN_NOCHANGEDIR;
4163
4164 if (!NILP (mustmatch))
4165 file_details.Flags |= OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST;
4166
4167 if (GetOpenFileName (&file_details))
4168 {
4169 dostounix_filename (filename);
4170 file = build_string (filename);
4171 }
4172 else
4173 file = Qnil;
4174
4175 UNBLOCK_INPUT;
4176 file = unbind_to (count, file);
4177 }
4178 /* Open File dialog will not allow folders to be selected, so resort
4179 to minibuffer completing reads for directories. */
4180 else
4181 file = Fcompleting_read (prompt, intern ("read-file-name-internal"),
4182 dir, mustmatch, dir, Qfile_name_history,
4183 default_filename, Qnil);
4184
4185 UNGCPRO;
4186
4187 /* Make "Cancel" equivalent to C-g. */
4188 if (NILP (file))
4189 Fsignal (Qquit, Qnil);
4190
4191 return unbind_to (count, file);
4192 }
4193 #endif /* MAC_TODO */
4194
4195
4196 \f
4197 /***********************************************************************
4198 Initialization
4199 ***********************************************************************/
4200
4201 /* Keep this list in the same order as frame_parms in frame.c.
4202 Use 0 for unsupported frame parameters. */
4203
4204 frame_parm_handler mac_frame_parm_handlers[] =
4205 {
4206 x_set_autoraise,
4207 x_set_autolower,
4208 x_set_background_color,
4209 x_set_border_color,
4210 x_set_border_width,
4211 x_set_cursor_color,
4212 x_set_cursor_type,
4213 x_set_font,
4214 x_set_foreground_color,
4215 x_set_icon_name,
4216 0, /* MAC_TODO: x_set_icon_type, */
4217 x_set_internal_border_width,
4218 x_set_menu_bar_lines,
4219 x_set_mouse_color,
4220 x_explicitly_set_name,
4221 x_set_scroll_bar_width,
4222 x_set_title,
4223 x_set_unsplittable,
4224 x_set_vertical_scroll_bars,
4225 x_set_visibility,
4226 x_set_tool_bar_lines,
4227 0, /* MAC_TODO: x_set_scroll_bar_foreground, */
4228 0, /* MAC_TODO: x_set_scroll_bar_background, */
4229 x_set_screen_gamma,
4230 x_set_line_spacing,
4231 0, /* MAC_TODO: x_set_fringe_width, */
4232 0, /* MAC_TODO: x_set_fringe_width, */
4233 0, /* x_set_wait_for_wm, */
4234 0, /* MAC_TODO: x_set_fullscreen, */
4235 };
4236
4237 void
4238 syms_of_macfns ()
4239 {
4240 /* Certainly running on Mac. */
4241 mac_in_use = 1;
4242
4243 /* The section below is built by the lisp expression at the top of the file,
4244 just above where these variables are declared. */
4245 /*&&& init symbols here &&&*/
4246 Qnone = intern ("none");
4247 staticpro (&Qnone);
4248 Qsuppress_icon = intern ("suppress-icon");
4249 staticpro (&Qsuppress_icon);
4250 Qundefined_color = intern ("undefined-color");
4251 staticpro (&Qundefined_color);
4252 /* This is the end of symbol initialization. */
4253
4254 Qhyper = intern ("hyper");
4255 staticpro (&Qhyper);
4256 Qsuper = intern ("super");
4257 staticpro (&Qsuper);
4258 Qmeta = intern ("meta");
4259 staticpro (&Qmeta);
4260 Qalt = intern ("alt");
4261 staticpro (&Qalt);
4262 Qctrl = intern ("ctrl");
4263 staticpro (&Qctrl);
4264 Qcontrol = intern ("control");
4265 staticpro (&Qcontrol);
4266 Qshift = intern ("shift");
4267 staticpro (&Qshift);
4268
4269 /* Text property `display' should be nonsticky by default. */
4270 Vtext_property_default_nonsticky
4271 = Fcons (Fcons (Qdisplay, Qt), Vtext_property_default_nonsticky);
4272
4273 Qface_set_after_frame_default = intern ("face-set-after-frame-default");
4274 staticpro (&Qface_set_after_frame_default);
4275
4276 Fput (Qundefined_color, Qerror_conditions,
4277 Fcons (Qundefined_color, Fcons (Qerror, Qnil)));
4278 Fput (Qundefined_color, Qerror_message,
4279 build_string ("Undefined color"));
4280
4281 DEFVAR_LISP ("x-pointer-shape", &Vx_pointer_shape,
4282 doc: /* The shape of the pointer when over text.
4283 Changing the value does not affect existing frames
4284 unless you set the mouse color. */);
4285 Vx_pointer_shape = Qnil;
4286
4287 Vx_nontext_pointer_shape = Qnil;
4288
4289 Vx_mode_pointer_shape = Qnil;
4290
4291 DEFVAR_LISP ("x-hourglass-pointer-shape", &Vx_hourglass_pointer_shape,
4292 doc: /* The shape of the pointer when Emacs is hourglass.
4293 This variable takes effect when you create a new frame
4294 or when you set the mouse color. */);
4295 Vx_hourglass_pointer_shape = Qnil;
4296
4297 DEFVAR_BOOL ("display-hourglass", &display_hourglass_p,
4298 doc: /* Non-zero means Emacs displays an hourglass pointer on window systems. */);
4299 display_hourglass_p = 1;
4300
4301 DEFVAR_LISP ("hourglass-delay", &Vhourglass_delay,
4302 doc: /* *Seconds to wait before displaying an hourglass pointer.
4303 Value must be an integer or float. */);
4304 Vhourglass_delay = make_number (DEFAULT_HOURGLASS_DELAY);
4305
4306 DEFVAR_LISP ("x-sensitive-text-pointer-shape",
4307 &Vx_sensitive_text_pointer_shape,
4308 doc: /* The shape of the pointer when over mouse-sensitive text.
4309 This variable takes effect when you create a new frame
4310 or when you set the mouse color. */);
4311 Vx_sensitive_text_pointer_shape = Qnil;
4312
4313 DEFVAR_LISP ("x-cursor-fore-pixel", &Vx_cursor_fore_pixel,
4314 doc: /* A string indicating the foreground color of the cursor box. */);
4315 Vx_cursor_fore_pixel = Qnil;
4316
4317 DEFVAR_LISP ("x-no-window-manager", &Vx_no_window_manager,
4318 doc: /* Non-nil if no window manager is in use.
4319 Emacs doesn't try to figure this out; this is always nil
4320 unless you set it to something else. */);
4321 /* We don't have any way to find this out, so set it to nil
4322 and maybe the user would like to set it to t. */
4323 Vx_no_window_manager = Qnil;
4324
4325 DEFVAR_LISP ("x-pixel-size-width-font-regexp",
4326 &Vx_pixel_size_width_font_regexp,
4327 doc: /* Regexp matching a font name whose width is the same as `PIXEL_SIZE'.
4328
4329 Since Emacs gets width of a font matching with this regexp from
4330 PIXEL_SIZE field of the name, font finding mechanism gets faster for
4331 such a font. This is especially effective for such large fonts as
4332 Chinese, Japanese, and Korean. */);
4333 Vx_pixel_size_width_font_regexp = Qnil;
4334
4335 /* X window properties. */
4336 defsubr (&Sx_change_window_property);
4337 defsubr (&Sx_delete_window_property);
4338 defsubr (&Sx_window_property);
4339
4340 defsubr (&Sxw_display_color_p);
4341 defsubr (&Sx_display_grayscale_p);
4342 defsubr (&Sxw_color_defined_p);
4343 defsubr (&Sxw_color_values);
4344 defsubr (&Sx_server_max_request_size);
4345 defsubr (&Sx_server_vendor);
4346 defsubr (&Sx_server_version);
4347 defsubr (&Sx_display_pixel_width);
4348 defsubr (&Sx_display_pixel_height);
4349 defsubr (&Sx_display_mm_width);
4350 defsubr (&Sx_display_mm_height);
4351 defsubr (&Sx_display_screens);
4352 defsubr (&Sx_display_planes);
4353 defsubr (&Sx_display_color_cells);
4354 defsubr (&Sx_display_visual_class);
4355 defsubr (&Sx_display_backing_store);
4356 defsubr (&Sx_display_save_under);
4357 defsubr (&Sx_create_frame);
4358 #if 0 /* MAC_TODO: implement network support */
4359 defsubr (&Sx_open_connection);
4360 defsubr (&Sx_close_connection);
4361 #endif
4362 defsubr (&Sx_display_list);
4363 defsubr (&Sx_synchronize);
4364
4365 /* Setting callback functions for fontset handler. */
4366 get_font_info_func = x_get_font_info;
4367
4368 #if 0 /* This function pointer doesn't seem to be used anywhere.
4369 And the pointer assigned has the wrong type, anyway. */
4370 list_fonts_func = x_list_fonts;
4371 #endif
4372
4373 load_font_func = x_load_font;
4374 find_ccl_program_func = x_find_ccl_program;
4375 query_font_func = x_query_font;
4376 set_frame_fontset_func = x_set_font;
4377 check_window_system_func = check_mac;
4378
4379 hourglass_atimer = NULL;
4380 hourglass_shown_p = 0;
4381
4382 defsubr (&Sx_show_tip);
4383 defsubr (&Sx_hide_tip);
4384 tip_timer = Qnil;
4385 staticpro (&tip_timer);
4386 tip_frame = Qnil;
4387 staticpro (&tip_frame);
4388
4389 #if 0 /* MAC_TODO */
4390 defsubr (&Sx_file_dialog);
4391 #endif
4392 }
4393
4394 /* arch-tag: d7591289-f374-4377-b245-12f5dbbb8edc
4395 (do not change this comment) */