
/******************************************************************
 *                                                                *
 *                  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.h    *************************/
/******************************************************************/
/*                                                                */
/*    This file include all files required for the Toolkit. Also, */
/*  it contains the definition & Initialization of all the Global */
/*  Variables and Structures used throughout the Project.         */
/*                                                                */
/******************************************************************/

#ifndef MAINFILE
#define MAINFILE

/******************************************************************/
/*                                                                */
/*    This section contains  the  include files  required for the */
/*  Toolkit.                                                      */
/*                                                                */
/******************************************************************/


#include <stdio.h>

#include <math.h>
#include <X11/Intrinsic.h>     /* Intrinsics Definitions */
#include <X11/StringDefs.h>
#include <X11/Shell.h>
#include <X11/Xaw/AsciiText.h>
#include <X11/Xaw/Label.h>
#include <X11/Xaw/Form.h>
#include <X11/Xaw/Viewport.h>
#include <X11/Xaw/Paned.h>
#include <X11/Xaw/Box.h>
#include <X11/Xaw/Command.h>
#include <X11/Xaw/Dialog.h>
#include <X11/Xaw/Cardinals.h>
#include <X11/X10.h>
#include <X11/Xlib.h>
#include <X11/cursorfont.h>


#include <Xm/Text.h>
#include <Xm/MainW.h>
#include <Xm/Command.h>


#include <Xm/RowColumn.h>
#include <Xm/LabelG.h>
#include <Xm/Label.h>
#include <X11/Xos.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <ctype.h>
#include <Xm/Form.h>
#include <Xm/ScrolledW.h>
#include <Xm/SelectioB.h>
#include <Xm/MessageB.h>
#include <Xm/PanedW.h>
#include <Xm/FileSB.h>

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>


#include <Xm/Xm.h>
#include <Xm/PushB.h>
#include <Xm/PushBG.h>
#include <Xm/DialogS.h>
#include <Xm/PanedW.h>
#include <Xm/TextF.h>
#include <Xm/BulletinB.h>

#include <tmp/libpq.h>
#include <tmp/libpq-fe.h>


/******************************************************************/
/*                                                                */
/*    This section contains the definition of all the Global Var- */
/*  iables & Structures  used throughout the Project.             */
/*                                                                */
/*  Note:* All Variables Starting with Xt belong to X intrinsic.  */
/*       * All Variables Starting with Xm belong to X motif.      */
/*       * All Variables Starting with Xa belong to the Graphical */
/*         User Interface of the application.                     */
/*       * All Variables Starting with XaF are Function Name that */
/*         belong to the GUI of the Main Aplication.              */
/*       * All Variables Starting with Ma belong to the Main App- */
/*         lication.                                              */
/*       * All Variables Starting with MaF are Function Name that */
/*         belong to the Main Aplication.                         */
/*                                                                */
/******************************************************************/


#define XaMainWindowLabel  "Graphical Development Environment for Postgres"
                                                /* Label Of The Main
                                                Window Application */

#define MaTRUE                                 1
#define MaFALSE                                0
#define MaMaxLabelSize                         200
#define MaMaxRecSize                           1000
#define MaMaxBufSize                           BUFSIZ
#define MaMaxListItemsNum                      50
#define MaMaxPortalNameNum                     8
#define MaMaxOidNumber                         999999

#define MaSelectionMustNotMatch               -1  /* Tell the selection List that */
                                                  /* selection choice must not    */
                                                  /* match the items in the list. */

#define MaAnySelectionOk                       0  /* Tell the selection List that */
                                                  /* any selection choice is ok.  */
                                            
#define MaSelectionMustMatch                   1  /* Tell the selection List that */
                                                  /* selection choice must match  */
                                                  /* one item in the list.        */

#define MaDisplayBefore                        1  /* To show that an instance has */
                                                  /* already been displayed.      */

#define MaDisplayCurrent                       0  /* To show that an instance is  */
                                                  /* currently being displayed.   */

