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