// PeeperDoc.cpp : implementation of the CPeeperDoc class
//

#include "stdafx.h"
#include "Peeper.h"

#include "PeeperDoc.h"

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

/////////////////////////////////////////////////////////////////////////////
// CPeeperDoc

IMPLEMENT_DYNCREATE(CPeeperDoc, CDocument)

BEGIN_MESSAGE_MAP(CPeeperDoc, CDocument)
	//{{AFX_MSG_MAP(CPeeperDoc)
		// NOTE - the ClassWizard will add and remove mapping macros here.
		//    DO NOT EDIT what you see in these blocks of generated code!
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CPeeperDoc construction/destruction

CPeeperDoc::CPeeperDoc()
{
	// TODO: add one-time construction code here
	HNode::Initalize();
}

CPeeperDoc::~CPeeperDoc()
{
}

BOOL CPeeperDoc::OnNewDocument()
{
//	if (!CDocument::OnNewDocument())
//		return FALSE;

	// TODO: add reinitialization code here
	// (SDI documents will reuse this document)

	return FALSE;
}



/////////////////////////////////////////////////////////////////////////////
// CPeeperDoc serialization

void CPeeperDoc::Serialize(CArchive& ar)
{
	if (ar.IsStoring())
	{
		// TODO: add storing code here
	}
	else
	{
	}
}

/////////////////////////////////////////////////////////////////////////////
// CPeeperDoc diagnostics

#ifdef _DEBUG
void CPeeperDoc::AssertValid() const
{
	CDocument::AssertValid();
}

void CPeeperDoc::Dump(CDumpContext& dc) const
{
	CDocument::Dump(dc);
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CPeeperDoc commands

BOOL CPeeperDoc::OnOpenDocument(LPCTSTR lpszPathName) 
{
//	if (!CDocument::OnOpenDocument(lpszPathName))
//		return FALSE;
	DspPath=lpszPathName;
Parsed=false;
	DoParse();

	return TRUE;
}

void CPeeperDoc::DoParse()
{
if(!Parsed)
{
PathMan.ScanProject(DspPath);
FileTree.SetPathManager(&PathMan);

	CString dsppath,dspbase;
	dsppath=DspPath.Left(DspPath.ReverseFind('\\')+1);
	dspbase=DspPath.Mid(DspPath.ReverseFind('\\')+1);

FileTree.ParseDsp(dspbase,dsppath);
	Parsed=true;
}

}


BOOL CPeeperDoc::OnSaveDocument(LPCTSTR lpszPathName) 
{
	// TODO: Add your specialized code here and/or call the base class
	
	return CDocument::OnSaveDocument(lpszPathName);
}
