Computer Science 2574
Intro to Data Structures & Soft Eng

/*
-Module Name:  		ODB.c
-Header File:    	odb.h
-Implementation File 	odb.cpp
-
-This is the main file for the program.  It's main job is to
-handle calls from the GeoSim graphical interface.  These functions 
-call functions in the other modules to handle the file i/o, 
-list management, etc.
-
-
-
-
-Called by :  GeoSim.h
-
-Author:  Jon Ford
-Version: 1.0
-Revised: 3/26/96
*/



#include "odb.h"
#include
#include
#include
#include"string.h"
#include"geosim.h"
#include"odbread.h"
#include"odbwrite.h"
#include"dlist.h"


/* the following defines are for windows and fields in the GUI*/

#define NAME "Opscan Database Grader"
#define IFILE "odbint.inf"
#define BSTORE 0
#define MAIN_WIND "MainWindow"
#define INPUT_WIND "InputWindow"
#define ABOUT_WIND "AboutWindow"
#define HELP_WIND "HelpWindow"
#define FILE_WIND "FileWindow"
#define TYPE_WIND "FileTypeWindow"
#define QUIT_WIND "QuitWindow"
#define SAVE_WIND "SaveFirstWindow"
#define DEL_WIND "DelStudWindow"
#define PROC_WIND "ProcessWindow"
#define FILE_FLD "FileField"
#define INPUT_FLD "InputField"
#define ITEM_FLD "InputItem"
#define STUD_FLD "StudField"
#define AVE_FLD "AveField"
#define DEV_FLD "DevField"
#define QUEST_FLD "QuestField"
#define DATE_FLD "DateField"
#define DESC_FLD "DescField"
#define LIST_FLD "ListField"
#define FILENAME_FLD "FileNameField"
#define DELNAME_FLD "DelStudName"
#define DELSSN_FLD "DelStudSSN"

#define INPUTOK_BTN "InputOK"
#define INPUTCANCEL_BTN "InputCancel"
#define ABOUTOK_BTN "AboutOK"
#define HELPOK_BTN "HelpOK"
#define FILEOK_BTN "FileOKButton"
#define FILECANCEL_BTN "FileCancelButton"
#define QUITOK_BTN "QuitOK"
#define QUITCANCEL_BTN "QuitCancel"
#define SAVEFILE_BTN "SaveFileButton"
#define DUMPFILE_BTN "DumpFileButton"
#define DELSTUDOK_BTN "DelOK"
#define DELSTUDCANCEL_BTN "DelStudCancel"
#define OPENOP_BTN "OpenOP"
#define OPENODB_BTN "OpenODB"

/*defines for the 'popup' menus in the GUI*/

#define FILE_MENU "FilePopUp"
#define EDIT_MENU "EditPopUp"
#define STUD_MENU "StudPopUp"
#define TEST_MENU "TestPopUp"
#define HELP_MENU "HelpPopUp"


/*defines for the pick list */

#define LIST_DA "ListDragArea"
#define SCROLL_DA "ScrollDragArea"
#define LIST_UP_BTN "UpButton"
#define LIST_DOWN_BTN "DownButton"



/*defines for handling text */

#define CHAR_FUNC "char_func"


/*misc. defines for operations in the code*/

#define TEST_FILE "TestFile"
#define FILE_SAVE "FileSave"
#define ODB_FILE "ODBFile"
#define SSN_EDIT "SSN"
#define NAME_EDIT "Name"
#define CORRECT_EDIT "Correct"
#define GROUP_EDIT "Group"
#define FORM_EDIT "Form"
#define OMIT_EDIT "Omitted"
#define SEAT_EDIT "Seat"
#define INSERT "Insert"
#define DELETE "Delete"
#define QUESTIONS "Questions"
#define DESCRIPTION "Description"
#define DESC_EDIT "DescEdit"
#define DATE "Date"
#define NONE "None"
#define EMPTY ""
#define NOFILE 2
#define OPFILE 0
#define ODBFILE 1

#define MAX_EDIT_LEN 80
#define NUM_COLUMNS 1
#define NOITEM -1


/*
Function Prototypes - see function code for detailed description
of function operation
*/

bool redraw_func();
bool char_func(int, int, char);
bool null_func();
void initialize();
bool OpenTest();
bool OpenODB();
bool OpenGen();
bool SaveFile();
bool SaveFileAs();
bool CloseFile();
bool Break();
bool Quit();
bool EditSSN();
bool EditName();
bool EditCorrNum();
bool EditGroup();
bool EditForm();
bool EditOmit();
bool EditSeat();
bool StudInsert();
bool StudDelete();
bool TestQuestNum();
bool TestDesc();
bool TestDate();
bool TestEval();
bool HelpAbout();
bool HelpHelp();
bool InputOK();
bool InputCancel();
bool AboutOK();
bool ShowFilePopUp();
bool ShowEditPopUp();
bool ShowStudPopUp();
bool ShowTestPopUp();
bool ShowHelpPopUp();
bool HelpOK();
bool FileOK();
bool FileCancel();
bool QuitOK();
bool QuitCancel();
bool DumpFileButton();
bool SaveFileConfirm();
bool StudDeleteOK();
bool StudDeleteCancel();
void DisplayEdit();
void EnableEdit();
void EnableSave();
void DisableSave();
void DisableEdit();
void Stats();



/*these functions handle specific GIL tasks*/

char *label_func(int slot);
void text_func(GSlistHandle list, int slot);
void in_func(int slot){}
void out_func(){}
void click_func(int slot);
bool ListDrag(int x, int y, DragStatusType status);
bool ScrollDrag(int x, int y, DragStatusType status);
bool UpButton();
bool DownButton();



/* 
Globals - only because the example code was this way
I don't prefer this but just learning GIL this is ok for 
first project.  Also, they are only global to this module.
*/


GSlistHandle list_handle;
GSsclistHandle sclist_handle;



/*-----------------------------------------------------------
-Funciton Name:      		Main
-Description:	
-this function initializes the interface for GIL and initializes
-the variables in the program.  It then starts the GIL message
-loop by calling GSinterface.
-
-
-Calls:     	GSinterfaceinit
-		initialize
-		GSinterface     
-
-Author:      	Jon Ford -  
-Revision:	3/26/96
-Version:     	1.0
--------------------------------------------------------------*/

void main(int argc, char *argv[])
{
	GSinterfaceinit(NAME, IFILE, BSTORE, "wc", G640x480x256, argc, argv);
	initialize();
	GSinterface();
}



/*-----------------------------------------------------------
-Funciton Name:      		redraw_func
-Description:
-this function redraws the main window and all the elements
-on the main window such as buttons, etc.
-
-
-Called by:     	GIL
-		misc other functions
-
-Calls:		GetList
-		Many GIL functions
-
-Author:      	Jon Ford -  
-Revision:	3/26/96
-Version:     	1.0
------------------------------------------------------5@@@@ine(x,y+ht,x+wd,y+ht);
		GSdrawsclist(sclist_handle);	      
	}
	GSsetcurrentnamedwindow(MAIN_WIND);
	
	return TRUE;
}


/*-----------------------------------------------------------
-Funciton Name:      null_func
-
-Description:
-
-does nothing - needed by GIL
-
-
-Called by:          GIL
-
-Author:      	Jon Ford -  
-Revision:	3/26/96
-Version:     	1.0
--------------------------------------------------------------*/

bool null_func()
{
	return TRUE;
}


/*-----------------------------------------------------------
-Funciton Name:      	initialize
-Description:
-
-this function displays the 'splash' screen at start up and 
-initializes the list and sets all of the variables with their
-starting values. It also sets up the pick list with GIL.
-
-
-Called by:         main 
-
-Calls:		GetList
-		GIL functions   
-
-Author:      	Jon Ford -  
-Revision:	3/26/96
-Version:     	1.0
--------------------------------------------------------------*/

void initialize()
{
	ListMgr listmgr;
	int x,y,wd,ht;	

	listmgr = GetList(NEW_LIST);
	strcpy(listmgr->title.currentedit,EMPTY);
	listmgr->title.filetype=NOFILE;

	/*Let's disable all of the dialog box buttons since GIL can't
	  take care of them like it is supposed to*/

	listmgr->title.students=0; /*initialize the number of students*/

	
	GScharfunc(CHAR_FUNC);

		GSsclistsetup(MAIN_WIND,
			      LIST_DA,
			      NUM_COLUMNS,
			      LIST_FLD,
			      0,0,
			      JUST_LEFT,
			      label_func,
			      text_func,
			      in_func,
			      out_func,
			      click_func,
			      SCROLL_DA,
			      GSconvertcolor("sclistcol"),
			      GSconvertcolor("sclistt1"),
			      GSconvertcolor("sclistbr"),
			      0,0,  /*start with one item, we'll change later*/
			      NULL,
			      LIST_UP_BTN,LIST_DOWN_BTN,
			      &list_handle, &sclist_handle);
		
		GSgetdragareaspecs(MAIN_WIND,LIST_DA, &x,&y,&wd,&ht,NULL,NULL);
		GSsetcurrentnamedwindow(MAIN_WIND);

		GSsetcolor(GSconvertcolor("black"));
		GSwdrawline(x-1,y-1,x-1,y+ht-1);
		GSwdrawline(x-1,y-1,x+wd-1,y-1);
		GSsetcolor(GSconvertcolor("dgray"));
		GSwdrawline(x+wd,y,x+wd,y+ht);
		GSwdrawline(x,y+ht,x+wd,y+ht);
		GSdrawsclist(sclist_handle);	      


	redraw_func();
	
	GSdrawnamedwindow(ABOUT_WIND, BSTORE, POPUP);
	GSinvisiblebutton(ABOUT_WIND, "AboutOK", DRAW);
	GSdelay(30);
	GSvisiblebutton(ABOUT_WIND, "AboutOK", DRAW);
	GSremovenamedwindow(ABOUT_WIND);


	/*Let's disable all of the dialog box buttons since GIL can't
	  take care of them like it is supposed to*/
	
	GSdisablebutton(INPUT_WIND,INPUTOK_BTN,NO_DRAW);
	GSdisablebutton(INPUT_WIND,INPUTCANCEL_BTN,NO_DRAW);
	GSdisablebutton(ABOUT_WIND,ABOUTOK_BTN,NO_DRAW);
	GSdisablebutton(HELP_WIND,HELPOK_BTN,NO_DRAW);
	GSdisablebutton(FILE_WIND,FILEOK_BTN,NO_DRAW);
	GSdisablebutton(FILE_WIND,FILECANCEL_BTN,NO_DRAW);
	GSdisablebutton(QUIT_WIND,QUITOK_BTN,NO_DRAW);
	GSdisablebutton(QUIT_WIND,QUITCANCEL_BTN,NO_DRAW);
	GSdisablebutton(SAVE_WIND,SAVEFILE_BTN,NO_DRAW);
	GSdisablebutton(SAVE_WIND,DUMPFILE_BTN,NO_DRAW);
	GSdisablebutton(DEL_WIND,DELSTUDOK_BTN,NO_DRAW);
	GSdisablebutton(DEL_WIND,DELSTUDCANCEL_BTN,NO_DRAW);
	GSdisablebutton(TYPE_WIND,OPENOP_BTN,NO_DRAW);
	GSdisablebutton(TYPE_WIND,OPENODB_BTN,NO_DRAW);
	redraw_func();	
}


