home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: Java / Java.zip / javasamp.zip / jempower.h < prev    next >
C/C++ Source or Header  |  1996-05-02  |  8KB  |  193 lines

  1. /******************************************************************************
  2.  *  IBM JEmpower                                                              *
  3.  *                                                                            *
  4.  *  (C) Copyright IBM Corp. 1996                                              *
  5.  *  All Rights Reserved.                                                      *
  6.  *                                                                            *
  7.  ******************************************************************************
  8.  *                                                                            *
  9.  *  Module Name: JEmppower.h - JEmpower functions                             *
  10.  *                                                                            *
  11.  *****************************************************************************/
  12.  
  13. #ifndef _JEMPOWER_H_
  14. #define _JEMPOWER_H_
  15.  
  16. #ifdef __cplusplus
  17. extern "C" {
  18. #endif
  19.  
  20. #ifdef __OS2__
  21. #define JELINKAGE _System
  22. #ifdef  JEMPOWER_DYNAMIC
  23. #define JE_HAS_ORDINALS
  24. #endif
  25. #elif defined(_WIN32) || defined(WIN32)
  26. #define JELINKAGE __cdecl
  27. #ifdef  JEMPOWER_DYNAMIC
  28. #define JE_HAS_ORDINALS
  29. #endif
  30. #else
  31. #define JELINKAGE
  32. #endif
  33.  
  34. typedef unsigned long JEAPPLETHND;
  35. typedef unsigned long JECONTEXTID;
  36. typedef int           JERESULT;
  37.  
  38. /* JENATIVEWND is the type used for windows in the native operating system.
  39.  * For example, it is an HWND on WIN32 and OS2, an X Window under UNIX, etc.
  40.  * To avoid having to load os2.h, windows.h, etc in this header file,
  41.  * we are declaring as an opaque pointer to a struct. 
  42.  * When using the functions that take an JENATIVEWND
  43.  * (jeAppletInit and jeHWNDFromHandle), explicitly cast to and from HWND,
  44.  * Window, or whatever.
  45.  */
  46. struct rec_jenativewnd;
  47. typedef struct rec_jenativewnd* JENATIVEWND;
  48.  
  49. /*******************************************************************/
  50.  
  51. /* 
  52.  * This API can be used statically or dynamically.  
  53.  *
  54.  * For statically, simply link with the JEmpower library and call functions
  55.  * such as jeInitJavaRuntime or jeAppletInit.  
  56.  *
  57.  * For dynamically, load each of the functions using operating system 
  58.  * functions such as GetProcAddress (for windows) and assign variables
  59.  * of the correct type to the results for later use.  For example,
  60.  *    JE_FP_jeAppletInit jeAppletInit;
  61.  *    jeAppletInit = (JE_FP_jeAppletInit)GetProcAddress(lib, "jeAppletInit");
  62.  *    ...
  63.  *    jeAppletInit(usual arguments);
  64.  * To use this library dynamically, 
  65.  * #define JEMPOWER_DYNAMIC before loading jempower.h
  66.  * Notice that the call site of jeAppletInit looks identical regardless
  67.  * of whether JEMPOWER is used statically or dynamically
  68.  */
  69. #ifndef JEMPOWER_DYNAMIC
  70. #define JE_FN_DECL(rettype, fnName, fnTypeName) \
  71.    rettype JELINKAGE fnName
  72. #else
  73. #define JE_FN_DECL(rettype, fnName, fnTypeName) \
  74.    typedef rettype (JELINKAGE fnTypeName)
  75. #endif
  76.  
  77. JE_FN_DECL(void, jeVersion, JE_FP_jeVersion)
  78.    (int *majorVersion, int *minorVersion);
  79.  
  80. JE_FN_DECL(JERESULT, jeInitJavaRuntime, JE_FP_jeInitJavaRuntime)
  81.    (void);
  82. JE_FN_DECL(JERESULT, jeInitJavaRuntimeEx, JE_FP_jeInitJavaRuntimeEx)
  83.    (int extraArgc, char **extraArgv);
  84.  
  85. JE_FN_DECL(JERESULT, jeAppletInit, JE_FP_jeAppletInit)
  86.    (JEAPPLETHND *pAppResult,
  87.     JECONTEXTID contextID, JENATIVEWND parent,
  88.     const char *documentURL,
  89.     const char *code, long width, long height,
  90.     int parmCount, const char **parms);
  91.  
  92. JE_FN_DECL(JERESULT, jeAppletStart, JE_FP_jeAppletStart)
  93.    (JEAPPLETHND applet);
  94. JE_FN_DECL(JERESULT, jeAppletStop, JE_FP_jeAppletStop)
  95.    (JEAPPLETHND applet);
  96. JE_FN_DECL(JERESULT, jeAppletDestroy, JE_FP_jeAppletDestroy)
  97.    (JEAPPLETHND applet);
  98. JE_FN_DECL(JERESULT, jeAppletToolBarShow, JE_FP_jeAppletToolBarShow)
  99.    (JEAPPLETHND applet, int show);
  100. JE_FN_DECL(JERESULT, jeAppletInformationShow, JE_FP_jeAppletInformationShow)
  101.    (JEAPPLETHND applet, int show);
  102. JE_FN_DECL(JERESULT, jeAppletResize, JE_FP_jeAppletResize)
  103.    (JEAPPLETHND applet, long width, long height);
  104.  
  105. JE_FN_DECL(JENATIVEWND, jeHWNDFromHandle, JE_FP_jeHWNDFromHandle)
  106.    (JEAPPLETHND applet);
  107.  
  108. JE_FN_DECL(JERESULT, jeAppletsIconify, JE_FP_jeAppletsIconify)
  109.    (JECONTEXTID contextID);
  110. JE_FN_DECL(JERESULT, jeAppletsUniconify, JE_FP_jeAppletsUniconify)
  111.    (JECONTEXTID contextID);
  112. JE_FN_DECL(JERESULT, jeAppletsDestroy, JE_FP_jeAppletsDestroy)
  113.    (JECONTEXTID contextID);   
  114.  
  115. JE_FN_DECL(JERESULT, jeConsoleShow, JE_FP_jeConsoleShow)
  116.    (int show);
  117.  
  118. JE_FN_DECL(JERESULT, jeGetProperty, JE_FP_jeGetProperty)
  119.    (const char *key, char *value, 
  120.     int valueLength, int *trueLength);
  121. JE_FN_DECL(JERESULT, jeSetProperty, JE_FP_jeSetProperty)
  122.    (const char *key, const char *value);
  123.  
  124. typedef void (* JELINKAGE jeShowDocumentFnPtr)(JECONTEXTID contextID, 
  125.                                                const char *url,
  126.                                                const char *target);
  127. JE_FN_DECL(JERESULT, jeRegisterShowDocument, JE_FP_jeRegisterShowDocument)
  128.    (jeShowDocumentFnPtr fnPtr);
  129.  
  130. typedef int (* JELINKAGE jeShowStatusFnPtr)(JECONTEXTID contextID, 
  131.                                             const char *status);
  132. JE_FN_DECL(JERESULT, jeRegisterShowStatus, JE_FP_jeRegisterShowStatus)
  133.    (jeShowStatusFnPtr fnPtr);
  134.  
  135. typedef int (* JELINKAGE jeShowConsoleFnPtr)(const char *string);
  136. JE_FN_DECL(JERESULT, jeRegisterShowConsole, JE_FP_jeRegisterShowConsole)
  137.    (jeShowConsoleFnPtr fnPtr);
  138.  
  139. /*******************************************************************/
  140.  
  141. #ifdef  JEMPOWER_DYNAMIC
  142. /* To make dynamic loading easier.  The names and ordinals for the API */
  143. #define JE_NAM_jeVersion               "jeVersion"
  144. #define JE_NAM_jeInitJavaRuntime       "jeInitJavaRuntime"
  145. #define JE_NAM_jeInitJavaRuntimeEx     "jeInitJavaRuntimeEx"
  146. #define JE_NAM_jeAppletInit            "jeAppletInit"
  147. #define JE_NAM_jeAppletStart           "jeAppletStart"
  148. #define JE_NAM_jeAppletStop            "jeAppletStop"
  149. #define JE_NAM_jeAppletDestroy         "jeAppletDestroy"
  150. #define JE_NAM_jeAppletToolBarShow     "jeAppletToolBarShow"
  151. #define JE_NAM_jeAppletInformationShow "jeAppletInformationShow"
  152. #define JE_NAM_jeAppletResize          "jeAppletResize"
  153. #define JE_NAM_jeAppletsIconify        "jeAppletsIconify"
  154. #define JE_NAM_jeAppletsUniconify      "jeAppletsUniconify"
  155. #define JE_NAM_jeAppletsDestroy        "jeAppletsDestroy"
  156. #define JE_NAM_jeConsoleShow           "jeConsoleShow"
  157. #define JE_NAM_jeGetProperty           "jeGetProperty"   
  158. #define JE_NAM_jeSetProperty           "jeSetProperty"   
  159. #define JE_NAM_jeRegisterShowDocument  "jeRegisterShowDocument"
  160. #define JE_NAM_jeRegisterShowStatus    "jeRegisterShowStatus"
  161. #define JE_NAM_jeRegisterShowConsole   "jeRegisterShowConsole"
  162.  
  163. #ifdef  JE_HAS_ORDINALS
  164. #define JE_ORD_jeVersion               1000
  165. #define JE_ORD_jeInitJavaRuntime       1001
  166. #define JE_ORD_jeInitJavaRuntimeEx     1002
  167. #define JE_ORD_jeAppletInit            1050
  168. #define JE_ORD_jeAppletStart           1051
  169. #define JE_ORD_jeAppletStop            1052
  170. #define JE_ORD_jeAppletDestroy         1053
  171. #define JE_ORD_jeAppletToolBarShow     1054
  172. #define JE_ORD_jeAppletInformationShow 1055
  173. #define JE_ORD_jeAppletResize          1056
  174. #define JE_ORD_jeAppletsIconify        1100
  175. #define JE_ORD_jeAppletsUniconify      1101
  176. #define JE_ORD_jeAppletsDestroy        1102
  177. #define JE_ORD_jeConsoleShow           1150
  178. #define JE_ORD_jeGetProperty           1200
  179. #define JE_ORD_jeSetProperty           1201
  180. #define JE_ORD_jeRegisterShowDocument  1152
  181. #define JE_ORD_jeRegisterShowStatus    1153
  182. #define JE_ORD_jeRegisterShowConsole   1151
  183. #endif  /* JE_HAS_ORDINALS */
  184.    
  185. #endif  /* JEMPOWER_DYNAMIC */
  186.  
  187. #ifdef __cplusplus
  188. }
  189. #endif
  190.  
  191. #endif
  192.  
  193.