/****************************/
/*   	DIALOG STUFF.C	    */
/* (c)1995 Pangea Software  */
/* By Brian Greenstone      */
/****************************/


/****************************/
/*    EXTERNALS             */
/****************************/

#include "myglobals.h"
#include "misc.h"
#include "dialogStuff.h"
#include "windows.h"


extern	Boolean	gShowContentStructure,gShow3DMFSummary,gSaveTextToFile,gRemoveDupeVerts;
extern	Boolean	gFuseAllMeshes,gPreTransform,gReverseBackfaces,gSaveAsBinary,gCalcVertexNormals;


/****************************/
/*    PROTOTYPES            */
/****************************/


/****************************/
/*    CONSTANTS             */
/****************************/


/*********************/
/*    VARIABLES      */
/*********************/



/********************* DO 3DMF OPEN OPTIONS **********************/
//
// OUTPUT:  true = cancelled
//

Boolean Do3DMFOpenOptions(void)
{
DialogPtr 		myDialog;
short			itemType,itemHit;
ControlHandle	itemHandle;
Rect			itemRect;
Boolean			dialogDone,cancelled;

	myDialog = GetNewDialog(128,NIL_POINTER,MOVE_TO_FRONT);
	
				/* SET CONTROL VALUES */
					
	GetDItem(myDialog,3,&itemType,(Handle *)&itemHandle,&itemRect);
	SetCtlValue((ControlHandle)itemHandle,gShowContentStructure);

	GetDItem(myDialog,4,&itemType,(Handle *)&itemHandle,&itemRect);
	SetCtlValue((ControlHandle)itemHandle,gShow3DMFSummary);
	if (!gShowContentStructure)
		HiliteControl((ControlHandle)itemHandle,255);

	GetDItem(myDialog,5,&itemType,(Handle *)&itemHandle,&itemRect);
	SetCtlValue((ControlHandle)itemHandle,gSaveTextToFile);
	if (!gShowContentStructure)
		HiliteControl((ControlHandle)itemHandle,255);
	
	
			/* SET OUTLINE FOR USERITEM */
			
	GetDItem(myDialog,1,&itemType,(Handle *)&itemHandle,&itemRect);
	SetDItem(myDialog, 7, userItem, (Handle)NewUserItemProc(DoBold), &itemRect);
	
	
				/* DO IT */
				
	dialogDone = cancelled = FALSE;
	while(dialogDone == FALSE)
	{
		ModalDialog(NIL_POINTER, &itemHit);
		switch (itemHit)
		{
			case 	1:									// hit ok
					dialogDone = TRUE;
					break;
					
			case	2:									// hit cancel
					cancelled = TRUE;
					dialogDone = TRUE;
					break;
					
			case	3:
					gShowContentStructure = !gShowContentStructure;
					GetDItem(myDialog,itemHit,&itemType,(Handle *)&itemHandle,&itemRect);
					SetCtlValue((ControlHandle)itemHandle,gShowContentStructure);
					
					if (!gShowContentStructure)
					{
						GetDItem(myDialog,4,&itemType,(Handle *)&itemHandle,&itemRect);
						HiliteControl((ControlHandle)itemHandle,255);
						GetDItem(myDialog,5,&itemType,(Handle *)&itemHandle,&itemRect);
						HiliteControl((ControlHandle)itemHandle,255);
					}
					else
					{
						GetDItem(myDialog,4,&itemType,(Handle *)&itemHandle,&itemRect);
						HiliteControl((ControlHandle)itemHandle,0);
						GetDItem(myDialog,5,&itemType,(Handle *)&itemHandle,&itemRect);
						HiliteControl((ControlHandle)itemHandle,0);
					}
					break;
				
			case	4:
					gShow3DMFSummary = !gShow3DMFSummary;
					GetDItem(myDialog,itemHit,&itemType,(Handle *)&itemHandle,&itemRect);
					SetCtlValue((ControlHandle)itemHandle,gShow3DMFSummary);
					break;
			
			case	5:
					gSaveTextToFile = !gSaveTextToFile;
					GetDItem(myDialog,itemHit,&itemType,(Handle *)&itemHandle,&itemRect);
					SetCtlValue((ControlHandle)itemHandle,gSaveTextToFile);
					break;
		}
	}
	DisposDialog(myDialog);
			
	return(cancelled);
}


/********************* DO 3DMF SAVE OPTIONS **********************/
//
// OUTPUT:  true = cancelled
//

