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

#ifndef ListViewMoveH
#define ListViewMoveH
//---------------------------------------------------------------------------
#include "ListViewBase.h"
//---------------------------------------------------------------------------
typedef bool __fastcall (__closure *TNotifyItemClick)(int index, bool bOn);
typedef bool __fastcall (__closure *TNotifyItemChange)(int indSrc, int indDes);
typedef bool __fastcall (__closure *TNotifyItemClickPt)(int index, bool bOn, TPoint pt);
#define CELL_HEIGHT         18
typedef struct tagDataInfo{
	String caption;
	bool   bOn;
	tagDataInfo(String captionTmp, bool bOnTmp){
		caption = captionTmp;
		bOn = bOnTmp ;
	}
	tagDataInfo(){
		caption = L"";
		bOn = true;
	}
}DATAInfo;
//---------------------------------------------------------------------------
class TListViewMove: public TListViewBase
{

private:

	bool bMovBottom;
	TNotifyItemClick   FOnItemDBLClick, FOnItemStateChange;
	TNotifyItemChange  FOnItemDelete, FOnItemMoveIng, FOnItemMoveEnd;
	TNotifyItemClickPt FOnItemRightClick;

	virtual void __fastcall DoDrawBKG(TPanelDB *Sender, TCanvas *pCanvas, TRect rtBKG);
	virtual int  __fastcall DoTitle(TTableView *Sender);
	virtual int  __fastcall DoBottom(TTableView *Sender);

	virtual int  __fastcall DoCellHgt(TTableView *Sender, int iCellIndex);
	virtual int  __fastcall DoClickL(TStateBtn *Sender, TPoint pt);
	virtual int  __fastcall DoClickLP(TStateBtn *Sender, TPoint pt);
	virtual int  __fastcall DoClickR(TStateBtn *Sender, TPoint pt);
	virtual int  __fastcall DoMDNum(TTableView *Sender);
	virtual int  __fastcall DoMDBottom(TTableView *Sender);
	virtual int  __fastcall DoMDMOV(TStateBtn *Src, TStateBtn *Des, TPoint pt);

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

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

	int 	   m_nCapLeft;
	int 	   m_nCapWidth;

	TList     *m_LstData;

	int m_iSrc, m_iDes;
	TBitmap   *m_pMovLine;
	TBitmap   *m_pMovBmp;
	TPanelDB  *m_pMovPanel;
	void __fastcall DoMovPaint(TPanelDB *Sender, TCanvas *pCanvas, TRect rtBKG);

	TPngImage *m_pImgDel;
	TPngImage *m_pImgOff;
	TPngImage *m_pImgOn;

public:

	void __fastcall AddIcon(TPngImage *pImgDel, TPngImage *pImgOff, TPngImage *pImgOn);
	void __fastcall AddItem(String caption, bool bOn=true, bool bPaint=true, int insertIndex=-1);
	void __fastcall DeleteItem(int index, bool bPaint=true);
	void __fastcall MoveItems(int srcIndex, int desIndex);
	void __fastcall ClearAllItems();
	int  __fastcall GetItemState(int index);
	void __fastcall SetItemState(int index, bool bOn=true, bool bPaint=true);

	__fastcall TListViewMove(TComponent* Owner);
	__fastcall ~TListViewMove();

__published:

	__property  IndSel;
	__property  Count;

	__property TNotifyItemClick   OnItemDBLClick    = {read=FOnItemDBLClick,     write=FOnItemDBLClick };
	__property TNotifyItemClickPt OnItemRightClick  = {read=FOnItemRightClick,   write=FOnItemRightClick };
	__property TNotifyItemClick   OnItemStateChange = {read=FOnItemStateChange,  write=FOnItemStateChange };
	__property TNotifyItemChange  OnItemDelete      = {read=FOnItemDelete,       write=FOnItemDelete };
	__property TNotifyItemChange  OnItemMoveIng     = {read=FOnItemMoveIng,      write=FOnItemMoveIng };
	__property TNotifyItemChange  OnItemMoveEnd     = {read=FOnItemMoveEnd,      write=FOnItemMoveEnd };
};
#endif