#define MaDisplayNotYet                       -1  /* To show that an instance is  */
                                                  /* not being displayed yet.     */

#define MaSelectionActionSetDataBase           0  /* Tell the selction box to set */
                                                  /* set the  Database  Name with */
                                                  /* the selected choice.         */

#define MaSelectionActionSetClass              1  /* Tell the selction box to set */
                                                  /* set the Class  Name with the */
                                                  /* selected choice.             */

#define MaSelectionActionCreateDataBase        2  /* Tell the selction box to set */
                                                  /* set the  Database  Name with */
                                                  /* the selected choice.         */

#define MaSelectionActionSetLogCommand         3  /* Tell the selction box to set */
                                                  /* set the command are with the */
                                                  /* selected choice.             */

#define MaSelectionActionCreateNewClass        4  /* Tell the Instance Shell That */
                                                  /* we are in  Create New Class  */
                                                  /* mode.                        */

#define MaSelectionActionDestroyRootClass      5  /* Tell the Instance Shell That */
                                                  /* we are in Destroy Class Mode */

#define MaSelectionActionAddNewChild           6  /* Tell the Instance Shell That */
                                                  /* we are in Add New child Mode */

#define MaSelectionActionAddAttributeName      7  /* Tell the Instance Shell That */
                                                  /* we are in Add New attribute  */
                                                  /* name to the specified class  */

#define MaSelectionActionAddAttributeType      8  /* Tell the Instance Shell That */
                                                  /* we are in Add New attribute  */
                                                  /* type to the specified class  */

#define MaSelectionActionAddInstance           9  /* Tell the Instance Shell That */
                                                  /* we are in Add Mode.          */

#define MaSelectionActionEditInstance          10 /* Tell the Instance Shell That */
                                                  /* we are in Edit Mode.         */

#define MaSelectionActionEditInstanceDelete    11 /* Tell the Instance Shell That */
                                                  /* we are in Edit Mode and del- */
                                                  /* ete an instance case.        */

#define MaSelectionActionChangeParentClass     12 /* Tell the Instance Shell That */
                                                  /* we are in Edit Mode and del- */
                                                  /* ete an instance case.        */

#define MaSelectionActionViewClassDescription  13 /* Tell the Instance Shell That */
                                                  /* we are in a View Mode.       */

#define MaSelectionActionViewInstance          14 /* Tell the Instance Shell That */
                                                  /* we are in a View Mode.       */

#define MaSelectionActionExportClassDefinition 15 /* Tell the Instance Shell That */
                                                  /* we are in a View Mode.       */

#define MaSelectionActionExportClassInstances  16 /* Tell the Instance Shell That */
                                                  /* we are in a View Mode.       */

#define MaSelectionActionMosaicSelectSubject   17 /* Tell the selction box we are */
                                                  /* in Mosaic Selection Subject  */
                                                  /* choice.                      */

#define MaSelectionActionMosaicSelectDocument  18 /* Tell the selction box we are */
                                                  /* in Mosaic Selection Document */
                                                  /* choice.                      */

#define XaDialogNotice                        XmDIALOG_MESSAGE

#define MaPqTextType         "text"

#define MaClear              "clear"     /* system command to clear the screen */
#define MaRemoveFile         "rm "       /* system command to delete a file    */
#define MaCopyFile           "cp "       /* system command to copy a file      */
#define MaLogFilenameExt     ".log"      /* extension for log file.            */
#define MaStatusFilenameExt  ".sta"      /* extension for status file.         */
#define MaCommandLogFilename "pcommand.log"   /* Postquel Command log filename */
#define MaRootClassName      "SHAPE"     /* Root Class Name At the Top Level   */
                                         /* of the TREE.                       */

#define MaClassExportSeparator   "\\g\n" /* separator to be added at he end of */
                                         /* each exported postquel command.    */
