/*
** Generated Code
*/
/*
**LIBS: -lXm -lXt -lX11
*/

#include <X11/Xatom.h>
#include <X11/Intrinsic.h>
#include <X11/Shell.h>

#include <Xm/Xm.h>
#include <X11/StringDefs.h>
#include <Xm/CascadeB.h>
#include <Xm/DialogS.h>
#include <Xm/DrawingA.h>
#include <Xm/Form.h>
#include <Xm/PushB.h>
#include <Xm/RowColumn.h>
#include <Xm/Separator.h>
#include <Xm/ToggleB.h>
#include <Xm/ToggleBG.h>
#include <stdio.h>
#include <stdlib.h>


#include "main.h"

shell_p shell = (shell_p) NULL;


static _xd_initialised = 0;

typedef struct PixelResources_s { 
	Pixel magenta;
	Pixel cyan;
	Pixel yellow;
	Pixel blue;
	Pixel green;
	Pixel red;
	Pixel white;
	Pixel black;
} PixelResources_t, *PixelResources_p;

static PixelResources_t pixel_resources;


static void initialise_objects( Widget parent )
{
	XrmValue from_value, to_value; /* For resource conversions */

	if ( _xd_initialised ) return;
	_xd_initialised = 1;
	while ( XtParent ( parent ) )
		parent = XtParent ( parent );
	if (DefaultDepthOfScreen(DefaultScreenOfDisplay(XtDisplay(parent))) != 1) {
	from_value.addr = "#ffff0000ffff";
	from_value.size = strlen(from_value.addr)+1;
	to_value.addr = NULL;
	XtConvertAndStore( parent, XmRString, &from_value, XmRPixel, &to_value);
	if ( to_value.addr )
		pixel_resources.magenta = *(Pixel*)to_value.addr;
	from_value.addr = "#0000ffffffff";
	from_value.size = strlen(from_value.addr)+1;
	to_value.addr = NULL;
	XtConvertAndStore( parent, XmRString, &from_value, XmRPixel, &to_value);
	if ( to_value.addr )
		pixel_resources.cyan = *(Pixel*)to_value.addr;
	from_value.addr = "#ffffffff0000";
	from_value.size = strlen(from_value.addr)+1;
	to_value.addr = NULL;
	XtConvertAndStore( parent, XmRString, &from_value, XmRPixel, &to_value);
	if ( to_value.addr )
		pixel_resources.yellow = *(Pixel*)to_value.addr;
	from_value.addr = "#00000000ffff";
	from_value.size = strlen(from_value.addr)+1;
	to_value.addr = NULL;
	XtConvertAndStore( parent, XmRString, &from_value, XmRPixel, &to_value);
	if ( to_value.addr )
		pixel_resources.blue = *(Pixel*)to_value.addr;
	from_value.addr = "#0000ffff0000";
	from_value.size = strlen(from_value.addr)+1;
	to_value.addr = NULL;
	XtConvertAndStore( parent, XmRString, &from_value, XmRPixel, &to_value);
	if ( to_value.addr )
		pixel_resources.green = *(Pixel*)to_value.addr;
	from_value.addr = "#ffff00000000";
	from_value.size = strlen(from_value.addr)+1;
	to_value.addr = NULL;
	XtConvertAndStore( parent, XmRString, &from_value, XmRPixel, &to_value);
	if ( to_value.addr )
		pixel_resources.red = *(Pixel*)to_value.addr;
	from_value.addr = "#ffffffffffff";
	from_value.size = strlen(from_value.addr)+1;
	to_value.addr = NULL;
	XtConvertAndStore( parent, XmRString, &from_value, XmRPixel, &to_value);
	if ( to_value.addr )
		pixel_resources.white = *(Pixel*)to_value.addr;
	from_value.addr = "#000000000000";
	from_value.size = strlen(from_value.addr)+1;
	to_value.addr = NULL;
	XtConvertAndStore( parent, XmRString, &from_value, XmRPixel, &to_value);
	if ( to_value.addr )
		pixel_resources.black = *(Pixel*)to_value.addr;
	}
}


