// EastDrawView.cpp : implementation of the CEastDrawView class
//
#include "stdafx.h"
#include "EastDraw.h"
#include "EastDrawDoc.h"
#include "EastDrawView.h"
#include "ReginSet.h"
#include "EditBox.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CEastDrawView
IMPLEMENT_DYNCREATE(CEastDrawView, CScrollView)
BEGIN_MESSAGE_MAP(CEastDrawView, CScrollView)
//{{AFX_MSG_MAP(CEastDrawView)
ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONUP()
ON_WM_MOUSEMOVE()
ON_COMMAND(ID_BUTTON_DLine, OnBUTTONDLine)
ON_COMMAND(ID_BUTTON32774_Move, OnBUTTON32774Move)
ON_COMMAND(ID_BUTTON32775_CircumRotate, OnBUTTON32775CircumRotate)
ON_COMMAND(ID_BUTTON32777_Curve, OnBUTTON32777Curve)
ON_COMMAND(ID_BUTTON32776_Rectangle, OnBUTTON32776Rectangle)
ON_COMMAND(ID_BUTTON32778_RoundRectangle, OnBUTTON32778RoundRectangle)
ON_COMMAND(ID_BUTTON32779_Ellipse, OnBUTTON32779Ellipse)
ON_COMMAND(ID_BUTTON32780_Round, OnBUTTON32780Round)
ON_COMMAND(ID_BUTTON32791_Polygon, OnBUTTON32791Polygon)
ON_WM_LBUTTONDBLCLK()
ON_WM_SETFOCUS()
ON_COMMAND(ID_MENUITEM32794_SetRegin, OnMENUITEM32794SetRegin)
ON_COMMAND(ID_BUTTON_LiEllipse, OnBUTTONLiEllipse)
ON_COMMAND(ID_BUTTON32800_RoundArc, OnBUTTON32800RoundArc)
ON_COMMAND(ID_BUTTON32805_EllipseArc, OnBUTTON32805EllipseArc)
ON_COMMAND(ID_BUTTON32807_PolyBezier, OnBUTTON32807PolyBezier)
ON_COMMAND(ID_BUTTON32809_Text, OnBUTTON32809Text)
ON_COMMAND(ID_CHAR_BOLD, OnCharBold)
ON_COMMAND(ID_CHAR_ITALIC, OnCharItalic)
ON_COMMAND(ID_CHAR_UNDERLINE, OnCharUnderline)
ON_WM_CONTEXTMENU()
ON_COMMAND(ID_MENUITEM_OK, OnMenuitemOk)
ON_WM_SETCURSOR()
ON_COMMAND(ID_CirCu, OnCirCu)
ON_UPDATE_COMMAND_UI(ID_CirCu, OnUpdateCirCu)
ON_WM_KEYUP()
ON_COMMAND(ID_Delete, OnDelete)
ON_COMMAND(ID_BUTTON32830_Lock, OnBUTTON32830Lock)
ON_UPDATE_COMMAND_UI(ID_BUTTON32830_Lock, OnUpdateBUTTON32830Lock)
ON_UPDATE_COMMAND_UI(ID_BUTTON_DLine, OnUpdateBUTTONDLine)
ON_UPDATE_COMMAND_UI(ID_BUTTON32776_Rectangle, OnUpdateBUTTON32776Rectangle)
ON_UPDATE_COMMAND_UI(ID_BUTTON32778_RoundRectangle, OnUpdateBUTTON32778RoundRectangle)
ON_UPDATE_COMMAND_UI(ID_BUTTON32791_Polygon, OnUpdateBUTTON32791Polygon)
ON_UPDATE_COMMAND_UI(ID_BUTTON32779_Ellipse, OnUpdateBUTTON32779Ellipse)
ON_UPDATE_COMMAND_UI(ID_BUTTON32780_Round, OnUpdateBUTTON32780Round)
ON_UPDATE_COMMAND_UI(ID_BUTTON32777_Curve, OnUpdateBUTTON32777Curve)
ON_UPDATE_COMMAND_UI(ID_BUTTON_LiEllipse, OnUpdateBUTTONLiEllipse)
ON_UPDATE_COMMAND_UI(ID_BUTTON32800_RoundArc, OnUpdateBUTTON32800RoundArc)
ON_UPDATE_COMMAND_UI(ID_BUTTON32805_EllipseArc, OnUpdateBUTTON32805EllipseArc)
ON_UPDATE_COMMAND_UI(ID_BUTTON32807_PolyBezier, OnUpdateBUTTON32807PolyBezier)
ON_UPDATE_COMMAND_UI(ID_BUTTON32809_Text, OnUpdateBUTTON32809Text)
ON_UPDATE_COMMAND_UI(ID_BUTTON32774_Move, OnUpdateBUTTON32774Move)
ON_COMMAND(ID_BUTTON32845_Axis, OnBUTTON32845Axis)
ON_UPDATE_COMMAND_UI(ID_BUTTON32845_Axis, OnUpdateBUTTON32845Axis)
ON_COMMAND(ID_BUTTON32850_ReDraw, OnBUTTON32850ReDraw)
ON_COMMAND(ID_BUTTON32856_DONothing, OnBUTTON32856DONothing)
ON_COMMAND(ID_BUTTON32858_OnDo, OnBUTTON32858OnDo)
ON_COMMAND(ID_BUTTON32859_ReDo, OnBUTTON32859ReDo)
ON_UPDATE_COMMAND_UI(ID_BUTTON32858_OnDo, OnUpdateBUTTON32858OnDo)
ON_UPDATE_COMMAND_UI(ID_BUTTON32859_ReDo, OnUpdateBUTTON32859ReDo)
ON_COMMAND(ID_MouseCap_On, OnMouseCapOn)
ON_UPDATE_COMMAND_UI(ID_MouseCap_On, OnUpdateMouseCapOn)
ON_WM_KEYDOWN()
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CScrollView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CScrollView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CScrollView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CEastDrawView construction/destruction
#include "MainFrm.h"
#include "CCurve.h"
#include "CDLine.h"
#include "CRectangle.h"
#include "CRoundRectangle.h"
#include "CEllipse.h"
#include "CRound.h"
#include "CPolygon.h"
#include"CLiEllipse.h"
#include"CRoundArc.h"
#include"CEllipseArc.h"
#include "CPolyBezier.h"
//#include "TextEdit.h"
#include "CText.h"
CEastDrawView::CEastDrawView()
{
// TODO: add construction code here
m_IsLastMove=false;
m_Rtimes=0;
m_Index=0;
m_pCurrentUnit=new CUnit;
m_HaveAxis=true;
m_Bitmap=NULL;
m_IsLocked=false;
CMainFrame*pMainFrame=STATIC_DOWNCAST(CMainFrame, AfxGetMainWnd());
m_DLineProperty=pMainFrame->m_DLineProperty;
m_IsMouseCap=true;
}
CEastDrawView::~CEastDrawView()
{
this->ReMoveTemp();
}
BOOL CEastDrawView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CScrollView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CEastDrawView drawing
void CEastDrawView::OnDraw(CDC* pDC)
{
CEastDrawDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
pDC->SetWindowOrg(m_CenterPoint);
this->DrawAll(pDC);
if(this->m_HaveAxis)
this->DrawAxis(pDC);
}
void CEastDrawView::OnInitialUpdate()
{
CScrollView::OnInitialUpdate();
CEastDrawDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
CSize sizeTotal;
// TODO: calculate the total size of this view
sizeTotal.cx = sizeTotal.cy =2000;
SetScrollSizes(MM_TEXT,pDoc->m_TotalSize);
m_CenterPoint=pDoc->m_CenterPoint;
//SetScrollSizes(MM_HIENGLISH, sizeTotal);
m_bHaveFindFirst=FALSE;
m_bHaveFindSecond=false;
m_LBDownTimes=0;
m_CurrentDrawTool=0;
m_CurrentDrawStatus=0;
ScrollToPosition(CPoint(900,600));
AddTempFile();
AutoSave();
}
/////////////////////////////////////////////////////////////////////////////
// CEastDrawView printing
void CEastDrawView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CEastDrawView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CEastDrawView diagnostics
#ifdef _DEBUG
void CEastDrawView::AssertValid() const
{
CScrollView::AssertValid();
}
void CEastDrawView::Dump(CDumpContext& dc) const
{
CScrollView::Dump(dc);
}
CEastDrawDoc* CEastDrawView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CEastDrawDoc)));
return (CEastDrawDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CEastDrawView message handlers
//******************************************************************************
//******************************************************************************
//**********void CEastDrawView::OnLButtonDown(UINT nFlags, CPoint point)********************************************************************
//******************************************************************************
//******************************************************************************
void CEastDrawView::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CEastDrawDoc*pDoc=this->GetDocument();
CPoint Devpoint=point;
CClientDC dc(this);
this->OnPrepareDC(&dc);
dc.SetWindowOrg(m_CenterPoint);
dc.DPtoLP(&point);
dc.SetROP2(R2_NOTXORPEN);
this->ComputeMinandMaxPoint(point);
m_ChangeingPoint=point;
this->SetMousePosText(point,Devpoint);
if(this->m_CurrentDrawStatus==Draw_Status)
{
if(this->m_CurrentDrawTool!=Polygon_Tool&&this->m_CurrentDrawTool!=PolyBezier_Tool)
{
if(this->m_CurrentDrawTool==EllipseArc_Tool)
{
if(m_LBDownTimes==3)
{
this->m_pCurre
评论3