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

#ifndef StyleSelPanelH
#define StyleSelPanelH
//---------------------------------------------------------------------------
#include <vcl.h>
//#include "TextButton.h"
#include "CKBox.h"
#include "LineEdit.h"
#include "ComboBoxComponent.h"
#include "MessageDef.h"

#define INSTR		0
#define STYLE		1
#define SORT		2


class SearchItem : public TCKBox
{
public:
	int count;
	char classify[20];	   //索引数据

	__fastcall SearchItem( System::Classes::TComponent* AOwner );
	__fastcall ~SearchItem(void);
};

class TStyleSelPanel : public Vcl::Extctrls::TPanel
{
private:
	TRect framRet;
	TPngImage *m_img;
	TList *m_ListStyle;
	TList *m_ListInstrBtn;
	TLineEdit *m_LineEit;
	TLabel *m_lblSort[2];
	TComboBoxComponent *m_cbSort[2];

	int iMouse;

	int oldX;
	int oldY;
	int oldAddLeft;

	void AddStyleButton(String sCaption,int iTag,bool bCheck = true);
	void AddInstrButton(String sCaption,int num,...);
	void DrawTab( int index );
	int GetHeight();
private:
    virtual void __fastcall CreateWnd();
	virtual void __fastcall Paint(void);
	void __fastcall CMClick(System::TObject* Sender);
	void __fastcall SortChanged(TComboBoxItem *Sender, int Index);

	void __fastcall CMMouseMove(System::TObject* Sender, System::Classes::TShiftState Shift, int X, int Y);
	void __fastcall CMMouseDown(System::TObject* Sender, System::Uitypes::TMouseButton Button, System::Classes::TShiftState Shift, int X, int Y);

	MESSAGE void __fastcall WMEraseBkgnd(TWMEraseBkgnd &Message);
	MESSAGE void __fastcall WMSize(Winapi::Messages::TWMSize &Message);
	MESSAGE void __fastcall CMMouseEnter(Winapi::Messages::TMessage &Msg);

	BEGIN_MESSAGE_MAP
		MESSAGE_HANDLER(WM_ERASEBKGND, TWMEraseBkgnd, WMEraseBkgnd)
		MESSAGE_HANDLER(WM_SIZE, TWMSize, WMSize)
		MESSAGE_HANDLER(CM_MOUSEENTER, TMessage, CMMouseEnter)
	END_MESSAGE_MAP(Vcl::Extctrls::TPanel)
public:
	int iSelect;    //搜索类型  STYLE INSTR
	int iSortType;	//排序类型 Time/Cost
	int iSortMode;  //排序模式 倒序/顺序
//	TList *LStyle;  //STYLE 的搜索范围
//	TList *LInStr;  //INSTR 的搜索范围
	System::DynamicArray<int> DStyle;
    System::DynamicArray<int> DInStr;

	void Reset(void);

	__fastcall TStyleSelPanel(System::Classes::TComponent* AOwner);
	__fastcall ~TStyleSelPanel(void);

	__property Canvas;
	__property Width;
};

#endif
