#pragma once

#include "../Base.h"
#include "../Font.h"
#include <Widgets/Checkbox/CheckboxBlueprint.h>
#include "Placeholder.h"

namespace gorgon { namespace widgets {

	class CheckboxElement;

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

	class CheckboxElement : public gge::widgets::checkbox::Blueprint::Element, public Base {
		friend CheckboxElement *LoadCheckboxElement(gorgon::Base *parent, File &file, std::istream &in, int Size);
	public:
		typedef gge::widgets::checkbox::Blueprint::Element parenttype;

		virtual GID::Type GetGID() const {
			return parenttype::GetGID();
		}

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

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

		using gorgon::Base::Subitems;

		virtual ~CheckboxElement() {
			if(font.guid_theme==gge::utils::SGuid::Empty)
				Font=NULL;
		}

	protected:
		FontInitiator font;
	};


	class CheckboxLine;

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

	class CheckboxLine : public gge::widgets::checkbox::Blueprint::Line, public Base {
		friend CheckboxLine *LoadCheckboxLine(gorgon::Base *parent, File &file, std::istream &in, int Size);
	public:
		typedef gge::widgets::checkbox::Blueprint::Line parenttype;

		CheckboxLine() {
			Contents.t=0;
			WidthMode=gge::widgets::checkbox::Blueprint::Full;
			HeightMode=gge::widgets::checkbox::Blueprint::MaximumAvailable;
			Height=0;
			Align=gge::Alignment::Middle_Center;
		}

		virtual GID::Type GetGID() const {
			return parenttype::GetGID();
		}

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

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

		using gorgon::Base::Subitems;

	protected:
	};


	class CheckboxGroup;

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

	class CheckboxGroup : public gge::widgets::checkbox::Blueprint::Group, public Base {
		friend CheckboxGroup *LoadCheckboxGroup(gorgon::Base *parent, File &file, std::istream &in, int Size);
	public:
		typedef gge::widgets::checkbox::Blueprint::Group parenttype;

		virtual GID::Type GetGID() const {
			return parenttype::GetGID();
		}

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

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

		using gorgon::Base::Subitems;

		void Update() { updatemapping(); }

	protected:
	};


	class Checkbox;

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

	class Checkbox : public gge::widgets::checkbox::Blueprint, public Base {
		friend 	Checkbox *LoadCheckbox(gorgon::Base *parent, File &file, std::istream &in, int Size);
	public:
		Checkbox() {
		}

		typedef gge::widgets::checkbox::Blueprint parenttype;

		virtual GID::Type GetGID() const {
			return parenttype::GetGID();
		}

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

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

		using gorgon::Base::Subitems;
	};

}}
