#pragma once

#include <Widgets/Definitions.h>
#include <Widgets/Combobox/ComboboxBase.h>
#include "../Base.h"
#include "../File.h"
#include "../Game/Animation.h"
#include "ResizableObject.h"

namespace gorgon { namespace widgets {

	class Combobox;

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

	class Combobox : public gge::widgets::combobox::Blueprint, public Base {
		friend Combobox *LoadCombobox(gorgon::Base *parent, File &file, std::istream &in, int Size);
	public:

		virtual void Save(std::ostream &out) {
			auto start=WriteObjectStart(out, *this);


			auto propstart=WriteSectionStart(out, gge::widgets::GID::Combobox_Props);

			WriteTo(out, DefaultSize);
			WriteLink(Textbox, out);
			WriteLink(Listbox, out);
			WriteLink(Dropbutton, out);
			WriteTo(out, ListMargins);

			WriteEnd(out, propstart);

			WriteNames(out, *this, gge::widgets::GID::Combobox_Names, gge::widgets::GID::Combobox_Name);
			WriteSubItems(out, *this);


			WriteEnd(out, start);
		}

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

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

			if(Textbox || Listbox || Dropbutton)
				return;

			file.FindObject(textbox, Textbox);
			file.FindObject(listbox, Listbox);
			file.FindObject(dropbutton, Dropbutton);
		}

		using gorgon::Base::Subitems;

	};	


}}
