📄 extdatamodel.cpp
字号:
// ExtDataModel.cpp: implementation of the CExtDataModel class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "ExtDataModel.h"
#include "BSample.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
/////////////////////////////////////////////////////////////////////////////
// CExtDataModel construction/destruction
IMPLEMENT_SERIAL(CExtDataModel, CFODataModel, 0)
CExtDataModel::CExtDataModel()
{
//FOTO:Add you code here.
}
CExtDataModel::CExtDataModel(const CExtDataModel& /*source*/)
{
}
CExtDataModel::~CExtDataModel()
{
//FOTO:Add you code here.
}
void CExtDataModel::DoInitData()
{
CFODataModel::DoInitData();
//FOTO:Add you code here.
}
void CExtDataModel::DoInitCreateShape(CFODrawShape *pShape)
{
pShape;
}
void CExtDataModel::NotifyObserver(LPARAM lHint, CObject*pHint)
{
CFODataModel::NotifyObserver(lHint,pHint);
//FOTO:Add you code here.
}
void CExtDataModel::UpdateTitle()
{
CFODataModel::UpdateTitle();
// if(m_pOwner == NULL)
// {
// return;
// }
//
// if(m_pOwner->GetSafeHwnd() != NULL)
// {
// if(m_pOwner ->IsKindOf(RUNTIME_CLASS(CFODrawView)))
// {
// CFODrawView *pView = (CFODrawView *) m_pOwner;
// CDocument *m_pDocument = (CDocument *)pView->GetDocument();
// if(m_pDocument != NULL)
// {
// if (m_strTitleOrg.IsEmpty() && !m_pDocument->GetTitle().IsEmpty())
// m_strTitleOrg = m_pDocument->GetTitle();
//
// if (!m_strTitleOrg.IsEmpty())
// {
// TCHAR szStr[256+_MAX_PATH];
// _tcscpy(szStr, m_strTitleOrg);
// if (IsDirty())
// {
// if(m_strTitleOrg.Find(_T("*"))<0)
// {
// lstrcat(szStr, _T(" *"));
// }
// }
// if (m_pDocument->GetTitle() != szStr)
// {
// m_pDocument->SetTitle(szStr);
// m_pDocument->UpdateFrameCounts();
// }
// }
// }
// }
// }
}
void CExtDataModel::DoActionChange(const CFOBaseAction* pAction)
{
CFODataModel::DoActionChange(pAction);
// FODO:Add your own specify code here.
}
CString CExtDataModel::CreateBaseName(UINT nType)
{
/*switch(nType)
{
case MY_DROPMENUBUTTON:
{
return _T("DropMenuButton");
}
break;
case MY_DROPCOLORBUTTON:
{
return _T("DropColorButton");
}
break;
default:
{*/
return CFODataModel::CreateBaseName(nType);
/*}
break;
}*/
}
CString CExtDataModel::CreateBaseCaption(UINT nType)
{
/*switch(nType)
{
case MY_DROPMENUBUTTON:
{
return _T("Drop Menu Button");
}
break;
case MY_DROPCOLORBUTTON:
{
return _T("Color");
}
break;
default:
{*/
return CFODataModel::CreateBaseCaption(nType);
/*}
break;
}*/
}
CString CExtDataModel::GetUniqueName(UINT nType)
{
return CFODataModel::GetUniqueName(nType);
}
CString CExtDataModel::GetUniqueCaption(UINT nType)
{
return CFODataModel::GetUniqueCaption(nType);
}
CFODrawShape *CExtDataModel::DoCreateShapeByType(UINT m_drawshape,
CRect &rcCreate,
CString strFileName,
CFOToolBoxItem *pCurItem)
{
CFODrawShape *pReturn = NULL;
/*CString strCaption;
CString strName;
strCaption = "";
strName = "";
CPoint ptTrack = rcCreate.TopLeft();
if(m_drawshape != FO_COMP_NONE)
{
CRect rc(rcCreate);
rc.NormalizeRect();
if(rc.IsRectEmpty()||(rc.Width()<=10 && rc.Height()<20))
{
switch(m_drawshape)
{
case MY_DROPMENUBUTTON:
{
rc = CRect(ptTrack.x-80,ptTrack.y-15,ptTrack.x+80,ptTrack.y+15);
}
break;
case MY_DROPCOLORBUTTON:
{
rc = CRect(ptTrack.x-80,ptTrack.y-15,ptTrack.x+80,ptTrack.y+15);
}
break;
default:
{
}
break;
}
}
switch(m_drawshape)
{
case MY_DROPMENUBUTTON:
{
pReturn = new CMyDropMenuButtonShape;
pReturn->AddRef();
pReturn->Create(rc,"");
pReturn->UpdatePosition();
strCaption = GetUniqueCaption(pReturn->GetType());
strName = GetUniqueName(pReturn->GetType());
pReturn->SetObjectCaption(strCaption);
pReturn->SetObjectName(strName);
}
break;
case MY_DROPCOLORBUTTON:
{
pReturn = new CMyColorPickerShape;
pReturn->AddRef();
pReturn->Create(rc,"");
pReturn->UpdatePosition();
strCaption = GetUniqueCaption(pReturn->GetType());
strName = GetUniqueName(pReturn->GetType());
pReturn->SetObjectCaption(strCaption);
pReturn->SetObjectName(strName);
}
break;
default:
{*/
pReturn = CFODataModel::DoCreateShapeByType(m_drawshape,rcCreate,strFileName);
/*}
break;
}
}*/
return pReturn;
}
CFOCompositeShape *CExtDataModel::DoCreateCompositeShapeByType(UINT m_drawshape,
CRect &rcCreate,
CArray<FOPORTVALUE,FOPORTVALUE> *arInitPorts,
CString strFileName,
UINT nResID,
CFOToolBoxItem *pCurItem)
{
CFOCompositeShape *pReturn = CFODataModel::DoCreateCompositeShapeByType(m_drawshape,
rcCreate,
arInitPorts,
strFileName,
nResID,
pCurItem);
// FODO: Add your own specify code here.
return pReturn;
}
void CExtDataModel::SetModifiedFlag(BOOL b)
{
CFODataModel::SetModifiedFlag(b);
//FOTO:Add you code here.
}
BOOL CExtDataModel::IsModified()
{
//FOTO:Add you code here.
return CFODataModel::IsModified();
}
void CExtDataModel::Serialize(CArchive& ar)
{
CFODataModel::Serialize(ar);
if(ar.IsStoring())
{
//FOTO:Add you code here.
}
else
{
//FOTO:Add you code here.
}
}
/////////////////////////////////////////////////////////////////////////////
// CPrintBaseJob serialization
CFile* CExtDataModel::GetFile(LPCTSTR lpszFileName, UINT nOpenFlags,
CFileException* pError)
{
CMirrorFile* pFile = new CMirrorFile;
ASSERT(pFile != NULL);
if (!pFile->Open(lpszFileName, nOpenFlags, pError))
{
delete pFile;
pFile = NULL;
}
return pFile;
}
void CExtDataModel::ReleaseFile(CFile* pFile, BOOL bAbort)
{
ASSERT_KINDOF(CFile, pFile);
if (bAbort)
pFile->Abort(); // will not throw an exception
else
pFile->Close();
delete pFile;
}
BOOL CExtDataModel::OpenDocument(LPCTSTR lpszPathName)
{
CFileException fe;
CFile* pFile = GetFile(lpszPathName,
CFile::modeRead|CFile::shareDenyWrite, &fe);
if (pFile == NULL)
{
return FALSE;
}
strCurOpenFormFile = CString(lpszPathName);
CArchive loadArchive(pFile, CArchive::load | CArchive::bNoFlushOnDelete);
loadArchive.m_bForceFlat = FALSE;
TRY
{
CWaitCursor wait;
if (pFile->GetLength() != 0)
Serialize(loadArchive); // load me
loadArchive.Close();
ReleaseFile(pFile, FALSE);
}
CATCH_ALL(e)
{
ReleaseFile(pFile, TRUE);
return FALSE;
}
END_CATCH_ALL
return TRUE;
}
BOOL CExtDataModel::SaveDocument(LPCTSTR lpszPathName)
{
CFileException fe;
CFile* pFile = NULL;
pFile = GetFile(lpszPathName, CFile::modeCreate |
CFile::modeReadWrite | CFile::shareExclusive, &fe);
if (pFile == NULL)
{
return FALSE;
}
strCurOpenFormFile = CString(lpszPathName);
CArchive saveArchive(pFile, CArchive::store | CArchive::bNoFlushOnDelete);
saveArchive.m_bForceFlat = FALSE;
TRY
{
CWaitCursor wait;
Serialize(saveArchive); // save me
saveArchive.Close();
ReleaseFile(pFile, FALSE);
}
CATCH_ALL(e)
{
ReleaseFile(pFile, TRUE);
return FALSE;
}
END_CATCH_ALL
return TRUE; // success
}
void CExtDataModel::OnDrawShape(CDC *pDC,const CRect &rcView)
{
CFODataModel::OnDrawShape(pDC,rcView);
//FOTO:Add you code here.
}
void CExtDataModel::OnDrawBack(CDC *pDC)
{
CFODataModel::OnDrawBack(pDC);
//FOTO:Add you code here.
}
/////////////////////////////////////////////////////////////////////////////
// CExtDataModel diagnostics
#ifdef _DEBUG
void CExtDataModel::AssertValid() const
{
CFODataModel::AssertValid();
}
void CExtDataModel::Dump(CDumpContext& dc) const
{
CFODataModel::Dump(dc);
}
#endif //_DEBUG
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -