comparison lwlib/lwlib-Xaw.c @ 406:b8cc9ab3f761 r21-2-33

Import from CVS: tag r21-2-33
author cvs
date Mon, 13 Aug 2007 11:17:09 +0200
parents 5a2589c672dc
children de805c49cfc1
comparison
equal deleted inserted replaced
405:0e08f63c74d2 406:b8cc9ab3f761
67 #endif 67 #endif
68 #ifdef LWLIB_WIDGETS_ATHENA 68 #ifdef LWLIB_WIDGETS_ATHENA
69 || XtIsSubclass (widget, labelWidgetClass) 69 || XtIsSubclass (widget, labelWidgetClass)
70 || XtIsSubclass (widget, toggleWidgetClass) 70 || XtIsSubclass (widget, toggleWidgetClass)
71 || XtIsSubclass (widget, gaugeWidgetClass) 71 || XtIsSubclass (widget, gaugeWidgetClass)
72 #if 0 72 #ifndef NEED_MOTIF
73 || XtIsSubclass (widget, textWidgetClass) 73 || XtIsSubclass (widget, asciiTextWidgetClass)
74 #endif 74 #endif
75 #endif 75 #endif
76 ); 76 );
77 } 77 }
78 78
131 #ifdef LWLIB_SCROLLBARS_ATHENA 131 #ifdef LWLIB_SCROLLBARS_ATHENA
132 else if (XtIsSubclass (widget, scrollbarWidgetClass)) 132 else if (XtIsSubclass (widget, scrollbarWidgetClass))
133 { 133 {
134 xaw_update_scrollbar (instance, widget, val); 134 xaw_update_scrollbar (instance, widget, val);
135 } 135 }
136 #endif
137 #ifdef LWLIB_WIDGETS_ATHENA
138 #ifndef NEED_MOTIF
139 else if (XtIsSubclass (widget, asciiTextWidgetClass))
140 {
141 }
142 #endif
136 #endif 143 #endif
137 #ifdef LWLIB_DIALOGS_ATHENA 144 #ifdef LWLIB_DIALOGS_ATHENA
138 else if (XtIsSubclass (widget, dialogWidgetClass)) 145 else if (XtIsSubclass (widget, dialogWidgetClass))
139 { 146 {
140 Arg al [1]; 147 Arg al [1];
218 val->edited = True; 225 val->edited = True;
219 } 226 }
220 #ifndef NEED_MOTIF 227 #ifndef NEED_MOTIF
221 else if (XtIsSubclass (widget, asciiTextWidgetClass)) 228 else if (XtIsSubclass (widget, asciiTextWidgetClass))
222 { 229 {
223 Arg al [1]; 230 Arg al [2];
231 String buf = 0;
232 XtSetArg (al [0], XtNstring, &buf);
233 XtGetValues (widget, al, 2);
234
224 if (val->value) 235 if (val->value)
225 free (val->value); 236 {
226 XtSetArg (al [0], XtNstring, &val->value); 237 free (val->value);
227 XtGetValues (widget, al, 1); 238 val->value = 0;
239 }
240 /* I don't think this causes a leak. */
241 if (buf)
242 val->value = strdup (buf);
228 val->edited = True; 243 val->edited = True;
229 } 244 }
230 #endif 245 #endif
231 #endif /* LWLIB_WIDGETS_ATHENA */ 246 #endif /* LWLIB_WIDGETS_ATHENA */
232 } 247 }
819 834
820 return scale; 835 return scale;
821 } 836 }
822 837
823 #ifndef NEED_MOTIF 838 #ifndef NEED_MOTIF
839 #define TEXT_BUFFER_SIZE 128
824 static Widget 840 static Widget
825 xaw_create_text_field (widget_instance *instance) 841 xaw_create_text_field (widget_instance *instance)
826 { 842 {
827 Arg al[20]; 843 Arg al[20];
828 int ac = 0; 844 int ac = 0;
829 Widget text = 0; 845 Widget text = 0;
830 widget_value* val = instance->info->val; 846 widget_value* val = instance->info->val;
831 847
832 XtSetArg (al [ac], XtNsensitive, val->enabled && val->call_data); ac++; 848 XtSetArg (al [ac], XtNsensitive, val->enabled); ac++;
833 XtSetArg (al [ac], XtNmappedWhenManaged, FALSE); ac++; 849 XtSetArg (al [ac], XtNmappedWhenManaged, FALSE); ac++;
834 XtSetArg (al [ac], XtNhighlightThickness, (Dimension)0); ac++; 850 XtSetArg (al [ac], XtNhighlightThickness, (Dimension)0); ac++;
835 XtSetArg (al [ac], XtNtype, XawAsciiString); ac++; 851 XtSetArg (al [ac], XtNtype, XawAsciiString); ac++;
836 XtSetArg (al [ac], XtNeditType, XawtextEdit); ac++; 852 XtSetArg (al [ac], XtNeditType, XawtextEdit); ac++;
853 XtSetArg (al [ac], XtNuseStringInPlace, False); ac++;
854 #if 0
855 XtSetArg (al [ac], XtNlength, TEXT_BUFFER_SIZE); ac++;
856 #endif
857 if (val->value)
858 {
859 XtSetArg (al [ac], XtNstring, val->value); ac++;
860 }
837 861
838 /* add any args the user supplied for creation time */ 862 /* add any args the user supplied for creation time */
839 lw_add_value_args_to_args (val, al, &ac); 863 lw_add_value_args_to_args (val, al, &ac);
840 864
841 text = XtCreateManagedWidget (val->name, asciiTextWidgetClass, 865 text = XtCreateManagedWidget (val->name, asciiTextWidgetClass,
842 instance->parent, al, ac); 866 instance->parent, al, ac);
867
868 /* add the callback */
869 if (val->call_data)
870 XtAddCallback (text, XtNgetValue, xaw_generic_callback, (XtPointer)instance);
871
843 XtManageChild (text); 872 XtManageChild (text);
844 873
845 return text; 874 return text;
846 } 875 }
847 #endif 876 #endif
877
848 #endif /* LWLIB_WIDGETS_ATHENA */ 878 #endif /* LWLIB_WIDGETS_ATHENA */
849 879
850 widget_creation_entry 880 widget_creation_entry
851 xaw_creation_table [] = 881 xaw_creation_table [] =
852 { 882 {