
/******************************************************************
 *                                                                *
 *                  Computer Science Department                   *
 *                                                                *
 *                        Master's Project                        *
 *                                                                *
 *                Graphical Development Environment               *
 *                                                                *
 *                     for Postgres Database                      *
 *                                                                *
 *                    Designed Especially for                     *
 *                                                                *
 *                 Postgres Developers and Users                  *
 *                                                                *
 *                              At                                *
 *                                                                *
 *                     Concordia University                       *
 *                                                                *
 ******************************************************************
 *                                                                *
 * Designer and Programmer:  Khaled Jababo                        *
 * Email                  :  jababo@cs.concordia.ca               *
 *                                                                *
 * Supervised by          :  Dr. Bipin C. Desai.                  *
 *                           Computer Science Department.         *
 * Email                  :  bcdesai@cs.concordia.ca              *
 *                                                                *
 * Last Modified          :  June 18, 1994                        *
 *                                                                *
 *                                                                *
 *                                                                *
 * Disclaimer:  There are no guarantees as to the accuracy, cu-   *
 *             rrency, quality, or usefulness of these programs   *
 *             or any information that is provided by using it.   *
 *             Furthermore, there is no assumption of responsi-   *
 *             bility for any los or damage which may be caused   *
 *             by their use.                                      *
 *                                                                *
 *                                                                *
 * Forward comments or questions about this report or the GDEP    *
 * system to:                                                     *
 *              bcdesai@cs.concordia.ca                           *
 *              jababo@cs.concordia.ca                            *
 *                                                                *
 ******************************************************************/


/******************************************************************/
/**********************     mainfile.c    *************************/
/*    This file contains the main for the whole project.   It is  */
/*  used to initialize the whole project parameters, creates the  */
/*  main window for GDEP and start the main loop for GDEP appli-  */
/*  cation.                                                       */
/******************************************************************/

#include "mainfile.h"

#ifndef MAINFILEC
#define MAINFILEC

