/// \file
/// \author Matthew Allen

#ifndef _XML_TREE_UI_H_
#define _XML_TREE_UI_H_

#include "lgi/common/Variant.h"
#include "lgi/common/List.h"
#include "lgi/common/Tree.h"

/// This class allows you to serialize data between the user interface and a
/// LDom instance. Useful for storing user visible application settings in
/// XML or an optons file.
class LXmlTreeUi
{
	class LXmlTreeUiPriv *d;

public:
	LXmlTreeUi();
	virtual ~LXmlTreeUi();

	typedef LListItem *(*CreateListItem)(void *User);
	typedef LTreeItem *(*CreateTreeItem)(void *User);

	/// Create attribute <-> UI element mapping for generic control
	void Map(const char *Attr, int UiIdent, int Type = GV_NULL);
	/// Create attribute <-> UI element mapping for GList control
	void Map(const char *Element, int UiIdent, CreateListItem Factory, const char *ChildElements, void *User = 0);
	/// Create attribute <-> UI element mapping for LTree control
	void Map(const char *Element, int UiIdent, CreateTreeItem Factory, const char *ChildElements, void *User = 0);
	/// Clear all mappings
	void EmptyMaps();
	/// Convert data to/from an XML tag
	virtual bool Convert(LDom *Tag, LViewI *ui, bool ToUI);
	/// Disable/enable all control
	void EnableAll(LViewI *ui, bool Enable);
	/// Empty all controls of text / value
	void EmptyAll(LViewI *ui);
	/// Returns true if the attribute is mapped
	bool IsMapped(const char *Attr);
};

#endif