// XmlMemberGui_String.cpp: implementation of the CXmlMemberGui_String class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "XmlMemberGui_String.h"
#include "XmlBaseElement.h"

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

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

CXmlMemberGui_String::CXmlMemberGui_String():
	displayMode_(enStringMemberDisplayMode_None)
{
}

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

void CXmlMemberGui_String::Clear()
{
	displayMode_ = enStringMemberDisplayMode_None;
}

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

bool CXmlMemberGui_String::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::StringMemberDisplayMode2String(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);	
   
	return true;
}

void CXmlMemberGui_String::SetDisplayMode(enStringMemberDisplayMode displayMode)
{
	displayMode_ = displayMode;
}

enStringMemberDisplayMode CXmlMemberGui_String::GetDisplayMode() const
{
	return displayMode_;
}

void CXmlMemberGui_String::SetDefaults()
{
	displayMode_ = enStringMemberDisplayMode_None;
}

