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

#ifndef ListViewBaseH
#define ListViewBaseH
//---------------------------------------------------------------------------
#include "TableViewUnit.h"
//---------------------------------------------------------------------------
class TListViewBase: public TTableView
{

private:

	TPoint  m_ptTimer;
	TTimer *m_MoveTimer;
	void __fastcall MoveTimerProc(System::TObject* Sender);

	bool 			   FRightCellChange;
	TNotifyDraw        FOnDrawCell;
	TNotiCell          FOnCellData;
	TNotifyBtn         FOnCellLClick,
					   FOnCellRClick,
					   FOnCellLDClick;

	bool 			   FRightIconChange;
	bool 			   FIconChange;
	TNotifyDraw	       FOnDrawIcon;
	TNotiCell	       FOnIconData;
	TNotiIconsNum      FOnIconsNum;
	TNotiIconsBounds   FOnIconsBounds;
	TNotifyBtn         FOnIconLClick,
					   FOnIconRClick,
					   FOnIconLDClick;

    void __fastcall DoIconDataAndBounds(TStateBtn *pBtnCol);

protected:

	//TStateBtn has "Index" property connect to data
	virtual void __fastcall BtnDown(TStateBtn *pCur, TPoint pt, bool bLeft=true);
	virtual void __fastcall BtnUp(TStateBtn *pCur, TStateBtn *pSel, TPoint pt, bool bLeft=true);
	virtual void __fastcall BtnMove(TStateBtn *pCur, TPoint pt);

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

	virtual int  __fastcall DoCellHgt(TTableView *Sender, int iCellIndex){return 0;}
	virtual int  __fastcall DoClickL(TStateBtn *Sender, TPoint pt){return 0;}
	virtual int  __fastcall DoClickLP(TStateBtn *Sender, TPoint pt){return 0;}
	virtual int  __fastcall DoClickR(TStateBtn *Sender, TPoint pt){return 0;}
	virtual int  __fastcall DoClickRP(TStateBtn *Sender, TPoint pt){return 0;}

	virtual int  __fastcall DoMDCell(TTableView *Sender, int iCellIndex);
	virtual int  __fastcall DoMDNum(TTableView *Sender){return 0;}
	virtual int  __fastcall DoMDTop(TTableView *Sender){return 0;}
	virtual int  __fastcall DoMDBottom(TTableView *Sender){return 0;}
	virtual int  __fastcall DoMDMOV(TStateBtn *Src, TStateBtn *Des, TPoint pt){return 0;}

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

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

	virtual	int  __fastcall DoMouseWheel(TObject *Sender);

public:
	void __fastcall SetTextFontSize(int sz);

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

__published:

	__property  OnDrawBKG;

	__property  OnCellHgt;
	__property  OnTitle;
	__property  OnBottom;
	__property  OnClickL;
	__property  OnClickLP;
	__property  OnClickR;
	__property  OnClickRP;

	__property  OnMDCell;
	__property  OnMDNum;
	__property  OnMDTop;
	__property  OnMDBottom;
	__property  OnMDMOV;

	__property  IndFocus;
	__property  IndSel;
	__property  HgtSmall;
	__property  OnChange;

	__property TNotiCell        OnCellData    = {read=FOnCellData,    write=FOnCellData };
	__property TNotifyDraw      OnDrawCell    = {read=FOnDrawCell,    write=FOnDrawCell };
	__property TNotifyBtn       OnCellLClick  = {read=FOnCellLClick,  write=FOnCellLClick };
	__property TNotifyBtn       OnCellRClick  = {read=FOnCellRClick,  write=FOnCellRClick };
	__property TNotifyBtn       OnCellLDClick = {read=FOnCellLDClick, write=FOnCellLDClick };
	__property bool             RightCellChange   = {read=FRightCellChange,   write=FRightCellChange, default=false };

	__property TNotiCell        OnIconData    = {read=FOnIconData,    write=FOnIconData };
	__property TNotiIconsNum    OnIconsNum    = {read=FOnIconsNum,    write=FOnIconsNum };
	__property TNotiIconsBounds OnIconsBounds = {read=FOnIconsBounds, write=FOnIconsBounds };
	__property TNotifyDraw      OnDrawIcon    = {read=FOnDrawIcon,    write=FOnDrawIcon };
	__property TNotifyBtn       OnIconLClick  = {read=FOnIconLClick,  write=FOnIconLClick };
	__property TNotifyBtn       OnIconRClick  = {read=FOnIconRClick,  write=FOnIconRClick };
	__property TNotifyBtn       OnIconLDClick = {read=FOnIconLDClick, write=FOnIconLDClick };
	__property bool             IconChange    = {read=FIconChange,    write=FIconChange, default=false  };
	__property bool             RightIconChange   = {read=FRightIconChange,   write=FRightIconChange, default=false };

};
#endif

