#include <Xm/Xm.h>
#include <Xm/MainW.h>
#include <Xm/RowColumn.h>
#include <Xm/PushB.h>
#include <Xm/Label.h>
#include <Xm/DrawingA.h>
#include <Xm/ScrollBar.h>
#include <Xm/Form.h>
#include <Xm/Frame.h>

#define LABEL_SIZE 100

int
main(int argc, char *argv[])
{
	XtAppContext app;
	Widget top;
	Widget main;
	Widget buttons;
	Widget quitbutton;
	Widget nextbutton;
	Widget prevbutton;
	Widget basebutton;
	Widget button;
	Widget spacerlabel;
	Widget timingbutton;
	Widget draw;
	Widget hscroll;
	Widget vscroll;
	Widget status;
	Widget infoframe;
	Widget csrframe;
	Widget mkrframe;
	Widget difframe;
	Widget infolabel;
	Widget csrlabel;
	Widget mkrlabel;
	Widget diflabel;

	//initialise the toolkit

	top = XtVaAppInitialize(&app, "VCD", NULL, 0, &argc, argv, NULL,



				NULL);






	main = XtVaCreateManagedWidget("main", xmMainWindowWidgetClass, top,

				       XmNheight, 400,

				       XmNwidth, 600,


				       NULL);



	buttons = XtVaCreateManagedWidget("buttons", xmRowColumnWidgetClass, main,

					  XmNorientation, XmHORIZONTAL,


					  XmNheight, LABEL_SIZE / 2,

					  NULL);


	//create the buttons to go in the 'buttons' widget      

	quitbutton = XtVaCreateManagedWidget("Quit", xmPushButtonWidgetClass, buttons,

					     NULL);



	nextbutton = XtVaCreateManagedWidget("NextEdge", xmPushButtonWidgetClass, buttons,

					     NULL);



	prevbutton = XtVaCreateManagedWidget("Prev Edge", xmPushButtonWidgetClass, buttons,

					     NULL);



	basebutton = XtVaCreateManagedWidget("Base->Marker", xmPushButtonWidgetClass, buttons,

					     NULL);



	spacerlabel = XtVaCreateManagedWidget("spacerlabel", xmLabelWidgetClass, buttons,

					      NULL);



	timingbutton = XtVaCreateManagedWidget("Timing Spread", xmPushButtonWidgetClass, buttons,

					       NULL);


	//work area widget

	draw = XtVaCreateManagedWidget("drawing area", xmDrawingAreaWidgetClass, main,

				       NULL);



	//create some scrollbars

	hscroll = XtVaCreateManagedWidget("hscroll", xmScrollBarWidgetClass, main,

					  XmNorientation, XmHORIZONTAL,

					  XmNmaximum, 10000,

					  XmNminimum, 0,

					  XmNsliderSize, 1000,


					  XmNpageIncrement, 1,

					  XmNincrement, 1,

					  NULL);




	vscroll = XtVaCreateManagedWidget("vscroll", xmScrollBarWidgetClass, main,


					  XmNorientation, XmVERTICAL,

					  XmNmaximum, 10000,


					  XmNminimum, 0,

					  XmNsliderSize, 1000,

					  XmNincrement, 1,


					  XmNpageIncrement, 1,

					  NULL);


	//container for info boxes
	//note: each label widget is contained within it's own frame widget (just to look nice)

	status = XtVaCreateManagedWidget("status",
					 xmFormWidgetClass, main,

					 XmNorientation, XmHORIZONTAL,


/*
   XmNheight,LABEL_SIZE,
 */

					 NULL);



	infoframe = XtVaCreateManagedWidget("infoframe", xmFrameWidgetClass, status,

					  XmNleftAttachment, XmATTACH_POSITION,

					    XmNleftPosition, 1,


					    XmNtopAttachment, XmATTACH_POSITION,

					    XmNtopPosition, 2,


					XmNbottomAttachment, XmATTACH_POSITION,

					    XmNbottomPosition, 48,


					 XmNrightAttachment, XmATTACH_POSITION,

					    XmNrightPosition, 99,


					    NULL);



	csrframe = XtVaCreateManagedWidget("csrframe", xmFrameWidgetClass, status,

					   XmNleftAttachment, XmATTACH_POSITION,


					   XmNleftPosition, 1,

					   XmNtopAttachment, XmATTACH_POSITION,


					   XmNtopPosition, 52,

					XmNbottomAttachment, XmATTACH_POSITION,


					   XmNbottomPosition, 98,

					 XmNrightAttachment, XmATTACH_POSITION,


					   XmNrightPosition, 33,

					   NULL);



	mkrframe = XtVaCreateManagedWidget("mkrframe", xmFrameWidgetClass, status,

					   XmNleftAttachment, XmATTACH_POSITION,

					   XmNleftPosition, 34,

					   XmNtopAttachment, XmATTACH_POSITION,

					   XmNtopPosition, 52,


					XmNbottomAttachment, XmATTACH_POSITION,

					   XmNbottomPosition, 98,


					 XmNrightAttachment, XmATTACH_POSITION,

					   XmNrightPosition, 66,


					   NULL);



	difframe = XtVaCreateManagedWidget("difframe", xmFrameWidgetClass, status,

					   XmNleftAttachment, XmATTACH_POSITION,


					   XmNleftPosition, 67,

					   XmNtopAttachment, XmATTACH_POSITION,


					   XmNtopPosition, 52,

					XmNbottomAttachment, XmATTACH_POSITION,


					   XmNbottomPosition, 98,

					 XmNrightAttachment, XmATTACH_POSITION,


					   XmNrightPosition, 99,

					   NULL);



	infolabel = XtVaCreateManagedWidget("infolabel", xmLabelWidgetClass, infoframe,


					    XmNalignment, XmALIGNMENT_BEGINNING,


					    XmNisAligned, TRUE,

					    NULL);



	csrlabel = XtVaCreateManagedWidget("csrlabel", xmLabelWidgetClass, csrframe,


					   XmNalignment, XmALIGNMENT_BEGINNING,


					   XmNisAligned, TRUE,

					   NULL);





	mkrlabel = XtVaCreateManagedWidget("mkrlabel", xmLabelWidgetClass, mkrframe,


					   XmNalignment, XmALIGNMENT_BEGINNING,


					   XmNisAligned, TRUE,

					   NULL);



	diflabel = XtVaCreateManagedWidget("diflabel", xmLabelWidgetClass, difframe,


					   XmNalignment, XmALIGNMENT_BEGINNING,


					   XmNisAligned, TRUE,

					   NULL);



	XmMainWindowSetAreas(main,

			     buttons,

			     status,	//<--this widget appears too high, underneath 'buttons' widget until resized

			     hscroll,

			     vscroll,


			     draw);


	XtRealizeWidget(top);
	XtAppMainLoop(app);

}
