⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 zcr14paintview.cpp

📁 一个画笔的程序,可以进行直线,圆和方形等图形进行画图,并可以撤消上一步的动作
💻 CPP
📖 第 1 页 / 共 2 页
字号:
		case RECT:
			{
				switch(GetRectType()) 
				{
				case RECT_HOLLOW:
					pRect->SetTypeCanvas(0,GetCanvasColor());
					break;
				case RECT_SOLID:
					pRect->SetTypeCanvas(1,GetCanvasColor());
					break;
				case RECT_REGULAR:
					pRect->SetTypeCanvas(2,GetCanvasColor());
					break;
		
				}
                pRect->Draw(pDC);
				pRect->SetPenWidthColor(GetPenWith(),GetPainColor());
				pRect->SetPoint(m_ptStart,m_ptEnd);
                pRect->Draw(pDC);
				//pDoc->m_lstShape.AddTail(pRect);
				break;
			}
		case ELLIPSE:
			{
				switch(GetRectType()) 
				{
				case RECT_HOLLOW:
					pEllipse->SetTypeCanvas(0,GetCanvasColor());
					break;
				case RECT_SOLID:
					pEllipse->SetTypeCanvas(1,GetCanvasColor());
					break;
				case RECT_REGULAR:
					pEllipse->SetTypeCanvas(2,GetCanvasColor());
					break;
					//		default:
				}
                pEllipse->Draw(pDC);
				pEllipse->SetPenWidthColor(GetPenWith(),GetPainColor());
				pEllipse->SetPoint(m_ptStart,m_ptEnd);
                pEllipse->Draw(pDC);
			//	pDoc->m_lstShape.AddTail(pEllipse);
				break;
			}

		
		}
		pDoc->SetStateModified();
	    ReleaseDC(pDC);
        //Invalidate();
	}



					
	CView::OnMouseMove(nFlags, point);
}

void CZCR14PaintView::OnUpdateButtonRect(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
		pCmdUI->SetCheck(m_emPaintType==RECT);
}

void CZCR14PaintView::OnButtonRect() 
{
	// TODO: Add your command handler code here
		m_emPaintType = RECT;
	    SetSelBox(SEL_RECTTYPE);
}

void CZCR14PaintView::OnUpdateButtonEllipse(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	pCmdUI->SetCheck(m_emPaintType==ELLIPSE);
}

void CZCR14PaintView::OnButtonEllipse() 
{
	// TODO: Add your command handler code here
	m_emPaintType=ELLIPSE;
	SetSelBox(SEL_RECTTYPE);
}

void CZCR14PaintView::OnButtonRoundRect() 
{
	// TODO: Add your command handler code here
	m_emPaintType=ROUND_RECT;
	SetSelBox(SEL_RECTTYPE);
}

void CZCR14PaintView::OnUpdateButtonRoundRect(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	pCmdUI->SetCheck(m_emPaintType==ROUND_RECT);
}

void CZCR14PaintView::OnButtonPolygon() 
{
	// TODO: Add your command handler code here
	m_emPaintType=POLYGON;
	SetSelBox(SEL_RECTTYPE);
}

void CZCR14PaintView::OnUpdateButtonPolygon(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	pCmdUI->SetCheck(m_emPaintType==POLYGON);
}

void CZCR14PaintView::OnButtonCurve() 
{
	// TODO: Add your command handler code here
	m_emPaintType=CURVE;
	SetSelBox(SEL_RECTTYPE);
}

void CZCR14PaintView::OnUpdateButtonCurve(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	pCmdUI->SetCheck(m_emPaintType==CURVE);
}

void CZCR14PaintView::OnButtonText() 
{
	// TODO: Add your command handler code here
	m_emPaintType=TEXT;
	SetSelBox(SEL_NONE);
}

void CZCR14PaintView::OnUpdateButtonText(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	pCmdUI->SetCheck(m_emPaintType==TEXT);
}

void CZCR14PaintView::OnButtonIrregSel() 
{
	// TODO: Add your command handler code here
	m_emPaintType=IRREG_SEL;
	SetSelBox(SEL_NONE);
}

void CZCR14PaintView::OnUpdateButtonIrregSel(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	pCmdUI->SetCheck(m_emPaintType==IRREG_SEL);
}

void CZCR14PaintView::OnButtonRectSel() 
{
	// TODO: Add your command handler code here
	m_emPaintType=RECT_SEL;
	SetSelBox(SEL_NONE);
}

void CZCR14PaintView::OnUpdateButtonRectSel(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	pCmdUI->SetCheck(m_emPaintType==RECT_SEL);
}

void CZCR14PaintView::OnButtonEraser() 
{
	// TODO: Add your command handler code here
	m_emPaintType=ERASER;
	SetSelBox(SEL_NONE);
}

