152 lines
4.0 KiB
C
152 lines
4.0 KiB
C
|
|
||
|
// hgjsonDlg.h : header file
|
||
|
//
|
||
|
|
||
|
#pragma once
|
||
|
#include "afxshelltreectrl.h"
|
||
|
#include "afxwin.h"
|
||
|
#include "afxcmn.h"
|
||
|
#include <vector>
|
||
|
#include <string>
|
||
|
#include <algorithm>
|
||
|
|
||
|
|
||
|
// ChgjsonDlg dialog
|
||
|
class ChgjsonDlg : public CDialogEx
|
||
|
{
|
||
|
// Construction
|
||
|
public:
|
||
|
ChgjsonDlg(CWnd* pParent = NULL); // standard constructor
|
||
|
|
||
|
// Dialog Data
|
||
|
enum { IDD = IDD_HGJSON_DIALOG };
|
||
|
|
||
|
protected:
|
||
|
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||
|
|
||
|
public:
|
||
|
typedef struct _depend_item
|
||
|
{
|
||
|
std::wstring parent;
|
||
|
std::wstring logic_values; // include logic operator: "==2"
|
||
|
|
||
|
bool operator==(const wchar_t* name)
|
||
|
{
|
||
|
return wcscmp(name, parent.c_str()) == 0;
|
||
|
}
|
||
|
}DEPENDITEM;
|
||
|
enum range_type
|
||
|
{
|
||
|
RANGE_TYPE_NONE = 0,
|
||
|
RANGE_TYPE_RANGE,
|
||
|
RANGE_TYPE_LIST,
|
||
|
};
|
||
|
typedef struct _range
|
||
|
{
|
||
|
int type;
|
||
|
double lower;
|
||
|
double upper;
|
||
|
std::vector<std::wstring> queue;
|
||
|
}RANGE;
|
||
|
typedef struct _hg_item
|
||
|
{
|
||
|
std::wstring title;
|
||
|
std::wstring desc;
|
||
|
std::wstring type;
|
||
|
std::wstring init_val;
|
||
|
int index;
|
||
|
int bytes;
|
||
|
bool advanced;
|
||
|
bool depend_or; // or or and
|
||
|
std::vector<DEPENDITEM> depend;
|
||
|
RANGE range;
|
||
|
|
||
|
bool operator==(const wchar_t* name)
|
||
|
{
|
||
|
return wcscmp(name, title.c_str()) == 0;
|
||
|
}
|
||
|
struct _hg_item(const wchar_t* ti= L"")
|
||
|
{
|
||
|
title = ti ? ti : L"";
|
||
|
desc = L"";
|
||
|
type = L"bool";
|
||
|
init_val = L"true";
|
||
|
bytes = 4;
|
||
|
advanced = false;
|
||
|
depend_or = true;
|
||
|
range.type = RANGE_TYPE_NONE;
|
||
|
}
|
||
|
}HGITEM;
|
||
|
std::vector<HGITEM> hg_items_;
|
||
|
bool show_tree_tooltips_;
|
||
|
bool show_list_tooltips_;
|
||
|
|
||
|
// Implementation
|
||
|
protected:
|
||
|
HICON m_hIcon;
|
||
|
CMenu tree_menu_;
|
||
|
CMenu func_menu_;
|
||
|
CImageList tree_img_;
|
||
|
|
||
|
// Generated message map functions
|
||
|
virtual BOOL OnInitDialog();
|
||
|
afx_msg void OnPaint();
|
||
|
afx_msg HCURSOR OnQueryDragIcon();
|
||
|
DECLARE_MESSAGE_MAP()
|
||
|
|
||
|
void init_control_statu(void);
|
||
|
void delete_tree_item(HTREEITEM root);
|
||
|
int find_config_item(const wchar_t* item_name);
|
||
|
int check_depend(const wchar_t* l, const wchar_t* r); // -1: l depends on r; 0: no depend; 1: r depends on l
|
||
|
void set_control_status(const HGITEM& item);
|
||
|
|
||
|
void* create_json(int item);
|
||
|
std::string to_json_text(void);
|
||
|
void add_item(void* jsn_root, void* jsn_obj, HTREEITEM parent);
|
||
|
bool load_from_json_text(const wchar_t* txt);
|
||
|
bool load_from_file(const wchar_t* path_file);
|
||
|
void get_all_names(HTREEITEM root, std::vector<std::wstring>& names, DWORD mask = 0);
|
||
|
void on_config_name_changed(const wchar_t* prev, const wchar_t* now);
|
||
|
HTREEITEM add_tree_item(const wchar_t* title, DWORD data, HTREEITEM parent = TVI_ROOT, HTREEITEM after = TVI_LAST);
|
||
|
|
||
|
public:
|
||
|
afx_msg void OnTreeAddGroup();
|
||
|
afx_msg void OnTreeAddItem();
|
||
|
afx_msg void OnTreeDelItem();
|
||
|
CTreeCtrl tree_;
|
||
|
afx_msg void OnTreeAddProduct();
|
||
|
afx_msg void OnBnClickedButton3();
|
||
|
afx_msg void OnBnClickedButton1();
|
||
|
afx_msg void OnBnClickedButton2();
|
||
|
CListBox depends_;
|
||
|
CListCtrl constraint_list_;
|
||
|
afx_msg void OnCbnSelchangeDataType();
|
||
|
afx_msg void OnCbnSelchangeConstraintType();
|
||
|
afx_msg void OnCbnSelchangeDependItem();
|
||
|
afx_msg void OnCbnSelchangeLogic();
|
||
|
afx_msg void OnLvnEndlabeleditListValues(NMHDR *pNMHDR, LRESULT *pResult);
|
||
|
CComboBox type_;
|
||
|
CComboBox constraint_;
|
||
|
afx_msg void OnBnClickedDepend();
|
||
|
CComboBox logic_;
|
||
|
CComboBox depend_item_;
|
||
|
afx_msg void OnBnClickedButton4();
|
||
|
afx_msg void OnNMRClickMfcshelltree1(NMHDR *pNMHDR, LRESULT *pResult);
|
||
|
CComboBox combo_default_;
|
||
|
afx_msg void OnTvnSelchangedTree1(NMHDR *pNMHDR, LRESULT *pResult);
|
||
|
afx_msg void OnListmenuSetdefault();
|
||
|
afx_msg void OnListmenuDelete();
|
||
|
afx_msg void OnNMRClickListValues(NMHDR *pNMHDR, LRESULT *pResult);
|
||
|
afx_msg void OnLbnDblclkList3();
|
||
|
afx_msg void OnDropFiles(HDROP hDropInfo);
|
||
|
afx_msg void OnTreeRename();
|
||
|
afx_msg void OnTreeLoadfile();
|
||
|
afx_msg void OnLvnKeydownListValues(NMHDR *pNMHDR, LRESULT *pResult);
|
||
|
afx_msg void OnTvnKeydownTree1(NMHDR *pNMHDR, LRESULT *pResult);
|
||
|
afx_msg void OnTvnGetInfoTipTree1(NMHDR *pNMHDR, LRESULT *pResult);
|
||
|
afx_msg void OnLvnGetInfoTipListValues(NMHDR *pNMHDR, LRESULT *pResult);
|
||
|
afx_msg void OnTreeTooltips();
|
||
|
afx_msg void OnListmenuTooltips();
|
||
|
};
|
||
|
|