www.pudn.com > winnie.rar > winnieView.cpp


// winnieView.cpp : implementation of the CwinnieView class 
// 
 
#include "stdafx.h" 
#include "winnie.h" 
 
#include "winnieDoc.h" 
#include "winnieView.h" 
#include 
#include"MyDialog.h" 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CwinnieView 
 
IMPLEMENT_DYNCREATE(CwinnieView, CView) 
 
BEGIN_MESSAGE_MAP(CwinnieView, CView) 
	//{{AFX_MSG_MAP(CwinnieView) 
	ON_WM_LBUTTONDOWN() 
	ON_WM_MOUSEMOVE() 
	ON_COMMAND(ID_line, Online) 
	ON_COMMAND(ID_circle, Oncircle) 
	ON_COMMAND(ID_roundcircle, Onroundcircle) 
	ON_COMMAND(ID_rectangle, Onrectangle) 
	ON_COMMAND(ID_circlerectangle, Oncirclerectangle) 
	ON_COMMAND(ID_huxian, Onhuxian) 
	ON_COMMAND(ID_chracter, Onchracter) 
	ON_COMMAND(ID_width1, Onwidth1) 
	ON_COMMAND(ID_width2, Onwidth2) 
	ON_COMMAND(ID_width3, Onwidth3) 
	ON_COMMAND(ID_width4, Onwidth4) 
	ON_COMMAND(ID_zi1, Onzi1) 
	ON_COMMAND(ID_zi2, Onzi2) 
	ON_COMMAND(ID_zi3, Onzi3) 
	ON_COMMAND(ID_kind1, Onkind1) 
	ON_COMMAND(ID_kind2, Onkind2) 
	ON_COMMAND(ID_kind3, Onkind3) 
	ON_COMMAND(ID_kind4, Onkind4) 
	ON_COMMAND(ID_kind5, Onkind5) 
	ON_COMMAND(ID_color1, Oncolor1) 
	ON_COMMAND(ID_color2, Oncolor2) 
	ON_COMMAND(ID_color3, Oncolor3) 
	ON_COMMAND(ID_color4, Oncolor4) 
	ON_COMMAND(ID_color5, Oncolor5) 
	ON_COMMAND(ID_color6, Oncolor6) 
	ON_COMMAND(ID_color7, Oncolor7) 
	ON_COMMAND(ID_color8, Oncolor8) 
	ON_COMMAND(ID_color9, Oncolor9) 
	ON_COMMAND(ID_color10, Oncolor10) 
	ON_COMMAND(ID_implement, Onimplement) 
	ON_COMMAND(ID_width5, Onwidth5) 
	ON_COMMAND(ID_color11, Oncolor11) 
	ON_COMMAND(ID_color12, Oncolor12) 
	ON_COMMAND(ID_color13, Oncolor13) 
	ON_COMMAND(ID_color14, Oncolor14) 
	ON_COMMAND(ID_color15, Oncolor15) 
	ON_COMMAND(ID_color16, Oncolor16) 
    ON_COMMAND(ID_w1, Onw1) 
	ON_COMMAND(ID_w2, Onw2) 
	ON_COMMAND(ID_w3, Onw3) 
	ON_COMMAND(ID_w4, Onw4) 
	ON_COMMAND(ID_w5, Onw5) 
	ON_COMMAND(ID_w6, Onw6) 
 
 
 
 
 
 
	ON_COMMAND(ID_clear, Onclear) 
	//}}AFX_MSG_MAP 
	// Standard printing commands 
	ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint) 
	ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint) 
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview) 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CwinnieView construction/destruction 
 
CwinnieView::CwinnieView() 
{ 
	// TODO: add construction code here 
	color=RGB(0,0,0); 
	width=1; 
	type=-1; 
	kind=PS_SOLID; 
	m_step=0; 
	m_bline=FALSE; 
	sign=-1; 
	fill=false; 
 
 
} 
 
CwinnieView::~CwinnieView() 
{ 
} 
 
BOOL CwinnieView::PreCreateWindow(CREATESTRUCT& cs) 
{ 
	// TODO: Modify the Window class or styles here by modifying 
	//  the CREATESTRUCT cs 
 
	return CView::PreCreateWindow(cs); 
} 
 
///////////////////////////////////////////////////////////////////////////// 
// CwinnieView drawing 
 
