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.

653 lines
15 KiB

  1. /*
  2. File: HIShape.h
  3. Contains: Generic Abstract Shape API
  4. Version: QuickTime 7.3
  5. Copyright: (c) 2007 (c) 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 __HISHAPE__
  11. #define __HISHAPE__
  12. #ifndef __APPLICATIONSERVICES__
  13. #include <ApplicationServices.h>
  14. #endif
  15. #ifndef __CARBONEVENTS__
  16. #include <CarbonEvents.h>
  17. #endif
  18. #if PRAGMA_ONCE
  19. #pragma once
  20. #endif
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. #if PRAGMA_IMPORT
  25. #pragma import on
  26. #endif
  27. /*
  28. * HIShape
  29. *
  30. * Discussion:
  31. * HIShape is an abstract shape object for use with some of the
  32. * HIToolbox APIs. It is designed as a replacement for RgnHandles
  33. * (though it is currently implemented in terms of them at the time
  34. * of this writing). This abstraction will allow us to avoid using
  35. * QD types in our APIs, particularly in HIView.
  36. *
  37. * One of the biggest benefits of HIShape is that we have mutable
  38. * and immutable variants. This means that immutable shapes can be
  39. * created and passed around and 'copied' very quickly, since they
  40. * are actually refcounted when copied. This avoids needing to do
  41. * the handle-to-handle copies that occur right now with
  42. * RgnHandle-based APIs.
  43. */
  44. typedef const struct __HIShape* HIShapeRef;
  45. typedef struct __HIShape* HIMutableShapeRef;
  46. /*
  47. * HIShapeGetTypeID()
  48. *
  49. * Discussion:
  50. * Returns the CF type ID for the HIShape class.
  51. *
  52. * Result:
  53. * A CF type ID.
  54. *
  55. * Availability:
  56. * Non-Carbon CFM: not available
  57. * CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.2 and later
  58. * Mac OS X: in version 10.2 and later
  59. */
  60. EXTERN_API_C( CFTypeID )
  61. HIShapeGetTypeID(void);
  62. /*======================================================================================*/
  63. /* IMMUTABLE FUNCTIONS */
  64. /*======================================================================================*/
  65. /*
  66. * HIShapeCreateWithQDRgn()
  67. *
  68. * Discussion:
  69. * Creates an immutable shape based on an existing Quickdraw region
  70. * handle.
  71. *
  72. * Parameters:
  73. *
  74. * inRgn:
  75. * The Quickdraw region from which to create the HIShape.
  76. *
  77. * Result:
  78. * An immutable HIShape reference.
  79. *
  80. * Availability:
  81. * Non-Carbon CFM: not available
  82. * CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.2 and later
  83. * Mac OS X: in version 10.2 and later
  84. */
  85. EXTERN_API_C( HIShapeRef )
  86. HIShapeCreateWithQDRgn(RgnHandle inRgn);
  87. /*
  88. * HIShapeCreateWithRect()
  89. *
  90. * Discussion:
  91. * Creates an immutable, rectangular shape based on a given
  92. * rectangle.
  93. *
  94. * Parameters:
  95. *
  96. * inRect:
  97. * The HIRect from which to create the resulting shape.
  98. *
  99. * Result:
  100. * An immutable HIShape reference.
  101. *
  102. * Availability:
  103. * Non-Carbon CFM: not available
  104. * CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.2 and later
  105. * Mac OS X: in version 10.2 and later
  106. */
  107. EXTERN_API_C( HIShapeRef )
  108. HIShapeCreateWithRect(const HIRect * inRect);
  109. /*
  110. * HIShapeCreateCopy()
  111. *
  112. * Discussion:
  113. * Creates an immutable copy of a mutable or immutable HIShape.
  114. *
  115. * Parameters:
  116. *
  117. * inShape:
  118. * The existing HIShapeRef you wish to copy.
  119. *
  120. * Result:
  121. * An immutable HIShape reference.
  122. *
  123. * Availability:
  124. * Non-Carbon CFM: not available
  125. * CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.2 and later
  126. * Mac OS X: in version 10.2 and later
  127. */
  128. EXTERN_API_C( HIShapeRef )
  129. HIShapeCreateCopy(HIShapeRef inShape);
  130. /*
  131. * HIShapeCreateIntersection()
  132. *
  133. * Discussion:
  134. * Creates a new immutable shape which is the intersection of two
  135. * others.
  136. *
  137. * Parameters:
  138. *
  139. * inShape1:
  140. * An existing HIShapeRef.
  141. *
  142. * inShape2:
  143. * An existing HIShapeRef.
  144. *
  145. * Result:
  146. * A new immutable HIShapeRef.
  147. *
  148. * Availability:
  149. * Non-Carbon CFM: not available
  150. * CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.2 and later
  151. * Mac OS X: in version 10.2 and later
  152. */
  153. EXTERN_API_C( HIShapeRef )
  154. HIShapeCreateIntersection(
  155. HIShapeRef inShape1,
  156. HIShapeRef inShape2);
  157. /*
  158. * HIShapeCreateDifference()
  159. *
  160. * Discussion:
  161. * Creates a new immutable shape which is the difference of two
  162. * others. The second shape is subtracted from the first.
  163. *
  164. * Parameters:
  165. *
  166. * inShape1:
  167. * An existing HIShapeRef.
  168. *
  169. * inShape2:
  170. * An existing HIShapeRef.
  171. *
  172. * Result:
  173. * A new immutable HIShapeRef.
  174. *
  175. * Availability:
  176. * Non-Carbon CFM: not available
  177. * CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.2 and later
  178. * Mac OS X: in version 10.2 and later
  179. */
  180. EXTERN_API_C( HIShapeRef )
  181. HIShapeCreateDifference(
  182. HIShapeRef inShape1,
  183. HIShapeRef inShape2);
  184. /*
  185. * HIShapeCreateUnion()
  186. *
  187. * Discussion:
  188. * Creates a new immutable shape which is the union of two others.
  189. *
  190. * Parameters:
  191. *
  192. * inShape1:
  193. * An existing HIShapeRef.
  194. *
  195. * inShape2:
  196. * An existing HIShapeRef.
  197. *
  198. * Result:
  199. * A new immutable HIShapeRef.
  200. *
  201. * Availability:
  202. * Non-Carbon CFM: not available
  203. * CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.2 and later
  204. * Mac OS X: in version 10.2 and later
  205. */
  206. EXTERN_API_C( HIShapeRef )
  207. HIShapeCreateUnion(
  208. HIShapeRef inShape1,
  209. HIShapeRef inShape2);
  210. /*
  211. * HIShapeIsEmpty()
  212. *
  213. * Discussion:
  214. * Returns true if the given HIShapeRef is empty, i.e. its area is
  215. * empty.
  216. *
  217. * Parameters:
  218. *
  219. * inShape:
  220. * The existing HIShapeRef you wish to test.
  221. *
  222. * Result:
  223. * A boolean result.
  224. *
  225. * Availability:
  226. * Non-Carbon CFM: not available
  227. * CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.2 and later
  228. * Mac OS X: in version 10.2 and later
  229. */
  230. EXTERN_API_C( Boolean )
  231. HIShapeIsEmpty(HIShapeRef inShape);
  232. /*
  233. * HIShapeIsRectangular()
  234. *
  235. * Discussion:
  236. * Returns true if the given HIShapeRef is rectangular.
  237. *
  238. * Parameters:
  239. *
  240. * inShape:
  241. * The existing HIShapeRef you wish to test.
  242. *
  243. * Result:
  244. * A boolean result.
  245. *
  246. * Availability:
  247. * Non-Carbon CFM: not available
  248. * CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.2 and later
  249. * Mac OS X: in version 10.2 and later
  250. */
  251. EXTERN_API_C( Boolean )
  252. HIShapeIsRectangular(HIShapeRef inShape);
  253. /*
  254. * HIShapeContainsPoint()
  255. *
  256. * Discussion:
  257. * Returns true if the given HIShapeRef contains the point passed in.
  258. *
  259. * Parameters:
  260. *
  261. * inShape:
  262. * An existing HIShapeRef.
  263. *
  264. * inPoint:
  265. * The point to check.
  266. *
  267. * Result:
  268. * A boolean result.
  269. *
  270. * Availability:
  271. * Non-Carbon CFM: not available
  272. * CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.2 and later
  273. * Mac OS X: in version 10.2 and later
  274. */
  275. EXTERN_API_C( Boolean )
  276. HIShapeContainsPoint(
  277. HIShapeRef inShape,
  278. const HIPoint * inPoint);
  279. /*
  280. * HIShapeGetBounds()
  281. *
  282. * Discussion:
  283. * Returns the bounding rectangle of a given HIShapeRef.
  284. *
  285. * Parameters:
  286. *
  287. * inShape:
  288. * An existing HIShapeRef.
  289. *
  290. * outRect:
  291. * Receives the bounding rectangle.
  292. *
  293. * Result:
  294. * A pointer to the rectangle you passed in, for convenience.
  295. *
  296. * Availability:
  297. * Non-Carbon CFM: not available
  298. * CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.2 and later
  299. * Mac OS X: in version 10.2 and later
  300. */
  301. EXTERN_API_C( HIRect * )
  302. HIShapeGetBounds(
  303. HIShapeRef inShape,
  304. HIRect * outRect);
  305. /*
  306. * HIShapeGetAsQDRgn()
  307. *
  308. * Discussion:
  309. * Changes a given Quickdraw region handle to have the same shape as
  310. * a given HIShapeRef. Essentially you are converting an HIShapeRef
  311. * into a RgnHandle. This conversion may lose fidelity depending on
  312. * how the shape was created originally.
  313. *
  314. * Parameters:
  315. *
  316. * inShape:
  317. * An existing HIShapeRef.
  318. *
  319. * outRgn:
  320. * An existing region to change.
  321. *
  322. * Result:
  323. * An operating system status code.
  324. *
  325. * Availability:
  326. * Non-Carbon CFM: not available
  327. * CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.2 and later
  328. * Mac OS X: in version 10.2 and later
  329. */
  330. EXTERN_API_C( OSStatus )
  331. HIShapeGetAsQDRgn(
  332. HIShapeRef inShape,
  333. RgnHandle outRgn);
  334. /*
  335. * HIShapeReplacePathInCGContext()
  336. *
  337. * Discussion:
  338. * Given an HIShapeRef and a CGContextRef, make the current path in
  339. * the context represent the shape. You might use this to clip to a
  340. * shape, for example. You could call this function and then
  341. * immediately call CGContextClip.
  342. *
  343. * Parameters:
  344. *
  345. * inShape:
  346. * An existing HIShapeRef.
  347. *
  348. * inContext:
  349. * The context to apply the shape to.
  350. *
  351. * Result:
  352. * An operating system status code.
  353. *
  354. * Availability:
  355. * Non-Carbon CFM: not available
  356. * CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.2 and later
  357. * Mac OS X: in version 10.2 and later
  358. */
  359. EXTERN_API_C( OSStatus )
  360. HIShapeReplacePathInCGContext(
  361. HIShapeRef inShape,
  362. CGContextRef inContext);
  363. /*
  364. * HIShapeSetQDClip()
  365. *
  366. * Discussion:
  367. * Given an HIShapeRef and a Quickdraw port, set the current clip in
  368. * the port to the shape.
  369. *
  370. * Parameters:
  371. *
  372. * inShape:
  373. * An existing HIShapeRef.
  374. *
  375. * inPort:
  376. * The port to set the clip for.
  377. *
  378. * Result:
  379. * An operating system status code.
  380. *
  381. * Availability:
  382. * Non-Carbon CFM: not available
  383. * CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.2 and later
  384. * Mac OS X: in version 10.2 and later
  385. */
  386. EXTERN_API_C( OSStatus )
  387. HIShapeSetQDClip(
  388. HIShapeRef inShape,
  389. CGrafPtr inPort);
  390. /*======================================================================================*/
  391. /* MUTABLE FUNCTIONS */
  392. /*======================================================================================*/
  393. /*
  394. * HIShapeCreateMutable()
  395. *
  396. * Discussion:
  397. * Creates a new, mutable, empty shape.
  398. *
  399. * Result:
  400. * A mutable shape reference.
  401. *
  402. * Availability:
  403. * Non-Carbon CFM: not available
  404. * CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.2 and later
  405. * Mac OS X: in version 10.2 and later
  406. */
  407. EXTERN_API_C( HIMutableShapeRef )
  408. HIShapeCreateMutable(void);
  409. /*
  410. * HIShapeCreateMutableCopy()
  411. *
  412. * Discussion:
  413. * Given an existing HIShapeRef, creates a new mutable copy.
  414. *
  415. * Parameters:
  416. *
  417. * inOrig:
  418. * The shape to copy.
  419. *
  420. * Result:
  421. * A mutable shape reference.
  422. *
  423. * Availability:
  424. * Non-Carbon CFM: not available
  425. * CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.2 and later
  426. * Mac OS X: in version 10.2 and later
  427. */
  428. EXTERN_API_C( HIMutableShapeRef )
  429. HIShapeCreateMutableCopy(HIShapeRef inOrig);
  430. /*
  431. * HIShapeSetEmpty()
  432. *
  433. * Discussion:
  434. * Sets a mutable shape to be an empty shape.
  435. *
  436. * Parameters:
  437. *
  438. * inShape:
  439. * The shape to empty.
  440. *
  441. * Result:
  442. * An operating system status code.
  443. *
  444. * Availability:
  445. * Non-Carbon CFM: not available
  446. * CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.2 and later
  447. * Mac OS X: in version 10.2 and later
  448. */
  449. EXTERN_API_C( OSStatus )
  450. HIShapeSetEmpty(HIMutableShapeRef inShape);
  451. /*
  452. * HIShapeIntersect()
  453. *
  454. * Discussion:
  455. * Takes two shapes and sets a third to be their intersection.
  456. *
  457. * Parameters:
  458. *
  459. * inShape1:
  460. * The first shape.
  461. *
  462. * inShape2:
  463. * The second shape.
  464. *
  465. * outResult:
  466. * The shape to receive the result of the intersection. This can
  467. * be one of the source shapes.
  468. *
  469. * Result:
  470. * An operating system status code.
  471. *
  472. * Availability:
  473. * Non-Carbon CFM: not available
  474. * CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.2 and later
  475. * Mac OS X: in version 10.2 and later
  476. */
  477. EXTERN_API_C( OSStatus )
  478. HIShapeIntersect(
  479. HIShapeRef inShape1,
  480. HIShapeRef inShape2,
  481. HIMutableShapeRef outResult);
  482. /*
  483. * HIShapeDifference()
  484. *
  485. * Discussion:
  486. * Takes two shapes and sets a third to be their difference. The
  487. * second shape is subtracted from the first.
  488. *
  489. * Parameters:
  490. *
  491. * inShape1:
  492. * The first shape.
  493. *
  494. * inShape2:
  495. * The second shape.
  496. *
  497. * outResult:
  498. * The shape to receive the result of the intersection. This can
  499. * be one of the source shapes.
  500. *
  501. * Result:
  502. * An operating system status code.
  503. *
  504. * Availability:
  505. * Non-Carbon CFM: not available
  506. * CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.2 and later
  507. * Mac OS X: in version 10.2 and later
  508. */
  509. EXTERN_API_C( OSStatus )
  510. HIShapeDifference(
  511. HIShapeRef inShape1,
  512. HIShapeRef inShape2,
  513. HIMutableShapeRef outResult);
  514. /*
  515. * HIShapeUnion()
  516. *
  517. * Discussion:
  518. * Takes two shapes and sets a third to be their union.
  519. *
  520. * Parameters:
  521. *
  522. * inShape1:
  523. * The first shape.
  524. *
  525. * inShape2:
  526. * The second shape.
  527. *
  528. * outResult:
  529. * The shape to receive the result of the union. This can be one
  530. * of the source shapes.
  531. *
  532. * Result:
  533. * An operating system status code.
  534. *
  535. * Availability:
  536. * Non-Carbon CFM: not available
  537. * CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.2 and later
  538. * Mac OS X: in version 10.2 and later
  539. */
  540. EXTERN_API_C( OSStatus )
  541. HIShapeUnion(
  542. HIShapeRef inShape1,
  543. HIShapeRef inShape2,
  544. HIMutableShapeRef outResult);
  545. /*
  546. * HIShapeOffset()
  547. *
  548. * Discussion:
  549. * Offsets a shape by some delta.
  550. *
  551. * Parameters:
  552. *
  553. * inShape:
  554. * The shape to offset.
  555. *
  556. * inDX:
  557. * The delta to move the shape on the X axis.
  558. *
  559. * inDY:
  560. * The delta to move the shape on the Y axis.
  561. *
  562. * Result:
  563. * An operating system status code.
  564. *
  565. * Availability:
  566. * Non-Carbon CFM: not available
  567. * CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.2 and later
  568. * Mac OS X: in version 10.2 and later
  569. */
  570. EXTERN_API_C( OSStatus )
  571. HIShapeOffset(
  572. HIMutableShapeRef inShape,
  573. float inDX,
  574. float inDY);
  575. #ifdef PRAGMA_IMPORT_OFF
  576. #pragma import off
  577. #elif PRAGMA_IMPORT
  578. #pragma import reset
  579. #endif
  580. #ifdef __cplusplus
  581. }
  582. #endif
  583. #endif /* __HISHAPE__ */