#pragma once // CDlgInput dialog #include #include #include #include #include #include #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: 基本设置;图像处理;送纸方式;高级设置; // // Cat: 图像处理; // 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_; CComboBox export_type_; CListBox depends_; CTreeCtrl tree_; CMenu tree_menu_; CImageList tree_img_; hex_edit fix_id_edit_; std::wstring get_item_text(UINT id); bool is_button_check(UINT id); void set_button_check(UINT id, bool check); public: CDlgOptJson(CWnd* pParent = NULL); // standard constructor virtual ~CDlgOptJson(); // Dialog Data enum { IDD = IDD_NEW_JSON }; 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; std::string def_val; std::wstring range_type; std::vector range; std::wstring depend_oper; std::vector depends; int ver; int pos; int fix_id; bool readonly; bool open; 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); } } static void init(struct _sane_opt_json* opt) { opt->name = opt->title = opt->desc = L""; opt->group = L"\u57FA\u672C\u8BBE\u7F6E"; opt->category = opt->unit = opt->affect = opt->depend_oper = opt->range_type = L"none"; opt->range.clear(); opt->depends.clear(); opt->def_val = ""; opt->type = L"int"; opt->ver = 1; opt->fix_id = 0; opt->pos = -1; opt->readonly = false; opt->open = true; opt->enable = true; opt->auto_restore_default = true; } static void affect_str(int& val, std::wstring& str, bool to_str) { static std::wstring affect_desc[] = { L"none", L"其它属性", L"图像参数", L"属性+参数" }; 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 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(); };