//
// Tools_GUIMenu_Widget_TextListBox.h
//
// Created by Richard Rice - 05/12/2006
// 
// Copyright (C) 2006 Rebellion, All Rights Reserved.
//


#ifdef ASURA_USE_PRAGMA_ONCE
    #pragma once
#endif


#ifndef _TOOLS_GUIMENU_WIDGET_TEXTLISTBOX_H_
#define _TOOLS_GUIMENU_WIDGET_TEXTLISTBOX_H_
#ifdef ASURA_USE_GUI_MENU_SYSTEM

#include "GUIMenu/Tools_GUIMenu_Widget_Base.h"


class Asura_GUIMenu_Widget_TextListBox;

class Tools_GUIMenu_Widget_TextListBox : public Tools_GUIMenu_Widget_Base
{
	typedef Tools_GUIMenu_Widget_Base PARENT;

	enum TOOLS_GUIMENU_TEXTLISTBOX_HORZ_JUSTIFY
	{
		HORZ_JUSTIFY_NONE,
		HORZ_JUSTIFY_LEFT,
		HORZ_JUSTIFY_CENTER,
		HORZ_JUSTIFY_RIGHT,

		HORZ_JUSTIFY_MAX
	};

	enum TOOLS_GUIMENU_TEXTLISTBOX_VERT_JUSTIFY
	{
		VERT_JUSTIFY_NONE,
		VERT_JUSTIFY_CENTER,
		VERT_JUSTIFY_BOTTOM,

		VERT_JUSTIFY_MAX
	};

public :
	Tools_GUIMenu_Widget_TextListBox(Asura_GUIMenu_Widget_TextListBox* pxAsuraListBox,Tools_GUIMenu_Root* pxToolsParent);

	virtual ~Tools_GUIMenu_Widget_TextListBox();

	virtual void InitialiseNewItem();
	virtual void Copy(const Tools_GUIMenu_Root* pxSource);

	virtual void Update();

protected :
	virtual void AddOverlayControls(Asura_Overlay* pxOverlay,Asura_Vector_2& xOffset);
	virtual void UpdateOverlayControls(Asura_Overlay* pxOverlay);
	virtual void SetRectangle(const Asura_Bounding_Rectangle& xRect);
	virtual u_int GetFlagsToEdit() const;
	const char* GetLocalDataFlagName(u_int uFlagValue) const;

	virtual void CopyToAsura();
	virtual void CopyFromAsura();

	virtual bool IsNavExitSupported(int iLink) const;
	virtual void SetFont(const char* szFont);
private :

	// update CurrentHorz(Vert)JustifyIndex from argument
	void CopyTextJustificationFromFlags( const u_int iFlags );
	
	// update argument from CurrentHorz(Vert)JustifyIndex 
	const u_int CopyTextJustificationToFlags( u_int& iFlags );

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

	OVERLAY_VOID_CALLBACK(ChooseFont)

	OVERLAY_BOOL_CALLBACK(CanEditWidth)
	OVERLAY_BOOL_CALLBACK(CanEditHeight)
	OVERLAY_BOOL_CALLBACK(CanEditMaxEntries)
	OVERLAY_BOOL_CALLBACK(CanEditMaxDisplayed)
	OVERLAY_BOOL_CALLBACK(CanEditFlash)
	OVERLAY_BOOL_CALLBACK(CanEditTextRenderFlags)
	OVERLAY_BOOL_CALLBACK(CanEditInputRepeat)
	OVERLAY_BOOL_CALLBACK(CanEditFont)
	OVERLAY_BOOL_CALLBACK(CanEditPopulationFunction)
	OVERLAY_BOOL_CALLBACK(CanEditCommandManager)

	#undef OVERLAY_VOID_CALLBACK
	#undef OVERLAY_BOOL_CALLBACK

	Asura_GUIMenu_Widget_TextListBox* m_pxAsuraListBox;

	u_int m_uMaxAllowedEntries;
	u_int m_uMaxDisplayedEntries;

	int	  m_iCurrentHorzJustifyIndex;
	int	  m_iCurrentVertJustifyIndex;
	bool  m_bJustifyChanged;

	bool  m_bMaxActionsChanged;

	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;

	Asura_RGBA m_xFlashColour;
	bool m_bFlashColourChanged;
	bool m_bFlashTimeChanged;
	float m_fFlashTime;
	float m_fFontScale;

	float m_fInitialRepeatDelay;
	float m_fSecondaryRepeatDelay;
	bool  m_bInputDelayChanged;
	float m_fScrollRate;
	bool  m_bWordWrap;
	bool  m_bResizeFont;

	static int s_iMostRecentSelectedFont;
};




#endif //ASURA_USE_GUI_MENU_SYSTEM
#endif //_TOOLS_GUIMENU_WIDGET_TEXTLISTBOX_H_
