/******************************************************************************/
/**									     **/
/**		      Copyright 1990 by Computer Science Dept.  	     **/
/**			University College London, England		     **/
/**									     **/
/**									     **/
/** Permission to use, copy and modify (but NOT distribute) this software    **/
/** and its documentation for any purpose and without fee is hereby granted, **/
/** provided the above copyright notice appears in all copies, and that both **/
/** that copyright notice and this permission notice appear in supporting    **/
/** documentation, and that the name Pygmalion not be used in advertising or **/
/** publicity of the software without specific, written prior permission of  **/
/** Thomson-CSF.							     **/
/**									     **/
/** THE DEPARTMENT OF COMPUTER SCIENCE, UNIVERSITY COLLEGE LONDON DISCLAIMS  **/
/** ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED       **/
/** WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL THE 	     **/
/** DEPARTMENT OF COMPUTER SCIENCE, UNIVERSITY COLLEGE LONDON BE LIABLE FOR  **/
/** ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER **/
/** RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF     **/
/** CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN      **/
/** CONJUNCTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.		     **/
/**									     **/
/******************************************************************************/

/******************************************************************************
 * Pygmalion Programming Environment v 1.01 30/1/90
 *
 * pgm 
 *
 * Patset_control.c
 ******************************************************************************/

#include "everything.h"
#include "myheader.h"

/*----------------------------------------------*/
/* THIS PROC DEALS WITH				*/
/* 	1- The creation of the BATCH/INTERACT button    */
/*	2- The effect = call Take_input 	*/
/* 			 which will take the filename.appli */
/*			or more .....           */
/*----------------------------------------------*/



/*----------------------------------------------*/
/* EXTERN for the 1- father widget		*/
/* 	          2- neighbour(s) within the form	*/
/* 		  3- the created widget itself 	*/
/*				IO           */
extern Widget simulation ;
extern Widget batchinteract;
extern Widget patset;
extern Widget pgmtarget;


/*-----------------------------------------------------*/
/* ARGUMENTS FOR BATCH/INTERACT widget				*/
/*-----------------------------------------------------*/

/* Args for batchinteract widget */
	Arg batchinteract_arg[] = {
                {XtNfromVert, (XtArgVal)NULL},
                {XtNfromHoriz, (XtArgVal)NULL},
                {XtNlabel, (XtArgVal)NULL},
                {XtNhighlightThickness, (XtArgVal)3},
/* MIKE CHANGE for foreground */
                {XtNdestroyCallback, (XtArgVal)NULL},
                {XtNhorizDistance, (XtArgVal)4},
                {XtNvertDistance, (XtArgVal)2},
                {XtNwidth, (XtArgVal)2*BUTTON_WIDTH},
                {XtNheight, (XtArgVal)BUTTON_HEIGHT},
        };

/*----------------------------------------------*/
/* CALL BACK OF THE COMMAND BATCH/INTERACT      */
/*---------------------------------------------*/

  void Batch_callback(initiateur, client_data, call_data)
  Widget initiateur;
  int client_data;  /* makes the difference between Batch and Interact */
  caddr_t call_data;     /* not used  */
  {

/* The user has asked to execute in batch mode */
/* user has to input the application filename */
  if (client_data == 1)
	{
 	printf("back to batch\n") ; 
 	Take_input(initiateur,0) ; 
	} 
  else
 	printf("back to interactive\n") ; 

  }

  void Interact_callback(initiateur, client_data, call_data)
  Widget initiateur;
  caddr_t client_data;  /* used as thepopup but no interest at the moment*/
  caddr_t call_data;     /* not used  */
  {

/* The user has asked to go back to interactive mode */
/* user has to input the appl;ication filename */
 	printf("back to interactive\n") ; 
  }
 
/*----------------------------------------------
 * CREATION OF THE BATCH/INTERACT command widget (proc name= BatchInteract)
 *  argument 1 => pop up Batch
 * 	     2 => pop up interact
/*----------------------------------------------*/
  void BatchInteract(which)
  int which ;
  {

  char label_batch[200] , label_interact[200] ;
  int my_argument ;

/* BTN1UP = DEFAULT + RESET otherwise does not unhighlight */
/* Declaration of the translation table for init */
  static String menu_trans = "<Btn1Up>: notify() unset() reset()" ;
  XtTranslations menu_compiled ;

  strcpy(label_batch ,"  Test Batch   " ) ;
  strcpy(label_interact , " Test Interactive " ) ;

 XtSetArg(batchinteract_arg[0],XtNfromVert, patset) ;
 XtSetArg(batchinteract_arg[1],XtNfromHoriz,pgmtarget ) ;
 XtSetArg(batchinteract_arg[2],XtNlabel, label_batch) ;

/* Undisplay the one on the screen  */
/* and display the new one */

 if(batchinteract)
  {
  XtUnrealizeWidget(batchinteract) ;
   if (which == 1 )
/* pop up batch */
	{
        XtSetArg(batchinteract_arg[2],XtNlabel, label_batch) ;
	my_argument = 1 ;
        XtManageChild(batchinteract) ;
        XtRealizeWidget(simulation) ;
        }
   else
/* pop up interactive */
	{
        XtSetArg(batchinteract_arg[2],XtNlabel, label_interact) ;
	my_argument = 2 ;
        XtManageChild(batchinteract) ;
        XtRealizeWidget(simulation) ;
        } ;
   }
/* none has been created  */
  else
   {
        batchinteract = XtCreateManagedWidget("",
                                commandWidgetClass,
                                simulation,
                                batchinteract_arg,
                                XtNumber(batchinteract_arg));
/* Compilation of the translation table for IO */
  menu_compiled = XtParseTranslationTable(menu_trans) ;
  XtOverrideTranslations(batchinteract, menu_compiled) ;
/* "Compile" the call back */
my_argument = 1 ;
XtAddCallback(batchinteract, XtNcallback,
        Batch_callback,(caddr_t)my_argument) ;

   } ;

} 
