// Implementation file for the definition of a text characteristic
///////////////////////////////////////////////////////////////////////
#include "StdAfx.h"

#include "Data\CTL_DatT.hpp"

#include "CTL_ErO.hpp"

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

//Constructor / Destructor
//************************************************************************************
CTL_Editor_TextData::CTL_Editor_TextData(CString csScriptName,
																				 CTL_Editor_DataList *_pclParentList,
																				 CTL_Editor_Data *pclCurrentBaseData /*= NULL*/)
										: CTL_Editor_Data(CTL_DATA_TYPE__TEXT, 
																			csScriptName,
																			_pclParentList,
																			pclCurrentBaseData)
{

}

//************************************************************************************
CTL_Editor_TextData::~CTL_Editor_TextData()
{
}

//Member functions

//**************************************************************************************
//Function called to Init the data
void CTL_Editor_TextData::m_fn_vInitData()
{

}

//************************************************************************************
//Function called to read associated motor's data
void CTL_Editor_TextData::m_fn_vGetMotorData()
{
	m_csCurrentString = (CString)((char *)m_pub_fn_pvGetMotorData());
}

//************************************************************************************
//Function called to update associated motor's data
void CTL_Editor_TextData::m_fn_vUpdateMotorData(CTL_tdeUpdateReason eReason,
																								long _lUserDefinedReason /*= 0*/)
{

}

//************************************************************************
//Function called to update data with another one
void CTL_Editor_TextData::m_fn_vUpdateData(CTL_Editor_Data *pclSourceData,
																					 CTL_tdeUpdateReason eReason,
																					 long _lUserDefinedReason /*= 0*/)
{
	ERROR_ASSERT(pclSourceData->m_pub_fn_tdeGetDataType() == m_pub_fn_tdeGetDataType());

	m_csCurrentString = ((CTL_Editor_TextData *)pclSourceData)->m_csCurrentString;
//	m_fn_bSetLink(pclSourceData->m_fn_eGetLink());
	
	m_fn_vUpdateMotorData(eReason, _lUserDefinedReason);
}	

//************************************************************************
//Function called to get a string representing the value of the data
CStringList *CTL_Editor_TextData::m_fn_pcslFormatDataValueString()
{
	m_csStringList.RemoveAll();

	m_csStringList.AddTail(m_csCurrentString);

	return &m_csStringList;
}

//************************************************************************
//Function called to set the value of the data acoording to a string representing it
void CTL_Editor_TextData::m_fn_vSetValueWithString(CStringList *pcslValueStringList)
{
	ERROR_ASSERT(pcslValueStringList->GetCount() == 1);
	CString csValueString = pcslValueStringList->GetHead();
	
	m_csCurrentString = csValueString;

	m_fn_vUpdateMotorData();
}

//************************************************************************
//Function called to look if data has been modified (by motor for example)
void CTL_Editor_TextData::m_fn_vLookIfDataHasBeenModified()
{
	m_fn_vGetMotorData();

	m_pub_fn_vSetDataHasChanged(m_csCurrentString != m_csOldString);

	if ( m_pub_fn_bGetDataHasChanged() )
		m_csOldString = m_csCurrentString;
}

//////////////////////////////////////////////////////////////////////////////////////////////////////
// Method	: mfn_bEqualsModifiedDataOldValue 
// Date		: 98/06/24
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Description	:
// Author		: Stegaru Cristian - CPA
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Modification	: 
// Date			:
// By			:
//////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL CTL_Editor_TextData::mfn_bEqualsModifiedDataOldValue (CTL_Editor_Data *pModifiedData)
{
	ASSERT (pModifiedData);

	ERROR_ASSERT(pModifiedData->m_pub_fn_tdeGetDataType() == m_pub_fn_tdeGetDataType());

	return m_csCurrentString == ((CTL_Editor_TextData *)pModifiedData)->m_csOldString;
}



