doc_and_tools/tools/apps/hgjson/DlgOptJson.h

200 lines
4.7 KiB
C
Raw Normal View History

#pragma once
// CDlgInput dialog
#include <string>
#include <vector>
#include <utility/known_file.h>
#include <coding/coding.h>
#include <file/file_util.h>
#include <sane/sane_ex.h>
#include "hex_edit.h"
namespace coding
{
typedef struct _clp_d
{
bool file;
std::wstring cont;
}CLPD, * LPCLPD;
INTER_MODULE_CALLBACK(get_string);
INTER_MODULE_CALLBACK(get_wstring);
INTER_MODULE_CALLBACK(get_clipboard_content);
std::wstring name_from_depend_exp(const std::wstring& depend_exp);
};
// Group: <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;<3B><>ֽ<EFBFBD><D6BD>ʽ;<3B>߼<EFBFBD><DFBC><EFBFBD><EFBFBD><EFBFBD>;
//
// Cat: ͼ<><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
//
2023-09-14 06:52:02 +00:00
class tooltip_wnd;
class CDlgOptJson : public CDialogEx
{
DECLARE_DYNAMIC(CDlgOptJson)
CComboBox group_;
CComboBox cat_;
CComboBox affect_;
CComboBox unit_;
CComboBox type_;
CComboBox range_;
CComboBox def_val_;
CComboBox depend_;
CComboBox parent_;
CComboBox logic_;
CComboBox lower_;
CComboBox upper_;
2023-09-21 08:10:25 +00:00
CComboBox visible_;
CComboBox export_type_;
CListBox depends_;
CTreeCtrl tree_;
CMenu tree_menu_;
CImageList tree_img_;
hex_edit fix_id_edit_;
2023-09-14 06:52:02 +00:00
tooltip_wnd* tooltips_;
std::wstring get_item_text(UINT id);
bool is_button_check(UINT id);
void set_button_check(UINT id, bool check);
2023-09-13 04:45:10 +00:00
std::wstring get_json_text(const wchar_t* tab = NULL);
public:
CDlgOptJson(CWnd* pParent = NULL); // standard constructor
virtual ~CDlgOptJson();
// Dialog Data
enum { IDD = IDD_NEW_JSON };
2023-09-13 04:45:10 +00:00
typedef struct _cond_val
{
std::string val;
std::string cond; // for range, must lead by 'min:' or 'max:' or 'step:'
}CONDVAL;
typedef struct _sane_opt_json
{
std::wstring name;
std::wstring title;
std::wstring desc;
std::wstring group;
std::wstring category;
std::wstring affect;
std::wstring unit;
std::wstring type;
2023-09-13 07:48:11 +00:00
std::vector<CONDVAL> def_val;
std::wstring range_type;
2023-09-13 04:45:10 +00:00
std::vector<CONDVAL> range;
std::wstring depend;
2023-09-18 07:59:52 +00:00
int size;
int ver;
int pos;
int fix_id;
2023-09-21 08:10:25 +00:00
int open;
bool readonly;
bool enable;
bool auto_restore_default;
struct _sane_opt_json()
{
init(this);
}
struct _sane_opt_json(known_file_util::IJsonW* jsn)
{
if (!from_json(jsn))
{
init(this);
}
}
2023-09-21 08:10:25 +00:00
static void init(struct _sane_opt_json* opt);
static void affect_str(int& val, std::wstring& str, bool to_str)
{
static std::wstring affect_desc[] = { L"none", L"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", L"ͼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", L"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>+<2B><><EFBFBD><EFBFBD>" };
if (to_str)
{
int ind = val >> 1;
if (ind >= 0 && ind < _countof(affect_desc))
str = affect_desc[ind];
else
str = affect_desc[0];
}
else
{
val = 0;
for (int i = 0; i < _countof(affect_desc); ++i)
{
if (str == affect_desc[i])
val = i << 1;
}
}
}
static bool compare_name(const struct _sane_opt_json& l, const struct _sane_opt_json& r)
{
return l.name < r.name;
}
static bool compare_title(const struct _sane_opt_json& l, const struct _sane_opt_json& r)
{
return l.title < r.title;
}
static bool compare_group(const struct _sane_opt_json& l, const struct _sane_opt_json& r)
{
return l.group < r.group;
}
static bool compare_position(const struct _sane_opt_json& l, const struct _sane_opt_json& r)
{
return l.pos < r.pos;
}
known_file_util::IJsonW* to_json(void);
bool from_json(known_file_util::IJsonW* jsn);
}SANEOPT;
std::vector<SANEOPT> opts_;
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
virtual BOOL OnInitDialog();
void from_ui(SANEOPT& sop);
void to_ui(const SANEOPT& sop);
HTREEITEM insert_new_item(const SANEOPT& opt, bool sel = true);
void delete_from_tree(const wchar_t* name = NULL);
HTREEITEM modify_tree_title(const wchar_t* name, const wchar_t* title);
bool load_from_file(const wchar_t* path_file);
bool load_from_json_text(const wchar_t* txt, std::wstring* err_msg = NULL);
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnCbnDataTypeSelchange();
afx_msg void OnCbnRangeSelchange();
afx_msg void OnCbnDependSelchange();
afx_msg void OnCbnParentSelchange();
afx_msg void OnCbnLogicSelchange();
afx_msg void OnCbnSelchange();
afx_msg void OnPaste();
afx_msg void OnBnClickedButtonModify();
afx_msg void OnBnClickedButtonAdd();
afx_msg void OnTvnSelchangedTree2(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnNMRClickTree2(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnTvnSelchangingTree2(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnTreeLoadfile();
afx_msg void OnTreeLoadclipboard();
afx_msg void OnLbnDblclkListDepend();
afx_msg void OnBnClickedButtonSet();
afx_msg void OnTreeDelitem();
afx_msg void OnBnClickedButtonExport();
afx_msg void OnTreeModifyallfield();
afx_msg void OnSortName();
afx_msg void OnSortTitle();
afx_msg void OnSortGroup();
afx_msg void OnSortPosition();
2023-09-13 04:45:10 +00:00
afx_msg void OnBnClickedButtonShowui();
2023-09-14 03:27:07 +00:00
afx_msg void OnDestroy();
};