/*-----------------------------------------------------------
-Funciton Name:      	OpenGen
-
-Description:
-
-this is a call back function for GIL to call for selection of
-the 'open...' menu item in the file menu.  It displays a dialog
-box 'TYPE_WIND' to allow the user to choose whether to open a
-opscan or and odb file.
-
-
-Called by:       GIL
-
-Calls:		GSdrawnamedwindow 
-   
-
-Author:      	Jon Ford -  
-Revision:	3/26/96
-Version:     	1.0
--------------------------------------------------------------*/

bool OpenGen()
{
	GSdrawnamedwindow(TYPE_WIND, BSTORE, POPUP);
	GSenablebutton(TYPE_WIND,OPENOP_BTN,DRAW);
	GSenablebutton(TYPE_WIND,OPENODB_BTN,DRAW);

	return TRUE;
}



/*-----------------------------------------------------------
-Funciton Name:      OpenTest
-
-Description:
-
-this function sets the appropriate variables and displays
-a dialog box allowing the user to enter the filename for a 
-opscan file
-
-
-Called by:      GIL
-
-Calls:		GetList
-		GIL 
-
-Author:      	Jon Ford -  
-Revision:	3/26/96
-Version:     	1.0
--------------------------------------------------------------*/

bool OpenTest()
{
	ListMgr listmgr;

	GSdisablebutton(TYPE_WIND,OPENOP_BTN,NO_DRAW);
	GSdisablebutton(TYPE_WIND,OPENODB_BTN,NO_DRAW);

	GSremovenamedwindow(TYPE_WIND);
	
	listmgr = GetList(CURR_LIST);
	strcpy (listmgr->title.currentedit, TEST_FILE);
	strcpy (listmgr->title.editvalue,EMPTY);
	listmgr->title.edit_len = strlen(listmgr->title.editvalue);
	listmgr->title.ins_point = listmgr->title.edit_len;
	listmgr->title.filetype=OPFILE; /*opscan file*/



	GSdrawnamedwindow(FILE_WIND, BSTORE, POPUP);
	GSenablebutton(FILE_WIND,FILEOK_BTN,DRAW);
	GSenablebutton(FILE_WIND,FILECANCEL_BTN,DRAW);


	DisplayEdit();	
		

	return TRUE;
}


/*-----------------------------------------------------------
-Funciton Name:      OpenODB
-
-Description:
-
-this function sets the appropriate variables and displays
-a dialog box allowing the user to enter the filename for a 
-ODB file
-
-
-Called by:      GIL
-
-Calls:		GetList
-		GIL 
-
-Author:      	Jon Ford -  
-Revision:	3/26/96
-Version:     	1.0
--------------------------------------------------------------*/

bool OpenODB()
{
	ListMgr listmgr;

	GSdisablebutton(TYPE_WIND,OPENOP_BTN,NO_DRAW);
	GSdisablebutton(TYPE_WIND,OPENODB_BTN,NO_DRAW);

	GSremovenamedwindow(TYPE_WIND);
	
	listmgr = GetList(CURR_LIST);
	strcpy (listmgr->title.currentedit, TEST_FILE);
	strcpy (listmgr->title.editvalue,EMPTY);
	listmgr->title.edit_len = strlen(listmgr->title.editvalue);
	listmgr->title.ins_point = listmgr->title.edit_len;
	listmgr->title.filetype=ODBFILE; /*odb file*/
	listmgr->title.savestatus=FALSE; /*doesn't need to be saved*/

	GSdrawnamedwindow(FILE_WIND, BSTORE, POPUP);
	GSenablebutton(FILE_WIND,FILEOK_BTN,DRAW);
	GSenablebutton(FILE_WIND,FILECANCEL_BTN,DRAW);


	DisplayEdit();	
		



	return TRUE;
}


/*-----------------------------------------------------------
-Funciton Name:		SaveFile
-
-Description:
-this function is called by gil as a response to selecting the
-'save' item on the file menu.  if the current open file is
-only a raw opscan file, the SaveAs function is called allowing
-the user to enter an ODB filename to save as.  If the file
-is already an ODB file, the file is saved. 
-
-
-
-Called by:          GIL
-
-Calls:		GetList
-		SaveFileAs
-		WriteODBFile
-
-
-Author:      	Jon Ford -  
-Revision:	3/26/96
-Version:     	1.0
--------------------------------------------------------------*/

bool SaveFile()
{
	ListMgr listmgr;
	GSremovenamedwindow(SAVE_WIND);
	redraw_func();
	Stats();	
	listmgr = GetList(CURR_LIST);

	if (listmgr->title.filetype==0)
	{
		SaveFileAs();
	}
	else
	{
		if(listmgr->title.savestatus==TRUE)
		{
			WriteODBFile(listmgr);
			listmgr->title.savestatus=FALSE;
		}
	}
	return TRUE;
}


/*-----------------------------------------------------------
-Funciton Name:		SaveFileAs
-
-Description:
-This funciton sets the appropriate variables and displays
-a dialog box which allows the user to enter a filename for
-saving the file as an ODB file.
-
-
-Called by:	GIL
-		SaveFile
-  
-Calls:		GetList
-		GIL functions
-		DisplayEdit
-
-Author:      	Jon Ford -  
-Revision:	3/26/96
-Version:     	1.0
--------------------------------------------------------------*/

bool SaveFileAs()
{

	ListMgr listmgr;
	
	listmgr = GetList(CURR_LIST);

	strcpy (listmgr->title.currentedit, FILE_SAVE);
	strcpy (listmgr->title.editvalue,listmgr->title.opfilename);
	listmgr->title.edit_len = strlen(listmgr->title.editvalue);
	listmgr->title.ins_point = listmgr->title.edit_len;
	

	GSdrawnamedwindow(FILE_WIND, BSTORE, POPUP);
	GSenablebutton(FILE_WIND,FILEOK_BTN,DRAW);
	GSenablebutton(FILE_WIND,FILECANCEL_BTN,DRAW);


	DisplayEdit();	
		

	return TRUE;
}


/*-----------------------------------------------------------
-Funciton Name:		Close File
-
-Description:
-This file is called in response to a user selecting 'close'
-from the file menu.  If the file does not have any unsaved
-changes, the file is closed and the list is emptied and 
-all variables reset.  It the file has unsaved changes, the
-user is prompted to allow them to save the file first.
-
-
-
-Called by:	GIL
-
-Calls:		GIL
-		GetList
-		redraw_func
-		DisableSave
-		distroyList 
-
-Author:      	Jon Ford -  
-Revision:	3/26/96
-Version:     	1.0
--------------------------------------------------------------*/

bool CloseFile()
{
	
	ListMgr listmgr;
	listmgr = GetList(CURR_LIST);
	
	if (listmgr->title.savestatus==TRUE)
	{
		GSdrawnamedwindow(SAVE_WIND, BSTORE, POPUP);
		GSenablebutton(SAVE_WIND,SAVEFILE_BTN,DRAW);
		GSenablebutton(SAVE_WIND,DUMPFILE_BTN,DRAW);
	}

	else
	{		
		listmgr->title.students=0;

		strcpy(listmgr->title.opfilename,NONE);

		GSsetsclistnumitems(sclist_handle, listmgr->title.students,TRUE);
		listmgr->title.filetype=2;
		DestroyList(listmgr);
		DisableSave();
		redraw_func();
	}

	return TRUE;
}


/*-----------------------------------------------------------
-Funciton Name:      break
-Description:
-this is here to handle the event that someone tries to select
-one of the breaks on the menus.
-
-Called by:    	GIL  
-       
-Author:      	Jon Ford -  
-Revision:	3/26/96
-Version:     	1.0
--------------------------------------------------------------*/

bool Break()
{
	return TRUE;
}


/*-----------------------------------------------------------
-Funciton Name:		Quit
-
-Description:
-this function is called in response to a user chosing 'quit'
-from the file menu.  This function displays a dialog box 
-which allows the user to confirm or cancel quitting the 
-program.
-
-
-Called by:   	GIL
-
-Calls:		GSdrawnamedwindow        
-
-Author:      	Jon Ford -  
-Revision:	3/26/96
-Version:     	1.0
--------------------------------------------------------------*/

bool Quit()
{
	GSdrawnamedwindow(QUIT_WIND, BSTORE, POPUP);
	GSenablebutton(QUIT_WIND,QUITOK_BTN,DRAW);
	GSenablebutton(QUIT_WIND,QUITCANCEL_BTN,DRAW);


	return TRUE;
}



/*-----------------------------------------------------------
-Funciton Name:		EditSSN
-  
-Description:
-
-This function is called in response to a user selecting the 
-SSN option on the Edit menu.  The function gets the currently
-selected student info from the linked list and displays the 
-dialog box allowing the user to change the current value.
-
-Called by:	GIL
-
-Calls:		GetList
-		ReturnElement
-		GIL functions
-
-Author:      	Jon Ford -  
-Revision:	3/26/96
-Version:     	1.0
--------------------------------------------------------------*/

bool EditSSN()
{
	ListMgr listmgr;
	ElemPtr element;
	char temp[80];	
	int x, y, wd, ht;
	GSColor col;

	listmgr = GetList(CURR_LIST);

	element = ReturnElement(listmgr,listmgr->title.currlistitem);
	strcpy (listmgr->title.currentedit, SSN_EDIT);
	strcpy (listmgr->title.editvalue,element->item.SSN);
	listmgr->title.edit_len = strlen(listmgr->title.editvalue);
	listmgr->title.ins_point = listmgr->title.edit_len;


	GSdrawnamedwindow(INPUT_WIND, BSTORE, POPUP);

	GSenablebutton(INPUT_WIND,INPUTOK_BTN,DRAW);
	GSenablebutton(INPUT_WIND,INPUTCANCEL_BTN,DRAW);

	/*display the input item name*/

	GSgetfieldrect(ITEM_FLD,&x,&y,&wd,&ht,&col);
	
	GSsetcolor(col);	
	GSwfillrect(x, y, wd, ht);
	/*	GSframefield(INPUT_WIND, ITEM_FLD, 
		GSconvertcolor("black"), GSconvertcolor("dgray"));*/

	GSsetcolor(GSconvertcolor("black"));
		
	sprintf(temp,"%s","SSN Edit Window");
	GSwwritemsg(x+1, y+SMALL+1, temp);


	DisplayEdit();	
		


	return TRUE;
}



