/*=========================================================================
* 
* ipo_intf.hpp :  IPO DLL Interface - definition
* 
* Version			2.0
* Creation date		22/05/97	Author : Vincent Lhullier	
* Revision date		26/06/97	Author : Shaitan	
*					02/07/97	Author : Vincent Lhullier	
*
* Shaitan
*=======================================================================*/

#ifndef __IPO_INTF_HPP__
#define __IPO_INTF_HPP__

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include "incGAM.h"
#include "x:\cpa\main\inc\_editid.h"
#include "OIT/Edit_IPO.hpp"
#include "IPO_Dlgs.h"
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/


/*=======================================================================================
	Query action definition 
 =======================================================================================*/

#define C_IPO_dwLoadPhysicalObjectClass	1

//ROMTEAM WorldEditor (Cristian Stegaru 11/97)
#define C_IPO_uiCreateITModel			2
class EditorPOClass;
//ENDROMTEAM WorldEditor (Cristian Stegaru)
 
//CPA2 Stegaru Cristian 98-04
static char szITObjectsExt[] = ".ito";
//End CPA2 Stegaru Cristian 98-04
 
/*===========================================================================
*		Description:	IPO DLL Interface 
*		Creation date:	22/05/97
*		Author:			Vincent Lhullier
*---------------------------------------------------------------------------
*		Revision date:  18/08/97		Author: Shaitan       
*=========================================================================*/

class IPOInterface : public CPA_ObjectDLLBase
{
  private:
	CSplitFrame					*m_p_oLeftFrame;
	CPA_DialogList				*m_p_oDialogList;
	CPhysicalObjectClassDialog	*m_p_oPOClassDlg;
	CIPOEditionDialog			*m_p_oIPOEditDlg;

	BOOL						m_bAllClassCreated;
	EditorIPO					*m_p_oSelectedIPO;
	CPA_BaseObject				*m_p_oSelectedSuperObject;

//ROMTEAM WorldEditor (Cristian Stegaru 11/97)
	EditorPOClass				*m_pEPOInxTriangle;
//ENDROMTEAM WorldEditor (Cristian Stegaru)
	//CPA2 Stegaru Cristian 98-04
	CStringList					m_lstOfInitialITObjects;
	//End CPA2 Stegaru Cristian 98-04

//ANNECY Shaitan Correction (15/04/98) {
public:
	BOOL						m_b3DView;
	BOOL						m_bMainDeviceWasSwapped;
	DEV_Device					*m_p_oMainDevice;
//ENDANNECY Shaitan Correction }

// CPA2 ASilvescu 98-04-14
public:
	CPA_SuperObject	*m_pSelectedSPO;
	GEO_tdxHandleToMatrix m_SPOMatrix;
	GEO_tdxHandleToMatrix m_SPOGlobelMatrix;
// CPA2 ASilvescu 98-04-14

  public:

    IPOInterface (void);

//ANNECY Shaitan Correction (15/04/98) {
	BOOL					fn_bIs3DView	(void) { return m_b3DView; }
	void					fn_vSet3DView	(BOOL b3DView);
//ENDANNECY Shaitan Correction }

	// ==> Inits
    void					fn_vJustAfterRegistered		(void);
    void					fn_vConstruct				(void);
    
	// ==> Reinit world
    void					fn_vOnChangeRoot			(void);
    void					fn_vOnChangeWorld			(void);
    void					fn_vOnChangeDevice			(void);

	// ==> Editor <-> Engine
	void					fn_vBeforeEngine			(void);
    void					fn_vBeforeEditor			(void);

	// ==> Current Editor 
    tdePermission			fn_eAcceptNewEditor			(CPA_EditorBase *pNewDLL)	{ return C_CloseBefore; }

    BOOL					fn_bCanActivateEditor		(CPA_List<CPA_BaseObject> *pParam);
    BOOL					fn_bCanCloseEditor			(void);

    void					fn_vOnActivateEditor		(CPA_List<CPA_BaseObject> *pParam, BOOL bBackActivated=FALSE);
    void					fn_vOnCloseEditor			(void);

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


	// ==> Menus 
    BOOL					fn_bDefineSubMenu			(EDT_SubMenu *p_oEDTSubMenu);
    void					_OnSubMenuCommand			(EDT_SubMenu *p_oEDTSubMenu, UINT uiMsgID);

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

	// ==> Hierarchy Inits
	void					fn_vInitListsOfModels		(void);
	void					fn_vInitListByType			(CPA_World *pWorld);
	BOOL					fn_bCanHandleThisType		(long lEngineType);

	// ==> Hierarchy Build
	CPA_SuperObject			*GetNewEditorInstance		(HIE_tdxHandleToSuperObject hEngineInstance);
	void					fn_vBuildNewEditorInstance	(CPA_SuperObject *pEditorInstance, HIE_tdxHandleToSuperObject hEngineInstance);
	void					fn_vUpdateEditorInstance	(CPA_SuperObject *pEditorInstance, HIE_tdxHandleToSuperObject pEngineInstance);