void CwinnieView::OnDraw(CDC* pDC) 
{ 
	CwinnieDoc* pDoc = GetDocument(); 
	ASSERT_VALID(pDoc); 
	// TODO: add draw code for native data here 
    pDC->SelectStockObject (NULL_BRUSH); 
	int num; 
	num=pDoc->num ; 
	for(int i=1;i<=num;i++) 
	{ 
		type=pDoc->points [i].type; 
		color=pDoc->points [i].color ; 
		width=pDoc->points [i].width ; 
		kind=pDoc->points [i].kind ; 
		sign=pDoc->points [i].sign ; 
		switch(type) 
		{ 
		case 0://直线 
			m_Startp=pDoc->points [i].m_Startp ; 
			m_Endp=pDoc->points [i].m_Endp ; 
			DrawLine(pDC,m_Startp,m_Endp); 
			break; 
		case 1://圆 
           m_centerp=pDoc->points [i].m_Startp ; 
		   m_aroundp=pDoc->points [i].m_Endp ; 
		   DrawCircle(pDC,m_centerp,m_aroundp); 
		   if(sign==1) 
		   { 
			   color=pDoc->points [i].color1 ; 
			   Implement(pDC,pDoc->points [i].m_Startp ,pDoc->points [i].m_Endp ); 
		   } 
		   break; 
		case 2://椭圆 
	    	m_top=pDoc->points [i].m_Startp ; 
		   m_botom=pDoc->points [i].m_Endp ; 
		   DrawlengthCircle(pDC,m_top,m_botom); 
           if(sign==2) 
		   { 
               color=pDoc->points [i].color1 ; 
			   Implement(pDC,pDoc->points [i].m_Startp ,pDoc->points [i].m_Endp ); 
		   } 
		   break; 
		case 3://矩形 
	    	m_up=pDoc->points [i].m_Startp ; 
		   m_down=pDoc->points [i].m_Endp ; 
		   Drawrectangle(pDC,m_up,m_down); 
          if(sign==3) 
		  { 
               color=pDoc->points [i].color1 ; 
			   Implement(pDC,pDoc->points [i].m_Startp ,pDoc->points [i].m_Endp ); 
		  } 
		   break; 
		case 4://圆角矩形 
           m_lup=pDoc->points [i].m_Startp ; 
		   m_ldown=pDoc->points [i].m_Endp ; 
		   DrawRoundRect(pDC,m_lup,m_ldown); 
           if(sign==4) 
		   { 
               color=pDoc->points [i].color1 ; 
			   Implement(pDC,pDoc->points [i].m_Startp ,pDoc->points [i].m_Endp ); 
		   } 
		   break; 
		case 5://弧线 
			top=pDoc->points [i].m_Startp ; 
			botom=pDoc->points [i].m_Endp ; 
			start=pDoc->points [i].m_mid1 ; 
			end=pDoc->points [i].m_mid2 ; 
			DrawArc(pDC,top,botom,start,end); 
			break; 
		case 6://字 
			position=pDoc->points [i].m_Startp; 
			TextOut(pDC,pDoc->points [i].point); 
			break; 
		default:; 
		} 
	} 
} 
 
///////////////////////////////////////////////////////////////////////////// 
// CwinnieView printing 
 
BOOL CwinnieView::OnPreparePrinting(CPrintInfo* pInfo) 
{ 
	// default preparation 
	return DoPreparePrinting(pInfo); 
} 
 
void CwinnieView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) 
{ 
	// TODO: add extra initialization before printing 
} 
 
void CwinnieView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) 
{ 
	// TODO: add cleanup after printing 
} 
 
///////////////////////////////////////////////////////////////////////////// 
// CwinnieView diagnostics 
 
#ifdef _DEBUG 
void CwinnieView::AssertValid() const 
{ 
	CView::AssertValid(); 
} 
 
void CwinnieView::Dump(CDumpContext& dc) const 
{ 
	CView::Dump(dc); 
} 
 
CwinnieDoc* CwinnieView::GetDocument() // non-debug version is inline 
{ 
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CwinnieDoc))); 
	return (CwinnieDoc*)m_pDocument; 
} 
#endif //_DEBUG 
 
///////////////////////////////////////////////////////////////////////////// 
// CwinnieView message handlers 
 
