
#include "wbmfieldP.h"

Widget make_editable_mail_field(parent_widget)
     Widget parent_widget;
     {
       Widget mail_widget;
       Widget keyWidget;
       Widget valueWidget;
       char *key_string;
       char *val_string;
       int val_string_length;
       Widget make_editable_label();
       void prstr_mfield();

       /* Create a Mail-Field widget */
       /* -------------------------- */
       arg_list[0].name = XtNborderWidth;
       arg_list[0].value = (XtArgVal) 1;
       arg_list[1].name = XtNleft;
       arg_list[1].value = (XtArgVal) XtChainLeft;
       arg_list[2].name = XtNright;
       arg_list[2].value = (XtArgVal) XtChainRight;
       arg_list[3].name = XtNwidth;
       arg_list[3].value = (XtArgVal) 400;
       arg_list[4].name = XtNwidth;
       arg_list[4].value = (XtArgVal) 20;
       arg_list[5].name = XtNresizable;
       arg_list[5].value = (XtArgVal) TRUE;
       mail_widget = XtCreateWidget((char *) gensym(),
			       formWidgetClass, 
			       parent_widget,
			       arg_list, 6);
       /* Add this widget to database, before creating any children */
       add_widget_node(mail_widget, parent_widget, "form", prstr_mfield);

       /* Create the Keyword field  as a label widget */
       /* ------------------------------------------- */
       keyWidget = make_editable_label(mail_widget);

       /* Create input Value field as an AsciiText widget */
       /* ----------------------------------------------- */
       val_string_length = 70;
       val_string = (char *) calloc((val_string_length + 1), 1);
       XtSetArg(arg_list[0], XtNeditType, XttextEdit);
       XtSetArg(arg_list[1], XtNstring, val_string);
       XtSetArg(arg_list[2], XtNfromHoriz, keyWidget);
       XtSetArg(arg_list[3], XtNlength, (val_string_length * WBFONTWIDTH));
       XtSetArg(arg_list[4], XtNtextOptions, 
		resizeHeight | resizeWidth); /* | editable); */
       XtSetArg(arg_list[5], XtNresizable, TRUE);
       valueWidget = XtCreateManagedWidget((char *) gensym(),
			       asciiStringWidgetClass, mail_widget,
			       arg_list, 6);

       make_widget_movable(mail_widget, parent_widget);
       make_widget_resizable(mail_widget, parent_widget);

       /* Now allow the new widget to become managed (and realized) */
       XtManageChild(mail_widget);

       /* Add these widgets to the linked list of created widgets */
       /* ------------------------------------------------------- */
       (add_widget_node(valueWidget, mail_widget,
			"ascii text", prstr_ascii_text))->string
	    = val_string;
       widgetsUsed.keyedMailField = TRUE;
       widgetsUsed.label = TRUE;
       widgetsUsed.text = TRUE;
       widgetsUsed.asciiText = TRUE;
       widgetsUsed.form = TRUE;

       return(mail_widget);

     };      /* end of make_editable_mail_field() */

/****************************************************************/

void prstr_mfield(buffer, node)
     MailBuffer *buffer;
     WidgetNode *node;
  {
  };         /* end of prstr_mfield()  */

/****************************************************************/
void edit_key_field(widget, event)
     Widget widget;
     XEvent *event;
 {
   char *str;
   int str_length;

   str_length = strlen(WBMarkedWidgetOption) + 1;
   str = (char *) calloc(str_length, 1);
   strcpy(str, WBMarkedWidgetOption);
   arg_list[0].name = XtNlabel;
   arg_list[0].value = (XtArgVal) str;
/*   arg_list[1].name = XtNlength;
   arg_list[1].value = (XtArgVal) str_length;  * WBFONTWIDTH; */
   XtSetValues(WBMarkedWidget, arg_list, 1);

 };           /* end of edit_key_field() */

/****************************************************************/
