#ifndef _VGUI_WIDGET_H
#define _VGUI_WIDGET_H

/* widget.h */
#include <map>
#include <string>
#include <GL/gl.h>
#include <SDL/SDL.h>
#include "multiplay.h"
#include "textures.h"
#include "font.h"
#include "gamestate.h"
#include "settings.h"
#include "configfile.h"
#include "globals.h"

namespace VGUI
{
	class Location
	{
	public:
		Location() : xpct(0.0), ypct(0.0) { }
		~Location() { }
		Location(float _xpct, float _ypct) { xpct = _xpct; ypct = _ypct; }
		Location( const Location& rhs ) : xpct(rhs.xpct), ypct(rhs.ypct) { }
		const Location& operator=( const Location& rhs ) { if( this != &rhs ) { xpct = rhs.xpct; ypct = rhs.ypct; } return *this; }
		float GetXPercent() const { return xpct; }
		float GetYPercent() const { return ypct; }
		void SetXPercent( float new_xpct ) { xpct = new_xpct; }
		void SetYPercent( float new_ypct ) { ypct = new_ypct; }

	private:
		float xpct, ypct;
	};


	class Widget
	{
	public:
		Widget()
		  : center(Location()), name(""), text(""), type(""), tip(""), rel_width(0.0), rel_height(0.0),
		    enabled(false), selected(false), is_default(false), is_cancel(false),
		    has_icon(false), width_auto(false), height_auto(false),
		    font_size(4), color_r(1.0), color_g(1.0), color_b(1.0)
		  { }
		~Widget() { }
		Widget( const Widget& rhs )
		  : center(rhs.center), name(rhs.name), text(rhs.text), type(rhs.type), tip(rhs.tip), rel_width(rhs.rel_width), rel_height(rhs.rel_height),
		    enabled(rhs.enabled), selected(rhs.selected), is_default(rhs.is_default), is_cancel(rhs.is_cancel),
		    has_icon(rhs.has_icon), width_auto(rhs.width_auto), height_auto(rhs.height_auto),
		    font_size(rhs.font_size), color_r(rhs.color_r), color_g(rhs.color_g), color_b(rhs.color_b)
		  { }
		const Widget& operator=( const Widget& rhs )
		{
			if( this != &rhs )
			{
				center = rhs.center;
				name = rhs.name;
				text = rhs.text;
				type = rhs.type;
				tip = rhs.tip;
				rel_width = rhs.rel_width;
				rel_height = rhs.rel_height;
				enabled = rhs.enabled;
				selected = rhs.selected;
				is_default = rhs.is_default;
				is_cancel = rhs.is_cancel;
				has_icon = rhs.has_icon;
				width_auto = rhs.width_auto;
				height_auto = rhs.height_auto;
				font_size = rhs.font_size;
				color_r = rhs.color_r;
				color_g = rhs.color_g;
				color_b = rhs.color_b;
			}
			return *this;
		}
		virtual void Save( void ) { }
		virtual void Draw( void ) { }
		virtual void Draw( float opacity ) { }
		virtual void IncValuePress( void ) { }
		virtual void DecValuePress( void ) { }
		virtual void IncValueRelease( void ) { }
		virtual void DecValueRelease( void ) { }
		virtual void HookIncValuePress( void ) { }
		virtual void HookDecValuePress( void ) { }
		virtual void HookIncValueRelease( void ) { }
		virtual void HookDecValueRelease( void ) { }
		virtual void HookRelease( void ) { }
		virtual void BackspacePress() { }
		virtual void DeletePress() { }
		virtual void BackspaceRelease() { }
		virtual void DeleteRelease() { }
		virtual string GetAction( void ) { return ""; }
		virtual string GetHook( void ) { return ""; }
		virtual int GetNumCols( void ) { return 0; }
		virtual void SetValue( bool val ) { }
		virtual void SetValue( string val ) { }
		virtual void SetValue( float val ) { }
		virtual void SetDefaultValue( bool val ) { }
		virtual void SetDefaultValue( string val ) { }
		virtual void SetDefaultValue( float val ) { }
		virtual void SetSetting( string new_setting ) { }
		virtual void SetSaved( bool new_saved ) { }
		virtual bool GetSaved() { return true; }
		virtual void SetNumCols( int new_num_cols ) { }
		virtual void TogValue( void ) { }
		virtual bool MouseOver( float x, float y ) { return false; }
		virtual void Press( void ) { }
		virtual void Release( void ) { }
		virtual string MousePress( float x, float y ) { return ""; }
		virtual string MouseRelease( float x, float y ) { return ""; }
		virtual void ResetValue() { }
		virtual void ClearCar() { }
		virtual void EnterText( SDLKey key ) { }
		virtual void GrabKey( SDLKey key ) { }
		virtual void GrabMouseMovement( string direction ) { }
		virtual void GrabMouseButton( int button_idx ) { }
		virtual void GrabJoyButton( Uint8 joy_idx, Uint8 joy_btn ) { }
		virtual void GrabJoyMove( Uint8 joy_idx, Uint8 joy_axis, bool joy_positive, float joy_value ) { }
		virtual void SelectIcon( unsigned int new_selected_icon ) { }
		virtual bool GetAdding() { return false; }
		virtual vector<string> SetOptionList() { vector<string> vs; return vs; }
		virtual void GetValueList( vector<string> &vs ) { vector<string> vs2; vs = vs2; }
		virtual void GetValueList( vector<int> &vi ) { vector<int> vi2; vi = vi2; }
		virtual void GetValueList( vector<float> &vf ) { vector<float> vf2; vf = vf2; }
		virtual void GetValueList( vector<bool> &vb ) { vector<bool> vb2; vb = vb2; }