void CwinnieView::OnLButtonDown(UINT nFlags, CPoint point)  
{ 
	// TODO: Add your message handler code here and/or call default 
	CwinnieDoc *pDoc=GetDocument(); 
	position=point; 
	CDC* pDC=GetDC(); 
	pDC->SelectStockObject (NULL_BRUSH); 
	switch(type) 
	{ 
	case 0://直线 
		if(pDoc->num ==100) 
		return; 
    	if(m_step==0) 
		pDoc->num ++; 
		pDoc->points [pDoc->num ].color=color; 
		pDoc->points [pDoc->num ].kind =kind; 
		pDoc->points [pDoc->num ].type =type; 
		pDoc->points [pDoc->num ].width =width; 
		switch(m_step) 
        { 
		case 0: 
			m_Startp=m_Endp=point; 
			pDoc->points [pDoc->num].m_Startp =point; 
			m_step++; 
			break; 
		case 1: 
			m_Endp=point; 
            pDoc->points [pDoc->num].m_Endp =point; 
			m_step=0; 
			m_bline=TRUE; 
			DrawLine(pDC,m_Startp,m_Endp); 
			break; 
		} 
	    break; 
	case 1://圆 
        if(pDoc->num ==100) 
		return; 
	     if(m_step==0) 
		pDoc->num ++;  
		pDoc->points [pDoc->num ].color=color; 
		pDoc->points [pDoc->num ].kind =kind; 
		pDoc->points [pDoc->num ].type =type; 
		pDoc->points [pDoc->num ].width =width; 
         switch(m_step) 
		 { 
	     case 0: 
		  m_centerp = m_aroundp = point; 
		  pDoc->points [pDoc->num ].m_Startp =point; 
		  m_step++; 
		  break; 
         case 1: 
		  m_aroundp = point; 
	      pDoc->points [pDoc->num].m_Endp =point; 
		  m_step = 0; 
		  DrawCircle(pDC,m_centerp,m_aroundp); 
		  break; 
		 } 
		 break; 
	case 2://椭圆 
       if(pDoc->num ==100) 
		return; 
	  if(m_step==0) 
		pDoc->num ++; 
		pDoc->points [pDoc->num ].color=color; 
		pDoc->points [pDoc->num ].kind =kind; 
		pDoc->points [pDoc->num ].type =type; 
		pDoc->points [pDoc->num ].width =width; 
        switch(m_step) 
		 { 
	     case 0: 
		  m_top= m_botom = point; 
		  pDoc->points [pDoc->num ].m_Startp =point; 
		  m_step++; 
		  break; 
         case 1: 
		  m_botom= point; 
	      pDoc->points [pDoc->num].m_Endp =point; 
		  m_step = 0; 
		  DrawlengthCircle(pDC,m_top,m_botom); 
		  break; 
		 } 
		 break; 
	case 3://矩形 
      if(pDoc->num ==100) 
		return; 
	  if(m_step==0) 
		pDoc->num ++; 
		pDoc->points [pDoc->num ].color=color; 
		pDoc->points [pDoc->num ].kind =kind; 
		pDoc->points [pDoc->num ].type =type; 
		pDoc->points [pDoc->num ].width =width; 
        switch(m_step) 
		 { 
	     case 0: 
		  m_up= m_down = point; 
		  pDoc->points [pDoc->num ].m_Startp =point; 
		  m_step++; 
		  break; 
         case 1: 
		  m_down= point; 
	      pDoc->points [pDoc->num].m_Endp =point; 
		  m_step = 0; 
		  Drawrectangle(pDC,m_up,m_down); 
		  break; 
		 } 
		 break; 
	case 4://圆角矩形 
      if(pDoc->num ==100) 
		return; 
	  if(m_step==0) 
		pDoc->num ++; 
		pDoc->points [pDoc->num ].color=color; 
		pDoc->points [pDoc->num ].kind =kind; 
		pDoc->points [pDoc->num ].type =type; 
		pDoc->points [pDoc->num ].width =width;   
	  switch(m_step) 
	  { 
	   case 0: 
		m_lup = m_ldown = point; 
        pDoc->points[pDoc->num].m_Startp = m_lup; 
		m_step++; 
		break; 
    	case 1: 
		m_ldown = point; 
        pDoc->points[pDoc->num].m_Endp = m_ldown; 
		m_step = 0; 
		DrawRoundRect(pDC,m_lup,m_ldown); 
		break; 
	   } 
	 break; 
	case 5://圆弧 
      if(pDoc->num ==100) 
		return; 
	  if(m_step==0) 
		pDoc->num ++; 
		pDoc->points [pDoc->num ].color=color; 
		pDoc->points [pDoc->num ].kind =kind; 
		pDoc->points [pDoc->num ].type =type; 
		pDoc->points [pDoc->num ].width =width;   
	  switch(m_step) 
	  { 
	   case 0: 
		top = botom=start=end= point; 
        pDoc->points[pDoc->num].m_Startp = top; 
		m_step++; 
		break; 
    	case 1: 
		botom = point; 
        pDoc->points[pDoc->num].m_Endp = botom; 
		m_step++; 
		break; 
		case 2: 
		start=point; 
		pDoc->points [pDoc->num ].m_mid1 =start; 
		m_step++; 
		break; 
		case 3: 
		end=point; 
		pDoc->points [pDoc->num ].m_mid2 =end; 
		m_step=0; 
		DrawArc(pDC,top,botom,start,end); 
		break; 
	   } 
	 break; 
	case 6: 
       if(pDoc->num ==100) 
		return; 
	    pDoc->num ++; 
		pDoc->points [pDoc->num ].color=color; 
		pDoc->points [pDoc->num ].kind =kind; 
		pDoc->points [pDoc->num ].type =type; 
		pDoc->points [pDoc->num ].width =width;  
		pDoc->points [pDoc->num ].m_Startp =point; 
        OnFunDlg(); 
		break; 
	default:; 
	} 
	ReleaseDC(pDC); 
	pDoc->SetModifiedFlag (); 
	CView::OnLButtonDown(nFlags, point); 
} 
 