void CZCR14PaintView::OnUpdateButtonEraser(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	pCmdUI->SetCheck(m_emPaintType==ERASER);
}

void CZCR14PaintView::OnButtonFill() 
{
	// TODO: Add your command handler code here
		m_emPaintType = FILL;
	    SetSelBox(SEL_NONE);
}

void CZCR14PaintView::OnUpdateButtonFill(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
		pCmdUI->SetCheck(m_emPaintType==FILL);
}

void CZCR14PaintView::OnButtonSelcolor() 
{
	// TODO: Add your command handler code here
		m_emPaintType=SEL_COLOR;
	    SetSelBox(SEL_NONE);
}

void CZCR14PaintView::OnUpdateButtonSelcolor(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
		pCmdUI->SetCheck(m_emPaintType==SEL_COLOR);
}

void CZCR14PaintView::OnButtonMagnify() 
{
	// TODO: Add your command handler code here
		m_emPaintType=MAGNIFY;
	    SetSelBox(SEL_NONE);	
}

void CZCR14PaintView::OnUpdateButtonMagnify(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	pCmdUI->SetCheck(m_emPaintType==MAGNIFY);
}

void CZCR14PaintView::OnButtonPen() 
{
	// TODO: Add your command handler code here
		m_emPaintType=PEN;
	    SetSelBox(SEL_NONE);
}

void CZCR14PaintView::OnUpdateButtonPen(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
		pCmdUI->SetCheck(m_emPaintType==PEN);
}

void CZCR14PaintView::OnButtonBrush() 
{
	// TODO: Add your command handler code here
		m_emPaintType=BRUSH;
	    SetSelBox(SEL_NONE);
}

void CZCR14PaintView::OnUpdateButtonBrush(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	pCmdUI->SetCheck(m_emPaintType==BRUSH);
}

void CZCR14PaintView::OnButtonAirbrush() 
{
	// TODO: Add your command handler code here
		m_emPaintType=AIRBRUSH;
	    SetSelBox(SEL_NONE);
}

void CZCR14PaintView::OnUpdateButtonAirbrush(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
		pCmdUI->SetCheck(m_emPaintType==AIRBRUSH);
}

int CZCR14PaintView::GetPenWith()
{
	CMainFrame* pFrame = (CMainFrame*)AfxGetMainWnd();
	if ( pFrame )
		return pFrame->GetPenWith();
	else
		return 1;

}

COLORREF CZCR14PaintView::GetPainColor()
{
	CMainFrame* pFrame = (CMainFrame*)AfxGetMainWnd();
	if ( pFrame )
		return pFrame->m_clrPaint;
	else
		return RGB(0,0,0);
}



COLORREF CZCR14PaintView::GetCanvasColor()
{
	CMainFrame* pFrame = (CMainFrame*)AfxGetMainWnd();
	if ( pFrame )
		return pFrame->m_clrCanvas;
	else
		return RGB(255,255,255);
}



void CZCR14PaintView::Rectangle(CDC *pDC, CPoint ptUpperLeft, CPoint ptLowerLeft, BOOL bXorROP)
{
	CPen pen;
	if ( !bXorROP )
		pen.CreateStockObject(WHITE_PEN);
	else
		pen.CreatePen(PS_SOLID, GetPenWith(), GetPainColor());
	CPen* pOldPen = (CPen*)pDC->SelectObject(&pen);
	
	CBrush brush;
	if ( bXorROP )
		brush.CreateSolidBrush(GetCanvasColor());
	else
	{
		brush.CreateStockObject(NULL_BRUSH);
		pDC->SetROP2(R2_XORPEN);
	}
	
	CBrush* pOldBrush = (CBrush*)pDC->SelectObject(&brush);
	
	pDC->Rectangle(ptUpperLeft.x,ptUpperLeft.y,ptLowerLeft.x,ptLowerLeft.y);
	
	pDC->SelectObject(pOldBrush);
	pDC->SelectObject(pOldPen);
}

void CZCR14PaintView::XorLine(CPoint pt1, CPoint pt2)
{
	CDC *pDC = GetDC();
	CPen pen;
	pen.CreateStockObject(WHITE_PEN);
	CPen* pOldPen = (CPen*)pDC->SelectObject(&pen);
	pDC->SetROP2(R2_XORPEN);
	
	pDC->MoveTo(pt1);
	pDC->LineTo(pt2);	
	
	pDC->SelectObject(pOldPen);
	
	ReleaseDC(pDC);
}



int CZCR14PaintView::GetRectType()
{
	CMainFrame* pFrame = (CMainFrame*)AfxGetMainWnd();
	if ( pFrame )
		return pFrame->GetRectType();
	else
		return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -