#include <stdio.h>
#include <X10/Xlib.h>
#include "Xtlib.h"

char *	GetAskForString();
Window	theBox;

main()
{

	XOpenDisplay();
	XtInitialize();

	theBox = MakeAskFor( RootWindow, "WARNING: Closing Toolbox will close all Toolbox applications.", "", 250, 250 );
	XMapWindow( theBox );
	
	while(1)
	{
	XEvent ev;

		XNextEvent(&ev);
		(void) XtDispatchEvent(&ev);
	}
}

static void ButtonAction(tag)
	char * tag;
{
	if( !strcmp(tag,"Help!") )
	{
		printf("SELECT \"CANCEL\" TO MAKE THIS DIALOG BOX GO AWAY.\nTHEN SELECT \"MENTOR TOOLBOX\" FROM THE TOOLBOX MENU;\nA HELP FILE WILL APPEAR.\n");
	}
	else if( !strcmp(tag,"Close Toolbox") )
	{
	        printf("value in (interactive!) box is '%s'\n", 
			GetAskForString(theBox) );
		
	}
	else if( !strcmp(tag,"Cancel") )
	{
		XtSendDestroyNotify( theBox );
		XDestroyWindow( theBox );
		exit();
	}
}

Window
MakeAskFor( parent, prompt, initval, x, y )
	Window parent;
	char *prompt;
	char *initval;
	int	x,y;
{
Window w;

	w = XtDialogCreate( parent, prompt, initval, "HELLO", 0 );
	XtDialogAddButton( w, "Help!", ButtonAction, "Help!" );
	XtDialogAddButton( w, "Close Toolbox", ButtonAction, "Close Toolbox" );
	XtDialogAddButton( w, "Cancel", ButtonAction, "Cancel" );
	XMoveWindow( w, x, y );
	return w;
}

char *
GetAskForString( w )
	Window w;
{
	return XtDialogGetValueString(w);
}
