// mymfc1View.cpp : implementation of the CMymfc1View class
//

#include "stdafx.h"
#include "mymfc1.h"

#include "mymfc1Doc.h"
#include "mymfc1View.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CMymfc1View

IMPLEMENT_DYNCREATE(CMymfc1View, CView)

BEGIN_MESSAGE_MAP(CMymfc1View, CView)
	//{{AFX_MSG_MAP(CMymfc1View)
	ON_WM_LBUTTONDOWN()
	//}}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()

/////////////////////////////////////////////////////////////////////////////
// CMymfc1View construction/destruction

CMymfc1View::CMymfc1View() : m_rectEllipse(0, 0, 4000, -4000)
{
	// TODO: add construction code here
	m_nColor = GRAY_BRUSH;
}

CMymfc1View::~CMymfc1View()
{
}

BOOL CMymfc1View::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CMymfc1View drawing

void CMymfc1View::OnDraw(CDC* pDC)
{
	pDC->SelectStockObject(m_nColor);
    pDC->Ellipse(m_rectEllipse);
}

/////////////////////////////////////////////////////////////////////////////
// CMymfc1View printing

BOOL CMymfc1View::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	return DoPreparePrinting(pInfo);
}

void CMymfc1View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add extra initialization before printing
}

void CMymfc1View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add cleanup after printing
}

/////////////////////////////////////////////////////////////////////////////
// CMymfc1View diagnostics

#ifdef _DEBUG
void CMymfc1View::AssertValid() const
{
	CView::AssertValid();
}

void CMymfc1View::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}

CMymfc1Doc* CMymfc1View::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMymfc1Doc)));
	return (CMymfc1Doc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CMymfc1View message handlers

void CMymfc1View::OnLButtonDown(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	CClientDC dc(this);
    OnPrepareDC(&dc);
    CRect rectDevice = m_rectEllipse;
    dc.LPtoDP(rectDevice);
    if (rectDevice.PtInRect(point)) {
        if (m_nColor == GRAY_BRUSH) {
            m_nColor = WHITE_BRUSH;
        }
        else {
            m_nColor = GRAY_BRUSH;
        }
        InvalidateRect(rectDevice);
    }
}

void CMymfc1View::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo) 
{
	// TODO: Add your specialized code here and/or call the base class
	pDC->SetMapMode(MM_HIMETRIC);
    CView::OnPrepareDC(pDC, pInfo);
}

