Exemple #1
1
void CZoominTool::OnLButtonUp(_CVIEW* pView, UINT nFlags, CPoint& point)
{
	CDC* pDC = NULL;
	pDC = pView->m_pDC;
	if (pDC == NULL) return;

	CRect newRect(c_PtDown,point);
	CPen Pen;
	if (!Pen.CreatePen(PS_SOLID, 1, RGB(0,0,0)))
	return;
	CPen *pOldPen = pDC->SelectObject(&Pen);
	int oldDrawMode = pDC->SetROP2(R2_NOT);
	pDC->SelectStockObject(NULL_BRUSH);
	pDC->Rectangle(newRect);
	pDC->SetROP2(oldDrawMode);
	pDC->SelectObject(pOldPen);
	Pen.DeleteObject();

	int cx = abs(point.x - c_PtDown.x);
	int cy = abs(point.y - c_PtDown.y);
	if (cx<5 && cy<5)
	{
		pView->m_Graphics.ZoomAtPoint(&c_PtDown,1.2);			
		pView->Refresh();
	}
	else
	{
		pView->m_Graphics.ZoomInAtExtent(&c_PtDown,&point);
		pView->Refresh();
	}
	CDrawTool::OnLButtonUp(pView, nFlags, point);
}
Exemple #2
1
void CZoominTool::OnMouseMove(_CVIEW* pView, UINT nFlags, CPoint& point)
{
	::SetCursor(AfxGetApp()->LoadCursor(IDC_ZOOMIN));
	CDC* pDC = NULL;
	pDC = pView->GetDC();
	if (pDC == NULL) return;
	if (!c_bDown)
	{
		DeleteDC(pDC->m_hDC);
		return;
	}

	CRect oldRect(c_PtDown,c_PtOld);
	CRect newRect(c_PtDown,point);
	//CRect TrackRect;
	//	TrackRect.SetRect(m_StartPoint,point);
	CPen Pen;
	if (!Pen.CreatePen(PS_SOLID, 1, RGB(0,0,0)))
	return;
	CPen *pOldPen = pDC->SelectObject(&Pen);
	//int oldDrawMode = m_pDC->SetROP2(R2_XORPEN);
	int oldDrawMode = pDC->SetROP2(R2_NOT);
	pDC->SelectStockObject(NULL_BRUSH);
	pDC->Rectangle(oldRect);
	pDC->Rectangle(newRect);
	pDC->SetROP2(oldDrawMode);
	pDC->SelectObject(pOldPen);
	Pen.DeleteObject();
	DeleteDC(pDC->m_hDC);
	CDrawTool::OnMouseMove(pView, nFlags, point);
}
void CMyMainWnd::OnPaint()
{
	CPaintDC myDC(this);
	CPen myPen;
	CRect myRect;
	CFont myFont;

	CString TypeFace;
	
	switch (r) 
	{
	case 1: myPen.CreatePen(PS_SOLID, 10, RGB(255, 0, 0)); myDC.SelectObject(myPen); myDC.Ellipse(10, 10, 100, 100); break;
	case 2: myPen.CreatePen(PS_SOLID, 20, RGB(172, 189, 16)); myDC.SelectObject(myPen); myDC.Ellipse(10, 10, 200, 150); break;
	case 3: myPen.CreatePen(PS_SOLID, 30, RGB(122, 124, 221)); myDC.SelectObject(myPen); myDC.Rectangle(10, 10, 300, 100); break;
	case 4: myPen.CreatePen(PS_SOLID, 40, RGB(100, 16, 147)); myDC.SelectObject(myPen); myDC.Rectangle(10, 10, 200, 200); break;
	case 5: myPen.CreatePen(PS_SOLID, 10, RGB(50, 150, 250)); myDC.SelectObject(myPen); myDC.LineTo(50, 50); myDC.LineTo(75, 0); myDC.LineTo(0,0); break;
	case 0: myPen.CreatePen(PS_SOLID, 6, RGB(62, 106, 110)); myDC.SelectObject(myPen); myDC.Rectangle(0,0,0,0); break;
	}
	switch (i)
	{
	case 1: myDC.SetTextColor(RGB(255, 0, 0)); TypeFace = "Arial"; myFont.CreateFont(20, 0, 0, 0, FW_BOLD, FALSE, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, DEFAULT_PITCH | FF_DONTCARE, TypeFace); myDC.SelectObject(myFont); myDC.TextOut(50, 50, L"Text 1");  break;
	case 2: myDC.SetTextColor(RGB(172, 189, 16)); TypeFace = "Calibri"; myFont.CreateFont(20, 0, 0, 0, FW_BOLD, FALSE, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, DEFAULT_PITCH | FF_DONTCARE, TypeFace); myDC.SelectObject(myFont); myDC.TextOut(100, 100, L"Text 2"); break;
	case 3: myDC.SetTextColor(RGB(122, 124, 221)); TypeFace = "Courier"; myFont.CreateFont(20, 0, 0, 0, FW_BOLD, FALSE, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, DEFAULT_PITCH | FF_DONTCARE, TypeFace); myDC.SelectObject(myFont); myDC.TextOut(150, 150, L"Text 3"); break;
	case 4: myDC.SetTextColor(RGB(100, 16, 147)); TypeFace = "Cambria"; myFont.CreateFont(20, 0, 0, 0, FW_BOLD, FALSE, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, DEFAULT_PITCH | FF_DONTCARE, TypeFace); myDC.SelectObject(myFont); myDC.TextOut(200, 200, L"Text 4"); break;
	case 5: myDC.SetTextColor(RGB(81, 83, 85)); TypeFace = "Segoe Print"; myFont.CreateFont(20, 0, 0, 0, FW_BOLD, FALSE, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, DEFAULT_PITCH | FF_DONTCARE, TypeFace); myDC.SelectObject(myFont); myDC.TextOut(250, 250, L"Text 5"); break;
	}
}
Exemple #4
0
void KTgaButton::OnPaint()
{
	CButton::OnPaint();

	if (m_bIsSelected)
	{
		CRect rect;
		GetClientRect(&rect);
		rect.left  += 2;
		rect.right -= 2;
		rect.top += 2;
		rect.bottom -= 2;
		CClientDC dc(this);
		//dc.FillRect(&rect, &CBrush(RGB(200,0,0)));

		CPen pen;

        if(m_byTexCoordIndex == 0)
		    pen.CreatePen(PS_SOLID, 2, RGB(255, 0, 0));
        else if(m_byTexCoordIndex == 1)
            pen.CreatePen(PS_SOLID, 2, RGB(0, 255, 0));
        else
            pen.CreatePen(PS_SOLID, 2, RGB(0, 0, 255));

		dc.SelectObject(&pen);

		dc.MoveTo(rect.left - 1, rect.top);
		dc.LineTo(rect.right, rect.top);
		dc.LineTo(rect.right, rect.bottom);
		dc.LineTo(rect.left, rect.bottom);
		dc.LineTo(rect.left, rect.top);

		UpdateData(false);
	}
}
void UICircle::Draw(CDC* ip_pdc)
  {

  HDC handle = ip_pdc->GetSafeHdc();
  CPen pen;
  if (m_is_selected)
    pen.CreatePen(PS_DASH, 1, m_circle_color);
  else
    pen.CreatePen(PS_SOLID, 1, m_circle_color);

  CBrush solid_brush;
  if (m_is_brush_defined && m_circle_brush != NULL_BRUSH)
    {
    solid_brush.CreateSolidBrush(m_circle_brush);
    ip_pdc->SelectObject(&solid_brush);
    }
  else
    {
    SelectObject(handle, GetStockObject(NULL_BRUSH));
    }

  ip_pdc->SelectObject(&pen);
  ip_pdc->SetDCPenColor(m_circle_color);

  double radius = mp_circle->GetRadius();

  double x_1 = mp_circle->GetFirstPoint().GetX() - radius;
  double y_1 = mp_circle->GetFirstPoint().GetY() + radius;

  double x_2 = mp_circle->GetFirstPoint().GetX() + radius;
  double y_2 = mp_circle->GetFirstPoint().GetY() - radius;

  ip_pdc->Ellipse((int)x_1, (int)y_1, (int)x_2, (int)y_2);
  }
Exemple #6
0
/* 画棋子 */
void Chess::DrawChess(CDC *pDC)
{
    CBrush *brush;
    COLORREF color;
    CPen pen;
    int a, b;

    a = x - SIZE / 2;
    b = y - SIZE / 2;

    /* 选择颜色 */
    if (this->color == WHITE)	/* 白色 */
    {
        color = RGB(255, 255, 255);
        pen.CreatePen(PS_SOLID, 1, color);
    }
    else	/* 黑色 */
    {
        color = RGB(0, 0, 0);
        pen.CreatePen(PS_SOLID, 1, color);
    }

    brush = new CBrush(color);	/* 笔的属性 */
    pDC->SelectObject(brush);			/* 使用这支笔 */
    pDC->SelectObject(&pen);
    pDC->Ellipse(a, b, a + size, b + size);	/* 画圆 */
    brush->DeleteObject();
    pen.DeleteObject();
}
void DlgPalette::DrawCell(CDC *pDC, long index)
{
	CRect rect;
	if (!GetCellRect(index, rect)) return;

	CBrush brush;
	
	if (m_editalpha){
		brush.CreateSolidBrush(RGB(m_pal[index].rgbReserved,
					 m_pal[index].rgbReserved ,
					 m_pal[index].rgbReserved ));
	}else{
		brush.CreateSolidBrush(RGB(m_pal[index].rgbRed ,
					 m_pal[index].rgbGreen ,
					 m_pal[index].rgbBlue ));
	}

	CPen   pen;
	if (index==m_selected)
		pen.CreatePen(PS_SOLID, 2, ::GetSysColor(COLOR_3DDKSHADOW));
	else
		pen.CreatePen(PS_SOLID, 1, ::GetSysColor(COLOR_3DSHADOW));

	CBrush* pOldBrush = (CBrush*) pDC->SelectObject(&brush);
	CPen*   pOldPen   = (CPen*)   pDC->SelectObject(&pen);

	// Draw the cell colour
	pDC->Rectangle(rect);

	// restore DC and cleanup
	pDC->SelectObject(pOldBrush);
	pDC->SelectObject(pOldPen);
	brush.DeleteObject();
	pen.DeleteObject();
}
Exemple #8
0
void CSatelliteView::OnDraw(CDC* pDC)
{
	CSatelliteDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	CRect rectClient;
	GetClientRect(&rectClient);
	double x,y;
	x=(rectClient.right-rectClient.left)/2;
	y=(rectClient.bottom-rectClient.top)/2;
    pDC->SelectStockObject(NULL_BRUSH);
	CPen newPen;
	CPen newPenx;
	CPen newPen_satellite;
	newPen.CreatePen(PS_SOLID,pDoc->m_widthDoc,pDoc->m_orbitColor);
	newPen_satellite.CreatePen(PS_SOLID,2,pDoc->m_satelliteColor);
	newPenx.CreatePen(PS_SOLID,pDoc->m_widthDocx,pDoc->m_orbitColor);
    CPen *poldPen;
	poldPen=pDC->SelectObject(&newPen);
	pDC->Ellipse(x-pDoc->m_radiiDoc,y-pDoc->m_radiiDoc,x+pDoc->m_radiiDoc,y+pDoc->m_radiiDoc);
	poldPen=pDC->SelectObject(&newPenx);
	pDC->Ellipse(x-pDoc->m_radiiDocx,y-pDoc->m_radiiDocx,x+pDoc->m_radiiDocx,y+pDoc->m_radiiDocx);
	poldPen=pDC->SelectObject(&newPen_satellite);
	pDC->Ellipse(x+pDoc->m_radiiDoc*cos(pDoc->m_angle)-15,y+pDoc->m_radiiDoc*sin(pDoc->m_angle)-15,x+pDoc->m_radiiDoc*cos(pDoc->m_angle)+15,y+pDoc->m_radiiDoc*sin(pDoc->m_angle)+15);
	pDC->Ellipse(x+pDoc->m_radiiDocx*cos(pDoc->m_angle)-15,y+pDoc->m_radiiDocx*sin(pDoc->m_angle)-15,x+pDoc->m_radiiDocx*cos(pDoc->m_angle)+15,y+pDoc->m_radiiDocx*sin(pDoc->m_angle)+15);
	// TODO: add draw code for native data here
}
Exemple #9
0
void CRichListCtrl::DrawRowBK(CDC *pDC, RECT rc, bool bSelected, bool bFocus,int nRow)  
{   
    bool bOdd = (nRow % 2 == 0 ? true : false);  
    CRect rect = rc;  
    if (rect.Width() == 0)  
    {  
        return;  
    }  
       
    int nSave = pDC->SaveDC();  
    if (bSelected)  
    {  
        if (bFocus)  
        {  
            CBrush selectBrush;  
            selectBrush.CreateSolidBrush(RGB(203, 223, 239));  
            pDC->FillRect(&rc, &selectBrush);  
        }  
        else  
        {  
            CBrush selectNoFocusBrush;  
            selectNoFocusBrush.CreateSolidBrush(RGB(206, 206, 206));  
            pDC->FillRect(&rc, &selectNoFocusBrush);  
        }  
    }  
    else if (bOdd)  
    {  
        CBrush oddBrush;  
        oddBrush.CreateSolidBrush(RGB(255, 255, 255));  
        pDC->FillRect(&rc, &oddBrush);  
    }  
    else  
    {  
        CBrush normalBrush;  
        normalBrush.CreateSolidBrush(RGB(243, 243, 243));  
        pDC->FillRect(&rc, &normalBrush);  
    }  
  
    // 画竖线  
    CPen pen;  
    pen.CreatePen(PS_SOLID, 1, RGB(218, 218, 218));  
    pDC->SelectObject(&pen);  
    pDC->MoveTo(rc.right - 1, rc.top);  
    pDC->LineTo(rc.right - 1, rc.bottom);  
	pDC->MoveTo(rc.left, rc.bottom - 1);  
	pDC->LineTo(rc.right, rc.bottom - 1);  

    // 画选中的底部分割线  
    if (bSelected)  
    {  
        CPen bottomPen;  
        bottomPen.CreatePen(PS_SOLID, 1, RGB(255, 255, 255));  
        pDC->SelectObject(&bottomPen);  
        pDC->MoveTo(rc.left, rc.bottom - 1);  
        pDC->LineTo(rc.right, rc.bottom - 1);  
    }  
    pDC->RestoreDC(nSave);  
}  
// 画网格图
void CGraphInstrumentList::DrawGrid(CDC* pDC, int iPaperX, int iPaperY, int iGridX, int iGridY)
{

	COLORREF oldBkColor = m_oPaperColor;

	CRect rect;
	rect.left = 0;
	rect.top = 0;
	rect.right = iPaperX;
	rect.bottom = iPaperY;

	// Center lines
	CPen penDash;
	penDash.CreatePen(PS_DASH, 0, m_oGridColor);
	CPen* pOldPen = pDC->SelectObject(&penDash);

	pDC->MoveTo(0, rect.top);
	pDC->LineTo(0, rect.bottom);
	pDC->MoveTo(rect.left, 0);
	pDC->LineTo(rect.right, 0);

	// Major unit lines
	CPen penDot;
	penDot.CreatePen(PS_DOT, 0, m_oGridColor);
	pDC->SelectObject(&penDot);

	for (int x = 0; x < rect.right; x += iGridX)
	{
		if (x != 0)
		{
			pDC->MoveTo(x, rect.top);
			pDC->LineTo(x, rect.bottom);
		}
	}

	for (int y = 0; y < rect.bottom; y += iGridY)
	{
		if (y != 0)
		{
			pDC->MoveTo(rect.left, y);
			pDC->LineTo(rect.right, y);
		}
	}

	// Outlines
	CPen penSolid;
	penSolid.CreatePen(PS_SOLID, 0, m_oGridColor);
	pDC->SelectObject(&penSolid);
	pDC->MoveTo(rect.left, rect.top);
	pDC->LineTo(rect.right, rect.top);
	pDC->LineTo(rect.right, rect.bottom);
	pDC->LineTo(rect.left, rect.bottom);
	pDC->LineTo(rect.left, rect.top);

	pDC->SelectObject(pOldPen);
	pDC->SetBkColor(oldBkColor);
}
Exemple #11
0
//********************************************************************************
void CHeaderView::DrawArrow(CGDI* pDC,CRect rc,BOOL bUp)
{
	CPen cp;
	CPen cps;
	CPen cpw;

	cp.CreatePen(PS_SOLID,1, m_clrFace);
	cps.CreatePen(PS_SOLID,1, m_clrShadow);
	cpw.CreatePen(PS_SOLID,1, m_clrLight);
	HPEN hPen;
	(void)hPen;
	rc.left=rc.right-12;
	rc.right=rc.left+8;
	rc.bottom=rc.top+12;
	rc.top+=2;	
	int m_mitad=rc.left+4;
	
	if (bUp == TRUE)
	{
			//linea izquierda
			hPen=pDC->SelectObject(&cps);
			pDC->MoveTo(rc.left,rc.bottom);
			pDC->LineTo(m_mitad,rc.top);
			//linea derecha
			pDC->SelectObject(&cpw);
			pDC->MoveTo(rc.right,rc.bottom);
			pDC->LineTo(m_mitad,rc.top);
			//linea de abajo
			pDC->MoveTo(rc.left,rc.bottom);
			pDC->LineTo(rc.right,rc.bottom);
	}
	else
	{
			rc.bottom=rc.top+12;
			rc.top+=4;	
			//linea izquierda
			hPen=pDC->SelectObject(&cps);
			pDC->MoveTo(rc.left,rc.top);
			pDC->LineTo(m_mitad,rc.bottom);
			//linea superior
			pDC->MoveTo(rc.left,rc.top);
			pDC->LineTo(rc.right,rc.top);
			//linea derecha
				pDC->SelectObject(&cpw);
			pDC->MoveTo(rc.right,rc.top);
			pDC->LineTo(m_mitad,rc.bottom);

	}

	cp.DeleteObject();
	cps.DeleteObject();
	cpw.DeleteObject();
	//pDC->SelectObject(pOld);
}
Exemple #12
0
void CChartLineSerie::Draw(CDC* pDC)
{
    if (!m_bIsVisible)
        return;

    // If shadow is enabled, the all series must be redrawn.
    if (m_bShadow)
    {
        DrawAll(pDC);
        return;
    }

    if (pDC->GetSafeHdc())
    {
        CPen NewPen;
        if (m_iPenStyle != PS_SOLID)
        {
            LOGBRUSH lb;
            lb.lbStyle = BS_SOLID;
            lb.lbColor = m_ObjectColor;
            NewPen.CreatePen(PS_GEOMETRIC | m_iPenStyle, m_iLineWidth, &lb);
        }
        else
        {
            NewPen.CreatePen(m_iPenStyle, m_iLineWidth, m_ObjectColor);
        }
        CPen* pOldPen;

        pDC->SetBkMode(TRANSPARENT);
        //To have lines limited in the drawing rectangle :
        pDC->IntersectClipRect(m_ObjectRect);
        pOldPen = pDC->SelectObject(&NewPen);

        //Draw all points that haven't been drawn yet
        for (m_iLastDrawnPoint;m_iLastDrawnPoint<(int)GetPointsCount()-1;m_iLastDrawnPoint++)
        {
            //We don't draw a line between the origin and the first point -> we must have
            // a least 2 points before begining drawing
        //  if (m_vPoints<1)
        //      break;

            CPoint ScreenPoint;
            ValueToScreen(m_vPoints[m_iLastDrawnPoint].X,m_vPoints[m_iLastDrawnPoint].Y,ScreenPoint);
            pDC->MoveTo(ScreenPoint.x,ScreenPoint.y);

            ValueToScreen(m_vPoints[m_iLastDrawnPoint+1].X,m_vPoints[m_iLastDrawnPoint+1].Y,ScreenPoint);
            pDC->LineTo(ScreenPoint.x,ScreenPoint.y);
        }

        pDC->SelectClipRgn(NULL);
        pDC->SelectObject(pOldPen);
        DeleteObject(NewPen);
    }
}
void CChartLineSerie::Draw(CDC* pDC)
{
	if (!m_bIsVisible)
		return;

	// If shadow or smooth is enabled, then the complete series
	// must be redrawn.
	if (m_bShadow || m_bSmooth)
	{
		DrawAll(pDC);
		return;
	}

	if (pDC->GetSafeHdc())
	{
		CPen NewPen;
		if (m_iPenStyle != PS_SOLID)
		{
			LOGBRUSH lb;
			lb.lbStyle = BS_SOLID;
			lb.lbColor = m_SerieColor;
			NewPen.CreatePen(PS_GEOMETRIC | m_iPenStyle, m_iLineWidth, &lb);
		}
		else
		{
			NewPen.CreatePen(m_iPenStyle, m_iLineWidth, m_SerieColor);
		}
		CPen* pOldPen;

		pDC->SetBkMode(TRANSPARENT);
		//To have lines limited in the drawing rectangle :
		pDC->IntersectClipRect(m_pParentCtrl->GetPlottingRect());
		pOldPen = pDC->SelectObject(&NewPen);

		//Draw all points that haven't been drawn yet
		for (m_uLastDrawnPoint;m_uLastDrawnPoint<GetPointsCount()-1;m_uLastDrawnPoint++)
		{
			SChartXYPoint Point = GetPoint(m_uLastDrawnPoint);
			CPoint ScreenPoint;
			ValueToScreen(Point.X, Point.Y, ScreenPoint);
			pDC->MoveTo(ScreenPoint.x,ScreenPoint.y);

			Point = GetPoint(m_uLastDrawnPoint+1);
			ValueToScreen(Point.X, Point.Y, ScreenPoint);
			pDC->LineTo(ScreenPoint.x,ScreenPoint.y);
		}

		pDC->SelectClipRgn(NULL);
		pDC->SelectObject(pOldPen);
		DeleteObject(NewPen);
	}
}
void CReportEntityLine::Draw( CDC* dc, CRect rect )
/* ============================================================
	Function :		CReportEntityLine::Draw
	Description :	Draws the object.
	Access :		Public

	Return :		void
	Parameters :	CDC* dc		-	"CDC" to draw to
					CRect rect	-	True (zoomed) rectangle to 
									draw to.
					
	Usage :			Called from "CDiagramEditor::DrawObjects".

   ============================================================*/
{
	CPen pen;
	const float* table = Drawer::GetColorByIndex(GetBorderColor());
	COLORREF clr = RGB((int)(table[0]*255.0f),(int)(table[1]*255.0f),(int)(table[2]*255.0f));
	pen.CreatePen( PS_SOLID, GetBorderThickness(), clr );
	dc->SelectObject( &pen );

	dc->MoveTo( rect.TopLeft() );
	dc->LineTo( rect.BottomRight() );

	dc->SelectStockObject( BLACK_PEN );

}
Exemple #15
0
/// <param name="rect">bounding rectangle</param>
/// <param name="fore">foreground text color</param>
/// <param name="back">background color</param>
/// <param name="font">font including face, point size, and style.</param>
/// <param name="text">text string to display in the designated font.</param>
/// <param name="cursor">cursor reticle.</param>
void Canvas::DrawEditString(const rect_t &rect, const rect_t &box, color_t fore, color_t back, const Font& font, align_t align, const string_t &text, size_t cursor)
{
	RECT rc = {0};
	privateDrawString(box, fore, back, font, align, text);
	if (cursor == 0)
	{
		_dc.DrawText(_T("A"), 1, &rc, DT_CALCRECT|DT_SINGLELINE);
		rc.right = rc.left;
	}
	else
		_dc.DrawText(&text[0], cursor, &rc, DT_CALCRECT|DT_SINGLELINE);
	// zero height?
	if (rc.top == rc.bottom)
		rc.bottom = box.high; // yes: zap for cursor bar.

	// draw cursor
	CPen pen;
	pen.CreatePen(PS_SOLID, 1, fore);
	_dc.SelectPen(pen);
	// TODO: code to clip line segments.
	_dc.MoveTo(rc.right, rc.top);
	_dc.LineTo(rc.right, rc.bottom);

	BitBlt(rect.x, rect.y, rect.wide, rect.high, _dc, box.x, box.y, SRCCOPY);
}
Exemple #16
0
//畫圈
void MsrFlow::DrawACircle(CPoint point)
{
    /*
    	在此畫出來的圈是以160*160大小
    	以中心點為參考點畫出來的
    	原函數是以左上角為參考點,在此修正誤差,將決定好的參考點
    	再往左往上各算一個半徑的距離,畫出來

    */
    //設定圈圈顏色=與背景相反顏色
    COLORREF CircleColor;
    CircleColor = RGB(255,255,255)-BackGroundColor;
    //設定畫圈目標物位址
    CWnd* pWndGrid = GetDlgItem(IDC_COLOR_PATTERN);
    CDC* pDC = pWndGrid->GetDC();
    //設定畫筆
    CPen aPen;
    aPen.CreatePen(PS_INSIDEFRAME,5,CircleColor);
    //設定暫存畫筆空間
    CPen* pOldPen = pDC ->SelectObject(&aPen);
    //對圓修正誤差,從左上調到中心(開方形可繪區塊)
    CPoint StartDrawPoint(-80,-80);
    CPoint EndDrawPoint(80,80);
    CRect* pRect = new CRect(point+StartDrawPoint,point+EndDrawPoint);
    //畫下去(畫下圓形,起點0,0,終點0,0)
    CPoint Start(0,0);
    CPoint End(0,0);
    pDC->Arc(pRect,Start,End);
    //畫筆換回預設值
    pDC->SelectObject(pOldPen);
}
Exemple #17
0
void CGroup1::Draw9(CDC* pDC, CSize& ScreenSize,
					int CameraX, int CameraY, // position on camera
					long x, long y, // position on screen
					long lFactorX, long lFactorY, long CameraFactor,
					COLORREF Pix, COLORREF PrevPix, DWORD)
{
	long Diff = Pix - PrevPix;
	long R = GetRValue(Diff);
	long G = GetGValue(Diff);
	long B = GetBValue(Diff);
	COLORREF CurrColor = SelectColor(R, G, B);
	
	long lastX = min(x+lFactorX, ScreenSize.cx);
	long lastY = min(y+lFactorY, ScreenSize.cy);
	
	CRect r(x, y, lastX, lastY);
	CBrush b(RGB(0,0,0));
	CPen pen;
	pen.CreatePen(PS_SOLID, 1, CurrColor);
	CPen* pOld = pDC->SelectObject(&pen);
	CBrush* pOldB = pDC->SelectObject(&b);
	
	pDC->MoveTo(R*3,G);
	pDC->LineTo(CameraX*3, B*3);
	
	b.DeleteObject();
	pen.DeleteObject();
	pDC->SelectObject(pOld);
	pDC->SelectObject(pOldB);
}
void CBorderStyleEdit::DrawEditFrame( CDC* pDC )
{	
	CRect rcItem;
	GetClientRect( &rcItem );

	if( m_bNowEditing )
		pDC->SetTextColor( m_dwActiveTextColor );
	else
		pDC->SetTextColor( m_dwTextColor );

	pDC->SetBkColor( m_dwBgColor );

	if( m_bShowBorder )
	{
		DWORD dwBorderColor = m_dwBorderColor;
		if( m_bWarning )
		{
			dwBorderColor = (m_bBlink == TRUE ? RGB(255, 0, 0) : m_dwBorderColor);
		}

		rcItem.InflateRect( 1, 1, 1, 1 );
		CBrush* pOldBrush = (CBrush*)pDC->SelectStockObject( NULL_BRUSH );
		CPen BorderPen;
		BorderPen.CreatePen( PS_SOLID, m_nBorderWidth, dwBorderColor );
		CPen* pOldPen = pDC->SelectObject( &BorderPen );

		//pDC->Rectangle( rcItem );

		pDC->SelectObject( pOldPen );
		pDC->SelectObject( pOldBrush );
	}
}
Exemple #19
0
BOOL CStroke::DrawStrokeIn( CDC* pDC, int nRestricWidth, int nRestricHeight )
{
	CPen penStroke;
	if( !penStroke.CreatePen(PS_SOLID, m_nPenWidth, m_rgbPenColor))
		return FALSE;

	CPen* pOldPen = pDC->SelectObject( &penStroke );

	CPoint prev = m_pointArray[0];

	pDC->MoveTo( m_pointArray[0] );
	for( int i=1; i < m_pointArray.GetSize(); i++ )
	{
		if (m_pointArray[i].x>nRestricWidth || m_pointArray[i].y > nRestricHeight)
		{
			prev = m_pointArray[i];
			continue;
		}

		if (prev.x>nRestricWidth || prev.y > nRestricHeight)
		{
			pDC->MoveTo(m_pointArray[i]);
		}
		pDC->LineTo( m_pointArray[i] );
		prev = m_pointArray[i];
	}
	pDC->SelectObject( pOldPen );
	return TRUE;
}
Exemple #20
0
void CThumbnail::OnPaint() 
{
	PAINTSTRUCT paintstruct;
	CDC* pDC;
	pDC=BeginPaint(&paintstruct);
	paintstruct.fErase=TRUE;
	CRect rect;
	GetClientRect(rect);
	// first draw scaled version of thumbnail underneath title bar
	CRButton* button;
	button=GETDLGITEM(IDJ_TITLE);
	CRect buttonrect;
	button->GetClientRect(buttonrect);
	rect.top+=buttonrect.bottom;
	// +1 prevents gaps
	int halfheight=rect.Height()/2+1;
	int offset=rect.Height()/8+1;
	int offset2=rect.Height()/16+1;
	DrawScaledBitmap(pDC,FIL_THUMBTOP,rect.left,rect.top-offset,rect.Width(),halfheight+offset2);
	DrawScaledBitmap(pDC,FIL_THUMBBOT,rect.left,rect.top+halfheight-offset2,rect.Width(),halfheight+offset2);
	// now draw the box in the appropriate position
	CRect rect2;
	m_pView->GetClientRect(rect2);
	m_boxSize=CSize((rect.right*rect2.right)/m_pView->m_size.cx,
					(rect.Height()*rect2.bottom)/m_pView->m_size.cy);
	if(m_LButtonDown==FALSE)
	{
		m_point=CPoint(((m_pView->m_scrollpoint.x*rect.right)/m_pView->m_size.cx)+(m_boxSize.cx/2),
					   ((m_pView->m_scrollpoint.y*rect.Height())/m_pView->m_size.cy)+(m_boxSize.cy/2)+rect.top);
		m_point=m_point+offsetfix;			//quick thumbnail fix
	}
	m_point.x=max(m_boxSize.cx/2,m_point.x);
	m_point.y=max((m_boxSize.cy/2)+rect.top,m_point.y);
	m_point.x=min(rect.right-(m_boxSize.cx/2),m_point.x);
	m_point.y=min(rect.bottom-(m_boxSize.cy/2),m_point.y);
	CPen pen;
	pen.CreatePen(PS_SOLID,2,RGB(255,0,0)); // red pen
	pDC->SelectObject(&pen);

	if (m_boxSize.cx<20) 
	{
		pDC->MoveTo(m_point.x-10,m_point.y);
		pDC->LineTo(m_point.x-m_boxSize.cx/2,m_point.y);
		pDC->MoveTo(m_point.x+10,m_point.y);
		pDC->LineTo(m_point.x+m_boxSize.cx/2,m_point.y);
	}
	if (m_boxSize.cy<20)
	{
		pDC->MoveTo(m_point.x,m_point.y-10);
		pDC->LineTo(m_point.x,m_point.y-m_boxSize.cy/2);
		pDC->MoveTo(m_point.x,m_point.y+10);
		pDC->LineTo(m_point.x,m_point.y+m_boxSize.cy/2);
	}
	pDC->MoveTo(m_point.x-(m_boxSize.cx/2),m_point.y-(m_boxSize.cy/2));
	pDC->LineTo(m_point.x+(m_boxSize.cx/2),m_point.y-(m_boxSize.cy/2));
	pDC->LineTo(m_point.x+(m_boxSize.cx/2),m_point.y+(m_boxSize.cy/2));
	pDC->LineTo(m_point.x-(m_boxSize.cx/2),m_point.y+(m_boxSize.cy/2));
	pDC->LineTo(m_point.x-(m_boxSize.cx/2),m_point.y-(m_boxSize.cy/2));
	EndPaint(&paintstruct);
}
void QuoteTableCtrlGeneralSort::OnDraw(CDC* pDC)
{
	CHSGridCtrl::OnDraw(pDC);

	CRect rect, itemrect, rccvlient;
	GetClientRect(rccvlient);
	ClientToScreen(rccvlient);
	GetClientRect(rect);
	itemrect = rect;
	if (GetRowCount() <=0)
		return;

	int rowheight = GetRowHeight(0);
	itemrect.bottom = rowheight-1;
	
	COLORREF bkcolor = GetBkColor();
	COLORREF textcolor = RGB(155,155,155);
	if (m_iColorFontProt)
		textcolor = m_iColorFontProt->GetQuoteTabTextColor();
	CFont* pFont;
	CFont* pOldFont;
	BOOL bCreat = FALSE;
	if (m_iFont)
		pFont = (CFont*)m_iFont->GetQuoteColHeadFont();
	else
	{
		pFont = new CFont();
		VERIFY(pFont->CreateFont(16,0, 0,0,FW_NORMAL,FALSE,FALSE,0,ANSI_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,ANTIALIASED_QUALITY,
			DEFAULT_PITCH | FF_SWISS, _T("宋体")));
		bCreat = TRUE;
	}

	pOldFont = pDC->SelectObject(pFont);

	
	pDC->SetBkColor( GetSysColor(COLOR_HIGHLIGHT) );
	pDC->SetBkColor(bkcolor);
	pDC->SetTextColor(textcolor);

	pDC->SetBkColor(bkcolor);
	pDC->DrawText(m_pTableFlag->strTitle, &itemrect, DT_CENTER | DT_SINGLELINE | DT_NOPREFIX | DT_VCENTER);

	pDC->SelectObject(pOldFont);
	if (bCreat)
		pFont->DeleteObject();

	
	
	CPen hPen;
	hPen.CreatePen(PS_SOLID ,1,RGB(200,0,0));
	CPen* hOldPen = pDC->SelectObject(&hPen);

	pDC->MoveTo(CPoint(itemrect.left,itemrect.bottom));
	pDC->LineTo(CPoint(itemrect.right, itemrect.bottom));

	pDC->SelectObject(hOldPen);
	hPen.DeleteObject();

	
}
Exemple #22
0
/// <param name="list">list of points</param>
/// <param name="count">number of points</param>
/// <param name="width">pen width for drawing line</param>
/// <param name="color">pen color</param>
/// <param name="fill">polygon fill color</param>
void Canvas::DrawPolygon(const rect_t &rect, const rect_t &box, point_t list[], size_t count, meter_t width, color_t color, color_t fill)
{
	CPen pen;
	CBrush brush;
	std::vector<POINT> pts;
	POINT pt = {0};

	for (size_t i = 0; i < count; i++)
	{
		pt.x = list[i].x - box.x + rect.x;
		pt.y = list[i].y - box.y + rect.y;
		pts.push_back(pt);
	}
	CRgn region;
	region.CreateRectRgn(rect.x, rect.y, rect.x + rect.wide, rect.y + rect.high);
	SelectClipRgn(region);

	brush.CreateSolidBrush(fill);
	pen.CreatePen(PS_SOLID, width, color);
	HPEN hSavePen = SelectPen(pen);
	HBRUSH hSaveBrush = SelectBrush(brush);
	Polygon(&pts[0], pts.size());

	SelectPen(hSavePen);
	SelectBrush(hSaveBrush);
	SelectClipRgn(NULL);
}
//-----  OnSizeParent()  ------------------------------------------------------
void BCTabBarCtrl::OnNcPaint() 
{
	CRect rectCLient, rectNC;
	GetWindowRect(rectNC);
	
	rectNC.OffsetRect(-rectNC.left, -rectNC.top);
	
	CWindowDC dc(this);
	CPen pen;
	
	DWORD dwSysGray = GetSysColor(COLOR_BTNFACE);
	
	dc.DrawEdge(rectNC, EDGE_ETCHED, BF_TOP);
	
	rectNC.DeflateRect(0, 2, 0, 0);
	
	CBrush brush(dwSysGray);
	dc.FrameRect(rectNC, &brush);
	
	for(int iIndx = 0; iIndx < 2; iIndx++)
	{
		rectNC.DeflateRect(1, 1, 1, 1);
		dc.FrameRect(rectNC, &brush);
	}
	
	rectNC.DeflateRect(0, 1, 0, 2);
	pen.DeleteObject();
	
	pen.CreatePen(PS_GEOMETRIC | PS_SOLID, 1, dwSysGray);
	dc.SelectObject(&pen);
	
	dc.MoveTo(rectNC.left, rectNC.top);
	dc.LineTo(rectNC.right, rectNC.top);
}
LRESULT PeersToolbarSearchPrompt::onPaint(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) {
  CPaintDC dc(m_hWnd);
  CRect r;
  GetClientRect(r);
  CBrush brush;
  brush.CreateSolidBrush(m_backgroundColor);
  dc.FillRect(r, brush);
  CPen pen;
  pen.CreatePen(PS_SOLID, 1, RGB(132,0,0));
  const HPEN oldPen = dc.SelectPen(pen);
  dc.MoveTo(r.left, r.top + 5);
  dc.LineTo(r.left, r.bottom - 5);
  dc.SelectPen(oldPen);
  const int len = GetWindowTextLength();
  if (len > 0) {
    r.left += m_leftPadding + 1;
    AutoArray<TCHAR> caption(len + 1);
    GetWindowText(caption, len + 1);
    const HFONT oldFont = dc.SelectFont(WinUtil::boldFont);
    dc.SetBkMode(TRANSPARENT);
    dc.SetTextColor(RGB(255,255,255));
    dc.DrawText(caption, len, r, DT_SINGLELINE | DT_VCENTER);
    dc.SelectFont(oldFont);
  }
  return 0;
}
Exemple #25
0
void CHeadCtrol::PaintDragLine(int pos, bool bOne ) //ÍÏקÏßÌõ
{
	CDC* pDC = CWnd::FromHandle(m_hListWnd)->GetWindowDC();
	int nRop = pDC->SetROP2(R2_NOTXORPEN);
	CRect lrect;
	CWnd::FromHandle(m_hListWnd)->GetClientRect( &lrect );

	CPen  pen;
	pen.CreatePen(0, 1, RGB(0, 0, 0));
	CPen *pOP = pDC->SelectObject(&pen);



	if( posPre != -1  ) 
	{
		pDC->MoveTo( posPre,0 );
		pDC->LineTo( posPre,lrect.bottom );
	}

	if(  !bOne  ) 
	{
		pDC->MoveTo( pos,0 );
		pDC->LineTo( pos,lrect.bottom );
	}


	pDC->SetROP2(nRop);
	pDC->SelectObject(pOP);
	pen.DeleteObject();

	ReleaseDC(pDC);

	posPre = pos;
}
void KGClassButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
	CClientDC dc(this);
	COLORREF color;
	CRect rect;
	CPen  pen;

	GetClientRect(&rect);
	dc.FillRect(&rect, &CBrush(RGB(255, 255, 255)));
	if (m_nStateFlag)
	{
		color = RGB(255, 2, 2);
	}
	else
	{
		color = RGB(100, 100, 100);
	}

	pen.CreatePen(PS_SOLID, 2, color);
	dc.SelectObject(&pen);

	if (m_hButtonIcon)
	{
		dc.DrawIcon(rect.left, rect.top, m_hButtonIcon);
	}

	if (m_nSelFlag)
	{
		dc.MoveTo(rect.left, rect.top);
		dc.LineTo(rect.right, rect.top);
		dc.LineTo(rect.right, rect.bottom);
		dc.LineTo(rect.left, rect.bottom);
		dc.LineTo(rect.left, rect.top - 2);
	}
}
void CSplitterControl::DrawLine(CDC* pDC, int x, int y)
{
	int nRop = pDC->SetROP2(R2_NOTXORPEN);

	CRect rcWnd;
	int d = 1;
	GetWindowRect(rcWnd);
	CPen  pen;
	pen.CreatePen(0, 1, RGB(200, 200, 200));
	CPen *pOP = pDC->SelectObject(&pen);
	
	if (m_nType == SPS_VERTICAL)
	{
		pDC->MoveTo(m_nX - d, rcWnd.top);
		pDC->LineTo(m_nX - d, rcWnd.bottom);

		pDC->MoveTo(m_nX + d, rcWnd.top);
		pDC->LineTo(m_nX + d, rcWnd.bottom);
	}
	else // m_nType == SPS_HORIZONTAL
	{
		pDC->MoveTo(rcWnd.left, m_nY - d);
		pDC->LineTo(rcWnd.right, m_nY - d);
		
		pDC->MoveTo(rcWnd.left, m_nY + d);
		pDC->LineTo(rcWnd.right, m_nY + d);
	}
	pDC->SetROP2(nRop);
	pDC->SelectObject(pOP);
}
Exemple #28
0
// Draw a curve
void CCurve::Draw(CDC* pDC, CElement* pElement)
{
	// Create a pen for this object and
	// initialize it to the object color and line width of m_PenWidth
	CPen aPen;
	
	if(!aPen.CreatePen(m_LineStyle, m_PenWidth, this==pElement ? SELECT_COLOR : m_Color))
	{
		// Pen creation failed
		AfxMessageBox(_T("Pen creation failed drawing a curve"), MB_OK);
		AfxAbort();
	}
	
	// Select the pen
	CPen* pOldPen = pDC->SelectObject(& aPen);

	// Now draw the curve
	//pDC->MoveTo(m_Points[0]);
	pDC->MoveTo(m_APoints[0]);

	/*
	for(size_t i=1; i<m_Points.size(); ++i)
	{
		pDC->LineTo(m_Points[i]);
	}
	*/
	for(int i=1; i<m_APoints.GetSize(); ++i)
	{
		pDC->LineTo(m_APoints[i]);
	}

	pDC->SelectObject(pOldPen); // Restore the old pen
}
Exemple #29
0
// Draw a circle
void CEllipse::Draw(CDC* pDC, CElement* pElement)
{
	
	// Create a pen for this object and
	// initialize it to the object color and line width of m_PenWidth
	CPen aPen;
	
	if(!aPen.CreatePen(m_LineStyle, m_PenWidth, this==pElement ? SELECT_COLOR : m_Color))
	{
		// Pen creation failed
		AfxMessageBox(_T("Pen creation failed drawing a circle"), MB_OK);
		AfxAbort();
	}
	
	// Select the pen
	CPen* pOldPen = pDC->SelectObject(& aPen); 
	
	// Select a null brush
	CBrush* pOldBrush = (CBrush*)pDC->SelectStockObject(NULL_BRUSH);
	
	// Now draw the circle
	pDC->Ellipse(m_EnclosingRect);
	pDC->SelectObject(pOldPen); // Restore the old pen
	pDC->SelectObject(pOldBrush); // Restore the old brush

}
Exemple #30
0
void CTEditCtrlWnd::OnPaint() 

{
	CPaintDC dc(this);
	
	CString strWindow, strCurreny;
	CRect	rcClient;
	
	GetClientRect(rcClient);

	dc.FillSolidRect(rcClient, m_clrFace);
	dc.SetBkMode(TRANSPARENT);
	/*dc.Draw3dRect(rcClient, m_clrBottomRight, m_clrTopLeft);*/
	CPen pen;
	pen.CreatePen(PS_SOLID, 1, RGB(200, 200, 200));
	CPen* pOldPen = (CPen*)dc.SelectObject(&pen);
	dc.Rectangle(rcClient);
	dc.SelectObject(pOldPen);
	pen.DeleteObject();
	
	
	rcClient.DeflateRect(2, 2, 2, 2);
	GetWindowText(strWindow);
	strCurreny = GetCurrencyText(strWindow);
	strCurreny = strWindow;
	
	CFont *pOldFont = dc.SelectObject(&m_fontDefault);
	dc.DrawText(strCurreny, rcClient, DT_VCENTER | DT_SINGLELINE | DT_RIGHT);
	dc.SelectObject(pOldFont);
}