void CwinnieView::OnMouseMove(UINT nFlags, CPoint point)  
{ 
	// TODO: Add your message handler code here and/or call default 
    CDC* pDC=GetDC(); 
	//获得状态条的指针 
	CStatusBar * pStatus = (CStatusBar *)AfxGetApp()-> 
		m_pMainWnd->GetDescendantWindow(ID_VIEW_STATUS_BAR); 
	if(pStatus) 
	{ 
		char tbuf[40]; 
		sprintf(tbuf,"(%d,%d)",point.x,point.y); 
		//在状态条的第二个窗格中输出当前鼠标的位置 
		pStatus->SetPaneText(1,tbuf); 
	} 
	int nDrawmode=pDC->SetROP2 (R2_NOT); 
	pDC->SelectStockObject (NULL_BRUSH); 
	switch(type) 
	{ 
	case 0: 
        if(m_step!=0&&m_step!=1) 
		 { 
			 m_step=0; 
			 break; 
		} 
		if(m_step==1) 
		{ 
			CPoint prePnt,curPnt; 
			prePnt=m_Endp; 
			curPnt=point; 
			DrawLine(pDC,m_Startp,prePnt); 
			DrawLine(pDC,m_Startp,curPnt); 
			m_Endp=point; 
		} 
		break; 
	case 1: 
        if(m_step!=0&&m_step!=1) 
		 { 
			 m_step=0; 
			 break; 
		} 
		if(m_step==1) 
		{ 
			CPoint prePnt,curPnt; 
			prePnt=m_aroundp; 
			curPnt=point; 
			DrawCircle(pDC,m_centerp,prePnt); 
			DrawCircle(pDC,m_centerp,curPnt); 
			m_aroundp=point; 
		} 
		break; 
	case 2: 
        if(m_step!=0&&m_step!=1) 
		 { 
			 m_step=0; 
			 break; 
		} 
		if(m_step==1) 
		{ 
			CPoint prePnt,curPnt; 
			prePnt=m_botom; 
			curPnt=point; 
			DrawlengthCircle(pDC,m_top,prePnt); 
			DrawlengthCircle(pDC,m_top,curPnt); 
			m_botom=point; 
		} 
		break; 
	case 3: 
        if(m_step!=0&&m_step!=1) 
		 { 
			 m_step=0; 
			 break; 
		} 
       if(m_step==1) 
		{ 
			CPoint prePnt,curPnt; 
			prePnt=m_down; 
			curPnt=point; 
			Drawrectangle(pDC,m_up,prePnt); 
			Drawrectangle(pDC,m_up,curPnt); 
			m_down=point; 
		} 
	   break; 
	case 4: 
        if(m_step!=0&&m_step!=1) 
		 { 
			 m_step=0; 
			 break; 
		} 
       if(m_step==1) 
		{ 
			CPoint prePnt,curPnt; 
			prePnt=m_ldown; 
			curPnt=point; 
			DrawRoundRect(pDC,m_lup,prePnt); 
			DrawRoundRect(pDC,m_lup,curPnt); 
			m_ldown=point; 
		} 
	   break; 
	 case 5: 
		 if(m_step==3) 
		 { 
			 CPoint prePnt,curPnt; 
			 prePnt=end; 
			 curPnt=point; 
			 DrawArc(pDC,top,botom,start,prePnt); 
			 DrawArc(pDC,top,botom,start,curPnt); 
			 end=point; 
		 } 
		 break; 
 
	default:; 
	} 
	pDC->SetROP2 (nDrawmode); 
	ReleaseDC(pDC); 
	 
	CView::OnMouseMove(nFlags, point); 
} 
 
