/***************************** 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/Label.h>
#include <Xm/PushB.h>
#include <Xm/RowColumn.h>
#include <Xm/ScrollBar.h>
#include <Xm/ScrolledW.h>
#include <Xm/Separator.h>
#include <Drag.h>

#include <xdclass.h>

class UIViewsDrawer_c: public xd_XmForm_c {
public:
	virtual void create (Widget parent, char *widget_name = NULL);
protected:
	Widget UIViewsDrawer;
	Widget drag_;
	Widget menu1_;
	Widget menu2_;
public:
	static void updateCB( Widget, XtPointer, XtPointer );
	virtual void updateCB( Widget, XtPointer ) = 0;
	static void openFolderCB( Widget, XtPointer, XtPointer );
	virtual void openFolderCB( Widget, XtPointer ) = 0;
	static void editCB( Widget, XtPointer, XtPointer );
	virtual void editCB( Widget, XtPointer ) = 0;
};

typedef UIViewsDrawer_c *UIViewsDrawer_p;

UIViewsDrawer_p UIViewsDrawer = (UIViewsDrawer_p) NULL;



void UIViewsDrawer_c::create (Widget parent, char *widget_name)
{
	Widget children[3];      /* Children to manage */
	Arg al[64];                    /* Arg List */
	register int ac = 0;           /* Arg Count */
	Widget scrolledWin1 = (Widget)NULL;
	Widget scrollbar1 = (Widget)NULL;
	Widget scrollbar2 = (Widget)NULL;
	Widget label1 = (Widget)NULL;
	Widget separator1 = (Widget)NULL;
	Widget button1 = (Widget)NULL;
	Widget button4 = (Widget)NULL;
	Widget button2 = (Widget)NULL;

	if ( !widget_name )
		widget_name = "Views";

	XtSetArg(al[ac], XmNautoUnmanage, FALSE); ac++;
	UIViewsDrawer = XmCreateForm ( parent, widget_name, al, ac );
	ac = 0;
	_xd_rootwidget = UIViewsDrawer;
	XtSetArg(al[ac], XmNscrollingPolicy, XmAUTOMATIC); ac++;
	scrolledWin1 = XmCreateScrolledWindow ( UIViewsDrawer, "scrolledWin1", al, ac );
	ac = 0;

	XtSetArg(al[ac], XmNhorizontalScrollBar, &scrollbar1 ); ac++;
	XtSetArg(al[ac], XmNverticalScrollBar, &scrollbar2 ); ac++;
	XtGetValues(scrolledWin1, al, ac );
	ac = 0;
	XtSetArg(al[ac], XmNautoSort, TRUE); ac++;
	XtSetArg(al[ac], XmNautoClean, TRUE); ac++;
	XtSetArg(al[ac], XmNeditNames, TRUE); ac++;
	XtSetArg(al[ac], XmNwidth, 32000); ac++;
	XtSetArg(al[ac], XmNheight, 32000); ac++;
	drag_ = XtCreateWidget("drag_", dragWidgetClass, scrolledWin1, al, ac);
	ac = 0;
	menu1_ = XmCreatePopupMenu ( drag_, "menu_", al, ac );
	label1 = XmCreateLabel ( menu1_, "title", al, ac );
	separator1 = XmCreateSeparator ( menu1_, "separator1", al, ac );
	button1 = XmCreatePushButton ( menu1_, "edit", al, ac );
	menu2_ = XmCreatePopupMenu ( drag_, "menu2_", al, ac );
	button4 = XmCreatePushButton ( menu2_, "Open folder...", al, ac );
	button2 = XmCreatePushButton ( menu2_, "Update", al, ac );

	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
	XtSetValues ( scrolledWin1,al, ac );
	ac = 0;
	XtAddCallback (button1, XmNactivateCallback, editCB, (XtPointer) this);
	children[ac++] = label1;
	children[ac++] = separator1;
	children[ac++] = button1;
	XtManageChildren(children, ac);
	ac = 0;
	XtAddCallback (button4, XmNactivateCallback, openFolderCB, (XtPointer) this);
	XtAddCallback (button2, XmNactivateCallback, updateCB, (XtPointer) this);
	children[ac++] = button4;
	children[ac++] = button2;
	XtManageChildren(children, ac);
	ac = 0;
	children[ac++] = drag_;
	XtManageChildren(children, ac);
	ac = 0;
	XmScrolledWindowSetAreas(scrolledWin1, scrollbar1, scrollbar2, drag_ );
	children[ac++] = scrolledWin1;
	XtManageChildren(children, ac);
	ac = 0;
}

void UIViewsDrawer_c::updateCB( Widget widget, XtPointer client_data, XtPointer call_data )
{
	UIViewsDrawer_p instance = (UIViewsDrawer_p) client_data;
	instance->updateCB ( widget, call_data );
}

void UIViewsDrawer_c::openFolderCB( Widget widget, XtPointer client_data, XtPointer call_data )
{
	UIViewsDrawer_p instance = (UIViewsDrawer_p) client_data;
	instance->openFolderCB ( widget, call_data );
}

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

