/***************************** 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/RowColumn.h>
#include <Xm/Scale.h>
#include <Xm/ScrollBar.h>
#include <Xm/ScrolledW.h>
#include <Tab.h>

#include <xdclass.h>

class UIColourEditor_c: public xd_XmForm_c {
public:
	virtual void create (Widget parent, char *widget_name = NULL);
protected:
	Widget UIColourEditor;
	Widget old_;
	Widget new_;
	Widget tab_;
	Widget names_;
	Widget r_;
	Widget rr_;
	Widget g_;
	Widget gg_;
	Widget b_;
	Widget bb_;
	Widget h_;
	Widget hh_;
	Widget s_;
	Widget ss_;
	Widget l_;
	Widget ll_;
public:
	static void tabCB( Widget, XtPointer, XtPointer );
	virtual void tabCB( Widget, XtPointer ) = 0;
	static void exposeCB( Widget, XtPointer, XtPointer );
	virtual void exposeCB( Widget, XtPointer ) = 0;
	static void hslCB( Widget, XtPointer, XtPointer );
	virtual void hslCB( Widget, XtPointer ) = 0;
	static void rgbCB( Widget, XtPointer, XtPointer );
	virtual void rgbCB( Widget, XtPointer ) = 0;
};

typedef UIColourEditor_c *UIColourEditor_p;

UIColourEditor_p UIColourEditor = (UIColourEditor_p) NULL;



void UIColourEditor_c::create (Widget parent, char *widget_name)
{
	Widget children[6];      /* Children to manage */
	Arg al[64];                    /* Arg List */
	register int ac = 0;           /* Arg Count */
	Widget frame1 = (Widget)NULL;
	Widget form1 = (Widget)NULL;
	Widget form2 = (Widget)NULL;
	Widget scrolledWin1 = (Widget)NULL;
	Widget scrollbar1 = (Widget)NULL;
	Widget scrollbar2 = (Widget)NULL;
	Widget form3 = (Widget)NULL;
	Widget rowcol1 = (Widget)NULL;
	Widget form4 = (Widget)NULL;
	Widget rowcol2 = (Widget)NULL;

	if ( !widget_name )
		widget_name = "UIColourEditor";

	XtSetArg(al[ac], XmNautoUnmanage, FALSE); ac++;
	UIColourEditor = XmCreateForm ( parent, widget_name, al, ac );
	ac = 0;
	_xd_rootwidget = UIColourEditor;
	XtSetArg(al[ac], XmNmarginHeight, 0); ac++;
	XtSetArg(al[ac], XmNmarginWidth, 0); ac++;
	frame1 = XmCreateFrame ( UIColourEditor, "frame1", al, ac );
	ac = 0;
	form1 = XmCreateForm ( frame1, "form1", al, ac );
	XtSetArg(al[ac], XmNheight, 80); ac++;
	old_ = XmCreateDrawingArea ( form1, "old_", al, ac );
	ac = 0;
	XtSetArg(al[ac], XmNheight, 80); ac++;
	new_ = XmCreateDrawingArea ( form1, "new_", al, ac );
	ac = 0;
	tab_ = XtCreateWidget("tab_", tabWidgetClass, UIColourEditor, al, ac);
	form2 = XmCreateForm ( tab_, "MAGICS", al, ac );
	XtSetArg(al[ac], XmNscrollingPolicy, XmAUTOMATIC); ac++;
	scrolledWin1 = XmCreateScrolledWindow ( form2, "scrolledWin1", al, ac );
	ac = 0;

	XtSetArg(al[ac], XmNhorizontalScrollBar, &scrollbar1 ); ac++;
	XtSetArg(al[ac], XmNverticalScrollBar, &scrollbar2 ); ac++;
	XtGetValues(scrolledWin1, al, ac );
	ac = 0;
	names_ = XmCreateRowColumn ( scrolledWin1, "names_", al, ac );
	form3 = XmCreateForm ( tab_, "RGB", al, ac );
	rowcol1 = XmCreateRowColumn ( form3, "rowcol1", al, ac );
	XtSetArg(al[ac], XmNx, 3); ac++;
	XtSetArg(al[ac], XmNy, 3); ac++;
	XtSetArg(al[ac], XmNshowValue, TRUE); ac++;
	XtSetArg(al[ac], XmNorientation, XmHORIZONTAL); ac++;
	XtSetArg(al[ac], XmNdecimalPoints, 2); ac++;
	r_ = XmCreateScale ( rowcol1, "r_", al, ac );
	ac = 0;
	XtSetArg(al[ac], XmNwidth, 256); ac++;
	XtSetArg(al[ac], XmNheight, 20); ac++;
	rr_ = XmCreateDrawingArea ( rowcol1, "rr_", al, ac );
	ac = 0;
	XtSetArg(al[ac], XmNx, 3); ac++;
	XtSetArg(al[ac], XmNy, 55); ac++;
	XtSetArg(al[ac], XmNshowValue, TRUE); ac++;
	XtSetArg(al[ac], XmNorientation, XmHORIZONTAL); ac++;
	XtSetArg(al[ac], XmNdecimalPoints, 2); ac++;
	g_ = XmCreateScale ( rowcol1, "g_", al, ac );
	ac = 0;
	XtSetArg(al[ac], XmNwidth, 256); ac++;
	XtSetArg(al[ac], XmNheight, 20); ac++;
	gg_ = XmCreateDrawingArea ( rowcol1, "gg_", al, ac );
	ac = 0;
	XtSetArg(al[ac], XmNx, 3); ac++;
	XtSetArg(al[ac], XmNy, 107); ac++;
	XtSetArg(al[ac], XmNshowValue, TRUE); ac++;
	XtSetArg(al[ac], XmNorientation, XmHORIZONTAL); ac++;
	XtSetArg(al[ac], XmNdecimalPoints, 2); ac++;
	b_ = XmCreateScale ( rowcol1, "b_", al, ac );
	ac = 0;
	XtSetArg(al[ac], XmNwidth, 256); ac++;
	XtSetArg(al[ac], XmNheight, 20); ac++;
	bb_ = XmCreateDrawingArea ( rowcol1, "bb_", al, ac );
	ac = 0;
	form4 = XmCreateForm ( tab_, "HSL", al, ac );
	rowcol2 = XmCreateRowColumn ( form4, "rowcol2", al, ac );
	XtSetArg(al[ac], XmNx, 3); ac++;
	XtSetArg(al[ac], XmNy, 3); ac++;
	XtSetArg(al[ac], XmNshowValue, TRUE); ac++;
	XtSetArg(al[ac], XmNmaximum, 360); ac++;
	XtSetArg(al[ac], XmNorientation, XmHORIZONTAL); ac++;
	h_ = XmCreateScale ( rowcol2, "h_", al, ac );
	ac = 0;
	XtSetArg(al[ac], XmNwidth, 256); ac++;
	XtSetArg(al[ac], XmNheight, 20); ac++;
	hh_ = XmCreateDrawingArea ( rowcol2, "hh_", al, ac );
	ac = 0;
	XtSetArg(al[ac], XmNx, 3); ac++;
	XtSetArg(al[ac], XmNy, 65); ac++;
	XtSetArg(al[ac], XmNshowValue, TRUE); ac++;
	XtSetArg(al[ac], XmNorientation, XmHORIZONTAL); ac++;
	XtSetArg(al[ac], XmNdecimalPoints, 2); ac++;
	s_ = XmCreateScale ( rowcol2, "s_", al, ac );
	ac = 0;
	XtSetArg(al[ac], XmNwidth, 256); ac++;
	XtSetArg(al[ac], XmNheight, 20); ac++;
	ss_ = XmCreateDrawingArea ( rowcol2, "ss_", al, ac );
	ac = 0;
	XtSetArg(al[ac], XmNx, 3); ac++;
	XtSetArg(al[ac], XmNy, 127); ac++;
	XtSetArg(al[ac], XmNshowValue, TRUE); ac++;
	XtSetArg(al[ac], XmNorientation, XmHORIZONTAL); ac++;
	XtSetArg(al[ac], XmNdecimalPoints, 2); ac++;
	l_ = XmCreateScale ( rowcol2, "l_", al, ac );
	ac = 0;
	XtSetArg(al[ac], XmNwidth, 256); ac++;
	XtSetArg(al[ac], XmNheight, 20); ac++;
	ll_ = XmCreateDrawingArea ( rowcol2, "ll_", 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_FORM); ac++;
	XtSetValues ( frame1,al, ac );
	ac = 0;

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

	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_POSITION); ac++;
	XtSetArg(al[ac], XmNrightPosition, 50); ac++;
	XtSetValues ( old_,al, ac );
	ac = 0;

	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNleftAttachment, XmATTACH_POSITION); ac++;
	XtSetArg(al[ac], XmNleftPosition, 50); ac++;
	XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
	XtSetValues ( new_,al, ac );
	ac = 0;
	children[ac++] = old_;
	children[ac++] = new_;
	XtManageChildren(children, ac);
	ac = 0;
	children[ac++] = form1;
	XtManageChildren(children, ac);
	ac = 0;
	XtAddCallback (tab_, XmNvalueChangedCallback, tabCB, (XtPointer) this);

	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;
	children[ac++] = names_;
	XtManageChildren(children, ac);
	ac = 0;
	XmScrolledWindowSetAreas(scrolledWin1, scrollbar1, scrollbar2, names_ );
	children[ac++] = scrolledWin1;
	XtManageChildren(children, ac);
	ac = 0;

	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNtopOffset, 40); ac++;
	XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_NONE); ac++;
	XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNleftOffset, 80); ac++;
	XtSetArg(al[ac], XmNrightAttachment, XmATTACH_NONE); ac++;
	XtSetValues ( rowcol1,al, ac );
	ac = 0;
	XtAddCallback (r_, XmNdragCallback, rgbCB, (XtPointer) this);
	XtAddCallback (r_, XmNvalueChangedCallback, rgbCB, (XtPointer) this);
	XtAddCallback (rr_, XmNexposeCallback, exposeCB, (XtPointer) this);
	XtAddCallback (g_, XmNdragCallback, rgbCB, (XtPointer) this);
	XtAddCallback (g_, XmNvalueChangedCallback, rgbCB, (XtPointer) this);
	XtAddCallback (gg_, XmNexposeCallback, exposeCB, (XtPointer) this);
	XtAddCallback (b_, XmNdragCallback, rgbCB, (XtPointer) this);
	XtAddCallback (b_, XmNvalueChangedCallback, rgbCB, (XtPointer) this);
	XtAddCallback (bb_, XmNexposeCallback, exposeCB, (XtPointer) this);
	children[ac++] = r_;
	children[ac++] = rr_;
	children[ac++] = g_;
	children[ac++] = gg_;
	children[ac++] = b_;
	children[ac++] = bb_;
	XtManageChildren(children, ac);
	ac = 0;
	children[ac++] = rowcol1;
	XtManageChildren(children, ac);
	ac = 0;

	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNtopOffset, 40); ac++;
	XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_NONE); ac++;
	XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNleftOffset, 80); ac++;
	XtSetArg(al[ac], XmNrightAttachment, XmATTACH_NONE); ac++;
	XtSetValues ( rowcol2,al, ac );
	ac = 0;
	XtAddCallback (h_, XmNdragCallback, hslCB, (XtPointer) this);
	XtAddCallback (h_, XmNvalueChangedCallback, hslCB, (XtPointer) this);
	XtAddCallback (hh_, XmNexposeCallback, exposeCB, (XtPointer) this);
	XtAddCallback (s_, XmNdragCallback, hslCB, (XtPointer) this);
	XtAddCallback (s_, XmNvalueChangedCallback, hslCB, (XtPointer) this);
	XtAddCallback (ss_, XmNexposeCallback, exposeCB, (XtPointer) this);
	XtAddCallback (l_, XmNdragCallback, hslCB, (XtPointer) this);
	XtAddCallback (l_, XmNvalueChangedCallback, hslCB, (XtPointer) this);
	XtAddCallback (ll_, XmNexposeCallback, exposeCB, (XtPointer) this);
	children[ac++] = h_;
	children[ac++] = hh_;
	children[ac++] = s_;
	children[ac++] = ss_;
	children[ac++] = l_;
	children[ac++] = ll_;
	XtManageChildren(children, ac);
	ac = 0;
	children[ac++] = rowcol2;
	XtManageChildren(children, ac);
	ac = 0;
	children[ac++] = form2;
	children[ac++] = form3;
	children[ac++] = form4;
	XtManageChildren(children, ac);
	ac = 0;
	children[ac++] = frame1;
	children[ac++] = tab_;
	XtManageChildren(children, ac);
	ac = 0;
}

void UIColourEditor_c::tabCB( Widget widget, XtPointer client_data, XtPointer call_data )
{
	UIColourEditor_p instance = (UIColourEditor_p) client_data;
	instance->tabCB ( widget, call_data );
}

void UIColourEditor_c::exposeCB( Widget widget, XtPointer client_data, XtPointer call_data )
{
	UIColourEditor_p instance = (UIColourEditor_p) client_data;
	instance->exposeCB ( widget, call_data );
}

void UIColourEditor_c::hslCB( Widget widget, XtPointer client_data, XtPointer call_data )
{
	UIColourEditor_p instance = (UIColourEditor_p) client_data;
	instance->hslCB ( widget, call_data );
}

void UIColourEditor_c::rgbCB( Widget widget, XtPointer client_data, XtPointer call_data )
{
	UIColourEditor_p instance = (UIColourEditor_p) client_data;
	instance->rgbCB ( widget, call_data );
}

