/***************************** 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 "xdclass.h"

class UIIconLine_c: public xd_XmForm_c {
public:
	virtual void create (Widget parent, char *widget_name = NULL);
protected:
	Widget UIIconLine;
	Widget drag_;
	Widget menu1_;
	Widget menu2_;
	Widget hidden_;
	Widget class_;
public:
	static void newIconCB( Widget, XtPointer, XtPointer );
	virtual void newIconCB( Widget, XtPointer ) = 0;
	static void openHiddenCB( Widget, XtPointer, XtPointer );
	virtual void openHiddenCB( Widget, XtPointer ) = 0;
	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 UIIconLine_c *UIIconLine_p;

UIIconLine_p UIIconLine = (UIIconLine_p) NULL;



void UIIconLine_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 */
	XPointer to_address; /* For Thread-safe resource conversion */ 
	Pixel to_pixel; /* For Thread-safe resource conversion */ 
	XtPointer tmp_value;             /* ditto */
	Widget widget2 = (Widget)NULL;
	Widget widget3 = (Widget)NULL;
	Widget widget4 = (Widget)NULL;
	Widget widget5 = (Widget)NULL;
	Widget widget6 = (Widget)NULL;
	Widget widget7 = (Widget)NULL;
	Widget widget8 = (Widget)NULL;
	Widget widget9 = (Widget)NULL;

	if ( !widget_name )
		widget_name = (char *) "UIIconLine";

	XtSetArg(al[ac], XmNautoUnmanage, FALSE); ac++;
	UIIconLine = XmCreateForm ( parent, widget_name, al, ac );
	ac = 0;
	_xd_rootwidget = UIIconLine;
	XtSetArg(al[ac], XmNshadowType, XmSHADOW_IN); ac++;
	widget2 = XmCreateFrame ( UIIconLine, (char *) "widget2", al, ac );
	ac = 0;
	XtSetArg(al[ac], XmNautoClean, TRUE); ac++;
	XtSetArg(al[ac], XmNsingleLine, TRUE); ac++;
	XtSetArg(al[ac], XmNeditNames, FALSE); ac++;
	XtSetArg(al[ac], XmNheight, 60); ac++;
	if (DefaultDepthOfScreen(DefaultScreenOfDisplay(display)) != 1) {

		from_value.addr = "#fb8bfb8bfb8b" ;
		from_value.size = strlen( from_value.addr ) + 1;
		to_value.size = sizeof(Pixel);
		to_value.addr = (XPointer) &to_pixel;
		XtConvertAndStore (widget2, XmRString, &from_value, XmRPixel, &to_value);

		if ( to_value.addr ) {
			XtSetArg(al[ac], XmNbackground, (*((Pixel*) to_value.addr))); ac++;
		}
	}
	drag_ = XtCreateWidget("drag_", dragWidgetClass, widget2, al, ac);
	ac = 0;
	menu1_ = XmCreatePopupMenu ( drag_, (char *) "menu1_", al, ac );
	widget3 = XmCreateLabel ( menu1_, (char *) "title", al, ac );
	widget4 = XmCreateSeparator ( menu1_, (char *) "widget4", al, ac );
	widget5 = XmCreatePushButton ( menu1_, (char *) "edit", al, ac );
	widget6 = XmCreatePushButton ( menu1_, (char *) "remove", al, ac );
	menu2_ = XmCreatePopupMenu ( drag_, (char *) "menu2_", al, ac );
	XtSetArg(al[ac], XmNsensitive, FALSE); ac++;
	widget7 = XmCreatePushButton ( menu2_, (char *) "New icon...", al, ac );
	ac = 0;
	hidden_ = XmCreatePushButton ( menu2_, (char *) "Open hidden folder....", al, ac );
	XtSetArg(al[ac], XmNframeChildType, XmFRAME_TITLE_CHILD); ac++;
	class_ = XmCreateLabel ( widget2, (char *) "GRIB:", al, ac );
	ac = 0;
	XtSetArg(al[ac], XmNheight, 80); ac++;
	widget8 = XmCreateDrawingArea ( UIIconLine, (char *) "widget8", al, ac );
	ac = 0;
	XtSetArg(al[ac], XmNwidth, 290); ac++;
	XtSetArg(al[ac], XmNheight, 1); ac++;
	widget9 = XmCreateDrawingArea ( UIIconLine, (char *) "widget9", al, ac );
	ac = 0;

	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_WIDGET); ac++;
	XtSetArg(al[ac], XmNbottomWidget, widget9); ac++;
	XtSetArg(al[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++;
	XtSetArg(al[ac], XmNleftWidget, widget8); ac++;
	XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
	XtSetValues ( widget2, 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_NONE); ac++;
	XtSetValues ( widget8, al, ac );
	ac = 0;

	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
	XtSetArg(al[ac], XmNtopWidget, widget8); ac++;
	XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
	XtSetValues ( widget9, al, ac );
	ac = 0;
	XtAddCallback (widget5, XmNactivateCallback, &UIIconLine_c::editCB, (XtPointer) this);
	XtAddCallback (widget6, XmNactivateCallback, &UIIconLine_c::removeCB, (XtPointer) this);
	if ((children[ac] = widget3) != (Widget) 0) { ac++; }
	if ((children[ac] = widget4) != (Widget) 0) { ac++; }
	if ((children[ac] = widget5) != (Widget) 0) { ac++; }
	if ((children[ac] = widget6) != (Widget) 0) { ac++; }
	if (ac > 0) { XtManageChildren(children, ac); }
	ac = 0;
	XtAddCallback (widget7, XmNactivateCallback, &UIIconLine_c::newIconCB, (XtPointer) this);
	XtAddCallback (hidden_, XmNactivateCallback, &UIIconLine_c::openHiddenCB, (XtPointer) this);
	if ((children[ac] = widget7) != (Widget) 0) { ac++; }
	if ((children[ac] = hidden_) != (Widget) 0) { ac++; }
	if (ac > 0) { XtManageChildren(children, ac); }
	ac = 0;
	if ((children[ac] = drag_) != (Widget) 0) { ac++; }
	if ((children[ac] = class_) != (Widget) 0) { ac++; }
	if (ac > 0) { XtManageChildren(children, ac); }
	ac = 0;
	if ((children[ac] = widget2) != (Widget) 0) { ac++; }
	if ((children[ac] = widget8) != (Widget) 0) { ac++; }
	if ((children[ac] = widget9) != (Widget) 0) { ac++; }
	if (ac > 0) { XtManageChildren(children, ac); }
	ac = 0;
}

void UIIconLine_c::newIconCB( Widget widget, XtPointer client_data, XtPointer call_data )
{
	UIIconLine_p instance = (UIIconLine_p) client_data;
	instance->newIconCB ( widget, call_data );
}

void UIIconLine_c::openHiddenCB( Widget widget, XtPointer client_data, XtPointer call_data )
{
	UIIconLine_p instance = (UIIconLine_p) client_data;
	instance->openHiddenCB ( widget, call_data );
}

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

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

