doc_and_tools/tools/apps/hgjson/DlgRange.h

88 lines
2.3 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#pragma once
// CDlgRange 对话框
#include <string>
#include <vector>
#include <functional>
#define INIT_VAL_API_PROTO std::function<void(const wchar_t*, CComboBox*)>
class CDlgRange : public CDialogEx
{
DECLARE_DYNAMIC(CDlgRange)
INIT_VAL_API_PROTO init_val_api_;
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 title_;
std::wstring get_item_text(UINT id);
public:
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:
typedef struct _cond_val
{
std::wstring val;
std::wstring cond; // for range, must lead by 'min:' or 'max:' or 'step:'
// bool def_only; // 是否仅应用于默认值上
struct _cond_val() : val(L""), cond(L"")//, def_only(false)
{}
struct _cond_val(const std::wstring& v) : val(v), cond(L"")//, def_only(false)
{}
}CONDVAL;
std::vector<CONDVAL> vals_;
std::vector<CONDVAL> init_;
int list_cur_sel_;
std::vector<std::wstring> visible_;
enum {TYPE_RANGE, TYPE_LIST, TYPE_FIELDS, TYPE_VISIBLE};
int type_; // 0 - range; 1 - list; 2 - modify fields
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;
item_val_ = range;
item_all_ = get_opts;
}
void set_visible_values(const std::vector<std::wstring>& vals)
{
visible_ = vals;
}
void set_title(const wchar_t* t)
{
title_ = t;
}
afx_msg void OnBnClickedButton1();
CListCtrl list_;
afx_msg void OnBnClickedOk();
afx_msg void OnNMDblclkList1(NMHDR* pNMHDR, LRESULT* pResult);
CComboBox val_;
CComboBox range_type_;
CMenu func_menu_;
afx_msg void OnCbnSelchangeComboField();
afx_msg void OnRangevaluemenuDefault();
afx_msg void OnRangevaluemenuDelete();
afx_msg void OnRangevaluemenuSetcondition();
afx_msg void OnNMRClickList1(NMHDR* pNMHDR, LRESULT* pResult);
};