BOOL  CXTPRibbonControlTab::OnSetSelected(int bSelected)
{
	if (bSelected == m_bSelected)
		return FALSE;

	if (IsKeyboardSelected(bSelected) && !GetRibbonBar()->IsRibbonMinimized())
		m_pParent->SetPopuped(-1);

	m_bSelected = bSelected;

	m_pParent->OnControlSelected(bSelected, this);

	if (IsKeyboardSelected(bSelected))
	{
		SetFocused(TRUE);
	}

	if (!bSelected)
	{
		SetFocused(FALSE);
		PerformMouseMove(m_pParent->GetSafeHwnd(), CPoint(-1, -1));
	}
	else
	{
		AccessibleNotifyWinEvent(EVENT_OBJECT_FOCUS , GetParent()->GetSafeHwnd(), GetID(), GetCurSel() + 1);
	}

	return TRUE;
}
void CXTPDockingPaneTabbedContainer::OnMouseMove(UINT nFlags, CPoint point)
{
	PerformMouseMove(m_hWnd, point);

	if (m_pTrackingPane)
	{
		for (int i = 0; i < m_lstRects.GetSize(); i++)
		{
			if (GetItemPane(i) != m_pTrackingPane && m_lstRects[i].PtInRect(point))
			{
				_Swap(GetItemPane(i), m_pTrackingPane);

				InvalidatePane(TRUE);
				return;
			}
		}


		if (CXTPTabManager::HitTest(point) == NULL)
		{
			if (GetDockingPaneManager()->NotifyAction(xtpPaneActionDetaching, m_pTrackingPane))
				return;

			ASSERT(m_pSelectedPane == m_pTrackingPane);
			m_pTrackingPane = NULL;
			ReleaseCapture();

			ClientToScreen(&point);

			CXTPDockingPaneContext* pContext = GetDockingPaneManager()->GetDockingContext();
			pContext->Drag(m_pSelectedPane, point);
		}
	}
	else
	{
		m_pCaptionButtons->CheckForMouseOver(point);
	}

	CWnd::OnMouseMove(nFlags, point);
}
Esempio n. 3
0
void CXTPTabManager::ReOrder(HWND hWnd, CPoint pt, CXTPTabManagerItem* pItem)
{
	CXTPTabManagerItem* pSelected = m_pSelected;
	m_pSelected = pItem;

	if (GetPaintManager()->m_bHotTracking)
		m_pHighlighted = pItem;

	Reposition();

	CArray<CRect, CRect&> arrRects;

	for (int j = 0; j < GetItemCount(); j++)
	{
		CRect rc = GetItem(j)->GetRect();
		arrRects.Add(rc);
	}

	int nIndex = pItem->GetIndex();

	::SetCapture(hWnd);

	while (::GetCapture() == hWnd)
	{
		MSG msg;
		VERIFY(::GetMessage(&msg, NULL, 0, 0));

		if (::GetCapture() != hWnd)
		{
			DispatchMessage (&msg);
			break;
		}
		switch (msg.message)
		{
			case WM_MOUSEMOVE:
				{
					pt = CPoint((short signed)LOWORD(msg.lParam), (short signed)HIWORD(msg.lParam));

					for (int i = 0; i < arrRects.GetSize(); i++)
					{
						if (i != pItem->GetIndex() && arrRects[i].PtInRect(pt))
						{

							while (i != pItem->GetIndex())
							{
								int j = i < pItem->GetIndex() ? pItem->GetIndex() - 1 : pItem->GetIndex() + 1;

								CXTPTabManagerItem* p1 = pItem;
								CXTPTabManagerItem* p2 = m_arrItems[pItem->GetIndex()] = m_arrItems[j];
								m_arrItems[j] = p1;

								OnItemsChanged();

								OnSwitchItem(p1, p2);
							}
							break;
						}
					}
				}

				break;

			case WM_KEYDOWN:
				if (msg.wParam != VK_ESCAPE)
					break;
			case WM_CANCELMODE:
			case WM_LBUTTONUP:
			case WM_RBUTTONDOWN:
				goto ExitLoop;

			default:
				DispatchMessage (&msg);
				break;
		}
	}

ExitLoop:
	ReleaseCapture();
	PerformMouseMove(hWnd, pt);

	m_pSelected = pSelected;
	OnItemClick(pItem);

	if (nIndex != pItem->GetIndex())
	{
		OnItemOrderChanged(pItem, nIndex, pItem->GetIndex());
	}
}
void CXTPDockingPaneTabbedContainer::OnLButtonDown(UINT /*nFlags*/, CPoint point)
{

	CXTPDockingPaneCaptionButton* pButton = HitTestCaptionButton(point);

	if (pButton)
	{
		_RestoreFocus();

		if (m_pSelectedPane && OnCaptionButtonDown(pButton))
			return;

		if (pButton->Click(this, point) && m_pSelectedPane)
		{
			OnCaptionButtonClick(pButton);
		}

		return;
	}

	if (IsTabsVisible() && PerformClick(m_hWnd, point, TRUE))
		return;

	int nHit = HitTest(point);
	if (nHit == DOCKINGPANE_HITCAPTION && !IsHidden())
	{
		ClientToScreen(&point);
		OnCaptionLButtonDown(point);
	}
	else if (nHit >= 0)
	{
		CXTPDockingPane* pPane = GetItemPane(nHit);
		if (GetDockingPaneManager()->NotifyAction(xtpPaneActionDragging, pPane))
		{
			SelectPane(pPane, TRUE, FALSE);
			PerformMouseMove(m_hWnd, point);
			Invalidate(FALSE);
			return;
		}

		m_lstRects.RemoveAll();
		for (int j = 0; j < GetItemCount(); j++)
		{
			CRect rc(GetItem(j)->GetRect());
			m_lstRects.Add(rc);
		}

		m_pTrackingPane = pPane;
		SelectPane(m_pTrackingPane, TRUE, FALSE);

		PerformMouseMove(m_hWnd, point);

		SetCapture();

		Invalidate(FALSE);
	}
	else
	{
		_RestoreFocus();
	}
}
Esempio n. 5
0
void CXTPTabManager::TrackClick(HWND hWnd, CPoint pt, CXTPTabManagerItem* pItem)
{
	if (GetPaintManager()->m_bHotTracking)
		m_pHighlighted = pItem;

	m_pPressed = pItem;
	BOOL bHighlighted = TRUE;

	Reposition();
	BOOL bAccept = FALSE;

	::SetCapture(hWnd);

	while (::GetCapture() == hWnd)
	{
		MSG msg;
		VERIFY(::GetMessage(&msg, NULL, 0, 0));

		if (::GetCapture() != hWnd)
		{
			DispatchMessage (&msg);
			break;
		}
		switch (msg.message)
		{
			case WM_MOUSEMOVE:
				{
					pt = CPoint((short signed)LOWORD(msg.lParam), (short signed)HIWORD(msg.lParam));

					bHighlighted = pItem->GetRect().PtInRect(pt);

					if (GetPaintManager()->m_bHotTracking)
					{
						CXTPTabManagerItem* pHighlighted = bHighlighted ? pItem : NULL;
						if (pHighlighted != m_pHighlighted)
						{
							m_pHighlighted = pHighlighted;
							RedrawControl(pItem->GetRect(), TRUE);
						}
					}

				}

				break;

			case WM_KEYDOWN:
				if (msg.wParam != VK_ESCAPE)
					break;
			case WM_CANCELMODE:
			case WM_RBUTTONDOWN:
				goto ExitLoop;

			case WM_LBUTTONUP:
				bAccept = TRUE;
				goto ExitLoop;

			default:
				DispatchMessage (&msg);
				break;
		}
	}

ExitLoop:
	ReleaseCapture();

	m_pPressed = FALSE;

	PerformMouseMove(hWnd, pt);

	RedrawControl(NULL, FALSE);

	if (bAccept && bHighlighted)
	{
		OnItemClick(pItem);
	}
}