部分选项特殊处理

This commit is contained in:
mo1027728827@qq.com 2022-06-28 17:28:51 +08:00
parent 17454877a8
commit a9f1e5a8dc
5 changed files with 50 additions and 41 deletions

View File

@ -20,13 +20,13 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>

View File

@ -20,7 +20,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<UseOfMfc>Dynamic</UseOfMfc>
</PropertyGroup>

View File

@ -5881,7 +5881,7 @@ BOOL ChgjsonDlg::OnInitDialog()
constraint_list_.InsertColumn(1, TEXT("Default"), 0, 48);
type_.SetCurSel(0);
constraint_.SetCurSel(0);
// constraint_list_.ModifyStyleEx(0, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_INFOTIP);
// constraint_list_.ModifyStyleEx(0, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_INFOTIP);
constraint_list_.SetExtendedStyle(constraint_list_.GetExtendedStyle() | LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_INFOTIP);
constraint_list_.SetItemData(constraint_list_.InsertItem(constraint_list_.GetItemCount(), TEXT("click me to add value ...")), 1);
tree_menu_.LoadMenu(IDR_MENU1);
@ -5950,15 +5950,15 @@ void ChgjsonDlg::to_define_header(std::vector<DEFH>& defs, const wchar_t* str, c
std::string ChgjsonDlg::save_define_header_2_file(std::vector<DEFH>& defs, const wchar_t* file)
{
int max_l = 0;
std::wstring space(L""),
cont(L"//\r\n// definitions for option titles and values\r\n//\r\n// all multi-bytes letter are in UTF-8 format\r\n//\r\n"),
prev(L"none");
std::wstring space(L""),
cont(L"//\r\n// definitions for option titles and values\r\n//\r\n// all multi-bytes letter are in UTF-8 format\r\n//\r\n"),
prev(L"none");
wchar_t buf[128] = { 0 };
time_t t = time(NULL);
struct tm *now = localtime(&t);
struct tm* now = localtime(&t);
swprintf(buf, L"// Date: %04d-%02d-%02d %02d:%02d:%02d\r\n//\r\n", now->tm_year + 1900, now->tm_mon + 1, now->tm_mday
, now->tm_hour, now->tm_min, now->tm_sec);
, now->tm_hour, now->tm_min, now->tm_sec);
cont += buf;
cont += L"\r\n#pragma once\r\n\r\n\r\n";
@ -6049,7 +6049,7 @@ void ChgjsonDlg::init_control_statu(void)
}
}
}
GetDlgItem(IDC_EDIT_DESC)->EnableWindow(valid);
GetDlgItem(IDC_CHECK_ADVANCED)->EnableWindow(valid);
constraint_.EnableWindow(valid);
@ -6107,7 +6107,7 @@ int ChgjsonDlg::find_config_item(const wchar_t* item_name)
else
return it - hg_items_.begin();
}
int ChgjsonDlg::check_depend(const wchar_t* l, const wchar_t* r)
int ChgjsonDlg::check_depend(const wchar_t* l, const wchar_t* r)
{
// -1: l depends on r; 0: no depend; 1: r depends on l
int depend = 0;
@ -6132,7 +6132,7 @@ int ChgjsonDlg::check_depend(const wchar_t* l, const wchar_t* r)
void ChgjsonDlg::set_control_status(const HGITEM& item)
{
::SetDlgItemTextW(m_hWnd, IDC_EDIT_DESC, item.desc.c_str());
if (item.type == L"bool")
type_.SetCurSel(0);
else if (item.type == L"int")
@ -6180,7 +6180,7 @@ void ChgjsonDlg::set_control_status(const HGITEM& item)
GetDlgItem(IDC_STATIC_TO)->ShowWindow(SW_SHOW);
GetDlgItem(IDC_EDIT_FROM)->ShowWindow(SW_SHOW);
GetDlgItem(IDC_EDIT_TO)->ShowWindow(SW_SHOW);
if (item.type == L"int")
{
SetDlgItemInt(IDC_EDIT_FROM, item.range.lower);
@ -6267,11 +6267,20 @@ void* ChgjsonDlg::create_json(int item, std::vector<DEFH>* def_h)
jsn->set_value(L"name", coding::a2u(SANE_STD_OPT_NAME_CUSTOM_AREA_RIGHT).c_str());
else if (hg_items_[item].title == L"\u626B\u63CF\u533A\u57DF\u4E0B\u4FA7\uFF08mm\uFF09")
jsn->set_value(L"name", coding::a2u(SANE_STD_OPT_NAME_CUSTOM_AREA_BOTTOM).c_str());
else if (hg_items_[item].title == L"ÑÕɫģʽ")
jsn->set_value(L"name", coding::a2u(SANE_STD_OPT_NAME_COLOR_MODE).c_str());
else if (hg_items_[item].title == L"Ö½Õųߴç")
jsn->set_value(L"name", coding::a2u(SANE_STD_OPT_NAME_PAPER).c_str());
else if (hg_items_[item].title == L"ɨÃèÒ³Ãæ")
jsn->set_value(L"name", coding::a2u(SANE_STD_OPT_NAME_PAGE_TYPE).c_str());
else if (hg_items_[item].title == L"³¬Éù²¨¼ì²â")
jsn->set_value(L"name", coding::a2u(SANE_STD_OPT_NAME_ULTRASONIC_CHECK).c_str());
else
{
swprintf_s(buf, _countof(buf) - 1, L"cfg-%d", hg_items_[item].index);
jsn->set_value(L"name", buf);
}
jsn->set_value(L"title", hg_items_[item].title.c_str());
if (def_h)
ChgjsonDlg::to_define_header(*def_h, hg_items_[item].title.c_str());
@ -6301,7 +6310,7 @@ void* ChgjsonDlg::create_json(int item, std::vector<DEFH>* def_h)
if (hg_items_[item].range.type == RANGE_TYPE_RANGE)
{
known_file_util::IJsonW *r = known_file_util::create_jsonW();
known_file_util::IJsonW* r = known_file_util::create_jsonW();
if (hg_items_[item].type == L"int")
{
r->set_value(L"min", (int)hg_items_[item].range.lower);
@ -6317,7 +6326,7 @@ void* ChgjsonDlg::create_json(int item, std::vector<DEFH>* def_h)
}
else if (hg_items_[item].range.type == RANGE_TYPE_LIST)
{
known_file_util::IJsonW *r = known_file_util::create_jsonW();
known_file_util::IJsonW* r = known_file_util::create_jsonW();
r->set_as_array(true);
if (hg_items_[item].type == L"int")
{
@ -6353,7 +6362,7 @@ void* ChgjsonDlg::create_json(int item, std::vector<DEFH>* def_h)
if (hg_items_[item].depend.size())
{
known_file_util::IJsonW *d = known_file_util::create_jsonW();
known_file_util::IJsonW* d = known_file_util::create_jsonW();
d->set_as_array(true);
for (int i = 0; i < hg_items_[item].depend.size(); ++i)
{
@ -6372,14 +6381,14 @@ void* ChgjsonDlg::create_json(int item, std::vector<DEFH>* def_h)
jsn->set_value(L"depend_and", d);
d->release();
}
if(prefer_size)
if (prefer_size)
jsn->set_value(L"size", prefer_size);
return jsn;
}
std::string ChgjsonDlg::to_json_text(bool for_const)
{
known_file_util::IJsonW *jsn = known_file_util::create_jsonW(), *item = NULL;
known_file_util::IJsonW* jsn = known_file_util::create_jsonW(), * item = NULL;
HTREEITEM root = tree_.GetRootItem(), child = NULL;
std::wstring val(get_tree_selected_item_text(&tree_, root));
int count = 1, group = 1, ind = 0;
@ -6476,14 +6485,14 @@ std::string ChgjsonDlg::to_json_text(bool for_const)
// file_util::display_file_in_explorer(file.c_str());
//}
}
return utf8;
}
void ChgjsonDlg::add_item(void* jsn_root, void* jsn_obj, HTREEITEM parent)
{
known_file_util::IJsonW *jsn = (known_file_util::IJsonW*)jsn_obj, *child = NULL,
*root = (known_file_util::IJsonW*)jsn_root;
const wchar_t *val = NULL;
known_file_util::IJsonW* jsn = (known_file_util::IJsonW*)jsn_obj, * child = NULL,
* root = (known_file_util::IJsonW*)jsn_root;
const wchar_t* val = NULL;
HGITEM item;
wchar_t buf[128] = { 0 };
@ -6556,7 +6565,7 @@ void ChgjsonDlg::add_item(void* jsn_root, void* jsn_obj, HTREEITEM parent)
if (split(m.str_val, &di))
{
known_file_util::IJsonW *d = NULL;
known_file_util::IJsonW* d = NULL;
root->get_value(di.parent.c_str(), &d);
if (d)
{
@ -6574,7 +6583,7 @@ void ChgjsonDlg::add_item(void* jsn_root, void* jsn_obj, HTREEITEM parent)
m = child->next_member();
if (split(m.str_val, &di))
{
known_file_util::IJsonW *d = NULL;
known_file_util::IJsonW* d = NULL;
root->get_value(di.parent.c_str(), &d);
if (d)
{
@ -6672,7 +6681,7 @@ void ChgjsonDlg::add_item(void* jsn_root, void* jsn_obj, HTREEITEM parent)
bool ChgjsonDlg::load_from_json_text(const wchar_t* txt)
{
int pos = 0;
known_file_util::IJsonW *jsn = known_file_util::create_jsonW(txt, &pos), *child = NULL;
known_file_util::IJsonW* jsn = known_file_util::create_jsonW(txt, &pos), * child = NULL;
if (!jsn)
return false;
@ -6697,7 +6706,7 @@ bool ChgjsonDlg::load_from_json_text(const wchar_t* txt)
for (int i = 1; i < count; ++i)
{
wchar_t key[20] = { 0 };
swprintf_s(key, _countof(key) - 1, L"%d", i);
jsn->get_value(key, &child);
if (child)
@ -7054,7 +7063,7 @@ void ChgjsonDlg::OnCbnSelchangeDependItem()
// TODO: Add your control notification handler code here
int sel = depend_item_.GetCurSel(), d_ind = -1;
wchar_t name[128] = { 0 }, type[128] = { 0 };
::GetWindowTextW(depend_item_.m_hWnd, name, _countof(name) - 1);
::GetWindowTextW(type_.m_hWnd, type, _countof(type) - 1);
d_ind = find_config_item(name);
@ -7133,9 +7142,9 @@ void ChgjsonDlg::OnCbnSelchangeLogic()
}
void ChgjsonDlg::OnLvnEndlabeleditListValues(NMHDR *pNMHDR, LRESULT *pResult)
void ChgjsonDlg::OnLvnEndlabeleditListValues(NMHDR* pNMHDR, LRESULT* pResult)
{
NMLVDISPINFO *pDispInfo = reinterpret_cast<NMLVDISPINFO*>(pNMHDR);
NMLVDISPINFO* pDispInfo = reinterpret_cast<NMLVDISPINFO*>(pNMHDR);
// TODO: Add your control notification handler code here
*pResult = 0;
DWORD_PTR data = constraint_list_.GetItemData(pDispInfo->item.iItem);
@ -7223,7 +7232,7 @@ void ChgjsonDlg::OnBnClickedButton3()
// add depend items
DEPENDITEM di;
wchar_t oper[128] = { 0 };
bool or = ((CButton*)GetDlgItem(IDC_RADIO_ANY))->GetCheck() == BST_CHECKED;
bool or = ((CButton*)GetDlgItem(IDC_RADIO_ANY))->GetCheck() == BST_CHECKED;
DWORD_PTR data = NULL;
std::wstring name(get_tree_selected_item_text(&tree_, &data));
std::vector<HGITEM>::iterator it = std::find(hg_items_.begin(), hg_items_.end(), name.c_str());
@ -7285,9 +7294,9 @@ void ChgjsonDlg::OnBnClickedButton3()
}
it->depend.push_back(di);
it->depend_or = or;
// if (depends_.FindString(-1, (di.parent + di.logic_values).c_str()) == -1)
depends_.AddString((di.parent + di.logic_values).c_str());
it->depend_or = or ;
// if (depends_.FindString(-1, (di.parent + di.logic_values).c_str()) == -1)
depends_.AddString((di.parent + di.logic_values).c_str());
}
void ChgjsonDlg::OnBnClickedButton4()
{
@ -7391,7 +7400,7 @@ void ChgjsonDlg::OnBnClickedButton4()
}
void ChgjsonDlg::OnNMRClickMfcshelltree1(NMHDR *pNMHDR, LRESULT *pResult)
void ChgjsonDlg::OnNMRClickMfcshelltree1(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
*pResult = 0;
@ -7426,7 +7435,7 @@ void ChgjsonDlg::OnNMRClickMfcshelltree1(NMHDR *pNMHDR, LRESULT *pResult)
}
void ChgjsonDlg::OnTvnSelchangedTree1(NMHDR *pNMHDR, LRESULT *pResult)
void ChgjsonDlg::OnTvnSelchangedTree1(NMHDR* pNMHDR, LRESULT* pResult)
{
LPNMTREEVIEW pNMTreeView = reinterpret_cast<LPNMTREEVIEW>(pNMHDR);
// TODO: Add your control notification handler code here
@ -7474,7 +7483,7 @@ void ChgjsonDlg::OnListmenuDelete()
}
void ChgjsonDlg::OnNMRClickListValues(NMHDR *pNMHDR, LRESULT *pResult)
void ChgjsonDlg::OnNMRClickListValues(NMHDR* pNMHDR, LRESULT* pResult)
{
LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR);
// TODO: Add your control notification handler code here
@ -7533,7 +7542,7 @@ void ChgjsonDlg::OnTreeLoadfile()
}
void ChgjsonDlg::OnLvnKeydownListValues(NMHDR *pNMHDR, LRESULT *pResult)
void ChgjsonDlg::OnLvnKeydownListValues(NMHDR* pNMHDR, LRESULT* pResult)
{
LPNMLVKEYDOWN pLVKeyDow = reinterpret_cast<LPNMLVKEYDOWN>(pNMHDR);
// TODO: Add your control notification handler code here
@ -7574,7 +7583,7 @@ void ChgjsonDlg::OnLvnKeydownListValues(NMHDR *pNMHDR, LRESULT *pResult)
}
void ChgjsonDlg::OnTvnKeydownTree1(NMHDR *pNMHDR, LRESULT *pResult)
void ChgjsonDlg::OnTvnKeydownTree1(NMHDR* pNMHDR, LRESULT* pResult)
{
LPNMTVKEYDOWN pTVKeyDown = reinterpret_cast<LPNMTVKEYDOWN>(pNMHDR);
// TODO: Add your control notification handler code here
@ -7666,7 +7675,7 @@ void ChgjsonDlg::OnTvnKeydownTree1(NMHDR *pNMHDR, LRESULT *pResult)
}
void ChgjsonDlg::OnTvnGetInfoTipTree1(NMHDR *pNMHDR, LRESULT *pResult)
void ChgjsonDlg::OnTvnGetInfoTipTree1(NMHDR* pNMHDR, LRESULT* pResult)
{
LPNMTVGETINFOTIP pGetInfoTip = reinterpret_cast<LPNMTVGETINFOTIP>(pNMHDR);
// TODO: Add your control notification handler code here
@ -7677,7 +7686,7 @@ void ChgjsonDlg::OnTvnGetInfoTipTree1(NMHDR *pNMHDR, LRESULT *pResult)
}
void ChgjsonDlg::OnLvnGetInfoTipListValues(NMHDR *pNMHDR, LRESULT *pResult)
void ChgjsonDlg::OnLvnGetInfoTipListValues(NMHDR* pNMHDR, LRESULT* pResult)
{
LPNMLVGETINFOTIP pGetInfoTip = reinterpret_cast<LPNMLVGETINFOTIP>(pNMHDR);
// TODO: Add your control notification handler code here
@ -7706,7 +7715,7 @@ void ChgjsonDlg::OnTreeExportCharConstants()
{
// TODO: 在此添加命令处理程序代码
std::string bom(to_json_text(true));
if(bom.empty())
if (bom.empty())
MessageBox(TEXT("No char constant"));
else
MessageBox(TEXT("const string has set to clipboard already"));

Binary file not shown.

Binary file not shown.