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

#ifndef __T3DINTERF_HPP__
#define __T3DINTERF_HPP__

#ifdef ACTIVE_EDITOR

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

class CPA_SuperObject;
class Evt_Editor;
class CPA_World;
class CPA_Contact;
class DEV_MultiDevice;
class Tool3D_FRMBaseMenu;
class Tool3D_World;

//Stefan Dumitrean 26-05-98
class Tool3D_Frame;
//End Stefan Dumitrean 26-05-98

class CAnimationView;
class CPA_Family;
class CPA_Animation;
class EditorObjectTable;

// Query Info
#define C_wTool3D_QI_CanOpenChar    1
#define C_wTool3D_QI_CanOpenMod     2
#define C_wTool3D_QI_CanOpenGeom    3
#define C_wTool3D_QI_CanOpenTable   4
#define C_wTool3D_QI_CanOpenViewer  5
#define C_wTool3D_QI_CanOpenObject  6

#define C_wTool3D_QI_GetState       10
#define C_wTool3D_QI_GetWorld       11
#define C_wTool3D_QI_GetDevice      12
#define C_wTool3D_QI_GetContact     13

// Type of Tool used
#define C_wTool3D_None          0
#define C_wTool3D_Char          1
#define C_wTool3D_Mod_Object    2
#define C_wTool3D_Mod_List      3
#define C_wTool3D_Table         4
#define C_wTool3D_Geom_Object   5
#define C_wTool3D_Viewer        6
#define C_wTool3D_Object        7

// General Actions
// Actions for 3DModTool
#define C_wTool3D_QA_ShowGrid           11
#define C_wTool3D_QA_HideGrid           12
#define C_wTool3D_QA_ShowSelect         13
#define C_wTool3D_QA_HideSelect         14
#define C_wTool3D_QA_NewChar            20
#define C_wTool3D_QA_NewSuperObject     21
#define C_wTool3D_QA_NewTable           22
#define C_wTool3D_QA_NewObject          23

typedef struct tdst_VW_ObjInfo_
{
    CPA_SuperObject             *m_p_oSuperObject;   // target object
    BOOL                        m_bUsePos;      //
    POS_tdstCompletePosition    stMatrix;
} tdst_VW_ObjInfo;

//----------------------------------------------------------
// Tool DLL interface class
//----------------------------------------------------------
class Tool3D_Interface : public CPA_ToolDLLBase
{
private:
    WORD                         m_wTypeOfTool;
    CPA_SuperObject             *m_p_InitialRoot;           // just reference
    Tool3D_World                *m_p_Tool3DWorld;           // created Here
    CPA_Contact                 *m_p_Tool3DContact;         // created Here
    DEV_MultiDevice3D           *m_p_Tool3DMultiDevice;     // created Here
    DEV_MultiDevice             *m_p_PreviousMultiDevice;
    Tool3D_FRMBaseMenu          *m_p_FRMBase;               // created here
    FRMBaseMenu                 *m_p_PreviousFRMBase;
    CPA_List<tdst_VW_ObjInfo>    m_oListOfVWObjInfo;
    CString                      m_csLastSelectMode;
	GLI_tdxHandleToLight	     m_hLightUp;
	GLI_tdxHandleToLight	     m_hLightDown;
    CPA_SuperObject             *m_p_oSprObjActor;
    CAnimationView              *m_p_oAnimView;
//Stefan Dumitrean 26-05-98
//	FRMBase                     *m_p_oAnimFrame;
	Tool3D_Frame				*m_p_oAnimFrame;
	CPA_Family					*m_p_CurrentFamily;
	BOOL						 m_bAnimPlayerInvoked;
//End Stefan Dumitrean 26-05-98
	CPA_KeyActionConfiguration	*m_p_oKeyboard;

public:
//Stefan Dumitrean 27-05-98
	virtual void GetListsForDialog(CPA_DialogList *pDialog);
	virtual void fn_vInitDefaultParameters(CPA_DialogList *pDialog);
	virtual BOOL fn_bOnButtonTest( CPA_DialogList *pDialog, CString csTypeName, tdeListDrawMode eDraw );
	virtual CPA_BaseObject* GetDialogSelection (CPA_DialogList *pDialog, CString csTypeName, tdeListDrawMode eDrawMode);
	virtual BOOL fn_bOnSelChangeListObjects(CPA_DialogList *pDialog, CString csTypeName, CPA_BaseObject *pSelectedObject, BOOL bUnselect);
	virtual BOOL fn_bOnDblClkListObjects(CPA_DialogList *pDialog, CString csTypeName, CPA_BaseObject *pSelectedObject);
private:
	void fn_vOnActivateEditorAnim();
public:
//End Stefan Dumitrean 27-05-98

    Tool3D_Interface(void);
//    ~Tool3D_Interface(void);

// ACP MEssages Functions overload
//  BOOL    fn_bPreTranslateMessage(MSG *);
//  void    fn_vJustAfterRegistered(void);
    void    fn_vConstruct(void);
//  void    fn_vRefreshDatas(void);
//  void    fn_vAddObjectsToDraw(GLD_tdstViewportAttributes *, GLI_tdstLight *);
//  void    fn_vAddObjectsToDraw2(GLD_tdstViewportAttributes *, GLI_tdstLight *);
    BOOL    fn_bAcceptToRunEngine(void) { return (m_wTypeOfTool==C_wTool3D_None); }
//  void    fn_vBeforeEngine(void);
    void    fn_vBeforeEditor(void);
//  void    fn_vHasLostFocus(void);
//  BOOL    fn_bHasGainedFocus(void);
//  BOOL    fn_bAcceptToExit(void);
    void    fn_vJustBeforeClosing(void);

	BOOL _OnMouseMove	  (UINT nFlags, tdstMousePos *p_stPos, MTH3D_tdstVector *p_stVect);
    BOOL _OnLButtonDblClk (UINT nFlags, tdstMousePos *p_stPos, ACP_tdxIndex xIndex, HIE_tdstPickInfo *p_stPickInfo);
    BOOL _OnRButtonDblClk (UINT nFlags, tdstMousePos *p_stPos, ACP_tdxIndex xIndex, HIE_tdstPickInfo *p_stPickInfo);
    BOOL _OnLButtonDown	  (UINT nFlags, tdstMousePos *p_stPos, ACP_tdxIndex xIndex, HIE_tdstPickInfo *p_stPickInfo);
    BOOL _OnRButtonDown	  (UINT nFlags, tdstMousePos *p_stPos, ACP_tdxIndex xIndex, HIE_tdstPickInfo *p_stPickInfo);
    BOOL _OnLButtonUp	  (UINT nFlags, tdstMousePos *p_stPos);
	BOOL _OnRButtonUp	  (UINT nFlags, tdstMousePos *p_stPos);

  // Current Editor
	tdePermission fn_eAcceptNewEditor	(CPA_EditorBase *pNewEditor);
	BOOL          fn_bCanActivateEditor	(CPA_List<CPA_BaseObject> *pParams);
	BOOL          fn_bCanCloseEditor	(void);

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

    long    OnQueryAction   (CPA_EditorBase*, WPARAM, LPARAM);
    long    OnQueryInfos    (CPA_EditorBase*, WPARAM, LPARAM);
    long    OnQueryOpen     (CPA_EditorBase*, WPARAM, LPARAM);
    long    OnQueryClose    (CPA_EditorBase*, WPARAM, LPARAM);

// 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);

protected:
    BOOL    fn_bTypeOfToolOK                (long _wType);
    BOOL    fn_bCanUseObject                (long _wType, long _lParam);
    BOOL    fn_bCanOpenTool                 (long _wType);
    BOOL    fn_bToolActive                  (long _wType);
    void    mfn_vAddAnObject                (CPA_SuperObject *_p_oSprObj, BOOL _bUsePos = TRUE);
    void    mfn_vAddAListOfSuperObject      (CPA_List<CPA_SuperObject> *_p_oList, BOOL _bUsePos = TRUE);
    void    mfn_vEditViewerContent          (void);
    void    mfn_vCenterCamera               (DEV_Device *p_oDevice, CPA_SuperObject *_p_oSprObj);
    void    mfn_vCenterCameraOnTarget       (tdst_VW_ObjInfo *_p_stObjInfo);
    void    mfn_vRestoreCameraOnTarget      (int _iTarget);
    void    mfn_vResetViewerContent         (void);
    void    mfn_vOpenAnim                   (CPA_SuperObject *_p_oSprObjActor);
    BOOL    mfn_bFindInfoAboutActor         (CPA_SuperObject *_p_oSprObj, CPA_Family **_p_p_oFamily,
                                             CPA_Animation **_p_p_oAnim, EditorObjectTable **_p_p_oObjectTable,
                                             unsigned short *_p_uwFrame);
};

extern tdstDLLIdentity g_stTool3DIdentity;

#endif // ACTIVE_EDITOR
#endif // __T3DINTERF_HPP__