// Copyright (C) 2002-2006 Nikolaus Gebhardt, Josh Turpen
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h

#ifndef _CGUIIMAGESKIN_H_
#define _CGUIIMAGESKIN_H_

#include "IGUISkin.h"
#include "irrString.h"
#include "ITexture.h"
#include "TAnimSpriteSceneNode.h"

namespace irr
{
namespace video
{
	class IVideoDriver;
}
namespace gui
{
	enum EGUI_ELEMENT_IMAGE_TYPE
	{
		EGEIT_BUTTON_PANE_STANDARD = 0,
		EGEIT_BUTTON_PANE_PRESSED,
		EGEIT_SUNKEN_PANE_FLAT,
		EGEIT_SUNKEN_PANE_SUNKEN,
		EGEIT_WINDOW_BACKGROUND,
		EGEIT_WINDOW_BACKGROUND_TITLEBAR,
		EGEIT_MENU_PANE,
		EGEIT_TOOLBAR,
		EGEIT_TAB_BUTTON,
		EGEIT_TAB_BODY,
		EGEIT_COUNT
	};


	class CGUIImageSkin : public IGUISkin
	{
	public:

		CGUIImageSkin(video::IVideoDriver* driver, scene::ISceneManager *scm, irr::ITimer *timer);

		//! destructor
		~CGUIImageSkin();

		//! loads the image file into the element type
		virtual bool Load(EGUI_ELEMENT_IMAGE_TYPE Type, core::stringc filename, s32 Ax,s32 Ay,s32 Aw,s32 Ah,s32 frmWidth,s32 frmHeight,bool useClrKey);

		virtual s32 getAnimationSpeed(EGUI_ELEMENT_IMAGE_TYPE Type);
		virtual void setAnimationSpeed(EGUI_ELEMENT_IMAGE_TYPE Type, s32 spd);

		virtual void setLoop(EGUI_ELEMENT_IMAGE_TYPE Type, bool l);
		virtual bool getLoop(EGUI_ELEMENT_IMAGE_TYPE Type);

		virtual void playForward(EGUI_ELEMENT_IMAGE_TYPE Type);
		virtual void playBackward(EGUI_ELEMENT_IMAGE_TYPE Type);

		virtual void resetAnimation(EGUI_ELEMENT_IMAGE_TYPE Type);

		//! returns default color
		virtual video::SColor getColor(EGUI_DEFAULT_COLOR color);

		//! sets a default color
		virtual void setColor(EGUI_DEFAULT_COLOR which, video::SColor newColor);

		//! returns default color
		virtual s32 getSize(EGUI_DEFAULT_SIZE size);

		//! sets a default size
		virtual void setSize(EGUI_DEFAULT_SIZE which, s32 size);

		//! returns the default font
		virtual IGUIFont* getFont(EGUI_DEFAULT_FONT which=EGDF_DEFAULT);

		//! sets a default font
		virtual void setFont(IGUIFont* font);

		//! Returns a default text.
		/** For example for Message box button captions:
		 "OK", "Cancel", "Yes", "No" and so on. */
		virtual const wchar_t* getDefaultText(EGUI_DEFAULT_TEXT text);

		//! Sets a default text.
		/** For example for Message box button captions:
		 "OK", "Cancel", "Yes", "No" and so on. */
		virtual void setDefaultText(EGUI_DEFAULT_TEXT which, const wchar_t* newText);

		//! draws a standard 3d button pane
		/**	Used for drawing for example buttons in normal state.
		It uses the colors EGDC_3D_DARK_SHADOW, EGDC_3D_HIGH_LIGHT, EGDC_3D_SHADOW and
		EGDC_3D_FACE for this. See EGUI_DEFAULT_COLOR for details.
		\param rect: Defining area where to draw.
		\param clip: Clip area.
		\param element: Pointer to the element which whiches to draw this. This parameter
		is usually not used by ISkin, but can be used for example by more complex
		implementations to find out how to draw the part exactly. */
		virtual void draw3DButtonPaneStandard(IGUIElement* element,
			const core::rect<s32>& rect,
			const core::rect<s32>* clip=0);

		//! draws a pressed 3d button pane
		/**	Used for drawing for example buttons in pressed state.
		It uses the colors EGDC_3D_DARK_SHADOW, EGDC_3D_HIGH_LIGHT, EGDC_3D_SHADOW and
		EGDC_3D_FACE for this. See EGUI_DEFAULT_COLOR for details.
		\param rect: Defining area where to draw.
		\param clip: Clip area.
		\param element: Pointer to the element which whiches to draw this. This parameter
		is usually not used by ISkin, but can be used for example by more complex
		implementations to find out how to draw the part exactly. */
		virtual void draw3DButtonPanePressed(IGUIElement* element,
			const core::rect<s32>& rect,
			const core::rect<s32>* clip=0);

		//! draws a sunken 3d pane
		/** Used for drawing the background of edit, combo or check boxes.
		\param element: Pointer to the element which whiches to draw this. This parameter
		is usually not used by ISkin, but can be used for example by more complex
		implementations to find out how to draw the part exactly.
		\param bgcolor: Background color.
		\param flat: Specifies if the sunken pane should be flat or displayed as sunken
		 deep into the ground.
		\param rect: Defining area where to draw.
		\param clip: Clip area.	*/
		virtual void draw3DSunkenPane(IGUIElement* element,
			video::SColor bgcolor, bool flat, bool fillBackGround,
			const core::rect<s32>& rect,
			const core::rect<s32>* clip=0);

		//! draws a window background
		/** Used for drawing the background of dialogs and windows.
		\param element: Pointer to the element which whiches to draw this. This parameter
		is usually not used by ISkin, but can be used for example by more complex
		implementations to find out how to draw the part exactly.
		\param titleBarColor: Title color.
		\param drawTitleBar: True to enable title drawing.
		\param rect: Defining area where to draw.
		\param clip: Clip area.
		\return Returns rect where to draw title bar text. */
		virtual core::rect<s32> draw3DWindowBackground(IGUIElement* element,
			bool drawTitleBar, video::SColor titleBarColor,
			const core::rect<s32>& rect,
			const core::rect<s32>* clip=0);

		//! draws a standard 3d menu pane
		/**	Used for drawing for menus and context menus.
		It uses the colors EGDC_3D_DARK_SHADOW, EGDC_3D_HIGH_LIGHT, EGDC_3D_SHADOW and
		EGDC_3D_FACE for this. See EGUI_DEFAULT_COLOR for details.
		\param element: Pointer to the element which whiches to draw this. This parameter
		is usually not used by ISkin, but can be used for example by more complex
		implementations to find out how to draw the part exactly.
		\param rect: Defining area where to draw.
		\param clip: Clip area.	*/
		virtual void draw3DMenuPane(IGUIElement* element,
			const core::rect<s32>& rect,
			const core::rect<s32>* clip=0);

		//! draws a standard 3d tool bar
		/**	Used for drawing for toolbars and menus.
		\param element: Pointer to the element which whiches to draw this. This parameter
		is usually not used by ISkin, but can be used for example by more complex
		implementations to find out how to draw the part exactly.
		\param rect: Defining area where to draw.
		\param clip: Clip area.	*/
		virtual void draw3DToolBar(IGUIElement* element,
			const core::rect<s32>& rect,
			const core::rect<s32>* clip=0);

		//! draws a tab button
		/**	Used for drawing for tab buttons on top of tabs.
		\param element: Pointer to the element which whiches to draw this. This parameter
		is usually not used by ISkin, but can be used for example by more complex
		implementations to find out how to draw the part exactly.
		\param active: Specifies if the tab is currently active.
		\param rect: Defining area where to draw.
		\param clip: Clip area.	*/
		virtual void draw3DTabButton(IGUIElement* element, bool active,
			const core::rect<s32>& rect, const core::rect<s32>* clip=0);

		//! draws a tab control body
		/**	\param element: Pointer to the element which whiches to draw this. This parameter
		is usually not used by ISkin, but can be used for example by more complex
		implementations to find out how to draw the part exactly.
		\param border: Specifies if the border should be drawn.
		\param background: Specifies if the background should be drawn.
		\param rect: Defining area where to draw.
		\param clip: Clip area.	*/
		virtual void draw3DTabBody(IGUIElement* element, bool border, bool background,
			const core::rect<s32>& rect, const core::rect<s32>* clip=0);

/**  Missing :

virtual void  drawIcon (IGUIElement *element, EGUI_DEFAULT_ICON icon, const core::position2di position, u32 starttime=0, u32 currenttime=0, bool loop=false, const core::rect< s32 > *clip=0)=0
  draws an icon, usually from the skin's sprite bank

virtual u32  getIcon (EGUI_DEFAULT_ICON icon)=0

virtual void  setIcon (EGUI_DEFAULT_ICON icon, u32 index)=0
*/

//! Returns a default icon
    u32 getIcon(EGUI_DEFAULT_ICON icon)
    {
        return 0 ;//Icons[icon];
    }

//! Sets a default icon
    void setIcon(EGUI_DEFAULT_ICON icon, u32 index)
    {
        //Icons[icon] = index;
    }

    void drawIcon(IGUIElement* element, EGUI_DEFAULT_ICON icon,
			const core::position2di position, u32 starttime, u32 currenttime,
			bool loop, const core::rect<s32>* clip)
{
//        if (!SpriteBank)
		return;

//	SpriteBank->draw2DSprite(Icons[icon], position, clip,
//			video::SColor(255,0,0,0), starttime, currenttime, loop, true);

}
    EGUI_SKIN_TYPE  getType () { return EGST_UNKNOWN ;}
  //;sets the sprite bank
    void  setSpriteBank (IGUISpriteBank *bank) {}
    IGUISpriteBank *  getSpriteBank () { return NULL; }

	private:

		video::SColor Colors[EGDC_COUNT];
		s32 Sizes[EGDS_COUNT];
		IGUIFont* Font;
		core::stringw Texts[EGDT_COUNT];
		video::IVideoDriver* Driver;

		scene::TAnimSpriteSceneNode *Sprites[EGEIT_COUNT];
		scene::ISceneManager *SceneManager;
		irr::ITimer *Timer;

		void drawSprite(scene::TAnimSpriteSceneNode *Sprite, const core::rect<s32> rect);
	};

} // end namespace gui
} // end namespace irr

#endif /* _CGUIIMAGESKIN_H_ */

