|
[code]#include "stdafx.h"
#include "RibbonTest.h"
#include "rxregsvc.h"
#include <accmd.h>
#include "tchar.h"
using namespace System;
using namespace Autodesk::Windows;
using namespace Autodesk::AutoCAD::Windows;
using namespace Autodesk::AutoCAD::Ribbon;
RibbonButton ^NewRibbonBtn(System::String ^text)
{
RibbonButton ^pButton = gcnew RibbonButton();
pButton->Text = text;
pButton->ShowText = true;
return pButton;
}
static void AddRibbon()
{
RibbonTab ^myRibbonTab = gcnew RibbonTab();
myRibbonTab->Title = "ARX Ribbon 测试";
myRibbonTab->Id = "ArxRibbonId";
RibbonPanel ^pPane1 = gcnew RibbonPanel();
RibbonPanelSource ^pPanel1Src = gcnew RibbonPanelSource();
pPanel1Src->Title = "ARX Panel 1";
pPane1->Source = pPanel1Src;
myRibbonTab->Panels->Add(pPane1);
RibbonButton ^pRbnBtnLine = NewRibbonBtn("直线");
pPanel1Src->Items->Add(pRbnBtnLine);
RibbonButton ^pRbnBtnCircle = NewRibbonBtn("圆");
pPanel1Src->Items->Add(pRbnBtnCircle);
RibbonPanel ^pPanel2 = gcnew RibbonPanel();
RibbonPanelSource ^panelSrc2 = gcnew RibbonPanelSource();
panelSrc2->Title = "ARX Panel 2";
pPanel2->Source = panelSrc2;
myRibbonTab->Panels->Add(pPanel2);
RibbonPaletteSet ^pPaletteSet = RibbonServices::RibbonPaletteSet;
RibbonControl ^pControl = pPaletteSet->RibbonControl;
pControl->Tabs->Add(myRibbonTab);
}
void init()
{
acedRegCmds->addCommand(_T("ArxRibbon"), _T("ArxRibbon"), _T("ArxRibbon"), ACRX_CMD_MODAL, AddRibbon);
}
void unload()
{
acedRegCmds->removeGroup(_T("ArxRibbon"));
}
extern "C" AcRx::AppRetCode acrxEntryPoint(AcRx::AppMsgCode msg, void* pkt)
{
switch (msg)
{
case AcRx::kNullMsg:
break;
case AcRx::kInitAppMsg:
acrxDynamicLinker->unlockApplication(pkt);
acrxDynamicLinker->registerAppMDIAware(pkt);
init();
break;
case AcRx::kUnloadAppMsg:
unload();
break;
case AcRx::kLoadDwgMsg:
break;
case AcRx::kUnloadDwgMsg:
break;
case AcRx::kInvkSubrMsg:
break;
case AcRx::kCfgMsg:
break;
case AcRx::kEndMsg:
break;
case AcRx::kQuitMsg:
break;
case AcRx::kSaveMsg:
break;
case AcRx::kDependencyMsg:
break;
case AcRx::kNoDependencyMsg:
break;
case AcRx::kOleUnloadAppMsg:
break;
case AcRx::kPreQuitMsg:
break;
case AcRx::kInitDialogMsg:
break;
case AcRx::kEndDialogMsg:
break;
case AcRx::kSuspendMsg:
break;
case AcRx::kInitTabGroupMsg:
break;
case AcRx::kEndTabGroupMsg:
break;
default:
break;
}
return AcRx::kRetOK;
}[/code] |
|