//**************************************
// This is the base class of your DLL interface
// All methods of CPA_ToolDLLBase are 
// present in that class.
//**************************************
#ifndef __PARTGEN_INTERF_HPP__
#define __PARTGEN_INTERF_HPP__

#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000

#include "ACP_Base.h"
#include "ITF.h"
//#include "DNM.h"
/*
#define D_State_Define
#include "IncGAM.h"
#undef D_State_Define
#include "GLI.h"
*/

// Specific Includes //
#include "TPGMyDoc.hpp"
#include "TPG_View.hpp"
#include "TPGMainF.hpp"


// if you want only one instance of your DLL
// activate the next line
//#define DLL_ONLY_ONE_INSTANCE

//----------------------------------------------------------
// Tool DLL interface class
//----------------------------------------------------------
class CPA_PartGen_Interface : public CPA_ToolDLLBase
{
  private:


  public:
    CPA_PartGen_Interface(void);
//    ~CPA_PartGen_Interface(void);

/*===========================================================================
	Virtual Functions
=========================================================================*/
public:

	// To pre translate all messages
//	virtual BOOL fn_bPreTranslateMessage(MSG * /*p_stMsg*/) { return FALSE; };
	// Called just after editor has been inserted in list of all editors
	virtual void fn_vJustAfterRegistered(void);
	// Called just before windows main loop processing
	virtual void fn_vConstruct(void);
	// Called to refresh datas of DLL if "fn_vCanBeRefresh" returns TRUE
//	virtual void fn_vRefreshDatas(void);
	// Called when level has changed
	virtual void fn_vLevelHasChanged (void);
//	virtual void fn_vLevelChanges(void);

	virtual BOOL fn_bLoadBaseObject	(CPA_BaseObject *p_oObject);

//	virtual void fn_vAfterSaveAll(void);   *** DR ***
	virtual BOOL fn_bAcceptToSave();

/*===========================================================================
	Current Editor
=========================================================================*/

	virtual tdePermission fn_eAcceptNewEditor	(CPA_EditorBase *pNewEditor);

	virtual BOOL fn_bCanActivateEditor(CPA_List<CPA_BaseObject> *pParams);
	virtual void fn_vOnActivateEditor(CPA_List<CPA_BaseObject> *pParams, BOOL bBackActivated=FALSE);

