///////////////////////////////////////////////////////////////////////////////
//
// File   : Tools_UI_Overrides_Filters.h
// Author : Andy Southgate
// Date   : 18-December-2008
//
// Copyright (C) 2008 Rebellion, All Rights Reserved.
//
///////////////////////////////////////////////////////////////////////////////

#ifdef ASURA_USE_PRAGMA_ONCE
#pragma once
#endif   // ifdef ASURA_USE_PRAGMA_ONCE



#ifndef __TOOLS_UI_OVERRIDES_FILTERS_H__
#define __TOOLS_UI_OVERRIDES_FILTERS_H__


#include "Interface/Asura_Dialog.h"
#include "Interface/Asura_Overlay.h"
#include "Interface/Asura_Overlay_System.h"

class Tools_UI_Overrides;

class Tools_UI_Overrides_Filter
{
	class FilterStringArray
	{
	public:
		FilterStringArray();
		~FilterStringArray();

		bool Allocate( const int iSize );
		void Free( void );
		bool Add( const char* const szString, const bool bCheckAlreadyAdded = true );
		const char* GetEntry( const int iEntry, const char* const szInvalid = "" );
		bool IsValid( void )					const	{ return( m_bValid ); }
		const char** GetArray( void )			const	{ return( (const char**)m_pszStrings ); }
		int GetCount( void )					const	{ return( m_iIndex ); }
		int GetSize( void )						const	{ return( m_iSize); }
		int Find( const char* const szString, const int iStartIndex = 0 )	const;

	private:
		int m_iSize;
		int m_iIndex;
		char** m_pszStrings;
		bool m_bValid;
	};

public:
	Tools_UI_Overrides_Filter();
	bool Init( Asura_Overlay* const pxOverlay, Asura_Tabs_Dialog* const pxTabsDialog, Asura_Vector_2 &xOffset, void (*pfnChanged)( int iUserData ), const int iUserData, bool( *pfnIsEnabled )( int ) );
	bool HasChanged( void )				const	{ return( m_iIndex != m_iLastIndex ); }
	void ResetChanged( void )					{ m_iLastIndex = m_iIndex; }
	const char* GetFilter( void );
	bool Populate( const int iNumEntries, const Asura_String *pxNameArray, const char* const szPrefix, const char* const szPrefix2 );
	void Clear( void );
	int FindFilter( const char* const szFilters )	const;
	void SetIndex( const int iIndex );
	void SetIndex( const char* const szFilters );

private:
	Asura_DropDown_List_Dialog* m_pxDropDownList;
	int m_iIndex;
	int m_iLastIndex;
	FilterStringArray m_xFiltersStringArray;

	static const int s_iDefaultListSize;
	static const char* const s_pszDefaultList[];
};


class Tools_UI_Overrides_FilterSet
{
public:
	Tools_UI_Overrides_FilterSet( Tools_UI_Overrides*	pxParent, Asura_Overlay* const pxOverlay, Asura_Tabs_Dialog* const pxTabsDialog, Asura_Vector_2 &xOffset, void( *pfnChanged )( void* const pxUserData ), void* const pxChangedUserData, bool( *pfnIsEnabled )( int ) = NULL );

	bool PopulateFilters( const bool bForce = false );
	bool MatchesFilters( const char* const szString );
	bool SetDefaults( Tools_UI_Overrides_FilterSet* const pxOverridesFilters );

private:

	static void Changed( int iUserData );
	void Changed( void );
	void( *m_pfnChanged )( void* const pxUserData );
	void* const m_pxChangedUserData;

	Tools_UI_Overrides*		  m_pxParent;
	Tools_UI_Overrides_Filter m_xFilterList1;
	Tools_UI_Overrides_Filter m_xFilterList2;
	Tools_UI_Overrides_Filter m_xFilterList3;
};



#endif // __TOOLS_UI_OVERRIDES_FILTERS_H__
