Mercurial > hg > xemacs-beta
comparison lwlib/lwlib-Xaw.c @ 3094:ad2f4ae9895b
[xemacs-hg @ 2005-11-26 11:45:47 by stephent]
Xft merge. <87k6ev4p8q.fsf@tleepslib.sk.tsukuba.ac.jp>
author | stephent |
---|---|
date | Sat, 26 Nov 2005 11:46:25 +0000 |
parents | 04bc9d2f42c7 |
children | 174eb4da74fb |
comparison
equal
deleted
inserted
replaced
3093:769dc945b085 | 3094:ad2f4ae9895b |
---|---|
50 #endif | 50 #endif |
51 #include <X11/Xatom.h> | 51 #include <X11/Xatom.h> |
52 | 52 |
53 static void xaw_generic_callback (Widget, XtPointer, XtPointer); | 53 static void xaw_generic_callback (Widget, XtPointer, XtPointer); |
54 | 54 |
55 extern int debug_xft; | |
55 | 56 |
56 Boolean | 57 Boolean |
57 lw_xaw_widget_p (Widget widget) | 58 lw_xaw_widget_p (Widget widget) |
58 { | 59 { |
59 return (0 | 60 return (0 |
736 | 737 |
737 /* add any args the user supplied for creation time */ | 738 /* add any args the user supplied for creation time */ |
738 lw_add_value_args_to_args (val, al, &ac); | 739 lw_add_value_args_to_args (val, al, &ac); |
739 | 740 |
740 if (!val->call_data) | 741 if (!val->call_data) |
741 button = XtCreateManagedWidget (val->name, labelWidgetClass, | 742 button = XtCreateWidget (val->name, labelWidgetClass, |
742 instance->parent, al, ac); | 743 instance->parent, al, ac); |
743 | 744 |
744 else | 745 else |
745 { | 746 { |
746 if (val->type == TOGGLE_TYPE || val->type == RADIO_TYPE) | 747 if (val->type == TOGGLE_TYPE || val->type == RADIO_TYPE) |
747 { | 748 { |
748 XtSetArg (al [ac], XtNstate, val->selected); ac++; | 749 XtSetArg (al [ac], XtNstate, val->selected); ac++; |
749 button = XtCreateManagedWidget | 750 button = XtCreateWidget |
750 (val->name, | 751 (val->name, |
751 val->type == TOGGLE_TYPE ? checkboxWidgetClass : radioWidgetClass, | 752 val->type == TOGGLE_TYPE ? checkboxWidgetClass : radioWidgetClass, |
752 instance->parent, al, ac); | 753 instance->parent, al, ac); |
753 } | 754 } |
754 else | 755 else |
755 { | 756 { |
756 button = XtCreateManagedWidget (val->name, commandWidgetClass, | 757 button = XtCreateWidget (val->name, commandWidgetClass, |
757 instance->parent, al, ac); | 758 instance->parent, al, ac); |
758 } | 759 } |
759 XtRemoveAllCallbacks (button, XtNcallback); | 760 XtRemoveAllCallbacks (button, XtNcallback); |
760 XtAddCallback (button, XtNcallback, xaw_generic_callback, (XtPointer)instance); | 761 XtAddCallback (button, XtNcallback, xaw_generic_callback, (XtPointer)instance); |
761 } | 762 } |
762 | 763 |
764 /* #### this maybe can be folded into the XtCreateWidget calls above */ | |
763 XtManageChild (button); | 765 XtManageChild (button); |
764 | 766 |
765 return button; | 767 return button; |
766 } | 768 } |
767 | 769 |
786 lw_add_value_args_to_args (val, al, &ac); | 788 lw_add_value_args_to_args (val, al, &ac); |
787 | 789 |
788 label = XtCreateManagedWidget (val->name, labelWidgetClass, | 790 label = XtCreateManagedWidget (val->name, labelWidgetClass, |
789 parent, al, ac); | 791 parent, al, ac); |
790 | 792 |
791 /* Do it again for arguments that have no effect until the widget is realized. */ | 793 /* Do it again for arguments that have no effect until the widget is realized. |
794 #### Uh, but the widget isn't realized until later? Do we mean "created"? */ | |
792 ac = 0; | 795 ac = 0; |
793 lw_add_value_args_to_args (val, al, &ac); | 796 lw_add_value_args_to_args (val, al, &ac); |
794 if (ac > 20) | 797 if (ac > 20) |
795 abort (); /* #### need assert macro in lwlib */ | 798 abort (); /* #### need assert macro in lwlib */ |
796 XtSetValues (label, al, ac); | 799 XtSetValues (label, al, ac); |
797 | 800 |
798 return label; | 801 return label; |
802 } | |
803 | |
804 static int debug_gauge = 0; | |
805 | |
806 static void | |
807 lw_debug_print_xt_arglist (ArgList al, int ac) | |
808 { | |
809 int i; | |
810 for (i = 0; i < ac; i++) | |
811 fprintf (stderr, "Widget has arg %s with value %lu.\n", | |
812 al[i].name, (unsigned long) al[i].value); | |
813 } | |
814 | |
815 static void | |
816 lw_debug_print_class_resources (WidgetClass class_) | |
817 { | |
818 Cardinal i; | |
819 do { | |
820 Cardinal m, n = class_->core_class.num_resources; | |
821 XtResourceList rl; | |
822 fprintf (stderr, "Class is %s (%p/%p) with %d resources.\n", | |
823 class_->core_class.class_name, class_, &(class_->core_class), n); | |
824 fprintf (stderr, " Class's resources are at %p. Converting...\n", | |
825 class_->core_class.resources); | |
826 /* resources may be compiled to an internal format */ | |
827 XtGetResourceList (class_, &rl, &m); | |
828 for (i = 0; i < m; i++) | |
829 fprintf (stderr, | |
830 " Class has a %s resource of type %s initialized from %s.\n", | |
831 rl[i].resource_class, rl[i].resource_type, rl[i].default_type); | |
832 /* special cases for commonly problematic resources */ | |
833 for (i = 0; i < m; i++) | |
834 { | |
835 if (!strcmp (rl[i].resource_class, "Font")) | |
836 { | |
837 fprintf (stderr, " Class has a Font resource.\n"); | |
838 fprintf (stderr, " Font resource is %s.\n", | |
839 (char *) rl[i].default_addr); | |
840 } | |
841 if (!strcmp (rl[i].resource_class, "FontSet")) | |
842 { | |
843 fprintf (stderr, " Class has a FontSet resource.\n"); | |
844 fprintf (stderr, " FontSet resource is %s.\n", | |
845 (char *) rl[i].default_addr); | |
846 } | |
847 if (!strcmp (rl[i].resource_class, "International")) | |
848 { | |
849 fprintf (stderr, " Class has an International resource.\n"); | |
850 fprintf (stderr, " International resource is %d.\n", | |
851 (int) rl[i].default_addr); | |
852 } | |
853 } | |
854 class_ = class_->core_class.superclass; | |
855 } while (class_ != NULL); | |
799 } | 856 } |
800 | 857 |
801 static Widget | 858 static Widget |
802 xaw_create_progress (widget_instance *instance) | 859 xaw_create_progress (widget_instance *instance) |
803 { | 860 { |
824 XtSetArg (al [ac], XtNntics, (Cardinal)10);ac++; | 881 XtSetArg (al [ac], XtNntics, (Cardinal)10);ac++; |
825 | 882 |
826 /* add any args the user supplied for creation time */ | 883 /* add any args the user supplied for creation time */ |
827 lw_add_value_args_to_args (val, al, &ac); | 884 lw_add_value_args_to_args (val, al, &ac); |
828 | 885 |
829 scale = XtCreateManagedWidget (val->name, gaugeWidgetClass, | 886 if (debug_gauge > 1) |
830 instance->parent, al, ac); | 887 lw_debug_print_class_resources (gaugeWidgetClass); |
888 if (debug_gauge > 0) | |
889 lw_debug_print_xt_arglist (al, ac); | |
890 | |
891 scale = XtCreateWidget (val->name, gaugeWidgetClass, | |
892 instance->parent, al, ac); | |
893 | |
831 /* add the callback */ | 894 /* add the callback */ |
832 if (val->call_data) | 895 if (val->call_data) |
833 XtAddCallback (scale, XtNgetValue, xaw_generic_callback, (XtPointer)instance); | 896 XtAddCallback (scale, XtNgetValue, xaw_generic_callback, |
834 | 897 (XtPointer) instance); |
898 | |
899 /* #### this maybe can be folded into the XtCreateWidget call above */ | |
835 XtManageChild (scale); | 900 XtManageChild (scale); |
836 | 901 |
837 return scale; | 902 return scale; |
838 } | 903 } |
839 | 904 |
862 } | 927 } |
863 | 928 |
864 /* add any args the user supplied for creation time */ | 929 /* add any args the user supplied for creation time */ |
865 lw_add_value_args_to_args (val, al, &ac); | 930 lw_add_value_args_to_args (val, al, &ac); |
866 | 931 |
867 text = XtCreateManagedWidget (val->name, asciiTextWidgetClass, | 932 text = XtCreateWidget (val->name, asciiTextWidgetClass, |
868 instance->parent, al, ac); | 933 instance->parent, al, ac); |
869 | 934 |
870 /* add the callback */ | 935 /* add the callback */ |
871 if (val->call_data) | 936 if (val->call_data) |
872 XtAddCallback (text, XtNgetValue, xaw_generic_callback, (XtPointer)instance); | 937 XtAddCallback (text, XtNgetValue, xaw_generic_callback, (XtPointer)instance); |