Mercurial > hg > xemacs-beta
comparison src/glyphs.c @ 434:9d177e8d4150 r21-2-25
Import from CVS: tag r21-2-25
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:30:53 +0200 |
parents | a5df635868b2 |
children | 84b14dcb0985 |
comparison
equal
deleted
inserted
replaced
433:892ca416f0fb | 434:9d177e8d4150 |
---|---|
1722 void | 1722 void |
1723 string_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, | 1723 string_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, |
1724 Lisp_Object pointer_fg, Lisp_Object pointer_bg, | 1724 Lisp_Object pointer_fg, Lisp_Object pointer_bg, |
1725 int dest_mask, Lisp_Object domain) | 1725 int dest_mask, Lisp_Object domain) |
1726 { | 1726 { |
1727 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data); | 1727 Lisp_Object string = find_keyword_in_vector (instantiator, Q_data); |
1728 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 1728 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
1729 | 1729 |
1730 assert (!NILP (data)); | 1730 assert (!NILP (string)); |
1731 if (dest_mask & IMAGE_TEXT_MASK) | 1731 if (dest_mask & IMAGE_TEXT_MASK) |
1732 { | 1732 { |
1733 IMAGE_INSTANCE_TYPE (ii) = IMAGE_TEXT; | 1733 IMAGE_INSTANCE_TYPE (ii) = IMAGE_TEXT; |
1734 IMAGE_INSTANCE_TEXT_STRING (ii) = data; | 1734 IMAGE_INSTANCE_TEXT_STRING (ii) = string; |
1735 } | 1735 } |
1736 else | 1736 else |
1737 incompatible_image_types (instantiator, dest_mask, IMAGE_TEXT_MASK); | 1737 incompatible_image_types (instantiator, dest_mask, IMAGE_TEXT_MASK); |
1738 } | 1738 } |
1739 | 1739 |
2534 will occur most of the time so this probably slows things | 2534 will occur most of the time so this probably slows things |
2535 down. But with the current design I don't see anyway | 2535 down. But with the current design I don't see anyway |
2536 round it. */ | 2536 round it. */ |
2537 if (UNBOUNDP (instance) | 2537 if (UNBOUNDP (instance) |
2538 && | 2538 && |
2539 dest_mask & (IMAGE_SUBWINDOW_MASK | IMAGE_WIDGET_MASK)) | 2539 dest_mask & (IMAGE_SUBWINDOW_MASK |
2540 | IMAGE_WIDGET_MASK | |
2541 | IMAGE_TEXT_MASK)) | |
2540 { | 2542 { |
2541 if (!WINDOWP (domain)) | 2543 if (!WINDOWP (domain)) |
2542 signal_simple_error ("Can't instantiate subwindow outside a window", | 2544 signal_simple_error ("Can't instantiate text or subwindow outside a window", |
2543 instantiator); | 2545 instantiator); |
2544 instance = Fgethash (instantiator, | 2546 instance = Fgethash (instantiator, |
2545 XWINDOW (domain)->subwindow_instance_cache, | 2547 XWINDOW (domain)->subwindow_instance_cache, |
2546 Qunbound); | 2548 Qunbound); |
2547 } | 2549 } |
2729 } | 2731 } |
2730 | 2732 |
2731 UNGCPRO; | 2733 UNGCPRO; |
2732 | 2734 |
2733 return retlist; | 2735 return retlist; |
2736 } | |
2737 | |
2738 /* Copy an image instantiator. We can't use Fcopy_tree since widgets | |
2739 may contain circular references which would send Fcopy_tree into | |
2740 infloop death. */ | |
2741 static Lisp_Object | |
2742 image_copy_vector_instantiator (Lisp_Object instantiator) | |
2743 { | |
2744 int i; | |
2745 struct image_instantiator_methods *meths; | |
2746 Lisp_Object *elt; | |
2747 int instantiator_len; | |
2748 | |
2749 CHECK_VECTOR (instantiator); | |
2750 | |
2751 instantiator = Fcopy_sequence (instantiator); | |
2752 elt = XVECTOR_DATA (instantiator); | |
2753 instantiator_len = XVECTOR_LENGTH (instantiator); | |
2754 | |
2755 meths = decode_image_instantiator_format (elt[0], ERROR_ME); | |
2756 | |
2757 for (i = 1; i < instantiator_len; i += 2) | |
2758 { | |
2759 int j; | |
2760 Lisp_Object keyword = elt[i]; | |
2761 Lisp_Object value = elt[i+1]; | |
2762 | |
2763 /* Find the keyword entry. */ | |
2764 for (j = 0; j < Dynarr_length (meths->keywords); j++) | |
2765 { | |
2766 if (EQ (keyword, Dynarr_at (meths->keywords, j).keyword)) | |
2767 break; | |
2768 } | |
2769 | |
2770 /* Only copy keyword values that should be copied. */ | |
2771 if (Dynarr_at (meths->keywords, j).copy_p | |
2772 && | |
2773 (CONSP (value) || VECTORP (value))) | |
2774 { | |
2775 elt [i+1] = Fcopy_tree (value, Qt); | |
2776 } | |
2777 } | |
2778 | |
2779 return instantiator; | |
2780 } | |
2781 | |
2782 static Lisp_Object | |
2783 image_copy_instantiator (Lisp_Object arg) | |
2784 { | |
2785 if (CONSP (arg)) | |
2786 { | |
2787 Lisp_Object rest; | |
2788 rest = arg = Fcopy_sequence (arg); | |
2789 while (CONSP (rest)) | |
2790 { | |
2791 Lisp_Object elt = XCAR (rest); | |
2792 if (CONSP (elt)) | |
2793 XCAR (rest) = Fcopy_tree (elt, Qt); | |
2794 else if (VECTORP (elt)) | |
2795 XCAR (rest) = image_copy_vector_instantiator (elt); | |
2796 if (VECTORP (XCDR (rest))) /* hack for (a b . [c d]) */ | |
2797 XCDR (rest) = Fcopy_tree (XCDR (rest), Qt); | |
2798 rest = XCDR (rest); | |
2799 } | |
2800 } | |
2801 else if (VECTORP (arg)) | |
2802 { | |
2803 arg = image_copy_vector_instantiator (arg); | |
2804 } | |
2805 return arg; | |
2734 } | 2806 } |
2735 | 2807 |
2736 DEFUN ("image-specifier-p", Fimage_specifier_p, 1, 1, 0, /* | 2808 DEFUN ("image-specifier-p", Fimage_specifier_p, 1, 1, 0, /* |
2737 Return non-nil if OBJECT is an image specifier. | 2809 Return non-nil if OBJECT is an image specifier. |
2738 | 2810 |
4471 SPECIFIER_HAS_METHOD (image, mark); | 4543 SPECIFIER_HAS_METHOD (image, mark); |
4472 SPECIFIER_HAS_METHOD (image, instantiate); | 4544 SPECIFIER_HAS_METHOD (image, instantiate); |
4473 SPECIFIER_HAS_METHOD (image, validate); | 4545 SPECIFIER_HAS_METHOD (image, validate); |
4474 SPECIFIER_HAS_METHOD (image, after_change); | 4546 SPECIFIER_HAS_METHOD (image, after_change); |
4475 SPECIFIER_HAS_METHOD (image, going_to_add); | 4547 SPECIFIER_HAS_METHOD (image, going_to_add); |
4548 SPECIFIER_HAS_METHOD (image, copy_instantiator); | |
4476 } | 4549 } |
4477 | 4550 |
4478 void | 4551 void |
4479 reinit_specifier_type_create_image (void) | 4552 reinit_specifier_type_create_image (void) |
4480 { | 4553 { |