void drawing_c::create (CWnd * parent, char *widget_name, unsigned int , CRect *)
{
	Arg al[64];                    /* Arg List */
	register int ac = 0;           /* Arg Count */

	if ( !widget_name )
		widget_name = "drawing";

	colours[black]=&pixel_resources.black;
	colours[white]=&pixel_resources.white;
	colours[red]=&pixel_resources.red;
	colours[green]=&pixel_resources.green;
	colours[blue]=&pixel_resources.blue;
	colours[yellow]=&pixel_resources.yellow;
	colours[cyan]=&pixel_resources.cyan;
	colours[magenta]=&pixel_resources.magenta;
	initialised = FALSE;    
	for ( unsigned char y = 0; y < 32; y++ )
		for ( unsigned char x = 0; x < 32; )
			for ( unsigned char c = (unsigned char)black; c <= (unsigned char)magenta; c++, x++ )
				cells [x][y] = (colour_type)c; 


	XtSetArg(al[ac], XmNwidth, 250); ac++;
	XtSetArg(al[ac], XmNheight, 250); ac++;
	xd_rootwidget ( XmCreateDrawingArea ( parent->xd_rootwidget(), widget_name, al, ac ) );
	ac = 0;
	XtAddCallback (xd_rootwidget(), XmNexposeCallback, DoExpose, (XtPointer) this);
	XtAddCallback (xd_rootwidget(), XmNinputCallback, DoInput, (XtPointer) this);
}

void drawing_c::DoInput( Widget, XtPointer client_data, XtPointer call_data )
{
	drawing_p instance = (drawing_p) client_data;
	instance->xd_call_data ( (XmAnyCallbackStruct *)call_data );
	instance->DoInput (  );
}

void drawing_c::DoExpose( Widget, XtPointer client_data, XtPointer call_data )
{
	drawing_p instance = (drawing_p) client_data;
	instance->xd_call_data ( (XmAnyCallbackStruct *)call_data );
	instance->DoExpose (  );
}

void tool_box_c::create (CWnd * parent, char *widget_name, unsigned int , CRect *)
{
	Widget children[4];      /* Children to manage */
	Arg al[64];                    /* Arg List */
	register int ac = 0;           /* Arg Count */
	XmString xmstrings[16];    /* temporary storage for XmStrings */

	if ( !widget_name )
		widget_name = "tool_box";

tool = pencil;
	XtSetArg(al[ac], XmNnumColumns, 2); ac++;
	XtSetArg(al[ac], XmNpacking, XmPACK_COLUMN); ac++;
	xd_rootwidget ( XmCreateRadioBox ( parent->xd_rootwidget(), widget_name, al, ac ) );
	ac = 0;
	xmstrings[0] = XmStringCreateLtoR("Pencil", (XmStringCharSet)XmFONTLIST_DEFAULT_TAG);
	XtSetArg(al[ac], XmNlabelString, xmstrings[0]); ac++;
	XtSetArg(al[ac], XmNset, TRUE); ac++;
	widget16->xd_rootwidget ( XmCreateToggleButtonGadget ( xd_rootwidget(), "widget16", al, ac ) );
	ac = 0;
	XmStringFree ( xmstrings [ 0 ] );
	xmstrings[0] = XmStringCreateLtoR("Line", (XmStringCharSet)XmFONTLIST_DEFAULT_TAG);
	XtSetArg(al[ac], XmNlabelString, xmstrings[0]); ac++;
	widget17->xd_rootwidget ( XmCreateToggleButtonGadget ( xd_rootwidget(), "widget17", al, ac ) );
	ac = 0;
	XmStringFree ( xmstrings [ 0 ] );
	xmstrings[0] = XmStringCreateLtoR("Rect", (XmStringCharSet)XmFONTLIST_DEFAULT_TAG);
	XtSetArg(al[ac], XmNlabelString, xmstrings[0]); ac++;
	widget18->xd_rootwidget ( XmCreateToggleButtonGadget ( xd_rootwidget(), "widget18", al, ac ) );
	ac = 0;
	XmStringFree ( xmstrings [ 0 ] );
	xmstrings[0] = XmStringCreateLtoR("Fill", (XmStringCharSet)XmFONTLIST_DEFAULT_TAG);
	XtSetArg(al[ac], XmNlabelString, xmstrings[0]); ac++;
	widget19->xd_rootwidget ( XmCreateToggleButtonGadget ( xd_rootwidget(), "widget19", al, ac ) );
	ac = 0;
	XmStringFree ( xmstrings [ 0 ] );
	XtAddCallback (widget16->xd_rootwidget(), XmNvalueChangedCallback, Pencil, (XtPointer) this);
	XtAddCallback (widget17->xd_rootwidget(), XmNvalueChangedCallback, Line, (XtPointer) this);
	XtAddCallback (widget18->xd_rootwidget(), XmNvalueChangedCallback, Rectangle, (XtPointer) this);
	XtAddCallback (widget19->xd_rootwidget(), XmNvalueChangedCallback, Fill, (XtPointer) this);
	children[ac++] = widget16->xd_rootwidget();
	children[ac++] = widget17->xd_rootwidget();
	children[ac++] = widget18->xd_rootwidget();
	children[ac++] = widget19->xd_rootwidget();
	XtManageChildren(children, ac);
	ac = 0;
}