Boolean Do3DMFSaveOptions(void)
{
DialogPtr 		myDialog;
short			itemType,itemHit;
ControlHandle	itemHandle;
Rect			itemRect;
Boolean			dialogDone,cancelled;

	myDialog = GetNewDialog(129,NIL_POINTER,MOVE_TO_FRONT);
	
				/* SET CONTROL VALUES */
	
	GetDItem(myDialog,3,&itemType,(Handle *)&itemHandle,&itemRect);
	SetCtlValue((ControlHandle)itemHandle,gSaveAsBinary);

	GetDItem(myDialog,4,&itemType,(Handle *)&itemHandle,&itemRect);
	SetCtlValue((ControlHandle)itemHandle,!gSaveAsBinary);

	GetDItem(myDialog,5,&itemType,(Handle *)&itemHandle,&itemRect);
	SetCtlValue((ControlHandle)itemHandle,gFuseAllMeshes);
	HiliteControl((ControlHandle)itemHandle,255);			// DISABLED NOW

	GetDItem(myDialog,6,&itemType,(Handle *)&itemHandle,&itemRect);
	SetCtlValue((ControlHandle)itemHandle,gPreTransform);

	GetDItem(myDialog,7,&itemType,(Handle *)&itemHandle,&itemRect);
	SetCtlValue((ControlHandle)itemHandle,gReverseBackfaces);
//	HiliteControl((ControlHandle)itemHandle,255);			// DISABLED NOW

	GetDItem(myDialog,13,&itemType,(Handle *)&itemHandle,&itemRect);
	SetCtlValue((ControlHandle)itemHandle,gCalcVertexNormals);

	GetDItem(myDialog,14,&itemType,(Handle *)&itemHandle,&itemRect);
	SetCtlValue((ControlHandle)itemHandle,gRemoveDupeVerts);

	
	
			/* SET OUTLINE FOR USERITEM */
			
	GetDItem(myDialog,1,&itemType,(Handle *)&itemHandle,&itemRect);			// OK
	SetDItem(myDialog, 8, userItem, (Handle)NewUserItemProc(DoBold), &itemRect);
	
	GetDItem(myDialog,9,&itemType,(Handle *)&itemHandle,&itemRect);			// box
	SetDItem(myDialog, 9, userItem, (Handle)NewUserItemProc(DoOutline), &itemRect);

	GetDItem(myDialog,15,&itemType,(Handle *)&itemHandle,&itemRect);			// box
	SetDItem(myDialog,15, userItem, (Handle)NewUserItemProc(DoOutline), &itemRect);
	
	
				/* DO IT */
				
	dialogDone = cancelled = FALSE;
	while(dialogDone == FALSE)
	{
		ModalDialog(NIL_POINTER, &itemHit);
		switch (itemHit)
		{
			case 	1:									// hit ok
					dialogDone = TRUE;
					break;
					
			case	2:									// hit cancel
					cancelled = TRUE;
					dialogDone = TRUE;
					break;
		
			case	3:
			case	4:
					gSaveAsBinary = !gSaveAsBinary;
					GetDItem(myDialog,3,&itemType,(Handle *)&itemHandle,&itemRect);
					SetCtlValue((ControlHandle)itemHandle,gSaveAsBinary);
					GetDItem(myDialog,4,&itemType,(Handle *)&itemHandle,&itemRect);
					SetCtlValue((ControlHandle)itemHandle,!gSaveAsBinary);
					break;

			case	5:
					gFuseAllMeshes = !gFuseAllMeshes;
					GetDItem(myDialog,itemHit,&itemType,(Handle *)&itemHandle,&itemRect);
					SetCtlValue((ControlHandle)itemHandle,gFuseAllMeshes);
					break;

			case	6:
					gPreTransform = !gPreTransform;
					GetDItem(myDialog,itemHit,&itemType,(Handle *)&itemHandle,&itemRect);
					SetCtlValue((ControlHandle)itemHandle,gPreTransform);
					break;

			case	7:
					gReverseBackfaces = !gReverseBackfaces;
					GetDItem(myDialog,itemHit,&itemType,(Handle *)&itemHandle,&itemRect);
					SetCtlValue((ControlHandle)itemHandle,gReverseBackfaces);
					break;
					
			case	13:
					gCalcVertexNormals = !gCalcVertexNormals;
					GetDItem(myDialog,itemHit,&itemType,(Handle *)&itemHandle,&itemRect);
					SetCtlValue((ControlHandle)itemHandle,gCalcVertexNormals);
					break;

			case	14:
					gRemoveDupeVerts = !gRemoveDupeVerts;
					GetDItem(myDialog,itemHit,&itemType,(Handle *)&itemHandle,&itemRect);
					SetCtlValue((ControlHandle)itemHandle,gRemoveDupeVerts);
					break;
			
			
		}
	}
	DisposDialog(myDialog);
			
	return(cancelled);
}








