comparison lwlib/lwlib-Xm.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 697ef44129c6
children 11054d720c21
comparison
equal deleted inserted replaced
419:66615b78f1a5 420:41dbb7a9d5f2
2 Copyright (C) 1992, 1993, 1994 Lucid, Inc. 2 Copyright (C) 1992, 1993, 1994 Lucid, Inc.
3 Copyright (C) 1995 Tinker Systems and INS Engineering Corp. 3 Copyright (C) 1995 Tinker Systems and INS Engineering Corp.
4 4
5 This file is part of the Lucid Widget Library. 5 This file is part of the Lucid Widget Library.
6 6
7 The Lucid Widget Library is free software; you can redistribute it and/or 7 The Lucid Widget Library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License as published by 8 modify it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option) 9 the Free Software Foundation; either version 2, or (at your option)
10 any later version. 10 any later version.
11 11
12 The Lucid Widget Library is distributed in the hope that it will be useful, 12 The Lucid Widget Library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details. 15 GNU General Public License for more details.
16 16
17 You should have received a copy of the GNU General Public License 17 You should have received a copy of the GNU General Public License
18 along with XEmacs; see the file COPYING. If not, write to 18 along with XEmacs; see the file COPYING. If not, write to
58 #include <Xm/RowColumn.h> 58 #include <Xm/RowColumn.h>
59 #include <Xm/ScrolledW.h> 59 #include <Xm/ScrolledW.h>
60 #include <Xm/Separator.h> 60 #include <Xm/Separator.h>
61 #include <Xm/DialogS.h> 61 #include <Xm/DialogS.h>
62 #include <Xm/Form.h> 62 #include <Xm/Form.h>
63 #include <Xm/Scale.h>
64 #if XmVERSION > 1
65 #include <Xm/ComboBox.h>
66 #endif
63 67
64 #ifdef LWLIB_MENUBARS_MOTIF 68 #ifdef LWLIB_MENUBARS_MOTIF
65 static void xm_pull_down_callback (Widget, XtPointer, XtPointer); 69 static void xm_pull_down_callback (Widget, XtPointer, XtPointer);
66 #if 0
67 static void xm_pop_down_callback (Widget, XtPointer, XtPointer);
68 #endif /* 0 */
69 #endif 70 #endif
70 static void xm_internal_update_other_instances (Widget, XtPointer, 71 static void xm_internal_update_other_instances (Widget, XtPointer,
71 XtPointer); 72 XtPointer);
73 static void xm_pop_down_callback (Widget, XtPointer, XtPointer);
72 static void xm_generic_callback (Widget, XtPointer, XtPointer); 74 static void xm_generic_callback (Widget, XtPointer, XtPointer);
73 #ifdef LWLIB_DIALOGS_MOTIF 75 #ifdef LWLIB_DIALOGS_MOTIF
74 static void xm_nosel_callback (Widget, XtPointer, XtPointer); 76 static void xm_nosel_callback (Widget, XtPointer, XtPointer);
75 #endif 77 #endif
76 #ifdef LWLIB_SCROLLBARS_MOTIF 78 #ifdef LWLIB_SCROLLBARS_MOTIF
82 xm_update_menu (widget_instance* instance, Widget widget, widget_value* val, 84 xm_update_menu (widget_instance* instance, Widget widget, widget_value* val,
83 Boolean deep_p); 85 Boolean deep_p);
84 #endif 86 #endif
85 87
86 /* Structures to keep destroyed instances */ 88 /* Structures to keep destroyed instances */
87 typedef struct _destroyed_instance 89 typedef struct _destroyed_instance
88 { 90 {
89 char* name; 91 char* name;
90 char* type; 92 char* type;
91 Widget widget; 93 Widget widget;
92 Widget parent; 94 Widget parent;
122 instance->parent = parent; 124 instance->parent = parent;
123 instance->pop_up_p = pop_up_p; 125 instance->pop_up_p = pop_up_p;
124 instance->next = NULL; 126 instance->next = NULL;
125 return instance; 127 return instance;
126 } 128 }
127 129
128 static void 130 static void
129 free_destroyed_instance (destroyed_instance* instance) 131 free_destroyed_instance (destroyed_instance* instance)
130 { 132 {
131 free (instance->name); 133 free (instance->name);
132 free (instance->type); 134 free (instance->type);
141 } 143 }
142 144
143 Boolean 145 Boolean
144 lw_motif_widget_p (Widget widget) 146 lw_motif_widget_p (Widget widget)
145 { 147 {
146 return 148 return
147 #ifdef LWLIB_DIALOGS_MOTIF 149 #ifdef LWLIB_DIALOGS_MOTIF
148 XtClass (widget) == xmDialogShellWidgetClass || 150 XtClass (widget) == xmDialogShellWidgetClass ||
149 #endif 151 #endif
150 XmIsPrimitive (widget) || XmIsManager (widget) || XmIsGadget (widget); 152 XmIsPrimitive (widget) || XmIsManager (widget) || XmIsGadget (widget);
151 } 153 }
153 static char * 155 static char *
154 resource_string (Widget widget, char *name) 156 resource_string (Widget widget, char *name)
155 { 157 {
156 XtResource resource; 158 XtResource resource;
157 char *result = NULL; 159 char *result = NULL;
158 160
159 resource.resource_name = "labelString"; 161 resource.resource_name = "labelString";
160 resource.resource_class = "LabelString"; /* #### should be Xmsomething... */ 162 resource.resource_class = "LabelString"; /* #### should be Xmsomething... */
161 resource.resource_type = XtRString; 163 resource.resource_type = XtRString;
162 resource.resource_size = sizeof (String); 164 resource.resource_size = sizeof (String);
163 resource.resource_offset = 0; 165 resource.resource_offset = 0;
179 int i; 181 int i;
180 182
181 children = XtCompositeChildren (widget, &number); 183 children = XtCompositeChildren (widget, &number);
182 if (children) 184 if (children)
183 { 185 {
184 /* Unmanage all children and destroy them. They will only be 186 /* Unmanage all children and destroy them. They will only be
185 * really destroyed when we get out of DispatchEvent. */ 187 * really destroyed when we get out of DispatchEvent. */
186 for (i = 0; i < number; i++) 188 for (i = 0; i < number; i++)
187 { 189 {
188 Widget child = children [i]; 190 Widget child = children [i];
189 if (!child->core.being_destroyed) 191 if (!child->core.being_destroyed)
281 } 283 }
282 284
283 XtSetArg (al [ac], XmNlabelString, built_string); ac++; 285 XtSetArg (al [ac], XmNlabelString, built_string); ac++;
284 XtSetArg (al [ac], XmNlabelType, XmSTRING); ac++; 286 XtSetArg (al [ac], XmNlabelType, XmSTRING); ac++;
285 } 287 }
286 288
287 if (val->key) 289 if (val->key)
288 { 290 {
289 key_string = XmStringCreateLtoR (val->key, XmSTRING_DEFAULT_CHARSET); 291 key_string = XmStringCreateLtoR (val->key, XmSTRING_DEFAULT_CHARSET);
290 XtSetArg (al [ac], XmNacceleratorText, key_string); ac++; 292 XtSetArg (al [ac], XmNacceleratorText, key_string); ac++;
291 } 293 }
361 363
362 } else { 364 } else {
363 XtRemoveAllCallbacks (widget, XmNcascadingCallback); 365 XtRemoveAllCallbacks (widget, XmNcascadingCallback);
364 XtAddCallback (widget, XmNcascadingCallback, xm_pull_down_callback, 366 XtAddCallback (widget, XmNcascadingCallback, xm_pull_down_callback,
365 instance); 367 instance);
366 } 368 }
367 } 369 }
368 370
369 #endif /* LWLIB_MENUBARS_MOTIF */ 371 #endif /* LWLIB_MENUBARS_MOTIF */
370 372
371 /* update toggle and radiobox */ 373 /* update toggle and radiobox */
457 xm_pop_down_callback, (XtPointer)instance); 459 xm_pop_down_callback, (XtPointer)instance);
458 */ 460 */
459 461
460 num_children = 0; 462 num_children = 0;
461 for (child_index = 0, cur = val; cur; child_index++, cur = cur->next) 463 for (child_index = 0, cur = val; cur; child_index++, cur = cur->next)
462 { 464 {
463 ac = 0; 465 ac = 0;
464 button = 0; 466 button = 0;
465 XtSetArg (al [ac], XmNsensitive, cur->enabled); ac++; 467 XtSetArg (al [ac], XmNsensitive, cur->enabled); ac++;
466 XtSetArg (al [ac], XmNalignment, XmALIGNMENT_BEGINNING); ac++; 468 XtSetArg (al [ac], XmNalignment, XmALIGNMENT_BEGINNING); ac++;
467 XtSetArg (al [ac], XmNuserData, cur->call_data); ac++; 469 XtSetArg (al [ac], XmNuserData, cur->call_data); ac++;
575 577
576 /* update the pulldown/pullaside as needed */ 578 /* update the pulldown/pullaside as needed */
577 menu = NULL; 579 menu = NULL;
578 XtSetArg (al [0], XmNsubMenuId, &menu); 580 XtSetArg (al [0], XmNsubMenuId, &menu);
579 XtGetValues (widget, al, 1); 581 XtGetValues (widget, al, 1);
580 582
581 contents = val->contents; 583 contents = val->contents;
582 584
583 if (!menu) 585 if (!menu)
584 { 586 {
585 if (contents) 587 if (contents)
656 } 658 }
657 659
658 #endif /* LWLIB_MENUBARS_MOTIF */ 660 #endif /* LWLIB_MENUBARS_MOTIF */
659 661
660 662
661 #ifdef LWLIB_DIALOGS_MOTIF
662
663 /* update text widgets */ 663 /* update text widgets */
664 664
665 static void 665 static void
666 xm_update_text (widget_instance* instance, Widget widget, widget_value* val) 666 xm_update_text (widget_instance* instance, Widget widget, widget_value* val)
667 { 667 {
683 XtRemoveAllCallbacks (widget, XmNvalueChangedCallback); 683 XtRemoveAllCallbacks (widget, XmNvalueChangedCallback);
684 XtAddCallback (widget, XmNvalueChangedCallback, 684 XtAddCallback (widget, XmNvalueChangedCallback,
685 xm_internal_update_other_instances, instance); 685 xm_internal_update_other_instances, instance);
686 } 686 }
687 687
688 #endif /* LWLIB_DIALOGS_MOTIF */
689 688
690 #ifdef LWLIB_SCROLLBARS_MOTIF 689 #ifdef LWLIB_SCROLLBARS_MOTIF
691 690
692 /* 691 /*
693 * If this function looks like it does a lot more work than it needs to, 692 * If this function looks like it does a lot more work than it needs to,
767 xm_update_one_widget (widget_instance* instance, Widget widget, 766 xm_update_one_widget (widget_instance* instance, Widget widget,
768 widget_value* val, Boolean deep_p) 767 widget_value* val, Boolean deep_p)
769 { 768 {
770 WidgetClass class; 769 WidgetClass class;
771 Arg al [2]; 770 Arg al [2];
772 771
773 /* Mark as not edited */ 772 /* Mark as not edited */
774 val->edited = False; 773 val->edited = False;
775 774
776 /* Common to all widget types */ 775 /* Common to all widget types */
777 XtSetArg (al [0], XmNsensitive, val->enabled); 776 XtSetArg (al [0], XmNsensitive, val->enabled);
780 779
781 #if defined (LWLIB_DIALOGS_MOTIF) || defined (LWLIB_MENUBARS_MOTIF) 780 #if defined (LWLIB_DIALOGS_MOTIF) || defined (LWLIB_MENUBARS_MOTIF)
782 /* Common to all label like widgets */ 781 /* Common to all label like widgets */
783 if (XtIsSubclass (widget, xmLabelWidgetClass)) 782 if (XtIsSubclass (widget, xmLabelWidgetClass))
784 xm_update_label (instance, widget, val); 783 xm_update_label (instance, widget, val);
785 #endif 784 #endif /* defined (LWLIB_DIALOGS_MOTIF) || defined (LWLIB_MENUBARS_MOTIF) */
786 785
787 class = XtClass (widget); 786 class = XtClass (widget);
788 /* Class specific things */ 787 /* Class specific things */
789 if (class == xmPushButtonWidgetClass || 788 if (class == xmPushButtonWidgetClass ||
790 class == xmArrowButtonWidgetClass) 789 class == xmArrowButtonWidgetClass)
791 { 790 {
806 { 805 {
807 Boolean radiobox = 0; 806 Boolean radiobox = 0;
808 807
809 XtSetArg (al [0], XmNradioBehavior, &radiobox); 808 XtSetArg (al [0], XmNradioBehavior, &radiobox);
810 XtGetValues (widget, al, 1); 809 XtGetValues (widget, al, 1);
811 810
812 if (radiobox) 811 if (radiobox)
813 xm_update_radiobox (instance, widget, val); 812 xm_update_radiobox (instance, widget, val);
814 #ifdef LWLIB_MENUBARS_MOTIF 813 #ifdef LWLIB_MENUBARS_MOTIF
815 else 814 else
816 xm_update_menu (instance, widget, val, deep_p); 815 xm_update_menu (instance, widget, val, deep_p);
817 #endif 816 #endif
818 } 817 }
819 #ifdef LWLIB_DIALOGS_MOTIF
820 else if (class == xmTextWidgetClass) 818 else if (class == xmTextWidgetClass)
821 { 819 {
822 xm_update_text (instance, widget, val); 820 xm_update_text (instance, widget, val);
823 } 821 }
824 else if (class == xmTextFieldWidgetClass) 822 else if (class == xmTextFieldWidgetClass)
825 { 823 {
826 xm_update_text_field (instance, widget, val); 824 xm_update_text_field (instance, widget, val);
827 } 825 }
828 #endif
829 else if (class == xmListWidgetClass) 826 else if (class == xmListWidgetClass)
830 { 827 {
831 xm_update_list (instance, widget, val); 828 xm_update_list (instance, widget, val);
832 } 829 }
833 #ifdef LWLIB_SCROLLBARS_MOTIF 830 #ifdef LWLIB_SCROLLBARS_MOTIF
851 if (!strcmp (val->name, old_wv->name)) 848 if (!strcmp (val->name, old_wv->name))
852 { 849 {
853 val->call_data = old_wv->call_data; 850 val->call_data = old_wv->call_data;
854 break; 851 break;
855 } 852 }
856 853
857 if (class == xmToggleButtonWidgetClass || class == xmToggleButtonGadgetClass) 854 if (class == xmToggleButtonWidgetClass || class == xmToggleButtonGadgetClass)
858 { 855 {
859 Arg al [1]; 856 Arg al [1];
860 XtSetArg (al [0], XmNset, &val->selected); 857 XtSetArg (al [0], XmNset, &val->selected);
861 XtGetValues (widget, al, 1); 858 XtGetValues (widget, al, 1);
862 val->edited = True; 859 val->edited = True;
863 } 860 }
864 #ifdef LWLIB_DIALOGS_MOTIF
865 else if (class == xmTextWidgetClass) 861 else if (class == xmTextWidgetClass)
866 { 862 {
867 if (val->value) 863 if (val->value)
868 free (val->value); 864 free (val->value);
869 val->value = XmTextGetString (widget); 865 val->value = XmTextGetString (widget);
874 if (val->value) 870 if (val->value)
875 free (val->value); 871 free (val->value);
876 val->value = XmTextFieldGetString (widget); 872 val->value = XmTextFieldGetString (widget);
877 val->edited = True; 873 val->edited = True;
878 } 874 }
879 #endif
880 else if (class == xmRowColumnWidgetClass) 875 else if (class == xmRowColumnWidgetClass)
881 { 876 {
882 Boolean radiobox = 0; 877 Boolean radiobox = 0;
883 { 878 {
884 Arg al [1]; 879 Arg al [1];
944 939
945 940
946 /* This function is for activating a button from a program. It's wrong because 941 /* This function is for activating a button from a program. It's wrong because
947 we pass a NULL argument in the call_data which is not Motif compatible. 942 we pass a NULL argument in the call_data which is not Motif compatible.
948 This is used from the XmNdefaultAction callback of the List widgets to 943 This is used from the XmNdefaultAction callback of the List widgets to
949 have a dble-click put down a dialog box like the button woudl do. 944 have a double-click put down a dialog box like the button would do.
950 I could not find a way to do that with accelerators. 945 I could not find a way to do that with accelerators.
951 */ 946 */
952 static void 947 static void
953 activate_button (Widget widget, XtPointer closure, XtPointer call_data) 948 activate_button (Widget widget, XtPointer closure, XtPointer call_data)
954 { 949 {
994 989
995 #ifdef DND_KLUDGE 990 #ifdef DND_KLUDGE
996 /* This is a kludge to disable drag-and-drop in dialog boxes. The symptom 991 /* This is a kludge to disable drag-and-drop in dialog boxes. The symptom
997 was a segv down in libXm somewhere if you used the middle button on a 992 was a segv down in libXm somewhere if you used the middle button on a
998 dialog box to begin a drag; when you released the button to make a drop 993 dialog box to begin a drag; when you released the button to make a drop
999 things would lose if you were not over the button where you started the 994 things would lose if you were not over the button where you started the
1000 drag (canceling the operation). This was probably due to the fact that 995 drag (canceling the operation). This was probably due to the fact that
1001 the dialog boxes were not set up to handle a drag but were trying to do 996 the dialog boxes were not set up to handle a drag but were trying to do
1002 so anyway for some reason. 997 so anyway for some reason.
1003 998
1004 So we disable drag-and-drop in dialog boxes by turning off the binding for 999 So we disable drag-and-drop in dialog boxes by turning off the binding for
1027 Widget children [16]; /* for the final XtManageChildren */ 1022 Widget children [16]; /* for the final XtManageChildren */
1028 int n_children; 1023 int n_children;
1029 Arg al[64]; /* Arg List */ 1024 Arg al[64]; /* Arg List */
1030 int ac; /* Arg Count */ 1025 int ac; /* Arg Count */
1031 int i; 1026 int i;
1032 1027
1033 #ifdef DND_KLUDGE 1028 #ifdef DND_KLUDGE
1034 XtTranslations dnd_override = XtParseTranslationTable (disable_dnd_trans); 1029 XtTranslations dnd_override = XtParseTranslationTable (disable_dnd_trans);
1035 # define DO_DND_KLUDGE(widget) XtOverrideTranslations ((widget), dnd_override) 1030 # define DO_DND_KLUDGE(widget) XtOverrideTranslations ((widget), dnd_override)
1036 #else /* ! DND_KLUDGE */ 1031 #else /* ! DND_KLUDGE */
1037 # define DO_DND_KLUDGE(widget) 1032 # define DO_DND_KLUDGE(widget)
1075 XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++; 1070 XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
1076 XtSetArg(al[ac], XmNleftOffset, 13); ac++; 1071 XtSetArg(al[ac], XmNleftOffset, 13); ac++;
1077 XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++; 1072 XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
1078 XtSetArg(al[ac], XmNrightOffset, 13); ac++; 1073 XtSetArg(al[ac], XmNrightOffset, 13); ac++;
1079 row = XmCreateRowColumn (form, "row", al, ac); 1074 row = XmCreateRowColumn (form, "row", al, ac);
1080 1075
1081 n_children = 0; 1076 n_children = 0;
1082 for (i = 0; i < left_buttons; i++) 1077 for (i = 0; i < left_buttons; i++)
1083 { 1078 {
1084 char button_name [16]; 1079 char button_name [16];
1085 sprintf (button_name, "button%d", i + 1); 1080 sprintf (button_name, "button%d", i + 1);
1117 XtSetArg (al[ac], XmNmappedWhenManaged, FALSE); ac++; 1112 XtSetArg (al[ac], XmNmappedWhenManaged, FALSE); ac++;
1118 children [n_children] = XmCreateLabel (row, "separator_button", 1113 children [n_children] = XmCreateLabel (row, "separator_button",
1119 al, ac); 1114 al, ac);
1120 DO_DND_KLUDGE (children [n_children]); 1115 DO_DND_KLUDGE (children [n_children]);
1121 n_children++; 1116 n_children++;
1122 1117
1123 for (i = 0; i < right_buttons; i++) 1118 for (i = 0; i < right_buttons; i++)
1124 { 1119 {
1125 char button_name [16]; 1120 char button_name [16];
1126 sprintf (button_name, "button%d", left_buttons + i + 1); 1121 sprintf (button_name, "button%d", left_buttons + i + 1);
1127 ac = 0; 1122 ac = 0;
1129 children [n_children] = XmCreatePushButton (row, button_name, al, ac); 1124 children [n_children] = XmCreatePushButton (row, button_name, al, ac);
1130 DO_DND_KLUDGE (children [n_children]); 1125 DO_DND_KLUDGE (children [n_children]);
1131 if (! button) button = children [n_children]; 1126 if (! button) button = children [n_children];
1132 n_children++; 1127 n_children++;
1133 } 1128 }
1134 1129
1135 XtManageChildren (children, n_children); 1130 XtManageChildren (children, n_children);
1136 1131
1137 ac = 0; 1132 ac = 0;
1138 XtSetArg(al[ac], XmNtopAttachment, XmATTACH_NONE); ac++; 1133 XtSetArg(al[ac], XmNtopAttachment, XmATTACH_NONE); ac++;
1139 XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_WIDGET); ac++; 1134 XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_WIDGET); ac++;
1140 XtSetArg(al[ac], XmNbottomOffset, 13); ac++; 1135 XtSetArg(al[ac], XmNbottomOffset, 13); ac++;
1141 XtSetArg(al[ac], XmNbottomWidget, row); ac++; 1136 XtSetArg(al[ac], XmNbottomWidget, row); ac++;
1230 1225
1231 /* this is the easiest way I found to have the dble click in the 1226 /* this is the easiest way I found to have the dble click in the
1232 list activate the default button */ 1227 list activate the default button */
1233 XtAddCallback (value, XmNdefaultActionCallback, activate_button, button); 1228 XtAddCallback (value, XmNdefaultActionCallback, activate_button, button);
1234 } 1229 }
1235 1230
1236 ac = 0; 1231 ac = 0;
1237 XtSetArg(al[ac], XmNalignment, XmALIGNMENT_BEGINNING); ac++; 1232 XtSetArg(al[ac], XmNalignment, XmALIGNMENT_BEGINNING); ac++;
1238 XtSetArg(al[ac], XmNtopAttachment, XmATTACH_FORM); ac++; 1233 XtSetArg(al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
1239 XtSetArg(al[ac], XmNtopOffset, 13); ac++; 1234 XtSetArg(al[ac], XmNtopOffset, 13); ac++;
1240 XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_WIDGET); ac++; 1235 XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_WIDGET); ac++;
1246 XtSetArg(al[ac], XmNleftWidget, icon); ac++; 1241 XtSetArg(al[ac], XmNleftWidget, icon); ac++;
1247 XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++; 1242 XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
1248 XtSetArg(al[ac], XmNrightOffset, 13); ac++; 1243 XtSetArg(al[ac], XmNrightOffset, 13); ac++;
1249 message = XmCreateLabel (form, "message", al, ac); 1244 message = XmCreateLabel (form, "message", al, ac);
1250 DO_DND_KLUDGE (message); 1245 DO_DND_KLUDGE (message);
1251 1246
1252 if (list) 1247 if (list)
1253 XtManageChild (value); 1248 XtManageChild (value);
1254 1249
1255 i = 0; 1250 i = 0;
1256 children [i] = row; i++; 1251 children [i] = row; i++;
1261 } 1256 }
1262 children [i] = message; i++; 1257 children [i] = message; i++;
1263 children [i] = icon; i++; 1258 children [i] = icon; i++;
1264 children [i] = icon_separator; i++; 1259 children [i] = icon_separator; i++;
1265 XtManageChildren (children, i); 1260 XtManageChildren (children, i);
1266 1261
1267 if (text_input_slot || list) 1262 if (text_input_slot || list)
1268 { 1263 {
1269 XtInstallAccelerators (value, button); 1264 XtInstallAccelerators (value, button);
1270 XmProcessTraversal(value, XmTRAVERSE_CURRENT); 1265 XmProcessTraversal(value, XmTRAVERSE_CURRENT);
1271 } 1266 }
1272 else 1267 else
1273 { 1268 {
1274 XtInstallAccelerators (form, button); 1269 XtInstallAccelerators (form, button);
1275 XmProcessTraversal(value, XmTRAVERSE_CURRENT); 1270 XmProcessTraversal(value, XmTRAVERSE_CURRENT);
1276 } 1271 }
1277 1272
1278 #ifdef DND_KLUDGE 1273 #ifdef DND_KLUDGE
1279 XtFree ((char *) dnd_override); 1274 XtFree ((char *) dnd_override);
1280 #endif 1275 #endif
1281 #undef DO_DND_KLUDGE 1276 #undef DO_DND_KLUDGE
1282 1277
1351 XtSetArg (al [1], XtNheight, &parent_height); 1346 XtSetArg (al [1], XtNheight, &parent_height);
1352 XtGetValues (parent, al, 2); 1347 XtGetValues (parent, al, 2);
1353 1348
1354 x = (Position) ((parent_width - child_width) / 2); 1349 x = (Position) ((parent_width - child_width) / 2);
1355 y = (Position) ((parent_height - child_height) / 2); 1350 y = (Position) ((parent_height - child_height) / 2);
1356 1351
1357 XtTranslateCoords (parent, x, y, &x, &y); 1352 XtTranslateCoords (parent, x, y, &x, &y);
1358 1353
1359 if ((Dimension) (x + child_width) > screen_width) 1354 if ((Dimension) (x + child_width) > screen_width)
1360 x = screen_width - child_width; 1355 x = screen_width - child_width;
1361 if (x < 0) 1356 if (x < 0)
1464 case 'Q': case 'q': 1459 case 'Q': case 'q':
1465 icon_name = "dbox-question"; 1460 icon_name = "dbox-question";
1466 shell_name = "Question"; 1461 shell_name = "Question";
1467 break; 1462 break;
1468 } 1463 }
1469 1464
1470 total_buttons = name [1] - '0'; 1465 total_buttons = name [1] - '0';
1471 1466
1472 if (name [3] == 'T' || name [3] == 't') 1467 if (name [3] == 'T' || name [3] == 't')
1473 { 1468 {
1474 text_input_slot = False; 1469 text_input_slot = False;
1475 radio_box = True; 1470 radio_box = True;
1476 } 1471 }
1477 else if (name [3]) 1472 else if (name [3])
1478 right_buttons = name [4] - '0'; 1473 right_buttons = name [4] - '0';
1479 1474
1480 left_buttons = total_buttons - right_buttons; 1475 left_buttons = total_buttons - right_buttons;
1481 1476
1482 widget = make_dialog (name, parent, pop_up_p, 1477 widget = make_dialog (name, parent, pop_up_p,
1483 shell_name, icon_name, text_input_slot, radio_box, 1478 shell_name, icon_name, text_input_slot, radio_box,
1484 list, left_buttons, right_buttons); 1479 list, left_buttons, right_buttons);
1485 1480
1486 XtAddCallback (widget, XmNpopdownCallback, xm_nosel_callback, 1481 XtAddCallback (widget, XmNpopdownCallback, xm_nosel_callback,
1535 int ac = 0; 1530 int ac = 0;
1536 static XtCallbackRec callbacks[2] = 1531 static XtCallbackRec callbacks[2] =
1537 { {xm_scrollbar_callback, NULL}, {NULL, NULL} }; 1532 { {xm_scrollbar_callback, NULL}, {NULL, NULL} };
1538 1533
1539 callbacks[0].closure = (XtPointer) instance; 1534 callbacks[0].closure = (XtPointer) instance;
1540 1535
1541 XtSetArg (al[ac], XmNminimum, 1); ac++; 1536 XtSetArg (al[ac], XmNminimum, 1); ac++;
1542 XtSetArg (al[ac], XmNmaximum, INT_MAX); ac++; 1537 XtSetArg (al[ac], XmNmaximum, INT_MAX); ac++;
1543 XtSetArg (al[ac], XmNincrement, 1); ac++; 1538 XtSetArg (al[ac], XmNincrement, 1); ac++;
1544 XtSetArg (al[ac], XmNpageIncrement, 1); ac++; 1539 XtSetArg (al[ac], XmNpageIncrement, 1); ac++;
1545 XtSetArg (al[ac], XmNborderWidth, 0); ac++; 1540 XtSetArg (al[ac], XmNborderWidth, 0); ac++;
1569 return make_scrollbar (instance, 0); 1564 return make_scrollbar (instance, 0);
1570 } 1565 }
1571 1566
1572 #endif /* LWLIB_SCROLLBARS_MOTIF */ 1567 #endif /* LWLIB_SCROLLBARS_MOTIF */
1573 1568
1574 /* Table of functions to create widgets */ 1569 /* glyph widgets */
1570 static Widget
1571 make_button (widget_instance *instance)
1572 {
1573 Arg al[20];
1574 int ac = 0;
1575 Widget button = 0;
1576 widget_value* val = instance->info->val;
1577
1578 XtSetArg (al [ac], XmNsensitive, val->enabled); ac++;
1579 XtSetArg (al [ac], XmNalignment, XmALIGNMENT_BEGINNING); ac++;
1580 XtSetArg (al [ac], XmNuserData, val->call_data); ac++;
1581 XtSetArg (al [ac], XmNmappedWhenManaged, FALSE); ac++;
1582 /* The highlight doesn't appear to be dynamically set which makes it
1583 look ugly. I think this may be a LessTif bug but for now we just
1584 get rid of it. */
1585 XtSetArg (al [ac], XmNhighlightThickness, (Dimension)0);ac++;
1586
1587 /* add any args the user supplied for creation time */
1588 lw_add_value_args_to_args (val, al, &ac);
1589
1590 if (!val->call_data)
1591 button = XmCreateLabel (instance->parent, val->name, al, ac);
1592
1593 else if (val->type == TOGGLE_TYPE || val->type == RADIO_TYPE)
1594 {
1595 XtSetArg (al [ac], XmNset, val->selected); ac++;
1596 XtSetArg (al [ac], XmNindicatorType,
1597 (val->type == TOGGLE_TYPE ?
1598 XmN_OF_MANY : XmONE_OF_MANY)); ac++;
1599 XtSetArg (al [ac], XmNvisibleWhenOff, True); ac++;
1600 button = XmCreateToggleButton (instance->parent, val->name, al, ac);
1601 XtRemoveAllCallbacks (button, XmNvalueChangedCallback);
1602 XtAddCallback (button, XmNvalueChangedCallback, xm_generic_callback,
1603 (XtPointer)instance);
1604 }
1605 else
1606 {
1607 button = XmCreatePushButton (instance->parent, val->name, al, ac);
1608 XtAddCallback (button, XmNactivateCallback, xm_generic_callback,
1609 (XtPointer)instance);
1610 }
1611
1612 XtManageChild (button);
1613
1614 return button;
1615 }
1616
1617 static Widget
1618 make_progress (widget_instance *instance)
1619 {
1620 Arg al[20];
1621 int ac = 0;
1622 Widget scale = 0;
1623 widget_value* val = instance->info->val;
1624
1625 XtSetArg (al [ac], XmNsensitive, val->enabled); ac++;
1626 XtSetArg (al [ac], XmNalignment, XmALIGNMENT_BEGINNING); ac++;
1627 XtSetArg (al [ac], XmNuserData, val->call_data); ac++;
1628 XtSetArg (al [ac], XmNmappedWhenManaged, FALSE); ac++;
1629 XtSetArg (al [ac], XmNorientation, XmHORIZONTAL); ac++;
1630 /* The highlight doesn't appear to be dynamically set which makes it
1631 look ugly. I think this may be a LessTif bug but for now we just
1632 get rid of it. */
1633 XtSetArg (al [ac], XmNhighlightThickness, (Dimension)0);ac++;
1634 if (!val->call_data)
1635 XtSetArg (al [ac], XmNsensitive, False); ac++;
1636
1637 /* add any args the user supplied for creation time */
1638 lw_add_value_args_to_args (val, al, &ac);
1639
1640 scale = XmCreateScale (instance->parent, val->name, al, ac);
1641 if (val->call_data)
1642 XtAddCallback (scale, XmNvalueChangedCallback, xm_generic_callback,
1643 (XtPointer)instance);
1644
1645 XtManageChild (scale);
1646
1647 return scale;
1648 }
1649
1650 static Widget
1651 make_text_field (widget_instance *instance)
1652 {
1653 Arg al[20];
1654 int ac = 0;
1655 Widget text = 0;
1656 widget_value* val = instance->info->val;
1657
1658 XtSetArg (al [ac], XmNsensitive, val->enabled && val->call_data); ac++;
1659 XtSetArg (al [ac], XmNalignment, XmALIGNMENT_BEGINNING); ac++;
1660 XtSetArg (al [ac], XmNuserData, val->call_data); ac++;
1661 XtSetArg (al [ac], XmNmappedWhenManaged, FALSE); ac++;
1662 /* The highlight doesn't appear to be dynamically set which makes it
1663 look ugly. I think this may be a LessTif bug but for now we just
1664 get rid of it. */
1665 XtSetArg (al [ac], XmNhighlightThickness, (Dimension)0);ac++;
1666
1667 /* add any args the user supplied for creation time */
1668 lw_add_value_args_to_args (val, al, &ac);
1669
1670 text = XmCreateTextField (instance->parent, val->name, al, ac);
1671 if (val->call_data)
1672 XtAddCallback (text, XmNvalueChangedCallback, xm_generic_callback,
1673 (XtPointer)instance);
1674
1675 XtManageChild (text);
1676
1677 return text;
1678 }
1679
1680 #if XmVERSION > 1
1681 static Widget
1682 make_combo_box (widget_instance *instance)
1683 {
1684 Arg al[20];
1685 int ac = 0;
1686 Widget combo = 0;
1687 widget_value* val = instance->info->val;
1688
1689 XtSetArg (al [ac], XmNsensitive, val->enabled); ac++;
1690 XtSetArg (al [ac], XmNalignment, XmALIGNMENT_BEGINNING); ac++;
1691 XtSetArg (al [ac], XmNuserData, val->call_data); ac++;
1692 XtSetArg (al [ac], XmNmappedWhenManaged, FALSE); ac++;
1693 /* The highlight doesn't appear to be dynamically set which makes it
1694 look ugly. I think this may be a LessTif bug but for now we just
1695 get rid of it. */
1696 XtSetArg (al [ac], XmNhighlightThickness, (Dimension)0);ac++;
1697
1698 /* add any args the user supplied for creation time */
1699 lw_add_value_args_to_args (val, al, &ac);
1700
1701 combo = XmCreateComboBox (instance->parent, val->name, al, ac);
1702 if (val->call_data)
1703 XtAddCallback (combo, XmNselectionCallback, xm_generic_callback,
1704 (XtPointer)instance);
1705
1706 XtManageChild (combo);
1707
1708 return combo;
1709 }
1710 #endif
1711
1712
1713 /* Table of functions to create widgets */
1575 1714
1576 widget_creation_entry 1715 widget_creation_entry
1577 xm_creation_table [] = 1716 xm_creation_table [] =
1578 { 1717 {
1579 #ifdef LWLIB_MENUBARS_MOTIF 1718 #ifdef LWLIB_MENUBARS_MOTIF
1580 {"menubar", make_menubar}, 1719 {"menubar", make_menubar},
1581 {"popup", make_popup_menu}, 1720 {"popup", make_popup_menu},
1582 #endif 1721 #endif
1583 #ifdef LWLIB_SCROLLBARS_MOTIF 1722 #ifdef LWLIB_SCROLLBARS_MOTIF
1584 {"vertical-scrollbar", make_vertical_scrollbar}, 1723 {"vertical-scrollbar", make_vertical_scrollbar},
1585 {"horizontal-scrollbar", make_horizontal_scrollbar}, 1724 {"horizontal-scrollbar", make_horizontal_scrollbar},
1725 #endif
1726 {"button", make_button},
1727 {"progress", make_progress},
1728 {"text-field", make_text_field},
1729 #if XmVERSION > 1
1730 {"combo-box", make_combo_box},
1586 #endif 1731 #endif
1587 {NULL, NULL} 1732 {NULL, NULL}
1588 }; 1733 };
1589 1734
1590 /* Destruction of instances */ 1735 /* Destruction of instances */
1698 #endif 1843 #endif
1699 { 1844 {
1700 if (up) 1845 if (up)
1701 XtManageChild (widget); 1846 XtManageChild (widget);
1702 else 1847 else
1703 XtUnmanageChild (widget); 1848 XtUnmanageChild (widget);
1704 } 1849 }
1705 } 1850 }
1706 1851
1707 1852
1708 /* motif callback */ 1853 /* motif callback */
1709 1854
1710 enum do_call_type { pre_activate, selection, no_selection, post_activate }; 1855 enum do_call_type { pre_activate, selection, no_selection, post_activate };
1711 1856
1712 static void 1857 static void
1713 do_call (Widget widget, XtPointer closure, enum do_call_type type) 1858 do_call (Widget widget, XtPointer closure, enum do_call_type type)
1753 abort (); 1898 abort ();
1754 } 1899 }
1755 } 1900 }
1756 1901
1757 /* Like lw_internal_update_other_instances except that it does not do 1902 /* Like lw_internal_update_other_instances except that it does not do
1758 anything if its shell parent is not managed. This is to protect 1903 anything if its shell parent is not managed. This is to protect
1759 lw_internal_update_other_instances to dereference freed memory 1904 lw_internal_update_other_instances to dereference freed memory
1760 if the widget was ``destroyed'' by caching it in the all_destroyed_instances 1905 if the widget was ``destroyed'' by caching it in the all_destroyed_instances
1761 list */ 1906 list */
1762 static void 1907 static void
1763 xm_internal_update_other_instances (Widget widget, XtPointer closure, 1908 xm_internal_update_other_instances (Widget widget, XtPointer closure,
1788 XtGetValues (widget, al, 1); 1933 XtGetValues (widget, al, 1);
1789 1934
1790 XtSetArg (al [0], XmNset, !check); 1935 XtSetArg (al [0], XmNset, !check);
1791 XtSetValues (widget, al, 1); 1936 XtSetValues (widget, al, 1);
1792 } 1937 }
1793 #endif 1938 #endif
1794 lw_internal_update_other_instances (widget, closure, call_data); 1939 lw_internal_update_other_instances (widget, closure, call_data);
1795 do_call (widget, closure, selection); 1940 do_call (widget, closure, selection);
1941 }
1942
1943 static void
1944 xm_pop_down_callback (Widget widget, XtPointer closure, XtPointer call_data)
1945 {
1946 do_call (widget, closure, post_activate);
1796 } 1947 }
1797 1948
1798 #ifdef LWLIB_DIALOGS_MOTIF 1949 #ifdef LWLIB_DIALOGS_MOTIF
1799 1950
1800 static void 1951 static void
1821 { 1972 {
1822 #if 0 1973 #if 0
1823 if (call_data) 1974 if (call_data)
1824 { 1975 {
1825 /* new behavior for incremental menu construction */ 1976 /* new behavior for incremental menu construction */
1826 1977
1827 } 1978 }
1828 else 1979 else
1829 #endif 1980 #endif
1830 do_call (widget, closure, pre_activate); 1981 do_call (widget, closure, pre_activate);
1831 } 1982 }
1832
1833 #if 0
1834 static void
1835 xm_pop_down_callback (Widget widget, XtPointer closure, XtPointer call_data)
1836 {
1837 do_call (widget, closure, post_activate);
1838 }
1839 #endif /* 0 */
1840 1983
1841 #endif /* LWLIB_MENUBARS_MOTIF */ 1984 #endif /* LWLIB_MENUBARS_MOTIF */
1842 1985
1843 #ifdef LWLIB_SCROLLBARS_MOTIF 1986 #ifdef LWLIB_SCROLLBARS_MOTIF
1844 static void 1987 static void