// ItemDragTarget.cpp : implementation file
//

#pragma warning( disable : 4786 )		// long names generated by STL

#include "afxole.h"
#include "stdafx.h"
#include "demopaja.h"
#include "ItemDragTarget.h"
//#include "DropTarget.h"
#include "sizecbar.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CItemDragTarget

//IMPLEMENT_DYNCREATE(CItemDragTarget, COleDropTarget)

CItemDragTarget::CItemDragTarget() //:
//	m_hWndParent( 0 )
{
	// empty
}

CItemDragTarget::~CItemDragTarget()
{
/*	for( int i = 0; i < m_rActiveDockBars.size(); i++ ) {
		if( m_rActiveDockBars[i] == m_hWndParent ) {
			m_rActiveDockBars.erase( m_rActiveDockBars.begin() + i );
			break;
		}
	}*/
}


BEGIN_MESSAGE_MAP(CItemDragTarget, COleDropTarget)
	//{{AFX_MSG_MAP(CItemDragTarget)
		// NOTE - the ClassWizard will add and remove mapping macros here.
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CItemDragTarget message handlers

/*
void CItemDragTarget::RegisterDockBar( CWnd* pWnd )
{
	TRACE( "CItemDragTarget:  Registering: %x\n", pWnd->m_hWnd );
	m_hWndParent = pWnd->m_hWnd;
	m_rActiveDockBars.push_back( pWnd->m_hWnd );

	Register( pWnd );
}
*/

DROPEFFECT CItemDragTarget::OnDragOver(CWnd* pWnd, COleDataObject* pDataObject, DWORD dwKeyState, CPoint point) 
{
	// see, if the window exists in the list
/*	bool	bExists = false;
	for( int i = 0; i < m_rActiveDockBars.size(); i++ ) {
		TRACE( "CItemDragTarget:  Checking: %x against %x\n", pWnd->m_hWnd, m_rActiveDockBars[i] );
		if( m_rActiveDockBars[i] == pWnd->m_hWnd ) {
			bExists = true;
			break;
		}
	}

	if( bExists ) {
		CSizingControlBar*	pTgt = (CSizingControlBar*)pWnd;
		return pTgt->OnDragOver( pDataObject, dwKeyState, point );
	}*/

	if( pWnd->IsKindOf( RUNTIME_CLASS( CSizingControlBar ) ) ) {
		CSizingControlBar*	pTgt = (CSizingControlBar*)pWnd;
		return pTgt->OnDragOver( pDataObject, dwKeyState, point );
	}

	return DROPEFFECT_NONE;
}

BOOL CItemDragTarget::OnDrop(CWnd* pWnd, COleDataObject* pDataObject, DROPEFFECT dropEffect, CPoint point) 
{
	// see, if the window exists in the list
/*	bool	bExists = false;
	for( int i = 0; i < m_rActiveDockBars.size(); i++ ) {
		TRACE( "CItemDragTarget:  Checking: %x against %x\n", pWnd->m_hWnd, m_rActiveDockBars[i] );
		if( m_rActiveDockBars[i] == pWnd->m_hWnd ) {
			bExists = true;
			break;
		}
	}

	if( bExists ) {
		CSizingControlBar*	pTgt = (CSizingControlBar*)pWnd;
		return pTgt->OnDrop( pDataObject, dropEffect, point );
	}*/

	if( pWnd->IsKindOf( RUNTIME_CLASS( CSizingControlBar ) ) ) {
		CSizingControlBar*	pTgt = (CSizingControlBar*)pWnd;
		return pTgt->OnDrop( pDataObject, dropEffect, point );
	}


	return FALSE;
}
