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

#ifndef ScrollViewUnitH
#define ScrollViewUnitH
//---------------------------------------------------------------------------
#include "SkinScrollBarUnit.h"
#include "PanelDB.h"

typedef void __fastcall (__closure *ChangeSBPos)(TObject *Sender, short ScrollCode, int iTopLine);
typedef void __fastcall (__closure *ChangeSize)(TObject *Sender, TRect rtPanelDB);
typedef int  __fastcall (__closure *TNotiScoll)(TObject *Sender);

class TScrollView: public TPanelDB
{

private:

	TNotiScoll FOnHgtTitle;
	TNotiScoll FOnHgtBottom;
	TNotiScoll FOnMouseWheel;

	ChangeSize   FChangeSize;
	ChangeSBPos  FChangeSBPos;

	TSkinScrollBar *m_ScrollBar;
	int m_iTotalLine;
	int m_iShowLine;
	int m_iTopLine;
	void __fastcall SBSizeChange();

	int FBorder;
	int FScrollBarWidth;

protected:

	MESSAGE void __fastcall WMEraseBkgnd(TWMEraseBkgnd &Message);
	MESSAGE void __fastcall WMSize(Winapi::Messages::TWMSize &Message);
	MESSAGE void __fastcall WMVScroll(Winapi::Messages::TWMScroll &Message);
	MESSAGE void __fastcall WMMouseWheel(TWMMouseWheel &Message);

	BEGIN_MESSAGE_MAP
		MESSAGE_HANDLER(WM_ERASEBKGND, TWMEraseBkgnd, WMEraseBkgnd)
		MESSAGE_HANDLER(WM_SIZE, TWMSize, WMSize)
		MESSAGE_HANDLER(WM_VSCROLL, TWMVScroll, WMVScroll)
		MESSAGE_HANDLER(WM_MOUSEWHEEL, TWMMouseWheel, WMMouseWheel)
	END_MESSAGE_MAP( TPanelDB )

public:

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

	bool __fastcall SetSB(int iTotalLine, int iShowLine, int iTopLine);

__published:

	__property ChangeSBPos  OnChangeSBPos= { read=FChangeSBPos, write=FChangeSBPos };
	__property ChangeSize   OnChangeSize = { read=FChangeSize,  write=FChangeSize };
	__property TNotiScoll   OnHgtTitle   = { read=FOnHgtTitle,  write=FOnHgtTitle };
	__property TNotiScoll   OnHgtBottom  = { read=FOnHgtBottom, write=FOnHgtBottom };
	__property TNotiScoll   OnMouseWheel = { read=FOnMouseWheel,write=FOnMouseWheel };
	__property int          Border       = { read=FBorder,      write=FBorder };
	__property int          ScrollBarWidth = { read=FScrollBarWidth,  write=FScrollBarWidth, default=0 };
};
/* * * * *
read me

if the tittle panel is exsit, the border setting has no effect,
you should draw border in title canvas, the same as bottom panel.

* * * * */
#endif
