//---------------------------------------------------------------------------

#ifndef StateBtnH
#define StateBtnH
//---------------------------------------------------------------------------
#include <list>
#include <vector>
using namespace std;
#include <Vcl.Imaging.pngimage.hpp>
#include <Vcl.Imaging.jpeg.hpp>
#include <Vcl.Graphics.hpp>
//#define TJCOMPONENT
#ifdef  TJCOMPONENT
//#include "GlobalCBEnvUnit.h"
#else
//#include "GlobalUnit.h"
#endif
//---------------------------------------------------------------------------
#define SAFE_DELETE(p)  { if(p) { delete (p);     (p)=NULL; } }
#define NULL_RETURN(p)  { if(NULL==p) return; }
#define NULL_RETURN0(p) { if(NULL==p) return 0; }

#define RECTCOMPONENT(COM) \
	TRect(COM->Left, COM->Top, COM->Left+COM->Width, COM->Top+COM->Height);

#define RECTSET(COM, L, T, W, H)  \
	 COM->Left   = L;             \
	 COM->Top    = T;             \
	 COM->Width  = W;             \
	 COM->Height = H;

#define Bs_NORMAL  0
#define Bs_ENTER   1
#define Bs_DOWN    2
#define Bs_DISABLE 3
//---------------------------------------------------------------------------
typedef vector<char *> VCStr;
typedef vector<int>    VCInt;

class TStateBtn;
class TPanelDB;
typedef list<TStateBtn *> BTNLST;

typedef void __fastcall (__closure *TNotifyBtn)(TStateBtn *sender);
typedef void __fastcall (__closure *TNotifyDraw)(TStateBtn *sender, int BsTmp, TRect rtTmp, TCanvas *pCanvas);
typedef void __fastcall (__closure *TNotifyBounds)(TStateBtn *sender, TRect &rtCell);
//---------------------------------------------------------------------------

class TStateBtn: public TObject
{

private:

	int    FIndex,
		   FLeft, FTop, FWidth, FHeight,
		   FStateCount, FState;

	bool   FEnable, FEnter, FDown, FStateCus;

	TNotifyBtn FNotifyState;
	TNotifyDraw FNotifyDraw;

	TNotifyBtn FOnClick;
	TNotifyBtn FOnClickR;
	TNotifyBtn FOnDBClick;

	void __fastcall SetAlphaBlend(bool bAlphaBlend);
	void __fastcall SetTrans(bool bTrans);

	BTNLST m_LstSub;
	void __fastcall Clear();

protected:

	TPanelDB *m_Panel;

public:

	TStateBtn *m_UP, *m_PRE, *m_NEXT, *m_PAR;
	void      *m_Data;

	TRect      __fastcall GetBounds();
	BTNLST*    __fastcall GetSub();
	TStateBtn* __fastcall GetSubCusor(TPoint pt);

	void       __fastcall SetSub(TStateBtn *pBtn);
	void       __fastcall SetBounds(int nLeft, int nTop, int nWidth, int nHeight);
	void       __fastcall SetData(void *pData);

	bool 	   __fastcall DoNotifyStateHandle();
	void       __fastcall Paint(TCanvas *Canvas=NULL);

	__fastcall TStateBtn(TPanelDB *panel);
	__fastcall ~TStateBtn();

__published:

	__property int  Index       = { read=FIndex,      write=FIndex,      default=0 };
	__property int  Left        = { read=FLeft,       write=FLeft,       default=0 };
	__property int  Top         = { read=FTop,        write=FTop,        default=0 };
	__property int  Width       = { read=FWidth,      write=FWidth,      default=0 };
	__property int  Height      = { read=FHeight,     write=FHeight,     default=0 };
	__property int  StateCount  = { read=FStateCount, write=FStateCount, default=4 };
	__property int  State       = { read=FState,      write=FState,      default=0 };

	__property bool Enable      = { read=FEnable,     write=FEnable,     default=true };
	__property bool Enter       = { read=FEnter,      write=FEnter,      default=true };
	__property bool Down        = { read=FDown,       write=FDown,       default=false};
	__property bool StateCus    = { read=FStateCus,   write=FStateCus,   default=false};

	__property TNotifyBtn   OnNotifyState = { read=FNotifyState , write=FNotifyState };
	__property TNotifyDraw  OnNotifyDraw  = { read=FNotifyDraw ,  write=FNotifyDraw };

	__property TNotifyBtn OnClick   = { read=FOnClick ,  write=FOnClick };
	__property TNotifyBtn OnClickR  = { read=FOnClickR , write=FOnClickR };
	__property TNotifyBtn OnDBClick = { read=FOnDBClick ,write=FOnDBClick };
};
//---------------------------------------------------------------------------


/* * * * *
read me
* * * * */

//×Óbtn Ïà¶Ô¸¸×ø±ê

#endif