	// ==> models & instances 
	tdeTypeSO				GetTypeInstance				(CString csTypeName, CString csModelName);
//ANNECY Shaitan EmptySectors 25/02/98
	tdeSaveStatus			GetStatusInstance			(CString csTypeName, CString csModelName);
//ENDANNECY Shaitan EmptySectors
	CPA_SuperObject			*GetNewInstance				(CString csTypeName, CString csModelName, CPA_SuperObject *pParent);
	CPA_BaseObject			*Duplicate					(CPA_BaseObject *pObject, CPA_SuperObject *pNewSuperObject);

	// ==> Editor Modifs
	void					fn_vOnModifDelete			(CPA_List<EDT_SaveParents> *pListObjects, tdeTypeModif eType, tdeStatus eStatus);
	void					fn_vOnModifCopy				(CPA_List<EDT_SaveParents> *pListObjects, tdeTypeModif eType, tdeStatus eStatus);
	void					fn_vOnModifInsert			(CPA_SuperObject *pEdObj, CPA_SuperObject *pParent,tdstPosition *p_stPosition, tdeTypeModif eType, tdeStatus eStatus);
	void					fn_vOnModifMove				(CPA_List<EDT_SavePos> *pListObjects, CPA_List<EDT_SaveGlobalPos> *pListConcerned, tdeTypeModif eType, tdeStatus eStatus);
	void					fn_vOnSelect				(CPA_SuperObject *pEdObj, tdeTypeModif eType, tdeStatus eStatus);
	
	// ==> for Dialog List
	CPA_BaseObject			*GetDialogSelection			(CPA_DialogList *pDialog, CString csTypeName, tdeListDrawMode eDrawMode);
	void					GetListsForDialog			(CPA_DialogList *pDialog);
	void					fn_vInitDefaultParameters	(CPA_DialogList *pDialog);

	BOOL					fn_bOnSelChangeListObjects	(CPA_DialogList *pDialog, CString csListName, CPA_BaseObject *pSelectedObject, BOOL bUnselect);

	// ==> Bounding volume 
	void					fn_vComputeBoundingVolume	(CPA_BaseObject *pObj);
	ACP_tdxHandleOfObject	fn_hGetBoundingVolume		(CPA_BaseObject *pObj);

	// ==> Load 
	long					OnQueryAction				(CPA_EditorBase *p_oSender, WPARAM wQuery, LPARAM lParam);
	BOOL					fn_bLoadBaseObject			(CPA_BaseObject *p_oObject);

	// ==> specific functions 
	void					fn_vFindAllClasses			(void);
	BOOL					fn_bGetIPOFromListOrSelection( CPA_List<CPA_BaseObject> *_p_oListObjects );
	BOOL					fn_bGetIPOFromObject		( CPA_BaseObject *_p_oObject );

//ROMTEAM WorldEditor (Nicu 10/11/97) 
	BOOL		_OnLButtonDblClk (UINT nFlags, tdstMousePos *p_stPos, ACP_tdxIndex xIndex, HIE_tdstPickInfo *p_stPickInfo);
	BOOL        _OnMouseMove     (UINT nFlags, tdstMousePos * p_stPos, MTH3D_tdstVector * p_stObject);
	BOOL        _OnLButtonDown   (UINT nFlags, tdstMousePos * p_stPos, ACP_tdxIndex xIndex, HIE_tdstPickInfo * p_stObject);
	BOOL        _OnRButtonDown   (UINT nFlags, tdstMousePos * p_stPos, ACP_tdxIndex xIndex, HIE_tdstPickInfo * p_stObject);
	BOOL        _OnLButtonUp     (UINT nFlags, tdstMousePos * p_stPos);          // Called when the left button is released
	BOOL		_OnKeyDown		 (UINT _nChar , UINT , UINT);
	BOOL		_OnKeyUp		 (UINT _nChar , UINT , UINT);
	//CPA2 Stegaru Cristian 98-04
	EditorPOClass * mfn_pGetITClass () { return m_pEPOInxTriangle;}
    virtual void fn_vAfterSaveAll (void);
	CStringList & GetInitialITObjectsList () { return m_lstOfInitialITObjects;}
	//End CPA2 Stegaru Cristian 98-04

private:
	EditorPO*					mfn_vCreateCloneGeomPO (EditorPO *po);
	void						mfn_vCreateITDirectory (void);
//ENDROMTEAM WorldEditor (Nicu) 
	//CPA2 Stegaru Cristian 98-04
	void mfn_vLoadITObjects ();
	void mfn_vSaveITObjects ();
	CString mfn_csGetITObjectsFileName ();
	void mfn_vLoadBaseITObject (CPA_BaseObject *pObject, CString csITObjectName);
	//End CPA2 Stegaru Cristian 98-04

};

/*=======================================================================================
	DLL identity structure
 =======================================================================================*/

#undef extern
extern tdstDLLIdentity g_stIPOIdentity;


#endif //__IPO_INTF_HPP__