#pragma once

#include "../Base.h"
#include "../Font.h"
#include <Widgets/Textbox/TextboxBlueprint.h>
#include "Placeholder.h"

namespace gorgon { namespace widgets {

	class TextboxElement;

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

	class TextboxElement : public gge::widgets::textbox::Blueprint::Element, public Base {
		friend TextboxElement *LoadTextboxElement(gorgon::Base *parent, File &file, std::istream &in, int Size);
	public:
		typedef gge::widgets::textbox::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;

	protected:
		FontInitiator font, selectedfont;
	};


	class Textbox;

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

	class Textbox : public gge::widgets::textbox::Blueprint, public Base {
		friend 	Textbox *LoadTextbox(gorgon::Base *parent, File &file, std::istream &in, int Size);
	public:
		Textbox() {
			gge::utils::CheckAndDelete(CaretPlace);
			CaretPlace=new Placeholder;
		}

		typedef gge::widgets::textbox::Blueprint parenttype;

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

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

		void Update() { updatemapping(); }

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

		using gorgon::Base::Subitems;
	};

}}
