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

📄 llview.cpp

📁 windows核心编程,详细讲述WINDOWS编程原理
💻 CPP
📖 第 1 页 / 共 2 页
字号:
	{
	case DRAW_LINE:
    m_pShape=new CLine;
	break;
	case DRAW_ERASER:
    m_pShape=new CEraser;
	break;
	case DRAW_RECTANGLE:
    m_pShape=new CRectangle;
	break;
	case DRAW_ELLIPSE:
    m_pShape=new CEllipse;
	break;
	case DRAW_CIRCLE:
    m_pShape=new CCircle;
	break;
	case DRAW_SQUARE:
    m_pShape=new CSquare;
	break;
	case DRAW_RANDOM:
    m_pShape=new CRandom;
	break;
	}
		}

	CView::OnLButtonDown(nFlags, point);
}

void CLlView::OnEllipse() 
{
	// TODO: Add your command handler code here
m_euDraw_Type=DRAW_ELLIPSE;	
}

void CLlView::OnRectangle() 
{
	// TODO: Add your command handler code here
    m_euDraw_Type=DRAW_RECTANGLE;	
}

/*void CLlView::OnRandom() 
{
	// TODO: Add your command handler code here
	m_euDraw_Type=DRAW_RANDOM;
}*/

void CLlView::OnSquare() 
{
	// TODO: Add your command handler code here
	m_euDraw_Type=DRAW_SQUARE;
}

void CLlView::OnCircle() 
{
	// TODO: Add your command handler code here
	m_euDraw_Type=DRAW_CIRCLE;
}

void CLlView::OnRandom() 
{
	// TODO: Add your command handler code here
	m_euDraw_Type=DRAW_RANDOM;

}

void CLlView::OnDash() 
{
	// TODO: Add your command handler code here
	m_nLinetype=PS_DASH;
}

void CLlView::OnDashdot() 
{
	// TODO: Add your command handler code here
	m_nLinetype=PS_DASHDOT;		
}

void CLlView::OnSolid() 
{
	// TODO: Add your command handler code here
	m_nLinetype=PS_SOLID;
}

void CLlView::OnPenwidth1() 
{
	// TODO: Add your command handler code here
	m_nPenwidth=1;
}

void CLlView::OnPenwidth2() 
{
	// TODO: Add your command handler code here
  m_nPenwidth=3;	
}

void CLlView::OnPenwidth3() 
{
	// TODO: Add your command handler code here
	m_nPenwidth=6;
}

void CLlView::OnPenwidth4() 
{
	// TODO: Add your command handler code here
    m_nPenwidth=8;	
}

void CLlView::OnBrushcolor() 
{
	// TODO: Add your command handler code here
	CColorDialog dlg;
	if(dlg.DoModal()==IDOK)
		m_Brushcolor=dlg.GetColor();
}

void CLlView::OnPencolor() 
{
	// TODO: Add your command handler code here
	CColorDialog  dlg;
	if(dlg.DoModal()==IDOK)
	m_Pencolor = dlg.GetColor();
}

void CLlView::OnUpdateDash(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	pCmdUI->SetCheck(m_nLinetype==PS_DASH);
}

void CLlView::OnUpdateDashdot(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
pCmdUI->SetCheck(m_nLinetype==PS_DASHDOT);	
}

void CLlView::OnUpdateSolid(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
pCmdUI->SetCheck(m_nLinetype==PS_SOLID);	
}

void CLlView::OnUpdatePenwidth1(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	pCmdUI->SetCheck(m_nPenwidth==1);
}

void CLlView::OnUpdatePenwidth2(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	pCmdUI->SetCheck(m_nPenwidth==3);
}

void CLlView::OnUpdatePenwidth3(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	pCmdUI->SetCheck(m_nPenwidth==6);
}

void CLlView::OnUpdatePenwidth4(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
pCmdUI->SetCheck(m_nPenwidth==8);	
}





void CLlView::OnEraser() 
{
	// TODO: Add your command handler code here
m_euDraw_Type=DRAW_ERASER;	
}

void CLlView::OnBrush4() 
{
	// TODO: Add your command handler code here
m_nBrushtype=3;	
}

