// XmlMemberGui_Boolean.cpp: implementation of the CXmlMemberGui_Boolean class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "XmlMemberGui_Boolean.h"
#include "XmlBaseElement.h"

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

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

CXmlMemberGui_Boolean::CXmlMemberGui_Boolean():
	displayMode_(enBooleanMemberDisplayMode_None)
{
}

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

void CXmlMemberGui_Boolean::Clear()
{
	displayMode_ = enBooleanMemberDisplayMode_None;
}

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

bool CXmlMemberGui_Boolean::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::BooleanMemberDisplayMode2String(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_Boolean::SetDisplayMode(enBooleanMemberDisplayMode displayMode)
{
	displayMode_ = displayMode;
}

enBooleanMemberDisplayMode CXmlMemberGui_Boolean::GetDisplayMode() const
{
	return displayMode_;
}

void CXmlMemberGui_Boolean::SetDefaults()
{
	displayMode_ = enBooleanMemberDisplayMode_None;
}

