// CXMLStorageForm.h
//

#if !defined(_XMLFORMINFO_H_)
#define _XMLFORMINFO_H_

#include <map>
#include <string>
#include "XmlSerializable.h"

using namespace std;

class CXmlBaseFormItem;
class CXmlFormItem_Static;
class CXmlFormItem_TextBox;
class CXmlFormItem_ComboBox;
class CXmlFormItem_CheckBox;

typedef map<cmString, CXmlBaseFormItem*> FormItemList;
 
class CXmlFormInfo: public CXmlSerializable
{
public:
	CXmlFormInfo();
	virtual ~CXmlFormInfo();

	// implementation of CXmlSerializable
	//
public:
	virtual bool BuildFromXml(IXMLDOMNode* node);
	virtual bool AppendToDOMDocument(IXMLDOMDocument2* xmlDoc, IXMLDOMElement* parentElement);

public:
	
	void Reset();
	
	CXmlFormItem_Static* AddStatic(const cmString& name);
	CXmlFormItem_TextBox* AddTextBox(const cmString& name);
	CXmlFormItem_ComboBox* AddComboBox(const cmString& name);
	CXmlFormItem_CheckBox* AddCheckBox(const cmString& name);

	void DeleteItem(DWORD id);
	CXmlBaseFormItem* GetItemById(DWORD id);

	FormItemList* GetItemList();

	virtual cmString GetXmlNodeName() {return _T("FormInfo");}

protected:
	
	virtual void Clear();
	virtual void SetDefaults();

	void AddFormItem(CXmlBaseFormItem* newItem);

	FormItemList formItems_;

	DWORD idCounter_;
};

#endif //!defined(_XMLFORMINFO_H_)
