// cviewvw.cpp : implementation of the CCviewerView class
//

#include "stdafx.h"
#include "cviewer.h"

#include "cviewdoc.h"
#include "cviewvw.h"
#include "mainfrm.h"

#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CCviewerView

IMPLEMENT_DYNCREATE(CCviewerView, CView)

BEGIN_MESSAGE_MAP(CCviewerView, CView)
	//{{AFX_MSG_MAP(CCviewerView)
	ON_WM_SETFOCUS()
	ON_WM_DESTROY()
	//}}AFX_MSG_MAP
	// Standard printing commands
	ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CCviewerView construction/destruction

CCviewerView::CCviewerView()
{
}
          
CCviewerView::~CCviewerView()
{
}

/////////////////////////////////////////////////////////////////////////////
// CCviewerView drawing

void CCviewerView::OnDraw(CDC* pDC)
{
}         

/////////////////////////////////////////////////////////////////////////////
// CCviewerView printing

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

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

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

/////////////////////////////////////////////////////////////////////////////
// CCviewerView diagnostics

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

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

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

/////////////////////////////////////////////////////////////////////////////
// CCviewerView message handlers


// called whenever view is focused on
void CCviewerView::OnSetFocus(CWnd* pOldWnd)
{
	CView::OnSetFocus(pOldWnd);

	// Setup last view variable in main frame to point to this view
	((CMainFrame *)AfxGetApp()->m_pMainWnd)->SetLastView(this);
}

void CCviewerView::OnDestroy()
{
	GetDocument()->CloseAVDoc();
	CView::OnDestroy();
}