//
//	Copyright © 2006 Nemetschek North America 
//	All Rights Reserved.
//
// Created by Vladislav Stanev

#include "StdHeaders.h"

#include "DialogEventArgs.h"

using namespace VectorWorks::VWUI;

VWDialogEventArgs::VWDialogEventArgs(long dlgID, long ctrlID, void* pData)
{
	fDialogID			= dlgID;
	fpData				= pData;
	fbNegativeControlID	= ctrlID < 0;
	fControlID			= ctrlID >= 0 ? ctrlID : - ctrlID;
}

VWDialogEventArgs::~VWDialogEventArgs()
{
	fDialogID	= 0;
	fControlID	= 0;
	fpData		= NULL;
}

long VWDialogEventArgs::GetEventData() const
{
	long	data	= 0;
	
	if ( fpData ) {
		long*	pData	= (long*) fpData;
		data			= *pData;
	}

	return data;
}

EListBrowserEventType VWDialogEventArgs::GetListBrowserEvent(size_t& outRowIndex, size_t& outColumnIndex) const
{
	EListBrowserEventType	type		= kListBrowserEventType_Unknown;
	int						eventType	= 0;
	int						rowIndex	= 0;
	int						columnIndex	= 0;
	if ( ::GS_GetListBrowserEventInfo( gCBP, fDialogID, fControlID, eventType, rowIndex, columnIndex ) ) {
		type			= (EListBrowserEventType) eventType;
		outRowIndex		= rowIndex;
		outColumnIndex	= columnIndex;
	}

	return type;
}

bool VWDialogEventArgs::IsListBrowserDoubleClickEvent() const
{
	return fbNegativeControlID;
}

bool VWDialogEventArgs::IsPullDownNotification() const
{
	return this->GetEventData() == -1;
}

bool VWDialogEventArgs::IsCustomCtrlDoubleClickEvent() const
{
	return fbNegativeControlID;
}

bool VWDialogEventArgs::IsCustomCtrlRightClickEvent() const
{
	return this->GetEventData() == 1;	// right
}

bool VWDialogEventArgs::IsCustomCtrlMiddleClickEvent() const
{
	return this->GetEventData() == 2;	// middle
}


