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

#ifndef UpDownUnitH
#define UpDownUnitH
//---------------------------------------------------------------------------

#define STATE_NORMAL	0
#define STATE_HIGHLIGHT 1
#define STATE_PUSH 		2

#define ORIENTATION_LEFT	0
#define ORIENTATIONRIGHT    1
#define ORIENTATION_NONE 	2
#define ORIENTATION_ALL 	3

#define SPEED_MIN           50
#define SPEED_MAX		    200

#define TIME_DELAY 		    200
//---------------------------------------------------------------------------
namespace UpDownUnit{

class TUpDown: public Vcl::Comctrls::TUpDown
{
private:
	MESSAGE void __fastcall WMPaint(Winapi::Messages::TWMPaint &Message);
	MESSAGE void __fastcall WMLButtonDown(TWMMouse &Message);
	MESSAGE void __fastcall WMLButtonUp(TWMMouse &Message);
	MESSAGE void __fastcall WMMouseMove(TWMMouse &Message);
	MESSAGE void __fastcall CMMouseLeave(TMessage &Message);

	BEGIN_MESSAGE_MAP
		MESSAGE_HANDLER(WM_PAINT, TWMPaint, WMPaint)
		MESSAGE_HANDLER(WM_LBUTTONDOWN, TWMLButtonDown, WMLButtonDown)
		MESSAGE_HANDLER(WM_LBUTTONUP, TWMLButtonUp, WMLButtonUp)
		MESSAGE_HANDLER(WM_MOUSEMOVE, TWMMouseMove, WMMouseMove)
		MESSAGE_HANDLER(CM_MOUSELEAVE, TMessage, CMMouseLeave)
	END_MESSAGE_MAP(Vcl::Comctrls::TUpDown)

protected:
	virtual void __fastcall PaintWindow(HDC DC);

private:
	TCanvas *m_pCanvas;
	TTimer *m_pTimer;

	bool m_iDown;
    int  m_iCurOrentation,m_iPreOrentation;

	void __fastcall Draw(int iState, int iOrentation=ORIENTATION_ALL);
	int __fastcall HitTest(int x, int y);
	void __fastcall TimerProc(TObject* Sender);

public:
	__fastcall virtual TUpDown(System::Classes::TComponent* AOwner);
	__fastcall ~TUpDown();
};

}

using namespace UpDownUnit;
#endif