	virtual BOOL fn_bCanCloseEditor(void);
	virtual void fn_vOnCloseEditor(void);

public:
/*===========================================================================
	Messages from Evt_Editor
=========================================================================*/

// for changes
//	virtual void fn_vOnChangeDevice (void) { }

// Editor Modifs
//	virtual void fn_vOnModifDelete	(CPA_List<EDT_SaveParents> *pListObjects, tdeTypeModif eType, tdeStatus eStatus);
//	virtual void fn_vOnModifParent	(CPA_List<EDT_SaveParents> *pListObjects, tdeTypeModif eType, tdeStatus eStatus) { }
//	virtual void fn_vOnModifCopy	(CPA_List<EDT_SaveParents> *pListObjects, tdeTypeModif eType, tdeStatus eStatus) { }
//	virtual void fn_vOnModifName(CPA_SuperObject *pEdObj, CString csInitalName, CString csFinalName, tdeTypeModif eType, tdeStatus eStatus);
//	virtual void fn_vOnSelect(CPA_SuperObject *pEdObj, tdeTypeModif eType, tdeStatus eStatus);

//	virtual void fn_vOnModifInsert(CPA_SuperObject *pEdObj, CPA_SuperObject *pParent,
//									 tdstPosition *p_stPosition, tdeTypeModif eType, tdeStatus eStatus) { }

// Moves
//	virtual void fn_vOnModifMove(CPA_List<EDT_SavePos> *pListObjects, CPA_List<EDT_SaveGlobalPos> *pListConcerned, tdeTypeModif eType, tdeStatus eStatus)	 { }
//	virtual void fn_vOnBeginMove(CPA_List<CPA_SuperObject> *pListObjects, CPA_List<CPA_SuperObject> *pListConcerned, tdeStatus eStatus) { }
//	virtual void fn_vOnMoving(CPA_List<CPA_SuperObject> *pListObjects, CPA_List<CPA_SuperObject> *pListConcerned, tdeStatus eStatus) { }

// Models
//	virtual void fn_vOnAddModelToList(CPA_ObjectDLLBase *pOwnerDLL, CString csListName, CString csModelName, tdeTypeModif eType) { }

// permission
//	virtual BOOL fn_bAcceptModifDelete(CPA_List<CPA_SuperObject> *pListObjects, tdeStatus eStatus);
//	virtual BOOL fn_bAcceptModifParent(CPA_List<CPA_SuperObject> *pListObjects, tdeStatus eStatus)  { return TRUE; }
//	virtual BOOL fn_bAcceptModifCopy(CPA_List<CPA_SuperObject> *pListObjects, tdeStatus eStatus);
//	virtual BOOL fn_bAcceptModifTranslate(CPA_List<CPA_SuperObject> *pListObjects, tdeStatus eStatus)  { return TRUE; }
//	virtual BOOL fn_bAcceptModifRotate(CPA_List<CPA_SuperObject> *pListObjects, tdeStatus eStatus)  { return TRUE; }
//	virtual BOOL fn_bAcceptModifInsert(CPA_SuperObject *pEdObj, CPA_SuperObject *pParent, tdeStatus eStatus) { return TRUE; }
//	virtual BOOL fn_bAcceptModifScale(CPA_SuperObject *pEdObj, tdeStatus eStatus) { return TRUE; }
//	virtual BOOL fn_bAcceptModifName(CPA_SuperObject *pEdObj, tdeStatus eStatus);
//	virtual BOOL fn_bAcceptMultiSelect(void)	{ return TRUE; }

// to precise selection
//	virtual tdeTypeAnswer fn_bAcceptSelect(CPA_SuperObject *pEdObj, ACP_tdxIndex xIndex, HIE_tdstPickInfo *pPicking, tdeStatus eStatus);

/*===========================================================================
	Dialog List
=========================================================================*/

//	virtual BOOL fn_bSetCustomTest		(CPA_DialogList *pDialog) { return FALSE; }
//	virtual BOOL fn_bCustomTestFunction (CString csCurrentType, CString csTestName, CPA_SaveObject *pEdObj) { return TRUE; }

/*===========================================================================
	General Purpose
=========================================================================*/

//	long OnQueryAction	(CPA_EditorBase * /*p_oSender*/, WPARAM, LPARAM);
//	virtual long OnQueryInfos	(CPA_DLLBase * /*p_oSender*/, WPARAM, LPARAM) { return 0; };
//	virtual long OnQueryOpen	(CPA_DLLBase * /*p_oSender*/, WPARAM, LPARAM) { return 0; };
//	virtual long OnQueryClose	(CPA_DLLBase * /*p_oSender*/, WPARAM, LPARAM) { return 0; };

/*===========================================================================
	Coherence
=========================================================================*/

//	virtual BOOL fn_bOnInvalidateLink	(CPA_ObjectBase *pOwner, CPA_ObjectBase *pReferencedObject, BOOL bDestroyed) { return FALSE; }
//	virtual void fn_vOnRestoreLink		(CPA_ObjectBase *pOwner, CPA_ObjectBase *pReferencedObject) { }

/*===========================================================================
	Messages
=========================================================================*/
// focus
	virtual void fn_vHasLostFocus	(void);
	virtual BOOL fn_bHasGainedFocus	(void);
// engine - editor
	virtual void fn_vBeforeEngine (void);
	virtual void fn_vBeforeEditor (void);
// engine
//	virtual BOOL fn_bAcceptToRunEngine(void) { return TRUE; };
//	virtual BOOL fn_bAcceptToRunTimerEngine	(void) { return TRUE; };
// end appli
//	virtual void fn_vJustBeforeClosing	(void) { };
//	virtual BOOL fn_bAcceptToExit		(void) { return TRUE; };
// keys
//	virtual BOOL _OnKeyDown (UINT nChar, UINT nRepCnt, UINT nFlags)	{ return FALSE; };
//	virtual BOOL _OnKeyUp	(UINT nChar, UINT nRepCnt, UINT nFlags)	{ return FALSE; };
// mouse
//	virtual BOOL _OnMouseMove	  (UINT nFlags, tdstMousePos *p_stPos, MTH3D_tdstVector *p_stVect)	{ return FALSE; };
//	virtual BOOL _OnLButtonDblClk (UINT nFlags, tdstMousePos *p_stPos, ACP_tdxIndex xIndex, HIE_tdstPickInfo *p_stPickInfo)	{ return FALSE; };
//	virtual BOOL _OnRButtonDblClk (UINT nFlags, tdstMousePos *p_stPos, ACP_tdxIndex xIndex, HIE_tdstPickInfo *p_stPickInfo)	{ return FALSE; };
//	virtual BOOL _OnLButtonDown	  (UINT nFlags, tdstMousePos *p_stPos, ACP_tdxIndex xIndex, HIE_tdstPickInfo *p_stPickInfo)	{ return FALSE; };
//	virtual BOOL _OnRButtonDown	  (UINT nFlags, tdstMousePos *p_stPos, ACP_tdxIndex xIndex, HIE_tdstPickInfo *p_stPickInfo)	{ return FALSE; };
//	virtual BOOL _OnLButtonUp	  (UINT nFlags, tdstMousePos *p_stPos)	{ return FALSE; };
//	virtual BOOL _OnRButtonUp	  (UINT nFlags, tdstMousePos *p_stPos)	{ return FALSE; };
// command
//	virtual BOOL _OnCommand			(UINT IDCmdMsg)				{ return FALSE; };
//	virtual BOOL _OnUpdateCommandUI	(UINT uiID, CCmdUI *pCmdUI)	{ return FALSE; };
// dragdrop
//	virtual BOOL _OnDragDropEnd			(WPARAM wParam, LPARAM lParam)	{ return FALSE; };
//	virtual BOOL _OnDragDropMove		(WPARAM wParam, LPARAM lParam)	{ return FALSE; };
//	virtual BOOL _OnDragDropLooseFocus	(WPARAM wParam, LPARAM lParam)	{ return FALSE; };
//	virtual BOOL _OnDragDropGainFocus	(WPARAM wParam, LPARAM lParam)	{ return FALSE; };
// add objects to draw
//	virtual void fn_vAddObjectsToDraw	(GLD_tdstViewportAttributes *p1, GLI_tdxHandleToLight p2)	{ };
//	virtual void fn_vAddObjectsToDraw2	(GLD_tdstViewportAttributes *p1, GLI_tdxHandleToLight p2)	{ };

/*===========================================================================
	Reinit
=========================================================================*/

//	virtual void fn_vOnChangeRoot	(void)	{ };
//	virtual void fn_vOnChangeWorld	(void)	{ };

/*===========================================================================
	for Dialog List
=========================================================================*/

