diff options
author | kinddragon <kinddragon@users.sourceforge.net> | 2010-04-20 06:17:50 +0400 |
---|---|---|
committer | kinddragon <kinddragon@users.sourceforge.net> | 2010-04-20 06:17:50 +0400 |
commit | 4f8e4a60a362334579435db89e08f00e78a5de48 (patch) | |
tree | 8aa488487d0984467be5789c0ed6bd226c8d9cbb /src/apps/mplayerc/PPageAccelTbl.cpp | |
parent | 3c584d0200f48d4b29f783bec509a756f3579ff3 (diff) |
long sequences of "if" replaced by "switch" for better performance and simplifying debugging
git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk@1802 10f7b99b-c216-0410-bff0-8a66a9350fd8
Diffstat (limited to 'src/apps/mplayerc/PPageAccelTbl.cpp')
-rw-r--r-- | src/apps/mplayerc/PPageAccelTbl.cpp | 266 |
1 files changed, 128 insertions, 138 deletions
diff --git a/src/apps/mplayerc/PPageAccelTbl.cpp b/src/apps/mplayerc/PPageAccelTbl.cpp index e02651c0f..752801522 100644 --- a/src/apps/mplayerc/PPageAccelTbl.cpp +++ b/src/apps/mplayerc/PPageAccelTbl.cpp @@ -1445,88 +1445,76 @@ void CPPageAccelTbl::OnDolabeleditList(NMHDR* pNMHDR, LRESULT* pResult) LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
LV_ITEM* pItem = &pDispInfo->item;
- *pResult = FALSE;
-
if(pItem->iItem < 0)
- return;
+ {
+ *pResult = FALSE;
+ return;
+ }
+
+ *pResult = TRUE;
wmcmd& wc = m_wmcmds.GetAt((POSITION)m_list.GetItemData(pItem->iItem));
ACCEL& a = wc;
CAtlList<CString> sl;
- int nSel = -1;
-
- if(pItem->iSubItem == COL_MOD)
- {
- for(int i = 0; i < countof(s_mods); i++)
- {
- sl.AddTail(MakeAccelModLabel(s_mods[i]));
- if((a.fVirt&~3) == s_mods[i]) nSel = i;
- }
-
- m_list.ShowInPlaceComboBox(pItem->iItem, pItem->iSubItem, sl, nSel);
-
- *pResult = TRUE;
- }
- else if(pItem->iSubItem == COL_KEY)
- {
- for(int i = 0; i < 256; i++)
- {
- sl.AddTail(MakeAccelVkeyLabel(i, a.fVirt&FVIRTKEY));
- if(a.key == i) nSel = i;
- }
-
- m_list.ShowInPlaceComboBox(pItem->iItem, pItem->iSubItem, sl, nSel);
-
- *pResult = TRUE;
- }
- else if(pItem->iSubItem == COL_TYPE)
- {
- sl.AddTail(_T("VIRTKEY"));
- sl.AddTail(_T("ASCII"));
-
- nSel = !(a.fVirt&FVIRTKEY);
-
- m_list.ShowInPlaceComboBox(pItem->iItem, pItem->iSubItem, sl, nSel);
-
- *pResult = TRUE;
- }
- else if(pItem->iSubItem == COL_MOUSE)
- {
- for(UINT i = 0; i < wmcmd::LAST; i++)
- {
- sl.AddTail(MakeMouseButtonLabel(i));
- if(wc.mouse == i) nSel = i;
- }
-
- m_list.ShowInPlaceComboBox(pItem->iItem, pItem->iSubItem, sl, nSel);
-
- *pResult = TRUE;
- }
- else if(pItem->iSubItem == COL_APPCMD)
- {
- for(int i = 0; i < countof(g_CommandList); i++)
- {
- sl.AddTail(g_CommandList[i].cmdname);
- if(wc.appcmd == g_CommandList[i].appcmd) nSel = i;
- }
-
- m_list.ShowInPlaceComboBox(pItem->iItem, pItem->iSubItem, sl, nSel);
-
- *pResult = TRUE;
- }
- else if(pItem->iSubItem == COL_RMCMD)
- {
- m_list.ShowInPlaceEdit(pItem->iItem, pItem->iSubItem);
-
- *pResult = TRUE;
- }
- else if(pItem->iSubItem == COL_RMREPCNT)
- {
- m_list.ShowInPlaceEdit(pItem->iItem, pItem->iSubItem);
-
- *pResult = TRUE;
- }
+ int nSel = -1;
+
+ switch(pItem->iSubItem)
+ {
+ case COL_MOD:
+ for(int i = 0; i < countof(s_mods); i++)
+ {
+ sl.AddTail(MakeAccelModLabel(s_mods[i]));
+ if((a.fVirt&~3) == s_mods[i]) nSel = i;
+ }
+
+ m_list.ShowInPlaceComboBox(pItem->iItem, pItem->iSubItem, sl, nSel);
+ break;
+ case COL_KEY:
+ for(int i = 0; i < 256; i++)
+ {
+ sl.AddTail(MakeAccelVkeyLabel(i, a.fVirt&FVIRTKEY));
+ if(a.key == i) nSel = i;
+ }
+
+ m_list.ShowInPlaceComboBox(pItem->iItem, pItem->iSubItem, sl, nSel);
+ break;
+ case COL_TYPE:
+ sl.AddTail(_T("VIRTKEY"));
+ sl.AddTail(_T("ASCII"));
+
+ nSel = !(a.fVirt&FVIRTKEY);
+
+ m_list.ShowInPlaceComboBox(pItem->iItem, pItem->iSubItem, sl, nSel);
+ break;
+ case COL_MOUSE:
+ for(UINT i = 0; i < wmcmd::LAST; i++)
+ {
+ sl.AddTail(MakeMouseButtonLabel(i));
+ if(wc.mouse == i) nSel = i;
+ }
+
+ m_list.ShowInPlaceComboBox(pItem->iItem, pItem->iSubItem, sl, nSel);
+ break;
+ case COL_APPCMD:
+ for(int i = 0; i < countof(g_CommandList); i++)
+ {
+ sl.AddTail(g_CommandList[i].cmdname);
+ if(wc.appcmd == g_CommandList[i].appcmd) nSel = i;
+ }
+
+ m_list.ShowInPlaceComboBox(pItem->iItem, pItem->iSubItem, sl, nSel);
+ break;
+ case COL_RMCMD:
+ m_list.ShowInPlaceEdit(pItem->iItem, pItem->iSubItem);
+ break;
+ case COL_RMREPCNT:
+ m_list.ShowInPlaceEdit(pItem->iItem, pItem->iSubItem);
+ break;
+ default:
+ *pResult = FALSE;
+ break;
+ }
}
void CPPageAccelTbl::OnEndlabeleditList(NMHDR* pNMHDR, LRESULT* pResult)
@@ -1542,68 +1530,70 @@ void CPPageAccelTbl::OnEndlabeleditList(NMHDR* pNMHDR, LRESULT* pResult) if(pItem->iItem < 0)
return;
- wmcmd& wc = m_wmcmds.GetAt((POSITION)m_list.GetItemData(pItem->iItem));
-
- if(pItem->iSubItem == COL_MOD)
- {
- if(pItem->lParam >= 0 && pItem->lParam < countof(s_mods))
- {
- wc.fVirt = (wc.fVirt&3) | (s_mods[pItem->lParam]&~3);
- m_list.SetItemText(pItem->iItem, COL_MOD, pItem->pszText);
- *pResult = TRUE;
- }
- }
- else if(pItem->iSubItem == COL_KEY)
- {
- int i = pItem->lParam;
- if(i >= 0 && i < 256)
- {
- wc.key = (WORD)i;
- m_list.SetItemText(pItem->iItem, COL_KEY, pItem->pszText);
- *pResult = TRUE;
- }
- }
- else if(pItem->iSubItem == COL_TYPE)
- {
- int i = pItem->lParam;
- if(i >= 0 && i < 2)
- {
- wc.fVirt = (wc.fVirt&~FVIRTKEY) | (i == 0 ? FVIRTKEY : 0);
- m_list.SetItemText(pItem->iItem, COL_KEY, MakeAccelVkeyLabel(wc.key, wc.fVirt&FVIRTKEY));
- m_list.SetItemText(pItem->iItem, COL_TYPE, (wc.fVirt&FVIRTKEY)?_T("VIRTKEY"):_T("ASCII"));
- *pResult = TRUE;
- }
- }
- else if(pItem->iSubItem == COL_APPCMD)
- {
- int i = pItem->lParam;
- if(i >= 0 && i < countof(g_CommandList))
- {
- wc.appcmd = g_CommandList[i].appcmd;
- m_list.SetItemText(pItem->iItem, COL_APPCMD, pItem->pszText);
- *pResult = TRUE;
- }
- }
- else if(pItem->iSubItem == COL_MOUSE)
- {
- wc.mouse = pItem->lParam;
- m_list.SetItemText(pItem->iItem, COL_MOUSE, pItem->pszText);
- }
- else if(pItem->iSubItem == COL_RMCMD)
- {
- wc.rmcmd = CStringA(CString(pItem->pszText)).Trim();
- wc.rmcmd.Replace(' ', '_');
- m_list.SetItemText(pItem->iItem, pItem->iSubItem, CString(wc.rmcmd));
- *pResult = TRUE;
- }
- else if(pItem->iSubItem == COL_RMREPCNT)
- {
- CString str = CString(pItem->pszText).Trim();
- wc.rmrepcnt = _tcstol(str, NULL, 10);
- str.Format(_T("%d"), wc.rmrepcnt);
- m_list.SetItemText(pItem->iItem, pItem->iSubItem, str);
- *pResult = TRUE;
- }
+ wmcmd& wc = m_wmcmds.GetAt((POSITION)m_list.GetItemData(pItem->iItem));
+
+ switch(pItem->iSubItem)
+ {
+ case COL_MOD:
+ if(pItem->lParam >= 0 && pItem->lParam < countof(s_mods))
+ {
+ wc.fVirt = (wc.fVirt&3) | (s_mods[pItem->lParam]&~3);
+ m_list.SetItemText(pItem->iItem, COL_MOD, pItem->pszText);
+ *pResult = TRUE;
+ }
+ break;
+ case COL_KEY:
+ {
+ int i = pItem->lParam;
+ if(i >= 0 && i < 256)
+ {
+ wc.key = (WORD)i;
+ m_list.SetItemText(pItem->iItem, COL_KEY, pItem->pszText);
+ *pResult = TRUE;
+ }
+ }
+ break;
+ case COL_TYPE:
+ {
+ int i = pItem->lParam;
+ if(i >= 0 && i < 2)
+ {
+ wc.fVirt = (wc.fVirt&~FVIRTKEY) | (i == 0 ? FVIRTKEY : 0);
+ m_list.SetItemText(pItem->iItem, COL_KEY, MakeAccelVkeyLabel(wc.key, wc.fVirt&FVIRTKEY));
+ m_list.SetItemText(pItem->iItem, COL_TYPE, (wc.fVirt&FVIRTKEY)?_T("VIRTKEY"):_T("ASCII"));
+ *pResult = TRUE;
+ }
+ }
+ break;
+ case COL_APPCMD:
+ {
+ int i = pItem->lParam;
+ if(i >= 0 && i < countof(g_CommandList))
+ {
+ wc.appcmd = g_CommandList[i].appcmd;
+ m_list.SetItemText(pItem->iItem, COL_APPCMD, pItem->pszText);
+ *pResult = TRUE;
+ }
+ }
+ break;
+ case COL_MOUSE:
+ wc.mouse = pItem->lParam;
+ m_list.SetItemText(pItem->iItem, COL_MOUSE, pItem->pszText);
+ break;
+ case COL_RMCMD:
+ wc.rmcmd = CStringA(CString(pItem->pszText)).Trim();
+ wc.rmcmd.Replace(' ', '_');
+ m_list.SetItemText(pItem->iItem, pItem->iSubItem, CString(wc.rmcmd));
+ *pResult = TRUE;
+ break;
+ case COL_RMREPCNT:
+ CString str = CString(pItem->pszText).Trim();
+ wc.rmrepcnt = _tcstol(str, NULL, 10);
+ str.Format(_T("%d"), wc.rmrepcnt);
+ m_list.SetItemText(pItem->iItem, pItem->iSubItem, str);
+ *pResult = TRUE;
+ break;
+ }
if(*pResult)
SetModified();
|