void CwinnieView::DrawLine(CDC *pDC, CPoint start, CPoint end) 
{ 
    CPen newpen(kind,width,color); 
	CPen *poldpen = pDC->SelectObject(&newpen); 
	pDC->MoveTo(start); 
	pDC->LineTo(end); 
	pDC->SelectObject(poldpen); 
} 
 
void CwinnieView::DrawCircle(CDC *pDC, CPoint center, CPoint aroud) 
{ 
    CPen newpen(kind,width,color); 
	CPen *poldpen = pDC->SelectObject(&newpen); 
	double total = (double)(center.x-aroud.x)*(center.x-aroud.x)+(center.y-aroud.y)*(center.y-aroud.y); 
	int radius = (int) sqrt(total); 
	pDC->Ellipse((center.x-radius),(center.y-radius),(center.x+radius),(center.y+radius)); 
	pDC->SelectObject(poldpen); 
} 
 
void CwinnieView::DrawlengthCircle(CDC *pDC, CPoint center, CPoint aroud) 
{ 
    CPen newpen(kind,width,color); 
	CPen *poldpen = pDC->SelectObject(&newpen); 
	 
	pDC->Ellipse(center.x, center.y,aroud.x,aroud.y); 
	pDC->SelectObject(poldpen); 
} 
 
void CwinnieView::Drawrectangle(CDC *pDC, CPoint center, CPoint aroud) 
{ 
   CPen newpen(kind,width,color); 
	CPen *poldpen = pDC->SelectObject(&newpen); 
	 
	pDC->Rectangle (center.x, center.y,aroud.x,aroud.y); 
	pDC->SelectObject(poldpen); 
} 
 
void CwinnieView::DrawRoundRect(CDC *pDC, CPoint m_lup, CPoint m_ldown) 
{ 
    CPen newpen(kind,width,color); 
	CPen *poldpen = pDC->SelectObject(&newpen); 
	int x =(int) fabs(m_lup.x - m_ldown.x)/8; 
	int y =(int ) fabs(m_lup.y - m_ldown.y)/8; 
	pDC->RoundRect(m_lup.x,m_lup.y,m_ldown.x,m_ldown.y,x,y); 
	pDC->SelectObject(poldpen); 
} 
 
void CwinnieView::DrawArc(CDC *pDC, CPoint top, CPoint botom, CPoint start, CPoint end) 
{ 
    CPen newpen(kind,width,color); 
	CPen *poldpen = pDC->SelectObject(&newpen); 
 
	pDC->Arc(top.x,top.y,botom.x,botom.y,start.x,start.y,end.x,end.y); 
	pDC->SelectObject(poldpen); 
 
} 
 