/*-----------------------------------------------------------
-Funciton Name:		EditName
-  
-Description:
-
-This function is called in response to a user selecting the 
-Name option on the Edit menu.  The function gets the currently
-selected student info from the linked list and displays the 
-dialog box allowing the user to change the current value.
-
-Called by:	GIL
-
-Calls:		GetList
-		ReturnElement
-		GIL functions
-
-Author:      	Jon Ford -  
-Revision:	3/26/96
-Version:     	1.0
--------------------------------------------------------------*/

bool EditName()
{
	ListMgr listmgr;
	ElemPtr element;
	char temp[80];
	int x, y, wd, ht;
	GSColor col;
	
	listmgr = GetList(CURR_LIST);
	element = ReturnElement(listmgr,listmgr->title.currlistitem);

	sprintf(temp,"%s%s%s",element->item.lastname,element->item.initial1,
		element->item.initial2);

	strcpy (listmgr->title.currentedit, NAME_EDIT);
	strcpy (listmgr->title.editvalue,temp);
	listmgr->title.edit_len = strlen(listmgr->title.editvalue);
	listmgr->title.ins_point = listmgr->title.edit_len;


	GSdrawnamedwindow(INPUT_WIND, BSTORE, POPUP);
	GSenablebutton(INPUT_WIND,INPUTOK_BTN,DRAW);
	GSenablebutton(INPUT_WIND,INPUTCANCEL_BTN,DRAW);

	/*display the input item name*/

	GSgetfieldrect(ITEM_FLD,&x,&y,&wd,&ht,&col);
	
	GSsetcolor(col);	
	GSwfillrect(x, y, wd, ht);
	/*	GSframefield(INPUT_WIND, ITEM_FLD, 
		GSconvertcolor("black"), GSconvertcolor("dgray"));*/

	GSsetcolor(GSconvertcolor("black"));
		
	sprintf(temp,"%s","Name Edit Window");
	GSwwritemsg(x+1, y+SMALL+1, temp);


	DisplayEdit();	


	return TRUE;
}


/*-----------------------------------------------------------
-Funciton Name:		EditCorrNum
-  
-Description:
-
-This function is called in response to a user selecting the 
-Correct # option on the Edit menu.  The function gets the currently
-selected student info from the linked list and displays the 
-dialog box allowing the user to change the current value.
-
-Called by:	GIL
-
-Calls:		GetList
-		ReturnElement
-		GIL functions
-
-Author:      	Jon Ford -  
-Revision:	3/26/96
-Version:     	1.0
--------------------------------------------------------------*/
bool EditCorrNum()
{
	GSColor col;

	ListMgr listmgr;
	ElemPtr element;
	char temp[80];
	int x, y, wd, ht;

	char number[10];
	
	listmgr = GetList(CURR_LIST);
	element = ReturnElement(listmgr,listmgr->title.currlistitem);
	
	sprintf(number,"%d",element->item.correctcount);
	
	strcpy (listmgr->title.currentedit, CORRECT_EDIT);
	strcpy (listmgr->title.editvalue,number);
	listmgr->title.edit_len = strlen(listmgr->title.editvalue);
	listmgr->title.ins_point = listmgr->title.edit_len;


	GSdrawnamedwindow(INPUT_WIND, BSTORE, POPUP);
	GSenablebutton(INPUT_WIND,INPUTOK_BTN,DRAW);
	GSenablebutton(INPUT_WIND,INPUTCANCEL_BTN,DRAW);

	/*display the input item name*/

	GSgetfieldrect(ITEM_FLD,&x,&y,&wd,&ht,&col);
	
	GSsetcolor(col);	
	GSwfillrect(x, y, wd, ht);
	/*GSframefield(INPUT_WIND, ITEM_FLD, 
		GSconvertcolor("black"), GSconvertcolor("dgray"));*/

	GSsetcolor(GSconvertcolor("black"));
		
	sprintf(temp,"%s","Correct number edit window");
	GSwwritemsg(x+1, y+SMALL+1, temp);


	DisplayEdit();	


	return TRUE;
}



/*-----------------------------------------------------------
-Funciton Name:		EditGroup
-  
-Description:
-
-This function is called in response to a user selecting the 
-Group option on the Edit menu.  The function gets the currently
-selected student info from the linked list and displays the 
-dialog box allowing the user to change the current value.
-
-Called by:	GIL
-
-Calls:		GetList
-		ReturnElement
-		GIL functions
-
-Author:      	Jon Ford -  
-Revision:	3/26/96
-Version:     	1.0
--------------------------------------------------------------*/
bool EditGroup()
{

	ListMgr listmgr;
	ElemPtr element;
	int x, y, wd, ht;
	GSColor col;
	char temp[80];
	
	listmgr = GetList(CURR_LIST);

	element = ReturnElement(listmgr,listmgr->title.currlistitem);
	strcpy (listmgr->title.currentedit, GROUP_EDIT);
	strcpy (listmgr->title.editvalue,element->item.group);
	listmgr->title.edit_len = strlen(listmgr->title.editvalue);
	listmgr->title.ins_point = listmgr->title.edit_len;


	GSdrawnamedwindow(INPUT_WIND, BSTORE, POPUP);
	GSenablebutton(INPUT_WIND,INPUTOK_BTN,DRAW);
	GSenablebutton(INPUT_WIND,INPUTCANCEL_BTN,DRAW);

	/*display the input item name*/

	GSgetfieldrect(ITEM_FLD,&x,&y,&wd,&ht,&col);
	
	GSsetcolor(col);	
	GSwfillrect(x, y, wd, ht);
	/*GSframefield(INPUT_WIND, ITEM_FLD, 
		GSconvertcolor("black"), GSconvertcolor("dgray"));*/

	GSsetcolor(GSconvertcolor("black"));
		
	sprintf(temp,"%s","Group Edit Window");
	GSwwritemsg(x+1, y+SMALL+1, temp);


	DisplayEdit();	


	return TRUE;
}


/*-----------------------------------------------------------
-Funciton Name:		EditForm
-  
-Description:
-
-This function is called in response to a user selecting the 
-Form option on the Edit menu.  The function gets the currently
-selected student info from the linked list and displays the 
-dialog box allowing the user to change the current value.
-
-Called by:	GIL
-
-Calls:		GetList
-		ReturnElement
-		GIL functions
-
-Author:      	Jon Ford -  
-Revision:	3/26/96
-Version:     	1.0
--------------------------------------------------------------*/
bool EditForm()
{

	ListMgr listmgr;
	ElemPtr element;
	char temp[80];	
	int x, y, wd, ht;
	GSColor col;

	listmgr = GetList(CURR_LIST);

	element = ReturnElement(listmgr,listmgr->title.currlistitem);
	strcpy (listmgr->title.currentedit, FORM_EDIT);
	strcpy (listmgr->title.editvalue,element->item.form);
	listmgr->title.edit_len = strlen(listmgr->title.editvalue);
	listmgr->title.ins_point = listmgr->title.edit_len;


	GSdrawnamedwindow(INPUT_WIND, BSTORE, POPUP);
	GSenablebutton(INPUT_WIND,INPUTOK_BTN,DRAW);
	GSenablebutton(INPUT_WIND,INPUTCANCEL_BTN,DRAW);

	/*display the input item name*/

	GSgetfieldrect(ITEM_FLD,&x,&y,&wd,&ht,&col);
	
	GSsetcolor(col);	
	GSwfillrect(x, y, wd, ht);
	/*	GSframefield(INPUT_WIND, ITEM_FLD, 
		GSconvertcolor("black"), GSconvertcolor("dgray"));*/

	GSsetcolor(GSconvertcolor("black"));
		
	sprintf(temp,"%s","Form Edit Window");
	GSwwritemsg(x+1, y+SMALL+1, temp);


	DisplayEdit();	


	return TRUE;
}


/*-----------------------------------------------------------
-Funciton Name:		EditOmit
-  
-Description:
-
-This function is called in response to a user selecting the 
-Omitted # option on the Edit menu.  The function gets the currently
-selected student info from the linked list and displays the 
-dialog box allowing the user to change the current value.
-
-Called by:	GIL
-
-Calls:		GetList
-		ReturnElement
-		GIL functions
-
-Author:      	Jon Ford -  
-Revision:	3/26/96
-Version:     	1.0
--------------------------------------------------------------*/
bool EditOmit()
{

	ListMgr listmgr;
	ElemPtr element;
	char temp[80];
	int x, y, wd, ht;
	GSColor col;

	char number[10];
	
	listmgr = GetList(CURR_LIST);
	element = ReturnElement(listmgr,listmgr->title.currlistitem);
	
	sprintf(number,"%d",element->item.omittedcount);
	
	strcpy (listmgr->title.currentedit, OMIT_EDIT);
	strcpy (listmgr->title.editvalue,number);
	listmgr->title.edit_len = strlen(listmgr->title.editvalue);
	listmgr->title.ins_point = listmgr->title.edit_len;


	GSdrawnamedwindow(INPUT_WIND, BSTORE, POPUP);
	GSenablebutton(INPUT_WIND,INPUTOK_BTN,DRAW);
	GSenablebutton(INPUT_WIND,INPUTCANCEL_BTN,DRAW);

	/*display the input item name*/

	GSgetfieldrect(ITEM_FLD,&x,&y,&wd,&ht,&col);
	
	GSsetcolor(col);	
	GSwfillrect(x, y, wd, ht);
	/*GSframefield(INPUT_WIND, ITEM_FLD, 
		GSconvertcolor("black"), GSconvertcolor("dgray"));*/

	GSsetcolor(GSconvertcolor("black"));
		
	sprintf(temp,"%s","Omitted Number Edit Window");
	GSwwritemsg(x+1, y+SMALL+1, temp);


	DisplayEdit();	


	return TRUE;
}


/*-----------------------------------------------------------
-Funciton Name:		EditSeat
-  
-Description:
-
-This function is called in response to a user selecting the 
-Seat option on the Edit menu.  The function gets the currently
-selected student info from the linked list and displays the 
-dialog box allowing the user to change the current value.
-
-Called by:	GIL
-
-Calls:		GetList
-		ReturnElement
-		GIL functions
-
-Author:      	Jon Ford -  
-Revision:	3/26/96
-Version:     	1.0
--------------------------------------------------------------*/
bool EditSeat()
{

	ListMgr listmgr;
	ElemPtr element;
	char temp[80];
	int x, y, wd, ht;
	GSColor col;
	
	listmgr = GetList(CURR_LIST);

	element = ReturnElement(listmgr,listmgr->title.currlistitem);
	strcpy (listmgr->title.currentedit, SEAT_EDIT);
	strcpy (listmgr->title.editvalue,element->item.seatnumber);
	listmgr->title.edit_len = strlen(listmgr->title.editvalue);
	listmgr->title.ins_point = listmgr->title.edit_len;


	GSdrawnamedwindow(INPUT_WIND, BSTORE, POPUP);
	GSenablebutton(INPUT_WIND,INPUTOK_BTN,DRAW);
	GSenablebutton(INPUT_WIND,INPUTCANCEL_BTN,DRAW);

	/*display the input item name*/

	GSgetfieldrect(ITEM_FLD,&x,&y,&wd,&ht,&col);
	
	GSsetcolor(col);	
	GSwfillrect(x, y, wd, ht);
	/*GSframefield(INPUT_WIND, ITEM_FLD, 
		GSconvertcolor("black"), GSconvertcolor("dgray"));*/

	GSsetcolor(GSconvertcolor("black"));
		
	sprintf(temp,"%s","Seat Edit Window");
	GSwwritemsg(x+1, y+SMALL+1, temp);


	DisplayEdit();	


	return TRUE;
}



/*-----------------------------------------------------------
-Funciton Name:		StudInsert
-
-Description:
-This function is called in response to the user selecting
-'insert' from the student menu.  It creates a new student
-with some default values and sets a flag (newstud) to let
-the InputOK function know that it has to get values for all
-of the variables.  The function then displays the Input Dialog
-box to get the information from the user, displaying the default
-information along the way.
-
-
-Called by:	GIL
-
-Calls:		GetList
-		CreateElement
-		EditSSN
-		GIL
-
-
-Author:      	Jon Ford -  
-Revision:	3/26/96
-Version:     	1.0
--------------------------------------------------------------*/
bool StudInsert()
{
	ListMgr listmgr;
	ElemPtr element;

	listmgr = GetList(CURR_LIST);
	element = CreateElement();
	
	strcpy(element->item.SSN,"000000000");
	strcpy(element->item.lastname,"Name ");
	strcpy(element->item.initial1,"A ");
	strcpy(element->item.initial2,"A");
	strcpy(element->item.seatnumber,"1");
	strcpy(element->item.form,"1");
	strcpy(element->item.group,"1");
	element->item.correctcount=0;
	element->item.omittedcount=0;
	element->item.score=0;
	element->item.tscore=0;


	InsertElement(listmgr,element);	

	listmgr->title.students++;

	GSsetsclistnumitems(sclist_handle,listmgr->title.students,TRUE);


	listmgr->title.newstud = 1; /*starts the process of getting info*/

	/*set the current student to the one we just created*/
	listmgr->title.currlistitem=listmgr->title.students-1;

	EditSSN();

	return TRUE;
}


/*-----------------------------------------------------------
-Funciton Name:		StudDelete
-
-Description:
-
-This function is called in response to the user chosing delete
-from the student menu.  It thens displays a dialog box with
-the students name and SSN for the selected student in the list
-asking for confirmation of the delete.
-
-
-Called by:	GIL
-
-Calls:		GetList
-		ReturnElement
-		GIL
-  
-Author:      	Jon Ford -  
-Revision:	3/26/96
-Version:     	1.0
--------------------------------------------------------------*/
bool StudDelete()
{

	ListMgr listmgr;
	ElemPtr element;

	char temp[80];
	int x, y, wd, ht;
	GSColor col;
	
	listmgr = GetList(CURR_LIST);

	element = ReturnElement(listmgr,listmgr->title.currlistitem);

	GSdrawnamedwindow(DEL_WIND, BSTORE, POPUP);
	GSenablebutton(DEL_WIND,DELSTUDOK_BTN,DRAW);
	GSenablebutton(DEL_WIND,DELSTUDCANCEL_BTN,DRAW);

	/*display the input item name and SSN*/

	GSgetfieldrect(DELNAME_FLD,&x,&y,&wd,&ht,&col);
	
	GSsetcolor(col);	
	GSwfillrect(x, y, wd, ht);
	/*GSframefield(DEL_WIND, DELNAME_FLD, 
		GSconvertcolor("black"), GSconvertcolor("dgray"));*/

	GSsetcolor(GSconvertcolor("black"));

	sprintf(temp,"%s, %s %s",element->item.lastname,element->item.initial1,
			  element->item.initial2);
		
	GSwwritemsg(x+1, y+SMALL+1, temp);

	GSgetfieldrect(DELSSN_FLD,&x,&y,&wd,&ht,&col);
	
	GSsetcolor(col);	
	GSwfillrect(x, y, wd, ht);
	/*GSframefield(DEL_WIND, DELSSN_FLD, 
		GSconvertcolor("black"), GSconvertcolor("dgray"));*/

	GSsetcolor(GSconvertcolor("black"));

	sprintf(temp,"%s",element->item.SSN);
		
	GSwwritemsg(x+1, y+SMALL+1, temp);

	return TRUE;
}


/*-----------------------------------------------------------
-Funciton Name:		TestQuestNum
-  
-Description:
-
-This function is called in response to a user selecting the 
-Questions option on the Test menu.  The function gets the 
-info from the list header data structure and displays the 
-dialog box allowing the user to change the current value.
-
-Called by:	GIL
-
-Calls:		GetList
-		GIL functions
-
-Author:      	Jon Ford -  
-Revision:	3/26/96
-Version:     	1.0
--------------------------------------------------------------*/
bool TestQuestNum()
{

	ListMgr listmgr;
	char temp[80];
	int x, y, wd, ht;
	GSColor col;

	char number[10];
	
	listmgr = GetList(CURR_LIST);
	
	sprintf(number,"%d",listmgr->title.questions);
	
	strcpy (listmgr->title.currentedit, QUESTIONS);
	strcpy (listmgr->title.editvalue,number);
	listmgr->title.edit_len = strlen(listmgr->title.editvalue);
	listmgr->title.ins_point = listmgr->title.edit_len;


	GSdrawnamedwindow(INPUT_WIND, BSTORE, POPUP);
	GSenablebutton(INPUT_WIND,INPUTOK_BTN,DRAW);
	GSenablebutton(INPUT_WIND,INPUTCANCEL_BTN,DRAW);

	/*display the input item name*/

	GSgetfieldrect(ITEM_FLD,&x,&y,&wd,&ht,&col);
	
	GSsetcolor(col);	
	GSwfillrect(x, y, wd, ht);
	/*GSframefield(INPUT_WIND, ITEM_FLD, 
		GSconvertcolor("black"), GSconvertcolor("dgray"));*/

	GSsetcolor(GSconvertcolor("black"));
		
	sprintf(temp,"%s","Questions Edit Window");
	GSwwritemsg(x+1, y+SMALL+1, temp);


	DisplayEdit();	


	return TRUE;
}


/*-----------------------------------------------------------
-Funciton Name:		TestDesc
-  
-Description:
-
-This function is called in response to a user selecting the 
-Description option on the Test menu.  The function gets the 
-info from the list header data structure and displays the 
-dialog box allowing the user to change the current value.
-
-Called by:	GIL
-
-Calls:		GetList
-		GIL functions
-
-Author:      	Jon Ford -  
-Revision:	3/26/96
-Version:     	1.0
--------------------------------------------------------------*/
bool TestDesc()
{

	ListMgr listmgr;
	char temp[80];
	int x, y, wd, ht;
	GSColor col;
	
	listmgr = GetList(CURR_LIST);

	strcpy (listmgr->title.currentedit,DESC_EDIT);
	strcpy (listmgr->title.editvalue,listmgr->title.desc);
	listmgr->title.edit_len = strlen(listmgr->title.editvalue);
	listmgr->title.ins_point = listmgr->title.edit_len;


	GSdrawnamedwindow(INPUT_WIND, BSTORE, POPUP);
	GSenablebutton(INPUT_WIND,INPUTOK_BTN,DRAW);
	GSenablebutton(INPUT_WIND,INPUTCANCEL_BTN,DRAW);

	/*display the input item name*/

	GSgetfieldrect(ITEM_FLD,&x,&y,&wd,&ht,&col);
	
	GSsetcolor(col);	
	GSwfillrect(x, y, wd, ht);
	/*GSframefield(INPUT_WIND, ITEM_FLD, 
		GSconvertcolor("black"), GSconvertcolor("dgray"));*/

	GSsetcolor(GSconvertcolor("black"));
		
	sprintf(temp,"%s","Description Edit Window");
	GSwwritemsg(x+1, y+SMALL+1, temp);


	DisplayEdit();	


	return TRUE;
}


/*-----------------------------------------------------------
-Funciton Name:		TestDate
-  
-Description:
-
-This function is called in response to a user selecting the 
-Date option on the Test menu.  The function gets the 
-info from the list header data structure and displays the 
-dialog box allowing the user to change the current value.
-
-Called by:	GIL
-
-Calls:		GetList
-		GIL functions
-
-Author:      	Jon Ford -  
-Revision:	3/26/96
-Version:     	1.0
--------------------------------------------------------------*/
bool TestDate()
{

	ListMgr listmgr;
	char temp[80];
	int x, y, wd, ht;
	GSColor col;
	
	listmgr = GetList(CURR_LIST);

	strcpy (listmgr->title.currentedit, DATE);
	strcpy (listmgr->title.editvalue,listmgr->title.date);
	listmgr->title.edit_len = strlen(listmgr->title.editvalue);
	listmgr->title.ins_point = listmgr->title.edit_len;


	GSdrawnamedwindow(INPUT_WIND, BSTORE, POPUP);
	GSenablebutton(INPUT_WIND,INPUTOK_BTN,DRAW);
	GSenablebutton(INPUT_WIND,INPUTCANCEL_BTN,DRAW);

	/*display the input item name*/

	GSgetfieldrect(ITEM_FLD,&x,&y,&wd,&ht,&col);
	
	GSsetcolor(col);	
	GSwfillrect(x, y, wd, ht);
	/*GSframefield(INPUT_WIND, ITEM_FLD, 
		GSconvertcolor("black"), GSconvertcolor("dgray"));*/

	GSsetcolor(GSconvertcolor("black"));
		
	sprintf(temp,"%s","Date Edit Window");
	GSwwritemsg(x+1, y+SMALL+1, temp);


	DisplayEdit();	



	return TRUE;
}