		Location GetCenter() const { return center; }
		string GetName() const { return name; }
		string GetText() const { return text; }
		string GetType() const { return type; }
		string GetTip() const { return tip; }
		float GetRelWidth() const { return rel_width; }
		float GetRelHeight() const { return rel_height; }
		bool GetEnabled() const { return enabled; }
		bool GetSelected() const { return selected; }
		bool GetDefault() const { return is_default; }
		bool GetCancel() const { return is_cancel; }
		bool GetHasIcon() const { return has_icon; }
		bool GetWidthAuto() const { return width_auto; }
		bool GetHeightAuto() const { return height_auto; }
		int GetFontSize() const { return font_size; }
		float GetColorR() const { return color_r; }
		float GetColorG() const { return color_g; }
		float GetColorB() const { return color_b; }

		void SetCenter( Location new_center ) { center = new_center; }
		void SetName( string new_name ) { name = new_name; }
		void SetText( string new_text ) { text = new_text; }
		void SetType( string new_type ) { type = new_type; }
		void SetTip( string new_tip ) { tip = new_tip; }
		void SetRelWidth( float new_rel_width ) { rel_width = new_rel_width; }
		void SetRelHeight( float new_rel_height ) { rel_height = new_rel_height; }
		void SetEnabled( bool new_enabled ) { enabled = new_enabled; }
		void SetSelected( bool new_selected ) { selected = new_selected; }
		void SetDefault( bool new_is_default ) { is_default = new_is_default; }
		void SetCancel( bool new_is_cancel ) { is_cancel = new_is_cancel; }
		void SetHasIcon( bool new_has_icon ) { has_icon = new_has_icon; }
		void SetWidthAuto( bool new_width_auto ) { width_auto = new_width_auto; }
		void SetHeightAuto( bool new_height_auto ) { height_auto = new_height_auto; }
		void SetFontSize( int new_font_size ) { font_size = new_font_size; }
		void SetColor( float r, float g, float b ) { color_r = r; color_g = g; color_b = b; }

	protected:
		Location center;
		string name;
		string text;
		string type;
		string tip;
		float rel_width;
		float rel_height;
		bool enabled;
		bool selected;
		bool is_default;
		bool is_cancel;
		bool has_icon;
		bool width_auto;
		bool height_auto;
		int font_size;
		float color_r;
		float color_g;
		float color_b;
	};
}

#endif // _VGUI_WIDGET_H