void CwinnieView::TextOut(CDC *pDC, CString point) 
{ 
CFont newFont,*oldFont;     
    switch(kind) 
	{ 
	case 1: 
		    newFont.CreateFont(40, 
			0, 
			0, 
			0, 
			400, 
			1,   //是斜体字 
			0, 
			0, 
			ANSI_CHARSET, 
			OUT_DEFAULT_PRECIS, 
			CLIP_DEFAULT_PRECIS, 
			DEFAULT_QUALITY, 
			DEFAULT_PITCH, 
			"Arial"); 
			break; 
	         
	case 2: 
	       newFont.CreateFont(40,        
			0,                       
			0,                        
			0,                       
			1000,                    
			0,                       
			0,                       
			0,                        
			ANSI_CHARSET,           
			OUT_DEFAULT_PRECIS,      
			CLIP_DEFAULT_PRECIS,      
			DEFAULT_QUALITY,         
			DEFAULT_PITCH,           
	        "Arial");    
			break;  
		 
	case 3: 
	       newFont.CreateFont(40,      
			0,                     
			0,                      
			0,                     
			400,                    
			0,                      
			1,                     
			0,                     
			ANSI_CHARSET,           
			OUT_DEFAULT_PRECIS,    
			CLIP_DEFAULT_PRECIS,    
			DEFAULT_QUALITY,       
			DEFAULT_PITCH,       
			"Arial");     
		   break; 
	} 
	oldFont=pDC->SelectObject(&newFont);     
	pDC->SetTextColor (color); 
	pDC->SetBkMode (TRANSPARENT); 
	pDC->TextOut (position.x,position.y,point,strlen(point)); 
	pDC->SelectObject (oldFont); 
} 
 
void CwinnieView::Implement(CDC *pDC, CPoint start, CPoint end) 
{ 
double total; 
	int radius,x,y; 
	CBrush *newbrush,*oldbrush; 
	 newbrush=new CBrush(color); 
	 oldbrush=pDC->SelectObject (newbrush); 
	switch(sign) 
	{ 
      case 1: 
	  total=0; 
	  total = (double)(start.x-end.x)*(start.x-end.x)+(start.y-end.y)*(start.y-end.y); 
	  radius=0; 
	  radius = (int) sqrt(total); 
	  pDC->Ellipse((start.x-radius),(start.y-radius),(start.x+radius),(start.y+radius)); 
	  break; 
    case 2: 
	  pDC->Ellipse(start.x, start.y,end.x,end.y); 
	  break; 
    case 3: 
      pDC->Rectangle (start.x, start.y,end.x,end.y); 
	  break; 
	case 4: 
       x =(int) fabs(start.x - start.x)/8; 
	   y =(int ) fabs(start.y - start.y)/8; 
	  pDC->RoundRect(start.x,start.y,end.x,end.y,x,y); 
	  break; 
	default:; 
	} 
   pDC->SelectObject (oldbrush); 
} 
 
void CwinnieView::Online()  
{ 
	// TODO: Add your command handler code here 
	type=0; 
	 
} 
 
void CwinnieView::Oncircle()  
{ 
	// TODO: Add your command handler code here 
	type=1; 
	 
} 
 
void CwinnieView::Onroundcircle()  
{ 
	// TODO: Add your command handler code here 
	type=2; 
	 
} 
 
void CwinnieView::Onrectangle()  
{ 
	// TODO: Add your command handler code here 
	type=3; 
} 
 
void CwinnieView::Oncirclerectangle()  
{ 
	// TODO: Add your command handler code here 
	type=4; 
	 
} 
 
void CwinnieView::Onhuxian()  
{ 
	// TODO: Add your command handler code here 
	type=5; 
	 
} 
 
void CwinnieView::Onchracter()  
{ 
	// TODO: Add your command handler code here 
	type=6; 
} 
 
void CwinnieView::Onwidth1()  
{ 
	// TODO: Add your command handler code here 
	width=1; 
	 
} 
 
void CwinnieView::Onwidth2()  
{ 
	// TODO: Add your command handler code here 
	width=2; 
	 
} 
 
void CwinnieView::Onwidth3()  
{ 
	// TODO: Add your command handler code here 
	width=3; 
	 
} 
 
void CwinnieView::Onwidth4()  
{ 
	// TODO: Add your command handler code here 
	width=4; 
	 
} 
 
void CwinnieView::Onzi1()  
{ 
	// TODO: Add your command handler code here 
	kind=2; 
	 
} 
 
void CwinnieView::Onzi2()  
{ 
	// TODO: Add your command handler code here 
	kind=1; 
	 
} 
 
void CwinnieView::Onzi3()  
{ 
	// TODO: Add your command handler code here 
	kind=3; 
	 
} 
 
void CwinnieView::Onkind1()  
{ 
	// TODO: Add your command handler code here 
	kind=PS_SOLID; 
	 
} 
 