/*-----------------------------------------------------------
-Funciton Name:		TestEval
-
-Description:
-this function is called in response to the user selecting
-'evaluate' from the test menu.  It recalculates score and
-tscore for each of the students.
-
-Description of Algorithm:
-first we loop through the list recalculating score and calculating
-standard deviation.  Then we loop through the list again to 
-calculate tscore.
-
-
-Called by:	GIL
-
-Calls:		GetList
-		redraw_func
-		Stats
-		GIL
-
-Author:      	Jon Ford -  
-Revision:	3/26/96
-Version:     	1.0
--------------------------------------------------------------*/
bool TestEval()
{
	ListMgr listmgr;
	float average;
	float sum;
	float stddev;
	ElemPtr current;
	float temp;
	float correct;
	float quest;



	listmgr = GetList(CURR_LIST);



	if (listmgr->title.questions==0) return TRUE;/*can't calculate*/

	/*draw a window to let the user know we are processing*/

	GSdrawnamedwindow(PROC_WIND, BSTORE, POPUP);

	/*make sure the basic information is current*/

	Stats();

	average = ((listmgr->title.total)/(listmgr->title.students));

	quest = listmgr->title.questions;


	current = ReturnFirst(listmgr);

	sum=0;


	/*loop through the list recalculating score and summing squares for
	  stddev*/

	while (current!=NULL)
	{
		correct = current->item.correctcount;
		temp = correct/quest*100;
		current->item.score = temp;
		sum += ((current->item.score - average)*
			(current->item.score - average));
		current=ReturnNext(current);
	}
	
	stddev = sqrt((sum)/(listmgr->title.students));


	current = ReturnFirst(listmgr);

	/*loop through the list again recalculating tscore*/

	while (current!=NULL)
	{

		current->item.tscore=(10*((current->item.score-average)/
				     (stddev)))+50;
		current=ReturnNext(current);
	}

	
	GSremovenamedwindow(PROC_WIND); /*were done calculating*/

	listmgr->title.savestatus=TRUE;

	
	redraw_func();
	Stats();

	
	return TRUE;
}




/*-----------------------------------------------------------
-Funciton Name:		HelpAbout
-
-Description:
-Displays the about dialog box (same as the splash screen at
-startup
-
-
-Called by:	GIL
-
-Author:      	Jon Ford -  
-Revision:	3/26/96
-Version:     	1.0
--------------------------------------------------------------*/
bool HelpAbout()
{
	GSdrawnamedwindow(ABOUT_WIND, BSTORE, POPUP);
	GSenablebutton(ABOUT_WIND,ABOUTOK_BTN,DRAW);
	
	return TRUE;
}




/*-----------------------------------------------------------
-Funciton Name:		HelpHelp
-
-Description:
-This function displays a dialog box with some brief help
-information in it.
-
-
-Called by:	GIL    
-
-Author:      	Jon Ford -  
-Revision:	3/26/96
-Version:     	1.0
--------------------------------------------------------------*/
bool HelpHelp()
{
	GSdrawnamedwindow(HELP_WIND, BSTORE, POPUP);
	GSenablebutton(HELP_WIND,HELPOK_BTN,DRAW);

	return TRUE;
}




/*-----------------------------------------------------------
-Funciton Name:		InputOK
-
-Description:
-This function processes all of the input from the input 
-dialog box.  This includes all of the student information,
-test information, etc.
-
-
-Called by:	GIL
-
-Calls:		GetList
-		ReturnElement
-		redraw_func
-		Stats
-
-Author:      	Jon Ford -  
-Revision:	3/26/96
-Version:     	1.0
--------------------------------------------------------------*/

bool InputOK()
{

	ListMgr listmgr;
	ElemPtr element;

	char temp[80];
	
	listmgr = GetList(CURR_LIST);     /*get the current list*/

	/*get a pointer to the current element being edited*/

	element = ReturnElement(listmgr,listmgr->title.currlistitem);



	/*the following group of if statements let the function know
	how to handle the information in the edit value string.
	this determination is set by other functions when they display
	the input dailog box in the currentedit variable.*/

	if (strcmp(listmgr->title.currentedit,SSN_EDIT)==0)
	{
		strcpy(element->item.SSN,listmgr->title.editvalue);
	}

	if (strcmp(listmgr->title.currentedit,NAME_EDIT)==0)
	{
		sscanf(listmgr->title.editvalue,"%s%s%s",
			element->item.lastname,
			element->item.initial1,
			element->item.initial2);
	}

	if (strcmp(listmgr->title.currentedit,CORRECT_EDIT)==0)
	{
		element->item.correctcount=atoi(listmgr->title.editvalue);
	}

	if (strcmp(listmgr->title.currentedit,GROUP_EDIT)==0)
	{
		strcpy(element->item.group,listmgr->title.editvalue);
	}

	if (strcmp(listmgr->title.currentedit,FORM_EDIT)==0)
	{
		strcpy(element->item.form,listmgr->title.editvalue);
	}

	if (strcmp(listmgr->title.currentedit,OMIT_EDIT)==0)
	{
		element->item.omittedcount=atoi(listmgr->title.editvalue);
	}

	if (strcmp(listmgr->title.currentedit,SEAT_EDIT)==0)
	{
		strcpy(element->item.seatnumber,listmgr->title.editvalue);
	}

	if (strcmp(listmgr->title.currentedit,QUESTIONS)==0)
	{
		listmgr->title.questions=atoi(listmgr->title.editvalue);
	}

	if (strcmp(listmgr->title.currentedit,DESC_EDIT)==0)
	{
		strcpy(listmgr->title.desc,listmgr->title.editvalue);
	}

	if (strcmp(listmgr->title.currentedit,DATE)==0)
	{
		strcpy(listmgr->title.date,listmgr->title.editvalue);
	}

	strcpy(listmgr->title.currentedit,EMPTY);

	listmgr->title.savestatus=TRUE;

	GSdisablebutton(INPUT_WIND,INPUTOK_BTN,NO_DRAW);
	GSdisablebutton(INPUT_WIND,INPUTCANCEL_BTN,NO_DRAW);


	GSremovenamedwindow(INPUT_WIND); /* we have the info, remove window*/

	redraw_func();	/*redraw main window*/
	Stats();	/*recalculate stats and display*/


	/*the following switch statement handles the addition of a new
	student to the list.  listmgr->title.newstud is set to one by
	the insert function.  The user enters the SSN in the first 
	input dialog box and the each of the subsequent variables as
	we increment newstud.*/

	switch (listmgr->title.newstud)
	{

		case 1:
				
			EditName();
			listmgr->title.newstud++;
			break;

		case 2:
		
			EditCorrNum();
			listmgr->title.newstud++;
			break;

		case 3:
		
			EditGroup();
			listmgr->title.newstud++;
			break;
	
		case 4:
		
			EditForm();
			listmgr->title.newstud++;
			break;

		case 5:
		
			EditOmit();
			listmgr->title.newstud++;
			break;

		case 6:
		
			EditSeat();
			listmgr->title.newstud++;
			break;

		case 7:

			listmgr->title.newstud=0;
			InsertTail(listmgr);
			break;

		default:

	}

	return TRUE;
}




/*-----------------------------------------------------------
-Funciton Name:		InputCancel
-
-Description:
-This function is called when the user selects the cancel button
-from the input dialog box.  The box is closed and the data is
-ignored.
-
-
-Called by:	GIL 
-
-Author:      	Jon Ford -  
-Revision:	3/26/96
-Version:     	1.0
--------------------------------------------------------------*/
bool InputCancel()
{
	ListMgr listmgr;
	listmgr = GetList(CURR_LIST);


	GSdisablebutton(INPUT_WIND,INPUTOK_BTN,NO_DRAW);
	GSdisablebutton(INPUT_WIND,INPUTCANCEL_BTN,NO_DRAW);
	
	GSremovenamedwindow(INPUT_WIND);
	redraw_func();
	Stats();

	/*the following switch statement handles the addition of a new
	student to the list.  listmgr->title.newstud is set to one by
	the insert function.  The user enters the SSN in the first 
	input dialog box and the each of the subsequent variables as
	we increment newstud.*/

	switch (listmgr->title.newstud)
	{

		case 1:
				
			EditName();
			listmgr->title.newstud++;
			break;

		case 2:
		
			EditCorrNum();
			listmgr->title.newstud++;
			break;

		case 3:
		
			EditGroup();
			listmgr->title.newstud++;
			break;
	
		case 4:
		
			EditForm();
			listmgr->title.newstud++;
			break;
		case 5:
		
			EditOmit();
			listmgr->title.newstud++;
			break;

		case 6:
		
			EditSeat();
			listmgr->title.newstud++;
			break;

		case 7:

			listmgr->title.newstud=0;
			InsertTail(listmgr);
			break;

		default:

	}

	return TRUE;
}



/*-----------------------------------------------------------
-Funciton Name:		AboutOK
-
-Description:
-This function is called when the user selects the OK button
-in the About dialog box.  It closes the box and moves on.  It also
-redraws the main window and recalcuates and displays the stats.
-
-Called by:	GIL
-
-Calls:		GetList
-		redraw_func
-		Stats
-
-Author:      	Jon Ford -  
-Revision:	3/26/96
-Version:     	1.0
--------------------------------------------------------------*/
bool AboutOK()
{
	ListMgr listmgr;
	listmgr = GetList(CURR_LIST);

	GSdisablebutton(ABOUT_WIND,ABOUTOK_BTN,NO_DRAW);

	GSremovenamedwindow(ABOUT_WIND);
	redraw_func();
	if (listmgr->title.students!=0) /*no stats without a file*/
		Stats();
	return TRUE;
}


/*-----------------------------------------------------------
-Funciton Name:		ShowFilePopUp
-Description:
-Displays the Popup window - required by GIL
-
-
-Called by:	GIL 
-
-Author:      	Jon Ford -  
-Revision:	3/26/96
-Version:     	1.0
--------------------------------------------------------------*/
bool ShowFilePopUp()
{
	return TRUE;
}


