Mercurial > hg > xemacs-beta
comparison src/glyphs.c @ 420:41dbb7a9d5f2 r21-2-18
Import from CVS: tag r21-2-18
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:24:09 +0200 |
parents | e804706bfb8c |
children | 11054d720c21 |
comparison
equal
deleted
inserted
replaced
419:66615b78f1a5 | 420:41dbb7a9d5f2 |
---|---|
172 { | 172 { |
173 return decode_device_ii_format (Qnil, format, errb); | 173 return decode_device_ii_format (Qnil, format, errb); |
174 } | 174 } |
175 | 175 |
176 static int | 176 static int |
177 valid_image_instantiator_format_p (Lisp_Object format) | 177 valid_image_instantiator_format_p (Lisp_Object format, Lisp_Object locale) |
178 { | 178 { |
179 return (decode_image_instantiator_format (format, ERROR_ME_NOT) != 0); | 179 int i; |
180 struct image_instantiator_methods* meths = | |
181 decode_image_instantiator_format (format, ERROR_ME_NOT); | |
182 struct console* console = decode_console (locale); | |
183 Lisp_Object contype = console ? CONSOLE_TYPE (console) : locale; | |
184 /* nothing is valid in all locales */ | |
185 if (EQ (format, Qnothing)) | |
186 return 1; | |
187 /* reject unknown formats */ | |
188 else if (!console || !meths) | |
189 return 0; | |
190 | |
191 for (i = 0; i < Dynarr_length (meths->consoles); i++) | |
192 if (EQ (contype, Dynarr_at (meths->consoles, i).symbol)) | |
193 return 1; | |
194 return 0; | |
180 } | 195 } |
181 | 196 |
182 DEFUN ("valid-image-instantiator-format-p", Fvalid_image_instantiator_format_p, | 197 DEFUN ("valid-image-instantiator-format-p", Fvalid_image_instantiator_format_p, |
183 1, 1, 0, /* | 198 1, 2, 0, /* |
184 Given an IMAGE-INSTANTIATOR-FORMAT, return non-nil if it is valid. | 199 Given an IMAGE-INSTANTIATOR-FORMAT, return non-nil if it is valid. |
200 If LOCALE is non-nil then the format is checked in that domain. | |
201 If LOCALE is nil the current console is used. | |
185 Valid formats are some subset of 'nothing, 'string, 'formatted-string, | 202 Valid formats are some subset of 'nothing, 'string, 'formatted-string, |
186 'xpm, 'xbm, 'xface, 'gif, 'jpeg, 'png, 'tiff, 'cursor-font, 'font, | 203 'xpm, 'xbm, 'xface, 'gif, 'jpeg, 'png, 'tiff, 'cursor-font, 'font, |
187 'autodetect, 'widget and 'subwindow, depending on how XEmacs was compiled. | 204 'autodetect, 'widget and 'subwindow, depending on how XEmacs was compiled. |
188 */ | 205 */ |
189 (image_instantiator_format)) | 206 (image_instantiator_format, locale)) |
190 { | 207 { |
191 return valid_image_instantiator_format_p (image_instantiator_format) ? | 208 return valid_image_instantiator_format_p (image_instantiator_format, locale) ? |
192 Qt : Qnil; | 209 Qt : Qnil; |
193 } | 210 } |
194 | 211 |
195 DEFUN ("image-instantiator-format-list", Fimage_instantiator_format_list, | 212 DEFUN ("image-instantiator-format-list", Fimage_instantiator_format_list, |
196 0, 0, 0, /* | 213 0, 0, 0, /* |
545 struct image_instantiator_methods *meths; | 562 struct image_instantiator_methods *meths; |
546 struct gcpro gcpro1; | 563 struct gcpro gcpro1; |
547 int methp = 0; | 564 int methp = 0; |
548 | 565 |
549 GCPRO1 (ii); | 566 GCPRO1 (ii); |
567 if (!valid_image_instantiator_format_p (XVECTOR_DATA (instantiator)[0], device)) | |
568 signal_simple_error | |
569 ("Image instantiator format is invalid in this locale.", | |
570 instantiator); | |
571 | |
550 meths = decode_image_instantiator_format (XVECTOR_DATA (instantiator)[0], | 572 meths = decode_image_instantiator_format (XVECTOR_DATA (instantiator)[0], |
551 ERROR_ME); | 573 ERROR_ME); |
552 methp = (int)HAS_IIFORMAT_METH_P (meths, instantiate); | 574 methp = (int)HAS_IIFORMAT_METH_P (meths, instantiate); |
553 MAYBE_IIFORMAT_METH (meths, instantiate, (ii, instantiator, pointer_fg, | 575 MAYBE_IIFORMAT_METH (meths, instantiate, (ii, instantiator, pointer_fg, |
554 pointer_bg, dest_mask, domain)); | 576 pointer_bg, dest_mask, domain)); |
909 } | 931 } |
910 | 932 |
911 DEFINE_LRECORD_IMPLEMENTATION ("image-instance", image_instance, | 933 DEFINE_LRECORD_IMPLEMENTATION ("image-instance", image_instance, |
912 mark_image_instance, print_image_instance, | 934 mark_image_instance, print_image_instance, |
913 finalize_image_instance, image_instance_equal, | 935 finalize_image_instance, image_instance_equal, |
914 image_instance_hash, | 936 image_instance_hash, 0, |
915 struct Lisp_Image_Instance); | 937 struct Lisp_Image_Instance); |
916 | 938 |
917 static Lisp_Object | 939 static Lisp_Object |
918 allocate_image_instance (Lisp_Object device) | 940 allocate_image_instance (Lisp_Object device) |
919 { | 941 { |
2924 result = cons3 (Qimage, glyph->image, result); | 2946 result = cons3 (Qimage, glyph->image, result); |
2925 | 2947 |
2926 return result; | 2948 return result; |
2927 } | 2949 } |
2928 | 2950 |
2951 static const struct lrecord_description glyph_description[] = { | |
2952 { XD_LISP_OBJECT, offsetof(struct Lisp_Glyph, image), 5 }, | |
2953 { XD_END } | |
2954 }; | |
2955 | |
2929 DEFINE_LRECORD_IMPLEMENTATION_WITH_PROPS ("glyph", glyph, | 2956 DEFINE_LRECORD_IMPLEMENTATION_WITH_PROPS ("glyph", glyph, |
2930 mark_glyph, print_glyph, 0, | 2957 mark_glyph, print_glyph, 0, |
2931 glyph_equal, glyph_hash, | 2958 glyph_equal, glyph_hash, glyph_description, |
2932 glyph_getprop, glyph_putprop, | 2959 glyph_getprop, glyph_putprop, |
2933 glyph_remprop, glyph_plist, | 2960 glyph_remprop, glyph_plist, |
2934 struct Lisp_Glyph); | 2961 struct Lisp_Glyph); |
2935 | 2962 |
2936 Lisp_Object | 2963 Lisp_Object |
4100 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (formatted_string, "formatted-string"); | 4127 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (formatted_string, "formatted-string"); |
4101 | 4128 |
4102 IIFORMAT_HAS_METHOD (formatted_string, validate); | 4129 IIFORMAT_HAS_METHOD (formatted_string, validate); |
4103 IIFORMAT_HAS_METHOD (formatted_string, possible_dest_types); | 4130 IIFORMAT_HAS_METHOD (formatted_string, possible_dest_types); |
4104 IIFORMAT_HAS_METHOD (formatted_string, instantiate); | 4131 IIFORMAT_HAS_METHOD (formatted_string, instantiate); |
4105 | |
4106 IIFORMAT_VALID_KEYWORD (formatted_string, Q_data, check_valid_string); | 4132 IIFORMAT_VALID_KEYWORD (formatted_string, Q_data, check_valid_string); |
4107 | 4133 |
4108 /* subwindows */ | 4134 /* subwindows */ |
4109 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (subwindow, "subwindow"); | 4135 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (subwindow, "subwindow"); |
4110 IIFORMAT_HAS_METHOD (subwindow, possible_dest_types); | 4136 IIFORMAT_HAS_METHOD (subwindow, possible_dest_types); |