www.pudn.com > xtable2.zip > XMLTableView.cpp


// XMLTableView.cpp : implementation of the CXMLTableView class 
// 
 
#include "stdafx.h" 
#include "XMLTable.h" 
 
#include "XMLTableDoc.h" 
#include "XMLTableView.h" 
 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#endif 
// CXMLTableView 
 
IMPLEMENT_DYNCREATE(CXMLTableView, CView) 
 
BEGIN_MESSAGE_MAP(CXMLTableView, 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, CView::OnFilePrintPreview) 
	ON_WM_CLOSE() 
	ON_WM_CREATE() 
	ON_WM_LBUTTONDOWN() 
END_MESSAGE_MAP() 
 
// CXMLTableView construction/destruction 
 
CXMLTableView::CXMLTableView() 
{ 
} 
 
CXMLTableView::~CXMLTableView() 
{ 
} 
 
BOOL CXMLTableView::PreCreateWindow(CREATESTRUCT& cs) 
{ 
	// TODO: Modify the Window class or styles here by modifying 
	//  the CREATESTRUCT cs 
	return CView::PreCreateWindow(cs); 
} 
 
// CXMLTableView drawing 
void CXMLTableView::OnDraw(CDC* /*pDC*/) 
{ 
	CXMLTableDoc* pDoc = GetDocument(); 
	ASSERT_VALID(pDoc); 
 
	// TODO: add draw code for native data here 
} 
 
 
// CXMLTableView printing 
 
BOOL CXMLTableView::OnPreparePrinting(CPrintInfo* pInfo) 
{ 
	// default preparation 
	return DoPreparePrinting(pInfo); 
} 
 
void CXMLTableView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) 
{ 
	// TODO: add extra initialization before printing 
} 
 
void CXMLTableView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) 
{ 
	// TODO: add cleanup after printing 
} 
 
 
// CXMLTableView diagnostics 
 
#ifdef _DEBUG 
void CXMLTableView::AssertValid() const 
{ 
	CView::AssertValid(); 
} 
 
void CXMLTableView::Dump(CDumpContext& dc) const 
{ 
	CView::Dump(dc); 
} 
 
CXMLTableDoc* CXMLTableView::GetDocument() const // non-debug version is inline 
{ 
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CXMLTableDoc))); 
	return (CXMLTableDoc*)m_pDocument; 
} 
#endif //_DEBUG 
 
 
// CXMLTableView message handlers 
 
void CXMLTableView::OnClose() 
{ 
	CView::OnClose(); 
} 
 
int CXMLTableView::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{ 
	if (CView::OnCreate(lpCreateStruct) == -1) 
		return -1; 
 
	m_table.Create(CRect(0,0,800,800), this, 1000); 
 
	//m_table.SetCols (20); 
	//m_table.SetRows (20); 
	m_table.Test (); 
 
	//m_table.Invalidate(); 
 
	return 0; 
} 
 
void CXMLTableView::OnLButtonDown(UINT nFlags, CPoint point) 
{ 
	CView::OnLButtonDown(nFlags, point); 
} 
 
void CXMLTableView::OnUpdate(CView* /*pSender*/, LPARAM /*lHint*/, CObject* /*pHint*/) 
{ 
	CMarkup& markup = GetDocument()->markup; 
 
	if (markup.FindElem("xml")) 
	{ 
		if (markup.FindChildElem ("table")) 
			m_table.FromXML (markup); 
	} 
}