/***************************** LICENSE START ***********************************

 Copyright 2012 ECMWF and INPE. This software is distributed under the terms
 of the Apache License version 2.0. In applying this license, ECMWF does not
 waive the privileges and immunities granted to it by virtue of its status as
 an Intergovernmental Organization or submit itself to any jurisdiction.

 ***************************** LICENSE END *************************************/

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

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

#include <Xm/Xm.h>
#include <Xm/DialogS.h>
#include <Xm/Form.h>
#include <Xm/Label.h>
#include <Xm/PushB.h>
#include <Xm/RowColumn.h>

#include <xdclass.h>

class UICatalogDrawer_c: public xd_XmForm_c {
public:
	virtual void create (Widget parent, char *widget_name = NULL);
protected:
	Widget UICatalogDrawer;
	Widget message_;
public:
	static void helpCB( Widget, XtPointer, XtPointer );
	virtual void helpCB( Widget, XtPointer ) = 0;
	static void homeCB( Widget, XtPointer, XtPointer );
	virtual void homeCB( Widget, XtPointer ) = 0;
	static void grabCatalogCB( Widget, XtPointer, XtPointer );
	virtual void grabCatalogCB( Widget, XtPointer ) = 0;
	static void inCatalogCB( Widget, XtPointer, XtPointer );
	virtual void inCatalogCB( Widget, XtPointer ) = 0;
	static void topCatalogCB( Widget, XtPointer, XtPointer );
	virtual void topCatalogCB( Widget, XtPointer ) = 0;
};

typedef UICatalogDrawer_c *UICatalogDrawer_p;

UICatalogDrawer_p UICatalogDrawer = (UICatalogDrawer_p) NULL;



void UICatalogDrawer_c::create (Widget parent, char *widget_name)
{
	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 */
	XmString xmstrings[16];    /* temporary storage for XmStrings */
	Widget rowcol1 = (Widget)NULL;
	Widget button4 = (Widget)NULL;
	Widget button1 = (Widget)NULL;
	Widget button3 = (Widget)NULL;
	Widget button2 = (Widget)NULL;

	if ( !widget_name )
		widget_name = "MARS Catalogue";

	XtSetArg(al[ac], XmNautoUnmanage, FALSE); ac++;
	UICatalogDrawer = XmCreateForm ( parent, widget_name, al, ac );
	ac = 0;
	_xd_rootwidget = UICatalogDrawer;
	XtSetArg(al[ac], XmNnumColumns, 2); ac++;
	XtSetArg(al[ac], XmNpacking, XmPACK_COLUMN); ac++;
	rowcol1 = XmCreateRowColumn ( UICatalogDrawer, "rowcol1", al, ac );
	ac = 0;
	xmstrings[0] = XmStringCreateLtoR ( "MARS home page", (XmStringCharSet)XmFONTLIST_DEFAULT_TAG );
	XtSetArg(al[ac], XmNlabelString, xmstrings[0]); ac++;
	button4 = XmCreatePushButton ( rowcol1, "button4", al, ac );
	ac = 0;
	XmStringFree ( xmstrings [ 0 ] );
	xmstrings[0] = XmStringCreateLtoR ( "Open the MARS catalogue", (XmStringCharSet)XmFONTLIST_DEFAULT_TAG );
	XtSetArg(al[ac], XmNlabelString, xmstrings[0]); ac++;
	button1 = XmCreatePushButton ( rowcol1, "button1", al, ac );
	ac = 0;
	XmStringFree ( xmstrings [ 0 ] );
	xmstrings[0] = XmStringCreateLtoR ( "Find the current settings in the catalogue", (XmStringCharSet)XmFONTLIST_DEFAULT_TAG );
	XtSetArg(al[ac], XmNlabelString, xmstrings[0]); ac++;
	button3 = XmCreatePushButton ( rowcol1, "button3", al, ac );
	ac = 0;
	XmStringFree ( xmstrings [ 0 ] );
	xmstrings[0] = XmStringCreateLtoR ( "Grab request from current page", (XmStringCharSet)XmFONTLIST_DEFAULT_TAG );
	XtSetArg(al[ac], XmNlabelString, xmstrings[0]); ac++;
	button2 = XmCreatePushButton ( rowcol1, "button2", al, ac );
	ac = 0;
	XmStringFree ( xmstrings [ 0 ] );
	xmstrings[0] = XmStringCreateLtoR ( " ", (XmStringCharSet)XmFONTLIST_DEFAULT_TAG );
	XtSetArg(al[ac], XmNlabelString, xmstrings[0]); ac++;
	XtSetArg(al[ac], XmNalignment, XmALIGNMENT_CENTER); ac++;
	from_value.addr = "-*-*-bold-i-*-*-14-*-*-*-*-*-*-*" ;
	from_value.size = strlen( from_value.addr ) + 1;
	to_value.addr = NULL;
	XtConvertAndStore (UICatalogDrawer, XmRString, &from_value, XmRFontList, &to_value);
	if ( to_value.addr )
	{
		XtSetArg(al[ac], XmNfontList, *(unsigned int *)to_value.addr); ac++;
	}
	message_ = XmCreateLabel ( UICatalogDrawer, "message_", al, ac );
	ac = 0;
	XmStringFree ( xmstrings [ 0 ] );

	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
	XtSetArg(al[ac], XmNtopWidget, message_); ac++;
	XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_NONE); ac++;
	XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNrightAttachment, XmATTACH_NONE); ac++;
	XtSetValues ( rowcol1,al, ac );
	ac = 0;

	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_NONE); ac++;
	XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
	XtSetValues ( message_,al, ac );
	ac = 0;
	XtAddCallback (button4, XmNactivateCallback, homeCB, (XtPointer) this);
	XtAddCallback (button1, XmNactivateCallback, topCatalogCB, (XtPointer) this);
	XtAddCallback (button3, XmNactivateCallback, inCatalogCB, (XtPointer) this);
//	XtAddCallback (button2, XmNactivateCallback, grabCatalogCB, (XtPointer) this);
	children[ac++] = button4;
	children[ac++] = button1;
	children[ac++] = button3;
//	children[ac++] = button2;
	XtManageChildren(children, ac);
	ac = 0;
	children[ac++] = rowcol1;
	children[ac++] = message_;
	XtManageChildren(children, ac);
	ac = 0;
}

void UICatalogDrawer_c::helpCB( Widget widget, XtPointer client_data, XtPointer call_data )
{
	UICatalogDrawer_p instance = (UICatalogDrawer_p) client_data;
	instance->helpCB ( widget, call_data );
}

void UICatalogDrawer_c::homeCB( Widget widget, XtPointer client_data, XtPointer call_data )
{
	UICatalogDrawer_p instance = (UICatalogDrawer_p) client_data;
	instance->homeCB ( widget, call_data );
}

void UICatalogDrawer_c::grabCatalogCB( Widget widget, XtPointer client_data, XtPointer call_data )
{
	UICatalogDrawer_p instance = (UICatalogDrawer_p) client_data;
	instance->grabCatalogCB ( widget, call_data );
}

void UICatalogDrawer_c::inCatalogCB( Widget widget, XtPointer client_data, XtPointer call_data )
{
	UICatalogDrawer_p instance = (UICatalogDrawer_p) client_data;
	instance->inCatalogCB ( widget, call_data );
}

void UICatalogDrawer_c::topCatalogCB( Widget widget, XtPointer client_data, XtPointer call_data )
{
	UICatalogDrawer_p instance = (UICatalogDrawer_p) client_data;
	instance->topCatalogCB ( widget, call_data );
}

