void CKey::OnMouseMove(const UINT nFlags, CPoint point) { if (nFlags & MK_LBUTTON) { ClientToScreen(&point); CKeyboardLayout *parent = (CKeyboardLayout *)GetParent(); if (m_nKeyType == PUSHED_KEY) { int nPointedKey = parent->GetPointedKey(point); if (nPointedKey) { if (nPointedKey != m_nDroppableKey) { if (m_nDroppableKey) { reinterpret_cast<CKey*>(parent->GetDlgItem(m_nDroppableKey))->SetKeyType(m_nDroppableKeyType); SetNoCursor(); } if (IsDroppableKey(nPointedKey)) { m_nDroppableKey = nPointedKey; m_nDroppableKeyType = ((CKey*)parent->GetDlgItem(m_nDroppableKey))->GetKeyType(); reinterpret_cast<CKey*>(parent->GetDlgItem(m_nDroppableKey))->SetKeyType(DROPPABLE_KEY); SetDraggingCursor(); } } } else { if (m_nDroppableKey) { reinterpret_cast<CKey*>(parent->GetDlgItem(m_nDroppableKey))->SetKeyType(m_nDroppableKeyType); m_nDroppableKey = 0; m_nDroppableKeyType = NORMAL_KEY; SetNoCursor(); } } } if (m_nKeyType == REMAPPED_PUSHED_KEY) { if (m_nKey != parent->GetPointedKey(point)) { SetKeyType(REMAPPED_KEY); } } if (m_nKeyType == REMAPPED_KEY) { if (m_nKey == parent->GetPointedKey(point)) { SetKeyType(REMAPPED_PUSHED_KEY); } } } CButton::OnMouseMove(nFlags, point); }
void CKey::OnLButtonUp(const UINT nFlags, CPoint point) { if (m_nKeyType == PUSHED_KEY) { SetKeyType(NORMAL_KEY); } CKeyboardLayout *parent = reinterpret_cast<CKeyboardLayout *>(GetParent()); ClientToScreen(&point); if (m_nKeyType == REMAPPED_PUSHED_KEY) { if (m_nKey == parent->GetPointedKey(point)) { KeyboardLayout *pKeyboardLayout = parent->GetKeyboardLayout(m_nKey); if (pKeyboardLayout) { CString szWindowText; parent->GetDlgItem(pKeyboardLayout->nBaseControlID)->GetWindowText(szWindowText); SetWindowText(szWindowText); parent->ToolTip()->UpdateTipText(parent->GetToolTipID(pKeyboardLayout->nToolTipID), this); ScanCodeMapping mapping = {{0, 0}, {pKeyboardLayout->scancode.nScanCode, pKeyboardLayout->scancode.nPrefix}}; parent->SetScanCodeMap(m_HkeyType, mapping); } SetKeyType(ORIGINAL_KEY); } else { SetKeyType(REMAPPED_KEY); } } int nPointedKey = parent->GetPointedKey(point); if (m_nDroppableKey && nPointedKey) { if (m_nDroppableKey != nPointedKey) { reinterpret_cast<CKey*>(parent->GetDlgItem(m_nDroppableKey))->SetKeyType(m_nDroppableKeyType); if (IsDroppableKey(nPointedKey)) { m_nDroppableKey = nPointedKey; } else { m_nDroppableKey = 0; } } if (m_nDroppableKey) { KeyboardLayout *pKeyboardLayout = parent->GetKeyboardLayout(m_nDroppableKey); KeyboardLayout *pBaseKeyboardLayout = parent->GetKeyboardLayout(m_nKey); if (pKeyboardLayout && pBaseKeyboardLayout) { CString szWindowText; GetWindowText(szWindowText); parent->GetDlgItem(pKeyboardLayout->nCurrentControlID)->SetWindowText(szWindowText); parent->ToolTip()->UpdateTipText(parent->GetToolTipID(pBaseKeyboardLayout->nToolTipID), parent->GetDlgItem(pKeyboardLayout->nCurrentControlID)); reinterpret_cast<CKey *>(parent->GetDlgItem(pKeyboardLayout->nBaseControlID))->SetKeyType(NORMAL_KEY); reinterpret_cast<CKey*>(parent->GetDlgItem(pKeyboardLayout->nCurrentControlID))->SetKeyType(REMAPPED_KEY); ScanCodeMapping mapping = {{pBaseKeyboardLayout->scancode.nScanCode, pBaseKeyboardLayout->scancode.nPrefix}, {pKeyboardLayout->scancode.nScanCode, pKeyboardLayout->scancode.nPrefix}}; parent->SetScanCodeMap(m_HkeyType, mapping); } } } m_nDroppableKey = 0; m_nDroppableKeyType = NORMAL_KEY; SetNormalCursor(); CButton::OnLButtonUp(nFlags, point); }