//
// Tools_GUIMenu_Widget_ListBox.h
//
// Created by RDM - 24 April 2007
//
// Copyright (C) 2007 Rebellion, All Rights Reserved.
//

#ifdef ASURA_USE_PRAGMA_ONCE
#pragma once
#endif

#ifndef __TOOLS_GUIMENU_WIDGET_LISTBOX_H__
#define __TOOLS_GUIMENU_WIDGET_LISTBOX_H__

/************/
/* Includes */
/************/

#ifdef ASURA_USE_GUI_MENU_SYSTEM

// tools
#include "GUIMenu/Tools_GUIMenu_Widget_Base.h"

/***********/
/* Classes */
/***********/

class Asura_GUIMenu_Widget_Carousel;
class Asura_GUIMenu_Widget_ListBox;
class Asura_GUIMenu_Widget_ListBoxEntry;

class Tools_GUIMenu_Widget_ListBoxEntry : public Tools_GUIMenu_Widget_Base
{
private:
	typedef Tools_GUIMenu_Widget_Base PARENT;

public:
	// constructor
	Tools_GUIMenu_Widget_ListBoxEntry(Asura_GUIMenu_Widget_ListBoxEntry* pxAsuraListBoxEntry,Tools_GUIMenu_Root* pxToolsParent);

	// public functions	
	virtual void Update();
	virtual void RenderUI();
	virtual void AddOverlayControls( Asura_Overlay* pxOverlay, Asura_Vector_2& xOffset );
	virtual void AddParentOverlayControls( Asura_Overlay* pxOverlay, Asura_Vector_2& xOffset, Tools_GUIMenu_Root* pxChild );
	virtual bool CanBeRenamed() const {return false;}
	virtual void Destroy();
	virtual void CopyDataForThisStoredInParent(const Tools_GUIMenu_Root* pxSource, Tools_GUIMenu_Root* pxDest);

	void SetName( const char* szNewName ); 

protected:
	// data
	Asura_GUIMenu_Widget_ListBoxEntry* m_pxAsuraListBoxEntry;
};


class Tools_GUIMenu_Widget_ListBox : public Tools_GUIMenu_Widget_Base
{
private: 
	typedef Tools_GUIMenu_Widget_Base PARENT;

public :
	// constructor
	Tools_GUIMenu_Widget_ListBox(Asura_GUIMenu_Widget_ListBox* pxAsuraListBox,Tools_GUIMenu_Root* pxToolsParent);
	~Tools_GUIMenu_Widget_ListBox();

	// public interface functions
	virtual void InitialiseNewItem();
	virtual void Copy(const Tools_GUIMenu_Root* pxSource);
	virtual void Update();
	virtual void Rename();
	virtual void RenderUI();
	void RenderOffset();

	void CopyPopulationFunction(const Tools_GUIMenu_Widget_ListBox* pxSourceListBox, Asura_Hash_ID uSourceID, Asura_Hash_ID uDestID);
	void CopyVisibilityFunction(const Tools_GUIMenu_Widget_ListBox* pxSourceListBox, Asura_Hash_ID uSourceID, Asura_Hash_ID uDestID);

protected :
	// helper functions
	virtual void AddOverlayControls(Asura_Overlay* pxOverlay,Asura_Vector_2& xOffset);
	virtual void SetRectangle(const Asura_Bounding_Rectangle& xRect);	
	virtual void CopyToAsura();
	virtual void CopyFromAsura();
	virtual u_int GetFlagsToEdit() const;
	virtual bool IsNavExitSupported(int iLink) const;

	const char* GetLocalDataFlagName(u_int uFlagValue) const;


	// static functions (kinda)
#define OVERLAY_VOID_CALLBACK(__FnName)\
	static void __FnName(int iThis){((Tools_GUIMenu_Widget_ListBox*)iThis)->__FnName();}\
	void __FnName();
#define OVERLAY_BOOL_CALLBACK(__FnName)\
	static bool __FnName(int iThis){return ((Tools_GUIMenu_Widget_ListBox*)iThis)->__FnName();}\
	bool __FnName();

	OVERLAY_BOOL_CALLBACK(CanEditWidth)
	OVERLAY_BOOL_CALLBACK(CanEditHeight)
	OVERLAY_BOOL_CALLBACK(CanEditMaxEntries)
	OVERLAY_BOOL_CALLBACK(CanEditMaxDisplayed)
	OVERLAY_BOOL_CALLBACK(CanEditInputRepeat)
	OVERLAY_VOID_CALLBACK(ConvertToCarousel)
	OVERLAY_BOOL_CALLBACK(CanEditFlashDetails)
	OVERLAY_BOOL_CALLBACK(CanEditOffsetVector)

#undef OVERLAY_VOID_CALLBACK
#undef OVERLAY_BOOL_CALLBACK

	// data
	Asura_GUIMenu_Widget_ListBox* m_pxAsuraListBox;
	Tools_GUIMenu_Widget_ListBoxEntry* m_pxToolsListBoxEntryTemplate;

	u_int m_uMaxAllowedEntries;
	u_int m_uMaxDisplayedEntries;

	const char** m_pszImageNames;
	bool  m_bDecImageChanged;
	int	  m_iCurrentDecImageIndex;
	bool  m_bIncImageChanged;
	int	  m_iCurrentIncImageIndex;
	const char** m_pszPathNames;
	bool  m_bScrollBarChanged;
	int	  m_iCurrentScrollBarIndex;

	bool  m_bMaxActionsChanged;

	float m_fInitialRepeatDelay;
	float m_fSecondaryRepeatDelay;
	bool  m_bInputDelayChanged;

	bool m_bOffsetVector_Downwards;
	bool m_bChangedOffsetVector_Downwards;
	bool m_bOffsetVector_Right;
	bool m_bChangedOffsetVector_Right;
	float m_fOffsetOri;
	bool m_bChangedOffsetOri;
	bool m_bLoopSelection;
	bool m_bCarousel;
	bool m_bAllowSubScroll;
};


#endif //ASURA_USE_GUI_MENU_SYSTEM

/***************/
/* End of File */
/***************/

#endif//__TOOLS_GUIMENU_WIDGET_LISTBOX_H__
