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

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

#include <Xm/Xm.h>
#include <Xm/RepType.h>
#include <Xm/CascadeB.h>
#include <Xm/DialogS.h>
#include <Xm/DrawingA.h>
#include <Xm/Form.h>
#include <Xm/Label.h>
#include <Xm/PushB.h>
#include <Xm/RowColumn.h>
#include <Xm/TextF.h>


#include "resize.h"

#ifndef   _NO_PROTO
extern void DrawableCreateCallback(Widget, XtPointer, XtPointer) ;
#else  /* _NO_PROTO */
extern void DrawableCreateCallback() ;
#endif /* _NO_PROTO */

/* Action Procedure Declarations */

#ifndef   _NO_PROTO
extern void HandleResize(Widget, XEvent *, String *, Cardinal *) ;
#else  /* _NO_PROTO */
extern void HandleResize() ;
#endif /* _NO_PROTO */

Widget shell = (Widget) NULL;
Widget topform = (Widget) NULL;
Widget subform = (Widget) NULL;
Widget menubar = (Widget) NULL;
Widget help_b = (Widget) NULL;
Widget drawable = (Widget) NULL;



void create_shell (Display *display, char *app_name, int app_argc, char **app_argv)
{
	Widget children[4];      /* Children to manage */
	Arg al[64];                    /* Arg List */
	register int ac = 0;           /* Arg Count */
	XrmValue from_value, to_value; /* For resource conversion */
	XtPointer tmp_value;             /* ditto */
	XmString xmstrings[16];    /* temporary storage for XmStrings */
	Widget cascade1 = (Widget)NULL;
	Widget cascade2 = (Widget)NULL;
	Widget label1 = (Widget)NULL;
	Widget text1 = (Widget)NULL;
	Widget button1 = (Widget)NULL;

	XtSetArg(al[ac], XmNallowShellResize, TRUE); ac++;
	XtSetArg(al[ac], XmNargc, app_argc); ac++;
	XtSetArg(al[ac], XmNargv, app_argv); ac++;
	shell = XtAppCreateShell(app_name, (char *) "XApplication", applicationShellWidgetClass, display, al, ac);

	ac = 0;
	XtSetArg(al[ac], XmNresizePolicy, XmRESIZE_NONE); ac++;
	XtSetArg(al[ac], XmNautoUnmanage, FALSE); ac++;
	topform = XmCreateForm ( shell, (char *) "topform", al, ac );
	ac = 0;
	subform = XmCreateForm ( topform, (char *) "subform", al, ac );
	menubar = XmCreateMenuBar ( subform, (char *) "menubar", al, ac );
	xmstrings[0] = XmStringGenerate ( "File", XmFONTLIST_DEFAULT_TAG, XmCHARSET_TEXT, NULL );
	XtSetArg(al[ac], XmNlabelString, xmstrings[0]); ac++;
	from_value.addr = "F" ;
	from_value.size = strlen( from_value.addr ) + 1;
	to_value.addr = NULL;
	XtConvertAndStore (menubar, XmRString, &from_value, XmRKeySym, &to_value);
	if ( to_value.addr ) {
		XtSetArg(al[ac], XmNmnemonic, (*((KeySym*) to_value.addr))); ac++;
	}
	cascade1 = XmCreateCascadeButton ( menubar, (char *) "cascade1", al, ac );
	ac = 0;
	XmStringFree ( xmstrings [ 0 ] );
	xmstrings[0] = XmStringGenerate ( "Edit", XmFONTLIST_DEFAULT_TAG, XmCHARSET_TEXT, NULL );
	XtSetArg(al[ac], XmNlabelString, xmstrings[0]); ac++;
	from_value.addr = "E" ;
	from_value.size = strlen( from_value.addr ) + 1;
	to_value.addr = NULL;
	XtConvertAndStore (menubar, XmRString, &from_value, XmRKeySym, &to_value);
	if ( to_value.addr ) {
		XtSetArg(al[ac], XmNmnemonic, (*((KeySym*) to_value.addr))); ac++;
	}
	cascade2 = XmCreateCascadeButton ( menubar, (char *) "cascade2", al, ac );
	ac = 0;
	XmStringFree ( xmstrings [ 0 ] );
	xmstrings[0] = XmStringGenerate ( "Help", XmFONTLIST_DEFAULT_TAG, XmCHARSET_TEXT, NULL );
	XtSetArg(al[ac], XmNlabelString, xmstrings[0]); ac++;
	from_value.addr = "H" ;
	from_value.size = strlen( from_value.addr ) + 1;
	to_value.addr = NULL;
	XtConvertAndStore (menubar, XmRString, &from_value, XmRKeySym, &to_value);
	if ( to_value.addr ) {
		XtSetArg(al[ac], XmNmnemonic, (*((KeySym*) to_value.addr))); ac++;
	}
	help_b = XmCreateCascadeButton ( menubar, (char *) "help_b", al, ac );
	ac = 0;
	XmStringFree ( xmstrings [ 0 ] );
	XtSetArg(al[ac], XmNmenuHelpWidget, help_b); ac++;
	XtSetValues ( menubar, al, ac );
	ac = 0;
	label1 = XmCreateLabel ( subform, (char *) "label1", al, ac );
	text1 = XmCreateTextField ( subform, (char *) "text1", al, ac );
	button1 = XmCreatePushButton ( subform, (char *) "button1", al, ac );
	XtSetArg(al[ac], XmNwidth, 600); ac++;
	XtSetArg(al[ac], XmNheight, 300); ac++;
	if (DefaultDepthOfScreen(DefaultScreenOfDisplay(display)) != 1) {
		from_value.addr = "white" ;
		from_value.size = strlen( from_value.addr ) + 1;
		to_value.addr = NULL;
		XtConvertAndStore (topform, XmRString, &from_value, XmRPixel, &to_value);
		if ( to_value.addr ) {
			XtSetArg(al[ac], XmNbackground, (*((Pixel*) to_value.addr))); ac++;
		}
	}
	drawable = XmCreateDrawingArea ( topform, (char *) "drawable", al, ac );
	ac = 0;


	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNtopOffset, 5); ac++;
	XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNleftOffset, 5); ac++;
	XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNrightOffset, 5); ac++;
	XtSetValues ( subform,al, ac );
	ac = 0;

	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
	XtSetArg(al[ac], XmNtopOffset, 5); ac++;
	XtSetArg(al[ac], XmNtopWidget, subform); ac++;
	XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNbottomOffset, 5); ac++;
	XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNleftOffset, 5); ac++;
	XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNrightOffset, 5); ac++;
	XtSetValues ( drawable,al, ac );
	ac = 0;

	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
	XtSetValues ( menubar,al, ac );
	ac = 0;

	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
	XtSetArg(al[ac], XmNtopOffset, 0); ac++;
	XtSetArg(al[ac], XmNtopWidget, text1); ac++;
	XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
	XtSetArg(al[ac], XmNbottomOffset, 0); ac++;
	XtSetArg(al[ac], XmNbottomWidget, text1); ac++;
	XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNleftOffset, 5); ac++;
	XtSetArg(al[ac], XmNrightAttachment, XmATTACH_WIDGET); ac++;
	XtSetArg(al[ac], XmNrightOffset, 5); ac++;
	XtSetArg(al[ac], XmNrightWidget, button1); ac++;
	XtSetValues ( label1,al, ac );
	ac = 0;

	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
	XtSetArg(al[ac], XmNtopOffset, 5); ac++;
	XtSetArg(al[ac], XmNtopWidget, menubar); ac++;
	XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_NONE); ac++;
	XtSetArg(al[ac], XmNleftAttachment, XmATTACH_POSITION); ac++;
	XtSetArg(al[ac], XmNleftPosition, 50); ac++;
	XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNrightOffset, 5); ac++;
	XtSetValues ( text1,al, ac );
	ac = 0;

	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
	XtSetArg(al[ac], XmNtopOffset, 0); ac++;
	XtSetArg(al[ac], XmNtopWidget, text1); ac++;
	XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
	XtSetArg(al[ac], XmNbottomOffset, 0); ac++;
	XtSetArg(al[ac], XmNbottomWidget, text1); ac++;
	XtSetArg(al[ac], XmNleftAttachment, XmATTACH_NONE); ac++;
	XtSetArg(al[ac], XmNrightAttachment, XmATTACH_WIDGET); ac++;
	XtSetArg(al[ac], XmNrightOffset, 5); ac++;
	XtSetArg(al[ac], XmNrightWidget, text1); ac++;
	XtSetValues ( button1,al, ac );
	ac = 0;
	if ((children[ac] = cascade1) != (Widget) 0) { ac++; }
	if ((children[ac] = cascade2) != (Widget) 0) { ac++; }
	if ((children[ac] = help_b) != (Widget) 0) { ac++; }
	if (ac > 0) { XtManageChildren(children, ac); }
	ac = 0;
	if ((children[ac] = menubar) != (Widget) 0) { ac++; }
	if ((children[ac] = label1) != (Widget) 0) { ac++; }
	if ((children[ac] = text1) != (Widget) 0) { ac++; }
	if ((children[ac] = button1) != (Widget) 0) { ac++; }
	if (ac > 0) { XtManageChildren(children, ac); }
	ac = 0;
	DrawableCreateCallback( drawable, (XtPointer) 0, (XtPointer) 0 );
	XtOverrideTranslations(drawable, XtParseTranslationTable("Ctrl<Key>R: HandleResize()"));
	if ((children[ac] = subform) != (Widget) 0) { ac++; }
	if ((children[ac] = drawable) != (Widget) 0) { ac++; }
	if (ac > 0) { XtManageChildren(children, ac); }
	ac = 0;
	if (topform != (Widget) 0) { XtManageChild ( topform); }
}



