void PlatformWindowSite::OnMouseButtonDblClk(gm::PointF clientMousePos, int button) { POINT screenMousePos; ::GetCursorPos(&screenMousePos); UIElement* hitElement = nullptr; UIElement* child = GetRootElement(); // Visual* child = get_Child(); if (child) { hitElement = child->HitTest_(clientMousePos); } // hitElement = child; if (hitElement) { MouseButtonEventArgs* args = new MouseButtonEventArgs(nullptr, 0); if (button == 0) args->set_RoutedEvent(UIElement::get_MouseLeftButtonDoubleClickEvent()); else if (button == 1) args->set_RoutedEvent(UIElement::get_MouseMiddleButtonDoubleClickEvent()); else args->set_RoutedEvent(UIElement::get_MouseRightButtonDoubleClickEvent()); args->m_screenpos = Point(float(screenMousePos.x), float(screenMousePos.y)); args->m_clientpos = clientMousePos; hitElement->RaiseEvent(args); } }
HRESULT PlatformWindowSite::DragOver( /* [in] */ DWORD grfKeyState, /* [in] */ POINTL pt, /* [out][in] */ __RPC__inout DWORD *pdwEffect) { Point screenMousePos(pt.x, pt.y); ScreenToClient(m_platformWindow->get_Handle(), (POINT*)&pt); Point clientMousePos(pt.x, pt.y); if (m_DragOverElement) { DragEventArgs* args = new DragEventArgs(m_pDataObject); args->set_RoutedEvent(UIElement::get_DragLeaveEvent()); // args->m_screenpos = Point(float(screenMousePos.x), float(screenMousePos.y)); // args->m_clientpos = clientMousePos; m_DragOverElement->RaiseEvent(args); } UIElement* child = GetRootElement(); if (child) { m_DragOverElement = child->HitTest_(clientMousePos); } if (m_DragOverElement == nullptr) { m_DragOverElement = GetRootWindow(); } if (m_DragOverElement) { DragEventArgs* args = new DragEventArgs(m_pDataObject); args->set_RoutedEvent(UIElement::get_DragEnterEvent()); // args->m_screenpos = Point(float(screenMousePos.x), float(screenMousePos.y)); // args->m_clientpos = clientMousePos; m_DragOverElement->RaiseEvent(args); } // Call IDragImages::DragEnter last m_dropTargetHelper->DragOver((POINT*)&pt, *pdwEffect); return S_OK; }
void PlatformWindowSite::OnMouseMove(gm::PointF clientMousePos) { POINT screenMousePos; ::GetCursorPos(&screenMousePos); UIElement* hitElement = nullptr; if (m_MouseCaptureElement) { hitElement = m_MouseCaptureElement; } else { //Visual* child = get_Child(); UIElement* child = GetRootElement(); if (child) { hitElement = child->HitTest_(clientMousePos); } } if (m_MouseOverElement != hitElement) { // Find common ancestor UIElement* commonAncestor = m_MouseOverElement->FindCommonAncestor(hitElement); // ASSERT(commonAncestor); for (UIElement* p = m_MouseOverElement; p != commonAncestor; p = p->get_Parent()) { p->set_IsMouseOver(false); } for (UIElement* p = hitElement; p != commonAncestor; p = p->get_Parent()) { p->set_IsMouseOver(true); } if (m_MouseOverElement) { m_MouseOverElement->set_IsMouseDirectlyOver(false); } m_MouseOverElement = hitElement; if (m_MouseOverElement) { m_MouseOverElement->set_IsMouseDirectlyOver(true); } } if (hitElement) { MouseEventArgs* args = new MouseEventArgs(nullptr, 0); args->set_RoutedEvent(UIElement::get_MouseMoveEvent()); args->m_screenpos = Point(float(screenMousePos.x), float(screenMousePos.y)); args->m_clientpos = clientMousePos; hitElement->RaiseEvent(args); } }
bool PlatformWindowSite::OnSetCursor(UINT hitTest, POINT screenMousePos) { if (hitTest == HTCLIENT) { gm::PointF clientMousePos(screenMousePos.x, screenMousePos.y); ScreenToClient(m_platformWindow->get_Handle(), (POINT*)&clientMousePos); IInputElement* hitElement = nullptr; if (m_MouseCaptureElement) { hitElement = m_MouseCaptureElement; } else { //Visual* child = get_Child(); UIElement* child = GetRootElement(); if (child) { hitElement = child->HitTest_(clientMousePos); } // hitElement = child; } if (hitElement == nullptr) { hitElement = dynamic_cast<IInputElement*>(this); } if (hitElement) { /* MouseEventArgs* args = new MouseEventArgs(nullptr, 0); args->set_RoutedEvent(UIElement::MouseMoveEvent); args->m_screenpos = Point(float(screenMousePos.x), float(screenMousePos.y)); args->m_clientpos = clientMousePos; hitElement->RaiseEvent(args); */ Cursor* pCursor = dynamic_cast<UIElement*>(hitElement)->get_Cursor(); if (pCursor) { SetCursor(pCursor->GetHCursor()); if (!showCursor) { showCursor = true; ::ShowCursor(TRUE); } return true; } else { if (showCursor) { showCursor = false; ::ShowCursor(FALSE); } } } } return false; }
HRESULT PlatformWindowSite::DragEnter( ::IDataObject* pDataObject, /* [in] */ DWORD grfKeyState, /* [in] */ POINTL pt, /* [out][in] */ __RPC__inout DWORD *pdwEffect) { m_pDataObject = pDataObject; /* if (m_pDataObject != pDataObject) { m_pDataObject = pDataObject; m_dataObject = new DataObject; m_dataObject->m_pDataObject = m_pDataObject; }*/ if (m_dropTargetHelper == nullptr) { HRESULT hr; hr = m_dropTargetHelper.CoCreateInstance(CLSID_DragDropHelper); if (FAILED(hr)) return hr; } // ComPtr<IEnumFORMATETC> enumfmt; // pDataObject->EnumFormatEtc(DATADIR_GET, &enumfmt); /* FORMATETC fetc; DWORD fetched; while ((enumfmt->Next(1, &fetc, &fetched) == S_OK) && fetched) { DebugTrace("Format " << fetc.cfFormat << "\n"); //CF_TEXT } */ UIElement* hitElement = nullptr; gm::PointF screenMousePos(float(pt.x), float(pt.y)); ScreenToClient(m_platformWindow->get_Handle(), (POINT*)&pt); Point clientMousePos(pt.x, pt.y); UIElement* child = GetRootElement(); if (child) { hitElement = child->HitTest_(clientMousePos); } if (hitElement == nullptr) { hitElement = GetRootWindow(); } if (hitElement) { m_DragOverElement = hitElement; DragEventArgs* args = new DragEventArgs(pDataObject); args->set_RoutedEvent(UIElement::get_DragEnterEvent()); // args->m_screenpos = Point(float(screenMousePos.x), float(screenMousePos.y)); // args->m_clientpos = clientMousePos; hitElement->RaiseEvent(args); } // Call IDragImages::DragEnter last m_dropTargetHelper->DragEnter(m_platformWindow->get_Handle(), pDataObject, (POINT*)&pt, *pdwEffect); return S_OK; }