/*
* FX Editor Tabbed Class
* @version 7-12-06
* @author Joseph 'Pcjoe' Florencio
*/

#pragma warning (disable:4786)
#pragma warning (disable:4530)

#ifndef FXEDITORTABBED_H
#define FXEDITORTABBED_H
#include <VGUI_Panel.h>
#include <VGUI_TablePanel.h>
#include <VGUI_HeaderPanel.h>
#include <VGUI_TextGrid.h>
#include <VGUI_Label.h>
#include "vgui_fxeditormisc.h"
#include <string>
#include <map>
using namespace std;

/*
* Tabbed Selector
*/
class CTabbedWindow;
class CWindowTab;
class CHandler_TabSelect : public InputSignal
{
public:
	// Constructor
	CHandler_TabSelect( CTabbedWindow *pParent, CWindowTab *pTab );

	// Mouse Released
	void mouseReleased(MouseCode code,Panel* panel);

	void mousePressed(MouseCode code,Panel* panel) {}
	void cursorEntered(Panel *panel) { }
	void cursorExited(Panel* panel) { }
	void cursorMoved(int x,int y,Panel* panel) {};
	void mouseDoublePressed(MouseCode code,Panel* panel) {};
	void mouseWheeled(int delta,Panel* panel) {};
	void keyPressed(KeyCode code,Panel* panel) {};
	void keyTyped(KeyCode code,Panel* panel) {};
	void keyReleased(KeyCode code,Panel* panel) {};
	void keyFocusTicked(Panel* panel) {};

private:
	CTabbedWindow *m_pParent;
	CWindowTab *m_pTab;
};

/*
* Single tab for tabbed manager
*/
class CTabbedWindow;
class CWindowTab
{
public:
	/*
	* Constructor
	*/
	CWindowTab( CTabbedWindow *pParent, CFadeImageButton *pBtn, CFadeImageButton *pBtnSel, Image *pPanelBK );

	// Set as Current
	void setAsCurrent( void );

	// Disable Current
	void disableCurrent( void );

	// Bring panel to front
	void bringPanelToFront( void );

	// Bring button to front
	void bringButtonToFront( void );

	// Bring selected button to front
	void bringSelButtonToFront( void );

	/*
	* Accessors/Mutators
	*/

	void setButton( CFadeImageButton *pBtn ) { m_pButton = pBtn; }
	CFadeImageButton *getButton( void ) { return m_pButton; }

	void setButtonSel( CFadeImageButton *pBtn ) { m_pButtonSel = pBtn; }
	CFadeImageButton *getButtonSel( void ) { return m_pButtonSel; }

	void setPanel( CImagePanel *pPanel ) { m_pPanel = pPanel; }
	CImagePanel *getPanel( void ) { return m_pPanel; }

	void setCurrentTab( bool bCurrent ) { m_bCurrentTab = bCurrent; }
	bool isCurrentTab( void ) { return m_bCurrentTab; }

	void setFadeRate( float flRate ) { m_flFadeRate = flRate; }
	float getFadeRate( void ) { return m_flFadeRate; }

	void setArmed( bool armed ) { m_bArmed = armed; }
	bool isArmed( void ) { return m_bArmed; }

	void setAlpha( float alpha ) { m_flAlpha = alpha; }
	float getAlpha( void ) { return m_flAlpha; }

protected:
	CFadeImageButton *m_pButton;
	CFadeImageButton *m_pButtonSel;
	CImagePanel *m_pPanel;
	Panel *m_pParent;
	bool m_bCurrentTab;
	bool m_bArmed;
	float m_flFadeRate;
	float m_flAlpha;
};

/*
* Tabbed window interface
*/
class CTabbedWindow : public CTransparentPanel
{
public:
	/*
	* Constructor
	*/
	CTabbedWindow(int x, int y, int wide, int tall);

	/*
	* Destructor
	*/
	~CTabbedWindow();

	// Resize panels to correspond with tabbed window size
	void resizePanels( void );

	// Set Current
	void setCurrent( int iTab );
	void setCurrent( CWindowTab *pTab );

	// Get Tab Amount
	int getTabAmount( void );

	// Add Tab
	CWindowTab *addTab(char *pTitle);

	// Get Tab by Index
	CWindowTab *getTabByIndex( int idx );


protected:

	// font/image related names
	virtual string getFontHandleName( void ) { return "Tabbed Font"; }
	virtual string getTabPrefixName( void ) { return "tab"; }
	virtual string getPanelBGName( void ) { return "white"; }

	// List of tabs and associated 'windows'
	std::vector<CWindowTab*> m_Tabs;
};

#endif