/***************************** 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/Form.h>
#include <Xm/ScrollBar.h>
#include <Xm/Text.h>

#include <xdclass.h>

class UIOutputDrawer_c: public xd_XmForm_c {
public:
	virtual void create (Widget parent, char *widget_name = NULL);
protected:
	Widget UIOutputDrawer;
	Widget text_;
public:
	static void clickCB( Widget, XtPointer, XtPointer );
	virtual void clickCB( Widget, XtPointer ) = 0;
};

typedef UIOutputDrawer_c *UIOutputDrawer_p;

UIOutputDrawer_p UIOutputDrawer = (UIOutputDrawer_p) NULL;



void UIOutputDrawer_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 scrolledText1 = (Widget)NULL;

	if ( !widget_name )
		widget_name = "Output";

	XtSetArg(al[ac], XmNautoUnmanage, FALSE); ac++;
	UIOutputDrawer = XmCreateForm ( parent, widget_name, al, ac );
	ac = 0;
	_xd_rootwidget = UIOutputDrawer;
	XtSetArg(al[ac], XmNeditMode, XmMULTI_LINE_EDIT); ac++;
	XtSetArg(al[ac], XmNrows, 10); ac++;
	text_ = XmCreateScrolledText ( UIOutputDrawer, "text_", al, ac );
	ac = 0;
	scrolledText1 = XtParent ( text_ );


	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNtopOffset, 0); 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 ( scrolledText1,al, ac );
	ac = 0;
	XtAddCallback (text_, XmNmotionVerifyCallback, clickCB, (XtPointer) this);
	XtManageChild(text_);
}

void UIOutputDrawer_c::clickCB( Widget widget, XtPointer client_data, XtPointer call_data )
{
	UIOutputDrawer_p instance = (UIOutputDrawer_p) client_data;
	instance->clickCB ( widget, call_data );
}