tool_box_c::tool_box_c()
{
	widget16 = new CButton;
	widget17 = new CButton;
	widget18 = new CButton;
	widget19 = new CButton;
}

tool_box_c::~tool_box_c()
{
	delete widget16;
	delete widget17;
	delete widget18;
	delete widget19;
}

void tool_box_c::Fill( Widget, XtPointer client_data, XtPointer call_data )
{
	tool_box_p instance = (tool_box_p) client_data;
	instance->xd_call_data ( (XmAnyCallbackStruct *)call_data );
	instance->Fill (  );
}

void tool_box_c::Rectangle( Widget, XtPointer client_data, XtPointer call_data )
{
	tool_box_p instance = (tool_box_p) client_data;
	instance->xd_call_data ( (XmAnyCallbackStruct *)call_data );
	instance->Rectangle (  );
}

void tool_box_c::Line( Widget, XtPointer client_data, XtPointer call_data )
{
	tool_box_p instance = (tool_box_p) client_data;
	instance->xd_call_data ( (XmAnyCallbackStruct *)call_data );
	instance->Line (  );
}

void tool_box_c::Pencil( Widget, XtPointer client_data, XtPointer call_data )
{
	tool_box_p instance = (tool_box_p) client_data;
	instance->xd_call_data ( (XmAnyCallbackStruct *)call_data );
	instance->Pencil (  );
}