/*-----------------------------------------------------------
-Funciton Name:		ShowEditPopUp
-Description:
-Displays the Popup window - required by GIL
-
-
-Called by:	GIL 
-
-Author:      	Jon Ford -  
-Revision:	3/26/96
-Version:     	1.0
--------------------------------------------------------------*/
bool ShowEditPopUp()
{
	return TRUE;
}


/*-----------------------------------------------------------
-Funciton Name:		ShowStudPopUp
-Description:
-Displays the Popup window - required by GIL
-
-
-Called by:	GIL 
-
-Author:      	Jon Ford -  
-Revision:	3/26/96
-Version:     	1.0
--------------------------------------------------------------*/
bool ShowStudPopUp()
{
	return TRUE;
}


/*-----------------------------------------------------------
-Funciton Name:		ShowEditPopUp
-Description:
-Displays the Popup window - required by GIL
-
-
-Called by:	GIL 
-
-Author:      	Jon Ford -  
-Revision:	3/26/96
-Version:     	1.0
--------------------------------------------------------------*/
bool ShowTestPopUp()
{
	return TRUE;
}


/*-----------------------------------------------------------
-Funciton Name:		ShowHelpPopUp
-Description:
-Displays the Popup window - required by GIL
-
-
-Called by:	GIL 
-
-Author:      	Jon Ford -  
-Revision:	3/26/96
-Version:     	1.0
--------------------------------------------------------------*/

bool ShowHelpPopUp()
{
	return TRUE;
}



/*-----------------------------------------------------------
-Funciton Name:		HelpOK
-Description:
-This function is called in the event that the user selects
-OK in the help dialog box.  It closes the box and redraws
-the main window and the statistics(if a file is open).
-
-Called by:	GIL
-
-Calls:		GetList
-		redraw_func
-		Stats 
-
-Author:      	Jon Ford -  
-Revision:	3/26/96
-Version:     	1.0
--------------------------------------------------------------*/
bool HelpOK()
{
	ListMgr listmgr;
	listmgr=GetList(CURR_LIST);

	GSdisablebutton(HELP_WIND,HELPOK_BTN,NO_DRAW);

	GSremovenamedwindow(HELP_WIND);
	redraw_func();
	if (listmgr->title.students!=0)
		Stats();
	return TRUE;
}


/*-----------------------------------------------------------
-Funciton Name:		FileOK
-
-Description:
-This function is called when the user selects ok in the file
-dialog box.  It then opens or saves the file as appropriate.
-
-
-Called by:	GIL
-
-Calls:		GetList
-		Stats
-		ReadFile
-		WriteODBFile
-		GIL 
-
-Author:      	Jon Ford -  
-Revision:	3/26/96
-Version:     	1.0
--------------------------------------------------------------*/

bool FileOK()
{
	ListMgr listmgr;
	int x, y, wd, ht;
	GSColor col;
	BigString str;
	char temp[80];

	GSdisablebutton(FILE_WIND,FILEOK_BTN,NO_DRAW);
	GSdisablebutton(FILE_WIND,FILECANCEL_BTN,NO_DRAW);

	GSremovenamedwindow(FILE_WIND);
	redraw_func();

	
	listmgr = GetList(CURR_LIST);
	
	/*if we are using the dialog box to open a file, read it.*/

	if(strcmp(listmgr->title.currentedit,TEST_FILE)==0)
	{
		strcpy (listmgr->title.currentedit, EMPTY);
		strcpy(listmgr->title.opfilename,listmgr->title.editvalue);
		
		ReadFile(listmgr);
		
		if (listmgr->title.students!=0)
		{
			
			EnableSave();
			GSsetsclistnumitems(sclist_handle, 
				listmgr->title.students,TRUE);

			listmgr->title.currlistitem=NOITEM;

			if (listmgr->title.filetype==OPFILE)
				listmgr->title.savestatus=TRUE;
			redraw_func();
			Stats();
		}
		
	}
	
	/*if we are using the dialog box to save a file, save it.*/

	if(strcmp(listmgr->title.currentedit,FILE_SAVE)==0)
	{
		strcpy (listmgr->title.currentedit, EMPTY);
		
		strcpy (listmgr->title.opfilename, listmgr->title.editvalue);

		WriteODBFile(listmgr);
		
		listmgr->title.currlistitem=NOITEM;
		redraw_func();
		listmgr->title.savestatus=FALSE;
		listmgr->title.filetype=ODBFILE; /*odb file*/
		Stats();
	}
	
	return TRUE;
}




/*-----------------------------------------------------------
-Funciton Name:		FileCancel
-Description:
-Called in response to the user selecting cancel in the file
-dialog box.  It removes the file dialog and redraws the other
-stuff.
-
-
-Called by:	GIL
-
-Calls:		GetList
-		redraw_func
-		Stats
-
-Author:      	Jon Ford -  
-Revision:	3/26/96
-Version:     	1.0
--------------------------------------------------------------*/
bool FileCancel()
{
	ListMgr listmgr;


	listmgr = GetList(CURR_LIST);
	strcpy (listmgr->title.currentedit, EMPTY);

	GSdisablebutton(FILE_WIND,FILEOK_BTN,NO_DRAW);
	GSdisablebutton(FILE_WIND,FILECANCEL_BTN,NO_DRAW);

	GSremovenamedwindow(FILE_WIND);
	redraw_func();

	if (listmgr->title.students!=0)
		Stats();

	return TRUE;
}




/*-----------------------------------------------------------
-Funciton Name:		QuitOK
-Description:
-Called in response to the user selecting the OK button in the
-quit dialog box.  It frees the memory by calling Destroy List
-and then exits.
-
-Called by:	GIL
-
-Calls:		GetList
-		DestroyList
-		GSQuit
-
-Author:      	Jon Ford -  
-Revision:	3/26/96
-Version:     	1.0
--------------------------------------------------------------*/
bool QuitOK()
{
	ListMgr listmgr;

	listmgr = GetList(CURR_LIST);

	DestroyList(listmgr);
	
	GSquit(NULL);
	return TRUE;
}




/*-----------------------------------------------------------
-Funciton Name:		QuitCancel
-
-Description:
-This function is called in respose to the user selecting the
-Cancel button in the quit dialog box.  It closes the dialog
-box and redraws all the other stuff.
-
-Called by:	GIL
-
-Calls:		GetList
-		redraw_func
-		Stats
-
-Author:      	Jon Ford -  
-Revision:	3/26/96
-Version:     	1.0
--------------------------------------------------------------*/
bool QuitCancel()
{
	ListMgr listmgr;

	listmgr = GetList(CURR_LIST);

	GSdisablebutton(QUIT_WIND,QUITOK_BTN,NO_DRAW);
	GSdisablebutton(QUIT_WIND,QUITCANCEL_BTN,NO_DRAW);

	GSremovenamedwindow(QUIT_WIND);
	redraw_func();
	if (listmgr->title.students!=0) /*no students, no stats*/
		Stats();
	return TRUE;
}




/*-----------------------------------------------------------
-Funciton Name:		DumpFileButton
-
-Description:
-This function is called in the event that the user selects
-the don's save button in the close confirm save dialog box.
-It clears the list and moves on.
-
-Called by:	GIL
-
-Calls:		GetList
-		DestroyList
-		DisableSave
-		DisableEdit
-		redraw_func
-
-Author:      	Jon Ford -  
-Revision:	3/26/96
-Version:     	1.0
--------------------------------------------------------------*/
bool DumpFileButton()
{
	ListMgr listmgr;
	
	listmgr = GetList(CURR_LIST);
	
	listmgr->title.students=0;

	strcpy(listmgr->title.opfilename,NONE);

	GSsetsclistnumitems(sclist_handle, listmgr->title.students,TRUE);

	DestroyList(listmgr);

	DisableSave();

	DisableEdit();

	GSdisablebutton(SAVE_WIND,SAVEFILE_BTN,NO_DRAW);
	GSdisablebutton(SAVE_WIND,DUMPFILE_BTN,NO_DRAW);
	
	GSremovenamedwindow(SAVE_WIND);
	redraw_func();
	return TRUE;
}




/*-----------------------------------------------------------
-Funciton Name:		SaveFileConfirm
-
-Description:
-This function calls save file in response to the user selecting
-save in the close save confirm dialog box.
-
-Called by:	GIL
-
-Calls:		SaveFile
-		GIL 
-
-Author:      	Jon Ford -  
-Revision:	3/26/96
-Version:     	1.0
--------------------------------------------------------------*/

bool SaveFileConfirm()
{
	GSdisablebutton(SAVE_WIND,SAVEFILE_BTN,NO_DRAW);
	GSdisablebutton(SAVE_WIND,DUMPFILE_BTN,NO_DRAW);

	GSremovenamedwindow(SAVE_WIND);
	SaveFile();	
	return TRUE;
}




/*-----------------------------------------------------------
-Funciton Name:		StudDeleteOK
-
-Description:
-This function is called in response to the user selecting the
-OK function in the student delete dialog box.  It removes the
-student from the list.
-
-
-Called by:	GIL
-
-Calls:		GetList
-		ReturnElement
-		RemoveElement
-		GIL
-		Stats
-		redraw_func
-
-Author:      	Jon Ford -  
-Revision:	3/26/96
-Version:     	1.0
--------------------------------------------------------------*/

bool StudDeleteOK()
{
	ListMgr listmgr;
	ElemPtr element;

	listmgr = GetList(CURR_LIST);

	element = ReturnElement(listmgr,listmgr->title.currlistitem);

	RemoveElement(listmgr,element);

	listmgr->title.students--;

	GSsetsclistnumitems(sclist_handle,listmgr->title.students,TRUE);

	listmgr->title.savestatus=TRUE;

	GSdisablebutton(DEL_WIND,DELSTUDOK_BTN,NO_DRAW);
	GSdisablebutton(DEL_WIND,DELSTUDCANCEL_BTN,NO_DRAW);

	GSremovenamedwindow(DEL_WIND);
	
	redraw_func();
	
	Stats();
	return TRUE;
}
	


/*-----------------------------------------------------------
-Funciton Name:		StudDeleteCancel
-
-Description:
-This function is called in response to the user selecting the
-cancel button in the student delete dialog box.  It closes the
-window and redisplays all of the other stuff.
-
-Called by:	GIL
-
-Calls:		redraw_func
-		Stats
-		GIL 
-
-Author:      	Jon Ford -  
-Revision:	3/26/96
-Version:     	1.0
--------------------------------------------------------------*/
bool StudDeleteCancel()
{
	GSdisablebutton(DEL_WIND,DELSTUDOK_BTN,NO_DRAW);
	GSdisablebutton(DEL_WIND,DELSTUDCANCEL_BTN,NO_DRAW);

	GSremovenamedwindow(DEL_WIND);
	redraw_func();
	Stats();
	return TRUE;
}



