/*
** Generated by X-Designer 
*/
/*
**LIBS: -lXm -lXt -lX11
*/

#include <X11/Xatom.h>
#include <X11/Intrinsic.h>
#include <X11/Shell.h>

#include <Xm/Xm.h>
#include <Xm/DialogS.h>
#include <Xm/Label.h>
#include <Xm/RowColumn.h>
#include <Xm/Text.h>
#include <stdio.h>

extern void modify_verify ();
extern Boolean aardvarkConverter ();
extern Boolean objStringConverter ();
Widget appshell = (Widget) NULL;
Widget rowcol = (Widget) NULL;
Widget label = (Widget) NULL;
Widget text = (Widget) NULL;


void 
modify_verify(w, client_data, call_data)
	Widget          w;
	XtPointer       client_data;
	XtPointer       call_data;
{
	XmTextVerifyCallbackStruct *cb_data =
	(XmTextVerifyCallbackStruct *) call_data;
	/* Allow programmatic changes */
	if (!cb_data->event)
		return;
	/* Don't allow deletes or multiple character paste */
	if (cb_data->startPos != cb_data->endPos
	    || cb_data->text->length > 1) {
		cb_data->doit = False;
		return;
	}
	/* Only output a * */
	cb_data->text->ptr[0] = '*';
}

void create_appshell (display, app_name, app_argc, app_argv)
Display *display;
char *app_name;
int app_argc;
char **app_argv;
{
	Widget children[2];      /* Children to manage */
	Arg al[64];                    /* Arg List */
	register int ac = 0;           /* Arg Count */
	XmString xmstrings[16];    /* temporary storage for XmStrings */

	XtSetArg(al[ac], XmNallowShellResize, TRUE); ac++;
	XtSetArg(al[ac], XmNtitle, "XmText ModifyVerify"); ac++;
	XtSetArg(al[ac], XmNargc, app_argc); ac++;
	XtSetArg(al[ac], XmNargv, app_argv); ac++;
	appshell = XtAppCreateShell ( app_name, "XApplication", applicationShellWidgetClass, display, al, ac );
	ac = 0;
	XtSetArg(al[ac], XmNorientation, XmHORIZONTAL); ac++;
	rowcol = XmCreateRowColumn ( appshell, "rowcol", al, ac );
	ac = 0;
	xmstrings[0] = XmStringCreateLtoR("Enter password", (XmStringCharSet)XmFONTLIST_DEFAULT_TAG);
	XtSetArg(al[ac], XmNlabelString, xmstrings[0]); ac++;
	label = XmCreateLabel ( rowcol, "label", al, ac );
	ac = 0;
	XmStringFree ( xmstrings [ 0 ] );
	text = XmCreateText ( rowcol, "text", al, ac );
	XtAddCallback (text, XmNmodifyVerifyCallback, modify_verify,NULL);
	children[ac++] = label;
	children[ac++] = text;
	XtManageChildren(children, ac);
	ac = 0;
	XtManageChild ( rowcol);
}



XtAppContext app_context;
Display *display;       /*  Display             */

int main (argc,argv)
int    argc;
char            **argv;
{
	XtSetLanguageProc ( (XtAppContext) NULL, (XtLanguageProc) NULL, (XtPointer) NULL );
	XtToolkitInitialize ();
	app_context = XtCreateApplicationContext ();
	display = XtOpenDisplay (app_context, NULL, argv[0], "XApplication",
	                         NULL, 0, &argc, argv);
	if (!display)
	{
	    printf("%s: can't open display, exiting...\n", argv[0]);
	    exit (-1);
	}
	create_appshell ( display, argv[0], argc, argv );
	XtRealizeWidget (appshell);
	XtAppMainLoop (app_context);
	exit (0);
}