void colour_box_c::create (CWnd * parent, char *widget_name, unsigned int , CRect *)
{
	Widget children[8];      /* Children to manage */
	Arg al[64];                    /* Arg List */
	register int ac = 0;           /* Arg Count */
	XmString xmstrings[16];    /* temporary storage for XmStrings */

	if ( !widget_name )
		widget_name = "colour_box";

colour = black;
	XtSetArg(al[ac], XmNnumColumns, 2); ac++;
	XtSetArg(al[ac], XmNpacking, XmPACK_COLUMN); ac++;
	XtSetArg(al[ac], XmNradioBehavior, TRUE); ac++;
	xd_rootwidget ( XmCreateRowColumn ( parent->xd_rootwidget(), widget_name, al, ac ) );
	ac = 0;
	XtSetArg(al[ac], XmNforeground, pixel_resources.white); ac++;
	XtSetArg(al[ac], XmNbackground, pixel_resources.black); ac++;
	xmstrings[0] = XmStringCreateLtoR("Black", (XmStringCharSet)XmFONTLIST_DEFAULT_TAG);
	XtSetArg(al[ac], XmNlabelString, xmstrings[0]); ac++;
	XtSetArg(al[ac], XmNindicatorType, XmONE_OF_MANY); ac++;
	XtSetArg(al[ac], XmNset, TRUE); ac++;
	widget22->xd_rootwidget ( XmCreateToggleButton ( xd_rootwidget(), "widget22", al, ac ) );
	ac = 0;
	XmStringFree ( xmstrings [ 0 ] );
	XtSetArg(al[ac], XmNbackground, pixel_resources.white); ac++;
	xmstrings[0] = XmStringCreateLtoR("White", (XmStringCharSet)XmFONTLIST_DEFAULT_TAG);
	XtSetArg(al[ac], XmNlabelString, xmstrings[0]); ac++;
	XtSetArg(al[ac], XmNindicatorType, XmONE_OF_MANY); ac++;
	widget23->xd_rootwidget ( XmCreateToggleButton ( xd_rootwidget(), "widget23", al, ac ) );
	ac = 0;
	XmStringFree ( xmstrings [ 0 ] );
	XtSetArg(al[ac], XmNbackground, pixel_resources.red); ac++;
	xmstrings[0] = XmStringCreateLtoR("Red", (XmStringCharSet)XmFONTLIST_DEFAULT_TAG);
	XtSetArg(al[ac], XmNlabelString, xmstrings[0]); ac++;
	XtSetArg(al[ac], XmNindicatorType, XmONE_OF_MANY); ac++;
	widget24->xd_rootwidget ( XmCreateToggleButton ( xd_rootwidget(), "widget24", al, ac ) );
	ac = 0;
	XmStringFree ( xmstrings [ 0 ] );
	XtSetArg(al[ac], XmNbackground, pixel_resources.green); ac++;
	xmstrings[0] = XmStringCreateLtoR("Green", (XmStringCharSet)XmFONTLIST_DEFAULT_TAG);
	XtSetArg(al[ac], XmNlabelString, xmstrings[0]); ac++;
	XtSetArg(al[ac], XmNindicatorType, XmONE_OF_MANY); ac++;
	widget25->xd_rootwidget ( XmCreateToggleButton ( xd_rootwidget(), "widget25", al, ac ) );
	ac = 0;
	XmStringFree ( xmstrings [ 0 ] );
	XtSetArg(al[ac], XmNforeground, pixel_resources.white); ac++;
	XtSetArg(al[ac], XmNbackground, pixel_resources.blue); ac++;
	xmstrings[0] = XmStringCreateLtoR("Blue", (XmStringCharSet)XmFONTLIST_DEFAULT_TAG);
	XtSetArg(al[ac], XmNlabelString, xmstrings[0]); ac++;
	XtSetArg(al[ac], XmNindicatorType, XmONE_OF_MANY); ac++;
	widget26->xd_rootwidget ( XmCreateToggleButton ( xd_rootwidget(), "widget26", al, ac ) );
	ac = 0;
	XmStringFree ( xmstrings [ 0 ] );
	XtSetArg(al[ac], XmNbackground, pixel_resources.yellow); ac++;
	xmstrings[0] = XmStringCreateLtoR("Yellow", (XmStringCharSet)XmFONTLIST_DEFAULT_TAG);
	XtSetArg(al[ac], XmNlabelString, xmstrings[0]); ac++;
	XtSetArg(al[ac], XmNindicatorType, XmONE_OF_MANY); ac++;
	widget27->xd_rootwidget ( XmCreateToggleButton ( xd_rootwidget(), "widget27", al, ac ) );
	ac = 0;
	XmStringFree ( xmstrings [ 0 ] );
	XtSetArg(al[ac], XmNbackground, pixel_resources.cyan); ac++;
	xmstrings[0] = XmStringCreateLtoR("Cyan", (XmStringCharSet)XmFONTLIST_DEFAULT_TAG);
	XtSetArg(al[ac], XmNlabelString, xmstrings[0]); ac++;
	XtSetArg(al[ac], XmNindicatorType, XmONE_OF_MANY); ac++;
	widget28->xd_rootwidget ( XmCreateToggleButton ( xd_rootwidget(), "widget28", al, ac ) );
	ac = 0;
	XmStringFree ( xmstrings [ 0 ] );
	XtSetArg(al[ac], XmNbackground, pixel_resources.magenta); ac++;
	xmstrings[0] = XmStringCreateLtoR("Magenta", (XmStringCharSet)XmFONTLIST_DEFAULT_TAG);
	XtSetArg(al[ac], XmNlabelString, xmstrings[0]); ac++;
	XtSetArg(al[ac], XmNindicatorType, XmONE_OF_MANY); ac++;
	widget29->xd_rootwidget ( XmCreateToggleButton ( xd_rootwidget(), "widget29", al, ac ) );
	ac = 0;
	XmStringFree ( xmstrings [ 0 ] );
	XtAddCallback (widget22->xd_rootwidget(), XmNvalueChangedCallback, Black, (XtPointer) this);
	XtAddCallback (widget23->xd_rootwidget(), XmNvalueChangedCallback, White, (XtPointer) this);
	XtAddCallback (widget24->xd_rootwidget(), XmNvalueChangedCallback, Red, (XtPointer) this);
	XtAddCallback (widget25->xd_rootwidget(), XmNvalueChangedCallback, Green, (XtPointer) this);
	XtAddCallback (widget26->xd_rootwidget(), XmNvalueChangedCallback, Blue, (XtPointer) this);
	XtAddCallback (widget27->xd_rootwidget(), XmNvalueChangedCallback, Yellow, (XtPointer) this);
	XtAddCallback (widget28->xd_rootwidget(), XmNvalueChangedCallback, Cyan, (XtPointer) this);
	XtAddCallback (widget29->xd_rootwidget(), XmNvalueChangedCallback, Magenta, (XtPointer) this);
	children[ac++] = widget22->xd_rootwidget();
	children[ac++] = widget23->xd_rootwidget();
	children[ac++] = widget24->xd_rootwidget();
	children[ac++] = widget25->xd_rootwidget();
	children[ac++] = widget26->xd_rootwidget();
	children[ac++] = widget27->xd_rootwidget();
	children[ac++] = widget28->xd_rootwidget();
	children[ac++] = widget29->xd_rootwidget();
	XtManageChildren(children, ac);
	ac = 0;
}

