Exemplo n.º 1
0
///////////////////////////////////////////////////////////////////////////////////////////////
// left mouse button handlers
void PixRasterBaseCtrl::LeftDown(Point p, dword keyflags)
{
	// translates mouse coordinate in page and page coordinates
	int page;
	Point pagePt;
	if(!PointToPage(p, page, pagePt))
	   return;
	   
	// found a page on point, scan it to get the marker on it (if any)

	// gets the PixRaster object
	PixBase *pixBase = pixRasterCtrl->GetPixBase();

	int minDist = ScaleToPage(5);
	Markers *markers = pixBase->GetMarkersEx(page);
	for(int i = 0; i < markers->GetCount(); i++)
	{
		Marker &marker = (*markers)[i];
		int index;
		Marker::HitKind hitKind = marker.Hit(pagePt, minDist, index);
		if(hitKind == Marker::Miss)
			continue;
		
		// found a marker on cursor -- start drag op
		dragPolygon = PointsToView(page, marker.DragOutline(pagePt, pagePt, minDist));
		selectedMarker = &marker;
		dragPoint = pagePt;
		dragPage = page;
	}
	
	
} // END PixRasterBaseCtrl::LeftDown()
Exemplo n.º 2
0
void PixRasterBaseCtrl::MouseMove(Point p, dword keyflags)
{
	Point endDragPoint;
	int endDragPage;
	
	if(!pixRasterCtrl || !pixRasterCtrl->GetPixBase())
		return;
	
	// check what we're dragging....
	if(keyflags & K_MOUSEMIDDLE)
	{
		// moves with middle button pressed -- panning image
		
		// gets distance between current and pan point
		int dx = panPoint.x - p.x + panHScroll;
		int dy = panPoint.y - p.y + panVScroll;
	
		// gets max scrolling values	
		int hMax = hScrollBar.GetTotal();
		int vMax = vScrollBar.GetTotal();
		
		// sets new pan position
		if(dx < 0) dx = 0;
		if(dx > hMax) dx = hMax;
		if(dy < 0) dy = 0;
		if(dy > vMax) dy = vMax;
		hScrollBar.Set(dx);
		vScrollBar.Set(dy);
	
		Refresh();
	}
	else if((keyflags & K_MOUSELEFT) && selectedMarker)
	{
		// dragging a marker
		
		int minDist = ScaleToPage(5);
		PointToPage(p, endDragPage, endDragPoint);

		if(endDragPage == dragPage)
			dragPolygon = PointsToView(dragPage, selectedMarker->DragOutline(dragPoint, endDragPoint, minDist));
		else
			dragPolygon.Clear();
		pixRasterCtrl->Refresh();
	}
	else
	{
		// nothing else, just highlight marker under cursor
		// and set the appropriate cursor
		int page;
		Point pagePt;
		int minDist = ScaleToPage(5);
		Marker *newMarker = NULL;
		if(PointToPage(p, page, pagePt))
		{
			PixBase *pixBase = pixRasterCtrl->GetPixBase();
			Markers *markers = pixBase->GetMarkersEx(page);
			for(int iMarker = 0; iMarker < markers->GetCount(); iMarker++)
			{
				Marker &marker = (*markers)[iMarker];
				int index;
				if(marker.Hit(pagePt, minDist, index) != Marker::Miss)
				{
					newMarker = &marker;
					break;
				}
			}
		}
		if(highlightMarker != newMarker)
		{
			highlightMarker = newMarker;
			pixRasterCtrl->Refresh();
		}
	}
	
} // END PixRasterBaseCtrl::MouseMove()