Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

457 lines
11 KiB

  1. /*
  2. File: JavaControl.h
  3. Contains: interface to embedding Java code in a Carbon Control
  4. Version: QuickTime 7.3
  5. Copyright: (c) 2007 (c) 2000-2001 by Apple Computer, Inc., all rights reserved.
  6. Bugs?: For bug reports, consult the following page on
  7. the World Wide Web:
  8. http://developer.apple.com/bugreporter/
  9. */
  10. #ifndef __MACTYPES__
  11. #include <MacTypes.h>
  12. #endif
  13. #ifndef __CONTROLS__
  14. #include <Controls.h>
  15. #endif
  16. #ifndef __MACWINDOWS__
  17. #include <MacWindows.h>
  18. #endif
  19. #include <JavaVM/jni.h>
  20. #if PRAGMA_ONCE
  21. #pragma once
  22. #endif
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif
  26. #if PRAGMA_IMPORT
  27. #pragma import on
  28. #endif
  29. /*
  30. * Summary:
  31. * JavaControl Embedding errors
  32. *
  33. * Discussion:
  34. * The following are all errors which can be returned from the
  35. * routines contained in this file. Most are self explanatory.
  36. */
  37. enum {
  38. errJavaEmbeddingNotYetImplemented = -9950,
  39. errJavaEmbeddingIntializationFailed = -9962, /* previously errClassConstructorNotFound, errClassNotFound, and errMethodNotFound*/
  40. errJavaEmbeddingMissingURL = -9955, /* previously errMissingURL*/
  41. errJavaEmbeddingCouldNotCreateApplet = -9956, /* previously errCouldNotCreateApplet*/
  42. errJavaEmbeddingCouldNotEmbedFrame = -9957, /* previously errCouldNotEmbedFrame */
  43. errJavaEmbeddingCouldNotConvertURL = -9958, /* previously errCouldNotConvertURL*/
  44. errJavaEmbeddingNotAFrame = -9959, /* previously errNotAFrame*/
  45. errJavaEmbeddingControlNotEmbedded = -9960, /* previously errControlNotEmbedded*/
  46. errJavaEmbeddingExceptionThrown = -9961, /* previously errExceptionThrown*/
  47. errJavaEmbeddingJavaDisabled = -9963
  48. };
  49. /*
  50. * MoveAndClipJavaControl()
  51. *
  52. * Summary:
  53. * Positions the control in the containing window, and sets the clip
  54. * bounds for drawing.
  55. *
  56. * Discussion:
  57. * All coordinates are local to the host window, and 0,0 is the top
  58. * left corner of the content area of the host window - just below
  59. * the title bar.
  60. * Usually a call to MoveAndClipJavaControl is followed by a call to
  61. * DrawJavaControl.
  62. *
  63. * Parameters:
  64. *
  65. * env:
  66. * The JNI Environment for the current thread.
  67. *
  68. * theControl:
  69. * The Java control (applet).
  70. *
  71. * posX:
  72. * The x position of the control.
  73. *
  74. * posY:
  75. * The y position of the control.
  76. *
  77. * clipX:
  78. * The left of the clip region.
  79. *
  80. * clipY:
  81. * The top of the clip region.
  82. *
  83. * clipWidth:
  84. * The width of the clip region. (Notice this is not right, but
  85. * width)
  86. *
  87. * clipHeight:
  88. * The height of the clip region. (Notice this is not bottom, but
  89. * height)
  90. *
  91. * Availability:
  92. * Non-Carbon CFM: not available
  93. * CarbonLib: not available
  94. * Mac OS X: in version 10.1 and later
  95. */
  96. EXTERN_API_C( OSStatus )
  97. MoveAndClipJavaControl(
  98. JNIEnv * env,
  99. ControlRef theControl,
  100. int posX,
  101. int posY,
  102. int clipX,
  103. int clipY,
  104. int clipWidth,
  105. int clipHeight);
  106. /*
  107. * SizeJavaControl()
  108. *
  109. * Summary:
  110. * Sets the size of the Java control.
  111. *
  112. * Availability:
  113. * Non-Carbon CFM: not available
  114. * CarbonLib: not available
  115. * Mac OS X: in version 10.1 and later
  116. */
  117. EXTERN_API_C( OSStatus )
  118. SizeJavaControl(
  119. JNIEnv * env,
  120. ControlRef theControl,
  121. int width,
  122. int height);
  123. /*
  124. * ShowHideJavaControl()
  125. *
  126. * Summary:
  127. * Makes a Java control visible or invisible.
  128. *
  129. * Parameters:
  130. *
  131. * env:
  132. * The JNI Environment for the current thread.
  133. *
  134. * theControl:
  135. * The Java control (applet).
  136. *
  137. * visible:
  138. * True shows the control.
  139. *
  140. * Availability:
  141. * Non-Carbon CFM: not available
  142. * CarbonLib: not available
  143. * Mac OS X: in version 10.1 and later
  144. */
  145. EXTERN_API_C( OSStatus )
  146. ShowHideJavaControl(
  147. JNIEnv * env,
  148. ControlRef theControl,
  149. Boolean visible);
  150. /*
  151. * StopJavaControlAsyncDrawing()
  152. *
  153. * Summary:
  154. * Stops a Java applet from drawing asynchonously.
  155. *
  156. * Discussion:
  157. * Many applets are used for animation and they draw themselves at
  158. * times other than when the control is drawn. In order to handle
  159. * things like live resize and scrolling a host app must be able to
  160. * suspend asynchronous drawing otherwise a draw may occur before
  161. * the host app is able to reposition/reclip the control thus
  162. * causing drawing in the wrong location. When async drawing is off
  163. * normal paint events in an applet are ignored. Only
  164. * DrawJavaControl events are allowed to paint. This allows
  165. * temporary fine grained control of when an applet can paint, and
  166. * should only be used when needed.
  167. *
  168. * Parameters:
  169. *
  170. * env:
  171. * The JNI Environment for the current thread.
  172. *
  173. * theControl:
  174. * The Java control (applet).
  175. *
  176. * Availability:
  177. * Non-Carbon CFM: not available
  178. * CarbonLib: not available
  179. * Mac OS X: in version 10.1 and later
  180. */
  181. EXTERN_API_C( OSStatus )
  182. StopJavaControlAsyncDrawing(
  183. JNIEnv * env,
  184. ControlRef theControl);
  185. /*
  186. * RestartJavaControlAsyncDrawing()
  187. *
  188. * Summary:
  189. * Allows a Java applet to draw asynchonously.
  190. *
  191. * Discussion:
  192. * This should be called when it is safe again for an applet to draw
  193. * asynchronously. See StopJavaControlAsyncDrawing.
  194. *
  195. * Parameters:
  196. *
  197. * env:
  198. * The JNI Environment for the current thread.
  199. *
  200. * theControl:
  201. * The Java control (applet).
  202. *
  203. * Availability:
  204. * Non-Carbon CFM: not available
  205. * CarbonLib: not available
  206. * Mac OS X: in version 10.1 and later
  207. */
  208. EXTERN_API_C( OSStatus )
  209. RestartJavaControlAsyncDrawing(
  210. JNIEnv * env,
  211. ControlRef theControl);
  212. /*
  213. * DrawJavaControl()
  214. *
  215. * Summary:
  216. * Causes a Java control that to be drawn.
  217. *
  218. * Discussion:
  219. * This should be called whenever the host app needs the
  220. * applet/control to be redrawn. In the case where Async drawing is
  221. * paused, DrawJavaControl will still cause the applet to draw. So
  222. * if the host app is stopping async drawing for something like live
  223. * scrolling, if there are convenient times the host app should call
  224. * DrawJavaControl (usually after a call to MoveAndClipJavaControl)
  225. * to provide some feedback to the user.
  226. *
  227. * Parameters:
  228. *
  229. * env:
  230. * The JNI Environment for the current thread.
  231. *
  232. * theControl:
  233. * The corresponding Java control (applet) that is to be drawn.
  234. *
  235. * Availability:
  236. * Non-Carbon CFM: not available
  237. * CarbonLib: not available
  238. * Mac OS X: in version 10.1 and later
  239. */
  240. EXTERN_API_C( OSStatus )
  241. DrawJavaControl(
  242. JNIEnv * env,
  243. ControlRef theControl);
  244. /*
  245. ========================================================================================
  246. UTILITY API - functions to determine the status of a window or control
  247. ========================================================================================
  248. */
  249. /*
  250. * GetJavaWindowFromWindow()
  251. *
  252. * Discussion:
  253. * Given a native Carbon window this returns the corresponding Java
  254. * window.
  255. *
  256. * Parameters:
  257. *
  258. * env:
  259. * The JNI Environment for the current thread.
  260. *
  261. * inMacWindow:
  262. * A reference to a native window.
  263. *
  264. * outJavaWindow:
  265. * Returns a JNI global ref. Call env->DeleteGlobalRef() on it
  266. * when done.
  267. *
  268. * Availability:
  269. * Non-Carbon CFM: not available
  270. * CarbonLib: not available
  271. * Mac OS X: in version 10.1 and later
  272. */
  273. EXTERN_API_C( OSStatus )
  274. GetJavaWindowFromWindow(
  275. JNIEnv * env,
  276. WindowRef inMacWindow,
  277. jobject * outJavaWindow);
  278. /*
  279. * GetWindowFromJavaWindow()
  280. *
  281. * Discussion:
  282. * Given a Java window this returns the corresponding native Carbon
  283. * window.
  284. *
  285. * Parameters:
  286. *
  287. * env:
  288. * The JNI Environment for the current thread.
  289. *
  290. * inJavaWindow:
  291. * A reference to a Java window.
  292. *
  293. * outMacWindow:
  294. * The corresponding native window.
  295. *
  296. * Availability:
  297. * Non-Carbon CFM: not available
  298. * CarbonLib: not available
  299. * Mac OS X: in version 10.1 and later
  300. */
  301. EXTERN_API_C( OSStatus )
  302. GetWindowFromJavaWindow(
  303. JNIEnv * env,
  304. jobject inJavaWindow,
  305. WindowRef * outMacWindow);
  306. /*
  307. * GetJavaFrameFromControl()
  308. *
  309. * Discussion:
  310. * Given an embedded control this returns the corresponding Java
  311. * applet frame.
  312. *
  313. * Parameters:
  314. *
  315. * env:
  316. * The JNI Environment for the current thread.
  317. *
  318. * inMacControl:
  319. * A reference to the control for the applet.
  320. *
  321. * outJavaFrame:
  322. * Returns a JNI global ref. Call env->DeleteGlobalRef() on it
  323. * when done.
  324. *
  325. * Availability:
  326. * Non-Carbon CFM: not available
  327. * CarbonLib: not available
  328. * Mac OS X: in version 10.1 and later
  329. */
  330. EXTERN_API_C( OSStatus )
  331. GetJavaFrameFromControl(
  332. JNIEnv * env,
  333. ControlRef inMacControl,
  334. jobject * outJavaFrame);
  335. /*
  336. * GetControlFromJavaFrame()
  337. *
  338. * Discussion:
  339. * Given a Java applet frame reference this returns the embedded
  340. * control.
  341. *
  342. * Parameters:
  343. *
  344. * env:
  345. * The JNI Environment for the current thread.
  346. *
  347. * inJavaFrame:
  348. * The applet reference obtained from CreateJavaApplet.
  349. *
  350. * outMacControl:
  351. * A reference to the control for the applet.
  352. *
  353. * Availability:
  354. * Non-Carbon CFM: not available
  355. * CarbonLib: not available
  356. * Mac OS X: in version 10.1 and later
  357. */
  358. EXTERN_API_C( OSStatus )
  359. GetControlFromJavaFrame(
  360. JNIEnv * env,
  361. jobject inJavaFrame,
  362. ControlRef * outMacControl);
  363. /*
  364. * CreateJavaControl()
  365. *
  366. * Discussion:
  367. * Creates a control for the specified applet whose content is drawn
  368. * and events processed by java.
  369. * All communication to this control should be through the APIs
  370. * specified here in JavaControl.h.
  371. *
  372. * Parameters:
  373. *
  374. * env:
  375. * The JNI Environment for the current thread.
  376. *
  377. * inNativeWindow:
  378. * The carbon window that will host the applet.
  379. *
  380. * inBounds:
  381. * The starting location for the applet.
  382. *
  383. * inAppletFrame:
  384. * The applet reference obtained from CreateJavaApplet.
  385. *
  386. * inVisible:
  387. * True if the applet should start out hidden.
  388. *
  389. * outControl:
  390. * A reference to the control that is created for the applet.
  391. *
  392. * Availability:
  393. * Non-Carbon CFM: not available
  394. * CarbonLib: not available
  395. * Mac OS X: in version 10.1 and later
  396. */
  397. EXTERN_API_C( OSStatus )
  398. CreateJavaControl(
  399. JNIEnv * env,
  400. WindowRef inNativeWindow,
  401. const Rect * inBounds,
  402. jobject inAppletFrame,
  403. Boolean inVisible,
  404. ControlRef * outControl);
  405. #ifdef PRAGMA_IMPORT_OFF
  406. #pragma import off
  407. #elif PRAGMA_IMPORT
  408. #pragma import reset
  409. #endif
  410. #ifdef __cplusplus
  411. }
  412. #endif