doc_and_tools/tools/apps/hgjson/DlgRange.h

70 lines
1.8 KiB
C
Raw Normal View History

#pragma once
// CDlgRange 对话框
#include <string>
#include <vector>
#include <functional>
#define INIT_VAL_API_PROTO std::function<void(const wchar_t*, CComboBox*)>
2023-09-13 04:45:10 +00:00
class CDlgRange : public CDialogEx
{
DECLARE_DYNAMIC(CDlgRange)
INIT_VAL_API_PROTO init_val_api_;
2023-09-13 04:45:10 +00:00
std::function < std::wstring(const wchar_t*/*name*/, int/*index*/)> item_val_;
std::function<std::wstring(int/*index*/, int*/*type*/, int*/*range type*/, std::wstring* /*name*/)> item_all_;
std::wstring name_;
std::wstring get_item_text(UINT id);
public:
2023-09-13 04:45:10 +00:00
CDlgRange(const wchar_t* name, int type, CWnd* pParent = nullptr); // 标准构造函数
virtual ~CDlgRange();
// 对话框数据
#ifdef AFX_DESIGN_TIME
enum { IDD = IDD_RANGE };
#endif
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
virtual BOOL OnInitDialog();
DECLARE_MESSAGE_MAP()
public:
2023-09-13 04:45:10 +00:00
typedef struct _cond_val
{
std::wstring val;
std::wstring cond; // for range, must lead by 'min:' or 'max:' or 'step:'
struct _cond_val() : val(L""), cond(L"")
{}
struct _cond_val(const std::wstring& v) : val(v), cond(L"")
{}
}CONDVAL;
2023-09-13 04:45:10 +00:00
std::vector<CONDVAL> vals_;
std::wstring init_;
enum {TYPE_RANGE, TYPE_LIST, TYPE_FIELDS};
int type_; // 0 - range; 1 - list; 2 - modify fields
2023-09-13 04:45:10 +00:00
void set_init_val_api(INIT_VAL_API_PROTO api, std::function<std::wstring(int/*index*/, int*/*type*/, int*/*range type*/, std::wstring* /*name*/)> get_opts, std::function < std::wstring(const wchar_t*/*name*/, int/*index*/)> range)
{
init_val_api_ = api;
2023-09-13 04:45:10 +00:00
item_val_ = range;
item_all_ = get_opts;
}
afx_msg void OnBnClickedButton1();
CListCtrl list_;
afx_msg void OnBnClickedOk();
afx_msg void OnNMDblclkList1(NMHDR* pNMHDR, LRESULT* pResult);
CComboBox val_;
2023-09-13 04:45:10 +00:00
CComboBox range_type_;
afx_msg void OnCbnSelchangeComboField();
};