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

#ifndef PredefineProjectSetUnitH
#define PredefineProjectSetUnitH

#include <vcl.h>

class TPrefineProjectSet;
class TPrefineProjectSetItem;
//---------------------------------------------------------------------------
class TPrefineProjectSetItem : public TGraphicControl
{
private:
	bool FIsSelected;
	bool FIsFocus;

	void __fastcall SetSelected(bool Value);

	MESSAGE void __fastcall CMMouseEnter(TMessage &Message);
	MESSAGE void __fastcall CMMouseLeave(TMessage &Message);
	MESSAGE void __fastcall WMLButtonDown(TWMLButtonDown &Message);

protected:
	BEGIN_MESSAGE_MAP
		MESSAGE_HANDLER(CM_MOUSEENTER, TMessage, CMMouseEnter)
		MESSAGE_HANDLER(CM_MOUSELEAVE, TMessage, CMMouseLeave)
		MESSAGE_HANDLER(WM_LBUTTONDOWN, TWMLButtonDown, WMLButtonDown)
	END_MESSAGE_MAP(TGraphicControl)

	virtual void __fastcall Paint();

public:
	int Key;
	BYTE PredefChord[8];
	int Index;

	TPrefineProjectSet *CtrlParent;

	virtual __fastcall TPrefineProjectSetItem(TWinControl *Parent);

	void __fastcall DrawChord(TCanvas *Canvas, TRect Rect, int iKey, int iType);

	static void __fastcall GetChordDisplayKey(int iKey, int iBaseKey, int& iMainKey, int& iAjustKey);
	static void __fastcall UniDrawChord(TCanvas *Canvas, TRect rcDraw, int iMainKey, int iAjustKey, int iType);

	__property bool IsSelected = {read = FIsSelected, write = SetSelected};
};

class TPrefineProjectSet : public TCustomControl
{
private:
	TWinControl *mContentArea;

	HWND mActiveWndBak;

	int mItemWidth;
	int mItemHeight;

	int mSelectedIndex;

	TList *mItemList;

	TPrefineProjectSetItem *mCurrentItem;

	void __fastcall SetSelectedIndex(int Value);

	MESSAGE void __fastcall WMKillFocus(TMessage &Message);
	MESSAGE void __fastcall WMEraseBkgnd(TWMEraseBkgnd &Message);
	MESSAGE void __fastcall WMSize(TWMSize &Message);

protected:
	BEGIN_MESSAGE_MAP
		MESSAGE_HANDLER(WM_KILLFOCUS, TMessage, WMKillFocus)
		MESSAGE_HANDLER(WM_ERASEBKGND, TWMEraseBkgnd, WMEraseBkgnd)
		MESSAGE_HANDLER(WM_SIZE, TWMSize, WMSize)
	END_MESSAGE_MAP(TCustomControl)

	void __fastcall CreateParams(TCreateParams &Params);
	void __fastcall CreateWnd();

public:
	TNotifyEvent OnHide;
	TNotifyEvent OnShow;

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

	void __fastcall DoItemClick(TPrefineProjectSetItem *Item, int Index);

	void __fastcall Hide();
    void __fastcall Show();

	void __fastcall AddItem(TPrefineProjectSetItem *Item);

	__property int SelectedIndex = {read = mSelectedIndex, write = SetSelectedIndex};
};

#endif