colour_box_c::colour_box_c()
{
	widget22 = new CButton;
	widget23 = new CButton;
	widget24 = new CButton;
	widget25 = new CButton;
	widget26 = new CButton;
	widget27 = new CButton;
	widget28 = new CButton;
	widget29 = new CButton;
}

colour_box_c::~colour_box_c()
{
	delete widget22;
	delete widget23;
	delete widget24;
	delete widget25;
	delete widget26;
	delete widget27;
	delete widget28;
	delete widget29;
}

void colour_box_c::Magenta( Widget, XtPointer client_data, XtPointer call_data )
{
	colour_box_p instance = (colour_box_p) client_data;
	instance->xd_call_data ( (XmAnyCallbackStruct *)call_data );
	instance->Magenta (  );
}

void colour_box_c::Cyan( Widget, XtPointer client_data, XtPointer call_data )
{
	colour_box_p instance = (colour_box_p) client_data;
	instance->xd_call_data ( (XmAnyCallbackStruct *)call_data );
	instance->Cyan (  );
}

void colour_box_c::Yellow( Widget, XtPointer client_data, XtPointer call_data )
{
	colour_box_p instance = (colour_box_p) client_data;
	instance->xd_call_data ( (XmAnyCallbackStruct *)call_data );
	instance->Yellow (  );
}

void colour_box_c::Blue( Widget, XtPointer client_data, XtPointer call_data )
{
	colour_box_p instance = (colour_box_p) client_data;
	instance->xd_call_data ( (XmAnyCallbackStruct *)call_data );
	instance->Blue (  );
}

void colour_box_c::Green( Widget, XtPointer client_data, XtPointer call_data )
{
	colour_box_p instance = (colour_box_p) client_data;
	instance->xd_call_data ( (XmAnyCallbackStruct *)call_data );
	instance->Green (  );
}