	virtual CPA_BaseObject *GetDialogSelection(CPA_DialogList *pDialog, CString csTypeName, tdeListDrawMode eDrawMode);
	virtual void GetListsForDialog (CPA_DialogList *pDialog);

//	virtual BOOL fn_bOnSelChangeHierarchyTree	(CPA_DialogList *pDialog, CString csTypeName, CPA_SuperObject *pSelectedObject)							{ return FALSE; };
//	virtual BOOL fn_bOnDblClkHierarchyTree		(CPA_DialogList *pDialog, CString csTypeName, CPA_SuperObject *pSelectedObject)							{ return FALSE; };
	virtual BOOL fn_bOnSelChangeListObjects(CPA_DialogList *pDialog, CString csTypeName, CPA_BaseObject *pSelectedObject, BOOL bUnselect);
//	virtual BOOL fn_bOnDblClkListObjects		(CPA_DialogList *pDialog, CString csTypeName, CPA_SaveObject *pSelectedObject)						{ return FALSE; };
//	virtual BOOL fn_bCanDragItemInHierarchyTree	(CPA_DialogList *pDialog, CString csTypeName, CPA_SuperObject *pObjectToDrag)							{ return FALSE; };
//	virtual BOOL fn_bCanDropItemInHierarchyTree	(CPA_DialogList *pDialog, CString csTypeName, CPA_SuperObject *pObjectToDrop, CPA_SuperObject *pTarget)	{ return FALSE; };
//	virtual BOOL fn_bOnDragDropInHierarchyTree	(CPA_DialogList *pDialog, CString csTypeName, CPA_SuperObject *pObject, CPA_SuperObject *pTarget)		{ return FALSE; };
//	virtual BOOL fn_bOnSelChangeComboList(CPA_DialogList *pDialog, CString csTypeName);
//	virtual BOOL fn_bOnButtonTest(CPA_DialogList *pDialog, CString csTypeName, tdeListDrawMode eDraw);

	virtual void fn_vInitDefaultParameters(CPA_DialogList *pDialog);

//	virtual void fn_vSetANewTest(CPA_DialogList *pDialog, CString csCurrentList);
//	virtual BOOL fn_bTestFunction(CString csCurrentType, CString csTestName, CPA_BaseObject *pEdObj);

/*===========================================================================
	Dialog Bar - Mircea Dunka 31 Aug. 1998
=========================================================================*/
	void fn_vDefineDlgBarBtnIcon (tde_DlgBarCategory wCategory, tds_DlgBarBtn *_pDlgBarBtn);

/*===========================================================================
	SubMenus and PopupMenu
=========================================================================*/

