/***************************** 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/PushB.h>
#include <Xm/RowColumn.h>
#include <Xm/TextF.h>
#include <Xm/ToggleB.h>
#include <Tab.h>

#include <Xm/Protocols.h>
#include "UIEditor.h"

UIEditor_p UIEditor = (UIEditor_p) NULL;



void UIEditor_c::create (Display *display, char *app_name, int app_argc, char **app_argv, char *app_class_name)
{
	Widget children[5];      /* Children to manage */
	Arg al[64];                    /* Arg List */
	register int ac = 0;           /* Arg Count */
	Widget frame2 = (Widget)NULL;
	Widget form1 = (Widget)NULL;
	Widget frame3 = (Widget)NULL;
	Widget form3 = (Widget)NULL;
	Widget button1 = (Widget)NULL;
	Widget button2 = (Widget)NULL;
	Widget button3 = (Widget)NULL;

	if ( !app_class_name )
		app_class_name = "XApplication";

	XtSetArg(al[ac], XmNallowShellResize, FALSE); ac++;
	XtSetArg(al[ac], XmNdeleteResponse, XmDO_NOTHING); ac++;
	XtSetArg(al[ac], XmNargc, app_argc); ac++;
	XtSetArg(al[ac], XmNargv, app_argv); ac++;
	UIEditor = XtAppCreateShell ( app_name, app_class_name, applicationShellWidgetClass, display, al, ac );
	ac = 0;
	_xd_rootwidget = UIEditor;
	XmAddWMProtocolCallback( UIEditor, XmInternAtom(XtDisplay(UIEditor), "WM_DELETE_WINDOW", False), closeCB, (XtPointer) this);
	XtSetArg(al[ac], XmNwidth, 500); ac++;
	XtSetArg(al[ac], XmNheight, 600); ac++;
	XtSetArg(al[ac], XmNautoUnmanage, FALSE); ac++;
	form_ = XmCreateForm ( UIEditor, "form_", al, ac );
	ac = 0;
	XtSetArg(al[ac], XmNdrawer, TRUE); ac++;
	drawer_ = XtCreateWidget("drawer_", tabWidgetClass, form_, al, ac);
	ac = 0;
	main_ = XmCreateFrame ( form_, "main_", al, ac );
	frame2 = XmCreateFrame ( form_, "frame2", al, ac );
	form1 = XmCreateForm ( frame2, "form1", al, ac );
	XtSetArg(al[ac], XmNwidth, 32); ac++;
	XtSetArg(al[ac], XmNheight, 32); ac++;
	XtSetArg(al[ac], XmNhighlightThickness, 0); ac++;
	XtSetArg(al[ac], XmNshadowThickness, 0); ac++;
	XtSetArg(al[ac], XmNlabelType, XmPIXMAP); ac++;
	icon_ = XmCreatePushButton ( form1, "icon_", al, ac );
	ac = 0;
	name_ = XmCreateTextField ( form1, "name_", al, ac );
	frame3 = XmCreateFrame ( form_, "frame3", al, ac );
	form3 = XmCreateForm ( frame3, "form3", al, ac );
	button1 = XmCreatePushButton ( form3, "Apply", al, ac );
	button2 = XmCreatePushButton ( form3, "Reset", al, ac );
	button3 = XmCreatePushButton ( form3, "Close", al, ac );
	stay_ = XmCreateToggleButton ( form3, "Stay open", al, ac );
	XtSetArg(al[ac], XmNspacing, 0); ac++;
	XtSetArg(al[ac], XmNmarginWidth, 0); ac++;
	XtSetArg(al[ac], XmNmarginHeight, 0); ac++;
	XtSetArg(al[ac], XmNorientation, XmHORIZONTAL); ac++;
	tool_ = XmCreateRowColumn ( form_, "tool_", al, ac );
	ac = 0;

	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_NONE); ac++;
	XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_WIDGET); ac++;
	XtSetArg(al[ac], XmNbottomOffset, 0); ac++;
	XtSetArg(al[ac], XmNbottomWidget, frame3); 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 ( drawer_,al, ac );
	ac = 0;

	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
	XtSetArg(al[ac], XmNtopWidget, tool_); ac++;
	XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_WIDGET); ac++;
	XtSetArg(al[ac], XmNbottomOffset, 0); ac++;
	XtSetArg(al[ac], XmNbottomWidget, drawer_); 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 ( main_,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_FORM); ac++;
	XtSetArg(al[ac], XmNrightOffset, 0); ac++;
	XtSetValues ( frame2,al, ac );
	ac = 0;

	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_NONE); 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 ( frame3,al, ac );
	ac = 0;

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

	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNtopOffset, 2); ac++;
	XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNbottomOffset, 2); ac++;
	XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNleftOffset, 2); ac++;
	XtSetValues ( icon_,al, ac );
	ac = 0;

	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNtopOffset, 2); ac++;
	XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_NONE); ac++;
	XtSetArg(al[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++;
	XtSetArg(al[ac], XmNleftOffset, 2); ac++;
	XtSetArg(al[ac], XmNleftWidget, icon_); ac++;
	XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNrightOffset, 2); ac++;
	XtSetValues ( name_,al, ac );
	ac = 0;
	XtAddCallback (icon_, XmNactivateCallback, textEditorCB, (XtPointer) this);
	children[ac++] = icon_;
	children[ac++] = name_;
	XtManageChildren(children, ac);
	ac = 0;
	children[ac++] = form1;
	XtManageChildren(children, ac);
	ac = 0;

	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_NONE); ac++;
	XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNbottomOffset, 2); ac++;
	XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNleftOffset, 2); ac++;
	XtSetValues ( button1,al, ac );
	ac = 0;

	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_NONE); ac++;
	XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNbottomOffset, 2); ac++;
	XtSetArg(al[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++;
	XtSetArg(al[ac], XmNleftOffset, 2); ac++;
	XtSetArg(al[ac], XmNleftWidget, button1); ac++;
	XtSetArg(al[ac], XmNrightAttachment, XmATTACH_NONE); ac++;
	XtSetValues ( button2,al, ac );
	ac = 0;

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

	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_NONE); ac++;
	XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNbottomOffset, 2); ac++;
	XtSetArg(al[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++;
	XtSetArg(al[ac], XmNleftOffset, 2); ac++;
	XtSetArg(al[ac], XmNleftWidget, button2); ac++;
	XtSetArg(al[ac], XmNrightAttachment, XmATTACH_NONE); ac++;
	XtSetValues ( stay_,al, ac );
	ac = 0;
	XtAddCallback (button1, XmNactivateCallback, applyCB, (XtPointer) this);
	XtAddCallback (button2, XmNactivateCallback, resetCB, (XtPointer) this);
	XtAddCallback (button3, XmNactivateCallback, closeCB, (XtPointer) this);
	children[ac++] = button1;
	children[ac++] = button2;
	children[ac++] = button3;
	children[ac++] = stay_;
	XtManageChildren(children, ac);
	ac = 0;
	children[ac++] = form3;
	XtManageChildren(children, ac);
	ac = 0;
	children[ac++] = drawer_;
	children[ac++] = main_;
	children[ac++] = frame2;
	children[ac++] = frame3;
	children[ac++] = tool_;
	XtManageChildren(children, ac);
	ac = 0;
	XtManageChild ( form_);
}

void UIEditor_c::textEditorCB( Widget widget, XtPointer client_data, XtPointer call_data )
{
	UIEditor_p instance = (UIEditor_p) client_data;
	instance->textEditorCB ( widget, call_data );
}

void UIEditor_c::resetCB( Widget widget, XtPointer client_data, XtPointer call_data )
{
	UIEditor_p instance = (UIEditor_p) client_data;
	instance->resetCB ( widget, call_data );
}

void UIEditor_c::applyCB( Widget widget, XtPointer client_data, XtPointer call_data )
{
	UIEditor_p instance = (UIEditor_p) client_data;
	instance->applyCB ( widget, call_data );
}

void UIEditor_c::closeCB( Widget widget, XtPointer client_data, XtPointer call_data )
{
	UIEditor_p instance = (UIEditor_p) client_data;
	instance->closeCB ( widget, call_data );
}

