Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef XAP_GENERIC_PLUGIN_H
00034 #define XAP_GENERIC_PLUGIN_H
00035
00036
00037 #ifndef ABI_PLUGIN_NAME // allow easy redefinition
00038 #define ABI_PLUGIN_NAME AbiPlugin
00039 #endif
00040
00041
00042
00043 #ifndef ABI_PLUGIN_SOURCE
00044 #define ABI_PLUGIN_SOURCE __FILE__
00045 #endif
00046
00047
00048
00049 #include "ut_assert.h"
00050 #include "ut_debugmsg.h"
00051 #include "ut_path.h"
00052 #include "ut_sleep.h"
00053
00054 #include "ut_process.h"
00055
00056 #include "xap_App.h"
00057 #include "xap_DialogFactory.h"
00058 #include "xap_Dlg_FileOpenSaveAs.h"
00059 #include "xap_Frame.h"
00060 #include "xap_Menu_Layouts.h"
00061 #include "xap_Module.h"
00062 #include "xap_Prefs.h"
00063 #include "ap_Dialog_Id.h"
00064 #include "ap_Menu_Id.h"
00065 #include "ev_EditMethod.h"
00066 #include "ev_Menu.h"
00067 #include "ev_Menu_Actions.h"
00068 #include "ev_Menu_Labels.h"
00069 #include "ev_Menu_Layouts.h"
00070 #include "fg_Graphic.h"
00071 #include "fl_BlockLayout.h"
00072 #include "fp_Run.h"
00073 #include "fv_View.h"
00074 #include "ie_imp.h"
00075 #include "ie_impGraphic.h"
00076 #include "ie_exp.h"
00077 #include "ie_types.h"
00078
00079 #include <sys/types.h>
00080 #include <sys/stat.h>
00081
00082
00083
00084
00085
00086 #define ABI_PLUGIN_mk2str(x) # x
00087 #define ABI_PLUGIN_mkstr(x) ABI_PLUGIN_mk2str(x)
00088 #define ABI_PLUGIN_glue(a,b) a ## b
00089 #define ABI_PLUGIN_xglue(a,b) ABI_PLUGIN_glue(a,b)
00090 #define ABI_PLUGIN_METHODNAME(a) ABI_PLUGIN_xglue(ABI_PLUGIN_NAME,a)
00091
00092 #define ABI_PLUGIN_SCHEME ABI_PLUGIN_xglue(_,ABI_PLUGIN_xglue(ABI_PLUGIN_NAME,_))
00093 #define ABI_PLUGIN_SCHEME_NAME ABI_PLUGIN_mkstr(ABI_PLUGIN_SCHEME)
00094
00095
00096
00097
00098 #define ABI_PLUGIN_METHOD(m) ABI_PLUGIN_METHODNAME(_PluginCallback_##m)
00099 #define ABI_PLUGIN_METHOD_STR(m) ABI_PLUGIN_mkstr(ABI_PLUGIN_METHOD(m))
00100 #define DECLARE_ABI_PLUGIN_METHOD(m) \
00101 bool ABI_PLUGIN_METHOD(m)(AV_View* v, EV_EditMethodCallData *d)
00102
00103
00104
00105
00106
00107
00108
00109 #define ABI_GRAYABLE_MENUITEM(m) ABI_PLUGIN_METHODNAME(_MenuGrayState_##m)
00110 #define ABI_GRAYABLE_MENUITEM_PROTOTYPE(m) \
00111 EV_Menu_ItemState ABI_GRAYABLE_MENUITEM(m)(AV_View * pAV_View, XAP_Menu_Id id)
00112 #define DECLARE_ABI_GRAYABLE_MENUITEM(m,boolFunc) \
00113 ABI_GRAYABLE_MENUITEM_PROTOTYPE(m) \
00114 { \
00115 UT_UNUSED(pAV_View); \
00116 UT_UNUSED(id); \
00117 if (boolFunc()) \
00118 return EV_MIS_ZERO; \
00119 else \
00120 return EV_MIS_Gray; \
00121 }
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136 #define ABI_TOGGLEABLE_MENUITEM(m) ABI_PLUGIN_METHODNAME(_MenuToggleState_##m)
00137 #define ABI_TOGGLEABLE_MENUITEM_PROTOTYPE(m) \
00138 EV_Menu_ItemState ABI_TOGGLEABLE_MENUITEM(m)(AV_View * pAV_View, XAP_Menu_Id id)
00139 #define DECLARE_ABI_TOGGLEABLE_MENUITEM(m,boolFunc) \
00140 ABI_TOGGLEABLE_MENUITEM_PROTOTYPE(m) \
00141 { \
00142 if (boolFunc()) \
00143 return EV_MIS_ZERO; \
00144 else \
00145 return EV_MIS_Toggled; \
00146 }
00147
00148
00149
00150
00151
00152
00153
00154
00155 ABI_FAR_CALL
00156 int abi_plugin_register (XAP_ModuleInfo * mi);
00157
00158 ABI_FAR_CALL
00159 int abi_plugin_unregister (XAP_ModuleInfo * mi);
00160
00161 ABI_FAR_CALL
00162 int abi_plugin_supports_version (UT_uint32 major, UT_uint32 minor, UT_uint32 release);
00163
00164
00165
00166
00167
00168
00169
00170 extern XAP_Prefs * prefs;
00171 extern XAP_PrefsScheme * prefsScheme;
00172
00173 extern const gchar * szAbiPluginSchemeName;
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185 typedef struct AbiMenuOptions
00186 {
00187 const char * methodName;
00188 EV_EditMethod_pFn method;
00189 const char * label;
00190 const char * description;
00191 EV_Menu_LayoutFlags flags;
00192 bool hasSubMenu;
00193 bool hasDialog;
00194 bool checkBox;
00195 EV_GetMenuItemState_pFn pfnGetState;
00196 EV_GetMenuItemComputedLabel_pFn pfnGetDynLabel;
00197
00198 bool inMainMenu;
00199 bool inContextMenu;
00200 XAP_Menu_Id id;
00201 } AbiMenuOptions ;
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213 UT_Error addToMenus(AbiMenuOptions amo[], UT_uint32 num_menuitems, XAP_Menu_Id prevMM, XAP_Menu_Id prevCM);
00214 UT_Error removeFromMenus(const AbiMenuOptions amo[], UT_uint32 num_menuitems);
00215
00216
00217 bool getFileName(std::string &szFile, XAP_Frame * pFrame, XAP_Dialog_Id id,
00218 const char **szDescList, const char **szSuffixList, int *ft);
00219
00220
00221 bool isImageSelected (void);
00222
00223
00224 void plugin_imp_lockGUI(EV_EditMethodCallData *d);
00225 void plugin_imp_unlockGUI(EV_EditMethodCallData *d);
00226 #ifdef ABI_PLUGIN_DONT_LOCKGUI
00227 #define lockGUI(d)
00228 #define unlockGUI(d)
00229 #else
00230 #define lockGUI(d) plugin_imp_lockGUI(d)
00231 #define unlockGUI(d) plugin_imp_unlockGUI(d)
00232 #endif
00233
00234
00235
00236
00237
00238
00239
00240 XAP_ModuleInfo * getModuleInfo(void);
00241 bool doRegistration(void);
00242 void doUnregistration(void);
00243
00244
00245 #endif