#define MaClassDefinitionFileExt ".cdf"  /* extension for class definition file*/
#define MaClassDefInheritFileExt ".cdi"  /* extension for class definition file*/
#define MaClassInstanceFileExt   ".cin"  /* extension for class instances file.*/
#define MaClassTreeFileExt       ".ctr"  /* extension for class Tree file.     */
#define MaClassTreeFileTempExt   ".ctmp" /* extension for class Tree Temp file.*/
#define MaClassChangeParentExt   ".cpcl" /* extension for Change Parent Class .*/


#define XaHelpTextValueEdit             0
#define XaHelpTextValueView             1
#define XaHelpTextValueFileSelectionBox 2
#define XaHelpTextValueUtilities        3
#define XaHelpTextValueMosaic           4
#define XaHelpTextValueHelp1            5
#define XaHelpTextValueHelp2            6
#define XaHelpTextValueHelp3            7
#define XaTopShellBorderWidth           3
#define XaTopShellBorderHeight         27

#define XaButtonSize                   40

typedef char MaLabelType[MaMaxLabelSize] ;
typedef char MaStringType[MaMaxRecSize]  ;
typedef char MaBufferType[MaMaxBufSize]  ;

typedef char *MaGargvType[20] ;

struct MaGstringRec
    {
      Widget               MaLchildWidgetId ;

      MaLabelType          MaLlabelName     ;
      MaLabelType          MaLlabelType     ;
      MaStringType         MaLstringData    ;
      struct MaGstringRec *MaLpNextString   ;
    } ;

typedef struct MaGstringRec *MaStringListStruct ;


struct MaGclientDataRec
    {
      Widget                   MaLshellWidgetId       ;
      Widget                   MaLshellPreviousButton ;
      Widget                   MaLshellNextButton     ;

      MaLabelType              MaLexportFilename      ;
      FILE                    *MaLstreamExportFile    ;

      MaStringListStruct       MaLobjectIdsList       ;
      MaStringListStruct       MaLstringList          ;
      MaStringListStruct       MaLtextStringList      ;
      MaStringListStruct       MaLchildrenStringList  ;

      MaStringType             MaLlistLabel           ;
      MaStringType             MaLclassName           ;
      MaStringType             MaLparentName          ;
      MaStringType             MaLchildName           ;
      MaStringType             MaLnewParentName       ;
      MaStringType             MaLattributeName       ;
      MaStringType             MaLattributeType       ;
      MaStringType             MaLdialogMessage       ;

      int                      MaLselectionAction     ;
      int                      MaLselectionMode       ;
      int                      MaLeditableMode        ;
      int                      MaLdialogType          ;
      int                      MaLpreviousOid         ;
      int                      MaLcurrentOid          ;
      int                      MaLnextOid             ;
      int                      MaLfreeNodeOk          ;
      int                      MaLCreateNewClassMode  ;
      int                      MaLexportInheritMode   ;
      int                      MaLparentChildConflict ;

      struct MaGclientDataRec *MaLpNextClientData     ;
    } ;

typedef struct MaGclientDataRec *MaClientDataStruct ;


/******************************************************************/
/*                                                                */
/*    This section contains the typing of all the Global Vriables */
/*  used throughout the Project.                                  */
/******************************************************************/

MaBufferType   XaDisplayBuffer        ;
MaBufferType   XaCommandBuffer        ;

XtAppContext XaApplication1           ;
static XtWorkProcId XaWorkId          ;
static XaGcounter                     ;

Widget XaTopLevel                     ;
Widget XaTopMainWindow                ;
Widget XaMainWindow                   ;
Widget XaMainMenubar                  ;
Widget XaMainWorkArea                 ;

Widget XaWorkAreaHeader               ;
Widget XaWorkAreaHeaderLogo           ;
Widget XaWorkAreaHeaderLogoPic        ;
Widget XaWorkAreaHeaderInfo           ;
Widget XaWorkAreaHeaderInfoDbsName    ;
Widget XaWorkAreaHeaderInfoClsName    ;

Widget XaWorkAreaDisplay              ;
Widget XaWorkAreaDisplayLabel         ;
Widget XaWorkAreaDisplayText          ;