/* Action Table */

static XtActionsRec actionsTable[] = {
	{ "HandleResize",	HandleResize }
} ;

/* Global Declarations */

XtAppContext app_context = (XtAppContext) 0 ;
Display     *display     = (Display *)    0 ;

int main(int argc, char **argv)
{

	/* Enable Localisation of the Application */

	XtSetLanguageProc((XtAppContext) 0, (XtLanguageProc) 0, (XtPointer) 0) ;

	/* Initialise the X Toolkit */

	XtToolkitInitialize ();

	/* Create a Global Application Context */

	app_context = XtCreateApplicationContext ();

	/* Action Procedure Registration */

	XtAppAddActions(app_context, actionsTable, XtNumber(actionsTable)) ; 

	/* Open the Display */

	display = XtOpenDisplay(app_context, (String) 0, argv[0], "XApplication",
	                       (XrmOptionDescRec *) 0, 0,
	                       &argc, argv);
	if (display == (Display *) 0) {
		printf("%s: can't open display, exiting...\n", argv[0]);
		exit (-1);
	}
	/* Call the Create Procedures for the Dialogs in the Application */

	create_shell ( display, argv[0], argc, argv );

	/* Display the Primary Application Shell */

	XtRealizeWidget (shell);

	/* Entering X Main Loop... */

	XtAppMainLoop (app_context);

	/* NOTREACHED */

	exit (0);
}

