2023-06-20 05:35:59 +00:00
|
|
|
|
#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
|
|
|
|
|
2023-06-20 05:35:59 +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_;
|
2023-06-20 05:35:59 +00:00
|
|
|
|
|
|
|
|
|
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); // 标准构造函数
|
2023-06-20 05:35:59 +00:00
|
|
|
|
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-06-20 05:35:59 +00:00
|
|
|
|
|
2023-09-13 04:45:10 +00:00
|
|
|
|
std::vector<CONDVAL> vals_;
|
2023-09-13 07:48:11 +00:00
|
|
|
|
std::vector<CONDVAL> init_;
|
|
|
|
|
int list_cur_sel_;
|
2023-06-20 05:35:59 +00:00
|
|
|
|
|
|
|
|
|
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)
|
2023-06-20 05:35:59 +00:00
|
|
|
|
{
|
|
|
|
|
init_val_api_ = api;
|
2023-09-13 04:45:10 +00:00
|
|
|
|
item_val_ = range;
|
|
|
|
|
item_all_ = get_opts;
|
2023-06-20 05:35:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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_;
|
2023-09-13 07:48:11 +00:00
|
|
|
|
CMenu func_menu_;
|
2023-06-20 05:35:59 +00:00
|
|
|
|
afx_msg void OnCbnSelchangeComboField();
|
2023-09-13 07:48:11 +00:00
|
|
|
|
afx_msg void OnRangevaluemenuDefault();
|
|
|
|
|
afx_msg void OnRangevaluemenuDelete();
|
|
|
|
|
afx_msg void OnRangevaluemenuSetcondition();
|
|
|
|
|
afx_msg void OnNMRClickList1(NMHDR* pNMHDR, LRESULT* pResult);
|
2023-06-20 05:35:59 +00:00
|
|
|
|
};
|