/***************************** 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/CascadeB.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 UIIconDrawer_c: public xd_XmForm_c {
public:
	virtual void create (Widget parent, char *widget_name = NULL);
protected:
	Widget UIIconDrawer;
	Widget drag_;
	Widget menu1_;
	Widget menu2_;
public:
	static void updateDrawerCB( Widget, XtPointer, XtPointer );
	virtual void updateDrawerCB( Widget, XtPointer ) = 0;
	static void openFolderCB( Widget, XtPointer, XtPointer );
	virtual void openFolderCB( Widget, XtPointer ) = 0;
	static void deleteDrawerCB( Widget, XtPointer, XtPointer );
	virtual void deleteDrawerCB( Widget, XtPointer ) = 0;
	static void renameDrawerCB( Widget, XtPointer, XtPointer );
	virtual void renameDrawerCB( Widget, XtPointer ) = 0;
	static void newDrawerCB( Widget, XtPointer, XtPointer );
	virtual void newDrawerCB( Widget, XtPointer ) = 0;
	static void newIconCB( Widget, XtPointer, XtPointer );
	virtual void newIconCB( Widget, XtPointer ) = 0;
	static void deleteCB( Widget, XtPointer, XtPointer );
	virtual void deleteCB( Widget, XtPointer ) = 0;
	static void editCB( Widget, XtPointer, XtPointer );
	virtual void editCB( Widget, XtPointer ) = 0;
};

typedef UIIconDrawer_c *UIIconDrawer_p;

UIIconDrawer_p UIIconDrawer = (UIIconDrawer_p) NULL;



void UIIconDrawer_c::create (Widget parent, char *widget_name)
{
	Widget children[10];      /* 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 button2 = (Widget)NULL;
	Widget button3 = (Widget)NULL;
	Widget separator2 = (Widget)NULL;
	Widget button4 = (Widget)NULL;
	Widget button5 = (Widget)NULL;
	Widget button12 = (Widget)NULL;
	Widget button6 = (Widget)NULL;
	Widget separator3 = (Widget)NULL;
	Widget cascade1 = (Widget)NULL;
	Widget menu2 = (Widget)NULL;
	Widget button7 = (Widget)NULL;
	Widget button8 = (Widget)NULL;
	Widget button10 = (Widget)NULL;
	Widget button11 = (Widget)NULL;
	Widget separator4 = (Widget)NULL;
	Widget button9 = (Widget)NULL;

	if ( !widget_name )
		widget_name = "Templates";

	XtSetArg(al[ac], XmNautoUnmanage, FALSE); ac++;
	UIIconDrawer = XmCreateForm ( parent, widget_name, al, ac );
	ac = 0;
	_xd_rootwidget = UIIconDrawer;
	XtSetArg(al[ac], XmNscrollingPolicy, XmAUTOMATIC); ac++;
	scrolledWin1 = XmCreateScrolledWindow ( UIIconDrawer, "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, 1024); ac++;
	XtSetArg(al[ac], XmNheight, 1024); ac++;
	drag_ = XtCreateWidget("drag_", dragWidgetClass, scrolledWin1, al, ac);
	ac = 0;
	menu1_ = XmCreatePopupMenu ( drag_, "menu1_", al, ac );
	label1 = XmCreateLabel ( menu1_, "title", al, ac );
	separator1 = XmCreateSeparator ( menu1_, "separator1", al, ac );
	button1 = XmCreatePushButton ( menu1_, "edit", al, ac );
	button2 = XmCreatePushButton ( menu1_, "delete", al, ac );
	menu2_ = XmCreatePopupMenu ( drag_, "menu2_", al, ac );
	button3 = XmCreatePushButton ( menu2_, "New icon...", al, ac );
	separator2 = XmCreateSeparator ( menu2_, "separator2", al, ac );
	button4 = XmCreatePushButton ( menu2_, "New drawer", al, ac );
	button5 = XmCreatePushButton ( menu2_, "Rename this drawer...", al, ac );
	button12 = XmCreatePushButton ( menu2_, "Update this drawer...", al, ac );
	button6 = XmCreatePushButton ( menu2_, "Delete this drawer...", al, ac );
	separator3 = XmCreateSeparator ( menu2_, "separator3", al, ac );
	cascade1 = XmCreateCascadeButton ( menu2_, "Layout", al, ac );
	XtSetArg(al[ac], XmNsensitive, FALSE); ac++;
	menu2 = XmCreatePulldownMenu ( menu2_, "menu2", al, ac );
	ac = 0;
	button7 = XmCreatePushButton ( menu2, "Small icons", al, ac );
	button8 = XmCreatePushButton ( menu2, "Large icons", al, ac );
	button10 = XmCreatePushButton ( menu2, "Sort by name", al, ac );
	button11 = XmCreatePushButton ( menu2, "Sort by class", al, ac );
	separator4 = XmCreateSeparator ( menu2_, "separator4", al, ac );
	button9 = XmCreatePushButton ( menu2_, "Open associated folder", 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);
	XtAddCallback (button2, XmNactivateCallback, deleteCB, (XtPointer) this);
	children[ac++] = label1;
	children[ac++] = separator1;
	children[ac++] = button1;
	children[ac++] = button2;
	XtManageChildren(children, ac);
	ac = 0;
	XtAddCallback (button3, XmNactivateCallback, newIconCB, (XtPointer) this);
	XtAddCallback (button4, XmNactivateCallback, newDrawerCB, (XtPointer) this);
	XtAddCallback (button5, XmNactivateCallback, renameDrawerCB, (XtPointer) this);
	XtAddCallback (button12, XmNactivateCallback, updateDrawerCB, (XtPointer) this);
	XtAddCallback (button6, XmNactivateCallback, deleteDrawerCB, (XtPointer) this);
	children[ac++] = button7;
	children[ac++] = button8;
	children[ac++] = button10;
	children[ac++] = button11;
	XtManageChildren(children, ac);
	ac = 0;
	XtSetArg(al[ac], XmNsubMenuId, menu2); ac++;
	XtSetValues ( cascade1, al, ac );
	ac = 0;
	XtAddCallback (button9, XmNactivateCallback, openFolderCB, (XtPointer) this);
	children[ac++] = button3;
	children[ac++] = separator2;
	children[ac++] = button4;
	children[ac++] = button5;
	children[ac++] = button12;
	children[ac++] = button6;
	children[ac++] = separator3;
	children[ac++] = cascade1;
	children[ac++] = separator4;
	children[ac++] = button9;
	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 UIIconDrawer_c::updateDrawerCB( Widget widget, XtPointer client_data, XtPointer call_data )
{
	UIIconDrawer_p instance = (UIIconDrawer_p) client_data;
	instance->updateDrawerCB ( widget, call_data );
}

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

void UIIconDrawer_c::deleteDrawerCB( Widget widget, XtPointer client_data, XtPointer call_data )
{
	UIIconDrawer_p instance = (UIIconDrawer_p) client_data;
	instance->deleteDrawerCB ( widget, call_data );
}

void UIIconDrawer_c::renameDrawerCB( Widget widget, XtPointer client_data, XtPointer call_data )
{
	UIIconDrawer_p instance = (UIIconDrawer_p) client_data;
	instance->renameDrawerCB ( widget, call_data );
}

void UIIconDrawer_c::newDrawerCB( Widget widget, XtPointer client_data, XtPointer call_data )
{
	UIIconDrawer_p instance = (UIIconDrawer_p) client_data;
	instance->newDrawerCB ( widget, call_data );
}

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

void UIIconDrawer_c::deleteCB( Widget widget, XtPointer client_data, XtPointer call_data )
{
	UIIconDrawer_p instance = (UIIconDrawer_p) client_data;
	instance->deleteCB ( widget, call_data );
}

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