/******************************************************/
/* Set the Concordia Logo Picture for the Main Window */
/******************************************************/
#define ConUlogo_width 71
#define ConUlogo_height 90
static char ConUlogo_bits[] = {
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff,
   0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xc0, 0xff, 0x07, 0x00, 0xc0,
   0xff, 0x03, 0x00, 0x80, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x01,
   0xe0, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x03, 0x38, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x18, 0x00, 0x40, 0x00, 0x08, 0x00,
   0x00, 0x00, 0x0c, 0x18, 0x00, 0x00, 0x00, 0x00, 0x40, 0x02, 0x00, 0x0c,
   0x18, 0x00, 0x80, 0x01, 0x00, 0x40, 0x02, 0x00, 0x0c, 0x18, 0x00, 0x40,
   0x00, 0x08, 0x00, 0x01, 0x00, 0x0c, 0x18, 0x00, 0x20, 0x00, 0x00, 0x80,
   0x01, 0x00, 0x0c, 0x18, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x02, 0x00, 0x0c,
   0x18, 0x00, 0xa0, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x0c, 0x18, 0x00, 0x00,
   0x00, 0x08, 0x00, 0x00, 0x00, 0x0c, 0x18, 0x00, 0x00, 0x00, 0x08, 0x00,
   0x00, 0x00, 0x0c, 0x18, 0x10, 0x00, 0x04, 0x08, 0x18, 0x00, 0x04, 0x0c,
   0x18, 0x10, 0x00, 0x0c, 0x08, 0x1c, 0x00, 0x04, 0x0c, 0x18, 0x60, 0x00,
   0x16, 0x08, 0x10, 0x00, 0x03, 0x0c, 0x18, 0x70, 0x00, 0x06, 0x00, 0x02,
   0x00, 0x04, 0x0c, 0x18, 0x08, 0x00, 0x44, 0x10, 0x12, 0x00, 0x08, 0x0c,
   0x18, 0x08, 0x00, 0x40, 0x14, 0x03, 0x00, 0x00, 0x0c, 0x18, 0x28, 0x18,
   0x48, 0xb6, 0x00, 0x0c, 0x0e, 0x0c, 0x18, 0x38, 0x18, 0x08, 0xf6, 0x08,
   0x0c, 0x04, 0x0c, 0x18, 0x00, 0xd0, 0x88, 0xf7, 0x8c, 0x04, 0x00, 0x0c,
   0x18, 0x00, 0x80, 0xc9, 0xc1, 0xcd, 0x00, 0x00, 0x0c, 0x18, 0x00, 0x60,
   0x1e, 0x00, 0x3c, 0x03, 0x00, 0x0c, 0x18, 0x00, 0x40, 0x8c, 0xff, 0x10,
   0x03, 0x00, 0x0c, 0x18, 0x00, 0x40, 0xe6, 0xff, 0x31, 0x01, 0x00, 0x0c,
   0x18, 0x60, 0x18, 0x00, 0x00, 0x00, 0xec, 0x03, 0x0c, 0x18, 0xa0, 0x99,
   0xff, 0xff, 0xff, 0x3d, 0x03, 0x0c, 0x98, 0x64, 0x80, 0xff, 0x89, 0xff,
   0x80, 0x80, 0x0c, 0x18, 0x80, 0x81, 0x7f, 0x08, 0xfe, 0x40, 0x80, 0x0c,
   0x18, 0x03, 0xa6, 0x1f, 0x08, 0xfc, 0x32, 0x00, 0x0c, 0x18, 0x02, 0x60,
   0x07, 0x08, 0x70, 0x0f, 0x40, 0x0c, 0x98, 0x07, 0x78, 0x00, 0x08, 0x20,
   0x03, 0x50, 0x0c, 0x18, 0x00, 0xa0, 0x00, 0x08, 0x00, 0x02, 0xf0, 0x0c,
   0x18, 0x00, 0xbe, 0x01, 0x08, 0xe0, 0x1e, 0x00, 0x0c, 0x18, 0xe0, 0x81,
   0x01, 0x08, 0xe0, 0xc2, 0x03, 0x0c, 0x18, 0x78, 0x80, 0x01, 0x08, 0xe0,
   0x02, 0x0f, 0x0c, 0x18, 0x80, 0x87, 0x01, 0x08, 0x60, 0xf2, 0x00, 0x0c,
   0x18, 0x00, 0xb8, 0x01, 0x08, 0x60, 0x0e, 0x00, 0x04, 0x10, 0x00, 0x20,
   0x01, 0x08, 0x20, 0x02, 0x00, 0x06, 0x30, 0x00, 0x30, 0x01, 0x08, 0x20,
   0x0f, 0x00, 0x02, 0x30, 0x00, 0x7e, 0xe0, 0xcd, 0x23, 0x11, 0x00, 0x03,
   0x60, 0x00, 0x41, 0x38, 0x08, 0x2e, 0xf0, 0x00, 0x03, 0x60, 0x80, 0x01,
   0x18, 0x14, 0xac, 0x03, 0x01, 0x03, 0x60, 0x40, 0xe0, 0xf9, 0xf7, 0xef,
   0x0c, 0x03, 0x03, 0x60, 0x60, 0x86, 0x03, 0x00, 0xe0, 0xf0, 0x03, 0x03,
   0x60, 0xe0, 0x81, 0xc6, 0xf7, 0xb1, 0x00, 0x00, 0x01, 0xc0, 0x00, 0x40,
   0x06, 0x3e, 0x10, 0x01, 0x80, 0x01, 0xc0, 0x41, 0x60, 0x1e, 0xbe, 0x3c,
   0x03, 0xc1, 0x00, 0x80, 0x81, 0x20, 0xfb, 0xbe, 0x6f, 0x82, 0xc0, 0x00,
   0x80, 0xc1, 0x90, 0x98, 0xdf, 0xc8, 0x84, 0xc1, 0x00, 0x80, 0x61, 0x78,
   0x98, 0xc9, 0x08, 0x0f, 0x63, 0x00, 0x00, 0x03, 0x18, 0x88, 0x29, 0x08,
   0x0c, 0x62, 0x00, 0x00, 0x06, 0x04, 0x40, 0x3a, 0x09, 0x00, 0x30, 0x00,
   0x00, 0xe6, 0x04, 0x60, 0x14, 0x01, 0x80, 0x33, 0x00, 0x00, 0x06, 0x00,
   0x20, 0x04, 0x12, 0x00, 0x18, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x08, 0x34,
   0x00, 0x18, 0x00, 0x00, 0x18, 0x60, 0x14, 0x08, 0x18, 0x00, 0x0c, 0x00,
   0x00, 0x18, 0x60, 0x1c, 0x08, 0x18, 0x03, 0x0c, 0x00, 0x00, 0x30, 0x90,
   0x00, 0x08, 0x00, 0x00, 0x07, 0x00, 0x00, 0x70, 0x90, 0x00, 0x08, 0x80,
   0x04, 0x03, 0x00, 0x00, 0x60, 0x20, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00,
   0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x80, 0x01,
   0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x80, 0x61, 0x00, 0x00, 0x00,
   0xc3, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00,
   0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18,
   0x00, 0x08, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00,
   0x0c, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x1c, 0x00, 0x03, 0x00, 0x00,
   0x00, 0x00, 0x60, 0x00, 0x08, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x80,
   0x01, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0xc0,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x08, 0x30, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x0e, 0x08, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x38, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x07,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xc1, 0x01, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x80, 0xe7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00};


#endif

String fallback_resources[] = {
     "*XmText.fontlist: -*-courier-medium-r-*--24-*",
     "*background: white",
     "*foreground: black",
     NULL
  } ;

String fallback_logo_resources[] = {
     "*background: orange",
     "*foreground: green",
     NULL
  } ;

