/*
** 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/Form.h>
#include <Xm/Label.h>
#include <Xm/TextF.h>
#include <Xm/SpinB.h>

extern void set_initial_clock() ;

#include "SpinBoxClock.h"

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

Widget app_shell = (Widget) NULL;
Widget form = (Widget) NULL;
Widget spinbox = (Widget) NULL;
Widget hours = (Widget) NULL;
Widget minutes = (Widget) NULL;
Widget seconds = (Widget) NULL;



void create_app_shell (Display *display, char *app_name, int app_argc, char **app_argv)
{
	Widget children[5];      /* Children to manage */
	Arg al[64];                    /* Arg List */
	register int ac = 0;           /* Arg Count */
	XtPointer tmp_value;             /* ditto */
	XmString xmstrings[16];    /* temporary storage for XmStrings */
	Widget label1 = (Widget)NULL;
	Widget label2 = (Widget)NULL;

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

	ac = 0;
	XtSetArg(al[ac], XmNautoUnmanage, FALSE); ac++;
	form = XmCreateForm ( app_shell, (char *) "form", al, ac );
	ac = 0;
	spinbox = XmCreateSpinBox ( form, (char *) "spinbox", al, ac );
	XtSetArg(al[ac], XmNmaximumValue, 23); ac++;
	XtSetArg(al[ac], XmNminimumValue, 0); ac++;
	XtSetArg(al[ac], XmNposition, 0); ac++;
	XtSetArg(al[ac], XmNspinBoxChildType, XmNUMERIC); ac++;
	XtSetArg(al[ac], XmNcolumns, 2); ac++;
	hours = XmCreateTextField ( spinbox, (char *) "hours", al, ac );
	ac = 0;
	xmstrings[0] = XmStringGenerate ( ":", XmFONTLIST_DEFAULT_TAG, XmCHARSET_TEXT, NULL );
	XtSetArg(al[ac], XmNlabelString, xmstrings[0]); ac++;
	label1 = XmCreateLabel ( spinbox, (char *) "label1", al, ac );
	ac = 0;
	XmStringFree ( xmstrings [ 0 ] );
	XtSetArg(al[ac], XmNmaximumValue, 59); ac++;
	XtSetArg(al[ac], XmNminimumValue, 0); ac++;
	XtSetArg(al[ac], XmNposition, 0); ac++;
	XtSetArg(al[ac], XmNspinBoxChildType, XmNUMERIC); ac++;
	XtSetArg(al[ac], XmNcolumns, 2); ac++;
	minutes = XmCreateTextField ( spinbox, (char *) "minutes", al, ac );
	ac = 0;
	xmstrings[0] = XmStringGenerate ( ":", XmFONTLIST_DEFAULT_TAG, XmCHARSET_TEXT, NULL );
	XtSetArg(al[ac], XmNlabelString, xmstrings[0]); ac++;
	label2 = XmCreateLabel ( spinbox, (char *) "label2", al, ac );
	ac = 0;
	XmStringFree ( xmstrings [ 0 ] );
	XtSetArg(al[ac], XmNmaximumValue, 59); ac++;
	XtSetArg(al[ac], XmNminimumValue, 0); ac++;
	XtSetArg(al[ac], XmNposition, 0); ac++;
	XtSetArg(al[ac], XmNspinBoxChildType, XmNUMERIC); ac++;
	XtSetArg(al[ac], XmNcolumns, 2); ac++;
	seconds = XmCreateTextField ( spinbox, (char *) "seconds", al, ac );
	ac = 0;


	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNtopOffset, 5); 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 ( spinbox,al, ac );
	ac = 0;
	set_initial_clock() ;
	if (spinbox)
		XtAddCallback( spinbox, XmNvalueChangedCallback, value_changed_callback, (XtPointer) 0 );
	if ((children[ac] = hours) != (Widget) 0) { ac++; }
	if ((children[ac] = label1) != (Widget) 0) { ac++; }
	if ((children[ac] = minutes) != (Widget) 0) { ac++; }
	if ((children[ac] = label2) != (Widget) 0) { ac++; }
	if ((children[ac] = seconds) != (Widget) 0) { ac++; }
	if (ac > 0) { XtManageChildren(children, ac); }
	ac = 0;
	if ((children[ac] = spinbox) != (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);
	}
	/* Call the Create Procedures for the Dialogs in the Application */

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

	/* Display the Primary Application Shell */

	XtRealizeWidget (app_shell);

	/* Entering X Main Loop... */

	XtAppMainLoop (app_context);

	/* NOTREACHED */

	exit (0);
}

