- solidgraph_bin.zip
- solidgraph_bin
- DraftTemplates
- DT1.sdt
- DT2.sdt
- Plugins
- Boolean.ppl
- Kinematic.ppl
- Standard2D.ppl
- Standard3D.ppl
- Surfaces.ppl
- sgCore.dll
- Solidgraph.exe
- SplashLib.dll
- solidgraph_sources.zip
- solidgraph_sources
- ArMaX
- Boolean
- CxImage
- Debug
- DraftTemplates
- DT1.sdt
- DT2.sdt
- sgCore.dll
- ExGUILib
- jpeg
- Kinematic
- lua
- MaterialsEditor
- png
- Release
- sgCore.dll
- Scripts
- boxes.sgs
- circles.sgs
- cones.sgs
- cylinders.sgs
- ellipsoids.sgs
- lines.sgs
- points.sgs
- print.sgs
- Script.sgs
- spBands.sgs
- spheres.sgs
- toruses.sgs
- sgCore
- Solidgraph.sln
- Solidgraph
- SplashLib
- Standard2D
- arc.bmp
- circ.bmp
- Commands
- Dialogs
- line.bmp
- path.bmp
- pnt.bmp
- ReadMe.txt
- res
- circ_3p.bmp
- circ_c_r.bmp
- circ_edit_cen.bmp
- circ_edit_norm.bmp
- circ_edit_rad.bmp
- line_arc_end.bmp
- line_arc_perpendic_end.bmp
- line_edit.bmp
- line_line_extension.bmp
- line_line_perpendic_end.bmp
- line_point_increment.bmp
- line_point_vector.bmp
- line_two_points.bmp
- pnt_edit.bmp
- Spline_edit.bmp
- Standard2D.rc2
- resource.h
- spl.bmp
- Standard2D.cpp
- Standard2D.def
- Standard2D.rc
- Standard2D.vcproj
- StdAfx.cpp
- StdAfx.h
- toolbar.bmp
- toolbarBMP.bmp
- toolbarBMPOld.bmp
- Standard3D
- Surfaces
- tiff
- zlib
|
#include "stdafx.h"
#include "OneDocTemplate.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
IMPLEMENT_DYNAMIC(COneDocTemplate, CEGMultiDocTemplate)
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
COneDocTemplate::COneDocTemplate(UINT nIDResource, CRuntimeClass* pDocClass,
CRuntimeClass* pFrameClass, CRuntimeClass* pViewClass)
: CEGMultiDocTemplate(nIDResource, pDocClass, pFrameClass, pViewClass)
{
}
COneDocTemplate::~COneDocTemplate()
{
}
/////////////////////////////////////////////////////////////////////////////
// COneDocTemplate document management (a list of currently open documents)
void
COneDocTemplate::AddDocument(CDocument* pDoc)
{
ASSERT( m_docList.GetCount() == 0 ); // one at a time please
CEGMultiDocTemplate::AddDocument(pDoc);
}
/////////////////////////////////////////////////////////////////////////////
// COneDocTemplate commands
CDocument*
COneDocTemplate::OpenDocumentFile(LPCTSTR lpszPathName, BOOL bMakeVisible)
{
CDocument* pDocument = NULL;
CFrameWnd* pFrame = NULL;
BOOL bCreated = FALSE; // => doc and frame created
BOOL bWasModified = FALSE;
if( m_docList.GetCount() != 0 )
{
// already have a document - reinit it
POSITION pos = GetFirstDocPosition();
pDocument = GetNextDoc(pos);
if (!pDocument->SaveModified())
return NULL; // leave the original one
// assume 1 frame for the document
pos = pDocument->GetFirstViewPosition();
ASSERT( pos ); // at least 1 view must be exists
CView* pView = pDocument->GetNextView(pos);
ASSERT_VALID(pView);
ASSERT(::IsWindow(pView->m_hWnd));
pFrame = pView->GetParentFrame();
ASSERT(pFrame != NULL);
ASSERT_KINDOF(CFrameWnd, pFrame);
ASSERT_VALID(pFrame);
}
else
{
// create a new document
pDocument = CreateNewDocument();
ASSERT(pFrame == NULL); // will be created below
bCreated = TRUE;
};
if (pDocument == NULL)
{
TRACE0("CDocTemplate::CreateNewDocument returned NULL.\n");
AfxMessageBox(AFX_IDP_FAILED_TO_CREATE_DOC);
return NULL;
}
ASSERT_VALID(pDocument);
if (pFrame == NULL)
{
ASSERT(bCreated);
// create frame - set as main document frame
BOOL bAutoDelete = pDocument->m_bAutoDelete;
pDocument->m_bAutoDelete = FALSE;
// don't destroy if something goes wrong
pFrame = CreateNewFrame(pDocument, NULL);
pDocument->m_bAutoDelete = bAutoDelete;
if (pFrame == NULL)
{
AfxMessageBox(AFX_IDP_FAILED_TO_CREATE_DOC);
delete pDocument; // explicit delete on error
return NULL;
}
ASSERT_VALID(pFrame);
};
if (lpszPathName == NULL)
{
// create a new document - with default document name
SetDefaultTitle(pDocument);
// avoid creating temporary compound file when starting up invisible
if (!bMakeVisible)
pDocument->m_bEmbedded = TRUE;
if (!pDocument->OnNewDocument())
{
// user has been alerted to what failed in OnNewDocument
TRACE0("CDocument::OnNewDocument returned FALSE.\n");
if (bCreated)
{
pFrame->DestroyWindow(); // will destroy document
};
return NULL;
}
// it worked, now bump untitled count
//m_nUntitledCount++; // no need to count untitled docs!
}
else
{
// open an existing document
CWaitCursor wait;
bWasModified = pDocument->IsModified();
pDocument->SetModifiedFlag(FALSE); // not dirty for open
if (!pDocument->OnOpenDocument(lpszPathName))
{
// user has be alerted to what failed in OnOpenDocument
TRACE0("CDocument::OnOpenDocument returned FALSE.\n");
if (bCreated)
{
pFrame->DestroyWindow(); // will destroy document
}
else if (!pDocument->IsModified())
{
// original document is untouched
pDocument->SetModifiedFlag(bWasModified);
}
else
{
// we corrupted the original document
SetDefaultTitle(pDocument);
if (!pDocument->OnNewDocument())
{
TRACE0("Error: OnNewDocument failed after trying to open a document - trying to continue.\n");
// assume we can continue
}
}
return NULL; // open failed
}
pDocument->SetPathName(lpszPathName);
}
InitialUpdateFrame(pFrame, pDocument, bMakeVisible);
return pDocument;
}
void
COneDocTemplate::SetDefaultTitle(CDocument* pDocument)
{
CString strDocName;
if (!GetDocString(strDocName, CDocTemplate::docName) ||
strDocName.IsEmpty())
{
// use generic 'untitled'
VERIFY(strDocName.LoadString(AFX_IDS_UNTITLED));
}
pDocument->SetTitle(strDocName);
}
/////////////////////////////////////////////////////////////////////////////
// COneDocTemplate diagnostics
#ifdef _DEBUG
void
COneDocTemplate::AssertValid() const
{
CEGMultiDocTemplate::AssertValid();
ASSERT( m_docList.GetCount() <= 1 );
}
#endif //_DEBUG
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.