void extern XaFeventMainMenubarApplication(),
            XaFeventMainMenubarEdit(),
            XaFeventMainMenubarView(),
            XaFeventMainMenubarUtilities(),
            XaFeventMainMenubarMosaic(),
            XaFeventMainMenubarHelp() ,
            XaFhelpCallback() ,
            XaFeventWorkAreaCommand() ;

String XaMainMenubarItemName[]    = {"Help" ,"Application", "Edit Class", 
                                     "View Class", "Utilities","Mosaic"} ;

char   XaMainMenubarItemLabel[]   = {'H', 'A', 'E', 'V', 'U', 'M'}  ;

int    XaMainMenubarItemNumber    = 6 ;

String XaWorkAreaHeaderInfoName[] = {"          Database Name:", "Class Name:   "} ;


/*****************************************************************/
/*                             mainLoop                          */
/*    Function to create the main Loop for the Window Aplication */
/*                                                               */
/*****************************************************************/

mainLoop(argc, argv,XaApplication)
int argc;
char *argv[];
XtAppContext XaApplication ;

  {
    int i ;

    XmString     XaString[20] ;

    argv[0] = XaMainWindowLabel ;

    XaTopLevel = XtVaAppInitialize(&XaApplication, "Main_Project", NULL, 0,
                                   &argc, argv, /*fallback_resources, */ NULL, NULL);

    XtVaSetValues(XaTopLevel,
                  XmNx,           XaMainWindowX,
                  XmNy,           XaMainWindowY,
                  NULL);


    /**********************************************************/
    /* the main window contains the work area and the menubar */
    /**********************************************************/

    XaMainWindow = XtVaCreateWidget("XaMainWindow",
                                    xmMainWindowWidgetClass, XaTopLevel,
                                    XmNwidth,                XaMainWindowWidth,
                                    NULL);


    /***************************/
    /***************************/
    /* Create The Main MenuBar */
    /***************************/
    /***************************/

      for (i = 0; i < XaMainMenubarItemNumber; i++)
        XaString[i] = XmStringCreateSimple(XaMainMenubarItemName[i]) ;

      XaMainMenubar = XmVaCreateSimpleMenuBar(XaMainWindow, "XaMainMenubar",
                            XmVaCASCADEBUTTON,XaString[0], XaMainMenubarItemLabel[0],
                            XmVaCASCADEBUTTON,XaString[1], XaMainMenubarItemLabel[1],
                            XmVaCASCADEBUTTON,XaString[2], XaMainMenubarItemLabel[2],
                            XmVaCASCADEBUTTON,XaString[3], XaMainMenubarItemLabel[3],
                            XmVaCASCADEBUTTON,XaString[4], XaMainMenubarItemLabel[4],
                            XmVaCASCADEBUTTON,XaString[5], XaMainMenubarItemLabel[5],
                            NULL);

      /**************************************************************/
      /* Tell Menubar That the First Item is the Help Menu in order */
      /* to place it on the extreme right of the window.            */
      /**************************************************************/

      if (XaTempWidget = XtNameToWidget(XaMainMenubar,"button_0"))
        XtVaSetValues(XaMainMenubar, XmNmenuHelpWidget, XaTempWidget, NULL) ;

      for (i = 0; i < XaMainMenubarItemNumber; i++)
        XmStringFree(XaString[i]) ;


      /*********************************************************/
      /* Create The SubMenus for Each Item in the Main MenuBar */
      /*********************************************************/

        /*****************************************************/
        /* Create The Pull Down Menu For Main Menu Item Help */
        /*****************************************************/

        XaString[0] = XmStringCreateSimple("Help Application");
        XaString[1] = XmStringCreateSimple("Help Display Area");
        XaString[2] = XmStringCreateSimple("Help Command Area");
        XmVaCreateSimplePulldownMenu(XaMainMenubar, "help_menu",
                                     0, XaFeventMainMenubarHelp,
                                     XmVaPUSHBUTTON, XaString[0], '1', NULL, NULL,
                                     XmVaPUSHBUTTON, XaString[1], '2', NULL, NULL,
                                     XmVaPUSHBUTTON, XaString[2], '3', NULL, NULL,
                                     NULL);

        for (i = 0; i < 3; i++)
        XmStringFree(XaString[i]) ;



        /************************************************************/
        /* Create The Pull Down Menu For Main Menu Item Application */
        /************************************************************/

        XaString[0]  = XmStringCreateSimple("Load Database");
        XaString[1]  = XmStringCreateSimple("Set Root Class");
        XaString[2]  = XmStringCreateSimple("Create Database");
        XaString[3]  = XmStringCreateSimple("Quit");
        XmVaCreateSimplePulldownMenu(XaMainMenubar, "application_menu",
                                     1, XaFeventMainMenubarApplication,
                                     XmVaPUSHBUTTON, XaString[0], 'L', NULL, NULL,
                                     XmVaPUSHBUTTON, XaString[1], 'S', NULL, NULL,
                                     XmVaPUSHBUTTON, XaString[2], 'C', NULL, NULL,
                                     XmVaDOUBLE_SEPARATOR,
                                     XmVaPUSHBUTTON, XaString[3], 'Q', NULL, NULL,
                                     NULL);

        for (i = 0; i < 4; i++)
        XmStringFree(XaString[i]) ;


        /*****************************************************/
        /* Create The Pull Down Menu For Main Menu Item Edit */
        /*****************************************************/

        XaString[0] = XmStringCreateSimple("create New class");
        XaString[1] = XmStringCreateSimple("Destroy Root  class");
        XaString[2] = XmStringCreateSimple("add new cHild");
        XaString[3] = XmStringCreateSimple("add Attribute class");
        XaString[4] = XmStringCreateSimple("add Instance  class");
        XaString[5] = XmStringCreateSimple("Edit instance class");
        XaString[6] = XmStringCreateSimple("Change parent class");
        XaString[7] = XmStringCreateSimple("Help");
        XmVaCreateSimplePulldownMenu(XaMainMenubar, "edit_menu",
                                     2, XaFeventMainMenubarEdit,
                                     XmVaPUSHBUTTON, XaString[0], 'N', NULL, NULL,
                                     XmVaPUSHBUTTON, XaString[1], 'D', NULL, NULL,
                                     XmVaPUSHBUTTON, XaString[2], 'H', NULL, NULL,
                                     XmVaPUSHBUTTON, XaString[3], 'A', NULL, NULL,
                                     XmVaPUSHBUTTON, XaString[4], 'I', NULL, NULL,
                                     XmVaPUSHBUTTON, XaString[5], 'E', NULL, NULL,
                                     XmVaPUSHBUTTON, XaString[6], 'C', NULL, NULL,
                                     XmVaSEPARATOR,
                                     XmVaPUSHBUTTON, XaString[7], 'H', NULL, NULL,
                                     NULL);

        for (i = 0; i < 8; i++)
        XmStringFree(XaString[i]) ;


        /*****************************************************/
        /* Create The Pull Down Menu For Main Menu Item View */
        /*****************************************************/

        XaString[0] = XmStringCreateSimple("View class Description") ;
        XaString[1] = XmStringCreateSimple("View Parent of class") ;
        XaString[2] = XmStringCreateSimple("View Children of class") ;
        XaString[3] = XmStringCreateSimple("View class Instances") ;
        XaString[4] = XmStringCreateSimple("View class instances by Tuple") ;
        XaString[5] = XmStringCreateSimple("Help");
        XmVaCreateSimplePulldownMenu(XaMainMenubar, "view_menu",
                                     3, XaFeventMainMenubarView,
                                     XmVaPUSHBUTTON, XaString[0], 'D', NULL, NULL,
                                     XmVaPUSHBUTTON, XaString[1], 'P', NULL, NULL,
                                     XmVaPUSHBUTTON, XaString[2], 'C', NULL, NULL,
                                     XmVaPUSHBUTTON, XaString[3], 'I', NULL, NULL,
                                     XmVaPUSHBUTTON, XaString[4], 'T', NULL, NULL,
                                     XmVaSEPARATOR,
                                     XmVaPUSHBUTTON, XaString[5], 'H', NULL, NULL,
                                     NULL);

        for (i = 0; i < 6; i++)
        XmStringFree(XaString[i]) ;


        /**********************************************************/
        /* Create The Pull Down Menu For Main Menu Item Utilities */
        /**********************************************************/

        XaString[0]  = XmStringCreateSimple("Hide Command Window");
        XaString[1]  = XmStringCreateSimple("Show Command Window");
        XaString[2]  = XmStringCreateSimple("Resize  Windows ");
        XaString[3]  = XmStringCreateSimple("reFresh Windows ");
        XaString[4]  = XmStringCreateSimple("Clear Display Area");
        XaString[5]  = XmStringCreateSimple("Export class definition");
        XaString[6]  = XmStringCreateSimple("export class Def inherit");
        XaString[7]  = XmStringCreateSimple("export class Instances");
        XaString[8]  = XmStringCreateSimple("export class Tree");
        XaString[9]  = XmStringCreateSimple("import Postquel file");
        XaString[10] = XmStringCreateSimple("Help");
        XaTempWidget = XmVaCreateSimplePulldownMenu(XaMainMenubar, "utilities_menu",
                                     4, XaFeventMainMenubarUtilities,
                                     XmVaPUSHBUTTON, XaString[0], 'W', NULL, NULL,
                                     XmVaPUSHBUTTON, XaString[1], 'S', NULL, NULL,
                                     XmVaPUSHBUTTON, XaString[2], 'R', NULL, NULL,
                                     XmVaPUSHBUTTON, XaString[3], 'F', NULL, NULL,
                                     XmVaPUSHBUTTON, XaString[4], 'C', NULL, NULL,
                                     XmVaPUSHBUTTON, XaString[5], 'E', NULL, NULL,
                                     XmVaPUSHBUTTON, XaString[6], 'D', NULL, NULL,
                                     XmVaPUSHBUTTON, XaString[7], 'I', NULL, NULL,
                                     XmVaPUSHBUTTON, XaString[8], 'T', NULL, NULL,
                                     XmVaPUSHBUTTON, XaString[9], 'P', NULL, NULL,
                                     XmVaSEPARATOR,
                                     XmVaPUSHBUTTON, XaString[10], 'H', NULL, NULL,
                                     NULL);

        XaCommandWindowHideButton = XtNameToWidget(XaTempWidget,"button_0") ;
        XaCommandWindowShowButton = XtNameToWidget(XaTempWidget,"button_1") ;
        XaCommandWindowResizeButton = XtNameToWidget(XaTempWidget,"button_2") ;
        XtUnmanageChild(XaCommandWindowResizeButton) ;

        for (i = 0; i < 10; i++)
        XmStringFree(XaString[i]) ;


        /*********************************************************/
        /* Create The Pull Down Menu For Main Menu Item Graphics */
        /* This is for Future Expansion To be implemented.       */
        /*********************************************************/

        XaString[0] = XmStringCreateSimple("Launch Main Application");
        XaString[1] = XmStringCreateSimple("Launch Selected Document");
        XaString[2] = XmStringCreateSimple("Help");
        XmVaCreateSimplePulldownMenu(XaMainMenubar, "mosaic_menu",
                                     5, XaFeventMainMenubarMosaic,
                                     XmVaPUSHBUTTON, XaString[0], 'M', NULL, NULL,
                                     XmVaPUSHBUTTON, XaString[1], 'S', NULL, NULL,
                                     XmVaSEPARATOR,
                                     XmVaPUSHBUTTON, XaString[2], 'H', NULL, NULL,
                                     NULL);
/*
        XaGraphicsMenubarButton = XtNameToWidget(XaMainMenubar,"button_5") ;
        XtUnmanageChild(XaGraphicsMenubarButton) ;
*/
        for (i = 0; i < 3; i++)
        XmStringFree(XaString[i]) ;


      /**************************************************************/
      /* Manage the Main MenuBar After all its Children Are Created */
      /**************************************************************/

      XtManageChild(XaMainMenubar);

    /***************************/
    /* End Create Main MenuBar */
    /***************************/


    /****************************************************/
    /****************************************************/
    /* Create Main Window Work Area For The Application */
    /****************************************************/
    /****************************************************/

    XaMainWorkArea = XtVaCreateWidget("XaMainWorkArea",
                                      xmPanedWindowWidgetClass,  XaMainWindow,
                                      NULL);


      /**************************************/
      /* Create The Work Area Header Window */
      /**************************************/

      XaWorkAreaHeader =  XtVaCreateWidget("XaWorkAreaHeader",
                                    xmFormWidgetClass,         XaMainWorkArea,
                                    XmNwidth,                  XaMainWindowWidth,
                                    XmNheight,                 XaWorkAreaHeaderHeight,
                                    XmNscrollBarDisplayPolicy, XmAS_NEEDED,
                                    XmNscrollingPolicy,        XmAUTOMATIC,
                                    NULL) ;


        /********************************************/
        /* Create The Work Area Header Logo Window  */
        /********************************************/

        {
          Pixmap       XaPixmap ;
          Pixel        fg, bg ;
          char         *XaLogoPictureName ;


          XaWorkAreaHeaderLogo = XtVaCreateManagedWidget("XaWorkAreaHeaderLogo",
                                    xmMainWindowWidgetClass, XaWorkAreaHeader,
/*
                                    fallback_logo_resources,
*/
                                    XmNwidth,                ConUlogo_width,
                                    XmNtopAttachment ,       XmATTACH_FORM,
                                    XmNleftAttachment ,      XmATTACH_FORM,
                                    XmNbottomAttachment ,    XmATTACH_FORM,
                                    NULL) ;

         /*************************************/
         /*  Create the Logo for Main Window  */
         /*************************************/
         XtVaGetValues(XaWorkAreaHeaderLogo,
                       XmNforeground, &fg,
                       XmNbackground, &bg,
                       NULL) ;

         XaPixmap = XCreatePixmapFromBitmapData(XtDisplay(XaWorkAreaHeaderLogo),
                                  RootWindowOfScreen(XtScreen(XaWorkAreaHeaderLogo)),
                                  ConUlogo_bits,
                                  ConUlogo_width,
                                  ConUlogo_height,
                                  fg, bg,
                                  DefaultDepthOfScreen(XtScreen(XaWorkAreaHeaderLogo)));

         XaWorkAreaHeaderLogoPic  = XtVaCreateManagedWidget("XaLlabel",
                                        xmLabelGadgetClass,   XaWorkAreaHeaderLogo,
                                        XmNlabelType,         XmPIXMAP,
                                        XmNlabelPixmap,       XaPixmap,
                                        XmNleftAttachment,    XmATTACH_FORM,
                                        XmNtopAttachment,     XmATTACH_FORM,
                                        XmNbottomAttachment,  XmATTACH_FORM,
                                        NULL) ;

      /*****************************************/
      /*  end Create the Logo for Main Window  */
      /*****************************************/


/*
          XaWorkAreaHeaderLogo = XtVaCreateManagedWidget("XaWorkAreaHeaderLogo",
                                    xmMainWindowWidgetClass, XaWorkAreaHeader,
                                    XmNwidth,                XaWorkAreaHeaderLogoWidth,
                                    XmNtopAttachment ,       XmATTACH_FORM,
                                    XmNleftAttachment ,      XmATTACH_FORM,
                                    XmNbottomAttachment ,    XmATTACH_FORM,
                                    NULL) ;

          XaLogoPictureName = XaLogoPathFilename ;

          XaPixmap = XmGetPixmap(XtScreen(XaTopLevel), XaLogoPictureName,
                                 BlackPixelOfScreen(XtScreen(XaTopLevel)),
                                 WhitePixelOfScreen(XtScreen(XaTopLevel))) ;

          if (XaPixmap == XmUNSPECIFIED_PIXMAP)
            {
              printf("can't create pixmap from %s\n",argv[1]) ;
              exit(1) ;
            }

          XaWorkAreaHeaderLogoPic = XtVaCreateManagedWidget("XaWorkAreaHeaderLogoPic",
                                         xmLabelWidgetClass,  XaWorkAreaHeaderLogo,
                                         XmNlabelType,   XmPIXMAP,
                                         XmNlabelPixmap, XaPixmap,
                                         NULL) ;
*/
        }

        /********************************************/
        /* End Create Work Area Header Logo Window  */
        /********************************************/


        /********************************************/
        /* Create The Work Area Header Info Window  */
        /********************************************/

        XaWorkAreaHeaderInfo = XtVaCreateWidget("XaWorkAreaHeaderInfo",
                                       xmFormWidgetClass,         XaWorkAreaHeader,
                                       XmNtopAttachment,          XmATTACH_FORM,
                                       XmNleftAttachment,         XmATTACH_WIDGET,
                                       XmNleftWidget,             XaWorkAreaHeaderLogo,
                                       XmNrightAttachment,        XmATTACH_FORM,
                                       XmNbottomAttachment,       XmATTACH_FORM,
                                       XmNscrollBarDisplayPolicy, XmAS_NEEDED,
                                       XmNscrollingPolicy,        XmAUTOMATIC,
                                       NULL) ;

          /************************************************************************/
          /* Create The Labels and their Values for Work Area Header Info Window  */
          /************************************************************************/               
          {
            int XaLi ;
            Widget XaWorkAreaHeaderInfoMain,
                   XaWorkAreaHeaderInfoRowCol,
                   XaWorkAreaHeaderInfoRowColForm, XaLtempWidget,
                   XaWorkAreaHeaderInfoRowColText ;

            XaWorkAreaHeaderInfoMain = XtVaCreateWidget("XaLmain",
                                                        xmMainWindowWidgetClass,
                                                        XaWorkAreaHeaderInfo,
                                                        NULL) ;

            XaWorkAreaHeaderInfoRowCol = XtVaCreateWidget("XaWorkAreaHeaderInfoRowCol",
                                                          xmRowColumnWidgetClass,
                                                          XaWorkAreaHeaderInfoMain,
                                                          NULL) ;

            for (XaLi = 0; XaLi < XtNumber(XaWorkAreaHeaderInfoName); XaLi++)
              {
                XaWorkAreaHeaderInfoRowColForm = XtVaCreateWidget("XaLform",
                                                   xmFormWidgetClass,
                                                   XaWorkAreaHeaderInfoRowCol,
                                                   XmNfractionBase, 10,
                                                   NULL) ;

                XtVaCreateManagedWidget(XaWorkAreaHeaderInfoName[XaLi],
                              xmLabelGadgetClass,       XaWorkAreaHeaderInfoRowColForm,
                              XmNtopAttachment,         XmATTACH_FORM,
                              XmNbottomAttachment,      XmATTACH_FORM,
                              XmNleftAttachment,        XmATTACH_FORM,
                              XmNrightAttachment,       XmATTACH_POSITION,
                              XmNrightPosition,         4,
                              XmNalignment,             XmALIGNMENT_END,
                              NULL) ;

                XaWorkAreaHeaderInfoRowColText = XtVaCreateManagedWidget("XaLtext",
                              xmTextFieldWidgetClass,   XaWorkAreaHeaderInfoRowColForm,
                              XmNtraversalOn,           False,
                              XmNcursorPositionVisible, False,
                              XmNrightAttachment,       XmATTACH_FORM,
                              XmNleftAttachment,        XmATTACH_POSITION,
                              XmNleftPosition,          5,
                              NULL) ;

                if (XaLi == 0)
                  {
                    XaWorkAreaHeaderInfoDbsName = XaWorkAreaHeaderInfoRowColText ;
                    XmTextReplace(XaWorkAreaHeaderInfoDbsName,
                                  0, strlen(MaDbName), MaDbName) ;
                  }
                else if (XaLi == 1)
                  {
                    XaWorkAreaHeaderInfoClsName = XaWorkAreaHeaderInfoRowColText ;
                    XmTextReplace(XaWorkAreaHeaderInfoClsName,
                                  0, strlen(MaClassName), MaClassName) ;
                  }

                XtManageChild(XaWorkAreaHeaderInfoRowColForm) ;
              }

            XtManageChild(XaWorkAreaHeaderInfoRowCol) ;
            XtManageChild(XaWorkAreaHeaderInfoMain) ;
          }

        XtManageChild(XaWorkAreaHeaderInfo) ;

        /********************************************/
        /* End Create Work Area Header Info Window  */
        /********************************************/


      XtManageChild(XaWorkAreaHeader) ;

      /**************************************/
      /* End Create Work Area Header Window */
      /**************************************/


      /***********************************/
      /* Create Work Area Display Window */
      /***********************************/

      XaWorkAreaDisplay = XtVaCreateWidget("XaWorkAreaDisplay",
                                    xmPanedWindowWidgetClass, XaMainWorkArea,
                                    NULL);


        /**********************************************/
        /* Create The Work Area Display Label Window  */
        /**********************************************/

        XaWorkAreaDisplayLabel = XtVaCreateManagedWidget("Display Area",
                         xmLabelWidgetClass, XaWorkAreaDisplay,
                         NULL) ;

        /**********************************************/
        /* End Create Work Area Display Label Window  */
        /**********************************************/

        /*********************************************/
        /* Create The Work Area Display Text Window  */
        /*********************************************/

        XtSetArg(XaArguments[0], XmNrows,      XaWorkAreaDisplayRows);
        XtSetArg(XaArguments[1], XmNcolumns,   80);
        XtSetArg(XaArguments[2], XmNeditable,  False);
        XtSetArg(XaArguments[3], XmNeditMode,  XmMULTI_LINE_EDIT);
        XtSetArg(XaArguments[4], XmNwordWrap,  True);
        XtSetArg(XaArguments[5], XmNblinkRate, 0);
        XtSetArg(XaArguments[6], XmNautoShowCursorPosition, False);
        XtSetArg(XaArguments[7], XmNcursorPositionVisible,  False);
        XtSetArg(XaArguments[8], XmNtraversalOn,            False);

        XaWorkAreaDisplayText = XmCreateScrolledText(XaWorkAreaDisplay,
                                                     "XaWorkAreaDisplayText",
                                                     XaArguments, 9);

        XaFfillupTextBufferArea(XaDisplayBuffer, XaWorkAreaDisplayText) ;
        XtManageChild(XaWorkAreaDisplayText) ;

        /*********************************************/
        /* End Create Work Area Display Text Window  */
        /*********************************************/


      XtManageChild(XaWorkAreaDisplay) ;

      /***************************************/
      /* End Create Work Area Display Window */
      /***************************************/



      /***********************************/
      /* Create Work Area Command Window */
      /***********************************/

      XaWorkAreaCommand = XtVaCreateWidget("XaWorkAreaCommand",
                                    xmPanedWindowWidgetClass, XaMainWorkArea,
                                    NULL);


        /***********************************************/
        /* Create The Work Area Command Header Window  */
        /***********************************************/

        XaWorkAreaCommandHeader = XtVaCreateManagedWidget("Command Area",
                         xmLabelWidgetClass, XaWorkAreaCommand,
                         NULL) ;

        /***********************************************/
        /* End Create Work Area Command Header Window  */
        /***********************************************/


        /*********************************************/
        /* Create The Work Area Command Text Window  */
        /*********************************************/

        XtSetArg(XaArguments[0], XmNrows,   XaWorkAreaCommandRows) ;
        XtSetArg(XaArguments[1], XmNcolumns,                   80) ;
        XtSetArg(XaArguments[2], XmNeditable,                True) ;
        XtSetArg(XaArguments[3], XmNeditMode,   XmMULTI_LINE_EDIT) ;
        XtSetArg(XaArguments[4], XmNwordWrap,                True) ;
        XtSetArg(XaArguments[5], XmNblinkRate,                  0) ;
        XtSetArg(XaArguments[6], XmNautoShowCursorPosition, False) ;

        XaWorkAreaCommandText = XmCreateScrolledText(XaWorkAreaCommand,
                                                     "XaWorkAreaDisplayText",
                                                     XaArguments, 6);

        XaFfillupTextBufferArea(XaCommandBuffer, XaWorkAreaCommandText) ;
        XtManageChild(XaWorkAreaCommandText) ;

        /*********************************************/
        /* End Create Work Area Command Text Window  */
        /*********************************************/



        /***********************************************/
        /* Create The Work Area Command Option Window  */
        /***********************************************/

        XaWorkAreaCommandOption = XtVaCreateWidget("XaWorkAreaCommandOption",
                                                   xmFormWidgetClass, XaWorkAreaCommand,
                                                   XmNfractionBase,      10,
                                                   XmNpaneMinimum,       XaButtonSize,
                                                   XmNpaneMaximum,       XaButtonSize,
                                                   NULL) ;

        XaWorkAreaCommandOptionClear = XtVaCreateManagedWidget("Clear",
                                   xmPushButtonGadgetClass, XaWorkAreaCommandOption,
                                   XmNtopAttachment,     XmATTACH_FORM,
                                   XmNbottomAttachment,  XmATTACH_FORM,
                                   XmNleftAttachment,    XmATTACH_POSITION,
                                   XmNleftPosition,      1,
                                   XmNrightAttachment,   XmATTACH_POSITION,
                                   XmNrightPosition,     3,
                                   XmNshowAsDefault,     True,
                                   XmNdefaultButtonShadowThickness, 1,
                                   NULL) ;

        XtAddCallback(XaWorkAreaCommandOptionClear, XmNactivateCallback,
                      XaFeventWorkAreaCommand,0) ;


        XaWorkAreaCommandOptionExecute = XtVaCreateManagedWidget("Execute",
                                   xmPushButtonGadgetClass, XaWorkAreaCommandOption,
                                   XmNtopAttachment,     XmATTACH_FORM,
                                   XmNbottomAttachment,  XmATTACH_FORM,
                                   XmNleftAttachment,    XmATTACH_POSITION,
                                   XmNleftPosition,      4,
                                   XmNrightAttachment,   XmATTACH_POSITION,
                                   XmNrightPosition,     6,
                                   XmNshowAsDefault,     True,
                                   XmNdefaultButtonShadowThickness, 1,
                                   NULL) ;

        XtAddCallback(XaWorkAreaCommandOptionExecute, XmNactivateCallback,
                      XaFeventWorkAreaCommand,1) ;


        XaWorkAreaCommandOptionLog = XtVaCreateManagedWidget("Log",
                                   xmPushButtonGadgetClass, XaWorkAreaCommandOption,
                                   XmNtopAttachment,     XmATTACH_FORM,
                                   XmNbottomAttachment,  XmATTACH_FORM,
                                   XmNleftAttachment,    XmATTACH_POSITION,
                                   XmNleftPosition,      7,
                                   XmNrightAttachment,   XmATTACH_POSITION,
                                   XmNrightPosition,     9,
                                   XmNshowAsDefault,     True,
                                   XmNdefaultButtonShadowThickness, 1,
                                   NULL) ;

        XtAddCallback(XaWorkAreaCommandOptionLog, XmNactivateCallback,
                      XaFeventWorkAreaCommand,2) ;


        XtManageChild(XaWorkAreaCommandOption) ;

        /***********************************************/
        /* End Create Work Area Command Option Window  */
        /***********************************************/


      XtManageChild(XaWorkAreaCommand) ;

      /***************************************/
      /* End Create Work Area Command Window */
      /***************************************/


      /**********************************/
      /* Create Work Area Bottom Window */
      /* This is in case the user would */
      /* like to add more  functionali- */
      /* ties to the system.            */
      /**********************************/
/*
      XaWorkAreaBottom = XtVaCreateWidget("XaWorkAreaBottom",
                                    xmMainWindowWidgetClass, XaMainWorkArea,
                                    XmNwidth,       XaMainWindowWidth,
                                    XmNheight,      XaWorkAreaBottomHeight,
                                    NULL);


      XtManageChild(XaWorkAreaBottom) ;
*/
      /**************************************/
      /* End Create Work Area Bottom Window */
      /**************************************/


    XtManageChild(XaMainWorkArea) ;

    XtManageChild(XaMainWindow) ;


    /**********************************************/
    /* End Create Main Window For The Application */
    /**********************************************/

    XtRealizeWidget(XaTopLevel);

    if (XaShowCommandAreaStatus == MaTRUE)
      {
        XtUnmanageChild(XaCommandWindowShowButton) ;
      }
    else
      {
        XtUnmanageChild(XaWorkAreaCommand) ;
        XtUnmanageChild(XaCommandWindowHideButton) ;
      }

    XtAppMainLoop(XaApplication);

  }  


/*****************************************************************/
/*                             main                              */
/*    main program block.                                        */
/*                                                               */
/*****************************************************************/

main(MaLargc, MaLargv)
int MaLargc;
char *MaLargv[];

  { /* begin main program block */
    int     MaLi ;
    char   *getenv();

    strcpy(MaDbName,getenv("USER")) ;
    strcpy(MaClassName,"\0") ;
    for (MaLi = 0; MaLi < MaMaxPortalNameNum; MaLi++)
      MaGportalArrayAvailable[MaLi] = MaTRUE ;

    MaFstartUp() ;
    MaGargc = MaLargc ;
    MaGargv[0] = MaLargv[0] ;
    mainLoop(MaGargc, MaGargv,XaApplication1) ;

  } /* end  main program block */


/*****************************************************************/
/*                                                               */
/*                       END OF mainfile.c FILE                  */
/*                                                               */
/*****************************************************************/