//---------------------------------------------------------------------------
#ifndef ToolpalPanelH
#define ToolpalPanelH

#include <vector>
using namespace std;

#include "PNGButton.hpp"
#include "SkinScrollBarUnit.h"
#include "MenuUnit.h"
#include <Vcl.AppEvnts.hpp>

#define TPTYPE_STYLE		0
#define TPTYPE_CHORD		1
#define TPTYPE_EFFECT		2
#define LEFT_BOUND			4
#define RIGHT_BOUND			8

//drag mode
#define DM_ADJUSTWIDTH			1 //调整面板宽度
#define DM_ADJUSTHEIGHT			2 //调整面板高度
#define DM_ADJUSTSTYLE			3 //调整风格
#define DM_ADJUSTSTAGE			4 //调整段落
#define DM_ADJUSTAUDIO			5 //调整音频
#define DM_ADJUSTHEADER			6 //调整轨道头宽度

//---------------------------------------------------------------------------
class TToolpalPanel : public Vcl::Extctrls::TPanel
{
protected:
	TSkinScrollBar *m_sbVert;
	TApplicationEvents *m_ApplicationEvents;
	static TMenuPanel* m_PopMenu;          //弹出菜单

	vector<TPNGButton*> m_lstBtnTools;
	String m_strTitle;
	int m_nTitleHeight;

	void LayoutBtns();
	void DeleteToolBtn( int index );
	void DrawDragImg( int mode );

	virtual bool CanVSplit(){ return false; };

	virtual void __fastcall CreateWnd();
	virtual void __fastcall Paint(void);
	void __fastcall BtnToolMouseEnter(TObject* Sender);
	virtual void __fastcall DoHandleMessage(MSG &Msg, bool &Handled);  //鼠标消息处理

	virtual MESSAGE void __fastcall WMMouseDown(TWMMouse &Message);
	virtual MESSAGE void __fastcall WMSize(Winapi::Messages::TWMSize &Message);
	MESSAGE void __fastcall WMEraseBkgnd(Winapi::Messages::TWMEraseBkgnd &Message);

	BEGIN_MESSAGE_MAP
		MESSAGE_HANDLER(WM_ERASEBKGND, TWMEraseBkgnd, WMEraseBkgnd)
		MESSAGE_HANDLER(WM_LBUTTONDOWN, TWMMouse, WMMouseDown)
		MESSAGE_HANDLER(WM_RBUTTONDOWN, TWMMouse, WMMouseDown)
		MESSAGE_HANDLER(WM_SIZE, TWMSize, WMSize)
	END_MESSAGE_MAP(Vcl::Extctrls::TPanel)
public:
	int m_iType;

	__fastcall TToolpalPanel(System::Classes::TComponent* AOwner);
	__fastcall ~TToolpalPanel();

	static void SetPopMenu( TMenuPanel* pMenu ){ m_PopMenu = pMenu; };
	virtual bool ShowDragImg( bool bShow=true, int iState=0 );
	void SetTitle( String str ){ m_strTitle = str; };
	void __fastcall AddToolBtn( int stateCount, String resName,
									TNotifyEvent aClickEvent, String strHint, int index=-1 );
};

#endif
