/*
** 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/DialogS.h>
#include <Xm/DrawingA.h>
#include <Xm/Form.h>
#include <Xm/PushB.h>
#include <Xm/RowColumn.h>


#include "popups12.h"


/* Event Handler Declarations */

#ifndef   _NO_PROTO
extern void ButtonPressHandler(Widget, XtPointer, XEvent *, Boolean *) ;
#else  /* _NO_PROTO */
extern void ButtonPressHandler() ; 
#endif /* _NO_PROTO */

Widget shell = (Widget) NULL;
Widget form = (Widget) NULL;
Widget drawingArea1 = (Widget) NULL;
Widget menuA = (Widget) NULL;
Widget menuB = (Widget) NULL;



void create_menuA (Widget parent)
{
	Widget children[3];      /* Children to manage */
	Arg al[64];                    /* Arg List */
	register int ac = 0;           /* Arg Count */
	Widget button1 = (Widget)NULL;
	Widget button2 = (Widget)NULL;
	Widget button3 = (Widget)NULL;

	menuA = XmCreatePopupMenu ( parent, (char *) "menuA", al, ac );
	button1 = XmCreatePushButton ( menuA, (char *) "button1", al, ac );
	button2 = XmCreatePushButton ( menuA, (char *) "button2", al, ac );
	button3 = XmCreatePushButton ( menuA, (char *) "button3", al, ac );
	if ((children[ac] = button1) != (Widget) 0) { ac++; }
	if ((children[ac] = button2) != (Widget) 0) { ac++; }
	if ((children[ac] = button3) != (Widget) 0) { ac++; }
	if (ac > 0) { XtManageChildren(children, ac); }
	ac = 0;
}

void create_menuB (Widget parent)
{
	Widget children[4];      /* Children to manage */
	Arg al[64];                    /* Arg List */
	register int ac = 0;           /* Arg Count */
	Widget button4 = (Widget)NULL;
	Widget button5 = (Widget)NULL;
	Widget button6 = (Widget)NULL;
	Widget button7 = (Widget)NULL;

	menuB = XmCreatePopupMenu ( parent, (char *) "menuB", al, ac );
	button4 = XmCreatePushButton ( menuB, (char *) "button4", al, ac );
	button5 = XmCreatePushButton ( menuB, (char *) "button5", al, ac );
	button6 = XmCreatePushButton ( menuB, (char *) "button6", al, ac );
	button7 = XmCreatePushButton ( menuB, (char *) "button7", al, ac );
	if ((children[ac] = button4) != (Widget) 0) { ac++; }
	if ((children[ac] = button5) != (Widget) 0) { ac++; }
	if ((children[ac] = button6) != (Widget) 0) { ac++; }
	if ((children[ac] = button7) != (Widget) 0) { ac++; }
	if (ac > 0) { XtManageChildren(children, ac); }
	ac = 0;
}

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 */
	XtPointer tmp_value;             /* ditto */

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

	ac = 0;
	XtSetArg(al[ac], XmNwidth, 250); ac++;
	XtSetArg(al[ac], XmNheight, 250); ac++;
	XtSetArg(al[ac], XmNautoUnmanage, FALSE); ac++;
	form = XmCreateForm ( shell, (char *) "form", al, ac );
	ac = 0;
	drawingArea1 = XmCreateDrawingArea ( form, (char *) "drawingArea1", al, ac );


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

	/* Event Handler Registrations */

	XtAddEventHandler(drawingArea1, ButtonPressMask, False, ButtonPressHandler, (XtPointer) 0) ;

	if ((children[ac] = drawingArea1) != (Widget) 0) { ac++; }
	if (ac > 0) { XtManageChildren(children, ac); }
	ac = 0;
	if (form != (Widget) 0) { XtManageChild ( form); }
}


/* 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 ();

	/* 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);
	}

	/* This converter is not registered internally by Motif */

	XmRepTypeInstallTearOffModelConverter();

	/* Call the Create Procedures for the Dialogs in the Application */

	create_shell ( display, argv[0], argc, argv );
	create_menuA ( drawingArea1 );
	create_menuB ( drawingArea1 );

	/* Display the Primary Application Shell */

	XtRealizeWidget (shell);

	/* Entering X Main Loop... */

	XtAppMainLoop (app_context);

	/* NOTREACHED */

	exit (0);
}

