/////////////////////////////////////////////////////////////
// CINEMA 4D SDK                                           //
/////////////////////////////////////////////////////////////
// (c) MAXON Computer GmbH, all rights reserved            //
/////////////////////////////////////////////////////////////

//---------------------------------------------------
#ifndef _C4D_PICTUREVIEWER_H_
#define _C4D_PICTUREVIEWER_H_

#ifdef __API_INTERN__
#include "c4d_basetime.h"
#include "ge_string.h"
#include "c4d_library.h"
#include "c4d_gui.h"
#else
#include "c4d.h"
#endif

class GeListNode;
class Filename;
class BaseBitmap;
class BaseDocument;
class String;
class BaseSound;

#define C4D_PICTUREVIEWER_LIBRARY_ID		430000795


#define PICTUREVIEWER_INIT_ACTIVE		(-1)
#define PICTUREVIEWER_INIT_RENDER		(-2)

#define MSG_PICTUREVIEWER_LAYERCHANGE			300001063
#define MSG_PICTUREVIEWER_OVERWRITEIMAGE	300001064

enum STEREOTYPE
{
	STEREOTYPE_REGULAR	=	0,
	STEREOTYPE_STREAM		= 1,
	STEREOTYPE_COMBINED	= 2
} ENUM_END_LIST(STEREOTYPE);

enum PVFRAME_FINISH
{
	PVFRAME_FINISH_DESTROY_NODE						= 0,
	PVFRAME_FINISH_KEEP_NODE_AND_COPYBMP	= 1,
	PVFRAME_FINISH_KEEP_NODE_AND_USEBMP		= 2
} ENUM_END_LIST(PVFRAME_FINISH);

typedef Bool PVFinalizeImage(BaseBitmap *bmp, void *userdata);

class PictureViewer
{
	private:
		PictureViewer();
		~PictureViewer();
	public:
		Bool Open(void);

		Bool ShowFile(const Filename &File);
		Bool ShowImage(BaseBitmap *Bmp, const String &Name);
		GeListNode* OpenRendering(const String &Name,Real Fps,LONG lStart,LONG lEnd,BaseContainer* bcrender);
		Bool AddSound(GeListNode *pNode, const BaseTime &from, const BaseTime &to, BaseSound *snd);
		Bool Message(LONG id, void *t_data);

		Bool AddRenderingEx(GeListNode *pNode, BaseBitmap *Bmp,const String &Name,const BaseTime &Time,LONG Frame,
			const Filename &savename,Bool fully_saved,Filename **filename_list,LONG filename_count, Bool bAlwaysCopy, LONG lStream, STEREOTYPE lStereoType);
		Bool CloseRenderingEx(GeListNode *&pNode,LONG action, Bool bAlwaysCopy);

		GeListNode *BeginRendering(GeListNode *pNode, BaseBitmap *Bmp,const String &Name,const BaseTime &Time,LONG Frame,
			const Filename &savename,Bool fully_saved, const Filename &dispname, LONG lStream, STEREOTYPE lStereoType);
		Bool EndRendering(GeListNode *beginNode, PVFRAME_FINISH finish, Bool incomplete, PVFinalizeImage *callback, void *userdata);
		Bool CloseRendering(GeListNode *&pNode);

		Bool CheckHDMemory( );
};

PictureViewer* CreatePictureViewer(LONG type);

//---------------------------------------------------
//	---INTERNAL STUFF

class iPictureViewer;

struct PictureViewLibrary : public C4DLibrary
{
	iPictureViewer*	(*CreatePictureViewer)(LONG type);

	Bool					(*Open)(iPictureViewer *this_ptr);

	Bool					(*ShowFile)(iPictureViewer *this_ptr, const Filename &File);
	Bool					(*ShowImage)(iPictureViewer *this_ptr, BaseBitmap *Bmp,const String &Name);
	GeListNode*		(*OpenRendering)(iPictureViewer *this_ptr, const String &Name,Real Fps,LONG lStart,LONG lEnd,BaseContainer* bcrender );
	Bool					(*AddSound)(iPictureViewer *this_ptr, GeListNode *pNode, const BaseTime &from, const BaseTime &to, BaseSound *snd);
	Bool					(*Message)(iPictureViewer *this_ptr, LONG id, void *t_data);

	Bool					(*CheckHDMemory)(iPictureViewer *this_ptr);

	GeListNode*		(*BeginRendering)(iPictureViewer *this_ptr, GeListNode *pNode, BaseBitmap *Bmp,const String &Name,const BaseTime &Time,LONG Frame,const Filename &savename,Bool fully_saved,const Filename &dispname, LONG lStream, STEREOTYPE lStereoType);
	Bool					(*EndRendering)(iPictureViewer *this_ptr, GeListNode *pNode, PVFRAME_FINISH finish, Bool incomplete, PVFinalizeImage *callback, void *userdata);
	Bool					(*CloseRendering)(iPictureViewer *this_ptr, GeListNode *&pNode);
};

#endif

