
// Lesson19View.cpp : implementation of the CLesson19View class
//

#include "stdafx.h"
// SHARED_HANDLERS can be defined in an ATL project implementing preview, thumbnail
// and search filter handlers and allows sharing of document code with that project.
#ifndef SHARED_HANDLERS
#include "Lesson19.h"
#endif

#include "Lesson19Doc.h"
#include "Lesson19View.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif


// CLesson19View

IMPLEMENT_DYNCREATE(CLesson19View, CView)

BEGIN_MESSAGE_MAP(CLesson19View, CView)
	// Standard printing commands
	ON_COMMAND(ID_FILE_PRINT, &CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_DIRECT, &CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, &CLesson19View::OnFilePrintPreview)
	ON_WM_CONTEXTMENU()
	ON_WM_RBUTTONUP()
	ON_WM_CREATE()
	ON_WM_DESTROY()
END_MESSAGE_MAP()

// CLesson19View construction/destruction

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

}

CLesson19View::~CLesson19View()
{
}

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

	return CView::PreCreateWindow(cs);
}

// CLesson19View drawing

void CLesson19View::OnDraw(CDC* /*pDC*/)
{
	CLesson19Doc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	if (!pDoc)
		return;

	// TODO: add draw code for native data here
}


// CLesson19View printing


void CLesson19View::OnFilePrintPreview()
{
#ifndef SHARED_HANDLERS
	AFXPrintPreview(this);
#endif
}

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

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

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

void CLesson19View::OnRButtonUp(UINT /* nFlags */, CPoint point)
{
	ClientToScreen(&point);
	OnContextMenu(this, point);
}

void CLesson19View::OnContextMenu(CWnd* /* pWnd */, CPoint point)
{
#ifndef SHARED_HANDLERS
	theApp.GetContextMenuManager()->ShowPopupMenu(IDR_POPUP_EDIT, point.x, point.y, this, TRUE);
#endif
}


// CLesson19View diagnostics

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

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

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


// CLesson19View message handlers


int CLesson19View::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CView::OnCreate(lpCreateStruct) == -1)
		return -1;

	// TODO:  Add your specialized creation code here
	m_ChartWnd.Attach(m_hWnd, kTypePie);
	m_ChartWnd.GetChart()->AddPie(40);
	m_ChartWnd.GetChart()->AddPie(30);
	m_ChartWnd.GetChart()->AddPie(30);

	m_ChartWnd.GetChart()->SetPieTitle(_T("白富美"), 0);
	m_ChartWnd.GetChart()->SetPieTitle(_T("大舅子"), 1);
	m_ChartWnd.GetChart()->SetPieTitle(_T("二舅子"), 2);

	m_ChartWnd.GetChart()->SetTitle(_T("百亿富翁家产继承权"));

	return 0;
}


void CLesson19View::OnDestroy()
{
	CView::OnDestroy();

	// TODO: Add your message handler code here
	m_ChartWnd.Detach();
}