void CwinnieView::Onkind2()  
{ 
	// TODO: Add your command handler code here 
	kind=PS_DOT; 
	 
} 
 
void CwinnieView::Onkind3()  
{ 
	// TODO: Add your command handler code here 
	kind=PS_DASH; 
	 
} 
 
void CwinnieView::Onkind4()  
{ 
	// TODO: Add your command handler code here 
	kind=PS_DASHDOT; 
	 
} 
 
void CwinnieView::Onkind5()  
{ 
	// TODO: Add your command handler code here 
	kind=PS_DASHDOTDOT; 
	 
} 
 
void CwinnieView::Oncolor1()  
{ 
	// TODO: Add your command handler code here 
	color=RGB(255,0,0); 
	 
} 
 
void CwinnieView::Oncolor2()  
{ 
	// TODO: Add your command handler code here 
	color=RGB(0,0,0); 
	 
} 
 
void CwinnieView::Oncolor3()  
{ 
	// TODO: Add your command handler code here 
	color=RGB(0,0,255); 
	 
} 
 
void CwinnieView::Oncolor4()  
{ 
	// TODO: Add your command handler code here 
	color=RGB(0,255,0); 
} 
 
void CwinnieView::Oncolor5()  
{ 
	// TODO: Add your command handler code here 
	color=RGB(255,255,255); 
	 
} 
 
void CwinnieView::Oncolor6()  
{ 
	// TODO: Add your command handler code here 
		color=RGB(255,255,0); 
	 
} 
 
void CwinnieView::Oncolor7()  
{ 
	// TODO: Add your command handler code here 
	color=RGB(192,192,192); 
	 
	 
} 
 
void CwinnieView::Oncolor8()  
{ 
	// TODO: Add your command handler code here 
	color=RGB(255,0,255); 
	 
	 
} 
 
void CwinnieView::Oncolor9()  
{ 
	// TODO: Add your command handler code here 
		color=RGB(0,255,255); 
	 
} 
 
void CwinnieView::Oncolor10()  
{ 
	// TODO: Add your command handler code here 
	color=RGB(128,128,128); 
		 
} 
 
void CwinnieView::Onimplement()  
{ 
	// TODO: Add your command handler code here 
	CDC* pDC=GetDC(); 
	CwinnieDoc* pDoc=GetDocument(); 
	switch(type) 
	{ 
	case 1: 
		sign=1; 
		pDoc->points [pDoc->num ].color1=color; 
		pDoc->points [pDoc->num ].sign =sign; 
	    Implement(pDC,m_centerp,m_aroundp); 
		break; 
	case 2: 
		sign=2; 
	    pDoc->points [pDoc->num ].color1=color; 
		pDoc->points [pDoc->num ].sign =sign; 
		Implement(pDC,m_top,m_botom); 
		break; 
	case 3: 
		sign=3; 
	    pDoc->points [pDoc->num ].color1=color; 
		pDoc->points [pDoc->num ].sign =sign; 
		Implement(pDC,m_up,m_down); 
		break; 
	case 4: 
		sign=4; 
       	pDoc->points [pDoc->num ].color1=color; 
		pDoc->points [pDoc->num ].sign =sign; 
		Implement(pDC,m_lup,m_ldown); 
		break; 
	default:; 
	} 
} 
 
void CwinnieView::OnFunDlg() 
{ 
   CwinnieDoc* pDoc=GetDocument(); 
	MyDialog dlg; 
	CDC* pDC=GetDC(); 
	if(dlg.DoModal ()==IDOK) 
	{ 
		pDoc->points [pDoc->num ].point =dlg.m_edit ; 
		TextOut(pDC,pDoc->points [pDoc->num ].point ); 
	} 
	else 
	{ 
		; 
	} 
} 
 
void CwinnieView::Onwidth5()  
{ 
	// TODO: Add your command handler code here 
	width=5; 
	 
} 
 
void CwinnieView::Oncolor11()  
{ 
	// TODO: Add your command handler code here 
	color=RGB(128,128,0); 
} 
 
void CwinnieView::Oncolor12()  
{ 
	// TODO: Add your command handler code here 
	color=RGB(0,128,0); 
} 
 
