comparison src/w32fns.c @ 35288:912ea0b8e09b

(x_to_w32_color, x_set_icon_name, xlfd_strip_height) (w32_list_synthesized_fonts, lookup_image, Fx_file_dialog) (Fw32_send_sys_command): Remove unused variables. (w32_msg_pump): Add parentheses. (Fimage_size, image_ascent, lookup_image) (IMAGE_POSITIVE_INTEGER_VALUE_OR_PAIR, parse_image_spec) (xbm_format, xpm_format, pbm_format, png_format, jpeg_format) (tiff_format, gif_format, gs_format): Adapt to change of image margins.
author Jason Rumney <jasonr@gnu.org>
date Sat, 13 Jan 2001 00:03:17 +0000
parents 5091928844df
children b5a2207901e0
comparison
equal deleted inserted replaced
35287:28e0cac22fbd 35288:912ea0b8e09b
1507 1507
1508 COLORREF 1508 COLORREF
1509 x_to_w32_color (colorname) 1509 x_to_w32_color (colorname)
1510 char * colorname; 1510 char * colorname;
1511 { 1511 {
1512 register Lisp_Object tail, ret = Qnil; 1512 register Lisp_Object ret = Qnil;
1513 1513
1514 BLOCK_INPUT; 1514 BLOCK_INPUT;
1515 1515
1516 if (colorname[0] == '#') 1516 if (colorname[0] == '#')
1517 { 1517 {
1518 /* Could be an old-style RGB Device specification. */ 1518 /* Could be an old-style RGB Device specification. */
2345 void 2345 void
2346 x_set_icon_name (f, arg, oldval) 2346 x_set_icon_name (f, arg, oldval)
2347 struct frame *f; 2347 struct frame *f;
2348 Lisp_Object arg, oldval; 2348 Lisp_Object arg, oldval;
2349 { 2349 {
2350 int result;
2351
2352 if (STRINGP (arg)) 2350 if (STRINGP (arg))
2353 { 2351 {
2354 if (STRINGP (oldval) && EQ (Fstring_equal (oldval, arg), Qt)) 2352 if (STRINGP (oldval) && EQ (Fstring_equal (oldval, arg), Qt))
2355 return; 2353 return;
2356 } 2354 }
3830 and pointer here is not touched by GC (so the markbit 3828 and pointer here is not touched by GC (so the markbit
3831 can't be set). Numbers are safe because they are 3829 can't be set). Numbers are safe because they are
3832 immediate values. */ 3830 immediate values. */
3833 if (NILP (new_state) 3831 if (NILP (new_state)
3834 || (NUMBERP (new_state) 3832 || (NUMBERP (new_state)
3835 && (XUINT (new_state)) & 1 != cur_state)) 3833 && ((XUINT (new_state)) & 1) != cur_state))
3836 { 3834 {
3837 one_w32_display_info.faked_key = vk_code; 3835 one_w32_display_info.faked_key = vk_code;
3838 3836
3839 keybd_event ((BYTE) vk_code, 3837 keybd_event ((BYTE) vk_code,
3840 (BYTE) MapVirtualKey (vk_code, 0), 3838 (BYTE) MapVirtualKey (vk_code, 0),
5515 return charset + 1; 5513 return charset + 1;
5516 } 5514 }
5517 5515
5518 struct font_info *w32_load_bdf_font (struct frame *f, char *fontname, 5516 struct font_info *w32_load_bdf_font (struct frame *f, char *fontname,
5519 int size, char* filename); 5517 int size, char* filename);
5518 static Lisp_Object w32_list_bdf_fonts (Lisp_Object pattern, int max_names);
5520 BOOL w32_to_x_font (LOGFONT * lplf, char * lpxstr, int len, char * charset); 5519 BOOL w32_to_x_font (LOGFONT * lplf, char * lpxstr, int len, char * charset);
5521 5520
5522 struct font_info * 5521 static struct font_info *
5523 w32_load_system_font (f,fontname,size) 5522 w32_load_system_font (f,fontname,size)
5524 struct frame *f; 5523 struct frame *f;
5525 char * fontname; 5524 char * fontname;
5526 int size; 5525 int size;
5527 { 5526 {
5727 int size; 5726 int size;
5728 { 5727 {
5729 Lisp_Object bdf_fonts; 5728 Lisp_Object bdf_fonts;
5730 struct font_info *retval = NULL; 5729 struct font_info *retval = NULL;
5731 5730
5732 bdf_fonts = w32_list_bdf_fonts (build_string (fontname)); 5731 bdf_fonts = w32_list_bdf_fonts (build_string (fontname), 1);
5733 5732
5734 while (!retval && CONSP (bdf_fonts)) 5733 while (!retval && CONSP (bdf_fonts))
5735 { 5734 {
5736 char *bdf_name, *bdf_file; 5735 char *bdf_name, *bdf_file;
5737 Lisp_Object bdf_pair; 5736 Lisp_Object bdf_pair;
5788 * (registry "[^-]+") 5787 * (registry "[^-]+")
5789 * (encoding "[^-]+") 5788 * (encoding "[^-]+")
5790 * ) 5789 * )
5791 */ 5790 */
5792 5791
5793 LONG 5792 static LONG
5794 x_to_w32_weight (lpw) 5793 x_to_w32_weight (lpw)
5795 char * lpw; 5794 char * lpw;
5796 { 5795 {
5797 if (!lpw) return (FW_DONTCARE); 5796 if (!lpw) return (FW_DONTCARE);
5798 5797
5809 else 5808 else
5810 return FW_DONTCARE; 5809 return FW_DONTCARE;
5811 } 5810 }
5812 5811
5813 5812
5814 char * 5813 static char *
5815 w32_to_x_weight (fnweight) 5814 w32_to_x_weight (fnweight)
5816 int fnweight; 5815 int fnweight;
5817 { 5816 {
5818 if (fnweight >= FW_HEAVY) return "heavy"; 5817 if (fnweight >= FW_HEAVY) return "heavy";
5819 if (fnweight >= FW_EXTRABOLD) return "extrabold"; 5818 if (fnweight >= FW_EXTRABOLD) return "extrabold";
5826 if (fnweight >= FW_THIN) return "thin"; 5825 if (fnweight >= FW_THIN) return "thin";
5827 else 5826 else
5828 return "*"; 5827 return "*";
5829 } 5828 }
5830 5829
5831 LONG 5830 static LONG
5832 x_to_w32_charset (lpcs) 5831 x_to_w32_charset (lpcs)
5833 char * lpcs; 5832 char * lpcs;
5834 { 5833 {
5835 Lisp_Object this_entry, w32_charset; 5834 Lisp_Object this_entry, w32_charset;
5836 5835
5897 5896
5898 return DEFAULT_CHARSET; 5897 return DEFAULT_CHARSET;
5899 } 5898 }
5900 5899
5901 5900
5902 char * 5901 static char *
5903 w32_to_x_charset (fncharset) 5902 w32_to_x_charset (fncharset)
5904 int fncharset; 5903 int fncharset;
5905 { 5904 {
5906 static char buf[16]; 5905 static char buf[16];
5907 Lisp_Object charset_type; 5906 Lisp_Object charset_type;
6107 else 6106 else
6108 return CP_UNKNOWN; 6107 return CP_UNKNOWN;
6109 } 6108 }
6110 6109
6111 6110
6112 BOOL 6111 static BOOL
6113 w32_to_x_font (lplogfont, lpxstr, len, specific_charset) 6112 w32_to_x_font (lplogfont, lpxstr, len, specific_charset)
6114 LOGFONT * lplogfont; 6113 LOGFONT * lplogfont;
6115 char * lpxstr; 6114 char * lpxstr;
6116 int len; 6115 int len;
6117 char * specific_charset; 6116 char * specific_charset;
6195 6194
6196 lpxstr[len - 1] = 0; /* just to be sure */ 6195 lpxstr[len - 1] = 0; /* just to be sure */
6197 return (TRUE); 6196 return (TRUE);
6198 } 6197 }
6199 6198
6200 BOOL 6199 static BOOL
6201 x_to_w32_font (lpxstr, lplogfont) 6200 x_to_w32_font (lpxstr, lplogfont)
6202 char * lpxstr; 6201 char * lpxstr;
6203 LOGFONT * lplogfont; 6202 LOGFONT * lplogfont;
6204 { 6203 {
6205 struct coding_system coding; 6204 struct coding_system coding;
6367 /* Strip the pixel height and point height from the given xlfd, and 6366 /* Strip the pixel height and point height from the given xlfd, and
6368 return the pixel height. If no pixel height is specified, calculate 6367 return the pixel height. If no pixel height is specified, calculate
6369 one from the point height, or if that isn't defined either, return 6368 one from the point height, or if that isn't defined either, return
6370 0 (which usually signifies a scalable font). 6369 0 (which usually signifies a scalable font).
6371 */ 6370 */
6372 int xlfd_strip_height (char *fontname) 6371 static int
6373 { 6372 xlfd_strip_height (char *fontname)
6374 int pixel_height, point_height, dpi, field_number; 6373 {
6374 int pixel_height, field_number;
6375 char *read_from, *write_to; 6375 char *read_from, *write_to;
6376 6376
6377 xassert (fontname); 6377 xassert (fontname);
6378 6378
6379 pixel_height = field_number = 0; 6379 pixel_height = field_number = 0;
6482 6482
6483 return pixel_height; 6483 return pixel_height;
6484 } 6484 }
6485 6485
6486 /* Assume parameter 1 is fully qualified, no wildcards. */ 6486 /* Assume parameter 1 is fully qualified, no wildcards. */
6487 BOOL 6487 static BOOL
6488 w32_font_match (fontname, pattern) 6488 w32_font_match (fontname, pattern)
6489 char * fontname; 6489 char * fontname;
6490 char * pattern; 6490 char * pattern;
6491 { 6491 {
6492 char *regex = alloca (strlen (pattern) * 2); 6492 char *regex = alloca (strlen (pattern) * 2);
6554 XFontStruct *size_ref; 6554 XFontStruct *size_ref;
6555 Lisp_Object *pattern; 6555 Lisp_Object *pattern;
6556 Lisp_Object *tail; 6556 Lisp_Object *tail;
6557 } enumfont_t; 6557 } enumfont_t;
6558 6558
6559 int CALLBACK 6559 static int CALLBACK
6560 enum_font_cb2 (lplf, lptm, FontType, lpef) 6560 enum_font_cb2 (lplf, lptm, FontType, lpef)
6561 ENUMLOGFONT * lplf; 6561 ENUMLOGFONT * lplf;
6562 NEWTEXTMETRIC * lptm; 6562 NEWTEXTMETRIC * lptm;
6563 int FontType; 6563 int FontType;
6564 enumfont_t * lpef; 6564 enumfont_t * lpef;
6628 } 6628 }
6629 6629
6630 return (1); 6630 return (1);
6631 } 6631 }
6632 6632
6633 int CALLBACK 6633 static int CALLBACK
6634 enum_font_cb1 (lplf, lptm, FontType, lpef) 6634 enum_font_cb1 (lplf, lptm, FontType, lpef)
6635 ENUMLOGFONT * lplf; 6635 ENUMLOGFONT * lplf;
6636 NEWTEXTMETRIC * lptm; 6636 NEWTEXTMETRIC * lptm;
6637 int FontType; 6637 int FontType;
6638 enumfont_t * lpef; 6638 enumfont_t * lpef;
6642 (FONTENUMPROC) enum_font_cb2, 6642 (FONTENUMPROC) enum_font_cb2,
6643 (LPARAM) lpef); 6643 (LPARAM) lpef);
6644 } 6644 }
6645 6645
6646 6646
6647 int CALLBACK 6647 static int CALLBACK
6648 enum_fontex_cb2 (lplf, lptm, font_type, lpef) 6648 enum_fontex_cb2 (lplf, lptm, font_type, lpef)
6649 ENUMLOGFONTEX * lplf; 6649 ENUMLOGFONTEX * lplf;
6650 NEWTEXTMETRICEX * lptm; 6650 NEWTEXTMETRICEX * lptm;
6651 int font_type; 6651 int font_type;
6652 enumfont_t * lpef; 6652 enumfont_t * lpef;
6656 enumerated seperately. */ 6656 enumerated seperately. */
6657 return enum_font_cb2 ((ENUMLOGFONT *) lplf, (NEWTEXTMETRIC *) lptm, 6657 return enum_font_cb2 ((ENUMLOGFONT *) lplf, (NEWTEXTMETRIC *) lptm,
6658 font_type, lpef); 6658 font_type, lpef);
6659 } 6659 }
6660 6660
6661 int CALLBACK 6661 static int CALLBACK
6662 enum_fontex_cb1 (lplf, lptm, font_type, lpef) 6662 enum_fontex_cb1 (lplf, lptm, font_type, lpef)
6663 ENUMLOGFONTEX * lplf; 6663 ENUMLOGFONTEX * lplf;
6664 NEWTEXTMETRICEX * lptm; 6664 NEWTEXTMETRICEX * lptm;
6665 int font_type; 6665 int font_type;
6666 enumfont_t * lpef; 6666 enumfont_t * lpef;
6679 } 6679 }
6680 6680
6681 /* Interface to fontset handler. (adapted from mw32font.c in Meadow 6681 /* Interface to fontset handler. (adapted from mw32font.c in Meadow
6682 and xterm.c in Emacs 20.3) */ 6682 and xterm.c in Emacs 20.3) */
6683 6683
6684 Lisp_Object w32_list_bdf_fonts (Lisp_Object pattern, int max_names) 6684 static Lisp_Object w32_list_bdf_fonts (Lisp_Object pattern, int max_names)
6685 { 6685 {
6686 char *fontname, *ptnstr; 6686 char *fontname, *ptnstr;
6687 Lisp_Object list, tem, newlist = Qnil; 6687 Lisp_Object list, tem, newlist = Qnil;
6688 int n_fonts = 0; 6688 int n_fonts = 0;
6689 6689
6710 } 6710 }
6711 6711
6712 return newlist; 6712 return newlist;
6713 } 6713 }
6714 6714
6715 Lisp_Object w32_list_synthesized_fonts (FRAME_PTR f, Lisp_Object pattern, 6715 static Lisp_Object w32_list_synthesized_fonts (FRAME_PTR f,
6716 int size, int max_names); 6716 Lisp_Object pattern,
6717 int size, int max_names);
6717 6718
6718 /* Return a list of names of available fonts matching PATTERN on frame 6719 /* Return a list of names of available fonts matching PATTERN on frame
6719 F. If SIZE is not 0, it is the size (maximum bound width) of fonts 6720 F. If SIZE is not 0, it is the size (maximum bound width) of fonts
6720 to be listed. Frame F NULL means we have not yet created any 6721 to be listed. Frame F NULL means we have not yet created any
6721 frame, which means we can't get proper size info, as we don't have 6722 frame, which means we can't get proper size info, as we don't have
6918 newlist = w32_list_synthesized_fonts (f, pattern, size, maxnames); 6919 newlist = w32_list_synthesized_fonts (f, pattern, size, maxnames);
6919 6920
6920 return newlist; 6921 return newlist;
6921 } 6922 }
6922 6923
6923 Lisp_Object 6924 static Lisp_Object
6924 w32_list_synthesized_fonts (f, pattern, size, max_names) 6925 w32_list_synthesized_fonts (f, pattern, size, max_names)
6925 FRAME_PTR f; 6926 FRAME_PTR f;
6926 Lisp_Object pattern; 6927 Lisp_Object pattern;
6927 int size; 6928 int size;
6928 int max_names; 6929 int max_names;
6929 { 6930 {
6930 int fields; 6931 int fields;
6931 char *full_pattn, *new_pattn, foundary[50], family[50], *pattn_part2; 6932 char *full_pattn, *new_pattn, foundary[50], family[50], *pattn_part2;
6932 char style[20], slant; 6933 char style[20], slant;
6933 Lisp_Object matches, match, tem, synthed_matches = Qnil; 6934 Lisp_Object matches, tem, synthed_matches = Qnil;
6934 6935
6935 full_pattn = XSTRING (pattern)->data; 6936 full_pattn = XSTRING (pattern)->data;
6936 6937
6937 pattn_part2 = alloca (XSTRING (pattern)->size); 6938 pattn_part2 = alloca (XSTRING (pattern)->size);
6938 /* Allow some space for wildcard expansion. */ 6939 /* Allow some space for wildcard expansion. */
7030 fontp->font_encoder = ccl; 7031 fontp->font_encoder = ccl;
7031 } 7032 }
7032 } 7033 }
7033 7034
7034 7035
7036 /* Find BDF files in a specified directory. (use GCPRO when calling,
7037 as this calls lisp to get a directory listing). */
7038 static Lisp_Object
7039 w32_find_bdf_fonts_in_dir (Lisp_Object directory)
7040 {
7041 Lisp_Object filelist, list = Qnil;
7042 char fontname[100];
7043
7044 if (!STRINGP(directory))
7045 return Qnil;
7046
7047 filelist = Fdirectory_files (directory, Qt,
7048 build_string (".*\\.[bB][dD][fF]"), Qt);
7049
7050 for ( ; CONSP(filelist); filelist = XCDR (filelist))
7051 {
7052 Lisp_Object filename = XCAR (filelist);
7053 if (w32_BDF_to_x_font (XSTRING (filename)->data, fontname, 100))
7054 store_in_alist (&list, build_string (fontname), filename);
7055 }
7056 return list;
7057 }
7058
7035 DEFUN ("w32-find-bdf-fonts", Fw32_find_bdf_fonts, Sw32_find_bdf_fonts, 7059 DEFUN ("w32-find-bdf-fonts", Fw32_find_bdf_fonts, Sw32_find_bdf_fonts,
7036 1, 1, 0, 7060 1, 1, 0,
7037 "Return a list of BDF fonts in DIR, suitable for appending to\n\ 7061 "Return a list of BDF fonts in DIR, suitable for appending to\n\
7038 w32-bdf-filename-alist. Fonts which do not contain an xlfd description\n\ 7062 w32-bdf-filename-alist. Fonts which do not contain an xlfd description\n\
7039 will not be included in the list. DIR may be a list of directories.") 7063 will not be included in the list. DIR may be a list of directories.")
7053 pair[1] = Qnil; 7077 pair[1] = Qnil;
7054 GCPRO2 (directory, list); 7078 GCPRO2 (directory, list);
7055 pair[1] = w32_find_bdf_fonts_in_dir( XCAR (directory) ); 7079 pair[1] = w32_find_bdf_fonts_in_dir( XCAR (directory) );
7056 list = Fnconc( 2, pair ); 7080 list = Fnconc( 2, pair );
7057 UNGCPRO; 7081 UNGCPRO;
7058 }
7059 return list;
7060 }
7061
7062 /* Find BDF files in a specified directory. (use GCPRO when calling,
7063 as this calls lisp to get a directory listing). */
7064 Lisp_Object w32_find_bdf_fonts_in_dir( Lisp_Object directory )
7065 {
7066 Lisp_Object filelist, list = Qnil;
7067 char fontname[100];
7068
7069 if (!STRINGP(directory))
7070 return Qnil;
7071
7072 filelist = Fdirectory_files (directory, Qt,
7073 build_string (".*\\.[bB][dD][fF]"), Qt);
7074
7075 for ( ; CONSP(filelist); filelist = XCDR (filelist))
7076 {
7077 Lisp_Object filename = XCAR (filelist);
7078 if (w32_BDF_to_x_font (XSTRING (filename)->data, fontname, 100))
7079 store_in_alist (&list, build_string (fontname), filename);
7080 } 7082 }
7081 return list; 7083 return list;
7082 } 7084 }
7083 7085
7084 7086
7718 { 7720 {
7719 IMAGE_DONT_CHECK_VALUE_TYPE, 7721 IMAGE_DONT_CHECK_VALUE_TYPE,
7720 IMAGE_STRING_VALUE, 7722 IMAGE_STRING_VALUE,
7721 IMAGE_SYMBOL_VALUE, 7723 IMAGE_SYMBOL_VALUE,
7722 IMAGE_POSITIVE_INTEGER_VALUE, 7724 IMAGE_POSITIVE_INTEGER_VALUE,
7725 IMAGE_POSITIVE_INTEGER_VALUE_OR_PAIR,
7723 IMAGE_NON_NEGATIVE_INTEGER_VALUE, 7726 IMAGE_NON_NEGATIVE_INTEGER_VALUE,
7724 IMAGE_ASCENT_VALUE, 7727 IMAGE_ASCENT_VALUE,
7725 IMAGE_INTEGER_VALUE, 7728 IMAGE_INTEGER_VALUE,
7726 IMAGE_FUNCTION_VALUE, 7729 IMAGE_FUNCTION_VALUE,
7727 IMAGE_NUMBER_VALUE, 7730 IMAGE_NUMBER_VALUE,
7821 7824
7822 case IMAGE_POSITIVE_INTEGER_VALUE: 7825 case IMAGE_POSITIVE_INTEGER_VALUE:
7823 if (!INTEGERP (value) || XINT (value) <= 0) 7826 if (!INTEGERP (value) || XINT (value) <= 0)
7824 return 0; 7827 return 0;
7825 break; 7828 break;
7829
7830 case IMAGE_POSITIVE_INTEGER_VALUE_OR_PAIR:
7831 if (INTEGERP (value) && XINT (value) >= 0)
7832 break;
7833 if (CONSP (value)
7834 && INTEGERP (XCAR (value)) && INTEGERP (XCDR (value))
7835 && XINT (XCAR (value)) >= 0 && XINT (XCDR (value)) >= 0)
7836 break;
7837 return 0;
7826 7838
7827 case IMAGE_ASCENT_VALUE: 7839 case IMAGE_ASCENT_VALUE:
7828 if (SYMBOLP (value) && EQ (value, Qcenter)) 7840 if (SYMBOLP (value) && EQ (value, Qcenter))
7829 break; 7841 break;
7830 else if (INTEGERP (value) 7842 else if (INTEGERP (value)
8001 int 8013 int
8002 image_ascent (img, face) 8014 image_ascent (img, face)
8003 struct image *img; 8015 struct image *img;
8004 struct face *face; 8016 struct face *face;
8005 { 8017 {
8006 int height = img->height + img->margin; 8018 int height = img->height + img->vmargin;
8007 int ascent; 8019 int ascent;
8008 8020
8009 if (img->ascent == CENTERED_IMAGE_ASCENT) 8021 if (img->ascent == CENTERED_IMAGE_ASCENT)
8010 { 8022 {
8011 if (face->font) 8023 if (face->font)
8266 break; 8278 break;
8267 8279
8268 /* If not found, create a new image and cache it. */ 8280 /* If not found, create a new image and cache it. */
8269 if (img == NULL) 8281 if (img == NULL)
8270 { 8282 {
8283 BLOCK_INPUT;
8271 img = make_image (spec, hash); 8284 img = make_image (spec, hash);
8272 cache_image (f, img); 8285 cache_image (f, img);
8273 img->load_failed_p = img->type->load (f, img) == 0; 8286 img->load_failed_p = img->type->load (f, img) == 0;
8274 xassert (!interrupt_input_blocked);
8275 8287
8276 /* If we can't load the image, and we don't have a width and 8288 /* If we can't load the image, and we don't have a width and
8277 height, use some arbitrary width and height so that we can 8289 height, use some arbitrary width and height so that we can
8278 draw a rectangle for it. */ 8290 draw a rectangle for it. */
8279 if (img->load_failed_p) 8291 if (img->load_failed_p)
8289 } 8301 }
8290 else 8302 else
8291 { 8303 {
8292 /* Handle image type independent image attributes 8304 /* Handle image type independent image attributes
8293 `:ascent PERCENT', `:margin MARGIN', `:relief RELIEF'. */ 8305 `:ascent PERCENT', `:margin MARGIN', `:relief RELIEF'. */
8294 Lisp_Object ascent, margin, relief, algorithm, heuristic_mask; 8306 Lisp_Object ascent, margin, relief;
8295 Lisp_Object file;
8296 8307
8297 ascent = image_spec_value (spec, QCascent, NULL); 8308 ascent = image_spec_value (spec, QCascent, NULL);
8298 if (INTEGERP (ascent)) 8309 if (INTEGERP (ascent))
8299 img->ascent = XFASTINT (ascent); 8310 img->ascent = XFASTINT (ascent);
8300 else if (EQ (ascent, Qcenter)) 8311 else if (EQ (ascent, Qcenter))
8301 img->ascent = CENTERED_IMAGE_ASCENT; 8312 img->ascent = CENTERED_IMAGE_ASCENT;
8302 8313
8303 margin = image_spec_value (spec, QCmargin, NULL); 8314 margin = image_spec_value (spec, QCmargin, NULL);
8304 if (INTEGERP (margin) && XINT (margin) >= 0) 8315 if (INTEGERP (margin) && XINT (margin) >= 0)
8305 img->margin = XFASTINT (margin); 8316 img->vmargin = img->hmargin = XFASTINT (margin);
8317 else if (CONSP (margin) && INTEGERP (XCAR (margin))
8318 && INTEGERP (XCDR (margin)))
8319 {
8320 if (XINT (XCAR (margin)) > 0)
8321 img->hmargin = XFASTINT (XCAR (margin));
8322 if (XINT (XCDR (margin)) > 0)
8323 img->vmargin = XFASTINT (XCDR (margin));
8324 }
8306 8325
8307 relief = image_spec_value (spec, QCrelief, NULL); 8326 relief = image_spec_value (spec, QCrelief, NULL);
8308 if (INTEGERP (relief)) 8327 if (INTEGERP (relief))
8309 { 8328 {
8310 img->relief = XINT (relief); 8329 img->relief = XINT (relief);
8311 img->margin += abs (img->relief); 8330 img->hmargin += abs (img->relief);
8331 img->vmargin += abs (img->relief);
8312 } 8332 }
8313 8333
8314 /* Should we apply a Laplace edge-detection algorithm? */ 8334 #if 0 /* TODO: image mask and algorithm. */
8315 algorithm = image_spec_value (spec, QCalgorithm, NULL); 8335 /* Manipulation of the image's mask. */
8316 if (img->pixmap && EQ (algorithm, Qlaplace)) 8336 if (img->pixmap)
8317 x_laplace (f, img); 8337 {
8318 8338 /* `:heuristic-mask t'
8319 /* Should we built a mask heuristically? */ 8339 `:mask heuristic'
8320 heuristic_mask = image_spec_value (spec, QCheuristic_mask, NULL); 8340 means build a mask heuristically.
8321 if (img->pixmap && !img->mask && !NILP (heuristic_mask)) 8341 `:heuristic-mask (R G B)'
8322 x_build_heuristic_mask (f, img, heuristic_mask); 8342 `:mask (heuristic (R G B))'
8343 means build a mask from color (R G B) in the
8344 image.
8345 `:mask nil'
8346 means remove a mask, if any. */
8347
8348 Lisp_Object mask;
8349
8350 mask = image_spec_value (spec, QCheuristic_mask, NULL);
8351 if (!NILP (mask))
8352 x_build_heuristic_mask (f, img, mask);
8353 else
8354 {
8355 int found_p;
8356
8357 mask = image_spec_value (spec, QCmask, &found_p);
8358
8359 if (EQ (mask, Qheuristic))
8360 x_build_heuristic_mask (f, img, Qt);
8361 else if (CONSP (mask)
8362 && EQ (XCAR (mask), Qheuristic))
8363 {
8364 if (CONSP (XCDR (mask)))
8365 x_build_heuristic_mask (f, img, XCAR (XCDR (mask)));
8366 else
8367 x_build_heuristic_mask (f, img, XCDR (mask));
8368 }
8369 else if (NILP (mask) && found_p && img->mask)
8370 {
8371 XFreePixmap (FRAME_X_DISPLAY (f), img->mask);
8372 img->mask = None;
8373 }
8374 }
8375 }
8376
8377 /* Should we apply an image transformation algorithm? */
8378 if (img->pixmap)
8379 {
8380 Lisp_Object algorithm;
8381
8382 algorithm = image_spec_value (spec, QCalgorithm, NULL);
8383 if (EQ (algorithm, Qdisabled))
8384 x_disable_image (f, img);
8385 else if (EQ (algorithm, Qlaplace))
8386 x_laplace (f, img);
8387 else if (EQ (algorithm, Qemboss))
8388 x_emboss (f, img);
8389 else if (CONSP (algorithm)
8390 && EQ (XCAR (algorithm), Qedge_detection))
8391 {
8392 Lisp_Object tem;
8393 tem = XCDR (algorithm);
8394 if (CONSP (tem))
8395 x_edge_detection (f, img,
8396 Fplist_get (tem, QCmatrix),
8397 Fplist_get (tem, QCcolor_adjustment));
8398 }
8399 }
8400 #endif /* TODO. */
8323 } 8401 }
8402 UNBLOCK_INPUT;
8403 xassert (!interrupt_input_blocked);
8324 } 8404 }
8325 8405
8326 /* We're using IMG, so set its timestamp to `now'. */ 8406 /* We're using IMG, so set its timestamp to `now'. */
8327 EMACS_GET_TIME (now); 8407 EMACS_GET_TIME (now);
8328 img->timestamp = EMACS_SECS (now); 8408 img->timestamp = EMACS_SECS (now);
8570 {":height", IMAGE_POSITIVE_INTEGER_VALUE, 0}, 8650 {":height", IMAGE_POSITIVE_INTEGER_VALUE, 0},
8571 {":data", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, 8651 {":data", IMAGE_DONT_CHECK_VALUE_TYPE, 0},
8572 {":foreground", IMAGE_STRING_VALUE, 0}, 8652 {":foreground", IMAGE_STRING_VALUE, 0},
8573 {":background", IMAGE_STRING_VALUE, 0}, 8653 {":background", IMAGE_STRING_VALUE, 0},
8574 {":ascent", IMAGE_NON_NEGATIVE_INTEGER_VALUE, 0}, 8654 {":ascent", IMAGE_NON_NEGATIVE_INTEGER_VALUE, 0},
8575 {":margin", IMAGE_POSITIVE_INTEGER_VALUE, 0}, 8655 {":margin", IMAGE_POSITIVE_INTEGER_VALUE_OR_PAIR, 0},
8576 {":relief", IMAGE_INTEGER_VALUE, 0}, 8656 {":relief", IMAGE_INTEGER_VALUE, 0},
8577 {":algorithm", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, 8657 {":algorithm", IMAGE_DONT_CHECK_VALUE_TYPE, 0},
8578 {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0} 8658 {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0}
8579 }; 8659 };
8580 8660
9160 { 9240 {
9161 {":type", IMAGE_SYMBOL_VALUE, 1}, 9241 {":type", IMAGE_SYMBOL_VALUE, 1},
9162 {":file", IMAGE_STRING_VALUE, 0}, 9242 {":file", IMAGE_STRING_VALUE, 0},
9163 {":data", IMAGE_STRING_VALUE, 0}, 9243 {":data", IMAGE_STRING_VALUE, 0},
9164 {":ascent", IMAGE_NON_NEGATIVE_INTEGER_VALUE, 0}, 9244 {":ascent", IMAGE_NON_NEGATIVE_INTEGER_VALUE, 0},
9165 {":margin", IMAGE_POSITIVE_INTEGER_VALUE, 0}, 9245 {":margin", IMAGE_POSITIVE_INTEGER_VALUE_OR_PAIR, 0},
9166 {":relief", IMAGE_INTEGER_VALUE, 0}, 9246 {":relief", IMAGE_INTEGER_VALUE, 0},
9167 {":algorithm", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, 9247 {":algorithm", IMAGE_DONT_CHECK_VALUE_TYPE, 0},
9168 {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, 9248 {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0},
9169 {":color-symbols", IMAGE_DONT_CHECK_VALUE_TYPE, 0} 9249 {":color-symbols", IMAGE_DONT_CHECK_VALUE_TYPE, 0}
9170 }; 9250 };
9850 { 9930 {
9851 {":type", IMAGE_SYMBOL_VALUE, 1}, 9931 {":type", IMAGE_SYMBOL_VALUE, 1},
9852 {":file", IMAGE_STRING_VALUE, 0}, 9932 {":file", IMAGE_STRING_VALUE, 0},
9853 {":data", IMAGE_STRING_VALUE, 0}, 9933 {":data", IMAGE_STRING_VALUE, 0},
9854 {":ascent", IMAGE_NON_NEGATIVE_INTEGER_VALUE, 0}, 9934 {":ascent", IMAGE_NON_NEGATIVE_INTEGER_VALUE, 0},
9855 {":margin", IMAGE_POSITIVE_INTEGER_VALUE, 0}, 9935 {":margin", IMAGE_POSITIVE_INTEGER_VALUE_OR_PAIR, 0},
9856 {":relief", IMAGE_INTEGER_VALUE, 0}, 9936 {":relief", IMAGE_INTEGER_VALUE, 0},
9857 {":algorithm", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, 9937 {":algorithm", IMAGE_DONT_CHECK_VALUE_TYPE, 0},
9858 {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0} 9938 {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0}
9859 }; 9939 };
9860 9940
10206 { 10286 {
10207 {":type", IMAGE_SYMBOL_VALUE, 1}, 10287 {":type", IMAGE_SYMBOL_VALUE, 1},
10208 {":data", IMAGE_STRING_VALUE, 0}, 10288 {":data", IMAGE_STRING_VALUE, 0},
10209 {":file", IMAGE_STRING_VALUE, 0}, 10289 {":file", IMAGE_STRING_VALUE, 0},
10210 {":ascent", IMAGE_NON_NEGATIVE_INTEGER_VALUE, 0}, 10290 {":ascent", IMAGE_NON_NEGATIVE_INTEGER_VALUE, 0},
10211 {":margin", IMAGE_POSITIVE_INTEGER_VALUE, 0}, 10291 {":margin", IMAGE_POSITIVE_INTEGER_VALUE_OR_PAIR, 0},
10212 {":relief", IMAGE_INTEGER_VALUE, 0}, 10292 {":relief", IMAGE_INTEGER_VALUE, 0},
10213 {":algorithm", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, 10293 {":algorithm", IMAGE_DONT_CHECK_VALUE_TYPE, 0},
10214 {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0} 10294 {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0}
10215 }; 10295 };
10216 10296
10692 { 10772 {
10693 {":type", IMAGE_SYMBOL_VALUE, 1}, 10773 {":type", IMAGE_SYMBOL_VALUE, 1},
10694 {":data", IMAGE_STRING_VALUE, 0}, 10774 {":data", IMAGE_STRING_VALUE, 0},
10695 {":file", IMAGE_STRING_VALUE, 0}, 10775 {":file", IMAGE_STRING_VALUE, 0},
10696 {":ascent", IMAGE_NON_NEGATIVE_INTEGER_VALUE, 0}, 10776 {":ascent", IMAGE_NON_NEGATIVE_INTEGER_VALUE, 0},
10697 {":margin", IMAGE_POSITIVE_INTEGER_VALUE, 0}, 10777 {":margin", IMAGE_POSITIVE_INTEGER_VALUE_OR_PAIR, 0},
10698 {":relief", IMAGE_INTEGER_VALUE, 0}, 10778 {":relief", IMAGE_INTEGER_VALUE, 0},
10699 {":algorithm", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, 10779 {":algorithm", IMAGE_DONT_CHECK_VALUE_TYPE, 0},
10700 {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0} 10780 {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0}
10701 }; 10781 };
10702 10782
11055 { 11135 {
11056 {":type", IMAGE_SYMBOL_VALUE, 1}, 11136 {":type", IMAGE_SYMBOL_VALUE, 1},
11057 {":data", IMAGE_STRING_VALUE, 0}, 11137 {":data", IMAGE_STRING_VALUE, 0},
11058 {":file", IMAGE_STRING_VALUE, 0}, 11138 {":file", IMAGE_STRING_VALUE, 0},
11059 {":ascent", IMAGE_NON_NEGATIVE_INTEGER_VALUE, 0}, 11139 {":ascent", IMAGE_NON_NEGATIVE_INTEGER_VALUE, 0},
11060 {":margin", IMAGE_POSITIVE_INTEGER_VALUE, 0}, 11140 {":margin", IMAGE_POSITIVE_INTEGER_VALUE_OR_PAIR, 0},
11061 {":relief", IMAGE_INTEGER_VALUE, 0}, 11141 {":relief", IMAGE_INTEGER_VALUE, 0},
11062 {":algorithm", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, 11142 {":algorithm", IMAGE_DONT_CHECK_VALUE_TYPE, 0},
11063 {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0} 11143 {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0}
11064 }; 11144 };
11065 11145
11374 { 11454 {
11375 {":type", IMAGE_SYMBOL_VALUE, 1}, 11455 {":type", IMAGE_SYMBOL_VALUE, 1},
11376 {":data", IMAGE_STRING_VALUE, 0}, 11456 {":data", IMAGE_STRING_VALUE, 0},
11377 {":file", IMAGE_STRING_VALUE, 0}, 11457 {":file", IMAGE_STRING_VALUE, 0},
11378 {":ascent", IMAGE_NON_NEGATIVE_INTEGER_VALUE, 0}, 11458 {":ascent", IMAGE_NON_NEGATIVE_INTEGER_VALUE, 0},
11379 {":margin", IMAGE_POSITIVE_INTEGER_VALUE, 0}, 11459 {":margin", IMAGE_POSITIVE_INTEGER_VALUE_OR_PAIR, 0},
11380 {":relief", IMAGE_INTEGER_VALUE, 0}, 11460 {":relief", IMAGE_INTEGER_VALUE, 0},
11381 {":algorithm", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, 11461 {":algorithm", IMAGE_DONT_CHECK_VALUE_TYPE, 0},
11382 {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, 11462 {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0},
11383 {":image", IMAGE_NON_NEGATIVE_INTEGER_VALUE, 0} 11463 {":image", IMAGE_NON_NEGATIVE_INTEGER_VALUE, 0}
11384 }; 11464 };
11689 {":pt-height", IMAGE_POSITIVE_INTEGER_VALUE, 1}, 11769 {":pt-height", IMAGE_POSITIVE_INTEGER_VALUE, 1},
11690 {":file", IMAGE_STRING_VALUE, 1}, 11770 {":file", IMAGE_STRING_VALUE, 1},
11691 {":loader", IMAGE_FUNCTION_VALUE, 0}, 11771 {":loader", IMAGE_FUNCTION_VALUE, 0},
11692 {":bounding-box", IMAGE_DONT_CHECK_VALUE_TYPE, 1}, 11772 {":bounding-box", IMAGE_DONT_CHECK_VALUE_TYPE, 1},
11693 {":ascent", IMAGE_NON_NEGATIVE_INTEGER_VALUE, 0}, 11773 {":ascent", IMAGE_NON_NEGATIVE_INTEGER_VALUE, 0},
11694 {":margin", IMAGE_POSITIVE_INTEGER_VALUE, 0}, 11774 {":margin", IMAGE_POSITIVE_INTEGER_VALUE_OR_PAIR, 0},
11695 {":relief", IMAGE_INTEGER_VALUE, 0}, 11775 {":relief", IMAGE_INTEGER_VALUE, 0},
11696 {":algorithm", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, 11776 {":algorithm", IMAGE_DONT_CHECK_VALUE_TYPE, 0},
11697 {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0} 11777 {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0}
11698 }; 11778 };
11699 11779
12770 filename[0] = '\0'; 12850 filename[0] = '\0';
12771 12851
12772 if (use_dialog_p) 12852 if (use_dialog_p)
12773 { 12853 {
12774 OPENFILENAME file_details; 12854 OPENFILENAME file_details;
12775 char *filename_file;
12776 12855
12777 /* Prevent redisplay. */ 12856 /* Prevent redisplay. */
12778 specbind (Qinhibit_redisplay, Qt); 12857 specbind (Qinhibit_redisplay, Qt);
12779 BLOCK_INPUT; 12858 BLOCK_INPUT;
12780 12859
12909 \n\ 12988 \n\
12910 If optional parameter FRAME is not specified, use selected frame.") 12989 If optional parameter FRAME is not specified, use selected frame.")
12911 (command, frame) 12990 (command, frame)
12912 Lisp_Object command, frame; 12991 Lisp_Object command, frame;
12913 { 12992 {
12914 WPARAM code;
12915 FRAME_PTR f = check_x_frame (frame); 12993 FRAME_PTR f = check_x_frame (frame);
12916 12994
12917 CHECK_NUMBER (command, 0); 12995 CHECK_NUMBER (command, 0);
12918 12996
12919 PostMessage (FRAME_W32_WINDOW (f), WM_SYSCOMMAND, XINT (command), 0); 12997 PostMessage (FRAME_W32_WINDOW (f), WM_SYSCOMMAND, XINT (command), 0);
13162 is set to off if the low bit of NEW-STATE is zero, otherwise on.") 13240 is set to off if the low bit of NEW-STATE is zero, otherwise on.")
13163 (key, new_state) 13241 (key, new_state)
13164 Lisp_Object key, new_state; 13242 Lisp_Object key, new_state;
13165 { 13243 {
13166 int vk_code; 13244 int vk_code;
13167 int cur_state;
13168 13245
13169 if (EQ (key, intern ("capslock"))) 13246 if (EQ (key, intern ("capslock")))
13170 vk_code = VK_CAPITAL; 13247 vk_code = VK_CAPITAL;
13171 else if (EQ (key, intern ("kp-numlock"))) 13248 else if (EQ (key, intern ("kp-numlock")))
13172 vk_code = VK_NUMLOCK; 13249 vk_code = VK_NUMLOCK;