/***************************** 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/DrawingA.h>
#include <Xm/Form.h>
#include <Xm/Frame.h>
#include <Xm/Label.h>
#include <Xm/PushB.h>
#include <Xm/RowColumn.h>
#include <Xm/Separator.h>
#include <Drag.h>
#include <Array.h>

#include <xdclass.h>

class UIParamEditor_c: public xd_XmForm_c {
public:
	virtual void create (Widget parent, char *widget_name = NULL);
protected:
	Widget UIParamEditor;
	Widget drag_;
	Widget menu_;
	Widget Macro;
	Widget editor_;
public:
	static void removeCB( Widget, XtPointer, XtPointer );
	virtual void removeCB( Widget, XtPointer ) = 0;
	static void editCB( Widget, XtPointer, XtPointer );
	virtual void editCB( Widget, XtPointer ) = 0;
};

typedef UIParamEditor_c *UIParamEditor_p;

UIParamEditor_p UIParamEditor = (UIParamEditor_p) NULL;



void UIParamEditor_c::create (Widget parent, char *widget_name)
{
	Widget children[4];      /* Children to manage */
	Display *display = XtDisplay ( parent );
	Arg al[64];                    /* Arg List */
	register int ac = 0;           /* Arg Count */
	XrmValue from_value, to_value; /* For resource conversion */
	Widget form1 = (Widget)NULL;
	Widget frame1 = (Widget)NULL;
	Widget label1 = (Widget)NULL;
	Widget separator1 = (Widget)NULL;
	Widget button1 = (Widget)NULL;
	Widget button2 = (Widget)NULL;
	Widget drawingArea4 = (Widget)NULL;
	Widget drawingArea3 = (Widget)NULL;

	if ( !widget_name )
		widget_name = "UIParamEditor";

	XtSetArg(al[ac], XmNautoUnmanage, FALSE); ac++;
	UIParamEditor = XmCreateForm ( parent, widget_name, al, ac );
	ac = 0;
	_xd_rootwidget = UIParamEditor;
	form1 = XmCreateForm ( UIParamEditor, "form1", al, ac );
	if (DefaultDepthOfScreen(DefaultScreenOfDisplay(display)) != 1) {
	from_value.addr = "oldlace" ;
	from_value.size = strlen( from_value.addr ) + 1;
	to_value.addr = NULL;
	XtConvertAndStore (form1, XmRString, &from_value, XmRPixel, &to_value);
	if ( to_value.addr )
	{
		XtSetArg(al[ac], XmNbackground, *(unsigned int *)to_value.addr); ac++;
	}
	}
	XtSetArg(al[ac], XmNshadowType, XmSHADOW_IN); ac++;
	frame1 = XmCreateFrame ( form1, "frame1", al, ac );
	ac = 0;
	XtSetArg(al[ac], XmNwidth, 300); ac++;
	if (DefaultDepthOfScreen(DefaultScreenOfDisplay(display)) != 1) {
	from_value.addr = "oldlace" ;
	from_value.size = strlen( from_value.addr ) + 1;
	to_value.addr = NULL;
	XtConvertAndStore (frame1, XmRString, &from_value, XmRPixel, &to_value);
	if ( to_value.addr )
	{
		XtSetArg(al[ac], XmNbackground, *(unsigned int *)to_value.addr); ac++;
	}
	}
	drag_ = XtCreateWidget("drag_", dragWidgetClass, frame1, al, ac);
	ac = 0;
	menu_ = XmCreatePopupMenu ( drag_, "menu_", al, ac );
	label1 = XmCreateLabel ( menu_, "title", al, ac );
	separator1 = XmCreateSeparator ( menu_, "separator1", al, ac );
	button1 = XmCreatePushButton ( menu_, "edit", al, ac );
	button2 = XmCreatePushButton ( menu_, "remove", al, ac );
	XtSetArg(al[ac], XmNchildType, XmFRAME_TITLE_CHILD); ac++;
	Macro = XmCreateLabel ( frame1, "Macro", al, ac );
	ac = 0;
	XtSetArg(al[ac], XmNheight, 70); ac++;
	drawingArea4 = XmCreateDrawingArea ( form1, "drawingArea4", al, ac );
	ac = 0;
	XtSetArg(al[ac], XmNwidth, 350); ac++;
	drawingArea3 = XmCreateDrawingArea ( form1, "drawingArea3", al, ac );
	ac = 0;
	editor_ = XtCreateWidget("editor_", arrayWidgetClass, form1, al, ac);

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

	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNtopOffset, 0); ac++;
	XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
	XtSetArg(al[ac], XmNbottomOffset, 0); ac++;
	XtSetArg(al[ac], XmNbottomWidget, drawingArea4); ac++;
	XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNleftOffset, 0); ac++;
	XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNrightOffset, 0); ac++;
	XtSetValues ( frame1,al, ac );
	ac = 0;

	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNtopOffset, 0); ac++;
	XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_NONE); ac++;
	XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNleftOffset, 0); ac++;
	XtSetArg(al[ac], XmNrightAttachment, XmATTACH_NONE); ac++;
	XtSetValues ( drawingArea4,al, ac );
	ac = 0;

	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNtopOffset, 73); ac++;
	XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_NONE); ac++;
	XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNleftOffset, 0); ac++;
	XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNrightOffset, 0); ac++;
	XtSetValues ( drawingArea3,al, ac );
	ac = 0;

	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
	XtSetArg(al[ac], XmNtopOffset, 0); ac++;
	XtSetArg(al[ac], XmNtopWidget, frame1); ac++;
	XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNbottomOffset, 0); ac++;
	XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNleftOffset, 0); ac++;
	XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNrightOffset, 0); ac++;
	XtSetValues ( editor_,al, ac );
	ac = 0;
	XtAddCallback (button1, XmNactivateCallback, editCB, (XtPointer) this);
	XtAddCallback (button2, XmNactivateCallback, removeCB, (XtPointer) this);
	children[ac++] = label1;
	children[ac++] = separator1;
	children[ac++] = button1;
	children[ac++] = button2;
	XtManageChildren(children, ac);
	ac = 0;
	children[ac++] = drag_;
	children[ac++] = Macro;
	XtManageChildren(children, ac);
	ac = 0;
	children[ac++] = frame1;
	children[ac++] = drawingArea4;
	children[ac++] = drawingArea3;
	children[ac++] = editor_;
	XtManageChildren(children, ac);
	ac = 0;
	children[ac++] = form1;
	XtManageChildren(children, ac);
	ac = 0;
}

void UIParamEditor_c::removeCB( Widget widget, XtPointer client_data, XtPointer call_data )
{
	UIParamEditor_p instance = (UIParamEditor_p) client_data;
	instance->removeCB ( widget, call_data );
}

void UIParamEditor_c::editCB( Widget widget, XtPointer client_data, XtPointer call_data )
{
	UIParamEditor_p instance = (UIParamEditor_p) client_data;
	instance->editCB ( widget, call_data );
}

