#pragma once
#include "global.h"
#include "MyStructDef.h"
//DirectX11渲染的列表框
struct CMyDXListDrawView
{
	float offY = 0;//原点坐标
	float window_w = 0, window_h = 0;//客户区大小
	float lineHeight;//行高
	int selected = -1;//已选择的下标
	float icon_w, icon_h;//小图标的显示尺寸
};
struct CMyDXListDrawItem
{
	CString name;//列表显示的名字
	CString png;//列表显示的图片名
};

class CMyDXList : public CDialog
{
	DECLARE_DYNAMIC(CMyDXList)
	DECLARE_MESSAGE_MAP()
public:
	CMyDXList(CWnd* pParent = nullptr);   // 标准构造函数
	virtual ~CMyDXList();
	// 对话框数据
#ifdef AFX_DESIGN_TIME
	enum { IDD = IDD_CMYDXLIST };
#endif
	void Draw();
	void Init(float lineHeight, float icon_w, float icon_h);
	void SetCurSel(int index);
	int GetCurSel();
	void AddItem(CString text, CString picName);
	void SetMenu(int selectedMenu, int notSelectedMenu = 0);
	void Clear();
	bool Empty();
protected:
	void DoDataExchange(CDataExchange* pDX) override;
	BOOL OnInitDialog() override;
public:
	afx_msg void OnSize(UINT nType, int cx, int cy);
	afx_msg void OnPaint();
	afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
	afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
	afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
private:
	void UpdateSel(CPoint point);
	void SetVScrollBar();
	void SendSelChangeMsg();
	ID3D11ShaderResourceView* GetTexture(CString pngName);
	std::vector<CMyDXListDrawItem> itemList;
	std::unordered_map<std::wstring, MyTextureAndSRV> loadedTexture;
	MyDX11Renderer pRenderer;
	CMyDXListDrawView view;
	TTF_Font* pFont_sourcesun14 = nullptr;
	std::unordered_map<wchar_t, MyFontData> pFontMap70;
	int selectedMenu, notSelectedMenu;
public:
	
};