	virtual BOOL fn_bDefineSubMenu(EDT_SubMenu *_p_oEDTSubMenu);
	virtual void _OnSubMenuCommand(EDT_SubMenu *_p_oEDTSubMenu,UINT uiMsgID);

//	virtual BOOL fn_bDefinePopupMenu(EDT_PopUpMenu *pPopup, CPA_List<CPA_SuperObject> *pSelection, BOOL bAsCurrentEditor);
//  virtual void _OnPopUpMenuCommand(UINT m_IDCmdMsg);

// Hierarchy
//	virtual CPA_SuperObject *GetNewEditorInstance(HIE_tdxHandleToSuperObject pEngineInstance);
//	virtual void fn_vUpdateEditorInstance(CPA_SuperObject *pEditorInstance, HIE_tdxHandleToSuperObject pEngineInstance);
//	virtual BOOL fn_bCanHandleThisType(long lEngineType);

// Models & Instances
//	virtual void fn_vInitListByType(CPA_World *pWorld);
//	virtual void fn_vInitListsOfModels(void);
//	virtual void fn_vSaveListModels(CString csListName, CPA_List<EDT_Model> *pListModels);
//	virtual CString	fn_csLoadListModels(void);
//	virtual EDT_Model *GetNewModel(CString csListName);
//	virtual BOOL fn_bCanLoadNewModel(CString csListName);
//	virtual BOOL fn_bCanDeleteModel(CString csListName) { return FALSE; };
//	virtual BOOL fn_bCanSaveListModels(CString csListName);
//	virtual BOOL fn_bCanLoadListModels(void);
//	virtual void fn_vOnLoadNewModel(CString csListName, EDT_Model *pNewModel);

//	virtual CPA_SuperObject *GetNewInstance(CString csTypeName, CString csModelName, CPA_SuperObject *pParent);
//	virtual tdeTypeSO GetTypeInstance(CString csTypeName, CString csModelName);
//	virtual CPA_SuperObject * GetParentForInsertion	 (CString csTypeName, CString csModelName, tdstPosition *p_stPosition) { return NULL; }
//	virtual BOOL fn_bChooseInsertPosition(CPA_SuperObject *pNewInstance, CPA_SuperObject *pParent, tdstPosition *p_stPosition);

// objects
//	virtual CPA_Object * GetNewObject (CString csObjectFile, CString csObjectName, FILE *p_fFile, CPA_MainWorld *p_oMainWorld) { return NULL; }
//	virtual CPA_Object *Duplicate(CPA_Object *pObject, CPA_SuperObject *pNewSuperObject);

//	virtual CPA_SuperObject *GetCopyOfProtectedChild (CPA_SuperObject *pInitialChild, CPA_SuperObject *pNewOwner);

// permissions for EvtEditor
//	virtual BOOL fn_bAcceptAsParent(CPA_Object *pChild, CPA_Object *pParent);
//	virtual BOOL fn_bAcceptAsChild(CPA_Object *pParent, CPA_Object *pChild);

// when insertion is canceled
//	virtual void fn_vOnCancelInsertion(CPA_SuperObject *pInstance);

	////////

	
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//(DR) Editor's specific members

//Attributes
public:
	//The (one and only) document
	CPA_PartGen_MyDocument m_clDocument;

	//The main frame
	CPA_PartGen_MainFrame *m_pclPartGenMainFrame;

	//The View
	TPG_View *m_pub_p_clView;

protected:

private:
	CString m_csEditorVersion;

	//CPA_PartGen_Card *m_pri_pclSelectedCard;

//Fucntions
public:
	CPA_PartGen_MyDocument	*m_pub_fn_p_clGetDocument();
	CPA_PartGen_Source		*m_pub_fn_p_clFindSourceWithEngine( PRT_tdstParticlesSource* );
	CPA_PartGen_System		*m_pub_fn_p_clFindSystemWithEngine( PRT_tdstParticlesSystem* );
	CPA_PartGen_Environment *m_pub_fn_p_clFindEnvWithEngine( PRT_tdstParticlesEnvironment* );
	CPA_PartGen_Generator	*m_pub_fn_p_clFindPrtGenWithEngine( tdxHandleToParticleGenerator );

protected:

private:
	void m_fn_vShowEditor();
	void m_fn_vHideEditor();

//(YB) End of Editor's specific members
//--------------------------------------------------------------------------
};

// DR //
extern CPA_PartGen_Interface *g_pclInterface;
// End DR //

extern tdstDLLIdentity g_stPartGenDLLIdentity;

#endif // __PARTGEN_INTERF_HPP__