void colour_box_c::Red( Widget, XtPointer client_data, XtPointer call_data )
{
	colour_box_p instance = (colour_box_p) client_data;
	instance->xd_call_data ( (XmAnyCallbackStruct *)call_data );
	instance->Red (  );
}

void colour_box_c::White( Widget, XtPointer client_data, XtPointer call_data )
{
	colour_box_p instance = (colour_box_p) client_data;
	instance->xd_call_data ( (XmAnyCallbackStruct *)call_data );
	instance->White (  );
}

void colour_box_c::Black( Widget, XtPointer client_data, XtPointer call_data )
{
	colour_box_p instance = (colour_box_p) client_data;
	instance->xd_call_data ( (XmAnyCallbackStruct *)call_data );
	instance->Black (  );
}

void shell_c::create (CWinApp *win_app, CRect *)
{
	Widget children[3];      /* Children to manage */
	Arg al[64];                    /* Arg List */
	register int ac = 0;           /* Arg Count */
	XmString xmstrings[16];    /* temporary storage for XmStrings */
	CWnd widget1;
	Widget widget4 = (Widget)NULL;
	Widget widget5 = (Widget)NULL;
	Widget widget6 = (Widget)NULL;
	Widget widget7 = (Widget)NULL;
	Widget widget9 = (Widget)NULL;
	Widget widget10 = (Widget)NULL;
	Widget widget11 = (Widget)NULL;
	Widget widget12 = (Widget)NULL;
	CWnd widget14;
	Widget widget20 = (Widget)NULL;

	if ( !win_app->xd_app_class() )
	win_app->xd_app_class ( "XApplication" );

	XtSetArg(al[ac], XmNallowShellResize, TRUE); ac++;
	XtSetArg(al[ac], XmNargc, win_app->xd_argc()); ac++;
	XtSetArg(al[ac], XmNargv, win_app->xd_argv()); ac++;
	xd_rootwidget ( XtAppCreateShell ( win_app->m_pszAppName, win_app->xd_app_class(), applicationShellWidgetClass, win_app->xd_display(), al, ac ) );
	ac = 0;
	initialise_objects ( xd_rootwidget() );
	XtSetArg(al[ac], XmNautoUnmanage, FALSE); ac++;
	widget1.xd_rootwidget( XmCreateForm ( xd_rootwidget(), "widget1", al, ac ) );
	ac = 0;
	widget2->xd_rootwidget ( XmCreateMenuBar ( widget1.xd_rootwidget(), "widget2", al, ac ) );
	xmstrings[0] = XmStringCreateLtoR("File", (XmStringCharSet)XmFONTLIST_DEFAULT_TAG);
	XtSetArg(al[ac], XmNlabelString, xmstrings[0]); ac++;
	widget3->xd_rootwidget ( XmCreateCascadeButton ( widget2->xd_rootwidget(), "widget3", al, ac ) );
	ac = 0;
	XmStringFree ( xmstrings [ 0 ] );
	widget4 = XmCreatePulldownMenu ( widget2->xd_rootwidget(), "widget4", al, ac );
	xmstrings[0] = XmStringCreateLtoR("New", (XmStringCharSet)XmFONTLIST_DEFAULT_TAG);
	XtSetArg(al[ac], XmNlabelString, xmstrings[0]); ac++;
	widget5 = XmCreatePushButton ( widget4, "widget5", al, ac );
	ac = 0;
	XmStringFree ( xmstrings [ 0 ] );
	widget3->xd_register_menu_item ( ID_shell_widget5, widget5 );
	xmstrings[0] = XmStringCreateLtoR("Open", (XmStringCharSet)XmFONTLIST_DEFAULT_TAG);
	XtSetArg(al[ac], XmNlabelString, xmstrings[0]); ac++;
	widget6 = XmCreatePushButton ( widget4, "widget6", al, ac );
	ac = 0;
	XmStringFree ( xmstrings [ 0 ] );
	widget3->xd_register_menu_item ( ID_shell_widget6, widget6 );
	xmstrings[0] = XmStringCreateLtoR("Exit", (XmStringCharSet)XmFONTLIST_DEFAULT_TAG);
	XtSetArg(al[ac], XmNlabelString, xmstrings[0]); ac++;
	widget7 = XmCreatePushButton ( widget4, "widget7", al, ac );
	ac = 0;
	XmStringFree ( xmstrings [ 0 ] );
	widget3->xd_register_menu_item ( ID_shell_widget7, widget7 );
	widget2->xd_register_menu ( widget3 );
	widget2->xd_register_menu_item ( IDC_shell_widget3, widget3->xd_rootwidget() );
	xmstrings[0] = XmStringCreateLtoR("Edit", (XmStringCharSet)XmFONTLIST_DEFAULT_TAG);
	XtSetArg(al[ac], XmNlabelString, xmstrings[0]); ac++;
	widget8->xd_rootwidget ( XmCreateCascadeButton ( widget2->xd_rootwidget(), "widget8", al, ac ) );
	ac = 0;
	XmStringFree ( xmstrings [ 0 ] );
	widget9 = XmCreatePulldownMenu ( widget2->xd_rootwidget(), "widget9", al, ac );
	xmstrings[0] = XmStringCreateLtoR("Cut", (XmStringCharSet)XmFONTLIST_DEFAULT_TAG);
	XtSetArg(al[ac], XmNlabelString, xmstrings[0]); ac++;
	widget10 = XmCreatePushButton ( widget9, "widget10", al, ac );
	ac = 0;
	XmStringFree ( xmstrings [ 0 ] );
	widget8->xd_register_menu_item ( ID_shell_widget10, widget10 );
	xmstrings[0] = XmStringCreateLtoR("Copy", (XmStringCharSet)XmFONTLIST_DEFAULT_TAG);
	XtSetArg(al[ac], XmNlabelString, xmstrings[0]); ac++;
	widget11 = XmCreatePushButton ( widget9, "widget11", al, ac );
	ac = 0;
	XmStringFree ( xmstrings [ 0 ] );
	widget8->xd_register_menu_item ( ID_shell_widget11, widget11 );
	xmstrings[0] = XmStringCreateLtoR("Paste", (XmStringCharSet)XmFONTLIST_DEFAULT_TAG);
	XtSetArg(al[ac], XmNlabelString, xmstrings[0]); ac++;
	widget12 = XmCreatePushButton ( widget9, "widget12", al, ac );
	ac = 0;
	XmStringFree ( xmstrings [ 0 ] );
	widget8->xd_register_menu_item ( ID_shell_widget12, widget12 );
	widget2->xd_register_menu ( widget8 );
	widget2->xd_register_menu_item ( IDC_shell_widget8, widget8->xd_rootwidget() );
	drawing->create ( &widget1, "drawing" );
	widget14.xd_rootwidget( XmCreateRowColumn ( widget1.xd_rootwidget(), "widget14", al, ac ) );
	tool_box->create ( &widget14, "tool_box" );
	widget20 = XmCreateSeparator ( widget14.xd_rootwidget(), "widget20", al, ac );
	colour_box->create ( &widget14, "colour_box" );

	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNtopOffset, 5); ac++;
	XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_NONE); ac++;
	XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNleftOffset, 5); ac++;
	XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNrightOffset, 5); ac++;
	XtSetValues ( widget2->xd_rootwidget(),al, ac );
	ac = 0;

	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
	XtSetArg(al[ac], XmNtopOffset, 5); ac++;
	XtSetArg(al[ac], XmNtopWidget, widget2->xd_rootwidget()); ac++;
	XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNbottomOffset, 5); ac++;
	XtSetArg(al[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++;
	XtSetArg(al[ac], XmNleftOffset, 5); ac++;
	XtSetArg(al[ac], XmNleftWidget, widget14.xd_rootwidget()); ac++;
	XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNrightOffset, 5); ac++;
	XtSetValues ( drawing->xd_rootwidget(),al, ac );
	ac = 0;

	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
	XtSetArg(al[ac], XmNtopOffset, 5); ac++;
	XtSetArg(al[ac], XmNtopWidget, widget2->xd_rootwidget()); ac++;
	XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_NONE); ac++;
	XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
	XtSetArg(al[ac], XmNleftOffset, 5); ac++;
	XtSetArg(al[ac], XmNrightAttachment, XmATTACH_NONE); ac++;
	XtSetValues ( widget14.xd_rootwidget(),al, ac );
	ac = 0;
	XtAddCallback (widget7, XmNactivateCallback, DoExit, (XtPointer) this);
	children[ac++] = widget5;
	children[ac++] = widget6;
	children[ac++] = widget7;
	XtManageChildren(children, ac);
	ac = 0;
	XtSetArg(al[ac], XmNsubMenuId, widget4); ac++;
	XtSetValues ( widget3->xd_rootwidget(), al, ac );
	ac = 0;
	children[ac++] = widget10;
	children[ac++] = widget11;
	children[ac++] = widget12;
	XtManageChildren(children, ac);
	ac = 0;
	XtSetArg(al[ac], XmNsubMenuId, widget9); ac++;
	XtSetValues ( widget8->xd_rootwidget(), al, ac );
	ac = 0;
	children[ac++] = widget3->xd_rootwidget();
	children[ac++] = widget8->xd_rootwidget();
	XtManageChildren(children, ac);
	ac = 0;
	children[ac++] = tool_box->xd_rootwidget();
	children[ac++] = widget20;
	children[ac++] = colour_box->xd_rootwidget();
	XtManageChildren(children, ac);
	ac = 0;
	children[ac++] = widget2->xd_rootwidget();
	children[ac++] = drawing->xd_rootwidget();
	children[ac++] = widget14.xd_rootwidget();
	XtManageChildren(children, ac);
	ac = 0;
	XtManageChild ( widget1.xd_rootwidget());
}

