将默认值,从range中独立出来成一条单独的数据,以适应条件可能不同带来的冲突
This commit is contained in:
parent
26978818ba
commit
59377eee76
|
@ -80,29 +80,23 @@ BOOL CDlgRange::OnInitDialog()
|
|||
if (type_ == TYPE_LIST || type_ == TYPE_RANGE || type_ == TYPE_VISIBLE)
|
||||
{
|
||||
bool def = false;
|
||||
std::vector<CONDVAL> init_cpy(init_);
|
||||
|
||||
for (auto& v: vals_)
|
||||
{
|
||||
int ind = list_.InsertItem(list_.GetItemCount(), v.val.c_str());
|
||||
std::wstring cond(v.cond);
|
||||
|
||||
for (auto& init : init_)
|
||||
{
|
||||
if (v.val == init.val)
|
||||
{
|
||||
//list_.SetItemText(ind, 2, L"yes");
|
||||
cond.insert(0, L"default:");
|
||||
//def = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
list_.SetItemText(ind, 1, cond.c_str());
|
||||
list_.SetItemData(ind, (DWORD_PTR)0);
|
||||
}
|
||||
|
||||
for (auto& init : init_)
|
||||
for (auto& init : init_cpy)
|
||||
{
|
||||
int ind = list_.InsertItem(list_.GetItemCount(), init.val.c_str());
|
||||
|
||||
list_.SetItemText(ind, 1, (L"default:" + init.cond).c_str());
|
||||
list_.SetItemData(ind, (DWORD_PTR)1);
|
||||
}
|
||||
}
|
||||
//else if(type_ == TYPE_RANGE && vals_.size() == 3)
|
||||
|
@ -285,23 +279,43 @@ void CDlgRange::OnRangevaluemenuDefault()
|
|||
wchar_t buf[512] = { 0 };
|
||||
bool def = false;
|
||||
|
||||
//list_.GetItemText(list_cur_sel_, 2, buf, _countof(buf) - 1);
|
||||
//if (buf[0] == 0)
|
||||
// wcscpy(buf, L"yes");
|
||||
//else
|
||||
// buf[0] = 0;
|
||||
//list_.SetItemText(list_cur_sel_, 2, buf);
|
||||
//def = wcscmp(buf, L"yes") == 0;
|
||||
|
||||
list_.GetItemText(list_cur_sel_, 1, buf, _countof(buf) - 1);
|
||||
std::wstring cond(buf);
|
||||
std::wstring cond(buf), val(L"");
|
||||
size_t pos = cond.find(L"default:");
|
||||
|
||||
if (pos == 0)
|
||||
cond.erase(0, lstrlenW(L"default:"));
|
||||
list_.DeleteItem(list_cur_sel_);
|
||||
else
|
||||
{
|
||||
list_.GetItemText(list_cur_sel_, 0, buf, _countof(buf) - 1);
|
||||
val = buf;
|
||||
for (int i = 0; i < list_.GetItemCount(); ++i)
|
||||
{
|
||||
if (i == list_cur_sel_)
|
||||
continue;
|
||||
list_.GetItemText(i, 0, buf, _countof(buf) - 1);
|
||||
if (val == buf)
|
||||
{
|
||||
list_.GetItemText(i, 1, buf, _countof(buf) - 1);
|
||||
if (wcsstr(buf, L"default:") == buf)
|
||||
{
|
||||
list_.EnsureVisible(i, FALSE);
|
||||
//ListView_SetSelectionMark(list_.m_hWnd, i);
|
||||
list_.SetItemState(list_cur_sel_, 0, LVIS_SELECTED);
|
||||
list_cur_sel_ = -1;
|
||||
list_.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cond.insert(0, L"default:");
|
||||
list_.SetItemText(list_cur_sel_, 1, cond.c_str());
|
||||
pos = list_.InsertItem(list_.GetItemCount(), val.c_str());
|
||||
list_.SetItemText(pos, 1, cond.c_str());
|
||||
list_.SetItemData(pos, (DWORD_PTR)1);
|
||||
list_.EnsureVisible(pos, FALSE);
|
||||
list_.SetItemState(pos, LVIS_SELECTED, LVIS_SELECTED);
|
||||
}
|
||||
|
||||
list_cur_sel_ = -1;
|
||||
}
|
||||
|
@ -341,6 +355,7 @@ void CDlgRange::OnRangevaluemenuSetcondition()
|
|||
list_cur_sel_ = -1;
|
||||
}
|
||||
|
||||
|
||||
int get_list_sel(CListCtrl* lc)
|
||||
{
|
||||
POSITION pos = lc->GetFirstSelectedItemPosition();
|
||||
|
@ -418,10 +433,13 @@ void CDlgRange::OnBnClickedOk()
|
|||
else
|
||||
val.cond = L"default";
|
||||
init_.push_back(val);
|
||||
if ((bool)list_.GetItemData(i)) // 是否仅用于默认值
|
||||
continue;
|
||||
//val.cond = c;
|
||||
if (er)
|
||||
val.cond.erase(0, lstrlenW(L"default"));
|
||||
}
|
||||
|
||||
if (range)
|
||||
{
|
||||
if (val.cond.find(L"min:") == 0)
|
||||
|
@ -530,3 +548,4 @@ void CDlgRange::OnBnClickedOk()
|
|||
|
||||
CDialogEx::OnOK();
|
||||
}
|
||||
|
||||
|
|
|
@ -41,10 +41,11 @@ public:
|
|||
{
|
||||
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"")
|
||||
struct _cond_val() : val(L""), cond(L"")//, def_only(false)
|
||||
{}
|
||||
struct _cond_val(const std::wstring& v) : val(v), cond(L"")
|
||||
struct _cond_val(const std::wstring& v) : val(v), cond(L"")//, def_only(false)
|
||||
{}
|
||||
}CONDVAL;
|
||||
|
||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue