home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / mesaaiok.zip / source / extaddin.h < prev    next >
C/C++ Source or Header  |  1995-10-24  |  19KB  |  377 lines

  1. /**************************************************************************
  2.  *                                                                        *
  3.  *                                                                        *
  4.  *          This code is copyright (c) 1995                               *
  5.  *                     Athena Design, Inc.                                *
  6.  *                                                                        *
  7.  *                                                                        *
  8.  *                ALL RIGHTS RESERVED                                     *
  9.  *                                                                        *
  10.  *                                                                        *
  11.  *                                                                        *
  12.  *                                                                        *
  13.  *                                                                        *
  14.  **************************************************************************/
  15.  
  16. /*
  17.     This is the external file that must be used be include'd by custom
  18.     AddIn's that will be linked into Mesa.  This file may be included in
  19.     either a C or C++ program.
  20.     
  21.     All functionality is performed via a call the the performAddInFunction()
  22.     function.  The first parameter is an integer that denotes the function to
  23.     be performed.  Additional parameters and the return value is different for each
  24.     function.  Please see the "forthcoming" documentation.
  25.     
  26.     This file is under construction.  All of the documented calls are implemented
  27.     unless there are specific implementation notes within the documentation.  The
  28.     functions that are labeled "FINISH" simply need to be hooked up to the
  29.     model code.  The functions labeled ???? may be finished or may need additional
  30.     work at the model or controller level to finish them.  4/26/95 DPP
  31. */
  32.  
  33. #ifndef _MH_ExternalAddIn_h
  34.  
  35. #define _MH_ExternalAddIn_h
  36.  
  37. #include <stdarg.h>
  38.  
  39. #ifdef __cplusplus
  40. extern "C"
  41. {
  42. #endif
  43.  
  44. #if defined(__HIGHC__) || !defined(M2Z)
  45. extern int performAddInFunction(int,...);
  46. #else
  47. extern int _System performAddInFunction(int,...);
  48. #endif
  49.  
  50. // Routines for dealing with Mesa's memory management instead of the compilers.
  51. // They all work like thier C equivilents
  52. extern void MFree(void *);
  53. extern char *MRealloc(void *,int);
  54. extern char *MMalloc(int);
  55.  
  56.  
  57. // the current list of commands
  58.  
  59. // HWND performAddInFunction(getMenuWindowMesaAddIn);
  60. // returns the handle to the application menu or 0 if there is no
  61. // application menu
  62. #define getMenuWindowMesaAddIn              1
  63.  
  64. // int performAddInFunction(registerMenuCallBackMesaAddIn, module handle, function address)
  65. // returns 1
  66. // registers a call-back to the menu handling routine.  The module handle is the paramter
  67. // passed to the AddIn when its AddInInit(void *) is called.  An AddIn can change the routing
  68. // called for the menu call-back by calling this routing again or may de-register the menu
  69. // callback by passing a NULL as the function address.
  70. // the function is called in the following format:
  71. // function(int command,int type) where:
  72. // command is the menu command (an integer between 27000 and 32767 that the AddIn associates)
  73. // with a particular menu command.  An AddIn will be called with other AddIn's commands and
  74. // should ignore these commands and return a 0 in all circumstances
  75. // the type is an integer denoting the action to take:
  76. // 0 - execute the menu command - return 1 if the command was executed
  77. // 1 - enabled? return a 1 if the AddIn can execute the command (i.e., the menu should be enabled)
  78. // 2 - Open a help dialog for the menu item
  79. #define registerMenuCallBackMesaAddIn       2
  80.  
  81.  
  82. // void *performAddInFunction(getActiveModelMesaAddIn)
  83. // returns a handle to the currently active model or NULL if there is no currently active
  84. // model
  85. #define getActiveModelMesaAddIn             3
  86.  
  87. // char *performAddInFunction(getModelNameMesaAddIn,void *model_handle)
  88. // returns a pointer to a string containing the name of the model refered to by the
  89. // handle.  NULL is returned if the model has not been named.  The returned string
  90. // must be free'd from storage with a call to MFree()
  91. #define getModelNameMesaAddIn               4
  92.  
  93. // void performAddInFunction(setModelNameMesaAddIn, void *model_handle,
  94. //        const char *new_name,int action)
  95. // changes the name of the model to the new name (which should be a complete path name)
  96. // if 0 is passed as the action, the windows displaying the model are redisplayed with the
  97. // new model name.  If -1 is passed as the action, the windows are not redisplayed
  98. #define setModelNameMesaAddIn               5
  99.  
  100. // void *performAddInFunction(openModelMesaAddIn, const char *file_name)
  101. // If the named model is currently open, it is brought to the front.  If it is not open,
  102. // it is loaded off of disk.  If it cannot be opened, NULL is returned, otherwise the
  103. // model handle is returned
  104. #define openModelMesaAddIn                  6
  105.  
  106. // char *performAddInFunction(addressToStringMesaAddIn,void *model_handle,
  107. //    int row,int col,int layer)
  108. // returns a character string that is the absolute address in row,col,layer
  109. // this string must be MFree'd after it is used
  110. #define addressToStringMesaAddIn            7
  111.  
  112. // char *performAddInFunction(rangeToStringMesaAddIn, void *model_handle,
  113. // int row,int col,int layer,int row,int col,int layer)
  114. // returns a character string that is the absolute range in row,col,layer to
  115. // row,col,layer
  116. // this string must be MFree'd after it is used
  117. #define rangeToStringMesaAddIn              8
  118.  
  119. // void performAddInFunction(selectMesaAddIn, const char *range_name)
  120. // selects the named range on the current window
  121. #define selectMesaAddIn                     9
  122.  
  123. // int performAddInFunction(getCurrentAddressMesaAddIn, int *row,int *col,
  124. //    int *layer) returns 1 if there is a valid selection (i.e., an open window
  125. // with a spreadsheet layer on top) and thus the row, column, and layer are set
  126. // correctly
  127. #define getCurrentAddressMesaAddIn          10
  128.  
  129. // int performAddInFunction(getCurrentRangeMesaAddIn, int *row,int *col,int *layer,
  130. //    int *row,int *col,int *layer) returns 1 if there is a valid range selection
  131. // (an open window with a sheet layer showing with a range selected (rather than a single
  132. // cell).  The rectangle of the first part of the selected range is placed into the
  133. // correct integers
  134. #define getCurrentRangeMesaAddIn            11
  135.  
  136. // void performAddInFunction(getCellValueMesaAddIn, void *model_handle,MesaAddInValue *aiv)
  137. // initialize the MesaAddInValue, set the row, column, and layer and call this
  138. // function.  The value of the cell is set and returned.  For NULL cells or
  139. // cells with no value, the value is a type of error and the error value is 0
  140. #define getCellValueMesaAddIn               12
  141.  
  142. // int performAddInFunction(setCellValueMesaAddIn, void *model_handle,MesaAddInValue *aiv,
  143. //         int action) - sets the given cell to the given value.  Set the value and address
  144. // in the MesaAddInValue, and call this funtion to set the value of a given cell.  An error
  145. // is returned.  0 if successful or non-zero if there was an error (the cell address was out of
  146. // range or the range was protected.  A 0 in the action will result in a recalc and a redisplay
  147. // where a -1 will result in neither
  148. #define setCellValueMesaAddIn               13
  149.  
  150. // int performAddInFunction(setExtentsMesaAddIn, void *model_handle,int layer,int maxRow,
  151. //        int maxCol, int action) - sets the maximum size of a given layer in the model.
  152. // The model must
  153. // have the layer in question as valid for this function to have any effect.  Set
  154. // action to 0 to redisplay the worksheets or -1 to avoid redisplay events.  Returns 0
  155. // if successful, otherwise an error number
  156. #define setExtentsMesaAddIn                 14
  157.  
  158. // void performAddInFunction(setBlobMesaAddIn, void *model_handle,const char *name,
  159. //        int len,const void *blob_data) - sets a named blob (Binary Length Of Bytes) in the
  160. // model that is saved with the model.  The AddIn may save AddIn specific information
  161. // with the model via this mechanism
  162. #define setBlobMesaAddIn                    15
  163.  
  164. // int performAddInFunction(getBlobMesaAddIn, void *model_handle,const char *name,
  165. //        int *len,void **blob_data) - retrieves a named blob from the model.  Returns
  166. // 1 if a blob with the given name was found.  The length of the blob is put in the
  167. // length and the blob_data is set to an allocated block of memory that contains the
  168. // blob data.  blob_data must be MFree'd when it is no longer needed
  169. #define getBlobMesaAddIn                    16
  170.  
  171. // void *performAddInFunction(newModelMesaAddIn)
  172. // creates a new model and displays it and returns a handle to the new model
  173. // returns 0 if a model cannot be created
  174. #define newModelMesaAddIn                   17
  175.  
  176. // int performAddInFunction(setColumnSizeMesaAddIn, void *model_handle, int layer, int column,
  177. //        int size, int action) - sets the particular column to a particular size in a given
  178. // layer.  If action is 0, workbooks will be redisplayed, -1 no redisplay.  Size is in points.
  179. // returns 0 if successful or error number
  180. #define setColumnSizeMesaAddIn              18
  181.  
  182. // int performAddInFunction(setRowSizeMesaAddIn, void *model_handle, int layer, int row,
  183. //        int size, int action) - sets the particular row to a particular size in a given
  184. // layer.  If action is 0, workbooks will be redisplayed, -1 no redisplay.  Size is in points
  185. // returns 0 if successful or error number
  186. #define setRowSizeMesaAddIn                 19
  187.  
  188. // int performAddInFunction(getColumnSizeMesaAddIn, void *model_handle,int layer,int col)
  189. // returns the size of the column in points.
  190. #define getColumnSizeMesaAddIn              20
  191.  
  192. // int performAddInFunction(getRowSizeMesaAddIn, void *model_handle,int layer,int row)
  193. // returns the size of the row in points.
  194. #define getRowSizeMesaAddIn                 21
  195.  
  196. // int performAddInFunction(getExtentsMesaAddIn, void *model_handle,int layer, int *nrows,
  197. //        int *ncols) - gets the size of the given layer.  If the layer does not exist in the
  198. // model, 0 is returned, otherwise nrows and ncols are set correctly
  199. #define getExtentsMesaAddIn                 22
  200.  
  201. // void performAddInFunction(redisplayMesaAddIn, void *model_handle) - causes all the windows
  202. // that are watching a given workbook to redisplay
  203. #define redisplayMesaAddIn                  23
  204.  
  205. // void performAddInFunction(recalcMesaAddIn, void *model_handle) - causes the model to
  206. // recalculate and redisplay.  The recalculation is done in the background and may be interupted
  207. // by other user activity in the model
  208. #define recalcMesaAddIn                     24
  209.  
  210. // int performAddInFunction(setCellStringMesaAddIn, void *model_handle,const char *string,
  211. //        int layer,int row, int col,int action) - sets a given cell to a string.  The string
  212. // is parsed (checked for being a formula, etc) as if the user typed the string.  action of
  213. // 0 will result in a redisplay and recalc (if recaclc is enabled, -1 no action.  0 return
  214. // indicates success, otherwise an error number will be returned
  215. #define setCellStringMesaAddIn              25
  216.  
  217. // char *performAddInFunction(getCellStringMesaAddIn, void *model_handle, int layer, int row,
  218. //        int col) - returns the contents of the "formula view" of the cell.  This string must
  219. // be MFree'd when it is no longer used
  220. #define getCellStringMesaAddIn              26
  221.  
  222. // char *performAddInFunction(getCellOutputMesaAddIn, void *model_hanlde, int layer, int row,
  223. //        int col) - returns the text of what will be displayed in a cell in the exact format
  224. // that it would appear in the cell.  The string must be MFree'd when it is no longer needed
  225. #define getCellOutputMesaAddIn              27
  226.  
  227. // void performAddInFunction(registerFunctionMesaAddIn, const char *func_name,
  228. //        const char *fbName,const char *fbPrototype, const char *fbDescription,
  229. //        const char *fbExample, int *fbMembers, void * callBack)
  230. // func_name - the name of the function, eg: "DOG("
  231. // fbName - optional (must be NULL if unused) - name as appears in formula bldr: "DOG"
  232. // fbPrototype - optional (must be NULL if unused) - prototype in formula builder
  233. // fbDescription - optional (must be NULL if unused) - description in formula builder
  234. // fbExample - optional (must be NULL if unused) - text example for formula builder
  235. // fbMembers - optional (must be NULL if unused) - 0 terminated list of function groups for fb
  236. // callBack - the address of the function that executes the AddIn function
  237. // this will be called with the following parameters:
  238. // function(int numberOfParameters, void *stack, void *model_handle)
  239. // use the popElementMesaAddIn to remove values from the
  240. // evaluation stack and process them and push the result back on the stack with pushValueMesaAddIn
  241. #define registerFunctionMesaAddIn           28
  242.  
  243. // void performAddInFunction(popElementMesaAddIn,void *stack, void *model_handle, MesaAddInValue *)
  244. // pops an element off the evaluation stack.  the MesaAddInValue must be initialized and free'd
  245. // after use
  246. #define popElementMesaAddIn                 29
  247.  
  248. // void performAddInFunction(pushValueMesaAddIn,void *stack, void *model_handle, MesaAddInValue *)
  249. // pushes an element onto the evaluation stack.
  250. #define pushValueMesaAddIn                  30
  251.  
  252. // int performAddInFunction(registerDoubleClickMesaAddIn, void * module_handle,
  253. //        void *function_address) - registers the call-back for double-clicking on a cell
  254. // if the user double-clicks on a cell in a sheet view, the AddIn is called in the following
  255. // way: void function(void *model_handle,int layer, int row, int column)
  256. #define registerDoubleClickMesaAddIn        31
  257.  
  258. // int performAddInFunction(registerAboutToSaveMesaAddIn, void *module_handle,
  259. //        void *function_address) - registers the call-back for the pre-save operation
  260. // just before a model is saved out to disk, this call-back is called.  This is an
  261. // opportunity for the AddIn to place information with the model or to verify that the
  262. // model has the correct contents.  If the AddIn returns '0' the model is saved (assuming
  263. // that other addin's return 0), otherwise, the save operation is aborted and the
  264. // saveBlockedByAddInError error is returned
  265. // int function(void *model_handle)
  266. #define registerAboutToSaveMesaAddIn        32
  267.  
  268. // int performAddInFunction(registerOpenedMesaAddIn, void *module_handle,
  269. //        void *function_address) - registers the call-back for the post-open operation
  270. // this call-back is called each time a model is opened from disk.  This is an
  271. // oportunity for an AddIn to check to see if a Model could use the AddIn's services
  272. // for example, by checking the BLOB info for a registered blob
  273. // void function(void *model_handle)
  274. #define registerOpenedMesaAddIn             33
  275.  
  276. // int performAddInFunction(registerAboutToCloseMesaAddIn, void *module_handle,
  277. //        void *function_address) - registers the call-back for the pre-close operation
  278. // this call-back is called just before the last window to a model is closed.  This
  279. // in an opportunity for the AddIn to block the close operation or to place data in the
  280. // model before it is closed.  Return 1 to block the close operation
  281. // int function(void *model_handle)
  282. #define registerAboutToCloseMesaAddIn       34
  283.  
  284. // int performAddInFunction(registerDataEnteredMesaAddIn, void *module_handle,
  285. //        void *function_address) - registers the call-back for the pre-enter data operation
  286. // this call-back is called just before data is entered into a cell.  This gives the addin
  287. // the opportunity to do data validation and optionally block the entry of data into
  288. // the cell.  return 1 to block data entry or 0 to allow it.  A entryBlockedByAddInError
  289. // is returned if the data addin blocks the data
  290. // int function(void * model_handle,int layer,int row,int column,const char *data)
  291. #define registerDataEnteredMesaAddIn        35
  292.  
  293. // int performAddInFunction(registerPMCallBackMesaAddIn, module handle, function address)
  294. // returns 1
  295. // registers a call-back to the PM Message handling routine.  The module handle is the paramter
  296. // passed to the AddIn when its AddInInit(void *) is called.  An AddIn can change the routing
  297. // called for the PM call-back by calling this routing again or may de-register the PM
  298. // callback by passing a NULL as the function address.
  299. // the function is called in the following format:
  300. // MRESULT function(HWND window,ULONG msg,MPARAM mp1,MPARAM mp2)
  301. // Messages greater than WM_USER + 1000 get passed to all addins.  It is the addin's job
  302. // to choose a unique PM Message number (sorry guys, no tips).  The MRESULTS are or'ed
  303. // together so if you don't recognize the message, return 0
  304. #define registerPMCallBackMesaAddIn         36
  305.  
  306. // HWND performAddInFunction(getActiveWindowMesaAddIn)
  307. // returns the HWND for the currently active spreadsheet window or 0 if there is no window
  308. #define getActiveWindowMesaAddIn            37
  309.  
  310. // HWND performAddInFunction(getApplicationWindowMesaAddIn)
  311. // returns the HWND for the application window.  This function can return 0 if there
  312. // is no application window (i.e., the addin is running in a custom application via MOLI)
  313. #define getApplicationWindowMesaAddIn       38
  314.  
  315. // void performAddInFunction(initValueMesaAddIn, MesaAddInValue *)
  316. // initializes the data structure to default values.  Must be done before the data
  317. // structure is used in any calls
  318. #define initValueMesaAddIn                  39
  319.  
  320. // void performAddInFunction(freeValueMesaAddIn, MesaAddInValue *)
  321. // releases any storage used by the MesaAddInValue.  This must be called before
  322. // the MesaAddInValue goes out of scope
  323. #define freeValueMesaAddIn                  40
  324.  
  325. // int performAddInFunction(getNumberOfLayersMesaAddIn,void *model_handle)
  326. // returns the number of layers in the model
  327. #define getNumberOfLayersMesaAddIn          41
  328.  
  329. // void performAddInFunction(addALayerMesaAddIn,void *model_handle,int action)
  330. // adds a layer to the model.  if the "action" parameter is 0, redisplay takes place
  331. // if the action parameter is -1, no redisplay takes place
  332. #define addALayerMesaAddIn                  42
  333.  
  334. // int performAddInFunction(saveModelAddIn, void *model_handle)
  335. // call to save the model.  Returns 0 if successful or error number
  336. #define saveModelAddIn                      43
  337.  
  338. #define stringToAddressMesaAddIn            44
  339. // int performAddInFunction(saveModelAddIn, void *model_handle,char *str,int *r, int *c, int *l)
  340. // returns 1 if sussessful
  341.  
  342. #define stringToRangeMesaAddIn              45
  343. // int performAddInFunction(saveModelAddIn, void *model_handle,char *str,int item,
  344. //                          int *r1, int *c1, int *l1,int *r2, int *c2, int *l2)
  345. // returns 0 if unsussessful, the total item count if it is (multi-ranges)
  346.  
  347. #define getVersionNumberMesaAddIn           46
  348. // int performAddInFunction(getVersionNumberMesaAddin)
  349. // returns the Version number of Mesa.  This is the build number found
  350. // on the About panel of the Mesa 2 Application.
  351.  
  352. typedef struct _MesaAddInValue
  353. {
  354.     int row;
  355.     unsigned short column;
  356.     unsigned short layer;
  357.     int type;
  358.     double number;
  359.     char *string;
  360.     int error;
  361.     unsigned short rows;
  362.     unsigned short cols;
  363.     _MesaAddInValue * array;
  364. } MesaAddInValue;
  365.  
  366. #define errorValueMesaAddInType 0
  367. #define stringValueMesaAddInType 1
  368. #define numberValueMesaAddInType 2
  369. #define arrayValueMesaAddInType 3
  370.  
  371. #ifdef __cplusplus
  372. }
  373. #endif
  374.  
  375. // ifndef _MH_ExternalAddIn_h
  376. #endif
  377.