// XmlIcon.h: interface for the CXmlIcon class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(_XMLICON_H_)
#define _XMLICON_H_

#include "XmlSerializable.h"

class CXmlIcon : public CXmlSerializable 
{
public:
	CXmlIcon();
	CXmlIcon(const CXmlIcon& c);
	virtual ~CXmlIcon();

	CXmlIcon& operator=(const CXmlIcon& c);
	
	// implementation of CXmlSerializable
	//
public:
	virtual bool BuildFromXml(IXMLDOMNode* node);
	virtual bool AppendToDOMDocument(IXMLDOMDocument2* xmlDoc, IXMLDOMElement* parentElement);

	void Clear();
	void SetDefaults();

	void Copy(const CXmlIcon& c);
	
	static cmString GetXmlNodeName(){return _T("Icon");}

	void SetFileName(const cmString& fileName);
	cmString GetFileName() const;

	void SetKey(const cmString& key);
	cmString GetKey() const;

	HICON GetIconHandle16() const;
	HICON GetIconHandle32() const;

	bool LoadFile(const cmString& fileName);

	bool WriteToFile(const cmString& fileName);

protected:

	void ReleaseIconHandle();
	bool CreateIconHandle(const cmString& fileName);

	cmString fileName_;
	cmString originalPath_;
	cmString fileContent_;
	cmString key_;
	HICON hIcon16_;
	HICON hIcon32_;
};

#endif // !defined(_XMLICON_H_)