/*-----------------------------------------------------------
-Funciton Name:		char_func
-
-Description:
-This function handles input of text from the user, storing it
-in listmgr->title.editvalue.
-
-Called by:	GIL
-
-Calls:		GetList
-		GIL
-
-Author:      	Jon Ford -  
-Revision:	3/26/96
-Version:     	1.0
--------------------------------------------------------------*/
bool char_func(int x, int y, char ch)
{
	int i;
	ListMgr listmgr;
	int edit_len, ins_point;

	listmgr = GetList(CURR_LIST);

	edit_len = listmgr->title.edit_len;
	ins_point = listmgr->title.ins_point;

	

	   
	if (strcmp(listmgr->title.currentedit, EMPTY) == 0)
		return;
		
		
		
	switch (ch) 
	{
	
		case KeyLeft:
			if (ins_point > 0)
				ins_point--;
			break;
			
		case KeyRight:
			if (ins_point < edit_len)
				ins_point++;
			break;
			
		case '\b':
			if (ins_point > 0) {
				
				/* delete character before ins_point */
				
				for (i=ins_point-1; ititle.editvalue[i] = 
						listmgr->title.editvalue[i+1];
					
				edit_len--;
				ins_point--;
				}
			break;
		
		default:
			if ((ch >= ' ') && (ch <= '~') && (edit_len < MAX_EDIT_LEN)) 				{
				
				/* insert ch at ins_point */
				
				for (i=edit_len; i >= ins_point; i--)
					listmgr->title.editvalue[i+1] = 
						listmgr->title.editvalue[i];
					
				listmgr->title.editvalue[ins_point] = ch;
				edit_len++;
				ins_point++;
				}
			break;
	}

	listmgr->title.edit_len = edit_len;
	listmgr->title.ins_point = ins_point;	


	DisplayEdit();
	

	return TRUE;
}




/*-----------------------------------------------------------
-Funciton Name:		DisplayEdit
-
-Description:
-This function displays the current value of the text being
-edited and draws a line to indicate the position of the cursor.
-
-
-Called by:	GIL
-
-Calls:		GetList
-		GIL 
-
-Author:      	Jon Ford -  
-Revision:	3/26/96
-Version:     	1.0
--------------------------------------------------------------*/
void DisplayEdit()
{
	int x, y, wd, ht;
	int curs_start, curs_len;
	int edit_len, ins_point;
	char curs_char;
	ListMgr listmgr;
	
	GSColor col;
	BigString str;


	listmgr = GetList(CURR_LIST);

	edit_len = listmgr->title.edit_len;
	ins_point = listmgr->title.ins_point;


	
	/*set the window to be drawn in to the window on the screen*/

	if ((strcmp(listmgr->title.currentedit,TEST_FILE)==0)||
		(strcmp(listmgr->title.currentedit,FILE_SAVE)==0))
		GSsetcurrentnamedwindow(FILE_WIND);
	else
		if (strcmp(listmgr->title.currentedit,ODB_FILE)==0)
			GSsetcurrentnamedwindow(FILE_WIND);
		else
			GSsetcurrentnamedwindow(INPUT_WIND);
			
			
	
	GSsetfont(SMALL);
	
	/*set the field to be drawn in to the field on the screen*/

	if ((strcmp(listmgr->title.currentedit,TEST_FILE)==0)||
		(strcmp(listmgr->title.currentedit,FILE_SAVE)==0))
		GSgetfieldrect(FILE_FLD,&x,&y,&wd,&ht,&col);
	else
		if (strcmp(listmgr->title.currentedit,ODB_FILE)==0)
			GSgetfieldrect(FILE_FLD,&x,&y,&wd,&ht,&col);
		else
			GSgetfieldrect(INPUT_FLD, &x, &y, &wd, &ht, &col);
	
	
	GSsetcolor(col);	
	GSwfillrect(x, y, wd, ht);
	
	

	if ((strcmp(listmgr->title.currentedit,TEST_FILE)==0)||
		(strcmp(listmgr->title.currentedit,FILE_SAVE)==0))
		GSframefield(FILE_WIND, FILE_FLD, 
			GSconvertcolor("black"), GSconvertcolor("dgray"));
	else
		if (strcmp(listmgr->title.currentedit,ODB_FILE)==0)
			GSframefield(FILE_WIND, FILE_FLD, 
				GSconvertcolor("black"), GSconvertcolor("dgray"));
		else
			GSframefield(INPUT_WIND, INPUT_FLD, 
				GSconvertcolor("black"), GSconvertcolor("dgray"));


	GSsetcolor(GSconvertcolor("black"));

	GSwwritemsg(x+1, y+SMALL+1, listmgr->title.editvalue);
	
	/* underline current position */
	
	sprintf(str, "%s", listmgr->title.editvalue);
	
	if (ins_point >= edit_len)
		curs_char = ' ';
	else
		curs_char = str[ins_point];
	
	str[ins_point] = '\0';
	curs_start = GStextwidth(str);
	str[0] = curs_char;
	str[1] = '\0';
	curs_len = GStextwidth(str);
	
	GSwdrawline(x+1+curs_start, y+SMALL+2, 
			x+1+curs_start+curs_len, y+SMALL+2);

	listmgr->title.edit_len = edit_len;
	listmgr->title.ins_point = ins_point;	

	return;
}




/*-----------------------------------------------------------
-Funciton Name:		EnableEdit
-
-Description:
-This function enables or disables all of the appropriate menu
-items for editing a student if they have selected one.
-
-Called by:	GIL
-
-Calls:		GIL 
-
-Author:      	Jon Ford -  
-Revision:	3/26/96
-Version:     	1.0
--------------------------------------------------------------*/
void EnableEdit()
{
	GSenablemenuitem(EDIT_MENU,"SSN");
	GSenablemenuitem(EDIT_MENU,"Name");
	GSenablemenuitem(EDIT_MENU,"CorrectNum");
	GSenablemenuitem(EDIT_MENU,"Group");
	GSenablemenuitem(EDIT_MENU,"Form");
	GSenablemenuitem(EDIT_MENU,"Omitted");
	GSenablemenuitem(EDIT_MENU,"Seat");
	GSenablemenuitem(STUD_MENU,"Delete");
}




/*-----------------------------------------------------------
-Funciton Name:		EnableSave
-
-Description:
-This function enables or disables all of the appropriate menu
-items for manipulating a file if they have one open.
-
-Called by:	GIL
-
-Calls:		GIL 
-
-Author:      	Jon Ford -  
-Revision:	3/26/96
-Version:     	1.0
--------------------------------------------------------------*/
void EnableSave()
{
	GSdisablemenuitem(FILE_MENU,"OpenTest");
	GSenablemenuitem(FILE_MENU,"SaveFile");
	GSenablemenuitem(FILE_MENU,"SaveAs");
	GSenablemenuitem(FILE_MENU,"Close");
	GSenablemenuitem(TEST_MENU,"QuestionsNum");
	GSenablemenuitem(TEST_MENU,"Description");
	GSenablemenuitem(TEST_MENU,"Date");
	GSenablemenuitem(TEST_MENU,"Evaluate");
	GSenablemenuitem(STUD_MENU,"Insert");
}




/*-----------------------------------------------------------
-Funciton Name:		DisableSave
-
-Description:
-This function enables or disables all of the appropriate menu
-items for loading a file if they do not have one open.
-
-Called by:	GIL
-
-Calls:		GIL 
-
-Author:      	Jon Ford -  
-Revision:	3/26/96
-Version:     	1.0
--------------------------------------------------------------*/
void DisableSave()	
{
	GSenablemenuitem(FILE_MENU,"OpenTest");
	GSdisablemenuitem(FILE_MENU,"SaveFile");
	GSdisablemenuitem(FILE_MENU,"SaveAs");
	GSdisablemenuitem(FILE_MENU,"Close");
	GSdisablemenuitem(TEST_MENU,"QuestionsNum");
	GSdisablemenuitem(TEST_MENU,"Description");
	GSdisablemenuitem(TEST_MENU,"Date");
	GSdisablemenuitem(TEST_MENU,"Evaluate");
}




/*-----------------------------------------------------------
-Funciton Name:		DisableEdit
-
-Description:
-This function enables or disables all of the appropriate menu
-items for editing a student if they have not selected one.
-
-Called by:	GIL
-
-Calls:		GIL 
-
-Author:      	Jon Ford -  
-Revision:	3/26/96
-Version:     	1.0
--------------------------------------------------------------*/

void DisableEdit()
{
	GSdisablemenuitem(EDIT_MENU,"SSN");
	GSdisablemenuitem(EDIT_MENU,"Name");
	GSdisablemenuitem(EDIT_MENU,"CorrectNum");
	GSdisablemenuitem(EDIT_MENU,"Group");
	GSdisablemenuitem(EDIT_MENU,"Form");
	GSdisablemenuitem(EDIT_MENU,"Omitted");
	GSdisablemenuitem(EDIT_MENU,"Seat");
	GSdisablemenuitem(STUD_MENU,"Delete");
	GSdisablemenuitem(STUD_MENU,"Insert");
}





/*-----------------------------------------------------------
-Funciton Name:		label_func
-
-Description:
-This function returns a pointer to a string to fill into each
-of the pick list slots.
-
-Called by:	GIL
-
-Calls:		GetList
-		ReturnElement
-
-Parameters:	slot
-
-Author:      	Jon Ford -  
-Revision:	3/26/96
-Version:     	1.0
--------------------------------------------------------------*/
char *label_func(int slot)
{
	
	ListMgr listmgr;
	static BigString label;
	ElemPtr elem;

	listmgr = GetList(CURR_LIST);
	
	elem = ReturnElement(listmgr,slot);

	

	if (elem==NULL)
	{
		strcpy(label,"hm");
	}
	else
	{
	sprintf(label,"%-11.11s%-13.13s%-2.2s%-4.4s%-6.1f%-8.1f%-7d%-5s%-6s%-4d%-2s", 
				elem->item.SSN,
				elem->item.lastname,
				elem->item.initial1,
				elem->item.initial2,
				elem->item.score,
				elem->item.tscore,
				elem->item.correctcount,
				elem->item.group,
				elem->item.form,
				elem->item.omittedcount,
				elem->item.seatnumber);

		
	}
	return label;
}





/*-----------------------------------------------------------
-Funciton Name:      text_func
-Description:
-
-Description of Algorithm:
-
-
-
-Called by:          GIL
-Parameters:         
-
-Author:      	Jon Ford -  
-Revision:	3/26/96
-Version:     	1.0
--------------------------------------------------------------*/

void text_func(GSlistHandle list, int slot)
{
	ListMgr listmgr;
	listmgr = GetList(CURR_LIST);
	if (slot==listmgr->title.currlistitem)
		GSsetcolor(GSconvertcolor("curitem"));
	else
		GSsetcolor(GSconvertcolor("black"));

}
		






/*-----------------------------------------------------------
-Funciton Name:		click_func
-
-Description:
-This function handles the click of the mouse inside the 
-drag area by highlighting the appropriate slot.
-
-Called by:	GIL
-
-Calls:		GetList
-		GIL
-
-Parameters:	slot
-		
-
-Author:      	Jon Ford -  
-Revision:	3/26/96
-Version:     	1.0
--------------------------------------------------------------*/

void click_func(int slot)
{
	ListMgr listmgr;
	
	int i,old_item;
	
	listmgr = GetList(CURR_LIST);

	old_item=listmgr->title.currlistitem;
	listmgr->title.currlistitem=slot;

	if (old_item != NOITEM)
		GSdrawlistitem(list_handle, New, old_item);


	GSdrawlistitem(list_handle, New, listmgr->title.currlistitem);

	EnableEdit();
}




/*-----------------------------------------------------------
-Funciton Name:		ListDrag
-
-Description:
-Handles drag inside the drag area.  Done by GIL
-
-Called by:	GIL
-
-Calls:		GIL
-
-Parameters:	x - potition 
-		y - position
-		DragStatusType
-
-Author:      	Jon Ford -  
-Revision:	3/26/96
-Version:     	1.0
--------------------------------------------------------------*/
bool ListDrag(int x, int y, DragStatusType status)
{
	GShandlelist(list_handle, x, y, status);
	return TRUE;
}




/*-----------------------------------------------------------
-Funciton Name:		ScrollDrag
-
-Description:
-Handles drag of the scroll bar.  Done by GIL
-
-Called by:	GIL
-
-Calls:		GIL
-
-Parameters:	x - potition 
-		y - position
-		DragStatusType
-
-Author:      	Jon Ford -  
-Revision:	3/26/96
-Version:     	1.0
--------------------------------------------------------------*/
bool ScrollDrag(int x, int y, DragStatusType status)
{
	GShandlesclist(sclist_handle,x,y,status);
	return TRUE;
}




/*-----------------------------------------------------------
-Funciton Name:		UpButton
-
-Description:
-Scrolls the list up when the scroll up button is pressed.
-Handled by GIL.
-
-Called by:	GIL
-
-Calls:		GIL
-
-Author:      	Jon Ford -  
-Revision:	3/26/96
-Version:     	1.0
--------------------------------------------------------------*/
bool UpButton()
{
	GShandleupbutton(sclist_handle);
	return TRUE;
}




/*-----------------------------------------------------------
-Funciton Name:		DownButton
-
-Description:
-Scrolls the list down when the scroll down button is pressed.
-Handled by GIL.
-
-Called by:	GIL
-
-Calls:		GIL
-
-Author:      	Jon Ford -  
-Revision:	3/26/96
-Version:     	1.0
--------------------------------------------------------------*/

bool DownButton()
{
	GShandledownbutton(sclist_handle);
	return TRUE;
}




/*-----------------------------------------------------------
-Funciton Name:		Stats
-Description:
-calculates and displays the information shown on the main
-window:  students, average, stddev, questions, date, description,
-file name, etc.
-
-
-Called by:	Misc above
-
-Calls:		GetList
-		GIL    
-
-Author:      	Jon Ford -  
-Revision:	3/26/96
-Version:     	1.0
--------------------------------------------------------------*/

void Stats()
{
	ListMgr listmgr;
	int x, y, wd, ht;
	GSColor col;
	BigString str;
	char temp[80];
	float average;
	float stddev;
	ElemPtr current;
	float sum;
	

	listmgr = GetList(CURR_LIST);

	current = ReturnFirst(listmgr);
	listmgr->title.total=0;

	/*loop through and count total so we can calculate average*/

	while (current!=NULL)
	{
		listmgr->title.total += current->item.score;
		current=ReturnNext(current);
	}
	
	average = ((listmgr->title.total)/(listmgr->title.students));

	current = ReturnFirst(listmgr);
	sum =0;

	/*loop through and calculate sum of squares so we can calc stddev*/

	while (current!=NULL)
	{
		sum += ((current->item.score - average)*
			(current->item.score - average));
		current=ReturnNext(current);
	}
	
	stddev = sqrt((sum)/(listmgr->title.students));



	/*display the number of students*/

	GSsetcurrentnamedwindow(MAIN_WIND);
			
	GSsetfont(SMALL);

	GSgetfieldrect(STUD_FLD,&x,&y,&wd,&ht,&col);
	
	GSsetcolor(col);	
	GSwfillrect(x, y, wd, ht);
	GSframefield(MAIN_WIND, STUD_FLD, 
		GSconvertcolor("black"), GSconvertcolor("dgray"));

	GSsetcolor(GSconvertcolor("black"));
		
	sprintf(temp,"%5d",listmgr->title.students);
	GSwwritemsg(x+1, y+SMALL+1, temp);



	/*display the average score*/

	GSgetfieldrect(AVE_FLD,&x,&y,&wd,&ht,&col);
	
	GSsetcolor(col);	
	GSwfillrect(x, y, wd, ht);
	GSframefield(MAIN_WIND, AVE_FLD, 
		GSconvertcolor("black"), GSconvertcolor("dgray"));

	GSsetcolor(GSconvertcolor("black"));
		
	sprintf(temp,"%8.2f",average);
	GSwwritemsg(x+1, y+SMALL+1, temp);



	/*display the standard deviation*/

	GSgetfieldrect(DEV_FLD,&x,&y,&wd,&ht,&col);
	
	GSsetcolor(col);	
	GSwfillrect(x, y, wd, ht);
	GSframefield(MAIN_WIND, DEV_FLD, 
		GSconvertcolor("black"), GSconvertcolor("dgray"));

	GSsetcolor(GSconvertcolor("black"));
		
	sprintf(temp,"%8.2f",stddev);
	GSwwritemsg(x+1, y+SMALL+1, temp);


	/*display the date*/

	GSgetfieldrect(DATE_FLD,&x,&y,&wd,&ht,&col);
	
	GSsetcolor(col);	
	GSwfillrect(x, y, wd, ht);
	GSframefield(MAIN_WIND, DATE_FLD, 
		GSconvertcolor("black"), GSconvertcolor("dgray"));

	GSsetcolor(GSconvertcolor("black"));
		
	sprintf(temp,"%s",listmgr->title.date);
	GSwwritemsg(x+1, y+SMALL+1, temp);
	

	/*display the filename*/

	GSgetfieldrect(FILENAME_FLD,&x,&y,&wd,&ht,&col);
	
	GSsetcolor(col);	
	GSwfillrect(x, y, wd, ht);
	GSframefield(MAIN_WIND, FILENAME_FLD, 
		GSconvertcolor("black"), GSconvertcolor("dgray"));

	GSsetcolor(GSconvertcolor("black"));
		
	sprintf(temp,"%s",listmgr->title.opfilename);
	GSwwritemsg(x+1, y+SMALL+1, temp);

	
	/*display the description*/

	GSgetfieldrect(DESC_FLD,&x,&y,&wd,&ht,&col);
	
	GSsetcolor(col);	
	GSwfillrect(x, y, wd, ht);
	GSframefield(MAIN_WIND, DESC_FLD, 
		GSconvertcolor("black"), GSconvertcolor("dgray"));

	GSsetcolor(GSconvertcolor("black"));
		
	sprintf(temp,"%s",listmgr->title.desc);
	GSwwritemsg(x+1, y+SMALL+1, temp);




	/*display the number of questions*/

	GSsetcurrentnamedwindow(MAIN_WIND);
			
	GSsetfont(SMALL);

	GSgetfieldrect(QUEST_FLD,&x,&y,&wd,&ht,&col);
	
	GSsetcolor(col);	
	GSwfillrect(x, y, wd, ht);
	GSframefield(MAIN_WIND, QUEST_FLD, 
		GSconvertcolor("black"), GSconvertcolor("dgray"));

	GSsetcolor(GSconvertcolor("black"));
		
	sprintf(temp,"%5d",listmgr->title.questions);
	GSwwritemsg(x+1, y+SMALL+1, temp);

	
}



/*GIL stuff*/

IntrFunction FuncNames[] ={
	{"redraw_func", redraw_func},
	{"char_func", (bool(*)())char_func},
 	{"null_func",null_func},
 	{"OpenTest",OpenTest},
	{"OpenODB",OpenODB},
	{"OpenGen",OpenGen},
	{"SaveFile",SaveFile},
	{"SaveFileAs",SaveFileAs},
	{"CloseFile",CloseFile},
	{"Break",Break},
	{"Quit",Quit},
	{"EditSSN",EditSSN},
	{"EditName",EditName},
	{"EditCorrNum",EditCorrNum},
	{"EditGroup",EditGroup},
	{"EditForm",EditForm},
	{"EditOmit",EditOmit},
	{"EditSeat",EditSeat},
	{"StudInsert",StudInsert},
	{"StudDelete",StudDelete},
	{"TestQuestNum",TestQuestNum},
	{"TestDesc",TestDesc},
	{"TestDate",TestDate},
	{"TestEval",TestEval},
	{"HelpAbout",HelpAbout},
	{"HelpHelp",HelpHelp},
	{"InputOK",InputOK},
	{"InputCancel",InputCancel},
	{"AboutOK",AboutOK},
	{"FilePopUp",ShowFilePopUp},
	{"EditPopUp",ShowEditPopUp},
	{"StudPopUp",ShowStudPopUp},
	{"TestPopUp",ShowTestPopUp},
	{"HelpPopUp",ShowHelpPopUp},
	{"UpButton",UpButton},
	{"DownButton",DownButton},
	{"ListDrag",ListDrag},
	{"ScrollDrag",ScrollDrag},
	{"HelpOK",HelpOK},
	{"FileOK",FileOK},
	{"FileCancel",FileCancel},
	{"QuitOK",QuitOK},
	{"QuitCancel",QuitCancel},
	{"DumpFileButton",DumpFileButton},
	{"SaveFileConfirm",SaveFileConfirm},
	{"StudDeleteOK",StudDeleteOK},
	{"StudDeleteCancel",StudDeleteCancel},
	};

int NumFuncs = GSnumifuncs(FuncNames);