void CwinnieView::Oncolor13()  
{ 
	// TODO: Add your command handler code here 
	color=RGB(128,0,128); 
} 
 
void CwinnieView::Oncolor14()  
{ 
	// TODO: Add your command handler code here 
	color=RGB(64,128,128); 
} 
void CwinnieView::Oncolor15()  
{ 
	// TODO: Add your command handler code here 
	color=RGB(128,0,0); 
} 
void CwinnieView::Oncolor16()  
{ 
	// TODO: Add your command handler code here 
	color=RGB(0,128,128); 
} 
 
 
void CwinnieView::Onw1()  
{ 
this->index=HS_BDIAGONAL; 
this->Fill();	 
} 
 
 
 
 
 
 
 
 
void CwinnieView::Onclear()  
{ 
	// TODO: Add your command handler code here 
  CwinnieDoc *pDoc=GetDocument(); 
  pDoc->num =0; 
  pDoc->SetModifiedFlag (); 
  Invalidate(); 
	 
} 
 
 
 
void CwinnieView::Fill() 
{ 
	CDC* pDC=GetDC(); 
	CwinnieDoc* pDoc=GetDocument(); 
	switch(type) 
	{ 
	case 1: 
		sign=1; 
		pDoc->points [pDoc->num ].color1=color; 
		pDoc->points [pDoc->num ].sign =sign; 
	    Implement1(pDC,m_centerp,m_aroundp); 
		break; 
	case 2: 
		sign=2; 
	    pDoc->points [pDoc->num ].color1=color; 
		pDoc->points [pDoc->num ].sign =sign; 
		Implement1(pDC,m_top,m_botom); 
		break; 
	case 3: 
		sign=3; 
	    pDoc->points [pDoc->num ].color1=color; 
		pDoc->points [pDoc->num ].sign =sign; 
		Implement1(pDC,m_up,m_down); 
		break; 
	case 4: 
		sign=4; 
       	pDoc->points [pDoc->num ].color1=color; 
		pDoc->points [pDoc->num ].sign =sign; 
		Implement1(pDC,m_lup,m_ldown); 
		break; 
	default:break;// 
	} 
} 
 
 
 
void CwinnieView::Implement1(CDC *pDC, CPoint start, CPoint end) 
{ 
double total; 
	int radius,x,y; 
	CBrush *newbrush,*oldbrush; 
	if(fill==false) 
	{newbrush=new CBrush(index,color);} 
	else if(fill==true) 
	{newbrush=new CBrush(color);} 
	 oldbrush=pDC->SelectObject (newbrush); 
	switch(sign) 
	{ 
      case 1: 
	  total=0; 
	  total = (double)(start.x-end.x)*(start.x-end.x)+(start.y-end.y)*(start.y-end.y); 
	  radius=0; 
	  radius = (int) sqrt(total); 
	  pDC->Ellipse((start.x-radius),(start.y-radius),(start.x+radius),(start.y+radius)); 
	  break; 
    case 2: 
	  pDC->Ellipse(start.x, start.y,end.x,end.y); 
	  break; 
    case 3: 
      pDC->Rectangle (start.x, start.y,end.x,end.y); 
	  break; 
	case 4: 
       x =(int) fabs(start.x - start.x)/8; 
	   y =(int ) fabs(start.y - start.y)/8; 
	  pDC->RoundRect(start.x,start.y,end.x,end.y,x,y); 
	  break; 
	default:; 
	} 
   pDC->SelectObject (oldbrush); 
   fill=false; 
} 
 
 
void CwinnieView::init() 
{ 
	color=RGB(0,0,0); 
	width=1; 
	type=-1; 
	kind=PS_SOLID; 
	m_step=0; 
	m_bline=FALSE; 
	sign=-1; 
 
} 
void CwinnieView::Onw2()  
{ 
this->index=HS_CROSS;	 
this->Fill(); 
} 
 
void CwinnieView::Onw3()  
{ 
this->index=HS_DIAGCROSS; 
this->Fill();	 
} 
 
void CwinnieView::Onw4()  
{ 
this->index=HS_FDIAGONAL; 
this->Fill();	 
} 
 
void CwinnieView::Onw5()  
{ 
this->index=HS_HORIZONTAL; 
this->Fill();	 
} 
 
void CwinnieView::Onw6()  
{ 
this->index=HS_VERTICAL; 
this->Fill();	 
}