LRESULT CActiveXUI::MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, bool& bHandled) { if( m_pControl == NULL ) return 0; ASSERT(m_pControl->m_bWindowless); if( !m_pControl->m_bInPlaceActive ) return 0; if( m_pControl->m_pInPlaceObject == NULL ) return 0; if( !IsMouseEnabled() && uMsg >= WM_MOUSEFIRST && uMsg <= WM_MOUSELAST ) return 0; bool bWasHandled = true; if( (uMsg >= WM_MOUSEFIRST && uMsg <= WM_MOUSELAST) || uMsg == WM_SETCURSOR ) { // Mouse message only go when captured or inside rect DWORD dwHitResult = m_pControl->m_bCaptured ? HITRESULT_HIT : HITRESULT_OUTSIDE; if( dwHitResult == HITRESULT_OUTSIDE && m_pControl->m_pViewObject != NULL ) { IViewObjectEx* pViewEx = NULL; m_pControl->m_pViewObject->QueryInterface(IID_IViewObjectEx, (LPVOID*) &pViewEx); if( pViewEx != NULL ) { POINT ptMouse = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; pViewEx->QueryHitPoint(DVASPECT_CONTENT, &m_rcItem, ptMouse, 0, &dwHitResult); pViewEx->Release(); } } if( dwHitResult != HITRESULT_HIT ) return 0; if( uMsg == WM_SETCURSOR ) bWasHandled = false; else if( uMsg == WM_LBUTTONDOWN || uMsg == WM_LBUTTONDBLCLK || uMsg == WM_RBUTTONDOWN ) { ::SetFocus(GetManager()->GetPaintWindow()); SetFocus(); } } else if( uMsg >= WM_KEYFIRST && uMsg <= WM_KEYLAST ) { // Keyboard messages just go when we have focus if( !IsFocused() ) return 0; } else { switch( uMsg ) { case WM_HELP: case WM_CONTEXTMENU: bWasHandled = false; break; default: return 0; } } LRESULT lResult = 0; HRESULT Hr = m_pControl->m_pInPlaceObject->OnWindowMessage(uMsg, wParam, lParam, &lResult); if( Hr == S_OK ) bHandled = bWasHandled; return lResult; }
//************************************ // 函数名称: DoEvent // 返回类型: void // 参数信息: TEventUI & event // 函数说明: //************************************ void CTreeNodeUI::DoEvent( TEventUI& event ) { if( !IsMouseEnabled() && event.Type > UIEVENT__MOUSEBEGIN && event.Type < UIEVENT__MOUSEEND ) { if( m_pOwner != NULL ) m_pOwner->DoEvent(event); else CContainerUI::DoEvent(event); return; } CListContainerElementUI::DoEvent(event); if( event.Type == UIEVENT_DBLCLICK ) { if( IsEnabled() ) { m_pManager->SendNotify(this, _T("itemdbclick")); Invalidate(); } return; } if( event.Type == UIEVENT_MOUSEENTER ) { if( IsEnabled()) { if(m_bSelected && GetSelItemHotTextColor()) pItemButton->SetTextColor(GetSelItemHotTextColor()); else pItemButton->SetTextColor(GetItemHotTextColor()); } else pItemButton->SetTextColor(pItemButton->GetDisabledTextColor()); return; } if( event.Type == UIEVENT_MOUSELEAVE ) { if( IsEnabled()) { if(m_bSelected && GetSelItemTextColor()) pItemButton->SetTextColor(GetSelItemTextColor()); else if(!m_bSelected) pItemButton->SetTextColor(GetItemTextColor()); } else pItemButton->SetTextColor(pItemButton->GetDisabledTextColor()); return; } }
void CCheckBoxUI::DoEvent(TEventUI& event) { if( !IsMouseEnabled() && event.Type > UIEVENT__MOUSEBEGIN && event.Type < UIEVENT__MOUSEEND ) { if( m_pParent != NULL ) m_pParent->DoEvent(event); else COptionUI::DoEvent(event); return; } if( m_bAutoCheck && (event.Type == UIEVENT_BUTTONDOWN || event.Type == UIEVENT_DBLCLICK)) { if( ::PtInRect(&m_rcItem, event.ptMouse) && IsEnabled() ) { SetCheck(!GetCheck()); m_pManager->SendNotify(this, DUI_MSGTYPE_CHECKCLICK, 0, 0); Invalidate(); } return; } COptionUI::DoEvent(event); }
void CHotButtonUI::DoEvent(TEventUI& event) { if( !IsMouseEnabled() && event.Type > UIEVENT__MOUSEBEGIN && event.Type < UIEVENT__MOUSEEND ) { if( m_pParent != NULL ) m_pParent->DoEvent(event); else CButtonUI::DoEvent(event); return; } if( event.Type == UIEVENT_MOUSEENTER ) { if( IsEnabled() ) { m_uButtonState |= UISTATE_HOT; m_pManager->SendNotify(this, DUI_MSGTYPE_BUTTON_HOT, event.wParam, event.lParam); Invalidate(); } return; } CButtonUI::DoEvent(event); }
void CMusicListGroupUI::DoEvent(TEventUI& event) { if( !IsMouseEnabled() && event.Type > UIEVENT__MOUSEBEGIN && event.Type < UIEVENT__MOUSEEND ) { if( m_pOwner != NULL ) m_pOwner->DoEvent(event); else CContainerUI::DoEvent(event); return; } if( event.Type == UIEVENT_BUTTONDOWN) { return; } else if( event.Type == UIEVENT_CONTEXTMENU ) { if( IsContextMenuUsed() ) { m_pManager->SendNotify(this, DUI_MSGTYPE_MENU, event.wParam, event.lParam); } } else { CTreeNodeUI::DoEvent(event); } }
void CButtonUI::DoEvent(TEventUI& event) { if( !IsMouseEnabled() && event.Type > UIEVENT__MOUSEBEGIN && event.Type < UIEVENT__MOUSEEND ) { if( m_pParent != NULL ) m_pParent->DoEvent(event); else CLabelUI::DoEvent(event); return; } if( event.Type == UIEVENT_SETFOCUS ) { Invalidate(); } if( event.Type == UIEVENT_KILLFOCUS ) { Invalidate(); } if( event.Type == UIEVENT_KEYDOWN ) { if (IsKeyboardEnabled()) { if( event.chKey == VK_SPACE || event.chKey == VK_RETURN ) { Activate(); return; } } } if( event.Type == UIEVENT_BUTTONDOWN || event.Type == UIEVENT_DBLCLICK ) { if( ::PtInRect(&m_rcItem, event.ptMouse) && IsEnabled() ) { m_uButtonState |= UISTATE_PUSHED | UISTATE_CAPTURED; Invalidate(); } return; } if( event.Type == UIEVENT_MOUSEMOVE ) { if( (m_uButtonState & UISTATE_CAPTURED) != 0 ) { if( ::PtInRect(&m_rcItem, event.ptMouse) ) m_uButtonState |= UISTATE_PUSHED; else m_uButtonState &= ~UISTATE_PUSHED; Invalidate(); } return; } if( event.Type == UIEVENT_BUTTONUP ) { if( (m_uButtonState & UISTATE_CAPTURED) != 0 ) { if( ::PtInRect(&m_rcItem, event.ptMouse) ) Activate(); m_uButtonState &= ~(UISTATE_PUSHED | UISTATE_CAPTURED); Invalidate(); } return; } if( event.Type == UIEVENT_CONTEXTMENU ) { if( IsContextMenuUsed() ) { m_pManager->SendNotify(this, _T("menu"), event.wParam, event.lParam); } return; } if( event.Type == UIEVENT_MOUSEENTER ) { if( IsEnabled() ) { m_uButtonState |= UISTATE_HOT; Invalidate(); } // return; } if( event.Type == UIEVENT_MOUSELEAVE ) { if( IsEnabled() ) { m_uButtonState &= ~UISTATE_HOT; Invalidate(); } // return; } if( event.Type == UIEVENT_SETCURSOR ) { ::SetCursor(::LoadCursor(NULL, MAKEINTRESOURCE(IDC_ARROW))); return; } CLabelUI::DoEvent(event); }
void CTextUI::DoEvent(TEventUI& event) { if( !IsMouseEnabled() && event.Type > UIEVENT__MOUSEBEGIN && event.Type < UIEVENT__MOUSEEND ) { if( m_pParent != NULL ) m_pParent->DoEvent(event); else CLabelUI::DoEvent(event); return; } if( event.Type == UIEVENT_SETCURSOR ) { for( int i = 0; i < m_nLinks; i++ ) { if( ::PtInRect(&m_rcLinks[i], event.ptMouse) ) { ::SetCursor(::LoadCursor(NULL, MAKEINTRESOURCE(IDC_HAND))); return; } } } if( event.Type == UIEVENT_BUTTONDOWN || event.Type == UIEVENT_DBLCLICK && IsEnabled() ) { for( int i = 0; i < m_nLinks; i++ ) { if( ::PtInRect(&m_rcLinks[i], event.ptMouse) ) { Invalidate(); return; } } } if( event.Type == UIEVENT_BUTTONUP && IsEnabled() ) { for( int i = 0; i < m_nLinks; i++ ) { if( ::PtInRect(&m_rcLinks[i], event.ptMouse) ) { m_pManager->SendNotify(this, DUI_MSGTYPE_LINK, i); return; } } } if( event.Type == UIEVENT_CONTEXTMENU ) { return; } // When you move over a link if( m_nLinks > 0 && event.Type == UIEVENT_MOUSEMOVE && IsEnabled() ) { int nHoverLink = -1; for( int i = 0; i < m_nLinks; i++ ) { if( ::PtInRect(&m_rcLinks[i], event.ptMouse) ) { nHoverLink = i; break; } } if(m_nHoverLink != nHoverLink) { m_nHoverLink = nHoverLink; Invalidate(); return; } } if( event.Type == UIEVENT_MOUSELEAVE ) { if( m_nLinks > 0 && IsEnabled() ) { if(m_nHoverLink != -1) { m_nHoverLink = -1; Invalidate(); return; } } } CLabelUI::DoEvent(event); }
void CRotateButtonUI::DoEvent(TEventUI& event) { if (!IsMouseEnabled() && event.Type > UIEVENT__MOUSEBEGIN && event.Type < UIEVENT__MOUSEEND) { if (m_pParent) { m_pParent->DoEvent(event); } return; } if (event.Type == UIEVENT_MOUSEMOVE) { if ((m_uButtonState & UISTATE_CAPTURED) != 0) { AdjustDragButton(event.ptMouse); Invalidate(); } return; } if (event.Type == UIEVENT_BUTTONDOWN) { if (IsEnabled()) { if (::PtInRect(&m_rcItem, event.ptMouse)) m_uButtonState |= UISTATE_CAPTURED; } return; } if (event.Type == UIEVENT_BUTTONUP) { if ((m_uButtonState & UISTATE_CAPTURED) != 0 ) { if (::PtInRect(&m_rcItem, event.ptMouse)) Activate(); m_uButtonState &= ~UISTATE_CAPTURED; Invalidate(); } return; } if (event.Type == UIEVENT_CONTEXTMENU) { return; } if (event.Type == UIEVENT_KEYDOWN) { if (IsKeyboardEnabled()) { if (event.chKey == VK_SPACE || event.chKey == VK_RETURN) { Activate(); return; } } } if (event.Type == UIEVENT_SETFOCUS) { Invalidate(); } if ( event.Type == UIEVENT_KILLFOCUS) { Invalidate(); } CControlUI::DoEvent(event); }
void CScrollBarUI::DoEvent(TEventUI& event) { if( !IsMouseEnabled() && event.Type > UIEVENT__MOUSEBEGIN && event.Type < UIEVENT__MOUSEEND ) { if( m_pOwner != NULL ) m_pOwner->DoEvent(event); else CControlUI::DoEvent(event); return; } if( event.Type == UIEVENT_SETFOCUS ) { return; } if( event.Type == UIEVENT_KILLFOCUS ) { return; } if( event.Type == UIEVENT_BUTTONDOWN || event.Type == UIEVENT_DBLCLICK ) { if( !IsEnabled() ) return; m_nLastScrollOffset = 0; m_nScrollRepeatDelay = 0; m_pManager->SetTimer(this, DEFAULT_TIMERID, 50U); if( ::PtInRect(&m_rcButton1, event.ptMouse) ) { m_uButton1State |= UISTATE_PUSHED; if( !m_bHorizontal ) { if( m_pOwner != NULL ) m_pOwner->LineUp(); else SetScrollPos(m_nScrollPos - m_nLineSize); } else { if( m_pOwner != NULL ) m_pOwner->LineLeft(); else SetScrollPos(m_nScrollPos - m_nLineSize); } } else if( ::PtInRect(&m_rcButton2, event.ptMouse) ) { m_uButton2State |= UISTATE_PUSHED; if( !m_bHorizontal ) { if( m_pOwner != NULL ) m_pOwner->LineDown(); else SetScrollPos(m_nScrollPos + m_nLineSize); } else { if( m_pOwner != NULL ) m_pOwner->LineRight(); else SetScrollPos(m_nScrollPos + m_nLineSize); } } else if( ::PtInRect(&m_rcThumb, event.ptMouse) ) { m_uThumbState |= UISTATE_CAPTURED | UISTATE_PUSHED; ptLastMouse = event.ptMouse; m_nLastScrollPos = m_nScrollPos; } else { if( !m_bHorizontal ) { if( event.ptMouse.y < m_rcThumb.top ) { if( m_pOwner != NULL ) m_pOwner->PageUp(); else SetScrollPos(m_nScrollPos + m_rcItem.top - m_rcItem.bottom); } else if ( event.ptMouse.y > m_rcThumb.bottom ){ if( m_pOwner != NULL ) m_pOwner->PageDown(); else SetScrollPos(m_nScrollPos - m_rcItem.top + m_rcItem.bottom); } } else { if( event.ptMouse.x < m_rcThumb.left ) { if( m_pOwner != NULL ) m_pOwner->PageLeft(); else SetScrollPos(m_nScrollPos + m_rcItem.left - m_rcItem.right); } else if ( event.ptMouse.x > m_rcThumb.right ){ if( m_pOwner != NULL ) m_pOwner->PageRight(); else SetScrollPos(m_nScrollPos - m_rcItem.left + m_rcItem.right); } } } if( m_pManager != NULL && m_pOwner == NULL ) m_pManager->SendNotify(this, DUI_MSGTYPE_SCROLL); return; } if( event.Type == UIEVENT_BUTTONUP ) { m_nScrollRepeatDelay = 0; m_nLastScrollOffset = 0; m_pManager->KillTimer(this, DEFAULT_TIMERID); if( (m_uThumbState & UISTATE_CAPTURED) != 0 ) { m_uThumbState &= ~( UISTATE_CAPTURED | UISTATE_PUSHED ); Invalidate(); } else if( (m_uButton1State & UISTATE_PUSHED) != 0 ) { m_uButton1State &= ~UISTATE_PUSHED; Invalidate(); } else if( (m_uButton2State & UISTATE_PUSHED) != 0 ) { m_uButton2State &= ~UISTATE_PUSHED; Invalidate(); } return; } if( event.Type == UIEVENT_MOUSEMOVE ) { if( (m_uThumbState & UISTATE_CAPTURED) != 0 ) { if( !m_bHorizontal ) { int vRange = m_rcItem.bottom - m_rcItem.top - m_rcThumb.bottom + m_rcThumb.top - 2 * m_cxyFixed.cx; if (vRange != 0) m_nLastScrollOffset = (event.ptMouse.y - ptLastMouse.y) * m_nRange / vRange; } else { int hRange = m_rcItem.right - m_rcItem.left - m_rcThumb.right + m_rcThumb.left - 2 * m_cxyFixed.cy; if (hRange != 0) m_nLastScrollOffset = (event.ptMouse.x - ptLastMouse.x) * m_nRange / hRange; } } else { if( (m_uThumbState & UISTATE_HOT) != 0 ) { if( !::PtInRect(&m_rcThumb, event.ptMouse) ) { m_uThumbState &= ~UISTATE_HOT; Invalidate(); } } else { if( !IsEnabled() ) return; if( ::PtInRect(&m_rcThumb, event.ptMouse) ) { m_uThumbState |= UISTATE_HOT; Invalidate(); } } } return; } if( event.Type == UIEVENT_CONTEXTMENU ) { return; } if( event.Type == UIEVENT_TIMER && event.wParam == DEFAULT_TIMERID ) { ++m_nScrollRepeatDelay; if( (m_uThumbState & UISTATE_CAPTURED) != 0 ) { if( !m_bHorizontal ) { if( m_pOwner != NULL ) m_pOwner->SetScrollPos(CDuiSize(m_pOwner->GetScrollPos().cx, \ m_nLastScrollPos + m_nLastScrollOffset)); else SetScrollPos(m_nLastScrollPos + m_nLastScrollOffset); } else { if( m_pOwner != NULL ) m_pOwner->SetScrollPos(CDuiSize(m_nLastScrollPos + m_nLastScrollOffset, \ m_pOwner->GetScrollPos().cy)); else SetScrollPos(m_nLastScrollPos + m_nLastScrollOffset); } Invalidate(); } else if( (m_uButton1State & UISTATE_PUSHED) != 0 ) { if( m_nScrollRepeatDelay <= 5 ) return; if( !m_bHorizontal ) { if( m_pOwner != NULL ) m_pOwner->LineUp(); else SetScrollPos(m_nScrollPos - m_nLineSize); } else { if( m_pOwner != NULL ) m_pOwner->LineLeft(); else SetScrollPos(m_nScrollPos - m_nLineSize); } } else if( (m_uButton2State & UISTATE_PUSHED) != 0 ) { if( m_nScrollRepeatDelay <= 5 ) return; if( !m_bHorizontal ) { if( m_pOwner != NULL ) m_pOwner->LineDown(); else SetScrollPos(m_nScrollPos + m_nLineSize); } else { if( m_pOwner != NULL ) m_pOwner->LineRight(); else SetScrollPos(m_nScrollPos + m_nLineSize); } } else { if( m_nScrollRepeatDelay <= 5 ) return; POINT pt = { 0 }; ::GetCursorPos(&pt); ::ScreenToClient(m_pManager->GetPaintWindow(), &pt); if( !m_bHorizontal ) { if( pt.y < m_rcThumb.top ) { if( m_pOwner != NULL ) m_pOwner->PageUp(); else SetScrollPos(m_nScrollPos + m_rcItem.top - m_rcItem.bottom); } else if ( pt.y > m_rcThumb.bottom ){ if( m_pOwner != NULL ) m_pOwner->PageDown(); else SetScrollPos(m_nScrollPos - m_rcItem.top + m_rcItem.bottom); } } else { if( pt.x < m_rcThumb.left ) { if( m_pOwner != NULL ) m_pOwner->PageLeft(); else SetScrollPos(m_nScrollPos + m_rcItem.left - m_rcItem.right); } else if ( pt.x > m_rcThumb.right ){ if( m_pOwner != NULL ) m_pOwner->PageRight(); else SetScrollPos(m_nScrollPos - m_rcItem.left + m_rcItem.right); } } } if( m_pManager != NULL && m_pOwner == NULL ) m_pManager->SendNotify(this, DUI_MSGTYPE_SCROLL); return; } if( event.Type == UIEVENT_MOUSEENTER ) { if( IsEnabled() ) { m_uButton1State |= UISTATE_HOT; m_uButton2State |= UISTATE_HOT; if( ::PtInRect(&m_rcThumb, event.ptMouse) ) m_uThumbState |= UISTATE_HOT; Invalidate(); } return; } if( event.Type == UIEVENT_MOUSELEAVE ) { if( IsEnabled() ) { m_uButton1State &= ~UISTATE_HOT; m_uButton2State &= ~UISTATE_HOT; m_uThumbState &= ~UISTATE_HOT; Invalidate(); } return; } if( m_pOwner != NULL ) m_pOwner->DoEvent(event); else CControlUI::DoEvent(event); }
void ZSlider::DoEvent(TEventUI& event) { if( !IsMouseEnabled() && event.Type > UIEVENT__MOUSEBEGIN && event.Type < UIEVENT__MOUSEEND ) { if( m_pParent != NULL ) m_pParent->DoEvent(event); else ZProgress::DoEvent(event); return; } if( event.Type == UIEVENT_BUTTONDOWN || event.Type == UIEVENT_DBLCLICK ) { if( IsEnabled() ) { RECT rcThumb = GetThumbRect(); if( PtInRect(&rcThumb, event.ptMouse) ) { m_uButtonState |= UISTATE_CAPTURED; } } return; } if( event.Type == UIEVENT_BUTTONUP ) { if( (m_uButtonState & UISTATE_CAPTURED) != 0 ) { m_uButtonState &= ~UISTATE_CAPTURED; } if( m_bHorizontal ) { if( event.ptMouse.x >= m_rcItem.right - m_szThumb.cx / 2 ) m_nValue = m_nMax; else if( event.ptMouse.x <= m_rcItem.left + m_szThumb.cx / 2 ) m_nValue = m_nMin; else m_nValue = m_nMin + (m_nMax - m_nMin) * (event.ptMouse.x - m_rcItem.left - m_szThumb.cx / 2 ) / (m_rcItem.right - m_rcItem.left - m_szThumb.cx); } else { if( event.ptMouse.y >= m_rcItem.bottom - m_szThumb.cy / 2 ) m_nValue = m_nMin; else if( event.ptMouse.y <= m_rcItem.top + m_szThumb.cy / 2 ) m_nValue = m_nMax; else m_nValue = m_nMin + (m_nMax - m_nMin) * (m_rcItem.bottom - event.ptMouse.y - m_szThumb.cy / 2 ) / (m_rcItem.bottom - m_rcItem.top - m_szThumb.cy); } DoLuaEvent("valueChanged",GetValue()); Invalidate(); return; } if( event.Type == UIEVENT_CONTEXTMENU ) { return; } if( event.Type == UIEVENT_SCROLLWHEEL ) { switch(event.wParam) { case SBT_LINEUP: SetValue(GetValue() + GetChangeStep()); break; case SBT_LINEDOWN: SetValue(GetValue() - GetChangeStep()); break; } DoLuaEvent("valueChanged",GetValue()); return; } if( event.Type == UIEVENT_MOUSEMOVE ) { if( (m_uButtonState & UISTATE_CAPTURED) != 0 ) { if( m_bHorizontal ) { if( event.ptMouse.x >= m_rcItem.right - m_szThumb.cx / 2 ) m_nValue = m_nMax; else if( event.ptMouse.x <= m_rcItem.left + m_szThumb.cx / 2 ) m_nValue = m_nMin; else m_nValue = m_nMin + (m_nMax - m_nMin) * (event.ptMouse.x - m_rcItem.left - m_szThumb.cx / 2 ) / (m_rcItem.right - m_rcItem.left - m_szThumb.cx); } else { if( event.ptMouse.y >= m_rcItem.bottom - m_szThumb.cy / 2 ) m_nValue = m_nMin; else if( event.ptMouse.y <= m_rcItem.top + m_szThumb.cy / 2 ) m_nValue = m_nMax; else m_nValue = m_nMin + (m_nMax - m_nMin) * (m_rcItem.bottom - event.ptMouse.y - m_szThumb.cy / 2 ) / (m_rcItem.bottom - m_rcItem.top - m_szThumb.cy); } Invalidate(); } return; } //if( event.Type == UIEVENT_SETCURSOR ) //{ // RECT rcThumb = GetThumbRect(); // if( IsEnabled() && ::PtInRect(&rcThumb, event.ptMouse) ) { // ::SetCursor(::LoadCursor(NULL, MAKEINTRESOURCE(IDC_HAND))); // return; // } //} if( event.Type == UIEVENT_MOUSEENTER ) { if( IsEnabled() ) { m_uButtonState |= UISTATE_HOT; Invalidate(); } return; } if( event.Type == UIEVENT_MOUSELEAVE ) { if( IsEnabled() ) { m_uButtonState &= ~UISTATE_HOT; Invalidate(); } return; } ZControl::DoEvent(event); }
void CComboUI::DoEvent(TEventUI& event) { if( !IsMouseEnabled() && event.Type > UIEVENT__MOUSEBEGIN && event.Type < UIEVENT__MOUSEEND ) { if( m_pParent != NULL ) m_pParent->DoEvent(event); else CContainerUI::DoEvent(event); return; } if( event.Type == UIEVENT_SETFOCUS ) { Invalidate(); } if( event.Type == UIEVENT_KILLFOCUS ) { Invalidate(); } if( event.Type == UIEVENT_BUTTONDOWN ) { if( IsEnabled() ) { Activate(); m_uButtonState |= UISTATE_PUSHED | UISTATE_CAPTURED; } return; } if( event.Type == UIEVENT_BUTTONUP ) { if( (m_uButtonState & UISTATE_CAPTURED) != 0 ) { m_uButtonState &= ~ UISTATE_CAPTURED; Invalidate(); } return; } if( event.Type == UIEVENT_MOUSEMOVE ) { return; } if( event.Type == UIEVENT_KEYDOWN ) { switch( event.chKey ) { case VK_F4: Activate(); return; case VK_UP: SelectItem(FindSelectable(m_iCurSel - 1, false)); return; case VK_DOWN: SelectItem(FindSelectable(m_iCurSel + 1, true)); return; case VK_PRIOR: SelectItem(FindSelectable(m_iCurSel - 1, false)); return; case VK_NEXT: SelectItem(FindSelectable(m_iCurSel + 1, true)); return; case VK_HOME: SelectItem(FindSelectable(0, false)); return; case VK_END: SelectItem(FindSelectable(GetCount() - 1, true)); return; } } if( event.Type == UIEVENT_SCROLLWHEEL ) { bool bDownward = LOWORD(event.wParam) == SB_LINEDOWN; SelectItem(FindSelectable(m_iCurSel + (bDownward ? 1 : -1), bDownward)); return; } if( event.Type == UIEVENT_CONTEXTMENU ) { return; } if( event.Type == UIEVENT_MOUSEENTER ) { if( ::PtInRect(&m_rcItem, event.ptMouse ) ) { if( (m_uButtonState & UISTATE_HOT) == 0 ) m_uButtonState |= UISTATE_HOT; Invalidate(); } return; } if( event.Type == UIEVENT_MOUSELEAVE ) { if( (m_uButtonState & UISTATE_HOT) != 0 ) { m_uButtonState &= ~UISTATE_HOT; Invalidate(); } return; } CControlUI::DoEvent(event); }
void CEditUI::DoEvent(TEventUI& event) { if( !IsMouseEnabled() && event.Type > UIEVENT__MOUSEBEGIN && event.Type < UIEVENT__MOUSEEND ) { if( m_pParent != NULL ) m_pParent->DoEvent(event); else CLabelUI::DoEvent(event); return; } if( event.Type == UIEVENT_SETCURSOR && IsEnabled() ) { ::SetCursor(::LoadCursor(NULL, MAKEINTRESOURCE(IDC_IBEAM))); return; } if( event.Type == UIEVENT_WINDOWSIZE ) { if( m_pWindow != NULL ) m_pManager->SetFocusNeeded(this); } if( event.Type == UIEVENT_SCROLLWHEEL ) { if( m_pWindow != NULL ) return; } if( event.Type == UIEVENT_SETFOCUS && IsEnabled() ) { if( m_pWindow ) return; m_pWindow = new CEditWnd(); ASSERT(m_pWindow); m_pWindow->Init(this); Invalidate(); } if( event.Type == UIEVENT_KILLFOCUS && IsEnabled() ) { Invalidate(); } if( event.Type == UIEVENT_BUTTONDOWN || event.Type == UIEVENT_DBLCLICK || event.Type == UIEVENT_RBUTTONDOWN) { if( IsEnabled() ) { GetManager()->ReleaseCapture(); if( IsFocused() && m_pWindow == NULL ) { m_pWindow = new CEditWnd(); ASSERT(m_pWindow); m_pWindow->Init(this); if( PtInRect(&m_rcItem, event.ptMouse) ) { int nSize = GetWindowTextLength(*m_pWindow); if( nSize == 0 ) nSize = 1; Edit_SetSel(*m_pWindow, 0, nSize); } } else if( m_pWindow != NULL ) { #if 1 int nSize = GetWindowTextLength(*m_pWindow); if( nSize == 0 ) nSize = 1; Edit_SetSel(*m_pWindow, 0, nSize); #else POINT pt = event.ptMouse; pt.x -= m_rcItem.left + m_rcTextPadding.left; pt.y -= m_rcItem.top + m_rcTextPadding.top; ::SendMessage(*m_pWindow, WM_LBUTTONDOWN, event.wParam, MAKELPARAM(pt.x, pt.y)); #endif } } return; } if( event.Type == UIEVENT_MOUSEMOVE ) { return; } if( event.Type == UIEVENT_BUTTONUP ) { return; } if( event.Type == UIEVENT_CONTEXTMENU ) { return; } if( event.Type == UIEVENT_MOUSEENTER ) { if( IsEnabled() ) { m_uButtonState |= UISTATE_HOT; Invalidate(); } return; } if( event.Type == UIEVENT_MOUSELEAVE ) { if( IsEnabled() ) { m_uButtonState &= ~UISTATE_HOT; Invalidate(); } return; } CLabelUI::DoEvent(event); }
void CUIButton::DoEvent(TEventUI& Event) { if(!IsMouseEnabled() && Event.Type > UIEVENT__MOUSEBEGIN && Event.Type < UIEVENT__MOUSEEND){ if(m_Parent != NULL) m_Parent->DoEvent(Event); else CUILabel::DoEvent(Event); return; } if(Event.Type == UIEVENT_SETFOCUS){ Invalidate(); } if(Event.Type == UIEVENT_KILLFOCUS){ Invalidate(); } if(Event.Type == UIEVENT_KEYDOWN){ // // TODO: keyboard support. // /*if (IsKeyboardEnabled()) { if( Event.chKey == VK_SPACE || Event.chKey == VK_RETURN ) { Activate(); return; } }*/ } if(Event.Type == UIEVENT_BUTTONDOWN || Event.Type == UIEVENT_DBLCLICK){ if(m_rcItem.IsPtIn(Event.ptMouse) && IsEnabled()){ m_uButtonState |= UISTATE_PUSHED | UISTATE_CAPTURED; Invalidate(); } return; } if(Event.Type == UIEVENT_MOUSEMOVE){ if( (m_uButtonState & UISTATE_CAPTURED) != 0 ) { UINT State = m_uButtonState; if(m_rcItem.IsPtIn(Event.ptMouse)) m_uButtonState |= UISTATE_PUSHED; else m_uButtonState &= ~UISTATE_PUSHED; if (State != m_uButtonState){ Invalidate(); } } return; } if(Event.Type == UIEVENT_BUTTONUP){ if( (m_uButtonState & UISTATE_CAPTURED) != 0 ) { if(m_rcItem.IsPtIn(Event.ptMouse)) Activate(); m_uButtonState &= ~(UISTATE_PUSHED | UISTATE_CAPTURED); Invalidate(); } return; } if(Event.Type == UIEVENT_CONTEXTMENU){ /*if( IsContextMenuUsed() ) { m_pManager->SendNotify(this, DUI_MSGTYPE_MENU, Event.wParam, Event.lParam); }*/ return; } if(Event.Type == UIEVENT_MOUSEENTER){ if(IsEnabled()){ m_uButtonState |= UISTATE_HOT; Invalidate(); } // return; } if(Event.Type == UIEVENT_MOUSELEAVE) { if(IsEnabled()){ m_uButtonState &= ~UISTATE_HOT; Invalidate(); } // return; } if(Event.Type == UIEVENT_SETCURSOR){ //::SetCursor(::LoadCursor(NULL, MAKEINTRESOURCE(IDC_HAND))); return; } CUILabel::DoEvent(Event); }
void CSliderUI::DoEvent(TEventUI& event) { if( !IsMouseEnabled() && event.Type > UIEVENT__MOUSEBEGIN && event.Type < UIEVENT__MOUSEEND ) { if( m_pParent != NULL ) m_pParent->DoEvent(event); else CProgressUI::DoEvent(event); return; } if( event.Type == UIEVENT_BUTTONDOWN || event.Type == UIEVENT_DBLCLICK ) { if( IsEnabled() ) {//2014.7.28 redrain 注释掉原来的代码,加上这些代码后可以让Slider不是在鼠标弹起时才改变滑块的位置 m_uButtonState |= UISTATE_CAPTURED; int nValue; if( m_bHorizontal ) { if( event.ptMouse.x >= m_rcItem.right - m_szThumb.cx / 2 ) nValue = m_nMax; else if( event.ptMouse.x <= m_rcItem.left + m_szThumb.cx / 2 ) nValue = m_nMin; else nValue = m_nMin + (m_nMax - m_nMin) * (event.ptMouse.x - m_rcItem.left - m_szThumb.cx / 2 ) / (m_rcItem.right - m_rcItem.left - m_szThumb.cx); } else { if( event.ptMouse.y >= m_rcItem.bottom - m_szThumb.cy / 2 ) nValue = m_nMin; else if( event.ptMouse.y <= m_rcItem.top + m_szThumb.cy / 2 ) nValue = m_nMax; else nValue = m_nMin + (m_nMax - m_nMin) * (m_rcItem.bottom - event.ptMouse.y - m_szThumb.cy / 2 ) / (m_rcItem.bottom - m_rcItem.top - m_szThumb.cy); } if(m_nValue !=nValue && nValue>=m_nMin && nValue<=m_nMax) { m_nValue =nValue; Invalidate(); } } return; } // if( event.Type == UIEVENT_BUTTONDOWN || event.Type == UIEVENT_DBLCLICK ) // { // if( IsEnabled() ) { // RECT rcThumb = GetThumbRect(); // if( ::PtInRect(&rcThumb, event.ptMouse) ) { // m_uButtonState |= UISTATE_CAPTURED; // } // } // return; // } if( event.Type == UIEVENT_BUTTONUP ) { int nValue; if( (m_uButtonState & UISTATE_CAPTURED) != 0 ) { m_uButtonState &= ~UISTATE_CAPTURED; } if( m_bHorizontal ) { if( event.ptMouse.x >= m_rcItem.right - m_szThumb.cx / 2 ) nValue = m_nMax; else if( event.ptMouse.x <= m_rcItem.left + m_szThumb.cx / 2 ) nValue = m_nMin; else nValue = m_nMin + (m_nMax - m_nMin) * (event.ptMouse.x - m_rcItem.left - m_szThumb.cx / 2 ) / (m_rcItem.right - m_rcItem.left - m_szThumb.cx); } else { if( event.ptMouse.y >= m_rcItem.bottom - m_szThumb.cy / 2 ) nValue = m_nMin; else if( event.ptMouse.y <= m_rcItem.top + m_szThumb.cy / 2 ) nValue = m_nMax; else nValue = m_nMin + (m_nMax - m_nMin) * (m_rcItem.bottom - event.ptMouse.y - m_szThumb.cy / 2 ) / (m_rcItem.bottom - m_rcItem.top - m_szThumb.cy); } if(/*m_nValue !=nValue && 2014.7.28 redrain 这个注释很关键,是他导致了鼠标拖动滑块无法发出DUI_MSGTYPE_VALUECHANGED消息*/nValue>=m_nMin && nValue<=m_nMax) { m_nValue =nValue; m_pManager->SendNotify(this, DUI_MSGTYPE_VALUECHANGED); Invalidate(); } return; } if( event.Type == UIEVENT_CONTEXTMENU ) { return; } if( event.Type == UIEVENT_SCROLLWHEEL ) { switch( LOWORD(event.wParam) ) { case SB_LINEUP: SetValue(GetValue() + GetChangeStep()); m_pManager->SendNotify(this, DUI_MSGTYPE_VALUECHANGED); return; case SB_LINEDOWN: SetValue(GetValue() - GetChangeStep()); m_pManager->SendNotify(this, DUI_MSGTYPE_VALUECHANGED); return; } } if( event.Type == UIEVENT_MOUSEMOVE ) { if( (m_uButtonState & UISTATE_CAPTURED) != 0 ) {//2014.7.28 redrain 重写这个消息判断让Slider发出DUI_MSGTYPE_VALUECHANGED_MOVE消息,让他在滑动过程也发出消息,比如用在改变音量时,一边滑动就可以一边改变音量 if( m_bHorizontal ) { if( event.ptMouse.x >= m_rcItem.right - m_szThumb.cx / 2 ) m_nValue = m_nMax; else if( event.ptMouse.x <= m_rcItem.left + m_szThumb.cx / 2 ) m_nValue = m_nMin; else m_nValue = m_nMin + (m_nMax - m_nMin) * (event.ptMouse.x - m_rcItem.left - m_szThumb.cx / 2 ) / (m_rcItem.right - m_rcItem.left - m_szThumb.cx); } else { if( event.ptMouse.y >= m_rcItem.bottom - m_szThumb.cy / 2 ) m_nValue = m_nMin; else if( event.ptMouse.y <= m_rcItem.top + m_szThumb.cy / 2 ) m_nValue = m_nMax; else m_nValue = m_nMin + (m_nMax - m_nMin) * (m_rcItem.bottom - event.ptMouse.y - m_szThumb.cy / 2 ) / (m_rcItem.bottom - m_rcItem.top - m_szThumb.cy); } if (m_bSendMove) m_pManager->SendNotify(this, DUI_MSGTYPE_VALUECHANGED_MOVE); Invalidate(); } // Generate the appropriate mouse messages POINT pt = event.ptMouse; RECT rcThumb = GetThumbRect(); if( IsEnabled() && ::PtInRect(&rcThumb, event.ptMouse) ) { m_uButtonState |= UISTATE_HOT; Invalidate(); }else { m_uButtonState &= ~UISTATE_HOT; Invalidate(); } return; } // if( event.Type == UIEVENT_MOUSEMOVE ) // { // if( (m_uButtonState & UISTATE_CAPTURED) != 0 ) { // if( m_bHorizontal ) { // if( event.ptMouse.x >= m_rcItem.right - m_szThumb.cx / 2 ) m_nValue = m_nMax; // else if( event.ptMouse.x <= m_rcItem.left + m_szThumb.cx / 2 ) m_nValue = m_nMin; // else m_nValue = m_nMin + (m_nMax - m_nMin) * (event.ptMouse.x - m_rcItem.left - m_szThumb.cx / 2 ) / (m_rcItem.right - m_rcItem.left - m_szThumb.cx); // } // else { // if( event.ptMouse.y >= m_rcItem.bottom - m_szThumb.cy / 2 ) m_nValue = m_nMin; // else if( event.ptMouse.y <= m_rcItem.top + m_szThumb.cy / 2 ) m_nValue = m_nMax; // else m_nValue = m_nMin + (m_nMax - m_nMin) * (m_rcItem.bottom - event.ptMouse.y - m_szThumb.cy / 2 ) / (m_rcItem.bottom - m_rcItem.top - m_szThumb.cy); // } // Invalidate(); // } // return; // } if( event.Type == UIEVENT_SETCURSOR ) { RECT rcThumb = GetThumbRect(); if( IsEnabled()) { ::SetCursor(::LoadCursor(NULL, MAKEINTRESOURCE(IDC_HAND))); return; } } // if( event.Type == UIEVENT_SETCURSOR ) // { // RECT rcThumb = GetThumbRect(); // if( IsEnabled() && ::PtInRect(&rcThumb, event.ptMouse) ) { // ::SetCursor(::LoadCursor(NULL, MAKEINTRESOURCE(IDC_HAND))); // return; // } // } if( event.Type == UIEVENT_MOUSEENTER ) {//2014.7.28 redrain 只有鼠标在滑块的范围内才变为UISTATE_HOT // if( IsEnabled() ) { // m_uButtonState |= UISTATE_HOT; // Invalidate(); // } // return; } if( event.Type == UIEVENT_MOUSELEAVE ) { if( IsEnabled() ) { m_uButtonState &= ~UISTATE_HOT; Invalidate(); } return; } CControlUI::DoEvent(event); }
void CGroupsUI::DoEvent(TEventUI& event) { if (!IsMouseEnabled() && event.Type > UIEVENT__MOUSEBEGIN && event.Type < UIEVENT__MOUSEEND) { if (m_pParent != NULL) m_pParent->DoEvent(event); else CVerticalLayoutUI::DoEvent(event); return; } if (event.Type == UIEVENT_TIMER && event.wParam == SCROLL_TIMERID) { if (delay_left_ > 0) { --delay_left_; SIZE sz = GetScrollPos(); LONG lDeltaY = (LONG)(CalculateDelay((double)delay_left_ / delay_number_) * delay_deltaY_); if ((lDeltaY > 0 && sz.cy != 0) || (lDeltaY < 0 && sz.cy != GetScrollRange().cy )) { sz.cy -= lDeltaY; SetScrollPos(sz); return; } } delay_deltaY_ = 0; delay_number_ = 0; delay_left_ = 0; m_pManager->KillTimer(this, SCROLL_TIMERID); return; } if (event.Type == UIEVENT_SCROLLWHEEL) { LONG lDeltaY = 0; if (delay_number_ > 0) lDeltaY = (LONG)(CalculateDelay((double)delay_left_ / delay_number_) * delay_deltaY_); switch (LOWORD(event.wParam)) { case SB_LINEUP: if (delay_deltaY_ >= 0) delay_deltaY_ = lDeltaY + 8; else delay_deltaY_ = lDeltaY + 12; break; case SB_LINEDOWN: if (delay_deltaY_ <= 0) delay_deltaY_ = lDeltaY - 8; else delay_deltaY_ = lDeltaY - 12; break; } if (delay_deltaY_ > 100) delay_deltaY_ = 100; else if (delay_deltaY_ < -100) delay_deltaY_ = -100; delay_number_ = (DWORD)sqrt((double)abs(delay_deltaY_)) * 5; delay_left_ = delay_number_; m_pManager->SetTimer(this, SCROLL_TIMERID, 50U); return; } CListUI::DoEvent(event); }
void CSliderUI::DoEvent(TEventUI& event) { if( !IsMouseEnabled() && event.Type > UIEVENT__MOUSEBEGIN && event.Type < UIEVENT__MOUSEEND ) { if( m_pParent != NULL ) m_pParent->DoEvent(event); else CProgressUI::DoEvent(event); return; } if( event.Type == UIEVENT_BUTTONDOWN || event.Type == UIEVENT_DBLCLICK ) { if( IsEnabled() ) { RECT rcThumb = GetThumbRect(); if( ::PtInRect(&rcThumb, event.ptMouse) ) { m_uButtonState |= UISTATE_CAPTURED; } } return; } if( event.Type == UIEVENT_BUTTONUP ) { int nValue; if( (m_uButtonState & UISTATE_CAPTURED) != 0 ) { m_uButtonState &= ~UISTATE_CAPTURED; } if( m_bHorizontal ) { if( event.ptMouse.x >= m_rcItem.right - m_szThumb.cx / 2 ) nValue = m_nMax; else if( event.ptMouse.x <= m_rcItem.left + m_szThumb.cx / 2 ) nValue = m_nMin; else nValue = m_nMin + (m_nMax - m_nMin) * (event.ptMouse.x - m_rcItem.left - m_szThumb.cx / 2 ) / (m_rcItem.right - m_rcItem.left - m_szThumb.cx); } else { if( event.ptMouse.y >= m_rcItem.bottom - m_szThumb.cy / 2 ) nValue = m_nMin; else if( event.ptMouse.y <= m_rcItem.top + m_szThumb.cy / 2 ) nValue = m_nMax; else nValue = m_nMin + (m_nMax - m_nMin) * (m_rcItem.bottom - event.ptMouse.y - m_szThumb.cy / 2 ) / (m_rcItem.bottom - m_rcItem.top - m_szThumb.cy); } if(m_nValue !=nValue && nValue>=m_nMin && nValue<=m_nMax) { m_nValue =nValue; m_pManager->SendNotify(this, DUI_MSGTYPE_VALUECHANGED); Invalidate(); } return; } if( event.Type == UIEVENT_CONTEXTMENU ) { return; } if( event.Type == UIEVENT_SCROLLWHEEL ) { switch( LOWORD(event.wParam) ) { case SB_LINEUP: SetValue(GetValue() + GetChangeStep()); m_pManager->SendNotify(this, DUI_MSGTYPE_VALUECHANGED); return; case SB_LINEDOWN: SetValue(GetValue() - GetChangeStep()); m_pManager->SendNotify(this, DUI_MSGTYPE_VALUECHANGED); return; } } if( event.Type == UIEVENT_MOUSEMOVE ) { if( (m_uButtonState & UISTATE_CAPTURED) != 0 ) { if( m_bHorizontal ) { if( event.ptMouse.x >= m_rcItem.right - m_szThumb.cx / 2 ) m_nValue = m_nMax; else if( event.ptMouse.x <= m_rcItem.left + m_szThumb.cx / 2 ) m_nValue = m_nMin; else m_nValue = m_nMin + (m_nMax - m_nMin) * (event.ptMouse.x - m_rcItem.left - m_szThumb.cx / 2 ) / (m_rcItem.right - m_rcItem.left - m_szThumb.cx); m_pManager->SendNotify(this, DUI_MSGTYPE_VALUECHANGED); } else { if( event.ptMouse.y >= m_rcItem.bottom - m_szThumb.cy / 2 ) m_nValue = m_nMin; else if( event.ptMouse.y <= m_rcItem.top + m_szThumb.cy / 2 ) m_nValue = m_nMax; else m_nValue = m_nMin + (m_nMax - m_nMin) * (m_rcItem.bottom - event.ptMouse.y - m_szThumb.cy / 2 ) / (m_rcItem.bottom - m_rcItem.top - m_szThumb.cy); m_pManager->SendNotify(this, DUI_MSGTYPE_VALUECHANGED); } Invalidate(); } return; } if( event.Type == UIEVENT_SETCURSOR ) { RECT rcThumb = GetThumbRect(); if( IsEnabled() && ::PtInRect(&rcThumb, event.ptMouse) ) { ::SetCursor(::LoadCursor(NULL, MAKEINTRESOURCE(IDC_HAND))); return; } } if( event.Type == UIEVENT_MOUSEENTER ) { if( IsEnabled() ) { m_uButtonState |= UISTATE_HOT; Invalidate(); } return; } if( event.Type == UIEVENT_MOUSELEAVE ) { if( IsEnabled() ) { m_uButtonState &= ~UISTATE_HOT; Invalidate(); } return; } CControlUI::DoEvent(event); }
void CContainerUI::DoEvent(TEventUI& event) { if( !IsMouseEnabled() && event.Type > UIEVENT__MOUSEBEGIN && event.Type < UIEVENT__MOUSEEND ) { if( m_pParent != NULL ) m_pParent->DoEvent(event); else CControlUI::DoEvent(event); return; } if( event.Type == UIEVENT_SETFOCUS ) { m_bFocused = true; return; } if( event.Type == UIEVENT_KILLFOCUS ) { m_bFocused = false; return; } if( m_pVerticalScrollBar != NULL && m_pVerticalScrollBar->IsVisible() && m_pVerticalScrollBar->IsEnabled() ) { if( event.Type == UIEVENT_KEYDOWN ) { switch( event.chKey ) { case VK_DOWN: LineDown(); return; case VK_UP: LineUp(); return; case VK_NEXT: PageDown(); return; case VK_PRIOR: PageUp(); return; case VK_HOME: HomeUp(); return; case VK_END: EndDown(); return; } } else if( event.Type == UIEVENT_SCROLLWHEEL ) { switch( LOWORD(event.wParam) ) { case SB_LINEUP: LineUp(); return; case SB_LINEDOWN: LineDown(); return; } } } if( m_pHorizontalScrollBar != NULL && m_pHorizontalScrollBar->IsVisible() && m_pHorizontalScrollBar->IsEnabled() ) { if( event.Type == UIEVENT_KEYDOWN ) { switch( event.chKey ) { case VK_DOWN: LineRight(); return; case VK_UP: LineLeft(); return; case VK_NEXT: PageRight(); return; case VK_PRIOR: PageLeft(); return; case VK_HOME: HomeLeft(); return; case VK_END: EndRight(); return; } } else if( event.Type == UIEVENT_SCROLLWHEEL ) { switch( LOWORD(event.wParam) ) { case SB_LINEUP: LineLeft(); return; case SB_LINEDOWN: LineRight(); return; } } } CControlUI::DoEvent(event); }
void CDateTimeUI::DoEvent(TEventUI& event) { if( !IsMouseEnabled() && event.Type > UIEVENT__MOUSEBEGIN && event.Type < UIEVENT__MOUSEEND ) { if( m_pParent != NULL ) m_pParent->DoEvent(event); else CLabelUI::DoEvent(event); return; } if( event.Type == UIEVENT_SETCURSOR && IsEnabled() ) { ::SetCursor(::LoadCursor(NULL, MAKEINTRESOURCE(IDC_IBEAM))); return; } if( event.Type == UIEVENT_WINDOWSIZE ) { if( m_pWindow != NULL ) m_pManager->SetFocusNeeded(this); } if( event.Type == UIEVENT_SCROLLWHEEL ) { if( m_pWindow != NULL ) return; } if( event.Type == UIEVENT_SETFOCUS && IsEnabled() ) { if( m_pWindow ) return; m_pWindow = new CDateTimeWnd(); ASSERT(m_pWindow); m_pWindow->Init(this); m_pWindow->ShowWindow(); } if( event.Type == UIEVENT_KILLFOCUS && IsEnabled() ) { Invalidate(); } if( event.Type == UIEVENT_BUTTONDOWN || event.Type == UIEVENT_DBLCLICK || event.Type == UIEVENT_RBUTTONDOWN) { if( IsEnabled() ) { GetManager()->ReleaseCapture(); if( IsFocused() && m_pWindow == NULL ) { m_pWindow = new CDateTimeWnd(); ASSERT(m_pWindow); } if( m_pWindow != NULL ) { m_pWindow->Init(this); m_pWindow->ShowWindow(); } } return; } if( event.Type == UIEVENT_MOUSEMOVE ) { return; } if( event.Type == UIEVENT_BUTTONUP ) { return; } if( event.Type == UIEVENT_CONTEXTMENU ) { return; } CLabelUI::DoEvent(event); }
void CWebkitUI::DoEvent(TEventUI& event) { if( !IsMouseEnabled() && event.Type > UIEVENT__MOUSEBEGIN && event.Type < UIEVENT__MOUSEEND ) { if( m_pParent != NULL ) m_pParent->DoEvent(event); else CControlUI::DoEvent(event); return; } if (bitmap_bits_ == NULL || view_ == NULL || !finish_layout_) return; if( event.Type == UIEVENT_SETFOCUS ) { view_->OnFocusChangeEvent(true); } if( event.Type == UIEVENT_KILLFOCUS ) { view_->OnFocusChangeEvent(false); } if( event.Type == UIEVENT_CHAR ) { KeyboardEvent keyEvent = {0}; keyEvent.mId = event.chKey; keyEvent.mbChar = true; keyEvent.mbDepressed = false; keyEvent.mbShift = ((event.wKeyState & MK_SHIFT) != 0); keyEvent.mbControl = ((event.wKeyState & MK_CONTROL) != 0); keyEvent.mbAlt = ((event.wKeyState & MK_ALT) != 0); view_->OnKeyboardEvent(keyEvent); } if( event.Type == UIEVENT_KEYDOWN ) { KeyboardEvent keyEvent = {0}; keyEvent.mId = event.chKey; keyEvent.mbChar = false; keyEvent.mbDepressed = true; keyEvent.mbShift = ((event.wKeyState & MK_SHIFT) != 0); keyEvent.mbControl = ((event.wKeyState & MK_CONTROL) != 0); keyEvent.mbAlt = ((event.wKeyState & MK_ALT) != 0); view_->OnKeyboardEvent(keyEvent); } if( event.Type == UIEVENT_KEYUP ) { KeyboardEvent keyEvent = {0}; keyEvent.mId = event.chKey; keyEvent.mbChar = false; keyEvent.mbDepressed = false; keyEvent.mbShift = ((event.wKeyState & MK_SHIFT) != 0); keyEvent.mbControl = ((event.wKeyState & MK_CONTROL) != 0); keyEvent.mbAlt = ((event.wKeyState & MK_ALT) != 0); view_->OnKeyboardEvent(keyEvent); } if( event.Type == UIEVENT_BUTTONDOWN || event.Type == UIEVENT_DBLCLICK || event.Type == UIEVENT_BUTTONUP ) { MouseButtonEvent mouseEvent = {0}; mouseEvent.mX = event.ptMouse.x - m_rcItem.left; mouseEvent.mY = event.ptMouse.y - m_rcItem.top; mouseEvent.mId = kMouseLeft; if( event.Type == UIEVENT_BUTTONDOWN || event.Type == UIEVENT_DBLCLICK ) mouseEvent.mbDepressed = true; else mouseEvent.mbDepressed = false; mouseEvent.mbShift = ((event.wKeyState & MK_SHIFT) != 0); mouseEvent.mbControl = ((event.wKeyState & MK_CONTROL) != 0); mouseEvent.mbAlt = ((event.wKeyState & MK_ALT) != 0); view_->OnMouseButtonEvent(mouseEvent); return; } if( event.Type == UIEVENT_MOUSEMOVE ) { MouseMoveEvent mouseEvent = {0}; mouseEvent.mX = event.ptMouse.x - m_rcItem.left; mouseEvent.mY = event.ptMouse.y - m_rcItem.top; mouseEvent.mDX = event.ptMouse.x - last_mouse_point_.x; mouseEvent.mDY = event.ptMouse.y - last_mouse_point_.y; mouseEvent.mbShift = ((event.wKeyState & MK_SHIFT) != 0); mouseEvent.mbControl = ((event.wKeyState & MK_CONTROL) != 0); mouseEvent.mbAlt = ((event.wKeyState & MK_ALT) != 0); view_->OnMouseMoveEvent(mouseEvent); last_mouse_point_.x = mouseEvent.mX; last_mouse_point_.y = mouseEvent.mY; return; } if( event.Type == UIEVENT_SCROLLWHEEL ) { MouseWheelEvent mouseEvent = {0}; mouseEvent.mX = event.ptMouse.x - m_rcItem.left; mouseEvent.mY = event.ptMouse.y - m_rcItem.top; // default value is 3 int uLineDelta = 3; SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &uLineDelta, 0); if( LOWORD(event.wParam) == SB_LINEUP ) mouseEvent.mLineDelta = static_cast<float>(uLineDelta); else mouseEvent.mLineDelta = static_cast<float>(-uLineDelta); mouseEvent.mbShift = ((event.wKeyState & MK_SHIFT) != 0); mouseEvent.mbControl = ((event.wKeyState & MK_CONTROL) != 0); mouseEvent.mbAlt = ((event.wKeyState & MK_ALT) != 0); view_->OnMouseWheelEvent(mouseEvent); return; } }