|
@@ -1,7 +1,7 @@
|
|
|
#include "pch.h"
|
|
#include "pch.h"
|
|
|
#include "CMemoWnd.h"
|
|
#include "CMemoWnd.h"
|
|
|
|
|
|
|
|
-//预设备注文案(24 条):0~3 辣度四档(互斥)、4~7 咸淡、8~15 忌口、16~23 出品与打包
|
|
|
|
|
|
|
+// 预设备注文案(24 条):0~7 口味、8~15 忌口、16~23 其他
|
|
|
const wchar_t* CMemoWnd::PRESET_MEMO[CMemoWnd::PRESET_COUNT] = {
|
|
const wchar_t* CMemoWnd::PRESET_MEMO[CMemoWnd::PRESET_COUNT] = {
|
|
|
L"免辣", L"微辣", L"中辣", L"特辣", L"少盐", L"少油", L"少糖", L"少醋",
|
|
L"免辣", L"微辣", L"中辣", L"特辣", L"少盐", L"少油", L"少糖", L"少醋",
|
|
|
L"免香菜", L"免葱", L"免蒜", L"免姜", L"免花生", L"免芝麻", L"免辣油", L"免味精",
|
|
L"免香菜", L"免葱", L"免蒜", L"免姜", L"免花生", L"免芝麻", L"免辣油", L"免味精",
|
|
@@ -115,7 +115,6 @@ LRESULT CMemoWnd::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandl
|
|
|
styleValue &= ~WS_CAPTION;
|
|
styleValue &= ~WS_CAPTION;
|
|
|
::SetWindowLong(*this, GWL_STYLE, styleValue | WS_CLIPSIBLINGS | WS_CLIPCHILDREN);
|
|
::SetWindowLong(*this, GWL_STYLE, styleValue | WS_CLIPSIBLINGS | WS_CLIPCHILDREN);
|
|
|
|
|
|
|
|
- // 把自己的窗口句柄与窗口绘制管理器挂接在一起
|
|
|
|
|
m_pm.Init(m_hWnd);
|
|
m_pm.Init(m_hWnd);
|
|
|
|
|
|
|
|
m_pm.AddPreMessageFilter(this);
|
|
m_pm.AddPreMessageFilter(this);
|
|
@@ -125,10 +124,8 @@ LRESULT CMemoWnd::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandl
|
|
|
CControlUI* pRoot = builder.Create(_T("memo_edit_dlg.xml"), (UINT)0, NULL, &m_pm);
|
|
CControlUI* pRoot = builder.Create(_T("memo_edit_dlg.xml"), (UINT)0, NULL, &m_pm);
|
|
|
ASSERT(pRoot && "Failed to parse XML");
|
|
ASSERT(pRoot && "Failed to parse XML");
|
|
|
|
|
|
|
|
- // 把这些控件绘制到本窗口上
|
|
|
|
|
m_pm.AttachDialog(pRoot);
|
|
m_pm.AttachDialog(pRoot);
|
|
|
|
|
|
|
|
- // 把自己加入到CPaintManagerUI的m_aNotifiers数组中,用于处理Notify函数
|
|
|
|
|
m_pm.AddNotifier(this);
|
|
m_pm.AddNotifier(this);
|
|
|
|
|
|
|
|
Init();
|
|
Init();
|
|
@@ -158,7 +155,7 @@ void CMemoWnd::Notify(TNotifyUI& msg)
|
|
|
}
|
|
}
|
|
|
else if (senderName == _T("memo_preset_item"))
|
|
else if (senderName == _T("memo_preset_item"))
|
|
|
{
|
|
{
|
|
|
- TogglePresetTag((int)msg.pSender->GetTag());
|
|
|
|
|
|
|
+ AppendPresetText((int)msg.pSender->GetTag());
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -170,32 +167,30 @@ void CMemoWnd::Notify(TNotifyUI& msg)
|
|
|
pFukuanEdit->SetFocus();
|
|
pFukuanEdit->SetFocus();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- //加上这句,才支持虚拟键盘
|
|
|
|
|
CModalWnd::Notify(msg);
|
|
CModalWnd::Notify(msg);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void CMemoWnd::Init()
|
|
void CMemoWnd::Init()
|
|
|
{
|
|
{
|
|
|
- for (int i = 0; i < PRESET_COUNT; i++)
|
|
|
|
|
- {
|
|
|
|
|
- m_presetSelected[i] = false;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
InitPresetTags();
|
|
InitPresetTags();
|
|
|
-
|
|
|
|
|
- UpdatePresetCount();
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void CMemoWnd::InitPresetTags()
|
|
void CMemoWnd::InitPresetTags()
|
|
|
{
|
|
{
|
|
|
- CTileLayoutUI* pTile = static_cast<CTileLayoutUI*>(m_pm.FindControl(_T("memo_preset")));
|
|
|
|
|
- if (pTile == NULL)
|
|
|
|
|
- {
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ CTileLayoutUI* pTiles[3] = {
|
|
|
|
|
+ static_cast<CTileLayoutUI*>(m_pm.FindControl(_T("memo_preset_kouwei"))),
|
|
|
|
|
+ static_cast<CTileLayoutUI*>(m_pm.FindControl(_T("memo_preset_jikou"))),
|
|
|
|
|
+ static_cast<CTileLayoutUI*>(m_pm.FindControl(_T("memo_preset_qita")))
|
|
|
|
|
+ };
|
|
|
|
|
|
|
|
for (int i = 0; i < PRESET_COUNT; i++)
|
|
for (int i = 0; i < PRESET_COUNT; i++)
|
|
|
{
|
|
{
|
|
|
|
|
+ int nGroup = i / 8;
|
|
|
|
|
+ if (nGroup < 0 || nGroup >= 3 || pTiles[nGroup] == NULL)
|
|
|
|
|
+ {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
CButtonUI* pBtn = new CButtonUI;
|
|
CButtonUI* pBtn = new CButtonUI;
|
|
|
|
|
|
|
|
pBtn->SetName(_T("memo_preset_item"));
|
|
pBtn->SetName(_T("memo_preset_item"));
|
|
@@ -203,121 +198,57 @@ void CMemoWnd::InitPresetTags()
|
|
|
pBtn->SetTag((UINT_PTR)i);
|
|
pBtn->SetTag((UINT_PTR)i);
|
|
|
pBtn->SetFont(13);
|
|
pBtn->SetFont(13);
|
|
|
|
|
|
|
|
- pTile->Add(pBtn);
|
|
|
|
|
-
|
|
|
|
|
- UpdatePresetTagStyle(i);
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-void CMemoWnd::TogglePresetTag(int nIndex)
|
|
|
|
|
-{
|
|
|
|
|
- if (nIndex < 0 || nIndex >= PRESET_COUNT)
|
|
|
|
|
- {
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- m_presetSelected[nIndex] = !m_presetSelected[nIndex];
|
|
|
|
|
|
|
+ // 方案 B:不维护选中态,标签使用抗锯齿 PNG 九宫格
|
|
|
|
|
+ // 按设计稿:73×40 白底圆角矩形(圆角 8)+ 1px #E8EAED 描边,源尺寸=目标尺寸无拉伸。
|
|
|
|
|
+ pBtn->SetNormalImage(_T("file='memo_tag_n.png' corner='8,8,8,8'"));
|
|
|
|
|
+ pBtn->SetHotImage(_T("file='memo_tag_h.png' corner='8,8,8,8'"));
|
|
|
|
|
+ pBtn->SetPushedImage(_T("file='memo_tag_p.png' corner='8,8,8,8'"));
|
|
|
|
|
+ pBtn->SetTextColor(0xFF1F2329);
|
|
|
|
|
+ pBtn->SetHotTextColor(0xFF1F2329);
|
|
|
|
|
+ pBtn->SetPushedTextColor(0xFF1F2329);
|
|
|
|
|
+ pBtn->SetFocusedTextColor(0xFF1F2329);
|
|
|
|
|
|
|
|
- //辣度四档(免辣/微辣/中辣/特辣)互斥,避免出现「免辣、特辣」这种矛盾备注
|
|
|
|
|
- if (m_presetSelected[nIndex] && nIndex < 4)
|
|
|
|
|
- {
|
|
|
|
|
- for (int i = 0; i < 4; i++)
|
|
|
|
|
- {
|
|
|
|
|
- if (i != nIndex && m_presetSelected[i])
|
|
|
|
|
- {
|
|
|
|
|
- m_presetSelected[i] = false;
|
|
|
|
|
- UpdatePresetTagStyle(i);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ pTiles[nGroup]->Add(pBtn);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- UpdatePresetTagStyle(nIndex);
|
|
|
|
|
-
|
|
|
|
|
- UpdatePresetCount();
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-void CMemoWnd::UpdatePresetTagStyle(int nIndex)
|
|
|
|
|
|
|
+void CMemoWnd::AppendPresetText(int nIndex)
|
|
|
{
|
|
{
|
|
|
if (nIndex < 0 || nIndex >= PRESET_COUNT)
|
|
if (nIndex < 0 || nIndex >= PRESET_COUNT)
|
|
|
{
|
|
{
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- CTileLayoutUI* pTile = static_cast<CTileLayoutUI*>(m_pm.FindControl(_T("memo_preset")));
|
|
|
|
|
- if (pTile == NULL)
|
|
|
|
|
|
|
+ CEditUI* pEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("content")));
|
|
|
|
|
+ if (pEdit == NULL)
|
|
|
{
|
|
{
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- CButtonUI* pBtn = static_cast<CButtonUI*>(pTile->GetItemAt(nIndex));
|
|
|
|
|
- if (pBtn == NULL)
|
|
|
|
|
- {
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ std::wstring wsEdit = pEdit->GetText();
|
|
|
|
|
+ std::wstring wsItem = PRESET_MEMO[nIndex];
|
|
|
|
|
|
|
|
- //三态必须都显式设:main.xml 的 <Default name="Button"> 会给所有 Button 套绿色三态图
|
|
|
|
|
- if (m_presetSelected[nIndex])
|
|
|
|
|
|
|
+ if (wsEdit.empty())
|
|
|
{
|
|
{
|
|
|
- pBtn->SetNormalImage(_T("file='tag_pill_s.png' corner='17,17,17,17'"));
|
|
|
|
|
- pBtn->SetHotImage(_T("file='tag_pill_s.png' corner='17,17,17,17'"));
|
|
|
|
|
- pBtn->SetPushedImage(_T("file='tag_pill_sp.png' corner='17,17,17,17'"));
|
|
|
|
|
- pBtn->SetTextColor(0xFFFFFFFF);
|
|
|
|
|
- pBtn->SetHotTextColor(0xFFFFFFFF);
|
|
|
|
|
- pBtn->SetPushedTextColor(0xFFFFFFFF);
|
|
|
|
|
- pBtn->SetFocusedTextColor(0xFFFFFFFF);
|
|
|
|
|
|
|
+ wsEdit = wsItem;
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
|
- pBtn->SetNormalImage(_T("file='tag_pill_n.png' corner='17,17,17,17'"));
|
|
|
|
|
- pBtn->SetHotImage(_T("file='tag_pill_h.png' corner='17,17,17,17'"));
|
|
|
|
|
- pBtn->SetPushedImage(_T("file='tag_pill_h.png' corner='17,17,17,17'"));
|
|
|
|
|
- pBtn->SetTextColor(0xFF1F2329);
|
|
|
|
|
- pBtn->SetHotTextColor(0xFF1F2329);
|
|
|
|
|
- pBtn->SetPushedTextColor(0xFF1F2329);
|
|
|
|
|
- pBtn->SetFocusedTextColor(0xFF1F2329);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- pBtn->NeedUpdate();
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-void CMemoWnd::UpdatePresetCount()
|
|
|
|
|
-{
|
|
|
|
|
- int nCount = 0;
|
|
|
|
|
- for (int i = 0; i < PRESET_COUNT; i++)
|
|
|
|
|
- {
|
|
|
|
|
- if (m_presetSelected[i])
|
|
|
|
|
|
|
+ // 避免用户手动输入了末尾「、」导致出现「、、」
|
|
|
|
|
+ if (wsEdit.back() != L'、')
|
|
|
{
|
|
{
|
|
|
- nCount++;
|
|
|
|
|
|
|
+ wsEdit += L'、';
|
|
|
}
|
|
}
|
|
|
|
|
+ wsEdit += wsItem;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- CLabelUI* pLabel = static_cast<CLabelUI*>(m_pm.FindControl(_T("preset_count")));
|
|
|
|
|
- if (pLabel != NULL)
|
|
|
|
|
- {
|
|
|
|
|
- //不用 swprintf_s(依赖 <cstdio>,本项目 pch 不保证引入),改 std::to_wstring 拼接
|
|
|
|
|
- std::wstring strCount = L"已选 " + std::to_wstring(nCount) + L" 条";
|
|
|
|
|
- pLabel->SetText(strCount.c_str());
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ pEdit->SetText(wsEdit.c_str());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void CMemoWnd::SetContent(std::string content)
|
|
void CMemoWnd::SetContent(std::string content)
|
|
|
{
|
|
{
|
|
|
std::wstring wsAll = CLewaimaiString::UTF8ToUnicode(content);
|
|
std::wstring wsAll = CLewaimaiString::UTF8ToUnicode(content);
|
|
|
|
|
|
|
|
- //每次打开都是全新状态:快捷选择的选中态一律清空,不保留上次的选择
|
|
|
|
|
- for (int i = 0; i < PRESET_COUNT; i++)
|
|
|
|
|
- {
|
|
|
|
|
- m_presetSelected[i] = false;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- for (int i = 0; i < PRESET_COUNT; i++)
|
|
|
|
|
- {
|
|
|
|
|
- UpdatePresetTagStyle(i);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- UpdatePresetCount();
|
|
|
|
|
-
|
|
|
|
|
- //已有备注整体填回输入框,供店员继续补充或删改(不填会丢掉上次手动写的内容)
|
|
|
|
|
CEditUI* pEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("content")));
|
|
CEditUI* pEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("content")));
|
|
|
if (pEdit != NULL)
|
|
if (pEdit != NULL)
|
|
|
{
|
|
{
|
|
@@ -341,7 +272,7 @@ void CMemoWnd::StartYanzheng()
|
|
|
CEditUI* pContent = static_cast<CEditUI*>(m_pm.FindControl(_T("content")));
|
|
CEditUI* pContent = static_cast<CEditUI*>(m_pm.FindControl(_T("content")));
|
|
|
std::wstring wsReason = pContent->GetText();
|
|
std::wstring wsReason = pContent->GetText();
|
|
|
|
|
|
|
|
- //去掉首尾空白,避免只输入空格时拼出多余的「、」
|
|
|
|
|
|
|
+ // 去掉首尾空白,避免只输入空格时保存空串
|
|
|
size_t nBeg = wsReason.find_first_not_of(L" \t\r\n");
|
|
size_t nBeg = wsReason.find_first_not_of(L" \t\r\n");
|
|
|
if (nBeg == std::wstring::npos)
|
|
if (nBeg == std::wstring::npos)
|
|
|
{
|
|
{
|
|
@@ -353,34 +284,7 @@ void CMemoWnd::StartYanzheng()
|
|
|
wsReason = wsReason.substr(nBeg, nEnd - nBeg + 1);
|
|
wsReason = wsReason.substr(nBeg, nEnd - nBeg + 1);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- //快捷选择在前,手动补充在后,用「、」连接
|
|
|
|
|
- std::wstring wsAll;
|
|
|
|
|
- for (int i = 0; i < PRESET_COUNT; i++)
|
|
|
|
|
- {
|
|
|
|
|
- if (!m_presetSelected[i])
|
|
|
|
|
- {
|
|
|
|
|
- continue;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (!wsAll.empty())
|
|
|
|
|
- {
|
|
|
|
|
- wsAll += L'、';
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- wsAll += PRESET_MEMO[i];
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (!wsReason.empty())
|
|
|
|
|
- {
|
|
|
|
|
- if (!wsAll.empty())
|
|
|
|
|
- {
|
|
|
|
|
- wsAll += L'、';
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- wsAll += wsReason;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- m_content = CLewaimaiString::UnicodeToUTF8(wsAll);
|
|
|
|
|
|
|
+ m_content = CLewaimaiString::UnicodeToUTF8(wsReason);
|
|
|
|
|
|
|
|
Close(IDOK);
|
|
Close(IDOK);
|
|
|
}
|
|
}
|