void CLlView::OnBrush1() 
{
	// TODO: Add your command handler code here
	m_nBrushtype=0;
}

void CLlView::OnBrush2() 
{
	// TODO: Add your command handler code here
	m_nBrushtype=1;
}

void CLlView::OnBrush3() 
{
	// TODO: Add your command handler code here
	m_nBrushtype=2;
}

void CLlView::OnBrush5() 
{
	// TODO: Add your command handler code here
m_nBrushtype=4;	
}

void CLlView::OnBrush6() 
{
	// TODO: Add your command handler code here
m_nBrushtype=5;	
}

void CLlView::OnBrush7() 
{
	// TODO: Add your command handler code here
	m_nBrushtype=6;
}

void CLlView::OnUpdateBrush1(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
pCmdUI->SetCheck(m_nBrushtype==0);	
}

void CLlView::OnUpdateBrush2(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
pCmdUI->SetCheck(m_nBrushtype==1);	
}

void CLlView::OnUpdateBrush3(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
pCmdUI->SetCheck(m_nBrushtype==2);	
}

void CLlView::OnUpdateBrush4(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
pCmdUI->SetCheck(m_nBrushtype==3);	
}

void CLlView::OnUpdateBrush5(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
pCmdUI->SetCheck(m_nBrushtype==4);	
}

void CLlView::OnUpdateBrush6(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
pCmdUI->SetCheck(m_nBrushtype==5);	
}

void CLlView::OnUpdateBrush7(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
pCmdUI->SetCheck(m_nBrushtype==6);	
}

bool CLlView::IsInArea(CPoint pt)
{
int x1,y1,x2,y2;
      x1=x2=y1=y2=0;
      CLlDoc *pDoc=GetDocument();
 POSITION pos=pDoc->m_listRecord.GetTailPosition();
 while (pos)
{m_pshapeSelect=(CShape*)pDoc->m_listRecord.GetPrev(pos);
 x1=m_pshapeSelect->GetOriginPoint().x;

y1=m_pshapeSelect->GetOriginPoint().y;
x2=m_pshapeSelect->GetEndPoint().x;
y2=m_pshapeSelect->GetEndPoint().y;


CRgn rgn;
rgn.CreateRectRgn(x1,y1,x2,y2);



BOOL IsIn=rgn.PtInRegion(pt);
if(IsIn)

{return true;}
 }

return false;
}





void CLlView::OnMove() 
{
	// TODO: Add your command handler code here
 //IsMove=true;
    m_euDraw_Type=IsMove;
}

void CLlView::OnDelete() 
{
	// TODO: Add your command handler code here
      m_euDraw_Type=IsDelete;
}

void CLlView::OnColorpane() 
{
	// TODO: Add your command handler code here
	CMainFrame* pFrame = (CMainFrame*)AfxGetMainWnd();
	if ( pFrame )
		m_Pencolor=pFrame->m_clrPaint;
	m_Brushcolor=pFrame->m_clrCanvas;
	//else
	  //  m_Pencolor=RGB(0,0,0);
}

void CLlView::OnEditRedo() 
{
	// TODO: Add your command handler code here
	CLlDoc *pDoc=GetDocument();
	if(m_listTemp.IsEmpty())
	{MessageBox("未作图","提示",MB_ICONEXCLAMATION);
	return;
	}
	CShape*pshape=(CShape*)m_listTemp.GetTail();
	pDoc->m_listDraw.AddTail(pshape);
	m_listTemp.RemoveTail();
	Invalidate();
	
}

void CLlView::OnEditUndo() 
{
	// TODO: Add your command handler code here
	CLlDoc *pDoc=GetDocument();
	if(pDoc->m_listDraw.IsEmpty())
	{MessageBox("未作图","提示",MB_ICONEXCLAMATION);
	return;
	}
	CShape*pshape=(CShape*)pDoc->m_listDraw.GetTail();
	m_listTemp.AddTail(pshape);
	pDoc->m_listDraw.RemoveTail();
	Invalidate();
	
}

⌨️ 快捷键说明

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