#ifndef _CWINDOW_HPP_
#define _CWINDOW_HPP_

/*** SDL Header Files ***/
#include <SDL.h>    

/*** Custom Header Files ***/
#include "GUIHelpers/cObject.hpp"
#include "GUIHelpers/Enums.hpp"
#include "GUIHelpers/GUIUtility.hpp"

/*** DLL Header File ***/
#include "dllExport.h"

/*** Custom Header Files ***/
#include "../UtilityEngine/cString.hpp"

using UtilityEngine::cString;

namespace GUIEngine {
	class EXPORT_FROM_MYDLL cWindow : public GUIHelpers::cObject
	{
	protected:
		static const UtilityEngine::cString sNAME; /*= "windows";*/
		static GUIHelpers::Position sPOSITION; /*= Position(0, 0);*/
		static GUIHelpers::Size sSIZE; /*= Size(0, 0);*/
		static GUIHelpers::Padding sPADDING; /*= Padding(5, 5, 5, 5);*/
		static GUIHelpers::RGBA sCOLOUR; /*= { 100, 100, 100, 255 };*/

		static GUIHelpers::eAlign sALIGN; /*= GUIHelpers::eAlign::CENTER;*/
		static GUIHelpers::eLayout sLAYOUT; /*= FILL_PARENT*/
		static GUIHelpers::eOrientation sORIENTATION; /*= GUIHelpers::eOrientation::NONE;*/

	protected:
		cWindow( cWindow* parent = nullptr, const signed int id = -1, const GUIHelpers::eOrientation& orientation = sORIENTATION, const GUIHelpers::eAlign& align = sALIGN,
			const GUIHelpers::eLayout& layout = sLAYOUT, const GUIHelpers::Position& pos = sPOSITION, const GUIHelpers::Size& size = sSIZE, 
			const GUIHelpers::Padding& padding = sPADDING, const cString& name = sNAME );

	public:
		virtual ~cWindow();

	protected:
		virtual void Create( cWindow* parent = nullptr, const signed int id = -1, const GUIHelpers::eOrientation& orientation = sORIENTATION, const GUIHelpers::eAlign& align = sALIGN,
			const GUIHelpers::eLayout& layout = sLAYOUT, const GUIHelpers::Position& pos = sPOSITION, const GUIHelpers::Size& size = sSIZE,
			const GUIHelpers::Padding& padding = sPADDING, const cString& name = sNAME );

	public:
		///Functions
		virtual void Display();

		const bool Inside( const MathEngine::iVector2& location ) const;

		void AddChild( cWindow* obj );

		const bool RemoveChild( cWindow* obj );
		
		///Sets
		static void PositionDefault( const GUIHelpers::Position& pos );
		static void SizeDefault( const GUIHelpers::Size& size );
		static void PaddingDefault( const GUIHelpers::Padding& pad );
		static void AlignDefault( const GUIHelpers::eAlign& align );
		static void LayoutDefault( const GUIHelpers::eLayout& layout );
		static void OrientationDefault( const GUIHelpers::eOrientation& orientation );

		void setOrientation( const GUIHelpers::eOrientation& orientation = sORIENTATION );
		void setAlign( const GUIHelpers::eAlign& align = sALIGN );
		void setLayout( const GUIHelpers::eLayout& layout = sLAYOUT );
		void setPosition( const GUIHelpers::Position& pos = sPOSITION );
		void setSize( const GUIHelpers::Size& size = sSIZE );
		void setPadding( const GUIHelpers::Padding& padding = sPADDING );
		void setContentSize( const GUIHelpers::Size& content );
		void setName( const cString& name = sNAME );

		void setParent( cWindow* parent );

		///Gets
		const GUIHelpers::Position getCenter( const bool pad = true ) const;

		const GUIHelpers::eOrientation& getOrientation() const;
		const GUIHelpers::eAlign& getAlign() const;
		const GUIHelpers::eLayout& getLayout() const;
		const GUIHelpers::Position getPosition( const bool pad = true ) const;
		const GUIHelpers::Size getSize( const bool pad = true ) const;
		const GUIHelpers::Padding& getPadding() const;
		const GUIHelpers::Size& getContentSize() const;
		const cString& getName() const;

		const GUIHelpers::Size getChildrenSize( const cWindow* ignore = nullptr );

		cWindow* getParent();

		virtual const GUIHelpers::eType getType() const;

		virtual void Resize();
		virtual void RebuildLayout( const GUIHelpers::eLayout& layout );
		
		virtual void RePos();
		virtual void RebuildPos();

		virtual const GUIHelpers::RGBA getDebugColour() const;

	/*protected:*/
		std::vector<cWindow*>& getChildren();

	private:
		void Rebuild( cWindow* const parent, const GUIHelpers::eLayout& layout );

		void AddSize( int x, int y, GUIHelpers::Size& mySize ) const;

		void DebugDisplay() const;

	private:
		GUIHelpers::eOrientation m_orientation;// = GUIHelper::eOrientation::NONE;
		GUIHelpers::eAlign m_align;// = GUIHelper::eAlign::CENTER;
		GUIHelpers::eLayout m_layout;// = GUIHelper::eLayout::FILL_PARENT;
		GUIHelpers::Position m_pos;// = POSITION;
		GUIHelpers::Size m_size;// = SIZE;
		GUIHelpers::Padding m_padding;// = PADDING;
		GUIHelpers::Size m_content;// = m_size;
		cString m_name;// = NAME;

		std::vector<cWindow*> m_children;
		cWindow* mp_parent;// = nullptr;
	};/// END CLASS DEFINITION cBoxSizer
}/// END NAMESPACE DEFINITION GUIEngine
#endif/// END IFNDEF _CBOXSIZER_HPP_
