/*
 * Generated by the ICS builderXcessory (BX).
 *
 *
 * Builder Xcessory 2.5.
 *
 */

/*
 * System Include Files
 */
#include <stdlib.h>

/*
 * Required Motif Include Files
 */
#include <Xm/Xm.h>
#include <Xm/DrawingA.h>

/*
 * User supplied include files.
 */


/*
 * Some Convenience Routines
 */
#ifndef IGNORE_CONVERT
/*SUPPRESS 592*/
static XtPointer
CONVERT(Widget w, char *from_string, char *to_type, int to_size, 
	Boolean *success)
{
    XrmValue		fromVal, toVal;	/* resource holders		*/
    Boolean		convResult;	/* return value			*/
    unsigned char	oByte;		/* one byte result		*/
    unsigned short	tByte;		/* two byte result		*/
    XtPointer		fByte;		/* four byte result		*/
    XtPointer		aByte;		/* allocated result		*/
    
    /*
     * Zero it.
     */
    *success = False;
    fByte = aByte = NULL;
    
    /*
     * String to string.
     */
    if( strcmp(XmRString, to_type) == 0 )
    {
	*success = True;
	return( from_string );
    }

    /*
     * Sometimes we do not know this at code output.
     */
    if(to_size == 0) to_size = strlen(from_string);
        
    /*
     * Motif String to StringTable converter
     * does not cache correctly and so
     * we need to special case this.
     */ 
    if( strcmp(to_type, "XmStringTable") == 0)
    {
	register int lcount, loop;
	register char tmp, *ptr, *e_ptr;
	char *tmp_from;
	XmStringTable table;
	
	tmp_from = XtNewString((char *)from_string);
	ptr = tmp_from;
	if ((ptr == NULL) || (*ptr == '\0'))
	{
	    XtFree((XtPointer)tmp_from);
	    return( NULL );
	}
	else 
	{	
	    lcount = 1;
	    while (*ptr != '\0') 
	    {
		if (*ptr++ == '\n')
		    lcount++;
	    }
	    table = (XmStringTable)
		XtMalloc(sizeof(XmString) * lcount);
	    
	    ptr = tmp_from;
	    
	    for (loop = 0; loop < lcount; loop++) 
	    {
		e_ptr = ptr;
		while((*e_ptr!='\0')&&(*e_ptr != '\n'))
		    e_ptr++;	     
		tmp = *e_ptr;
		*e_ptr = '\0';
		table[loop] = XmStringCreateSimple(ptr);
		*e_ptr = tmp;
		ptr = ++e_ptr;
	    }
	    
	    fByte = (XtPointer)table;
	}
	*success = True;
	XtFree((XtPointer)tmp_from);
	/*SUPPRESS 80*/
	return( fByte );
    }

    /*
     * Set up the list.
     */
    fromVal.size = strlen(from_string) + 1;
    fromVal.addr = from_string;

    switch( to_size )
    {
    case 1:
	toVal.size = sizeof(unsigned char);
	toVal.addr = (XtPointer)&oByte;
	break;
    case 2:
	toVal.size = sizeof(unsigned short);
	toVal.addr = (XtPointer)&tByte;
	break;
    default:
	toVal.size = sizeof(XtPointer);
	toVal.addr = (XtPointer)&fByte;
	break;
    }
    
    convResult = XtConvertAndStore(w, 
				   XmRString, 
				   &fromVal,
				   to_type,
				   &toVal);
    
    if( convResult )
    {
	switch( to_size )
	{
	case 1:
	    fByte = (XtPointer)((int)oByte);
	    break;
	case 2:
	    fByte = (XtPointer)((int)tByte);
	    break;
	default:
	    break;
	}
    }
    

    /*
     * Conversion will fail if we need more than 4 bytes.
     */
    if( !convResult && toVal.size != to_size )
    {
	/*
	 * Need to allocate more space for this one.
	 */
	toVal.addr = (XtPointer)XtMalloc(toVal.size);
	fByte = aByte = toVal.addr;
	convResult = XtConvertAndStore(w, 
				       XmRString, 
				       &fromVal,
				       to_type,
				       &toVal);
    }
    
    /*
     * Free any thing useless we may have allocated.
     */
    if( !convResult )
    {
	XtFree(aByte);
	aByte = NULL;
    }
    
    /*
     * Return the result.
     */
    *success = convResult;
    /*SUPPRESS 80*/
    return( fByte );
}
#endif

/*
 * Callback procedure declarations
 */

/*
 * Global widget declarations.
 *        - first remove definition of EXTERNAL
 */
#ifdef EXTERNAL
#undef EXTERNAL
#endif
#define EXTERNAL
/* Start Global Widget Declarations */
/* End Global Widget Declarations */

Widget
createDisplayDrawingArea(Widget parent)
{
    Arg    	args[512];
    Cardinal   	argcnt;
    Boolean   	argok;
    Widget 	retval;
    Widget	displayDrawingArea;

    XtInitializeWidgetClass(xmDrawingAreaWidgetClass);
    argcnt = 0;
    XtSetArg(args[argcnt], XmNbackground,
	     CONVERT(parent,"black", "Pixel", 0, &argok));
    if(argok) argcnt++;
    XtSetArg(args[argcnt], XmNforeground,
	     CONVERT(parent,"white", "Pixel", 0, &argok));
    if(argok) argcnt++;
    XtSetArg(args[argcnt], XmNx, 0); argcnt++;
    XtSetArg(args[argcnt], XmNy, 0); argcnt++;
    XtSetArg(args[argcnt], XmNwidth, 500); argcnt++;
    XtSetArg(args[argcnt], XmNheight, 500); argcnt++;

    displayDrawingArea =
	XtCreateWidget("displayDrawingArea", xmDrawingAreaWidgetClass, parent,
		       args, argcnt);

    retval = displayDrawingArea;

    return( retval );
}

