// Lesson15View.cpp : implementation of the CLesson15View class
//

#include "stdafx.h"
#include "Lesson15.h"

#include "Lesson15Doc.h"
#include "Lesson15View.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CLesson15View

IMPLEMENT_DYNCREATE(CLesson15View, CView)

BEGIN_MESSAGE_MAP(CLesson15View, CView)
	//{{AFX_MSG_MAP(CLesson15View)
	ON_WM_CREATE()
	ON_WM_DESTROY()
	ON_WM_LBUTTONDOWN()
	ON_WM_LBUTTONUP()
	ON_WM_LBUTTONDBLCLK()
	ON_WM_MOUSEMOVE()
	ON_WM_CONTEXTMENU()
	ON_WM_KEYDOWN()
	ON_WM_ERASEBKGND()
	//}}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()

/////////////////////////////////////////////////////////////////////////////
// CLesson15View construction/destruction

CLesson15View::CLesson15View()
{
	// TODO: add construction code here

}

CLesson15View::~CLesson15View()
{
}

BOOL CLesson15View::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CLesson15View drawing

void CLesson15View::OnDraw(CDC* pDC)
{
	CLesson15Doc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	// TODO: add draw code for native data here
	m_Chart.OnDraw(m_hWnd);
}

/////////////////////////////////////////////////////////////////////////////
// CLesson15View printing

BOOL CLesson15View::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	return DoPreparePrinting(pInfo);
}

void CLesson15View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add extra initialization before printing
}

void CLesson15View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add cleanup after printing
}

/////////////////////////////////////////////////////////////////////////////
// CLesson15View diagnostics

#ifdef _DEBUG
void CLesson15View::AssertValid() const
{
	CView::AssertValid();
}

void CLesson15View::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}

CLesson15Doc* CLesson15View::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CLesson15Doc)));
	return (CLesson15Doc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CLesson15View message handlers

int CLesson15View::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CView::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	// TODO: Add your specialized creation code here
/*	m_ChartWnd.Attach(m_hWnd, kTypeXY);
	m_ChartWnd.GetChart()->AddPoint2D(1.0, 3.0);
	m_ChartWnd.GetChart()->AddPoint2D(2.0, 2.5);
	m_ChartWnd.GetChart()->AddPoint2D(3.0, 1.0);
	m_ChartWnd.GetChart()->AddPoint2D(4.0, 6.0);
	m_ChartWnd.GetChart()->AddPoint2D(5.0, 7.0);
	m_ChartWnd.GetChart()->AddPoint2D(6.0, 2.0);
	m_ChartWnd.GetChart()->AddPoint2D(7.0, 1.0);
	m_ChartWnd.GetChart()->AddPoint2D(8.0, 4.0);

	m_ChartWnd.GetChart()->SetTitle(_T("²âÊÔÔÚMFCÏÂ»æÍ¼"));*/
	m_Chart.SetType(kTypeXY);
	m_Chart.AddPoint2D(1.0, 3.0);
	m_Chart.AddPoint2D(2.0, 2.5);
	m_Chart.AddPoint2D(3.0, 1.0);
	m_Chart.AddPoint2D(4.0, 6.0);
	m_Chart.AddPoint2D(5.0, 7.0);
	m_Chart.AddPoint2D(6.0, 2.0);
	m_Chart.AddPoint2D(7.0, 1.0);
	m_Chart.AddPoint2D(8.0, 4.0);
	
	m_Chart.SetTitle(_T("²âÊÔÔÚMFCÏÂ»æÍ¼"));
	
	return 0;
}

void CLesson15View::OnDestroy() 
{
	CView::OnDestroy();
	
	// TODO: Add your message handler code here
	//m_ChartWnd.Detach();
}

void CLesson15View::OnLButtonDown(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	m_Chart.OnLButtonDownR(m_hWnd, point, nFlags);
	
	//CView::OnLButtonDown(nFlags, point);
}

void CLesson15View::OnLButtonUp(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	m_Chart.OnLButtonUpR(m_hWnd, point, nFlags);
	
	//CView::OnLButtonUp(nFlags, point);
}

void CLesson15View::OnLButtonDblClk(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	m_Chart.OnLButtonDblClkR(m_hWnd, point, nFlags);
	
	//CView::OnLButtonDblClk(nFlags, point);
}

void CLesson15View::OnMouseMove(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	m_Chart.OnMouseMoveR(m_hWnd, point, nFlags);
	
	//CView::OnMouseMove(nFlags, point);
}

void CLesson15View::OnContextMenu(CWnd* pWnd, CPoint point) 
{
	// TODO: Add your message handler code here
	m_Chart.OnContextMenuR(NULL, m_hWnd, point);
}

void CLesson15View::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) 
{
	// TODO: Add your message handler code here and/or call default
	m_Chart.OnKeyDownR(m_hWnd, nChar);
	
	//CView::OnKeyDown(nChar, nRepCnt, nFlags);
}

BOOL CLesson15View::OnEraseBkgnd(CDC* pDC) 
{
	// TODO: Add your message handler code here and/or call default
	return TRUE;
	
	//return CView::OnEraseBkgnd(pDC);
}
