Ejemplo n.º 1
0
BOOL CXTPPopupControl::OnWndMsg(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
	if (m_pMarkupContext)
	{
		CPoint ptMouse(0);
		GetCursorPos(&ptMouse);
		ScreenToClient(&ptMouse);

		BOOL bRelay = FALSE;

		CXTPPopupItem* pItem = HitTest(ptMouse);
		if (pItem && pItem->GetMarkupUIElement())
		{
			bRelay = TRUE;
			if (XTPMarkupRelayMessage(pItem->GetMarkupUIElement(), message, wParam, lParam, pResult))
				return TRUE;
		}

		if (!bRelay)
		{
			if (XTPMarkupRelayMessage(GetMarkupContext(), message, wParam, lParam, pResult))
				return TRUE;
		}

	}
	return CWnd::OnWndMsg(message, wParam, lParam, pResult);
}
Ejemplo n.º 2
0
void CHTRichEditCtrl::OnContextMenu(CWnd* /*pWnd*/, CPoint point)
{
	if (point.x != -1 || point.y != -1) {
		CRect rcClient;
		GetClientRect(&rcClient);
		ClientToScreen(&rcClient);
		if (!rcClient.PtInRect(point)) {
			Default();
			return;
		}
	}

	long lSelStart, lSelEnd;
	GetSel(lSelStart, lSelEnd);

	// ugly, simulate a left click to get around the text cursor problem when right clicking.
	if (point.x != -1 && point.y != -1 && lSelStart == lSelEnd)
	{
		ASSERT( GetStyle() & ES_NOHIDESEL ); // this works only if ES_NOHIDESEL is set
		CPoint ptMouse(point);
		ScreenToClient(&ptMouse);
		SendMessage(WM_LBUTTONDOWN, MK_LBUTTON, MAKELONG(ptMouse.x, ptMouse.y));
		SendMessage(WM_LBUTTONUP, MK_LBUTTON, MAKELONG(ptMouse.x, ptMouse.y));
	}

	int iTextLen = GetWindowTextLength();

	CTitleMenu menu;
	menu.CreatePopupMenu();
	menu.AddMenuTitle(GetResString(IDS_LOGENTRY));
	menu.AppendMenu(MF_STRING | (lSelEnd > lSelStart ? MF_ENABLED : MF_GRAYED), MP_COPYSELECTED, GetResString(IDS_COPY));
	menu.AppendMenu(MF_SEPARATOR);
	menu.AppendMenu(MF_STRING | (iTextLen > 0 ? MF_ENABLED : MF_GRAYED), MP_SELECTALL, GetResString(IDS_SELECTALL));
	menu.AppendMenu(MF_STRING | (iTextLen > 0 ? MF_ENABLED : MF_GRAYED), MP_REMOVEALL , GetResString(IDS_PW_RESET));
	menu.AppendMenu(MF_STRING | (iTextLen > 0 ? MF_ENABLED : MF_GRAYED), MP_SAVELOG, GetResString(IDS_SAVELOG) + _T("..."));
	menu.AppendMenu(MF_SEPARATOR);
	menu.AppendMenu(MF_STRING | (m_bAutoScroll ? MF_CHECKED : MF_UNCHECKED), MP_AUTOSCROLL, GetResString(IDS_AUTOSCROLL));

	if (point.x == -1 && point.y == -1)
	{
		point.x = 16;
		point.y = 32;
		ClientToScreen(&point);
	}

	// Cheap workaround for the "Text cursor is showing while context menu is open" glitch. It could be solved properly
	// with the RE's COM interface, but because the according messages are not routed with a unique control ID, it's not
	// really useable (e.g. if there are more RE controls in one window). Would to envelope each RE window to get a unique ID..
	m_bForceArrowCursor = true;
	menu.TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, this);
	m_bForceArrowCursor = false;

	VERIFY( menu.DestroyMenu() );
}
Ejemplo n.º 3
0
void GraphWidget::removeCtrlPt(const int iMouseX, const int iMouseY)
{
	if (m_iCurrCurve >= 0) {
		Point ptMouse(iMouseX, iMouseY);
		Point ptCtrlPt;

		Point ptMouseInCurveCoord = windowToCurve(m_iCurrCurve, ptMouse);
		int iClosestCtrlPt = m_pcrvvCurves[m_iCurrCurve]->getClosestControlPoint(ptMouseInCurveCoord, ptCtrlPt);

		Point ptCtrlPtInWindowCoord = curveToWindow(m_iCurrCurve, ptCtrlPt);

		if (fabs(ptCtrlPtInWindowCoord.x - ptMouse.x) * 2 <= PICK_WINDOW_SIZE &&
			fabs(ptCtrlPtInWindowCoord.y - ptMouse.y) * 2 <= PICK_WINDOW_SIZE) {
			m_pcrvvCurves[m_iCurrCurve]->removeControlPoint(iClosestCtrlPt);
			deselectCtrlPts();
		}
	}
}
Ejemplo n.º 4
0
void GraphWidget::selectCurrCurve(const int iMouseX, const int iMouseY)
{
	Point ptMouse(iMouseX, iMouseY);

	for (int i = 0; i < m_ivActiveCurves.size(); ++i) {
		int iCurve = m_ivActiveCurves[i];
		Point ptMouseInCurveCoord = windowToCurve(iCurve, ptMouse);
		Point ptClosestPt;
		m_pcrvvCurves[iCurve]->getClosestPoint(ptMouseInCurveCoord, ptClosestPt);
		Point ptClosestPtInWindowCoord = curveToWindow(iCurve, ptClosestPt);

		// select this curve if the mouse cursor is close enough
		if (fabs(ptClosestPtInWindowCoord.x - ptMouse.x) * 2 <= PICK_WINDOW_SIZE &&
			fabs(ptClosestPtInWindowCoord.y - ptMouse.y) * 2 <= PICK_WINDOW_SIZE) {
			m_iCurrCurve = iCurve;
			return;
		}
	}
}
Ejemplo n.º 5
0
void GraphWidget::dragCtrlPt(const int iMouseX, const int iMouseY)
{
	if (m_ivActiveCurves.size() > 0) {
		Point ptMouse(iMouseX, iMouseY);
		ptMouse.x = max(0.0f, ptMouse.x); 
		ptMouse.x = min((float)(w() - 1), ptMouse.x);
		ptMouse.y = max(0.0f, ptMouse.y); 
		ptMouse.y = min((float)(h() - 1), ptMouse.y);
		for (int i = 0; i < m_ivActiveCurves.size(); ++i) {
			int iCurve = m_ivActiveCurves[i];

			Point ptMouseInCurveCoord = windowToCurve(iCurve, ptMouse);
			Point ptDragStartInCurveCoord = windowToCurve(iCurve, m_ptDragStart);
			Point ptOffset(ptMouseInCurveCoord.x - ptDragStartInCurveCoord.x,

			ptMouseInCurveCoord.y - ptDragStartInCurveCoord.y);

			m_pcrvvCurves[iCurve]->moveControlPoints(m_ivvCurrCtrlPts[iCurve], ptOffset,
				m_cdvCurveDomains[iCurve].minimum(), m_cdvCurveDomains[iCurve].maximum());
		}

		m_ptDragStart = ptMouse;
	}
}
Ejemplo n.º 6
0
void GraphWidget::selectAddCtrlPt(const int iMouseX, const int iMouseY)
{
	if (m_iCurrCurve >= 0) {
		Point ptMouse(iMouseX, iMouseY);
		Point ptCtrlPt;
		m_ptDragStart = ptMouse;

		// find the closest control point
		Point ptMouseInCurveCoord = windowToCurve(m_iCurrCurve, ptMouse);
		int iClosestCtrlPt = m_pcrvvCurves[m_iCurrCurve]->getClosestControlPoint(ptMouseInCurveCoord, ptCtrlPt);

		Point ptCtrlPtInWindowCoord = curveToWindow(m_iCurrCurve, ptCtrlPt);

		if (fabs(ptCtrlPtInWindowCoord.x - ptMouse.x) * 2 <= PICK_WINDOW_SIZE &&
			fabs(ptCtrlPtInWindowCoord.y - ptMouse.y) * 2 <= PICK_WINDOW_SIZE) {

			if (std::find(m_ivvCurrCtrlPts[m_iCurrCurve].begin(), 
				m_ivvCurrCtrlPts[m_iCurrCurve].end(), 
				iClosestCtrlPt) != m_ivvCurrCtrlPts[m_iCurrCurve].end()) {
				// the point is one of the currently selected points. do nothing
				return;
			}
			else {
				deselectCtrlPts();
				// select the control point
				m_ivvCurrCtrlPts[m_iCurrCurve].push_back(iClosestCtrlPt);
				return;
			}
		}

		// no control point is near the mouse cursor

		// see if it's a currently selected control point 
		for (int i = 0; i < m_ivActiveCurves.size(); ++i) {
			int iCurve = m_ivActiveCurves[i];

			Point ptMouseInCurveCoord = windowToCurve(iCurve, ptMouse);
			int iClosestCtrlPt = m_pcrvvCurves[iCurve]->getClosestControlPoint(ptMouseInCurveCoord, ptCtrlPt);

			Point ptCtrlPtInWindowCoord = curveToWindow(iCurve, ptCtrlPt);

			if (fabs(ptCtrlPtInWindowCoord.x - ptMouse.x) * 2 <= PICK_WINDOW_SIZE &&
				fabs(ptCtrlPtInWindowCoord.y - ptMouse.y) * 2 <= PICK_WINDOW_SIZE) {

				if (std::find(m_ivvCurrCtrlPts[iCurve].begin(), 
					m_ivvCurrCtrlPts[iCurve].end(), 
					iClosestCtrlPt) != m_ivvCurrCtrlPts[iCurve].end()) {
					// the point is one of the currently selected points. do nothing
					return;
				}
			}
		}

		// add a new control point to the current curve
		m_pcrvvCurves[m_iCurrCurve]->addControlPoint(ptMouseInCurveCoord);
		Point ptDummy;
		deselectCtrlPts();
		m_ivvCurrCtrlPts[m_iCurrCurve].push_back(
			m_pcrvvCurves[m_iCurrCurve]->getClosestControlPoint(ptMouseInCurveCoord, ptDummy));
	}
}