//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose: This is a panel which is rendered image on top of an entity
//
// $Revision: $
// $NoKeywords: $
//=============================================================================//

#ifndef VGUI_BITMAPBUTTONRTS_H
#define VGUI_BITMAPBUTTONRTS_H

#ifdef _WIN32
#pragma once
#endif

#include <vgui_controls/Button.h>
#include "VGui_BitmapImage.h"
#include "vgui/mousecode.h"

//-----------------------------------------------------------------------------
// forward declarations
//-----------------------------------------------------------------------------
class KeyValues;

//-----------------------------------------------------------------------------
// A button that renders images instead of standard vgui stuff...
//-----------------------------------------------------------------------------
class CBitmapButtonRTS : public vgui::Button
{
	typedef vgui::Button BaseClass;

public:
	enum ButtonImageType_t
	{
		BUTTON_ENABLED = 0,
		BUTTON_ENABLED_MOUSE_OVER,
		BUTTON_PRESSED,
		BUTTON_DISABLED,

		BUTTON_STATE_COUNT
	};

	/*#define F_ONEIMAGE		( 1 << 0 )
	#define F_SELECTED		( 1 << 1 )
	#define F_SHOWPROGRESS	( 1 << 2 )
	#define F_SHOWHEALTHBAR ( 1 << 3 )
	#define F_SHOWAMOUNT	( 1 << 3 )*/

	#define F_ONEIMAGE		0x001
	#define F_SELECTED		0x002
	#define F_SHOWPROGRESS	0x004
	#define F_SHOWHEALTHBAR 0x008
	#define F_SHOWAMOUNT	0x010

	// constructor
	CBitmapButtonRTS( vgui::Panel *pParent, const char *pName, const char *pText );
	~CBitmapButtonRTS();

	// initialization
	bool Init( KeyValues* pInitData );

	void SetImage( ButtonImageType_t type, BitmapImage *pMaterialImage, color32 color );
	bool IsImageLoaded( ButtonImageType_t type ) const;

	//void SetHighLightButton( int state );
	void SetHighLightImages( const char *pMaterialImageHover, const char *pMaterialImageSelected );
	void SetProgress( float weight );
	void SetHealth( float weight );
	void SetAmount( int amount );

	// initialization from build-mode dialog style .res files
	virtual void ApplySettings(KeyValues *inResourceData);

	virtual void Paint( void );
	virtual void PaintBackground( void ) {}
	void PaintNumbers(vgui::HFont font, int xpos, int ypos, int value);

	int	GetButtonFlags( void ) const;
	void AddButtonFlags( int nFlags );
	void RemoveButtonFlags( int nFlags );
	void ClearButtonFlags( void );
	bool HasButtonFlags( int nFlags ) const;

	virtual void OnMouseDoublePressed( vgui::MouseCode code);
	virtual void OnMouseReleased( vgui::MouseCode code);
	virtual void OnCursorEntered();
	virtual void OnCursorExited();

	virtual bool IsArmedIgnoredEnabled() { return m_bIsArmedIgnoreEnabled; }

	// Set the command to send when the button is pressed
	// Set the panel to send the command to with AddActionSignalTarget()
	virtual void SetCommand2( const char *command );
	// Set the message to send when the button is pressed
	virtual void SetCommand2( KeyValues *message );
private:
	KeyValues		  *_actionMessage2;

private:
	//virtual void OnMousePressed(vgui::MouseCode code);

	BitmapImage	*m_pImage[BUTTON_STATE_COUNT];
	bool m_bImageLoaded[BUTTON_STATE_COUNT];

	int m_pImageHover;
	int m_pImageSelected;

	//int m_iHighLightButton;
	float m_fProgress;		// progress as weight
	float m_fHealth;
	int m_iAmount;
	vgui::HFont m_hNumberFont;

	int m_iButtonFlags;

	bool m_bIsArmedIgnoreEnabled;
};

inline int CBitmapButtonRTS::GetButtonFlags( void ) const
{ 
	return m_iButtonFlags; 
}

inline void CBitmapButtonRTS::AddButtonFlags( int nFlags ) 
{ 
	m_iButtonFlags |= nFlags; 
}
inline void CBitmapButtonRTS::RemoveButtonFlags( int nFlags ) 
{ 
	m_iButtonFlags &= ~nFlags; 
}

inline void CBitmapButtonRTS::ClearButtonFlags( void ) 
{ 
	m_iButtonFlags = 0; 
}

inline bool CBitmapButtonRTS::HasButtonFlags( int nFlags ) const
{ 
	return (m_iButtonFlags & nFlags) != 0; 
}


#endif //  VGUI_BITMAPBUTTONRTS_H