コード例 #1
0
ファイル: Window.cpp プロジェクト: sigurdle/FirstProject2
void PlatformWindowSite::OnMouseButtonDown(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);
		args->m_screenpos = Point(float(screenMousePos.x), float(screenMousePos.y));
		args->m_clientpos = clientMousePos;

		// Raise general mousedown event
		args->set_RoutedEvent(UIElement::get_MouseButtonDownEvent());
		hitElement->RaiseEvent(args);

		// Raise button mousedown event
		if (button == 0)			args->set_RoutedEvent(UIElement::get_MouseLeftButtonDownEvent());
		else if (button == 1)	args->set_RoutedEvent(UIElement::get_MouseMiddleButtonDownEvent());
		else						args->set_RoutedEvent(UIElement::get_MouseRightButtonDownEvent());

		hitElement->RaiseEvent(args);
	}
}
コード例 #2
0
ファイル: Window.cpp プロジェクト: sigurdle/FirstProject2
void PlatformWindowSite::OnMouseButtonUp(gm::PointF clientMousePos, int button)
{
	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);
		}
		hitElement = child;
	}

	if (hitElement)
	{
		MouseButtonEventArgs* args = new MouseButtonEventArgs(nullptr, 0);

		if (button == 0)			args->set_RoutedEvent(UIElement::get_MouseLeftButtonUpEvent());
		else if (button == 1)	args->set_RoutedEvent(UIElement::get_MouseMiddleButtonUpEvent());
		else						args->set_RoutedEvent(UIElement::get_MouseRightButtonUpEvent());

		args->m_screenpos = Point(float(screenMousePos.x), float(screenMousePos.y));
		args->m_clientpos = clientMousePos;

		hitElement->RaiseEvent(args);
	}
}
コード例 #3
0
ファイル: Window.cpp プロジェクト: sigurdle/FirstProject2
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);
	}
}
コード例 #4
0
ファイル: Window.cpp プロジェクト: sigurdle/FirstProject2
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;
}