Widget XaWorkAreaCommand              ;
Widget XaWorkAreaCommandHeader        ;
Widget XaWorkAreaCommandText          ;
Widget XaWorkAreaCommandOption        ;
Widget XaWorkAreaCommandOptionClear   ;
Widget XaWorkAreaCommandOptionExecute ;
Widget XaWorkAreaCommandOptionLog     ;
Widget XaTempWidget                   ;
Widget XaGraphicsMenubarButton        ;
Widget XaCommandWindowHideButton      ;
Widget XaCommandWindowShowButton      ;
Widget XaCommandWindowResizeButton    ;
Widget XaHelpDialogBoxWindow          ;
Widget XaInstanceShellBoxWindow       ;

Widget XaWaitNoticeWindow             ; /* This is to inform the user that the Appl- */
                                        /* ication is busy Doing certain task, so it */
                                        /* asks the user to wait until the task is   */
                                        /* finished.                                 */

Arg    XaArguments[20]                ;

int    XaSystemAdministratorPrivilege ; /* If user has a system Adminstrator Privlege */
int    XaGDEPexportFileCompatible     ; /* Export File in GDEP format.                */
int    XaMainWindowX                  ; /* Initial X Position of Window in the Screen */
int    XaMainWindowY                  ; /* Initial Y Position of Window in the Screen */
int    XaMainWindowWidth              ;
int    XaMainWindowHeight             ;
int    XaWorkAreaHeaderHeight         ;
int    XaWorkAreaDisplayHeight        ;
int    XaWorkAreaDisplayRows          ;
int    XaWorkAreaCommandHeight        ;
int    XaWorkAreaCommandRows          ;
int    XaWorkAreaBottomHeight         ;
int    XaShowCommandAreaStatus        ;
int    XaHelpDialogBoxTextWidth       ;
int    XaHelpDialogBoxTextRows        ;
int    XaHelpDialogBoxX               ;
int    XaHelpDialogBoxY               ;
int    XaHelpWindowExistStatus        ;
int    XaInstanceShellBoxX            ;
int    XaInstanceShellBoxY            ;
int    XaInstanceAreaDisplayRows      ;
int    XaInstanceShellExistStatus     ;
int    MaGportalArrayAvailable[MaMaxPortalNameNum] ;

char  *XaLogoPictureName              ; 

int           MaGargc                 ;
MaGargvType   MaGargv                 ;

MaStringType  MaDbName ;           /* The Database to be used in this project. */
MaStringType  MaClassName ;        /* The Root Class That is current to the    */
                                   /* application.                             */
MaStringType  MaLogFilename ;      /* Log filename.                            */
MaStringType  MaStatusFilename ;   /* Status filename.                         */
MaStringType  MaProjectPath ;      /* Path to retrieve the customization vari- */
                                   /* ables related files to the project.      */
MaStringType  MaMosaicApplicationPath; /* Path to start the Mosaic Application */
MaStringType  MaCompressCommand   ;/* System command to Compress text files.   */
MaStringType  MaCompressedFileExt ;/* Extension for a compressed file.         */
MaStringType  MaUncompressCommand ;/* System command to Uncompressed compressed*/
                                   /* files.                                   */

MaStringType  XaHelpDialogBoxLabel ;

FILE   *MaStreamLogFile ;          /* Stream File for Log File.                */
FILE   *MaStreamStatusFile ;       /* Stream File for Status File.             */
FILE   *MaStreamCommandLogFile ;   /* Stream File for Postquel Command Log     */

int     MaKeepLog ;                /* Global Variable that can be true or false*/
                                   /* If True then project will keep log of the*/
                                   /* Postquel Commands, Otherwise it won't.   */

int     MaPrintHeader ;            /* Global Variable that can be true or false*/
                                   /* If True then header will be printed on   */
                                   /* top of the screen, Otherwise it won't.   */

extern void XaUtilities() ;

#endif


/*****************************************************************/
/*                                                               */
/*                       END OF mainfile.h FILE                  */
/*                                                               */
/*****************************************************************/