|
|
@@ -6,67 +6,50 @@ CAccels::CAccels()
|
|
|
{
|
|
|
m_handleRepeatKeys = false;
|
|
|
m_firstMapTick = 0;
|
|
|
+ m_activeFirstKey = 0;
|
|
|
}
|
|
|
|
|
|
void CAccels::AddAccel(CAccel a)
|
|
|
{
|
|
|
- m_Map.SetAt(a.Key, a);
|
|
|
+ m_multiMap.insert(pair<DWORD, CAccel>(a.Key, a));
|
|
|
}
|
|
|
|
|
|
void CAccels::AddAccel(DWORD cmd, DWORD key, DWORD key2)
|
|
|
{
|
|
|
- CAccel a(key, cmd);
|
|
|
-
|
|
|
- if((int)key2 > 0)
|
|
|
- {
|
|
|
- a.SecondKey = true;
|
|
|
- m_Map2.SetAt(key2, a);
|
|
|
- }
|
|
|
+ CAccel a(key, cmd, key2);
|
|
|
|
|
|
- m_Map.SetAt(key, a);
|
|
|
+ m_multiMap.insert(pair<DWORD, CAccel>(key, a));
|
|
|
}
|
|
|
|
|
|
void CAccels::RemoveAll()
|
|
|
{
|
|
|
- m_Map.RemoveAll();
|
|
|
- m_Map2.RemoveAll();
|
|
|
+ m_multiMap.clear();
|
|
|
}
|
|
|
|
|
|
CString CAccels::GetCmdKeyText(DWORD cmd)
|
|
|
{
|
|
|
- CString cmdShortcutText = _T("");
|
|
|
- POSITION pos = m_Map.GetStartPosition();
|
|
|
- DWORD mapShortcut;
|
|
|
- CAccel a;
|
|
|
- while (pos != NULL)
|
|
|
+ CString cmdShortcutText;
|
|
|
+ for (multimap<DWORD, CAccel>::iterator it = m_multiMap.begin(); it != m_multiMap.end(); ++it)
|
|
|
{
|
|
|
- m_Map.GetNextAssoc(pos, mapShortcut, a);
|
|
|
-
|
|
|
- if(a.Cmd == cmd)
|
|
|
+ if (it->second.Cmd == cmd)
|
|
|
{
|
|
|
- CString cmdShortcutText2;
|
|
|
- CAccel a2;
|
|
|
- DWORD mapShortcut2;
|
|
|
- POSITION pos2 = m_Map2.GetStartPosition();
|
|
|
- while (pos2 != NULL)
|
|
|
+ if (it->second.Key != 0)
|
|
|
{
|
|
|
- m_Map2.GetNextAssoc(pos2, mapShortcut2, a2);
|
|
|
- if(a2.Cmd == cmd)
|
|
|
+ cmdShortcutText = CHotKey::GetHotKeyDisplayStatic(it->second.Key);
|
|
|
+ if (it->second.Key2 != 0)
|
|
|
{
|
|
|
- cmdShortcutText2 = CHotKey::GetHotKeyDisplayStatic(mapShortcut2);
|
|
|
- }
|
|
|
- }
|
|
|
+ CString cmdShortcutText2 = CHotKey::GetHotKeyDisplayStatic(it->second.Key);
|
|
|
|
|
|
- cmdShortcutText = CHotKey::GetHotKeyDisplayStatic(mapShortcut);
|
|
|
-
|
|
|
- if(cmdShortcutText2.GetLength() > 0)
|
|
|
- {
|
|
|
- cmdShortcutText += _T(" - ");
|
|
|
- cmdShortcutText += cmdShortcutText2;
|
|
|
+ if (cmdShortcutText2.GetLength() > 0)
|
|
|
+ {
|
|
|
+ cmdShortcutText += _T(" - ");
|
|
|
+ cmdShortcutText += cmdShortcutText2;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
return cmdShortcutText;
|
|
|
}
|
|
|
@@ -87,7 +70,7 @@ bool CAccels::OnMsg(MSG *pMsg, CAccel &a)
|
|
|
|
|
|
m_handleRepeatKeys = false;
|
|
|
|
|
|
- if(!pMsg || m_Map.GetCount() <= 0)
|
|
|
+ if(!pMsg)
|
|
|
{
|
|
|
return NULL;
|
|
|
}
|
|
|
@@ -99,28 +82,44 @@ bool CAccels::OnMsg(MSG *pMsg, CAccel &a)
|
|
|
CString cs;
|
|
|
cs.Format(_T("Key: %d, Mod: %d, vkey: %d"), key, mod, vkey);
|
|
|
OutputDebugString(cs);
|
|
|
-
|
|
|
+
|
|
|
if (m_firstMapTick != 0 &&
|
|
|
(GetTickCount() - m_firstMapTick) < 500)
|
|
|
{
|
|
|
- if (m_Map2.Lookup(key, a))
|
|
|
+ pair<multimap<DWORD, CAccel>::iterator, multimap<DWORD, CAccel>::iterator> ppp;
|
|
|
+ ppp = m_multiMap.equal_range(m_activeFirstKey);
|
|
|
+
|
|
|
+ for (multimap<DWORD, CAccel>::iterator it2 = ppp.first; it2 != ppp.second; ++it2)
|
|
|
{
|
|
|
- m_firstMapTick = 0;
|
|
|
- return true;
|
|
|
+ if (vkey == it2->second.Key2)
|
|
|
+ {
|
|
|
+ a = (*it2).second;
|
|
|
+ m_firstMapTick = 0;
|
|
|
+ m_activeFirstKey = 0;
|
|
|
+ return true;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- if (m_Map.Lookup(key, a))
|
|
|
+ m_firstMapTick = 0;
|
|
|
+ m_activeFirstKey = 0;
|
|
|
+
|
|
|
+ pair<multimap<DWORD, CAccel>::iterator, multimap<DWORD, CAccel>::iterator> ppp;
|
|
|
+ ppp = m_multiMap.equal_range(vkey);
|
|
|
+
|
|
|
+ for (multimap<DWORD, CAccel>::iterator it2 = ppp.first; it2 != ppp.second; ++it2)
|
|
|
{
|
|
|
- if (a.SecondKey == false)
|
|
|
+ if (it2->second.Key2 == 0)
|
|
|
{
|
|
|
- m_firstMapTick = 0;
|
|
|
+ a = (*it2).second;
|
|
|
return true;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+ m_activeFirstKey = vkey;
|
|
|
m_firstMapTick = GetTickCount();
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
}
|