#ifndef __DRAGDROP_H__
#define __DRAGDROP_H__
 
#include "CPAMCapt.hpp"
 
/****************************************/
#ifndef CPA_EXPORT
#if defined(CPA_WANTS_IMPORT)
#define CPA_EXPORT __declspec(dllimport)
#elif defined(CPA_WANTS_EXPORT)
#define CPA_EXPORT __declspec(dllexport)
#else
#define CPA_EXPORT
#endif
#endif
/****************************************/
 
/**/
/*  Constants*/
/**/
#define C_ucMaxCWndRef  20          /* Max num of CWND references*/
 
#define WM_DRAGDROP_LOOSEFOCUS      WM_USER + 0x6100
#define WM_DRAGDROP_GAINFOCUS       WM_USER + 0x6101
#define WM_DRAGDROP_MOVE            WM_USER + 0x6102
#define WM_DRAGDROP_END             WM_USER + 0x6103
#define WM_DRAGDROP_SCROLL          WM_USER + 0x6104
 
/**/
/*  Typedef*/
/**/
typedef enum tdeDDError_
{
    E_DDERR_None = 0,
    E_DDERR_TooMuchRef,
    E_DDERR_UnknownRef
} tdeDDError;
 
typedef struct tdstDDRef
{
    HWND    hWnd;
    char    *p_szEditorName;
    UINT    uiDataType;
    BOOL    bCopyOnly;
} tdstDDRef;
 
/**/
/*  Class to communicate while doing a drag & drop*/
/**/
class CPA_EXPORT DD_Object : public CObject
#ifdef ACTIVE_EDITOR		/* MR0902*/
, public CPA_MouseCapturer
#endif
{
public:
    DD_Object(CWnd *pWnd = NULL, char *p_szEditorName = NULL, UINT uiDataType = 0, void *p_vData = NULL )
    {
        m_p_Owner = pWnd;
        m_p_szEditorName = p_szEditorName;
        m_uiDataType = uiDataType;
        m_p_vData = p_vData;
    }
 
private:
    CWnd    *m_p_Owner;         /* Owner of that object*/
    void    *m_p_vData;         /* Address of datas*/
    UINT    m_uiDataType;       /* A data type*/
    char    *m_p_szEditorName;  /* Editor that own the data*/
 
public:
    POINT   m_stMousePos;       /* Mouse pos while moving object*/
 
public:
    void    fn_vSetOwner(CWnd *p_stWnd)         { m_p_Owner = p_stWnd; }
    CWnd    *fn_p_stGetOwner(void)              { return m_p_Owner; }
    void    fn_vSetData(void *p_vData)          { m_p_vData = p_vData; }
    void    *fn_p_vGetData(void)                { return m_p_vData; }
    void    fn_vSetDataType(UINT uiType)        { m_uiDataType = uiType; }
    UINT    fn_uiGetDataType(void)              { return m_uiDataType; }
    void    fn_vSetEditorName(char *p_szName)   { m_p_szEditorName = p_szName; }
    char    *fn_p_szGetEditorName(void)         { return m_p_szEditorName; }
 /*any class deriving from CPA_MouseCapturer but not from CWnd must declare this method*/
 /*as non usable, the argued version must be used instead to provide for a custom CWnd pointer*/
 CWnd *m_p_oGrabCapture() { ASSERT(FALSE); return (CWnd *) NULL; }
};
 
/**/
/*  Protos*/
/**/
extern tdeDDError CPA_EXPORT    DD_eAddReference(HWND, char *, UINT, BOOL);
extern tdeDDError CPA_EXPORT    DD_eDelReference(HWND);
extern tdeDDError CPA_EXPORT    DD_eDelReferenceType(HWND, char *, UINT);
extern BOOL CPA_EXPORT          DD_bSearchReference(HWND, char *, UINT, BOOL *);
extern void CPA_EXPORT          DD_vDelAllReferences(void);
extern void CPA_EXPORT          DD_vRegisterRect(RECT *, HWND);
extern void CPA_EXPORT			DD_vSetScrollTime( UINT uiTime );
extern HWND CPA_EXPORT          DD_hBeginDragDrop(RECT *, DD_Object *);
 
#endif /* __DRAGDROP_H__*/
