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

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

UILogWindow_p UILogWindow = (UILogWindow_p) NULL;



void UILogWindow_c::create (Display *display, char *app_name, int app_argc, char **app_argv, char *app_class_name)
{
	Widget children[3];      /* Children to manage */
	Arg al[64];                    /* Arg List */
	register int ac = 0;           /* Arg Count */
	Widget scrolledText1 = (Widget)NULL;
	Widget form1 = (Widget)NULL;
	Widget button3 = (Widget)NULL;
	Widget toggle1 = (Widget)NULL;
	Widget button2 = (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++;
	UILogWindow = XtAppCreateShell ( app_name, app_class_name, applicationShellWidgetClass, display, al, ac );
	ac = 0;
	_xd_rootwidget = UILogWindow;
	XmAddWMProtocolCallback( UILogWindow, XmInternAtom(XtDisplay(UILogWindow), "WM_DELETE_WINDOW", False), closeCB, (XtPointer) this);
	XtSetArg(al[ac], XmNwidth, 500); ac++;
	XtSetArg(al[ac], XmNheight, 500); ac++;
	XtSetArg(al[ac], XmNautoUnmanage, FALSE); ac++;
	form_ = XmCreateForm ( UILogWindow, "form_", al, ac );
	ac = 0;
	XtSetArg(al[ac], XmNeditable, FALSE); ac++;
	XtSetArg(al[ac], XmNeditMode, XmMULTI_LINE_EDIT); ac++;
	text_ = XmCreateScrolledText ( form_, "text_", al, ac );
	ac = 0;
	scrolledText1 = XtParent ( text_ );

	form1 = XmCreateForm ( form_, "form1", al, ac );
	button3 = XmCreatePushButton ( form1, "Clear", al, ac );
	toggle1 = XmCreateToggleButton ( form1, "Freeze", al, ac );
	button2 = XmCreatePushButton ( form1, "Close", al, ac );

	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
	XtSetArg(al[ac], XmNtopWidget, form1); ac++;
	XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
	XtSetValues ( scrolledText1,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 ( form1,al, ac );
	ac = 0;
	XtManageChild(text_);

	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_WIDGET); ac++;
	XtSetArg(al[ac], XmNleftOffset, 2); ac++;
	XtSetArg(al[ac], XmNleftWidget, toggle1); ac++;
	XtSetArg(al[ac], XmNrightAttachment, XmATTACH_NONE); ac++;
	XtSetValues ( button3,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++;
	XtSetArg(al[ac], XmNrightAttachment, XmATTACH_NONE); ac++;
	XtSetValues ( toggle1,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_NONE); ac++;
	XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNrightOffset, 2); ac++;
	XtSetValues ( button2,al, ac );
	ac = 0;
	XtAddCallback (button3, XmNactivateCallback, clearCB, (XtPointer) this);
	XtAddCallback (toggle1, XmNvalueChangedCallback, freezeCB, (XtPointer) this);
	XtAddCallback (button2, XmNactivateCallback, closeCB, (XtPointer) this);
	children[ac++] = button3;
	children[ac++] = toggle1;
	children[ac++] = button2;
	XtManageChildren(children, ac);
	ac = 0;
	children[ac++] = form1;
	XtManageChildren(children, ac);
	ac = 0;
	XtManageChild ( form_);
}

void UILogWindow_c::freezeCB( Widget widget, XtPointer client_data, XtPointer call_data )
{
	UILogWindow_p instance = (UILogWindow_p) client_data;
	instance->freezeCB ( widget, call_data );
}

void UILogWindow_c::clearCB( Widget widget, XtPointer client_data, XtPointer call_data )
{
	UILogWindow_p instance = (UILogWindow_p) client_data;
	instance->clearCB ( widget, call_data );
}

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

