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

#ifndef HelpPanelUnitH
#define HelpPanelUnitH
//---------------------------------------------------------------------------
#include <vcl.h>

#include <vector>
//------------------------
#include "SkinScrollBarUnit.h"
#include <Vcl.Imaging.pngimage.hpp>
#include "QRcodePanel.h"

#define MODE_NUM 6
#define SOFTWARE_NUM 3
#define COLOR_BORDER RGB(164,115,70)
#define COLOR_QUESTION RGB( 207,169,207 )
#define COLOR_ANSWER RGB( 249,246,229 )

#include <vector>
using namespace std;

typedef struct{
	wstring str1;
	wstring str2;
} TWSPAIR;

typedef vector< TWSPAIR* > TWSPAIRLIST;

typedef struct tagLineString{
	int flag;
	wstring strText;

	tagLineString(){
		flag = 0;
	}
} TLineString;

typedef vector< TLineString* > TTEXTLINE;
//--------

class THelpPanel : public Extctrls::TPanel
{

private:
	TQRcodePanel *m_pQRPanelAndroid, *m_pQRPaneliOS;
	unsigned char *m_pQRdataAndroid, *m_pQRdataiOS;
	TLabel  *m_aLblSWName[SOFTWARE_NUM],
			*m_aLblSWLink[SOFTWARE_NUM],
			*m_lblCoinPage;

	TTEXTLINE m_lstLines;

	int m_iMode; //显示模式 0=常见问题，1=我要提问，2=网站公告，3=空间消息
	int m_iLastMode; //上次显示模式

//    char m_CharBuf[2048];

	void CalcViewArea();
	void ReadData();

	void __fastcall LinkClick(TObject *Sender);
	void __fastcall LinkMouseEnter(TObject *Sender);
	void __fastcall LinkMouseLeave(TObject *Sender);

	MESSAGE void __fastcall WMEraseBkgnd(Winapi::Messages::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(Vcl::Extctrls::TPanel)

//protected:
	//显示相关
	int m_nRowShow,
		m_nBeginShowRow,
		m_nRowNum,

		m_nPosFlag,
		m_nPosText,

/*		m_iFirstRowMode0,
		m_iFirstRowMode1,
		m_iFirstQAMode0,
		m_iFirstQAMode1,
*/
		m_aFirstRow[MODE_NUM],
		m_aFirstTitle[MODE_NUM],

		m_nRowWidth,
		m_nRowHight,

		m_nLeftBound,
		m_nRightBound,
		m_nTopBound,
		m_nBottomBound;

	TSkinScrollBar *m_sbVert;
//	TMemo* m_memoMsg;

	virtual void __fastcall CreateWnd();
	virtual void __fastcall Paint(void);

	void RefreshTextLines();

public:
	void ScrollView( int nPos, bool bRedraw=true );
	void SetMode( int iMode );
	void AddFeedback( wstring str );
	void SaveFirstRow();
	void InitialVars();
	bool HasScrollBar();
    void SetTextFontSize(int sz);

	__fastcall virtual THelpPanel(System::Classes::TComponent* AOwner);
	__fastcall ~THelpPanel();
};
#endif
