Exemple #1
0
void COXMonthCalPopup::AdjustDisplayRectangle(CRect &rect, CRect rectParent)
{
	// Get the rectangle of the monitor closest to the menu rectangle
	HMONITOR hMonitor = ::MonitorFromRect(rect, MONITOR_DEFAULTTONEAREST);
	MONITORINFO mi;
	mi.cbSize = sizeof(MONITORINFO);
	::GetMonitorInfo(hMonitor, &mi);

	const int iMixScreenX = mi.rcMonitor.left;
	const int iMaxScreenX = mi.rcMonitor.right;
	const int iMaxScreenY = mi.rcMonitor.bottom;

	CSize sizeParent(rectParent.Width(), rectParent.Height());
	CPoint ptTopLeft(rect.left, rect.top);

	if (ptTopLeft.x < iMixScreenX)
		ptTopLeft.x = iMixScreenX;
	if (ptTopLeft.x + rect.Width() > iMaxScreenX)
		ptTopLeft.x = iMaxScreenX - rect.Width();

	// Make sure the popup is not clipped at the bottom
	if (rect.bottom > iMaxScreenY)
	{
		// The popup should be above the item
		ptTopLeft.y = rectParent.top - rect.Height();
	}

	CSize sizeTemp = rect.Size();
	rect.SetRect(ptTopLeft.x, ptTopLeft.y,
		ptTopLeft.x + sizeTemp.cx, ptTopLeft.y + sizeTemp.cy);
}
CXTPChartRectF CXTPChartStackedBarSeriesPointView::GetScreenRect() const
{
	CXTPChartStackedBarSeriesView* pSeriesView = (CXTPChartStackedBarSeriesView*)GetSeriesView();
	CXTPChartStackedBarSeriesStyle* pSeriesStyle = STATIC_DOWNCAST(CXTPChartStackedBarSeriesStyle, GetSeriesView()->GetStyle());

	CXTPChartAxisView* pAxisXView = pSeriesView->GetAxisViewX();

	if (pSeriesView->m_nBarIndex != -1)
	{
		int nCount = pSeriesView->m_nBarCount;
		int nIndex = pSeriesView->m_nBarIndex;

		double dOffset = 3 / pAxisXView->GetScale();

		double dBarWidth = (pSeriesStyle->GetBarWidth() - dOffset * (nCount - 1)) / nCount;

		CXTPChartPointF ptTopLeft(pSeriesView->GetScreenPoint(m_pPoint->GetInternalArgumentValue() -
			pSeriesStyle->GetBarWidth() / 2 + dBarWidth * nIndex + dOffset * nIndex, m_dValueTo));

		CXTPChartPointF ptBottomRight(pSeriesView->GetScreenPoint(m_pPoint->GetInternalArgumentValue() -
			pSeriesStyle->GetBarWidth() / 2 + dBarWidth * nIndex + dOffset * nIndex + dBarWidth, m_dValueFrom));

		CXTPChartRectF rc(ptTopLeft, ptBottomRight);
		rc.Width++;
		rc.Height++;

		return rc;
	}

	return CXTPChartRectF(0, 0, 0, 0);
}
CXTPChartRectF CXTPChartRangeBarSeriesPointView::GetScreenRect() const
{
	CXTPChartRangeBarSeriesView* pSeriesView = (CXTPChartRangeBarSeriesView*)GetSeriesView();
	CXTPChartRangeBarSeriesStyle* pSeriesStyle = (CXTPChartRangeBarSeriesStyle*)GetSeriesView()->GetStyle();

	CXTPChartAxisView* pAxisXView = pSeriesView->GetAxisViewX();

	if (pSeriesView->m_nBarIndex != -1)
	{
		int nCount = pSeriesView->m_nBarCount;
		int nIndex = pSeriesView->m_nBarIndex;

		double dOffset = (1 + pSeriesStyle->GetBarDistanceFixed()) / pAxisXView->GetScale();

		double dRangeBarWidth = (pSeriesStyle->GetBarWidth() - dOffset * (nCount - 1)) / nCount;

		CXTPChartPointF ptTopLeft(pSeriesView->GetScreenPoint(m_pPoint->GetInternalArgumentValue() -
			pSeriesStyle->GetBarWidth() / 2 + dRangeBarWidth * nIndex + dOffset * nIndex, m_pPoint->GetValue(0)));

		CXTPChartPointF ptBottomRight(pSeriesView->GetScreenPoint(m_pPoint->GetInternalArgumentValue() -
			pSeriesStyle->GetBarWidth() / 2 + dRangeBarWidth * nIndex + dOffset * nIndex + dRangeBarWidth, m_pPoint->GetValue(1)));

		CXTPChartRectF rc(ptTopLeft, ptBottomRight);
		rc.Width++;
		rc.Height++;

		return rc;
	}

	return CXTPChartRectF(0, 0, 0, 0);
}
Exemple #4
0
RIntPoint RWinColorPalette::CellFromPoint( CPoint pt )
{
	RIntPoint ptTopLeft( (pt.x < kPtLeftCol.m_x ? kPtFirstCol : kPtLeftCol) ) ;
	RIntPoint ptPoint( pt.x - ptTopLeft.m_x, pt.y - ptTopLeft.m_y );

	RIntPoint ptCell;
	ptCell.m_x = ptPoint.m_x / kCellDistance * kCellDistance + ptTopLeft.m_x;
	ptCell.m_y = ptPoint.m_y / kCellDistance * kCellDistance + ptTopLeft.m_y;

	if ((pt.x % kCellDistance > kCellSize.m_dx) ||
		 (pt.y % kCellDistance > kCellSize.m_dy))
	{
		// Point wasn't over a cell
		ptCell.m_x = ptCell.m_y = -1;
	}
	else if ((ptCell.m_x > kPtFirstCol.m_x + kCellSize.m_dx) && (ptCell.m_x < kPtLeftCol.m_x))
	{
		// Point wasn't over a cell
		ptCell.m_x = ptCell.m_y = -1;
	}

	return ptCell;
}
void CXTPChartPyramidSeriesView::CalculatePointLayout(CXTPChartDeviceContext* pDC, CRect rcBounds)
{
	CXTPChartPyramidSeriesStyle* pStyle = STATIC_DOWNCAST(CXTPChartPyramidSeriesStyle, GetStyle());

	rcBounds.DeflateRect(5, 5, 5, 5);


	CXTPChartPyramidSeriesLabel* pLabel = (CXTPChartPyramidSeriesLabel*)pStyle->GetLabel();

	if (pLabel->IsVisible() && !pLabel->IsInside())
	{
		CSize sz(0, 0);
		for (int i = 0; i < m_pPointsView->GetCount(); i++)
		{
			CXTPChartPyramidSeriesPointView* pPointView = (CXTPChartPyramidSeriesPointView*)m_pPointsView->GetAt(i);

			CXTPChartString text(pLabel->GetPointLabel(pPointView->GetPoint()));
			CXTPChartTextPainter painter(pDC, text, pLabel);

			sz.cx = max(sz.cx, (INT)painter.GetSize().Width);
			sz.cy = max(sz.cy, (INT)painter.GetSize().Height);
		}

		int nLineLength = pStyle->GetLabel()->GetLineLength();
		if (pLabel->GetPosition() == xtpChartPyramidLabelRight)
			rcBounds.DeflateRect(0, 0, nLineLength + sz.cx, 0);
		if (pLabel->GetPosition() == xtpChartPyramidLabelLeft)
			rcBounds.DeflateRect(nLineLength + sz.cx, 0, 0, 0);
	}



	double dRatio = pStyle->GetHeightToWidthRatio();
	if (dRatio > CXTPChartMathUtils::m_dEPS)
	{
		int nHeight = rcBounds.Height();
		int nWidth = int(nHeight / dRatio);

		if (nWidth > rcBounds.Width())
		{
			nWidth = rcBounds.Width();
			nHeight = int(nWidth * dRatio);
		}

		CPoint ptTopLeft((rcBounds.left + rcBounds.right - nWidth) / 2, (rcBounds.top + rcBounds.bottom - nHeight) / 2);
		rcBounds = CRect(ptTopLeft, CSize(nWidth, nHeight));
	}


	m_rcInnterBounds = rcBounds;


	CalculateValues();

	int nCount = m_pPointsView->GetCount();

	double dFrom = 0;

	for (int i = 0; i < nCount; i++)
	{
		CXTPChartPyramidSeriesPointView* pPointView = (CXTPChartPyramidSeriesPointView*)m_pPointsView->GetAt(i);

		pPointView->CalculateLayout(i, nCount, dFrom, dFrom + pPointView->m_dValue);
		dFrom += pPointView->m_dValue;
	}
}
Exemple #6
0
void RWinColorPalette::OnKeyDown( UINT nChar, UINT nRepCnt, UINT nFlags )
{
	RIntPoint ptNew( kPtFirstCol );

	if (m_ptSelected.m_x >= 0 && m_ptSelected.m_y >= 0)
	{
		RIntPoint ptTopLeft( (m_ptSelected.m_x < kPtLeftCol.m_x ? kPtFirstCol : kPtLeftCol) ) ;
		RIntPoint ptPoint( m_ptSelected.m_x - ptTopLeft.m_x, m_ptSelected.m_y - ptTopLeft.m_y );

		if (m_ptSelected.m_x >= kPtLeftCol.m_x)
			ptPoint.m_x += kCellDistance;

		int nCurRow = ptPoint.m_y / kCellDistance;
		int nCurCol = ptPoint.m_x / kCellDistance;

		switch (nChar)
		{
		case VK_UP:
			nCurRow -= nRepCnt;
			break;

		case VK_DOWN:
			nCurRow += nRepCnt;
			break;

		case VK_LEFT:
			nCurCol -= nRepCnt;
			break;

		case VK_RIGHT:
			nCurCol += nRepCnt;
			break;
		}

		RBitmapImage& biPalette	= GetPaletteBitmapImage();
		int cxCols = (biPalette.GetWidthInPixels() - 
			kPtLeftCol.m_x) / kCellDistance + 1;  // One is added for first column

		int cxRows = (biPalette.GetHeightInPixels() -
			kPtLeftCol.m_y) / kCellDistance;

		nCurRow %= cxRows;
		nCurCol %= cxCols;

		if (nCurCol < 0) nCurCol += cxCols;
		if (nCurRow < 0) nCurRow += cxRows;

		ptNew.m_x = (nCurCol ? (nCurCol - 1) * kCellDistance + kPtLeftCol.m_x : kPtFirstCol.m_x);
		ptNew.m_y = nCurRow * kCellDistance + kPtLeftCol.m_y;
	}

	CRect rcInvalid( -1, -1, kCellSize.m_dx + 1, kCellSize.m_dy + 1 );
	rcInvalid.OffsetRect( m_ptSelected.m_x, m_ptSelected.m_y );
	InvalidateRect( rcInvalid, FALSE );

	RIntPoint pt( ptNew.m_x + 1, ptNew.m_y + 1 );
	m_crSelected = ColorFromPoint( pt );
	m_ptSelected = ptNew;

	GetParent()->SendMessage( UM_COLOR_CHANGED, GetDlgCtrlID(), (LPARAM) m_crSelected ) ;

	CStatic::OnKeyDown( nChar, nRepCnt, nFlags );
}
Exemple #7
0
// this routine calculates the size and position of the window relative
// to it's anchor point, and moves the window accordingly.  The region is also
// created and set here.
void CBalloonHelp::PositionWindow()
{
	CSize sizeWnd = CalcWindowSize();
	
	CPoint ptTail[3];
	CPoint ptTopLeft(0,0);
	CPoint ptBottomRight(sizeWnd.cx, sizeWnd.cy);
	
	// force recalculation of desktop
	m_screenRect.SetRectEmpty();
	
	switch (GetBalloonQuadrant())
	{
	case BQ_TOPLEFT:
		ptTopLeft.y = nTIP_TAIL;
		ptTail[0].x = (sizeWnd.cx-nTIP_TAIL)/4 + nTIP_TAIL;
		ptTail[0].y = nTIP_TAIL+1;
		ptTail[2].x = (sizeWnd.cx-nTIP_TAIL)/4;
		ptTail[2].y = ptTail[0].y;
		ptTail[1].x = ptTail[2].x;
		ptTail[1].y = 1;
		break;
	case BQ_TOPRIGHT:
		ptTopLeft.y = nTIP_TAIL;
		ptTail[0].x = (sizeWnd.cx-nTIP_TAIL)/4*3;
		ptTail[0].y = nTIP_TAIL+1;
		ptTail[2].x = (sizeWnd.cx-nTIP_TAIL)/4*3 + nTIP_TAIL;
		ptTail[2].y = ptTail[0].y;
		ptTail[1].x = ptTail[2].x;
		ptTail[1].y = 1;
		break;
	case BQ_BOTTOMLEFT:
		ptBottomRight.y = sizeWnd.cy-nTIP_TAIL;
		ptTail[0].x = (sizeWnd.cx-nTIP_TAIL)/4 + nTIP_TAIL;
		ptTail[0].y = sizeWnd.cy-nTIP_TAIL-2;
		ptTail[2].x = (sizeWnd.cx-nTIP_TAIL)/4;
		ptTail[2].y = ptTail[0].y;
		ptTail[1].x = ptTail[2].x;
		ptTail[1].y = sizeWnd.cy-2;
		break;
	case BQ_BOTTOMRIGHT:
		ptBottomRight.y = sizeWnd.cy-nTIP_TAIL;
		ptTail[0].x = (sizeWnd.cx-nTIP_TAIL)/4*3;
		ptTail[0].y = sizeWnd.cy-nTIP_TAIL-2;
		ptTail[2].x = (sizeWnd.cx-nTIP_TAIL)/4*3 + nTIP_TAIL;
		ptTail[2].y = ptTail[0].y;
		ptTail[1].x = ptTail[2].x;
		ptTail[1].y = sizeWnd.cy-2;
		break;
				default:
					ASSERT(FALSE);
	}
	
	// adjust for very narrow balloons
	if ( ptTail[0].x < nTIP_MARGIN )
		ptTail[0].x = nTIP_MARGIN;
	if ( ptTail[0].x > sizeWnd.cx - nTIP_MARGIN )
		ptTail[0].x = sizeWnd.cx - nTIP_MARGIN;
	if ( ptTail[1].x < nTIP_MARGIN )
		ptTail[1].x = nTIP_MARGIN;
	if ( ptTail[1].x > sizeWnd.cx - nTIP_MARGIN )
		ptTail[1].x = sizeWnd.cx - nTIP_MARGIN;
	if ( ptTail[2].x < nTIP_MARGIN )
		ptTail[2].x = nTIP_MARGIN;
	if ( ptTail[2].x > sizeWnd.cx - nTIP_MARGIN )
		ptTail[2].x = sizeWnd.cx - nTIP_MARGIN;
	
	// get window position
	CPoint ptAnchor = GetAnchorPoint();
	CPoint ptOffs(ptAnchor.x - ptTail[1].x, ptAnchor.y - ptTail[1].y);
	
	// adjust position so all is visible
	CRect rectScreen;
	GetAnchorScreenBounds(rectScreen);
	int nAdjustX = 0;
	int nAdjustY = 0;
	if ( ptOffs.x < rectScreen.left )
		nAdjustX = rectScreen.left-ptOffs.x;
	else if ( ptOffs.x + sizeWnd.cx >= rectScreen.right )
		nAdjustX = rectScreen.right - (ptOffs.x + sizeWnd.cx);
	if ( ptOffs.y + nTIP_TAIL < rectScreen.top )
		nAdjustY = rectScreen.top - (ptOffs.y + nTIP_TAIL);
	else if ( ptOffs.y + sizeWnd.cy - nTIP_TAIL >= rectScreen.bottom )
		nAdjustY = rectScreen.bottom - (ptOffs.y + sizeWnd.cy - nTIP_TAIL);
	
	// reposition tail
	// uncomment two commented lines below to move entire tail 
	// instead of just anchor point
	
	//ptTail[0].x -= nAdjustX;
	ptTail[1].x -= nAdjustX;
	//ptTail[2].x -= nAdjustX;
	ptOffs.x    += nAdjustX;
	ptOffs.y    += nAdjustY;
	
	// place window
	MoveWindow(ptOffs.x, ptOffs.y, sizeWnd.cx, sizeWnd.cy, TRUE);
	
	// apply region
	CRgn region;
	CRgn regionRound;
	CRgn regionComplete;
	region.CreatePolygonRgn(&ptTail[0], 3, ALTERNATE);
	regionRound.CreateRoundRectRgn(ptTopLeft.x,ptTopLeft.y,ptBottomRight.x,ptBottomRight.y,nTIP_MARGIN*3,nTIP_MARGIN*3);
	regionComplete.CreateRectRgn(0,0,1,1);
	regionComplete.CombineRgn(&region, &regionRound, RGN_OR);
	
	if ( NULL == m_rgnComplete.m_hObject )
		m_rgnComplete.CreateRectRgn(0,0,1,1);
	
	if ( !m_rgnComplete.EqualRgn(&regionComplete) )
	{
		m_rgnComplete.CopyRgn(&regionComplete);
		SetWindowRgn((HRGN)regionComplete.Detach(), TRUE);
		
		// There is a bug with layered windows and NC changes in Win2k
		// As a workaround, redraw the entire window if the NC area changed.
		// Changing the anchor point is the ONLY thing that will change the
		// position of the client area relative to the window during normal
		// operation.
		RedrawWindow(NULL, NULL, RDW_UPDATENOW| RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN);
	}
}
Exemple #8
0
static void test_CPoint()
{
    CPoint empty;

    ok(empty.x == 0, "Expected x to be 0, was %ld\n", empty.x);
    ok(empty.y == 0, "Expected y to be 0, was %ld\n", empty.y);

    CPoint ptTopLeft(0, 0);
    POINT ptHere;
    ptHere.x = 35;
    ptHere.y = 95;

    CPoint ptMFCHere(ptHere);

    SIZE sHowBig;
    sHowBig.cx = 300;
    sHowBig.cy = 10;

    CPoint ptMFCBig(sHowBig);
    DWORD dwSize;
    dwSize = MAKELONG(35, 95);

    CPoint ptFromDouble(dwSize);
    ok_point(ptFromDouble, ptMFCHere);

    CPoint ptStart(100, 100);
    ptStart.Offset(35, 35);

    CPoint ptResult(135, 135);
    ok_point(ptStart, ptResult);

    ptStart = CPoint(100, 100);
    POINT pt;

    pt.x = 35;
    pt.y = 35;

    ptStart.Offset(pt);
    ok_point(ptStart, ptResult);

    ptStart = CPoint(100, 100);
    SIZE size;

    size.cx = 35;
    size.cy = 35;

    ptStart.Offset(size);
    ok_point(ptStart, ptResult);

    CPoint ptFirst(256, 128);
    CPoint ptTest(256, 128);
    ok_point(ptFirst, ptTest);

    pt.x = 256;
    pt.y = 128;
    ok_point(ptTest, pt);

    ptTest = CPoint(111, 333);
    nok_point(ptFirst, ptTest);

    pt.x = 333;
    pt.y = 111;
    nok_point(ptTest, pt);

    ptStart = CPoint(100, 100);
    CSize szOffset(35, 35);

    ptStart += szOffset;

    ok_point(ptResult, ptStart);

    ptStart = CPoint(100, 100);

    ptStart += size;
    ok_point(ptResult, ptStart);

    ptStart = CPoint(100, 100);

    ptStart -= szOffset;

    ptResult = CPoint(65, 65);
    ok_point(ptResult, ptStart);


    ptStart = CPoint(100, 100);

    ptStart -= size;
    ok_point(ptResult, ptStart);

    ptStart = CPoint(100, 100);
    CPoint ptEnd;

    ptEnd = ptStart + szOffset;

    ptResult = CPoint(135, 135);
    ok_point(ptResult, ptEnd);

    ptEnd = ptStart + size;
    ok_point(ptResult, ptEnd);

    ptEnd = ptStart + pt;
    ptResult = CPoint(433, 211);
    ok_point(ptResult, ptEnd);

    ptEnd = ptStart - szOffset;
    ptResult = CPoint(65, 65);
    ok_point(ptResult, ptEnd);

    ptEnd = ptStart - size;
    ok_point(ptResult, ptEnd);

    szOffset = ptStart - pt;
    CSize expected(-233, -11);
    ok_size(szOffset, expected);

    ptStart += pt;
    ptResult = CPoint(433, 211);
    ok_point(ptResult, ptStart);

    ptStart -= pt;
    ptResult = CPoint(100, 100);
    ok_point(ptResult, ptStart);

    ptTest = CPoint(35, 35);
    ptTest = -ptTest;

    CPoint ptNeg(-35, -35);
    ok_point(ptTest, ptNeg);

    RECT rc = { 1, 2, 3, 4 };

    CRect rcres = ptStart + &rc;
    CRect rcexp(101, 102, 103, 104);
    ok_rect(rcexp, rcres);

    rcres = ptStart - &rc;
    rcexp = CRect(-99, -98, -97, -96);
    ok_rect(rcexp, rcres);
}