// XmlGuiCategoryInfoList.h
//

#if !defined(_XMLGUICATEGORYINFOLIST_H_)
#define _XMLGUICATEGORYINFOLIST_H_

#include <vector>
#include "XmlBaseElement.h"

using namespace std;

class CXmlGuiCategoryInfo;
class CXmlGuiCategoryField;
class CXmlClassInfo;

typedef vector<CXmlGuiCategoryInfo*> CategoryList;

class CXmlGuiCategoryInfoList: public CXmlBaseElement
{
public:
	CXmlGuiCategoryInfoList();
	virtual ~CXmlGuiCategoryInfoList();

	// implementation of XmlBaseElement
	//
	virtual bool BuildFromXml(IXMLDOMNode* node);
	virtual bool AppendToDOMDocument(IXMLDOMDocument2* xmlDoc, 
									 IXMLDOMElement* parentElement);
	cmString GetXmlNodeName() {return _T("GuiCategoryList");}

	CXmlGuiCategoryInfo* InsertCategory(int index);
	void MoveUpCategory(int index);
	void MoveDownCategory(int index);
	void RemoveCategory(int index);
	void RemoveCategory(const cmString& name);
	void RemoveCategory(CXmlGuiCategoryInfo* categoryInfo);

	int GetSize();
	CXmlGuiCategoryInfo* GetCategory(int index);
	CXmlGuiCategoryInfo* GetCategoryByCaption(const cmString& caption);
	CXmlGuiCategoryInfo* GetCategoryByName(const cmString& name);

	CXmlGuiCategoryField* GetFieldByMemberName(const cmString& memberName);
	CXmlGuiCategoryField* GetFieldByCaption(const cmString& caption);
	
	void Clear();

	void SetClassInfo(CXmlClassInfo* classInfo);

	void SetSorted(bool sorted);
	bool GetSorted() const;

protected:

	void MoveCategory(int oldIndex, int newIndex);

	CategoryList categories_;
	CXmlClassInfo* classInfo_;

	bool sorted_;
};

#endif //!defined(_XMLGUICATEGORYINFOLIST_H_)