??在illustrator SDK中,提供了一个类,可以通过修改这个类来开发新的插件。头文件代码如下:
class Plugin
{
protected:SPPluginRef fPluginRef;char fPluginName[kMaxStringLength];//插件名称Suites *fSuites;//套件指针int fLockCount;SPAccessRef fPluginAccess;ASErr fLastError;long fErrorTimeout;ASBoolean fSupressDuplicateErrors;time_t fLastErrorTime;public:Plugin(SPPluginRef pluginRef);Plugin() {}virtual ~Plugin();void *operator new(size_t size);void operator delete(void *pMem);ASBoolean SuitesAcquired() { return fSuites != nil; }virtual void ReportError(ASErr error, char *caller, char *selector, void *message);static void DefaultError(SPPluginRef ref, ASErr error);static ASBoolean FilterError(ASErr error);SPPluginRef GetPluginRef() { return fPluginRef; }virtual ASErr LockPlugin(ASBoolean lock);static ASBoolean IsReloadMsg(char *caller, char *selector);virtual ASErr StartupPlugin(SPInterfaceMessage *message); virtual ASErr PostStartupPlugin(); virtual ASErr ShutdownPlugin(SPInterfaceMessage *message); virtual ASErr UnloadPlugin(SPInterfaceMessage *message);virtual ASErr ReloadPlugin(SPInterfaceMessage *message);virtual ASErr AcquireProperty(SPPropertiesMessage *message);virtual ASErr ReleaseProperty(SPPropertiesMessage *message);virtual void GetPluginName(char *name, unsigned int maxlen);virtual ASBoolean Purge();virtual ASErr Message(char *caller, char *selector, void *message);virtual ASErr SetGlobal(Plugin *plugin);virtual ASErr AllocateSuiteTables();virtual ASErr FillSuiteTables();virtual ASErr EmptySuiteTables();virtual ASErr AcquireOptionalSuites();virtual ASErr Notify(AINotifierMessage *message);virtual ASErr GoAction(DoActionMessage *message);virtual ASErr GoMenuItem(AIMenuMessage *message);virtual ASErr UpdateMenuItem(AIMenuMessage *message);virtual ASErr GetFilterParameters(AIFilterMessage *message);virtual ASErr GoFilter(AIFilterMessage *message);virtual ASErr PluginGroupNotify(AIPluginGroupMessage *message);virtual ASErr PluginGroupUpdate(AIPluginGroupMessage *message);virtual ASErr GetFileFormatParameters(AIFileFormatMessage *message);virtual ASErr GoFileFormat(AIFileFormatMessage *message);virtual ASErr CheckFileFormat(AIFileFormatMessage *message);virtual ASErr FileFormatUpdate(AIUpdateFileFormatMessage *message);virtual ASErr SetFileFormatParameters(DoActionMessage *message);virtual ASErr EditTool(AIToolMessage *message);virtual ASErr TrackToolCursor(AIToolMessage *message);virtual ASErr ToolMouseDown(AIToolMessage *message);virtual ASErr ToolMouseDrag(AIToolMessage *message);virtual ASErr ToolMouseUp(AIToolMessage *message);virtual ASErr SelectTool(AIToolMessage *message);virtual ASErr DeselectTool(AIToolMessage *message);virtual ASErr ReselectTool(AIToolMessage *message);virtual ASErr DecreaseDiameter(AIToolMessage *message);virtual ASErr IncreaseDiameter(AIToolMessage *message);virtual ASErr EditLiveEffectParameters(AILiveEffectEditParamMessage * message);virtual ASErr GoLiveEffect(AILiveEffectGoMessage * message);virtual ASErr LiveEffectInterpolate(AILiveEffectInterpParamMessage * message);virtual ASErr LiveEffectGetInputType(AILiveEffectInputTypeMessage * message);virtual ASErr LiveEffectConvertColorSpace(AILiveEffectConvertColorMessage * message);virtual ASErr LiveEffectScaleParameters(AILiveEffectScaleParamMessage * message);virtual ASErr LiveEffectAdjustColors(AILiveEffectAdjustColorsMessage * message);virtual ASErr LiveEffectHandleMerge(AILiveEffectHandleMergeMessage * message);virtual ASErr GoTimer(AITimerMessage * message);virtual ASErr GoClipboard( AIClipboardMessage *message );virtual ASErr CanCopyClipboard( AIClipboardMessage *message );virtual ASErr CloneClipboard( AIClipboardMessage *message );virtual ASErr DisposeClipboard( AIClipboardMessage *message );virtual ASErr WorkspaceWrite( AIWorkspaceMessage *message );virtual ASErr WorkspaceRestore( AIWorkspaceMessage *message );virtual ASErr WorkspaceDefault( AIWorkspaceMessage *message );private:static char *FindMsg(SPPluginRef ref, ASErr error, char *buf, int len);
};
??这个类里大部分是分发部分的消息处理。先查看下,SDK提供的启动函数,代码如下所示:
ASErr Plugin::StartupPlugin(SPInterfaceMessage *message)
{ASErr error = kNoErr;if (!error)error = SetGlobal(this);//全局函数操作(空)fSuites = new(std::nothrow) Suites;//加载模块if (!fSuites)error = kOutOfMemoryErr;else{error = fSuites->Error();//是否发生错误fSuites->InitializeRefCount();//初始化引用计数}if (error){if (fSuites)delete fSuites;fSuites = nil;}if (!error){if(!error)error = sSPPlugins->SetPluginName( message->d.self, fPluginName );//设置插件名称if (!error){char notifierName[kMaxStringLength];sprintf(notifierName, "%s App Started Notifier", fPluginName);//应用程序启动通知error = sAINotifier->AddNotifier(message->d.self, notifierName, kAIApplicationStartedNotifier, NULL);}}if (!error)error = AllocateSuiteTables();if (!error)FillSuiteTables();if(!error)error = Plugin::LockPlugin(true);//增加引用计数return error;
}
??在插件的启动消息里,最主要是实现了需要使用到的系统其它模块的加载和插件的命名。
??欢迎光临知了软件开发网络平台,本公司定制开发各类软件,主要方向为桌面专业软件开发和插件定制开发,桌面软件主要包括文字图形识别类软件,信息管理类软件,3D打印类软件,视频类软件以及其它涉及专业的各类图形图像处理软件。插件包含AE插件,AI插件,PS插件,PDF插件,3DMAX插件以及Word,Excel等Office插件开发。详情请咨询,微信QQ:312117271,手机:18928899728,邮箱: anjingzhi_sea@163.com.
公司网址:http://www.zhiliaos.com