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

#ifndef ListViewPatternH
#define ListViewPatternH
//---------------------------------------------------------------------------
#include "ListViewBase.h"
#include "FavorTextureUnit.h"
#include "Compose.h"
#include "SkinHintWindow.h"

#define WIDTH_LINE        4
#define WIDTH_SB          14
#define WIDTH_IMG_PROG    0
#define WIDTH_IMG_COL     21
#define WIDTH_IMG_CHARGE  21

#define WIDTH_AVERAGE(W)  ((W-WIDTH_SB-WIDTH_IMG_PROG-WIDTH_IMG_COL-WIDTH_LINE*3)/5)
#define WIDTH_PROG(W)     (WIDTH_AVERAGE(W)*3)
#define WIDTH_SEG(W)      (WIDTH_AVERAGE(W)-6)
#define WIDTH_STYLE(W)    (WIDTH_AVERAGE(W)+6)

#define LEFT_CAPTION    (WIDTH_IMG_PROG)
#define LEFT_PROG       (LEFT_CAPTION)
#define LEFT_STYLE(W)   (LEFT_PROG     + WIDTH_PROG(W)  + WIDTH_LINE)
#define LEFT_SEG(W)     (LEFT_STYLE(W) + WIDTH_STYLE(W) + WIDTH_LINE)
#define LEFT_COL(W)     (LEFT_SEG(W) + WIDTH_SEG(W) + WIDTH_LINE)
//---------------------------------------------------------------------------
typedef struct tagTextureInfo
{
//	TPROSTYLE *styleInfo;
	UINT 		idLoc;		//位置id
	UINT 		idStyle;	//风格ID
	char 		segType;   //片段类型
	char 		segNo;		//片段号
	char 		chNo;		//轨道序号 (与FavorTexture结构不同）
	char 		prog;		//乐器号
	char 		vol;		//音量
	bool       	bCollected;

	tagTextureInfo(){
		memset( this, 0, sizeof(tagTextureInfo) );
	}
	tagTextureInfo( UINT loc, UINT sty, char type, char sNo, char cNo, char pg, char vl, bool bCol=false ){
		idLoc = loc;
		idStyle = sty;
		segType = type;
		segNo = sNo;
		chNo = cNo;
		prog = pg;
		vol = vl;
		bCollected  = bCol;
	}
}TTextureInfo, *PTTextureInfo;

typedef vector<TTextureInfo*> VCPtInfo;

class TListViewPattern: public TListViewBase
{
private:
	TStateBtn *m_btnHint;
	TStageList* m_lstStages;
	int m_iPlayBar;

	virtual int  __fastcall DoCellHgt(TTableView *Sender, int iCellIndex);
	virtual int  __fastcall DoMDNum(TTableView *Sender);

	virtual void __fastcall DoCellDraw(TStateBtn *sender, int BsTmp, TRect rtTmp, TCanvas *pCanvas);
	virtual int  __fastcall DoCellData(TStateBtn *sender);
	virtual void __fastcall DoCellLClick(TStateBtn *sender);
	virtual void __fastcall DoCellDBClick(TStateBtn *sender);

	virtual void __fastcall DoIconDraw(TStateBtn *sender, int BsTmp, TRect rtTmp, TCanvas *pCanvas);
	virtual int  __fastcall DoIconsNum(TStateBtn *parent);
	virtual int  __fastcall DoIconsBounds(TStateBtn *sender, TRect &rtBounds);
	virtual void __fastcall DoIconLClick(TStateBtn *sender);

	int  m_nPlayIndex;
	int  m_iseed;
	TNotifyEvent FOnTextureChanged;

protected:

    virtual	int  __fastcall DoMouseWheel(TObject *Sender);

public:

	bool m_bChan9;

	VCPtInfo *m_LstParttern;
	TTextureInfo *m_pPtInfo;
	char m_iFont, m_iProg;
	void __fastcall OnPartternPlay(TObject *sender);

	__fastcall TListViewPattern(TComponent* Owner, bool bChan9=false, TStageList* lstStages=NULL, int iPlayBar=-1);
	__fastcall ~TListViewPattern();

__published:
	__property TNotifyEvent OnTextureChanged = {read=FOnTextureChanged, write=FOnTextureChanged };
};
#endif

