// XmlMemberGui_Double.cpp: implementation of the CXmlMemberGui_Double class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "XmlMemberGui_Double.h"
#include "XmlBaseElement.h"

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

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CXmlMemberGui_Double::CXmlMemberGui_Double():
	displayMode_(enDoubleMemberDisplayMode_None)
{
}

CXmlMemberGui_Double::~CXmlMemberGui_Double()
{
	Clear();
}

void CXmlMemberGui_Double::Clear()
{
	displayMode_ = enDoubleMemberDisplayMode_None;
}

bool CXmlMemberGui_Double::BuildFromXml(IXMLDOMNode* node)
{
	Clear();
	
	ExtractMemberNode(node, _T("DisplayMode"), (int&)displayMode_);	
		
	return true;
}

bool CXmlMemberGui_Double::AppendToDOMDocument(IXMLDOMDocument2* xmlDoc, IXMLDOMElement* parentElement)
{
	IXMLDOMElement* newElement;
	map<cmString, cmString>::iterator it;
	HRESULT hr;

	hr = xmlDoc->createElement(CComBSTR((const TCHAR*)GetXmlNodeName()), &newElement);

	AppendMemberNode(_T("DisplayModeStr"), CXmlBaseElement::DoubleMemberDisplayMode2String(displayMode_), newElement, xmlDoc);
	AppendMemberNode(_T("DisplayMode"), (int)displayMode_, newElement, xmlDoc);
	
	IXMLDOMNode* newOutNode;

	if (parentElement)
		hr = parentElement->appendChild(newElement, &newOutNode);
	else
		hr = xmlDoc->appendChild(newElement, &newOutNode);	
	
	newOutNode->Release();
	
	return true;
}

void CXmlMemberGui_Double::SetDisplayMode(enDoubleMemberDisplayMode displayMode)
{
	displayMode_ = displayMode;
}

enDoubleMemberDisplayMode CXmlMemberGui_Double::GetDisplayMode() const
{
	return displayMode_;
}

void CXmlMemberGui_Double::SetDefaults()
{
	displayMode_ = enDoubleMemberDisplayMode_None;
}

