486 lines
11 KiB
C
486 lines
11 KiB
C
#if !defined(__ARXENTRYPOINT_H__)
|
|
#define __ARXENTRYPOINT_H__
|
|
|
|
#if _MSC_VER > 1000
|
|
#pragma once
|
|
#endif // _MSC_VER > 1000
|
|
|
|
// Only can incule this file in Source file(.c/.cpp) Only one time!
|
|
// Do not include this file in other "Include file(.h/.hpp)"! --wyg
|
|
|
|
#define AEC_BEGIN_IMPLEMENT_CMD_MAP_ARXAPP_ENTRYPOINT_EX(CArxEntryApp) \
|
|
CArxEntryApp theArxEntryApp; \
|
|
extern "C" AcRx::AppRetCode acrxEntryPoint(AcRx::AppMsgCode msg, void* pkt) \
|
|
{ \
|
|
if (msg == AcRx::kInitAppMsg) \
|
|
{ \
|
|
|
|
#define AEC_BEGIN_IMPLEMENT_CMD_MAP_ARXAPP_ENTRYPOINT() \
|
|
AEC_BEGIN_IMPLEMENT_CMD_MAP_ARXAPP_ENTRYPOINT_EX(ArxEntryApp) \
|
|
|
|
#define ON_AEC_ARXCMD_GROUP(CArxCmdGroup) \
|
|
theArxEntryApp.AddArxCommandGroup(RUNTIME_CLASS(CArxCmdGroup)); \
|
|
|
|
#define ON_AEC_ADSCMD_GROUP(CAdsCmdGroup) \
|
|
theArxEntryApp.AddAdsCommandGroup(RUNTIME_CLASS(CAdsCmdGroup)); \
|
|
|
|
#define AEC_END_IMPLEMENT_CMD_MAP_ARXAPP_ENTRYPOINT() \
|
|
} \
|
|
return theArxEntryApp.DispatchEntryMsg(msg, pkt); \
|
|
} \
|
|
const ArxEntryApp* GetArxEntryApp() \
|
|
{ \
|
|
return &theArxEntryApp; \
|
|
} \
|
|
|
|
#define AEC_IMPLEMENT_ARXAPP_ENTRYPOINT(CArxEntryApp) \
|
|
AEC_BEGIN_IMPLEMENT_CMD_MAP_ARXAPP_ENTRYPOINT_EX(CArxEntryApp) \
|
|
AEC_END_IMPLEMENT_CMD_MAP_ARXAPP_ENTRYPOINT() \
|
|
|
|
#define AEC_IMPLEMENT_CMD_ARXAPP_ENTRYPOINT(CArxCmdGroup, CAdsCmdGroup) \
|
|
AEC_BEGIN_IMPLEMENT_CMD_MAP_ARXAPP_ENTRYPOINT() \
|
|
ON_AEC_ARXCMD_GROUP(CArxCmdGroup) \
|
|
ON_AEC_ADSCMD_GROUP(CAdsCmdGroup) \
|
|
AEC_END_IMPLEMENT_CMD_MAP_ARXAPP_ENTRYPOINT() \
|
|
|
|
#define AEC_IMPLEMENT_ARXCMD_ARXAPP_ENTRYPOINT(CArxCmdGroup) \
|
|
AEC_BEGIN_IMPLEMENT_CMD_MAP_ARXAPP_ENTRYPOINT() \
|
|
ON_AEC_ARXCMD_GROUP(CArxCmdGroup) \
|
|
AEC_END_IMPLEMENT_CMD_MAP_ARXAPP_ENTRYPOINT() \
|
|
|
|
#define AEC_IMPLEMENT_ADSCMD_ARXAPP_ENTRYPOINT(CAdsCmdGroup) \
|
|
AEC_BEGIN_IMPLEMENT_CMD_MAP_ARXAPP_ENTRYPOINT() \
|
|
ON_AEC_ADSCMD_GROUP(CAdsCmdGroup) \
|
|
AEC_END_IMPLEMENT_CMD_MAP_ARXAPP_ENTRYPOINT() \
|
|
|
|
|
|
|
|
#include "AecDebug.h"
|
|
#include "ArxEntryApp.h"
|
|
#include "ArxCmdGroup.h"
|
|
#include "AdsCmdGroup.h"
|
|
|
|
|
|
IMPLEMENT_DYNCREATE(ArxEntryApp, CObject)
|
|
|
|
ArxEntryApp::ArxEntryApp()
|
|
{
|
|
m_eCurMsg = AcRx::kNullMsg;
|
|
m_pCurParam = NULL;
|
|
m_pThisArxApp = NULL;
|
|
|
|
// Must be 1 --wyg
|
|
m_iArxFunCode = 1;
|
|
m_iAdsFunCode = 1;
|
|
}
|
|
|
|
ArxEntryApp::~ArxEntryApp()
|
|
{
|
|
}
|
|
|
|
void ArxEntryApp::AddArxCommandGroup(CRuntimeClass* pClass)
|
|
{
|
|
AECASSERT(pClass != NULL);
|
|
AECASSERT(pClass->IsDerivedFrom(RUNTIME_CLASS(ArxCmdGroup)));
|
|
AECASSERT(GetArxCommandGroup(pClass) == NULL);
|
|
ArxCmdGroup* pArxCmdGroup = (ArxCmdGroup*)pClass->CreateObject();
|
|
AECASSERT(pArxCmdGroup != NULL);
|
|
pArxCmdGroup->m_pArxEntryApp = this;
|
|
m_arArxCmdGroups.Add(pArxCmdGroup);
|
|
}
|
|
|
|
void ArxEntryApp::AddAdsCommandGroup(CRuntimeClass* pClass)
|
|
{
|
|
AECASSERT(pClass != NULL);
|
|
AECASSERT(pClass->IsDerivedFrom(RUNTIME_CLASS(AdsCmdGroup)));
|
|
AECASSERT(GetAdsCommandGroup(pClass) == NULL);
|
|
AdsCmdGroup* pAdsCmdGroup = (AdsCmdGroup*)pClass->CreateObject();
|
|
AECASSERT(pAdsCmdGroup != NULL);
|
|
pAdsCmdGroup->m_pArxEntryApp = this;
|
|
m_arAdsCmdGroups.Add(pAdsCmdGroup);
|
|
}
|
|
|
|
ArxCmdGroup* ArxEntryApp::GetArxCommandGroup(CRuntimeClass* pClass)
|
|
{
|
|
AECASSERT(pClass != NULL);
|
|
ArxCmdGroup* pArxCmdGroup;
|
|
int iSize = m_arArxCmdGroups.GetSize();
|
|
for (int i = 0; i < iSize; i++)
|
|
{
|
|
pArxCmdGroup = m_arArxCmdGroups[i];
|
|
AECASSERT(pArxCmdGroup != NULL);
|
|
if (pArxCmdGroup->IsKindOf(pClass))
|
|
return pArxCmdGroup;
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
AdsCmdGroup* ArxEntryApp::GetAdsCommandGroup(CRuntimeClass* pClass)
|
|
{
|
|
AECASSERT(pClass != NULL);
|
|
AdsCmdGroup* pAdsCmdGroup;
|
|
int iSize = m_arAdsCmdGroups.GetSize();
|
|
for (int i = 0; i < iSize; i++)
|
|
{
|
|
pAdsCmdGroup = m_arAdsCmdGroups[i];
|
|
AECASSERT(pAdsCmdGroup != NULL);
|
|
if (pAdsCmdGroup->IsKindOf(pClass))
|
|
return pAdsCmdGroup;
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
AcRx::AppRetCode ArxEntryApp::DispatchEntryMsg(AcRx::AppMsgCode eMsg, void* pParam)
|
|
{
|
|
m_eCurMsg = eMsg;
|
|
m_pCurParam = pParam;
|
|
AcRx::AppRetCode eRetCode = AcRx::kRetOK;
|
|
|
|
switch (eMsg)
|
|
{
|
|
case AcRx::kInitAppMsg:
|
|
m_pThisArxApp = pParam;
|
|
eRetCode = On_PreInitAppMsg();
|
|
break;
|
|
case AcRx::kLoadDwgMsg:
|
|
eRetCode = On_kLoadDwgMsg();
|
|
break;
|
|
case AcRx::kUnloadDwgMsg:
|
|
eRetCode = On_kUnloadDwgMsg();
|
|
break;
|
|
case AcRx::kInvkSubrMsg:
|
|
eRetCode = On_kInvkSubrMsg();
|
|
break;
|
|
case AcRx::kInitDialogMsg:
|
|
eRetCode = On_kInitDialogMsg((CAdUiTabExtensionManager*)pParam);
|
|
break;
|
|
case AcRx::kEndDialogMsg:
|
|
eRetCode = On_kEndDialogMsg();
|
|
break;
|
|
case AcRx::kNullMsg:
|
|
eRetCode = On_kNullMsg();
|
|
break;
|
|
case AcRx::kCfgMsg:
|
|
eRetCode = On_kCfgMsg();
|
|
break;
|
|
case AcRx::kOleUnloadAppMsg:
|
|
eRetCode = On_kOleUnloadAppMsg();
|
|
break;
|
|
case AcRx::kDependencyMsg:
|
|
eRetCode = On_kDependencyMsg();
|
|
break;
|
|
case AcRx::kNoDependencyMsg:
|
|
eRetCode = On_kNoDependencyMsg();
|
|
break;
|
|
case AcRx::kSaveMsg:
|
|
eRetCode = On_kSaveMsg();
|
|
break;
|
|
case AcRx::kEndMsg:
|
|
eRetCode = On_kEndMsg();
|
|
break;
|
|
case AcRx::kPreQuitMsg:
|
|
eRetCode = On_kPreQuitMsg();
|
|
break;
|
|
case AcRx::kQuitMsg:
|
|
eRetCode = On_kQuitMsg();
|
|
break;
|
|
case AcRx::kUnloadAppMsg:
|
|
eRetCode = On_kUnloadAppMsg();
|
|
break;
|
|
}
|
|
|
|
return eRetCode;
|
|
}
|
|
|
|
void ArxEntryApp::LockApplication()
|
|
{
|
|
AECASSERT(m_pThisArxApp != NULL);
|
|
|
|
acrxDynamicLinker->lockApplication(m_pThisArxApp);
|
|
}
|
|
|
|
void ArxEntryApp::UnlockApplication()
|
|
{
|
|
AECASSERT(m_pThisArxApp != NULL);
|
|
|
|
acrxDynamicLinker->unlockApplication(m_pThisArxApp);
|
|
}
|
|
|
|
void* ArxEntryApp::GetThisArxApp()
|
|
{
|
|
return m_pThisArxApp;
|
|
}
|
|
|
|
AcRx::AppRetCode ArxEntryApp::On_PreInitAppMsg()
|
|
{
|
|
AECASSERT(m_pThisArxApp != NULL);
|
|
|
|
acrxDynamicLinker->unlockApplication(m_pThisArxApp);
|
|
acrxDynamicLinker->registerAppMDIAware(m_pThisArxApp);
|
|
|
|
return On_kInitAppMsg();
|
|
}
|
|
|
|
AcRx::AppRetCode ArxEntryApp::On_kInitAppMsg()
|
|
{
|
|
ArxCmdGroup* pArxCmdGroup;
|
|
int iSize = m_arArxCmdGroups.GetSize();
|
|
for (int i = 0; i < iSize; i++)
|
|
{
|
|
pArxCmdGroup = m_arArxCmdGroups[i];
|
|
AECASSERT(pArxCmdGroup != NULL);
|
|
pArxCmdGroup->OnAddCommands();
|
|
}
|
|
|
|
return AcRx::kRetOK;
|
|
}
|
|
|
|
AcRx::AppRetCode ArxEntryApp::On_kUnloadAppMsg()
|
|
{
|
|
ArxCmdGroup* pArxCmdGroup;
|
|
int iSize = m_arArxCmdGroups.GetSize();
|
|
int i = 0;
|
|
for (i = 0; i < iSize; i++)
|
|
{
|
|
pArxCmdGroup = m_arArxCmdGroups[i];
|
|
AECASSERT(pArxCmdGroup != NULL);
|
|
pArxCmdGroup->OnRemoveCommands();
|
|
delete pArxCmdGroup;
|
|
}
|
|
|
|
AdsCmdGroup* pAdsCmdGroup;
|
|
iSize = m_arAdsCmdGroups.GetSize();
|
|
for (i = 0; i < iSize; i++)
|
|
{
|
|
pAdsCmdGroup = m_arAdsCmdGroups[i];
|
|
AECASSERT(pAdsCmdGroup != NULL);
|
|
delete pAdsCmdGroup;
|
|
}
|
|
|
|
return AcRx::kRetOK;
|
|
}
|
|
|
|
AcRx::AppRetCode ArxEntryApp::On_kLoadDwgMsg()
|
|
{
|
|
AdsCmdGroup* pAdsCmdGroup;
|
|
int iSize = m_arAdsCmdGroups.GetSize();
|
|
for (int i = 0; i < iSize; i++)
|
|
{
|
|
pAdsCmdGroup = m_arAdsCmdGroups[i];
|
|
AECASSERT(pAdsCmdGroup != NULL);
|
|
pAdsCmdGroup->OnAddCommands();
|
|
}
|
|
|
|
return AcRx::kRetOK;
|
|
}
|
|
|
|
AcRx::AppRetCode ArxEntryApp::On_kUnloadDwgMsg()
|
|
{
|
|
AdsCmdGroup* pAdsCmdGroup;
|
|
int iSize = m_arAdsCmdGroups.GetSize();
|
|
for (int i = 0; i < iSize; i++)
|
|
{
|
|
pAdsCmdGroup = m_arAdsCmdGroups[i];
|
|
AECASSERT(pAdsCmdGroup != NULL);
|
|
pAdsCmdGroup->OnRemoveCommands();
|
|
}
|
|
|
|
return AcRx::kRetOK;
|
|
}
|
|
|
|
AcRx::AppRetCode ArxEntryApp::On_kInvkSubrMsg()
|
|
{
|
|
AdsCmdGroup* pAdsCmdGroup;
|
|
int iSize = m_arAdsCmdGroups.GetSize();
|
|
for (int i = 0; i < iSize; i++)
|
|
{
|
|
pAdsCmdGroup = m_arAdsCmdGroups[i];
|
|
AECASSERT(pAdsCmdGroup != NULL);
|
|
pAdsCmdGroup->OnInvkSubCommand();
|
|
}
|
|
|
|
return AcRx::kRetOK;
|
|
}
|
|
|
|
AcRx::AppRetCode ArxEntryApp::On_kInitDialogMsg(CAdUiTabExtensionManager* pTabMgr)
|
|
{
|
|
return AcRx::kRetOK;
|
|
}
|
|
|
|
AcRx::AppRetCode ArxEntryApp::On_kEndDialogMsg()
|
|
{
|
|
return AcRx::kRetOK;
|
|
}
|
|
|
|
AcRx::AppRetCode ArxEntryApp::On_kNullMsg()
|
|
{
|
|
return AcRx::kRetOK;
|
|
}
|
|
|
|
AcRx::AppRetCode ArxEntryApp::On_kCfgMsg()
|
|
{
|
|
return AcRx::kRetOK;
|
|
}
|
|
|
|
AcRx::AppRetCode ArxEntryApp::On_kOleUnloadAppMsg()
|
|
{
|
|
return AcRx::kRetOK;
|
|
}
|
|
|
|
AcRx::AppRetCode ArxEntryApp::On_kDependencyMsg()
|
|
{
|
|
return AcRx::kRetOK;
|
|
}
|
|
|
|
AcRx::AppRetCode ArxEntryApp::On_kNoDependencyMsg()
|
|
{
|
|
return AcRx::kRetOK;
|
|
}
|
|
|
|
AcRx::AppRetCode ArxEntryApp::On_kSuspendMsg()
|
|
{
|
|
return AcRx::kRetOK;
|
|
}
|
|
|
|
AcRx::AppRetCode ArxEntryApp::On_kSaveMsg()
|
|
{
|
|
return AcRx::kRetOK;
|
|
}
|
|
|
|
AcRx::AppRetCode ArxEntryApp::On_kEndMsg()
|
|
{
|
|
return AcRx::kRetOK;
|
|
}
|
|
|
|
AcRx::AppRetCode ArxEntryApp::On_kPreQuitMsg()
|
|
{
|
|
return AcRx::kRetOK;
|
|
}
|
|
|
|
AcRx::AppRetCode ArxEntryApp::On_kQuitMsg()
|
|
{
|
|
return AcRx::kRetOK;
|
|
}
|
|
|
|
|
|
IMPLEMENT_DYNAMIC(ArxCmdGroup, CObject)
|
|
|
|
ArxCmdGroup::ArxCmdGroup()
|
|
{
|
|
m_pArxEntryApp = NULL;
|
|
}
|
|
|
|
ArxCmdGroup::~ArxCmdGroup()
|
|
{
|
|
}
|
|
|
|
LPCTSTR ArxCmdGroup::GetStringFromId(int iID)
|
|
{
|
|
return NULL;
|
|
}
|
|
|
|
void ArxCmdGroup::OnAddCommands()
|
|
{
|
|
AcRxFunctionPtr pfnMainProc = OnGetMainProc();
|
|
AECASSERT(pfnMainProc != NULL);
|
|
ArxCmdInfo* pCmdEntry = OnGetCmdEntry();
|
|
AECASSERT(pCmdEntry != NULL);
|
|
LPCTSTR pszGroupName = OnGetGroupName();
|
|
AECASSERT(pszGroupName != NULL);
|
|
int iSize = OnGetCmdEntrySize();
|
|
for (int i = 0; i < iSize; i++, m_pArxEntryApp->m_iArxFunCode++)
|
|
{
|
|
pCmdEntry[i].pszGroup = pszGroupName;
|
|
pCmdEntry[i].iFunCode = m_pArxEntryApp->m_iArxFunCode;
|
|
if (pCmdEntry[i].idLocal > 0)
|
|
{
|
|
acedRegCmds->addCommand(pszGroupName, pCmdEntry[i].pszInter,
|
|
GetStringFromId(pCmdEntry[i].idLocal), pCmdEntry[i].lFlags,
|
|
pfnMainProc, NULL, m_pArxEntryApp->m_iArxFunCode);
|
|
}
|
|
else
|
|
{
|
|
acedRegCmds->addCommand(pszGroupName, pCmdEntry[i].pszInter,
|
|
pCmdEntry[i].pszLocal, pCmdEntry[i].lFlags,
|
|
pfnMainProc, NULL, m_pArxEntryApp->m_iArxFunCode);
|
|
}
|
|
}
|
|
}
|
|
|
|
void ArxCmdGroup::OnRemoveCommands()
|
|
{
|
|
LPCTSTR pszGroupName = OnGetGroupName();
|
|
AECASSERT(pszGroupName != NULL);
|
|
acedRegCmds->removeGroup(pszGroupName);
|
|
}
|
|
|
|
void ArxCmdGroup::OnInvkSubCommand()
|
|
{
|
|
ArxCmdInfo* pCmdEntry = OnGetCmdEntry();
|
|
AECASSERT(pCmdEntry != NULL && OnGetCmdEntrySize() > 0);
|
|
int iFunCode = acedGetFunCode();
|
|
int iFunIndex = iFunCode - pCmdEntry[0].iFunCode;
|
|
if (iFunIndex < 0 || iFunIndex >= OnGetCmdEntrySize()
|
|
|| pCmdEntry[iFunIndex].iFunCode != iFunCode)
|
|
return;
|
|
(this->*pCmdEntry[iFunIndex].pFnCmd)();
|
|
}
|
|
|
|
IMPLEMENT_DYNAMIC(AdsCmdGroup, CObject)
|
|
|
|
AdsCmdGroup::AdsCmdGroup()
|
|
{
|
|
m_pArxEntryApp = NULL;
|
|
}
|
|
|
|
AdsCmdGroup::~AdsCmdGroup()
|
|
{
|
|
}
|
|
|
|
void AdsCmdGroup::OnAddCommands()
|
|
{
|
|
AdsCmdInfo* pCmdEntry = OnGetCmdEntry();
|
|
AECASSERT(pCmdEntry != NULL);
|
|
int iSize = OnGetCmdEntrySize();
|
|
for (int i = 0; i < iSize; i++, m_pArxEntryApp->m_iAdsFunCode++)
|
|
{
|
|
pCmdEntry[i].iFunCode = m_pArxEntryApp->m_iAdsFunCode;
|
|
if (acedDefun(pCmdEntry[i].pszName, m_pArxEntryApp->m_iAdsFunCode) == RTNORM)
|
|
{
|
|
// not use or to be repaired
|
|
// if (pCmdEntry[i].bRegFunc)
|
|
// acedRegFunc(pCmdEntry[i].pFnCmd, m_pArxEntryApp->m_iAdsFunCode);
|
|
}
|
|
}
|
|
}
|
|
|
|
void AdsCmdGroup::OnRemoveCommands()
|
|
{
|
|
AdsCmdInfo* pCmdEntry = OnGetCmdEntry();
|
|
AECASSERT(pCmdEntry != NULL);
|
|
int iSize = OnGetCmdEntrySize();
|
|
for (int i = 0; i < iSize; i++)
|
|
{
|
|
acedUndef(pCmdEntry[i].pszName, pCmdEntry[i].iFunCode);
|
|
}
|
|
}
|
|
|
|
void AdsCmdGroup::OnInvkSubCommand()
|
|
{
|
|
AdsCmdInfo* pCmdEntry = OnGetCmdEntry();
|
|
AECASSERT(pCmdEntry != NULL && OnGetCmdEntrySize() > 0);
|
|
int iFunCode = acedGetFunCode();
|
|
int iFunIndex = iFunCode - pCmdEntry[0].iFunCode;
|
|
if (iFunIndex < 0 || iFunIndex >= OnGetCmdEntrySize()
|
|
|| pCmdEntry[iFunIndex].iFunCode != iFunCode)
|
|
return;
|
|
#ifdef RENDER
|
|
// not use or to be repaired
|
|
// if (pCmdEntry[iFunIndex].bRenderCmd)
|
|
// InitRender(false);
|
|
#endif // RENDER
|
|
if (!(this->*pCmdEntry[iFunIndex].pFnCmd)())
|
|
acedRetVoid();
|
|
}
|
|
|
|
#endif // __ARXENTRYPOINT_H__
|