//-------------------------------------------------------------------------------
//
//	File:
//		BidFormat.h
//
//	Copyright 1994-1997, Adobe Systems Incorporated.
//	All Rights Reserved.
//
//	Description:
//		This file contains the header prototypes and macros for the
//		File Format module BidFormat, 
//		which writes a flat file with merged document pixels.
//
//	Use:
//		Format modules are called from the Save, Save as,
//		and Save a copy dialogs.
//
//	Version history:
//		Version 1.0.0	1/1/1994	Created for Photoshop 3.0.
//			Written by Mark Hamburg
//
//		Version 2.0.0	5/27/1996	Updated for Photoshop 4.0.
//			Scripting added.
//
//		Version 2.1.0	6/28/1997	Updated for Photoshop 4.0.1.
//			Updated for new version of Photoshop and projects
//			moved to CodeWarrior Pro.
//
//-------------------------------------------------------------------------------

#ifndef __BidFormat_H__	// Has this not been defined yet?
#define __BidFormat_H__	// Only include this once by predefining it

#include "PIFormat.h"					// Format Photoshop header file.
#include "PIUtilities.h"				// SDK Utility library.
#include "FileUtilities.h"				// File Utility library.
#include "BidFormatTerminology.h"	// Terminology for plug-in.

//-------------------------------------------------------------------------------
//	Structure -- FileHeader
//-------------------------------------------------------------------------------

/*
typedef struct FileHeader
{
	char identifier [8];
	
	int16 mode;
	int16 depth;
	int16 rows;
	int16 cols;
	int16 planes;
	
	int32 resourceLength;
	
} FileHeader;
*/
//-------------------------------------------------------------------------------
//	Globals -- structures
//-------------------------------------------------------------------------------

// Windows handle for our plug-in (seen as a dynamically linked library):
extern Handle hDllInstance;

typedef struct Globals
{ // This is our structure that we use to pass globals between routines:

	short				*result;			// Must always be first in Globals.
	FormatRecord		*formatParamBlock;	// Must always be second in Globals.

	Boolean				queryForParameters;

	BufferID			pixelBuffer;
	Ptr					pixelData;
	
	int32				rowBytes;
	
	Boolean				fooValueForRead;
	Boolean				barValueForWrite;
	
	Str255				history;
	
} Globals, *GPtr, **GHdl;				// *GPtr = global pointer; **GHdl = global handle
	
//-------------------------------------------------------------------------------
//	Globals -- definitions and macros
//-------------------------------------------------------------------------------

#define gResult				(*(globals->result))
#define gStuff				(globals->formatParamBlock)

#define gQueryForParameters	(globals->queryForParameters)

#define gPixelBuffer		(globals->pixelBuffer)
#define gPixelData			(globals->pixelData)
#define gRowBytes			(globals->rowBytes)

#define gFooRead			(globals->fooValueForRead)
#define gBarWrite			(globals->barValueForWrite)

#define gHistory			(globals->history)

//-------------------------------------------------------------------------------
//	Prototypes
//-------------------------------------------------------------------------------

// Everything comes in and out of ENTRYPOINT. It must be first routine in source:
MACPASCAL void ENTRYPOINT (const short selector,
					  	   FormatRecord *formatParamBlock,
						   long *data,
						   short *result);

void InitGlobals (Ptr globalPtr);		  		// Initialize globals.
void DoAbout (AboutRecordPtr about); 	   		// Pop about box.

void ValidateParameters (GPtr globals);			// Validates (inits) parameters.
Boolean DoUI (GPtr globals);					// Show the UI.

// During read phase:
Boolean ReadScriptParamsOnRead (GPtr globals);	// Read any scripting params.
OSErr WriteScriptParamsOnRead (GPtr globals);	// Write any scripting params.

// During write phase:
Boolean ReadScriptParamsOnWrite (GPtr globals);	// Read any scripting params.
OSErr WriteScriptParamsOnWrite (GPtr globals);	// Write any scripting params.

//-------------------------------------------------------------------------------

#endif // __BidFormat_H__
