#pragma once
#include "../Base.h"
#include <Widgets/WidgetRegistry.h>
#include "../Extended/Sound.h"
#include "../Folder.h"
#include "../Generic/DataArray.h"

namespace gorgon { namespace widgets {

	class WidgetRegistry;

	WidgetRegistry *LoadWidgetRegistry(Base *parent, File &file, std::istream &in, int Size);

	class WidgetRegistry : public gge::widgets::WidgetRegistry, public Base {
		friend WidgetRegistry *LoadWidgetRegistry(Base *parent, File &file, std::istream &in, int Size);
	public:
		typedef gge::widgets::WidgetRegistry parenttype;

		WidgetRegistry();
		
		virtual void Save(std::ostream &out);

		virtual GID::Type GetGID() const {
			return gge::widgets::GID::WR;
		}

		template<class T_>
		T_ &Get(int index) {
			return dynamic_cast<T_&>(Subitems[index]);
		}

		virtual void Prepare(gge::GGEMain &main, File &file);

		void AddIcon(const std::string &key, gge::animation::RectangularGraphic2DSequenceProvider &image);
		void AddPicture(const std::string &key, gge::animation::RectangularGraphic2DSequenceProvider &image);
		void AddSound(const std::string &key, Sound &snd);

		using gorgon::Base::Subitems;

		Folder *pointers;

	protected:
		DataArray 
			*info, 
			*fonts, 
			*colors
		;

		Folder 
			*buttons,
			*textboxes,
			*checkboxes,
			*labels,
			*listboxes,
			*sliders,
			*progressbars,
			*panels,
			*others,
			*separators,
			*borders,
			*icons,
			*pictures,
			*sounds
		;

	};
	
} }