shell_c::shell_c()
{
	widget2 = new CMenu;
	widget3 = new CMenu;
	widget8 = new CMenu;
	drawing = new drawing_c;
	tool_box = new tool_box_c;
	colour_box = new colour_box_c;
}

shell_c::~shell_c()
{
	delete widget2;
	delete widget3;
	delete widget8;
	delete drawing;
	delete tool_box;
	delete colour_box;
}

void shell_c::DoExit( Widget, XtPointer client_data, XtPointer call_data )
{
	shell_p instance = (shell_p) client_data;
	instance->xd_call_data ( (XmAnyCallbackStruct *)call_data );
	instance->DoExit (  );
}


CXApplicationApp::CXApplicationApp ( const char *pszAppName )
	:CWinApp ( pszAppName )
{
}

BOOL CXApplicationApp::InitInstance ()
{
	BOOL base_return = CWinApp::InitInstance();
	shell = new shell_c;
	shell->create ( this );
	m_pMainWnd = shell;
	m_pMainWnd->ShowWindow ( m_nCmdShow );
	return TRUE;
}

int CXApplicationApp::ExitInstance ()
{
	return CWinApp::ExitInstance();
}

CXApplicationApp *XApplication;


XtAppContext app_context;
Display *display;       /*  Display             */

int main (int argc, char **argv)
{
	XtSetLanguageProc ( (XtAppContext) NULL, (XtLanguageProc) NULL, (XtPointer) NULL );
	XtToolkitInitialize ();
	app_context = XtCreateApplicationContext ();
	display = XtOpenDisplay (app_context, NULL, argv[0], "XApplication",
	                         NULL, 0, &argc, argv);
	if (!display)
	{
	    printf("%s: can't open display, exiting...\n", argv[0]);
	    exit (-1);
	}
	XApplication = new CXApplicationApp ( argv[0] );
	XApplication->xd_display ( display );
	XApplication->xd_argc ( argc );
	XApplication->xd_argv ( argv );
	XApplication->xd_app_class ( "XApplication" );
	if ( !XApplication->InitInstance () )
	{
		printf("%s: failed to initialise application instance, exiting...\n", argv[0]);
		exit (-1);
	}
	XtAppMainLoop (app_context);
	XApplication->ExitInstance ();
	delete XApplication;
	exit (0);
}

