//*****************************************************************************
void CBCGPRibbonSlider::OnMouseMove (CPoint point)
{
	ASSERT_VALID (this);

	CBCGPBaseRibbonElement::OnMouseMove (point);

	if (IsDisabled ())
	{
		return;
	}

	int nHighlightedOld = m_nHighlighted;

	m_nHighlighted = GetHitTest (point);

	if (nHighlightedOld != m_nHighlighted)
	{
		Redraw ();
	}

	if (m_bIsPressed)
	{
		if (m_nPressed == nThumbIndex)
		{
			int nPos = GetPosFromPoint (point);
			if (nPos != m_nPos)
			{
				SetPos (nPos);
				NotifyCommand ();
			}
		}
	}
}
//*****************************************************************************
void CBCGPRibbonSlider::OnLButtonUp (CPoint point)
{
	ASSERT_VALID (this);

	CBCGPBaseRibbonElement::OnLButtonUp (point);

	if (m_nPressed == m_nHighlighted && !IsDisabled ())
	{
		switch (m_nPressed)
		{
		case nZoomInIndex:
			SetPos (m_nPos + m_nPageSize);
			break;

		case nZoomOutIndex:
			SetPos (m_nPos - m_nPageSize);
			break;

		default:
			SetPos (GetPosFromPoint (point));
			break;
		}

		NotifyCommand ();
	}
}
//***************************************************************************
BOOL CBCGPRibbonSlider::OnAutoRepeat ()
{
	ASSERT_VALID (this);

	if (m_bIsDisabled)
	{
		return FALSE;
	}

	if (m_nPressed == nZoomInIndex)
	{
		SetPos (m_nPos + m_nPageSize);
		NotifyCommand ();
	}
	else if (m_nPressed == nZoomOutIndex)
	{
		SetPos (m_nPos - m_nPageSize);
		NotifyCommand ();
	}

	return TRUE;
}
Пример #4
0
//**************************************************************************
void CBCGPRibbonComboBox::OnSelectItem (int nItem)
{
	ASSERT_VALID (this);

	SelectItem (nItem);
	m_RecentChangeEvt = CBCGPRibbonEdit::BCGPRIBBON_EDIT_CHANGED_FROM_DROPDOWN;

	NotifyCommand (TRUE);

	if (m_pParentMenu != NULL)
	{
		ASSERT_VALID (m_pParentMenu);

		if (m_pParentMenu->IsFloaty ())
		{
			CBCGPRibbonFloaty* pFloaty = DYNAMIC_DOWNCAST (
				CBCGPRibbonFloaty, m_pParentMenu->GetParent ());

			if (pFloaty != NULL && !pFloaty->IsContextMenuMode ())
			{
				if (m_pWndEdit->GetSafeHwnd () != NULL && m_pWndEdit->GetTopLevelFrame () != NULL)
				{
					m_pWndEdit->GetTopLevelFrame ()->SetFocus ();
				}

				Redraw ();
				return;
			}
		}

		CFrameWnd* pParentFrame = BCGPGetParentFrame (m_pParentMenu);
		ASSERT_VALID (pParentFrame);

		pParentFrame->PostMessage (WM_CLOSE);
	}
	else
	{
		if (m_pWndEdit->GetSafeHwnd () != NULL && m_pWndEdit->GetTopLevelFrame () != NULL)
		{
			m_bNotifyCommand = FALSE;
			m_pWndEdit->GetTopLevelFrame ()->SetFocus ();
		}

		Redraw ();
	}
}
//***************************************************************************************
void CBCGPRadialMenuObject::OnMouseUp(int /*nButton*/, const CBCGPPoint& /*pt*/)
{
	StopAutorepeatTimer();

	BOOL bSendCommand = (m_nHighlighted == m_nPressed && m_nPressed >= 0 && m_nPressed < m_arItems.GetSize() &&
		m_pCtrl->GetSafeHwnd() != NULL && m_pCtrl->GetOwner() != NULL);

	if (!m_bIsFirstClick && m_bIsCloseOnInvoke && bSendCommand && m_pCtrl != NULL && m_pCtrl->IsPopup() && m_pCtrl->GetSafeHwnd() != NULL)
	{
		m_pCtrl->PostMessage(WM_CLOSE);
	}

	NotifyCommand();

	m_nHighlighted = -1;
	m_nPressed = -1;
	m_nLastClicked = -1;

	Redraw();
}
//***************************************************************************************
BOOL CBCGPRadialMenuObject::OnKeyboardDown(UINT nChar, UINT /*nRepCnt*/, UINT /*nFlags*/)
{
	int elem = -1;

	switch (nChar)
	{
	case VK_LEFT:
	case VK_NUMPAD4:
		elem = 2;
		break;

	case VK_HOME:
	case VK_NUMPAD7:
		elem = 1;
		break;

	case VK_UP:
	case VK_NUMPAD8:
		elem = 0;
		break;

	case VK_PRIOR:
	case VK_NUMPAD9:
		elem = 3;
		break;

	case VK_RIGHT:
	case VK_NUMPAD6:
		elem = 6;
		break;

	case VK_NEXT:
	case VK_NUMPAD3:
		elem = 5;
		break;

	case VK_DOWN:
	case VK_NUMPAD2:
		elem = 4;
		break;

	case VK_END:
	case VK_NUMPAD1:
		elem = 7;
		break;

	case VK_CLEAR:
	case VK_NUMPAD5:
		elem = 8;
		break;

	case VK_ESCAPE:
		if (m_pCtrl != NULL && m_pCtrl->IsPopup() && m_pCtrl->GetSafeHwnd() != NULL)
		{
			m_pCtrl->PostMessage(WM_CLOSE);
		}
		break;

	default:
		return FALSE;
	}

	if (elem < 0 || elem >= m_arItems.GetSize())
	{
		return FALSE;
	}

	if (IsItemDisabled(elem))
	{
		return TRUE;
	}

	m_nHighlighted = m_nPressed = elem;
	m_nLastClicked = elem;

	Redraw();

	NotifyCommand();

	m_nHighlighted = -1;
	m_nPressed = -1;
	m_nLastClicked = -1;

	Redraw();

	return TRUE;
}
//********************************************************************************
BOOL CBCGPRibbonSlider::OnProcessKey (UINT nChar)
{
	ASSERT_VALID (this);

	const int nPrevPos = m_nPos;
	int nPos = m_nPos;

	switch (nChar)
	{
	case VK_LEFT:
		if (!IsVert ())
		{
			nPos--;
		}
		else
		{
			return FALSE;
		}
		break;

	case VK_UP:
		if (IsVert ())
		{
			nPos++;
		}
		else
		{
			return FALSE;
		}
		break;

	case VK_SUBTRACT:
		if (!m_bZoomButtons)
		{
			return FALSE;
		}

	case VK_PRIOR:
		if (IsVert ())
		{
			nPos += m_nPageSize;
		}
		else
		{
			nPos -= m_nPageSize;
		}
		break;

	case VK_ADD:
		if (!m_bZoomButtons)
		{
			return FALSE;
		}

	case VK_NEXT:
		if (IsVert ())
		{
			nPos -= m_nPageSize;
		}
		else
		{
			nPos += m_nPageSize;
		}
		break;

	case VK_RIGHT:
		if (!IsVert ())
		{
			nPos++;
		}
		else
		{
			return FALSE;
		}
		break;

	case VK_DOWN:
		if (IsVert ())
		{
			nPos--;
		}
		else
		{
			return FALSE;
		}
		break;

	case VK_HOME:
		nPos = IsVert () ? m_nMax : m_nMin;
		break;

	case VK_END:
		nPos = IsVert () ? m_nMin : m_nMax;
		break;

	default:
		return FALSE;
	}

	nPos = min (max (m_nMin, nPos), m_nMax);

	if (nPrevPos != nPos)
	{
		SetPos (nPos);
		NotifyCommand ();
	}

	return TRUE;
}