//
// Intercept WM_SETCURSOR to change the mouse cursor.
//
BOOL CChartViewer::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) 
{
	if (m_isOnPlotArea)
	{
		switch (m_mouseUsage)
		{
		case Chart::MouseUsageZoomIn:
			if (canZoomIn(m_zoomDirection))
				::SetCursor(getZoomInCursor());
			else
				::SetCursor(getNoZoomCursor());
			return TRUE;
		case Chart::MouseUsageZoomOut:
			if (canZoomOut(m_zoomDirection))
				::SetCursor(getZoomOutCursor());
			else
				::SetCursor(getNoZoomCursor());
			return TRUE;
		}
	}

	if (m_isClickable)
    {
		// Hand cursor = IDC_HAND = 32649
		HCURSOR h = AfxGetApp()->LoadStandardCursor(MAKEINTRESOURCE(32649));
		if (NULL != h)
			::SetCursor(h);
		return TRUE;
    }

	return CStatic::OnSetCursor(pWnd, nHitTest, message);
}
Exemple #2
0
void ImageWidget::emitZoomStateChanged()
{
	emit canZoomInChanged(canZoomIn());
	emit canZoomOutChanged(canZoomOut());
	emit magnificationChanged(m_magnification);
	emit autoImageResizeChanged(m_flagAutoImageResize);
}
Exemple #3
0
void ImageWidget::zoomIn()
{
	if (canZoomIn()) {
		setAutoImageResize(false);
		zoom(m_magnification * 2.);
	}
}
//
// Mouse left button up event.
//
void CChartViewer::OnLButtonUp(UINT nFlags, CPoint point) 
{
	mouse_state=true;
	if (m_isPlotAreaMouseDown)
	{
		// Release the mouse capture.
		ReleaseCapture();
		m_isPlotAreaMouseDown = false;
		setRectVisible(false);
		bool hasUpdate = false;

		switch (m_mouseUsage)
		{
		case Chart::MouseUsageZoomIn :
			if (canZoomIn(m_zoomDirection))
			{
				if (isDrag(m_zoomDirection, point))
					// Zoom to the drag selection rectangle.
					hasUpdate = zoomTo(m_zoomDirection, 
						m_plotAreaMouseDownXPos, m_plotAreaMouseDownYPos, point.x, point.y);
				else
					// User just click on a point. Zoom-in around the mouse cursor position.
					hasUpdate = zoomAt(m_zoomDirection, point.x, point.y, m_zoomInRatio);
			}
			break;
		case Chart::MouseUsageZoomOut:
			// Zoom out around the mouse cursor position.
			if (canZoomOut(m_zoomDirection))
				hasUpdate = zoomAt(m_zoomDirection, point.x, point.y, m_zoomOutRatio);
			break;
		default :
			if (m_isDragScrolling)
				// Drag to scroll. We can update the image map now as scrolling has finished.
				updateViewPort(false, true);
			else
				// Is not zooming or scrolling, so is just a normal click event.
				GetParent()->SendMessage(WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(), BN_CLICKED), (LPARAM)m_hWnd);
			break;
		}

		m_isDragScrolling = false;
		if (hasUpdate)
			// View port has changed - update it.
			updateViewPort(true, true);
	}
	
	CStatic::OnLButtonUp(nFlags, point);
}
//
// Process mouse dragging over the plot area
//
void CChartViewer::OnPlotAreaMouseDrag(UINT /* nFlags */, CPoint point)
{
	switch (m_mouseUsage)
	{
		case Chart::MouseUsageZoomIn :
		{
			//
			// Mouse is used for zoom in. Draw the selection rectangle if necessary.
			//

			bool isDragZoom = canZoomIn(m_zoomDirection) && isDrag(m_zoomDirection, point);
			if (isDragZoom)
			{
				int spanX = m_plotAreaMouseDownXPos - point.x;
				int spanY = m_plotAreaMouseDownYPos - point.y;

				switch (m_zoomDirection)
				{
				case Chart::DirectionHorizontal:
					drawRect(point.x, getPlotAreaTop(), spanX, getPlotAreaHeight());
					break;
				case Chart::DirectionVertical:
					drawRect(getPlotAreaLeft(), point.y, getPlotAreaWidth(), spanY);
					break;
				default:
					drawRect(point.x, point.y, spanX, spanY);
					break;
				}
			}
			setRectVisible(isDragZoom);
			break;
		}
		case Chart::MouseUsageScroll :
		{
			//
			// Mouse is used for drag scrolling. Scroll and update the view port.
			//

			if (m_isDragScrolling || isDrag(m_scrollDirection, point))
			{
				m_isDragScrolling = true;
				switch (m_scrollDirection)
				{
				case Chart::DirectionHorizontal:
					::SetCursor(getNoMoveHorizCursor());
					break;
				case Chart::DirectionVertical:
					::SetCursor(getNoMoveVertCursor());
					break;
				default :
					::SetCursor(getNoMove2DCursor());
					break;
				}
								
				if (dragTo(m_scrollDirection, 
					point.x - m_plotAreaMouseDownXPos, point.y - m_plotAreaMouseDownYPos))
					updateViewPort(true, false);
			}
		}
	}
}
bool DisplayOptions::zoomIn()
{
	if ( !canZoomIn() ) return false;
	_magnification = allowedMagnifications[ closestIndex() + 1 ];
	return true;
}
Exemple #7
0
void ItemView::updateZoomActions() {
	action("view_zoom_in")->setEnabled(canZoomIn());
	action("view_zoom_out")->setEnabled(canZoomOut());
	action("view_actual_size")->setEnabled(m_zoomLevel != 1.0);
}