Source code of Windows XP (NT5)
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.

2642 lines
87 KiB

  1. /**************************************************************************\
  2. *
  3. * Copyright (c) 1998-2000, Microsoft Corp. All Rights Reserved.
  4. *
  5. * Module Name:
  6. *
  7. * Graphics.hpp
  8. *
  9. * Abstract:
  10. *
  11. * Declarations for Graphics class
  12. *
  13. * Revision History:
  14. *
  15. * 12/04/1998 davidx
  16. * Created it.
  17. *
  18. \**************************************************************************/
  19. #ifndef _GDIPLUSGRAPHICS_H
  20. #define _GDIPLUSGRAPHICS_H
  21. /**
  22. * Represent a graphics context
  23. */
  24. class Graphics : public GdiplusBase
  25. {
  26. public:
  27. friend class Region;
  28. friend class GraphicsPath;
  29. friend class Image;
  30. friend class Bitmap;
  31. friend class Metafile;
  32. friend class Font;
  33. friend class FontFamily;
  34. friend class FontCollection;
  35. friend class CachedBitmap;
  36. // Get a graphics context from an existing Win32 HDC or HWND
  37. static Graphics* FromHDC(IN HDC hdc)
  38. {
  39. return new Graphics(hdc);
  40. }
  41. static Graphics* FromHDC(IN HDC hdc,
  42. IN HANDLE hdevice)
  43. {
  44. return new Graphics(hdc, hdevice);
  45. }
  46. static Graphics* FromHWND(IN HWND hwnd,
  47. IN BOOL icm = FALSE)
  48. {
  49. return new Graphics(hwnd, icm);
  50. }
  51. static Graphics* FromImage(IN Image *image)
  52. {
  53. return new Graphics(image);
  54. }
  55. Graphics(IN HDC hdc)
  56. {
  57. GpGraphics *graphics = NULL;
  58. lastResult = DllExports::GdipCreateFromHDC(hdc, &graphics);
  59. SetNativeGraphics(graphics);
  60. }
  61. Graphics(IN HDC hdc,
  62. IN HANDLE hdevice)
  63. {
  64. GpGraphics *graphics = NULL;
  65. lastResult = DllExports::GdipCreateFromHDC2(hdc, hdevice, &graphics);
  66. SetNativeGraphics(graphics);
  67. }
  68. Graphics(IN HWND hwnd,
  69. IN BOOL icm = FALSE)
  70. {
  71. GpGraphics *graphics = NULL;
  72. if (icm)
  73. {
  74. lastResult = DllExports::GdipCreateFromHWNDICM(hwnd, &graphics);
  75. }
  76. else
  77. {
  78. lastResult = DllExports::GdipCreateFromHWND(hwnd, &graphics);
  79. }
  80. SetNativeGraphics(graphics);
  81. }
  82. Graphics(IN Image* image)
  83. {
  84. GpGraphics *graphics = NULL;
  85. if (image != NULL)
  86. {
  87. lastResult = DllExports::GdipGetImageGraphicsContext(
  88. image->nativeImage, &graphics);
  89. }
  90. SetNativeGraphics(graphics);
  91. }
  92. ~Graphics()
  93. {
  94. DllExports::GdipDeleteGraphics(nativeGraphics);
  95. }
  96. VOID Flush(IN FlushIntention intention = FlushIntentionFlush)
  97. {
  98. DllExports::GdipFlush(nativeGraphics, intention);
  99. }
  100. //------------------------------------------------------------------------
  101. // Interop methods
  102. //------------------------------------------------------------------------
  103. // Locks the graphics until ReleaseDC is called
  104. HDC GetHDC()
  105. {
  106. HDC hdc = NULL;
  107. SetStatus(DllExports::GdipGetDC(nativeGraphics, &hdc));
  108. return hdc;
  109. }
  110. VOID ReleaseHDC(IN HDC hdc)
  111. {
  112. SetStatus(DllExports::GdipReleaseDC(nativeGraphics, hdc));
  113. }
  114. //------------------------------------------------------------------------
  115. // Rendering modes
  116. //------------------------------------------------------------------------
  117. Status SetRenderingOrigin(IN INT x, IN INT y)
  118. {
  119. return SetStatus(
  120. DllExports::GdipSetRenderingOrigin(
  121. nativeGraphics, x, y
  122. )
  123. );
  124. }
  125. Status GetRenderingOrigin(OUT INT *x, OUT INT *y)
  126. {
  127. return SetStatus(
  128. DllExports::GdipGetRenderingOrigin(
  129. nativeGraphics, x, y
  130. )
  131. );
  132. }
  133. Status SetCompositingMode(IN CompositingMode compositingMode)
  134. {
  135. return SetStatus(DllExports::GdipSetCompositingMode(nativeGraphics,
  136. compositingMode));
  137. }
  138. CompositingMode GetCompositingMode() const
  139. {
  140. CompositingMode mode;
  141. SetStatus(DllExports::GdipGetCompositingMode(nativeGraphics,
  142. &mode));
  143. return mode;
  144. }
  145. Status SetCompositingQuality(IN CompositingQuality compositingQuality)
  146. {
  147. return SetStatus(DllExports::GdipSetCompositingQuality(
  148. nativeGraphics,
  149. compositingQuality));
  150. }
  151. CompositingQuality GetCompositingQuality() const
  152. {
  153. CompositingQuality quality;
  154. SetStatus(DllExports::GdipGetCompositingQuality(
  155. nativeGraphics,
  156. &quality));
  157. return quality;
  158. }
  159. Status SetTextRenderingHint(IN TextRenderingHint newMode)
  160. {
  161. return SetStatus(DllExports::GdipSetTextRenderingHint(nativeGraphics,
  162. newMode));
  163. }
  164. TextRenderingHint GetTextRenderingHint() const
  165. {
  166. TextRenderingHint hint;
  167. SetStatus(DllExports::GdipGetTextRenderingHint(nativeGraphics,
  168. &hint));
  169. return hint;
  170. }
  171. Status SetTextGammaValue(IN UINT gammaValue)
  172. {
  173. return SetStatus(DllExports::GdipSetTextGammaValue(nativeGraphics,
  174. gammaValue));
  175. }
  176. UINT GetTextGammaValue() const
  177. {
  178. UINT gammaValue;
  179. SetStatus(DllExports::GdipGetTextGammaValue(nativeGraphics,
  180. &gammaValue));
  181. return gammaValue;
  182. }
  183. InterpolationMode GetInterpolationMode() const
  184. {
  185. InterpolationMode mode = InterpolationModeInvalid;
  186. SetStatus(DllExports::GdipGetInterpolationMode(nativeGraphics,
  187. &mode));
  188. return mode;
  189. }
  190. Status SetInterpolationMode(IN InterpolationMode interpolationMode)
  191. {
  192. return SetStatus(DllExports::GdipSetInterpolationMode(nativeGraphics,
  193. interpolationMode));
  194. }
  195. SmoothingMode GetSmoothingMode() const
  196. {
  197. SmoothingMode smoothingMode = SmoothingModeInvalid;
  198. SetStatus(DllExports::GdipGetSmoothingMode(nativeGraphics,
  199. &smoothingMode));
  200. return smoothingMode;
  201. }
  202. Status SetSmoothingMode(IN SmoothingMode smoothingMode)
  203. {
  204. return SetStatus(DllExports::GdipSetSmoothingMode(nativeGraphics,
  205. smoothingMode));
  206. }
  207. PixelOffsetMode GetPixelOffsetMode() const
  208. {
  209. PixelOffsetMode pixelOffsetMode = PixelOffsetModeInvalid;
  210. SetStatus(DllExports::GdipGetPixelOffsetMode(nativeGraphics,
  211. &pixelOffsetMode));
  212. return pixelOffsetMode;
  213. }
  214. Status SetPixelOffsetMode(IN PixelOffsetMode pixelOffsetMode)
  215. {
  216. return SetStatus(DllExports::GdipSetPixelOffsetMode(nativeGraphics,
  217. pixelOffsetMode));
  218. }
  219. //------------------------------------------------------------------------
  220. // Manipulate the current world transform
  221. //------------------------------------------------------------------------
  222. Status SetTransform(IN const Matrix* matrix)
  223. {
  224. return SetStatus(DllExports::GdipSetWorldTransform(nativeGraphics,
  225. matrix->nativeMatrix));
  226. }
  227. Status ResetTransform()
  228. {
  229. return SetStatus(DllExports::GdipResetWorldTransform(nativeGraphics));
  230. }
  231. Status MultiplyTransform(IN Matrix* matrix,
  232. IN MatrixOrder order = MatrixOrderPrepend)
  233. {
  234. return SetStatus(DllExports::GdipMultiplyWorldTransform(nativeGraphics,
  235. matrix->nativeMatrix,
  236. order));
  237. }
  238. Status TranslateTransform(IN REAL dx,
  239. IN REAL dy,
  240. IN MatrixOrder order = MatrixOrderPrepend)
  241. {
  242. return SetStatus(DllExports::GdipTranslateWorldTransform(nativeGraphics,
  243. dx, dy, order));
  244. }
  245. Status ScaleTransform(IN REAL sx,
  246. IN REAL sy,
  247. IN MatrixOrder order = MatrixOrderPrepend)
  248. {
  249. return SetStatus(DllExports::GdipScaleWorldTransform(nativeGraphics,
  250. sx, sy, order));
  251. }
  252. Status RotateTransform(IN REAL angle,
  253. IN MatrixOrder order = MatrixOrderPrepend)
  254. {
  255. return SetStatus(DllExports::GdipRotateWorldTransform(nativeGraphics,
  256. angle, order));
  257. }
  258. /**
  259. * Return the current world transform
  260. */
  261. Status GetTransform(OUT Matrix* matrix) const
  262. {
  263. return SetStatus(DllExports::GdipGetWorldTransform(nativeGraphics,
  264. matrix->nativeMatrix));
  265. }
  266. /**
  267. * Manipulate the current page transform
  268. */
  269. Status SetPageUnit(IN Unit unit)
  270. {
  271. return SetStatus(DllExports::GdipSetPageUnit(nativeGraphics,
  272. unit));
  273. }
  274. Status SetPageScale(IN REAL scale)
  275. {
  276. return SetStatus(DllExports::GdipSetPageScale(nativeGraphics,
  277. scale));
  278. }
  279. /**
  280. * Retrieve the current page transform information
  281. * notes @ these are atomic
  282. */
  283. Unit GetPageUnit() const
  284. {
  285. Unit unit;
  286. SetStatus(DllExports::GdipGetPageUnit(nativeGraphics, &unit));
  287. return unit;
  288. }
  289. REAL GetPageScale() const
  290. {
  291. REAL scale;
  292. SetStatus(DllExports::GdipGetPageScale(nativeGraphics, &scale));
  293. return scale;
  294. }
  295. REAL GetDpiX() const
  296. {
  297. REAL dpi;
  298. SetStatus(DllExports::GdipGetDpiX(nativeGraphics, &dpi));
  299. return dpi;
  300. }
  301. REAL GetDpiY() const
  302. {
  303. REAL dpi;
  304. SetStatus(DllExports::GdipGetDpiY(nativeGraphics, &dpi));
  305. return dpi;
  306. }
  307. /**
  308. * Transform points in the current graphics context
  309. */
  310. // float version
  311. Status TransformPoints(IN CoordinateSpace destSpace,
  312. IN CoordinateSpace srcSpace,
  313. IN OUT PointF* pts,
  314. IN INT count) const
  315. {
  316. return SetStatus(DllExports::GdipTransformPoints(nativeGraphics,
  317. destSpace,
  318. srcSpace,
  319. pts,
  320. count));
  321. }
  322. // integer version
  323. Status TransformPoints(IN CoordinateSpace destSpace,
  324. IN CoordinateSpace srcSpace,
  325. IN OUT Point* pts,
  326. IN INT count) const
  327. {
  328. return SetStatus(DllExports::GdipTransformPointsI(nativeGraphics,
  329. destSpace,
  330. srcSpace,
  331. pts,
  332. count));
  333. }
  334. //------------------------------------------------------------------------
  335. // GetNearestColor (for <= 8bpp surfaces)
  336. // Note: alpha is ignored
  337. //------------------------------------------------------------------------
  338. Status GetNearestColor(IN OUT Color* color) const
  339. {
  340. if (color == NULL)
  341. {
  342. return SetStatus(InvalidParameter);
  343. }
  344. ARGB argb = color->GetValue();
  345. Status status = SetStatus(DllExports::GdipGetNearestColor(nativeGraphics, &argb));
  346. color->SetValue(argb);
  347. return status;
  348. }
  349. /**
  350. * Vector drawing methods
  351. *
  352. * @notes Do we need a set of methods that take
  353. * integer coordinate parameters?
  354. */
  355. // float version
  356. Status DrawLine(IN const Pen* pen,
  357. IN REAL x1,
  358. IN REAL y1,
  359. IN REAL x2,
  360. IN REAL y2)
  361. {
  362. return SetStatus(DllExports::GdipDrawLine(nativeGraphics,
  363. pen->nativePen, x1, y1, x2,
  364. y2));
  365. }
  366. Status DrawLine(IN const Pen* pen,
  367. IN const PointF& pt1,
  368. IN const PointF& pt2)
  369. {
  370. return DrawLine(pen, pt1.X, pt1.Y, pt2.X, pt2.Y);
  371. }
  372. Status DrawLines(IN const Pen* pen,
  373. IN const PointF* points,
  374. IN INT count)
  375. {
  376. return SetStatus(DllExports::GdipDrawLines(nativeGraphics,
  377. pen->nativePen,
  378. points, count));
  379. }
  380. // int version
  381. Status DrawLine(IN const Pen* pen,
  382. IN INT x1,
  383. IN INT y1,
  384. IN INT x2,
  385. IN INT y2)
  386. {
  387. return SetStatus(DllExports::GdipDrawLineI(nativeGraphics,
  388. pen->nativePen,
  389. x1,
  390. y1,
  391. x2,
  392. y2));
  393. }
  394. Status DrawLine(IN const Pen* pen,
  395. IN const Point& pt1,
  396. IN const Point& pt2)
  397. {
  398. return DrawLine(pen,
  399. pt1.X,
  400. pt1.Y,
  401. pt2.X,
  402. pt2.Y);
  403. }
  404. Status DrawLines(IN const Pen* pen,
  405. IN const Point* points,
  406. IN INT count)
  407. {
  408. return SetStatus(DllExports::GdipDrawLinesI(nativeGraphics,
  409. pen->nativePen,
  410. points,
  411. count));
  412. }
  413. // float version
  414. Status DrawArc(IN const Pen* pen,
  415. IN REAL x,
  416. IN REAL y,
  417. IN REAL width,
  418. IN REAL height,
  419. IN REAL startAngle,
  420. IN REAL sweepAngle)
  421. {
  422. return SetStatus(DllExports::GdipDrawArc(nativeGraphics,
  423. pen->nativePen,
  424. x,
  425. y,
  426. width,
  427. height,
  428. startAngle,
  429. sweepAngle));
  430. }
  431. Status DrawArc(IN const Pen* pen,
  432. IN const RectF& rect,
  433. IN REAL startAngle,
  434. IN REAL sweepAngle)
  435. {
  436. return DrawArc(pen, rect.X, rect.Y, rect.Width, rect.Height,
  437. startAngle, sweepAngle);
  438. }
  439. // int version
  440. Status DrawArc(IN const Pen* pen,
  441. IN INT x,
  442. IN INT y,
  443. IN INT width,
  444. IN INT height,
  445. IN REAL startAngle,
  446. IN REAL sweepAngle)
  447. {
  448. return SetStatus(DllExports::GdipDrawArcI(nativeGraphics,
  449. pen->nativePen,
  450. x,
  451. y,
  452. width,
  453. height,
  454. startAngle,
  455. sweepAngle));
  456. }
  457. Status DrawArc(IN const Pen* pen,
  458. IN const Rect& rect,
  459. IN REAL startAngle,
  460. IN REAL sweepAngle)
  461. {
  462. return DrawArc(pen,
  463. rect.X,
  464. rect.Y,
  465. rect.Width,
  466. rect.Height,
  467. startAngle,
  468. sweepAngle);
  469. }
  470. // float version
  471. Status DrawBezier(IN const Pen* pen,
  472. IN REAL x1,
  473. IN REAL y1,
  474. IN REAL x2,
  475. IN REAL y2,
  476. IN REAL x3,
  477. IN REAL y3,
  478. IN REAL x4,
  479. IN REAL y4)
  480. {
  481. return SetStatus(DllExports::GdipDrawBezier(nativeGraphics,
  482. pen->nativePen, x1, y1,
  483. x2, y2, x3, y3, x4, y4));
  484. }
  485. Status DrawBezier(IN const Pen* pen,
  486. IN const PointF& pt1,
  487. IN const PointF& pt2,
  488. IN const PointF& pt3,
  489. IN const PointF& pt4)
  490. {
  491. return DrawBezier(pen,
  492. pt1.X,
  493. pt1.Y,
  494. pt2.X,
  495. pt2.Y,
  496. pt3.X,
  497. pt3.Y,
  498. pt4.X,
  499. pt4.Y);
  500. }
  501. Status DrawBeziers(IN const Pen* pen,
  502. IN const PointF* points,
  503. IN INT count)
  504. {
  505. return SetStatus(DllExports::GdipDrawBeziers(nativeGraphics,
  506. pen->nativePen,
  507. points,
  508. count));
  509. }
  510. // int version
  511. Status DrawBezier(IN const Pen* pen,
  512. IN INT x1,
  513. IN INT y1,
  514. IN INT x2,
  515. IN INT y2,
  516. IN INT x3,
  517. IN INT y3,
  518. IN INT x4,
  519. IN INT y4)
  520. {
  521. return SetStatus(DllExports::GdipDrawBezierI(nativeGraphics,
  522. pen->nativePen,
  523. x1,
  524. y1,
  525. x2,
  526. y2,
  527. x3,
  528. y3,
  529. x4,
  530. y4));
  531. }
  532. Status DrawBezier(IN const Pen* pen,
  533. IN const Point& pt1,
  534. IN const Point& pt2,
  535. IN const Point& pt3,
  536. IN const Point& pt4)
  537. {
  538. return DrawBezier(pen,
  539. pt1.X,
  540. pt1.Y,
  541. pt2.X,
  542. pt2.Y,
  543. pt3.X,
  544. pt3.Y,
  545. pt4.X,
  546. pt4.Y);
  547. }
  548. Status DrawBeziers(IN const Pen* pen,
  549. IN const Point* points,
  550. IN INT count)
  551. {
  552. return SetStatus(DllExports::GdipDrawBeziersI(nativeGraphics,
  553. pen->nativePen,
  554. points,
  555. count));
  556. }
  557. // float version
  558. Status DrawRectangle(IN const Pen* pen,
  559. IN const RectF& rect)
  560. {
  561. return DrawRectangle(pen, rect.X, rect.Y, rect.Width, rect.Height);
  562. }
  563. Status DrawRectangle(IN const Pen* pen,
  564. IN REAL x,
  565. IN REAL y,
  566. IN REAL width,
  567. IN REAL height)
  568. {
  569. return SetStatus(DllExports::GdipDrawRectangle(nativeGraphics,
  570. pen->nativePen, x, y,
  571. width, height));
  572. }
  573. Status DrawRectangles(IN const Pen* pen,
  574. IN const RectF* rects,
  575. IN INT count)
  576. {
  577. return SetStatus(DllExports::GdipDrawRectangles(nativeGraphics,
  578. pen->nativePen,
  579. rects, count));
  580. }
  581. // integer version
  582. Status DrawRectangle(IN const Pen* pen,
  583. IN const Rect& rect)
  584. {
  585. return DrawRectangle(pen,
  586. rect.X,
  587. rect.Y,
  588. rect.Width,
  589. rect.Height);
  590. }
  591. Status DrawRectangle(IN const Pen* pen,
  592. IN INT x,
  593. IN INT y,
  594. IN INT width,
  595. IN INT height)
  596. {
  597. return SetStatus(DllExports::GdipDrawRectangleI(nativeGraphics,
  598. pen->nativePen,
  599. x,
  600. y,
  601. width,
  602. height));
  603. }
  604. Status DrawRectangles(IN const Pen* pen,
  605. IN const Rect* rects,
  606. IN INT count)
  607. {
  608. return SetStatus(DllExports::GdipDrawRectanglesI(nativeGraphics,
  609. pen->nativePen,
  610. rects,
  611. count));
  612. }
  613. // float version
  614. Status DrawEllipse(IN const Pen* pen,
  615. IN const RectF& rect)
  616. {
  617. return DrawEllipse(pen, rect.X, rect.Y, rect.Width, rect.Height);
  618. }
  619. Status DrawEllipse(IN const Pen* pen,
  620. IN REAL x,
  621. IN REAL y,
  622. IN REAL width,
  623. IN REAL height)
  624. {
  625. return SetStatus(DllExports::GdipDrawEllipse(nativeGraphics,
  626. pen->nativePen,
  627. x,
  628. y,
  629. width,
  630. height));
  631. }
  632. // integer version
  633. Status DrawEllipse(IN const Pen* pen,
  634. IN const Rect& rect)
  635. {
  636. return DrawEllipse(pen,
  637. rect.X,
  638. rect.Y,
  639. rect.Width,
  640. rect.Height);
  641. }
  642. Status DrawEllipse(IN const Pen* pen,
  643. IN INT x,
  644. IN INT y,
  645. IN INT width,
  646. IN INT height)
  647. {
  648. return SetStatus(DllExports::GdipDrawEllipseI(nativeGraphics,
  649. pen->nativePen,
  650. x,
  651. y,
  652. width,
  653. height));
  654. }
  655. // floating point version
  656. Status DrawPie(IN const Pen* pen,
  657. IN const RectF& rect,
  658. IN REAL startAngle,
  659. IN REAL sweepAngle)
  660. {
  661. return DrawPie(pen,
  662. rect.X,
  663. rect.Y,
  664. rect.Width,
  665. rect.Height,
  666. startAngle,
  667. sweepAngle);
  668. }
  669. Status DrawPie(IN const Pen* pen,
  670. IN REAL x,
  671. IN REAL y,
  672. IN REAL width,
  673. IN REAL height,
  674. IN REAL startAngle,
  675. IN REAL sweepAngle)
  676. {
  677. return SetStatus(DllExports::GdipDrawPie(nativeGraphics,
  678. pen->nativePen,
  679. x,
  680. y,
  681. width,
  682. height,
  683. startAngle,
  684. sweepAngle));
  685. }
  686. // integer point version
  687. Status DrawPie(IN const Pen* pen,
  688. IN const Rect& rect,
  689. IN REAL startAngle,
  690. IN REAL sweepAngle)
  691. {
  692. return DrawPie(pen,
  693. rect.X,
  694. rect.Y,
  695. rect.Width,
  696. rect.Height,
  697. startAngle,
  698. sweepAngle);
  699. }
  700. Status DrawPie(IN const Pen* pen,
  701. IN INT x,
  702. IN INT y,
  703. IN INT width,
  704. IN INT height,
  705. IN REAL startAngle,
  706. IN REAL sweepAngle)
  707. {
  708. return SetStatus(DllExports::GdipDrawPieI(nativeGraphics,
  709. pen->nativePen,
  710. x,
  711. y,
  712. width,
  713. height,
  714. startAngle,
  715. sweepAngle));
  716. }
  717. // float version
  718. Status DrawPolygon(IN const Pen* pen,
  719. IN const PointF* points,
  720. IN INT count)
  721. {
  722. return SetStatus(DllExports::GdipDrawPolygon(nativeGraphics,
  723. pen->nativePen,
  724. points,
  725. count));
  726. }
  727. // integer version
  728. Status DrawPolygon(IN const Pen* pen,
  729. IN const Point* points,
  730. IN INT count)
  731. {
  732. return SetStatus(DllExports::GdipDrawPolygonI(nativeGraphics,
  733. pen->nativePen,
  734. points,
  735. count));
  736. }
  737. // float version
  738. Status DrawPath(IN const Pen* pen,
  739. IN const GraphicsPath* path)
  740. {
  741. return SetStatus(DllExports::GdipDrawPath(nativeGraphics,
  742. pen->nativePen,
  743. path->nativePath));
  744. }
  745. // float version
  746. Status DrawCurve(IN const Pen* pen,
  747. IN const PointF* points,
  748. IN INT count)
  749. {
  750. return SetStatus(DllExports::GdipDrawCurve(nativeGraphics,
  751. pen->nativePen, points,
  752. count));
  753. }
  754. Status DrawCurve(IN const Pen* pen,
  755. IN const PointF* points,
  756. IN INT count,
  757. IN REAL tension)
  758. {
  759. return SetStatus(DllExports::GdipDrawCurve2(nativeGraphics,
  760. pen->nativePen, points,
  761. count, tension));
  762. }
  763. Status DrawCurve(IN const Pen* pen,
  764. IN const PointF* points,
  765. IN INT count,
  766. IN INT offset,
  767. IN INT numberOfSegments,
  768. IN REAL tension = 0.5f)
  769. {
  770. return SetStatus(DllExports::GdipDrawCurve3(nativeGraphics,
  771. pen->nativePen, points,
  772. count, offset,
  773. numberOfSegments, tension));
  774. }
  775. // integer version
  776. Status DrawCurve(IN const Pen* pen,
  777. IN const Point* points,
  778. IN INT count)
  779. {
  780. return SetStatus(DllExports::GdipDrawCurveI(nativeGraphics,
  781. pen->nativePen,
  782. points,
  783. count));
  784. }
  785. Status DrawCurve(IN const Pen* pen,
  786. IN const Point* points,
  787. IN INT count,
  788. IN REAL tension)
  789. {
  790. return SetStatus(DllExports::GdipDrawCurve2I(nativeGraphics,
  791. pen->nativePen,
  792. points,
  793. count,
  794. tension));
  795. }
  796. Status DrawCurve(IN const Pen* pen,
  797. IN const Point* points,
  798. IN INT count,
  799. IN INT offset,
  800. IN INT numberOfSegments,
  801. IN REAL tension = 0.5f)
  802. {
  803. return SetStatus(DllExports::GdipDrawCurve3I(nativeGraphics,
  804. pen->nativePen,
  805. points,
  806. count,
  807. offset,
  808. numberOfSegments,
  809. tension));
  810. }
  811. // float version
  812. Status DrawClosedCurve(IN const Pen* pen,
  813. IN const PointF* points,
  814. IN INT count)
  815. {
  816. return SetStatus(DllExports::GdipDrawClosedCurve(nativeGraphics,
  817. pen->nativePen,
  818. points, count));
  819. }
  820. Status DrawClosedCurve(IN const Pen *pen,
  821. IN const PointF* points,
  822. IN INT count,
  823. IN REAL tension)
  824. {
  825. return SetStatus(DllExports::GdipDrawClosedCurve2(nativeGraphics,
  826. pen->nativePen,
  827. points, count,
  828. tension));
  829. }
  830. // integer version
  831. Status DrawClosedCurve(IN const Pen* pen,
  832. IN const Point* points,
  833. IN INT count)
  834. {
  835. return SetStatus(DllExports::GdipDrawClosedCurveI(nativeGraphics,
  836. pen->nativePen,
  837. points,
  838. count));
  839. }
  840. Status DrawClosedCurve(IN const Pen *pen,
  841. IN const Point* points,
  842. IN INT count,
  843. IN REAL tension)
  844. {
  845. return SetStatus(DllExports::GdipDrawClosedCurve2I(nativeGraphics,
  846. pen->nativePen,
  847. points,
  848. count,
  849. tension));
  850. }
  851. Status Clear(IN const Color &color)
  852. {
  853. return SetStatus(DllExports::GdipGraphicsClear(
  854. nativeGraphics,
  855. color.GetValue()));
  856. }
  857. // float version
  858. Status FillRectangle(IN const Brush* brush,
  859. IN const RectF& rect)
  860. {
  861. return FillRectangle(brush, rect.X, rect.Y, rect.Width, rect.Height);
  862. }
  863. Status FillRectangle(IN const Brush* brush,
  864. IN REAL x,
  865. IN REAL y,
  866. IN REAL width,
  867. IN REAL height)
  868. {
  869. return SetStatus(DllExports::GdipFillRectangle(nativeGraphics,
  870. brush->nativeBrush, x, y,
  871. width, height));
  872. }
  873. Status FillRectangles(IN const Brush* brush,
  874. IN const RectF* rects,
  875. IN INT count)
  876. {
  877. return SetStatus(DllExports::GdipFillRectangles(nativeGraphics,
  878. brush->nativeBrush,
  879. rects, count));
  880. }
  881. // integer version
  882. Status FillRectangle(IN const Brush* brush,
  883. IN const Rect& rect)
  884. {
  885. return FillRectangle(brush,
  886. rect.X,
  887. rect.Y,
  888. rect.Width,
  889. rect.Height);
  890. }
  891. Status FillRectangle(IN const Brush* brush,
  892. IN INT x,
  893. IN INT y,
  894. IN INT width,
  895. IN INT height)
  896. {
  897. return SetStatus(DllExports::GdipFillRectangleI(nativeGraphics,
  898. brush->nativeBrush,
  899. x,
  900. y,
  901. width,
  902. height));
  903. }
  904. Status FillRectangles(IN const Brush* brush,
  905. IN const Rect* rects,
  906. IN INT count)
  907. {
  908. return SetStatus(DllExports::GdipFillRectanglesI(nativeGraphics,
  909. brush->nativeBrush,
  910. rects,
  911. count));
  912. }
  913. // float version
  914. Status FillPolygon(IN const Brush* brush,
  915. IN const PointF* points,
  916. IN INT count)
  917. {
  918. return FillPolygon(brush, points, count, FillModeAlternate);
  919. }
  920. Status FillPolygon(IN const Brush* brush,
  921. IN const PointF* points,
  922. IN INT count,
  923. IN FillMode fillMode)
  924. {
  925. return SetStatus(DllExports::GdipFillPolygon(nativeGraphics,
  926. brush->nativeBrush,
  927. points, count, fillMode));
  928. }
  929. // integer version
  930. Status FillPolygon(IN const Brush* brush,
  931. IN const Point* points,
  932. IN INT count)
  933. {
  934. return FillPolygon(brush, points, count, FillModeAlternate);
  935. }
  936. Status FillPolygon(IN const Brush* brush,
  937. IN const Point* points,
  938. IN INT count,
  939. IN FillMode fillMode)
  940. {
  941. return SetStatus(DllExports::GdipFillPolygonI(nativeGraphics,
  942. brush->nativeBrush,
  943. points, count,
  944. fillMode));
  945. }
  946. // float version
  947. Status FillEllipse(IN const Brush* brush,
  948. IN const RectF& rect)
  949. {
  950. return FillEllipse(brush, rect.X, rect.Y, rect.Width, rect.Height);
  951. }
  952. Status FillEllipse(IN const Brush* brush,
  953. IN REAL x,
  954. IN REAL y,
  955. IN REAL width,
  956. IN REAL height)
  957. {
  958. return SetStatus(DllExports::GdipFillEllipse(nativeGraphics,
  959. brush->nativeBrush, x, y,
  960. width, height));
  961. }
  962. // integer version
  963. Status FillEllipse(IN const Brush* brush,
  964. IN const Rect& rect)
  965. {
  966. return FillEllipse(brush, rect.X, rect.Y, rect.Width, rect.Height);
  967. }
  968. Status FillEllipse(IN const Brush* brush,
  969. IN INT x,
  970. IN INT y,
  971. IN INT width,
  972. IN INT height)
  973. {
  974. return SetStatus(DllExports::GdipFillEllipseI(nativeGraphics,
  975. brush->nativeBrush,
  976. x,
  977. y,
  978. width,
  979. height));
  980. }
  981. // float version
  982. Status FillPie(IN const Brush* brush,
  983. IN const RectF& rect,
  984. IN REAL startAngle,
  985. IN REAL sweepAngle)
  986. {
  987. return FillPie(brush, rect.X, rect.Y, rect.Width, rect.Height,
  988. startAngle, sweepAngle);
  989. }
  990. Status FillPie(IN const Brush* brush,
  991. IN REAL x,
  992. IN REAL y,
  993. IN REAL width,
  994. IN REAL height,
  995. IN REAL startAngle,
  996. IN REAL sweepAngle)
  997. {
  998. return SetStatus(DllExports::GdipFillPie(nativeGraphics,
  999. brush->nativeBrush, x, y,
  1000. width, height, startAngle,
  1001. sweepAngle));
  1002. }
  1003. // integer version
  1004. Status FillPie(IN const Brush* brush,
  1005. IN const Rect& rect,
  1006. IN REAL startAngle,
  1007. IN REAL sweepAngle)
  1008. {
  1009. return FillPie(brush, rect.X, rect.Y, rect.Width, rect.Height,
  1010. startAngle, sweepAngle);
  1011. }
  1012. Status FillPie(IN const Brush* brush,
  1013. IN INT x,
  1014. IN INT y,
  1015. IN INT width,
  1016. IN INT height,
  1017. IN REAL startAngle,
  1018. IN REAL sweepAngle)
  1019. {
  1020. return SetStatus(DllExports::GdipFillPieI(nativeGraphics,
  1021. brush->nativeBrush,
  1022. x,
  1023. y,
  1024. width,
  1025. height,
  1026. startAngle,
  1027. sweepAngle));
  1028. }
  1029. Status FillPath(IN const Brush* brush,
  1030. IN const GraphicsPath* path)
  1031. {
  1032. return SetStatus(DllExports::GdipFillPath(nativeGraphics,
  1033. brush->nativeBrush,
  1034. path->nativePath));
  1035. }
  1036. // float version
  1037. Status FillClosedCurve(IN const Brush* brush,
  1038. IN const PointF* points,
  1039. IN INT count)
  1040. {
  1041. return SetStatus(DllExports::GdipFillClosedCurve(nativeGraphics,
  1042. brush->nativeBrush,
  1043. points, count));
  1044. }
  1045. Status FillClosedCurve(IN const Brush* brush,
  1046. IN const PointF* points,
  1047. IN INT count,
  1048. IN FillMode fillMode,
  1049. IN REAL tension = 0.5f)
  1050. {
  1051. return SetStatus(DllExports::GdipFillClosedCurve2(nativeGraphics,
  1052. brush->nativeBrush,
  1053. points, count,
  1054. tension, fillMode));
  1055. }
  1056. // integer version
  1057. Status FillClosedCurve(IN const Brush* brush,
  1058. IN const Point* points,
  1059. IN INT count)
  1060. {
  1061. return SetStatus(DllExports::GdipFillClosedCurveI(nativeGraphics,
  1062. brush->nativeBrush,
  1063. points,
  1064. count));
  1065. }
  1066. Status FillClosedCurve(IN const Brush* brush,
  1067. IN const Point* points,
  1068. IN INT count,
  1069. IN FillMode fillMode,
  1070. IN REAL tension = 0.5f)
  1071. {
  1072. return SetStatus(DllExports::GdipFillClosedCurve2I(nativeGraphics,
  1073. brush->nativeBrush,
  1074. points, count,
  1075. tension, fillMode));
  1076. }
  1077. // float version
  1078. Status FillRegion(IN const Brush* brush,
  1079. IN const Region* region)
  1080. {
  1081. return SetStatus(DllExports::GdipFillRegion(nativeGraphics,
  1082. brush->nativeBrush,
  1083. region->nativeRegion));
  1084. }
  1085. // DrawString and MeasureString
  1086. Status
  1087. DrawString(
  1088. IN const WCHAR *string,
  1089. IN INT length,
  1090. IN const Font *font,
  1091. IN const RectF &layoutRect,
  1092. IN const StringFormat *stringFormat,
  1093. IN const Brush *brush
  1094. )
  1095. {
  1096. return SetStatus(DllExports::GdipDrawString(
  1097. nativeGraphics,
  1098. string,
  1099. length,
  1100. font->nativeFont,
  1101. &layoutRect,
  1102. stringFormat ? stringFormat->nativeFormat : NULL,
  1103. brush->nativeBrush
  1104. ));
  1105. }
  1106. Status
  1107. DrawString(
  1108. const WCHAR *string,
  1109. INT length,
  1110. const Font *font,
  1111. const PointF &origin,
  1112. const Brush *brush
  1113. )
  1114. {
  1115. RectF rect(origin.X, origin.Y, 0.0f, 0.0f);
  1116. return SetStatus(DllExports::GdipDrawString(
  1117. nativeGraphics,
  1118. string,
  1119. length,
  1120. font->nativeFont,
  1121. &rect,
  1122. NULL,
  1123. brush->nativeBrush
  1124. ));
  1125. }
  1126. Status
  1127. DrawString(
  1128. const WCHAR *string,
  1129. INT length,
  1130. const Font *font,
  1131. const PointF &origin,
  1132. const StringFormat *stringFormat,
  1133. const Brush *brush
  1134. )
  1135. {
  1136. RectF rect(origin.X, origin.Y, 0.0f, 0.0f);
  1137. return SetStatus(DllExports::GdipDrawString(
  1138. nativeGraphics,
  1139. string,
  1140. length,
  1141. font->nativeFont,
  1142. &rect,
  1143. stringFormat ? stringFormat->nativeFormat : NULL,
  1144. brush->nativeBrush
  1145. ));
  1146. }
  1147. Status
  1148. MeasureString(
  1149. IN const WCHAR *string,
  1150. IN INT length,
  1151. IN const Font *font,
  1152. IN const RectF &layoutRect,
  1153. IN const StringFormat *stringFormat,
  1154. OUT RectF *boundingBox,
  1155. OUT INT *codepointsFitted = 0,
  1156. OUT INT *linesFilled = 0
  1157. ) const
  1158. {
  1159. return SetStatus(DllExports::GdipMeasureString(
  1160. nativeGraphics,
  1161. string,
  1162. length,
  1163. font->nativeFont,
  1164. &layoutRect,
  1165. stringFormat ? stringFormat->nativeFormat : NULL,
  1166. boundingBox,
  1167. codepointsFitted,
  1168. linesFilled
  1169. ));
  1170. }
  1171. Status
  1172. MeasureString(
  1173. IN const WCHAR *string,
  1174. IN INT length,
  1175. IN const Font *font,
  1176. IN const SizeF &layoutRectSize,
  1177. IN const StringFormat *stringFormat,
  1178. OUT SizeF *size,
  1179. OUT INT *codepointsFitted = 0,
  1180. OUT INT *linesFilled = 0
  1181. ) const
  1182. {
  1183. RectF layoutRect(0, 0, layoutRectSize.Width, layoutRectSize.Height);
  1184. RectF boundingBox;
  1185. Status status;
  1186. if (size == NULL)
  1187. {
  1188. return SetStatus(InvalidParameter);
  1189. }
  1190. status = SetStatus(DllExports::GdipMeasureString(
  1191. nativeGraphics,
  1192. string,
  1193. length,
  1194. font->nativeFont,
  1195. &layoutRect,
  1196. stringFormat ? stringFormat->nativeFormat : NULL,
  1197. size ? &boundingBox : NULL,
  1198. codepointsFitted,
  1199. linesFilled
  1200. ));
  1201. if (size && status == Ok)
  1202. {
  1203. size->Width = boundingBox.Width;
  1204. size->Height = boundingBox.Height;
  1205. }
  1206. return status;
  1207. }
  1208. Status
  1209. MeasureString(
  1210. IN const WCHAR *string,
  1211. IN INT length,
  1212. IN const Font *font,
  1213. IN const PointF &origin,
  1214. IN const StringFormat *stringFormat,
  1215. OUT RectF *boundingBox
  1216. ) const
  1217. {
  1218. RectF rect(origin.X, origin.Y, 0.0f, 0.0f);
  1219. return SetStatus(DllExports::GdipMeasureString(
  1220. nativeGraphics,
  1221. string,
  1222. length,
  1223. font->nativeFont,
  1224. &rect,
  1225. stringFormat ? stringFormat->nativeFormat : NULL,
  1226. boundingBox,
  1227. NULL,
  1228. NULL
  1229. ));
  1230. }
  1231. Status
  1232. MeasureString(
  1233. IN const WCHAR *string,
  1234. IN INT length,
  1235. IN const Font *font,
  1236. IN const RectF &layoutRect,
  1237. OUT RectF *boundingBox
  1238. ) const
  1239. {
  1240. return SetStatus(DllExports::GdipMeasureString(
  1241. nativeGraphics,
  1242. string,
  1243. length,
  1244. font->nativeFont,
  1245. &layoutRect,
  1246. NULL,
  1247. boundingBox,
  1248. NULL,
  1249. NULL
  1250. ));
  1251. }
  1252. Status
  1253. MeasureString(
  1254. IN const WCHAR *string,
  1255. IN INT length,
  1256. IN const Font *font,
  1257. IN const PointF &origin,
  1258. OUT RectF *boundingBox
  1259. ) const
  1260. {
  1261. RectF rect(origin.X, origin.Y, 0.0f, 0.0f);
  1262. return SetStatus(DllExports::GdipMeasureString(
  1263. nativeGraphics,
  1264. string,
  1265. length,
  1266. font->nativeFont,
  1267. &rect,
  1268. NULL,
  1269. boundingBox,
  1270. NULL,
  1271. NULL
  1272. ));
  1273. }
  1274. Status
  1275. MeasureStringRegion(
  1276. IN const WCHAR *string,
  1277. IN INT length,
  1278. IN const Font *font,
  1279. IN const RectF &layoutRect,
  1280. IN const StringFormat *stringFormat,
  1281. IN INT firstCharacterIndex,
  1282. IN INT characterCount,
  1283. OUT Region *region
  1284. ) const
  1285. {
  1286. if (region == NULL)
  1287. {
  1288. return SetStatus(InvalidParameter);
  1289. }
  1290. return (SetStatus(DllExports::GdipMeasureStringRegion(
  1291. nativeGraphics,
  1292. string,
  1293. length,
  1294. font->nativeFont,
  1295. layoutRect,
  1296. stringFormat ? stringFormat->nativeFormat : NULL,
  1297. firstCharacterIndex,
  1298. characterCount,
  1299. region->nativeRegion)));
  1300. }
  1301. Status DrawDriverString(
  1302. IN const UINT16 *text,
  1303. IN INT length,
  1304. IN const Font *font,
  1305. IN const Brush *brush,
  1306. IN const PointF *positions,
  1307. IN INT flags,
  1308. IN Matrix *matrix
  1309. )
  1310. {
  1311. return SetStatus(DllExports::GdipDrawDriverString(
  1312. nativeGraphics,
  1313. text,
  1314. length,
  1315. font ? font->nativeFont : NULL,
  1316. brush ? brush->nativeBrush : NULL,
  1317. positions,
  1318. flags,
  1319. matrix ? matrix->nativeMatrix : NULL
  1320. ));
  1321. }
  1322. Status MeasureDriverString(
  1323. IN const UINT16 *text,
  1324. IN INT length,
  1325. IN const Font *font,
  1326. IN const PointF *positions,
  1327. IN INT flags,
  1328. IN Matrix *matrix,
  1329. OUT RectF *boundingBox
  1330. ) const
  1331. {
  1332. return SetStatus(DllExports::GdipMeasureDriverString(
  1333. nativeGraphics,
  1334. text,
  1335. length,
  1336. font ? font->nativeFont : NULL,
  1337. positions,
  1338. flags,
  1339. matrix ? matrix->nativeMatrix : NULL,
  1340. boundingBox
  1341. ));
  1342. }
  1343. Status DriverStringPointToCodepoint(
  1344. IN const UINT16 *text,
  1345. IN INT length,
  1346. IN const Font *font,
  1347. IN const PointF *positions,
  1348. IN INT flags,
  1349. IN Matrix *matrix,
  1350. IN const PointF &hit,
  1351. OUT INT *index,
  1352. OUT BOOL *rightEdge,
  1353. OUT REAL *distance
  1354. )
  1355. {
  1356. return SetStatus(DllExports::GdipDriverStringPointToCodepoint(
  1357. nativeGraphics,
  1358. text,
  1359. length,
  1360. font ? font->nativeFont : NULL,
  1361. positions,
  1362. flags,
  1363. matrix ? matrix->nativeMatrix : NULL,
  1364. &hit,
  1365. index,
  1366. rightEdge,
  1367. distance
  1368. ));
  1369. }
  1370. // Draw a cached bitmap on this graphics destination offset by
  1371. // x, y. Note this will fail with WrongState if the CachedBitmap
  1372. // native format differs from this Graphics.
  1373. Status DrawCachedBitmap(IN CachedBitmap *cb,
  1374. IN INT x,
  1375. IN INT y)
  1376. {
  1377. return SetStatus(DllExports::GdipDrawCachedBitmap(
  1378. nativeGraphics,
  1379. cb->nativeCachedBitmap,
  1380. x, y
  1381. ));
  1382. }
  1383. /**
  1384. * Draw images (both bitmap and vector)
  1385. */
  1386. // float version
  1387. Status DrawImage(IN Image* image,
  1388. IN const PointF& point)
  1389. {
  1390. return DrawImage(image, point.X, point.Y);
  1391. }
  1392. Status DrawImage(IN Image* image,
  1393. IN REAL x,
  1394. IN REAL y)
  1395. {
  1396. return SetStatus(DllExports::GdipDrawImage(nativeGraphics,
  1397. image ? image->nativeImage
  1398. : NULL,
  1399. x,
  1400. y));
  1401. }
  1402. Status DrawImage(IN Image* image,
  1403. IN RectF& rect)
  1404. {
  1405. return DrawImage(image, rect.X, rect.Y, rect.Width, rect.Height);
  1406. }
  1407. Status DrawImage(IN Image* image,
  1408. IN REAL x,
  1409. IN REAL y,
  1410. IN REAL width,
  1411. IN REAL height)
  1412. {
  1413. return SetStatus(DllExports::GdipDrawImageRect(nativeGraphics,
  1414. image ? image->nativeImage
  1415. : NULL,
  1416. x,
  1417. y,
  1418. width,
  1419. height));
  1420. }
  1421. // integer version
  1422. Status DrawImage(IN Image* image,
  1423. IN const Point& point)
  1424. {
  1425. return DrawImage(image, point.X, point.Y);
  1426. }
  1427. Status DrawImage(IN Image* image,
  1428. IN INT x,
  1429. IN INT y)
  1430. {
  1431. return SetStatus(DllExports::GdipDrawImageI(nativeGraphics,
  1432. image ? image->nativeImage
  1433. : NULL,
  1434. x,
  1435. y));
  1436. }
  1437. Status DrawImage(IN Image* image,
  1438. IN const Rect& rect)
  1439. {
  1440. return DrawImage(image,
  1441. rect.X,
  1442. rect.Y,
  1443. rect.Width,
  1444. rect.Height);
  1445. }
  1446. Status DrawImage(IN Image* image,
  1447. IN INT x,
  1448. IN INT y,
  1449. IN INT width,
  1450. IN INT height) {
  1451. return SetStatus(DllExports::GdipDrawImageRectI(nativeGraphics,
  1452. image ? image->nativeImage
  1453. : NULL,
  1454. x,
  1455. y,
  1456. width,
  1457. height));
  1458. }
  1459. /**
  1460. * Affine or perspective blt
  1461. * destPoints.length = 3: rect => parallelogram
  1462. * destPoints[0] <=> top-left corner of the source rectangle
  1463. * destPoints[1] <=> top-right corner
  1464. * destPoints[2] <=> bottom-left corner
  1465. * destPoints.length = 4: rect => quad
  1466. * destPoints[3] <=> bottom-right corner
  1467. *
  1468. * @notes Perspective blt only works for bitmap images.
  1469. */
  1470. Status DrawImage(IN Image* image,
  1471. IN const PointF* destPoints,
  1472. IN INT count)
  1473. {
  1474. if (count != 3 && count != 4)
  1475. return SetStatus(InvalidParameter);
  1476. return SetStatus(DllExports::GdipDrawImagePoints(nativeGraphics,
  1477. image ? image->nativeImage
  1478. : NULL,
  1479. destPoints, count));
  1480. }
  1481. Status DrawImage(IN Image* image,
  1482. IN const Point* destPoints,
  1483. IN INT count)
  1484. {
  1485. if (count != 3 && count != 4)
  1486. return SetStatus(InvalidParameter);
  1487. return SetStatus(DllExports::GdipDrawImagePointsI(nativeGraphics,
  1488. image ? image->nativeImage
  1489. : NULL,
  1490. destPoints,
  1491. count));
  1492. }
  1493. /**
  1494. * We need another set of methods similar to the ones above
  1495. * that take an additional Rect parameter to specify the
  1496. * portion of the source image to be drawn.
  1497. */
  1498. // float version
  1499. Status DrawImage(IN Image* image,
  1500. IN REAL x,
  1501. IN REAL y,
  1502. IN REAL srcx,
  1503. IN REAL srcy,
  1504. IN REAL srcwidth,
  1505. IN REAL srcheight,
  1506. IN Unit srcUnit)
  1507. {
  1508. return SetStatus(DllExports::GdipDrawImagePointRect(nativeGraphics,
  1509. image ? image->nativeImage
  1510. : NULL,
  1511. x, y,
  1512. srcx, srcy,
  1513. srcwidth, srcheight, srcUnit));
  1514. }
  1515. Status DrawImage(IN Image* image,
  1516. IN const RectF& destRect,
  1517. IN REAL srcx,
  1518. IN REAL srcy,
  1519. IN REAL srcwidth,
  1520. IN REAL srcheight,
  1521. IN Unit srcUnit,
  1522. IN ImageAttributes* imageAttributes = NULL,
  1523. IN DrawImageAbort callback = NULL,
  1524. IN VOID* callbackData = NULL)
  1525. {
  1526. return SetStatus(DllExports::GdipDrawImageRectRect(nativeGraphics,
  1527. image ? image->nativeImage
  1528. : NULL,
  1529. destRect.X,
  1530. destRect.Y,
  1531. destRect.Width,
  1532. destRect.Height,
  1533. srcx, srcy,
  1534. srcwidth, srcheight,
  1535. srcUnit,
  1536. imageAttributes
  1537. ? imageAttributes->nativeImageAttr
  1538. : NULL,
  1539. callback,
  1540. callbackData));
  1541. }
  1542. Status DrawImage(IN Image* image,
  1543. IN const PointF* destPoints,
  1544. IN INT count,
  1545. IN REAL srcx,
  1546. IN REAL srcy,
  1547. IN REAL srcwidth,
  1548. IN REAL srcheight,
  1549. IN Unit srcUnit,
  1550. IN ImageAttributes* imageAttributes = NULL,
  1551. IN DrawImageAbort callback = NULL,
  1552. IN VOID* callbackData = NULL)
  1553. {
  1554. return SetStatus(DllExports::GdipDrawImagePointsRect(nativeGraphics,
  1555. image ? image->nativeImage
  1556. : NULL,
  1557. destPoints, count,
  1558. srcx, srcy,
  1559. srcwidth,
  1560. srcheight,
  1561. srcUnit,
  1562. imageAttributes
  1563. ? imageAttributes->nativeImageAttr
  1564. : NULL,
  1565. callback,
  1566. callbackData));
  1567. }
  1568. // integer version
  1569. Status DrawImage(IN Image* image,
  1570. IN INT x,
  1571. IN INT y,
  1572. IN INT srcx,
  1573. IN INT srcy,
  1574. IN INT srcwidth,
  1575. IN INT srcheight,
  1576. IN Unit srcUnit)
  1577. {
  1578. return SetStatus(DllExports::GdipDrawImagePointRectI(nativeGraphics,
  1579. image ? image->nativeImage
  1580. : NULL,
  1581. x,
  1582. y,
  1583. srcx,
  1584. srcy,
  1585. srcwidth,
  1586. srcheight,
  1587. srcUnit));
  1588. }
  1589. Status DrawImage(IN Image* image,
  1590. IN const Rect& destRect,
  1591. IN INT srcx,
  1592. IN INT srcy,
  1593. IN INT srcwidth,
  1594. IN INT srcheight,
  1595. IN Unit srcUnit,
  1596. IN ImageAttributes* imageAttributes = NULL,
  1597. IN DrawImageAbort callback = NULL,
  1598. IN VOID* callbackData = NULL)
  1599. {
  1600. return SetStatus(DllExports::GdipDrawImageRectRectI(nativeGraphics,
  1601. image ? image->nativeImage
  1602. : NULL,
  1603. destRect.X,
  1604. destRect.Y,
  1605. destRect.Width,
  1606. destRect.Height,
  1607. srcx,
  1608. srcy,
  1609. srcwidth,
  1610. srcheight,
  1611. srcUnit,
  1612. imageAttributes
  1613. ? imageAttributes->nativeImageAttr
  1614. : NULL,
  1615. callback,
  1616. callbackData));
  1617. }
  1618. Status DrawImage(IN Image* image,
  1619. IN const Point* destPoints,
  1620. IN INT count,
  1621. IN INT srcx,
  1622. IN INT srcy,
  1623. IN INT srcwidth,
  1624. IN INT srcheight,
  1625. IN Unit srcUnit,
  1626. IN ImageAttributes* imageAttributes = NULL,
  1627. IN DrawImageAbort callback = NULL,
  1628. IN VOID* callbackData = NULL)
  1629. {
  1630. return SetStatus(DllExports::GdipDrawImagePointsRectI(nativeGraphics,
  1631. image ? image->nativeImage
  1632. : NULL,
  1633. destPoints,
  1634. count,
  1635. srcx,
  1636. srcy,
  1637. srcwidth,
  1638. srcheight,
  1639. srcUnit,
  1640. imageAttributes
  1641. ? imageAttributes->nativeImageAttr
  1642. : NULL,
  1643. callback,
  1644. callbackData));
  1645. }
  1646. // The following methods are for playing an EMF+ to a graphics
  1647. // via the enumeration interface. Each record of the EMF+ is
  1648. // sent to the callback (along with the callbackData). Then
  1649. // the callback can invoke the Metafile::PlayRecord method
  1650. // to play the particular record.
  1651. Status
  1652. EnumerateMetafile(
  1653. IN const Metafile * metafile,
  1654. IN const PointF & destPoint,
  1655. IN EnumerateMetafileProc callback,
  1656. IN VOID * callbackData = NULL,
  1657. IN ImageAttributes * imageAttributes = NULL
  1658. )
  1659. {
  1660. return SetStatus(DllExports::GdipEnumerateMetafileDestPoint(
  1661. nativeGraphics,
  1662. (const GpMetafile *)(metafile ? metafile->nativeImage:NULL),
  1663. destPoint,
  1664. callback,
  1665. callbackData,
  1666. imageAttributes ? imageAttributes->nativeImageAttr : NULL));
  1667. }
  1668. Status
  1669. EnumerateMetafile(
  1670. IN const Metafile * metafile,
  1671. IN const Point & destPoint,
  1672. IN EnumerateMetafileProc callback,
  1673. IN VOID * callbackData = NULL,
  1674. IN ImageAttributes * imageAttributes = NULL
  1675. )
  1676. {
  1677. return SetStatus(DllExports::GdipEnumerateMetafileDestPointI(
  1678. nativeGraphics,
  1679. (const GpMetafile *)(metafile ? metafile->nativeImage:NULL),
  1680. destPoint,
  1681. callback,
  1682. callbackData,
  1683. imageAttributes ? imageAttributes->nativeImageAttr : NULL));
  1684. }
  1685. Status
  1686. EnumerateMetafile(
  1687. IN const Metafile * metafile,
  1688. IN const RectF & destRect,
  1689. IN EnumerateMetafileProc callback,
  1690. IN VOID * callbackData = NULL,
  1691. IN ImageAttributes * imageAttributes = NULL
  1692. )
  1693. {
  1694. return SetStatus(DllExports::GdipEnumerateMetafileDestRect(
  1695. nativeGraphics,
  1696. (const GpMetafile *)(metafile ? metafile->nativeImage:NULL),
  1697. destRect,
  1698. callback,
  1699. callbackData,
  1700. imageAttributes ? imageAttributes->nativeImageAttr : NULL));
  1701. }
  1702. Status
  1703. EnumerateMetafile(
  1704. IN const Metafile * metafile,
  1705. IN const Rect & destRect,
  1706. IN EnumerateMetafileProc callback,
  1707. IN VOID * callbackData = NULL,
  1708. IN ImageAttributes * imageAttributes = NULL
  1709. )
  1710. {
  1711. return SetStatus(DllExports::GdipEnumerateMetafileDestRectI(
  1712. nativeGraphics,
  1713. (const GpMetafile *)(metafile ? metafile->nativeImage:NULL),
  1714. destRect,
  1715. callback,
  1716. callbackData,
  1717. imageAttributes ? imageAttributes->nativeImageAttr : NULL));
  1718. }
  1719. Status
  1720. EnumerateMetafile(
  1721. IN const Metafile * metafile,
  1722. IN const PointF * destPoints,
  1723. IN INT count,
  1724. IN EnumerateMetafileProc callback,
  1725. IN VOID * callbackData = NULL,
  1726. IN ImageAttributes * imageAttributes = NULL
  1727. )
  1728. {
  1729. return SetStatus(DllExports::GdipEnumerateMetafileDestPoints(
  1730. nativeGraphics,
  1731. (const GpMetafile *)(metafile ? metafile->nativeImage:NULL),
  1732. destPoints,
  1733. count,
  1734. callback,
  1735. callbackData,
  1736. imageAttributes ? imageAttributes->nativeImageAttr : NULL));
  1737. }
  1738. Status
  1739. EnumerateMetafile(
  1740. IN const Metafile * metafile,
  1741. IN const Point * destPoints,
  1742. IN INT count,
  1743. IN EnumerateMetafileProc callback,
  1744. IN VOID * callbackData = NULL,
  1745. IN ImageAttributes * imageAttributes = NULL
  1746. )
  1747. {
  1748. return SetStatus(DllExports::GdipEnumerateMetafileDestPointsI(
  1749. nativeGraphics,
  1750. (const GpMetafile *)(metafile ? metafile->nativeImage:NULL),
  1751. destPoints,
  1752. count,
  1753. callback,
  1754. callbackData,
  1755. imageAttributes ? imageAttributes->nativeImageAttr : NULL));
  1756. }
  1757. Status
  1758. EnumerateMetafile(
  1759. IN const Metafile * metafile,
  1760. IN const PointF & destPoint,
  1761. IN const RectF & srcRect,
  1762. IN Unit srcUnit,
  1763. IN EnumerateMetafileProc callback,
  1764. IN VOID * callbackData = NULL,
  1765. IN ImageAttributes * imageAttributes = NULL
  1766. )
  1767. {
  1768. return SetStatus(DllExports::GdipEnumerateMetafileSrcRectDestPoint(
  1769. nativeGraphics,
  1770. (const GpMetafile *)(metafile ? metafile->nativeImage:NULL),
  1771. destPoint,
  1772. srcRect,
  1773. srcUnit,
  1774. callback,
  1775. callbackData,
  1776. imageAttributes ? imageAttributes->nativeImageAttr : NULL));
  1777. }
  1778. Status
  1779. EnumerateMetafile(
  1780. IN const Metafile * metafile,
  1781. IN const Point & destPoint,
  1782. IN const Rect & srcRect,
  1783. IN Unit srcUnit,
  1784. IN EnumerateMetafileProc callback,
  1785. IN VOID * callbackData = NULL,
  1786. IN ImageAttributes * imageAttributes = NULL
  1787. )
  1788. {
  1789. return SetStatus(DllExports::GdipEnumerateMetafileSrcRectDestPointI(
  1790. nativeGraphics,
  1791. (const GpMetafile *)(metafile ? metafile->nativeImage:NULL),
  1792. destPoint,
  1793. srcRect,
  1794. srcUnit,
  1795. callback,
  1796. callbackData,
  1797. imageAttributes ? imageAttributes->nativeImageAttr : NULL));
  1798. }
  1799. Status
  1800. EnumerateMetafile(
  1801. IN const Metafile * metafile,
  1802. IN const RectF & destRect,
  1803. IN const RectF & srcRect,
  1804. IN Unit srcUnit,
  1805. IN EnumerateMetafileProc callback,
  1806. IN VOID * callbackData = NULL,
  1807. IN ImageAttributes * imageAttributes = NULL
  1808. )
  1809. {
  1810. return SetStatus(DllExports::GdipEnumerateMetafileSrcRectDestRect(
  1811. nativeGraphics,
  1812. (const GpMetafile *)(metafile ? metafile->nativeImage:NULL),
  1813. destRect,
  1814. srcRect,
  1815. srcUnit,
  1816. callback,
  1817. callbackData,
  1818. imageAttributes ? imageAttributes->nativeImageAttr : NULL));
  1819. }
  1820. Status
  1821. EnumerateMetafile(
  1822. IN const Metafile * metafile,
  1823. IN const Rect & destRect,
  1824. IN const Rect & srcRect,
  1825. IN Unit srcUnit,
  1826. IN EnumerateMetafileProc callback,
  1827. IN VOID * callbackData = NULL,
  1828. IN ImageAttributes * imageAttributes = NULL
  1829. )
  1830. {
  1831. return SetStatus(DllExports::GdipEnumerateMetafileSrcRectDestRectI(
  1832. nativeGraphics,
  1833. (const GpMetafile *)(metafile ? metafile->nativeImage:NULL),
  1834. destRect,
  1835. srcRect,
  1836. srcUnit,
  1837. callback,
  1838. callbackData,
  1839. imageAttributes ? imageAttributes->nativeImageAttr : NULL));
  1840. }
  1841. Status
  1842. EnumerateMetafile(
  1843. IN const Metafile * metafile,
  1844. IN const PointF * destPoints,
  1845. IN INT count,
  1846. IN const RectF & srcRect,
  1847. IN Unit srcUnit,
  1848. IN EnumerateMetafileProc callback,
  1849. IN VOID * callbackData = NULL,
  1850. IN ImageAttributes * imageAttributes = NULL
  1851. )
  1852. {
  1853. return SetStatus(DllExports::GdipEnumerateMetafileSrcRectDestPoints(
  1854. nativeGraphics,
  1855. (const GpMetafile *)(metafile ? metafile->nativeImage:NULL),
  1856. destPoints,
  1857. count,
  1858. srcRect,
  1859. srcUnit,
  1860. callback,
  1861. callbackData,
  1862. imageAttributes ? imageAttributes->nativeImageAttr : NULL));
  1863. }
  1864. Status
  1865. EnumerateMetafile(
  1866. IN const Metafile * metafile,
  1867. IN const Point * destPoints,
  1868. IN INT count,
  1869. IN const Rect & srcRect,
  1870. IN Unit srcUnit,
  1871. IN EnumerateMetafileProc callback,
  1872. IN VOID * callbackData = NULL,
  1873. IN ImageAttributes * imageAttributes = NULL
  1874. )
  1875. {
  1876. return SetStatus(DllExports::GdipEnumerateMetafileSrcRectDestPointsI(
  1877. nativeGraphics,
  1878. (const GpMetafile *)(metafile ? metafile->nativeImage:NULL),
  1879. destPoints,
  1880. count,
  1881. srcRect,
  1882. srcUnit,
  1883. callback,
  1884. callbackData,
  1885. imageAttributes ? imageAttributes->nativeImageAttr : NULL));
  1886. }
  1887. /**
  1888. * Clipping region operations
  1889. *
  1890. * @notes Simply incredible redundancy here.
  1891. */
  1892. Status SetClip(IN const Graphics* g,
  1893. IN CombineMode combineMode = CombineModeReplace)
  1894. {
  1895. return SetStatus(DllExports::GdipSetClipGraphics(nativeGraphics,
  1896. g->nativeGraphics,
  1897. combineMode));
  1898. }
  1899. Status SetClip(IN const RectF& rect,
  1900. IN CombineMode combineMode = CombineModeReplace)
  1901. {
  1902. return SetStatus(DllExports::GdipSetClipRect(nativeGraphics,
  1903. rect.X, rect.Y,
  1904. rect.Width, rect.Height,
  1905. combineMode));
  1906. }
  1907. Status SetClip(IN const Rect& rect,
  1908. IN CombineMode combineMode = CombineModeReplace)
  1909. {
  1910. return SetStatus(DllExports::GdipSetClipRectI(nativeGraphics,
  1911. rect.X, rect.Y,
  1912. rect.Width, rect.Height,
  1913. combineMode));
  1914. }
  1915. Status SetClip(IN const GraphicsPath* path,
  1916. IN CombineMode combineMode = CombineModeReplace)
  1917. {
  1918. return SetStatus(DllExports::GdipSetClipPath(nativeGraphics,
  1919. path->nativePath,
  1920. combineMode));
  1921. }
  1922. Status SetClip(IN const Region* region,
  1923. IN CombineMode combineMode = CombineModeReplace)
  1924. {
  1925. return SetStatus(DllExports::GdipSetClipRegion(nativeGraphics,
  1926. region->nativeRegion,
  1927. combineMode));
  1928. }
  1929. // This is different than the other SetClip methods because it assumes
  1930. // that the HRGN is already in device units, so it doesn't transform
  1931. // the coordinates in the HRGN.
  1932. Status SetClip(IN HRGN hRgn,
  1933. IN CombineMode combineMode = CombineModeReplace)
  1934. {
  1935. return SetStatus(DllExports::GdipSetClipHrgn(nativeGraphics, hRgn,
  1936. combineMode));
  1937. }
  1938. Status IntersectClip(IN const RectF& rect)
  1939. {
  1940. return SetStatus(DllExports::GdipSetClipRect(nativeGraphics,
  1941. rect.X, rect.Y,
  1942. rect.Width, rect.Height,
  1943. CombineModeIntersect));
  1944. }
  1945. Status IntersectClip(IN const Rect& rect)
  1946. {
  1947. return SetStatus(DllExports::GdipSetClipRectI(nativeGraphics,
  1948. rect.X, rect.Y,
  1949. rect.Width, rect.Height,
  1950. CombineModeIntersect));
  1951. }
  1952. Status IntersectClip(IN const Region* region)
  1953. {
  1954. return SetStatus(DllExports::GdipSetClipRegion(nativeGraphics,
  1955. region->nativeRegion,
  1956. CombineModeIntersect));
  1957. }
  1958. Status ExcludeClip(IN const RectF& rect)
  1959. {
  1960. return SetStatus(DllExports::GdipSetClipRect(nativeGraphics,
  1961. rect.X, rect.Y,
  1962. rect.Width, rect.Height,
  1963. CombineModeExclude));
  1964. }
  1965. Status ExcludeClip(IN const Rect& rect)
  1966. {
  1967. return SetStatus(DllExports::GdipSetClipRectI(nativeGraphics,
  1968. rect.X, rect.Y,
  1969. rect.Width, rect.Height,
  1970. CombineModeExclude));
  1971. }
  1972. Status ExcludeClip(IN const Region* region)
  1973. {
  1974. return SetStatus(DllExports::GdipSetClipRegion(nativeGraphics,
  1975. region->nativeRegion,
  1976. CombineModeExclude));
  1977. }
  1978. Status ResetClip()
  1979. {
  1980. return SetStatus(DllExports::GdipResetClip(nativeGraphics));
  1981. }
  1982. Status TranslateClip(IN REAL dx,
  1983. IN REAL dy)
  1984. {
  1985. return SetStatus(DllExports::GdipTranslateClip(nativeGraphics, dx, dy));
  1986. }
  1987. Status TranslateClip(IN INT dx,
  1988. IN INT dy)
  1989. {
  1990. return SetStatus(DllExports::GdipTranslateClipI(nativeGraphics,
  1991. dx, dy));
  1992. }
  1993. /**
  1994. * GetClip region from graphics context
  1995. */
  1996. Status GetClip(OUT Region* region) const
  1997. {
  1998. return SetStatus(DllExports::GdipGetClip(nativeGraphics,
  1999. region->nativeRegion));
  2000. }
  2001. /**
  2002. * Hit testing operations
  2003. */
  2004. Status GetClipBounds(OUT RectF* rect) const
  2005. {
  2006. return SetStatus(DllExports::GdipGetClipBounds(nativeGraphics, rect));
  2007. }
  2008. Status GetClipBounds(OUT Rect* rect) const
  2009. {
  2010. return SetStatus(DllExports::GdipGetClipBoundsI(nativeGraphics, rect));
  2011. }
  2012. BOOL IsClipEmpty() const
  2013. {
  2014. BOOL booln = FALSE;
  2015. SetStatus(DllExports::GdipIsClipEmpty(nativeGraphics, &booln));
  2016. return booln;
  2017. }
  2018. Status GetVisibleClipBounds(OUT RectF *rect) const
  2019. {
  2020. return SetStatus(DllExports::GdipGetVisibleClipBounds(nativeGraphics,
  2021. rect));
  2022. }
  2023. Status GetVisibleClipBounds(OUT Rect *rect) const
  2024. {
  2025. return SetStatus(DllExports::GdipGetVisibleClipBoundsI(nativeGraphics,
  2026. rect));
  2027. }
  2028. BOOL IsVisibleClipEmpty() const
  2029. {
  2030. BOOL booln = FALSE;
  2031. SetStatus(DllExports::GdipIsVisibleClipEmpty(nativeGraphics, &booln));
  2032. return booln;
  2033. }
  2034. BOOL IsVisible(IN INT x,
  2035. IN INT y) const
  2036. {
  2037. return IsVisible(Point(x,y));
  2038. }
  2039. BOOL IsVisible(IN const Point& point) const
  2040. {
  2041. BOOL booln = FALSE;
  2042. SetStatus(DllExports::GdipIsVisiblePointI(nativeGraphics,
  2043. point.X,
  2044. point.Y,
  2045. &booln));
  2046. return booln;
  2047. }
  2048. BOOL IsVisible(IN INT x,
  2049. IN INT y,
  2050. IN INT width,
  2051. IN INT height) const
  2052. {
  2053. return IsVisible(Rect(x, y, width, height));
  2054. }
  2055. BOOL IsVisible(IN const Rect& rect) const
  2056. {
  2057. BOOL booln = TRUE;
  2058. SetStatus(DllExports::GdipIsVisibleRectI(nativeGraphics,
  2059. rect.X,
  2060. rect.Y,
  2061. rect.Width,
  2062. rect.Height,
  2063. &booln));
  2064. return booln;
  2065. }
  2066. BOOL IsVisible(IN REAL x,
  2067. IN REAL y) const
  2068. {
  2069. return IsVisible(PointF(x, y));
  2070. }
  2071. BOOL IsVisible(IN const PointF& point) const
  2072. {
  2073. BOOL booln = FALSE;
  2074. SetStatus(DllExports::GdipIsVisiblePoint(nativeGraphics,
  2075. point.X,
  2076. point.Y,
  2077. &booln));
  2078. return booln;
  2079. }
  2080. BOOL IsVisible(IN REAL x,
  2081. IN REAL y,
  2082. IN REAL width,
  2083. IN REAL height) const
  2084. {
  2085. return IsVisible(RectF(x, y, width, height));
  2086. }
  2087. BOOL IsVisible(IN const RectF& rect) const
  2088. {
  2089. BOOL booln = TRUE;
  2090. SetStatus(DllExports::GdipIsVisibleRect(nativeGraphics,
  2091. rect.X,
  2092. rect.Y,
  2093. rect.Width,
  2094. rect.Height,
  2095. &booln));
  2096. return booln;
  2097. }
  2098. /**
  2099. * Save/restore graphics state
  2100. */
  2101. GraphicsState Save() const
  2102. {
  2103. GraphicsState gstate;
  2104. SetStatus(DllExports::GdipSaveGraphics(nativeGraphics, &gstate));
  2105. return gstate;
  2106. }
  2107. Status Restore(IN GraphicsState gstate)
  2108. {
  2109. return SetStatus(DllExports::GdipRestoreGraphics(nativeGraphics,
  2110. gstate));
  2111. }
  2112. /**
  2113. * Begin and end container drawing
  2114. */
  2115. GraphicsContainer BeginContainer(IN const RectF &dstrect,
  2116. IN const RectF &srcrect,
  2117. IN Unit unit)
  2118. {
  2119. GraphicsContainer state;
  2120. SetStatus(DllExports::GdipBeginContainer(nativeGraphics, &dstrect,
  2121. &srcrect, unit, &state));
  2122. return state;
  2123. }
  2124. /**
  2125. * Begin and end container drawing
  2126. */
  2127. GraphicsContainer BeginContainer(IN const Rect &dstrect,
  2128. IN const Rect &srcrect,
  2129. IN Unit unit)
  2130. {
  2131. GraphicsContainer state;
  2132. SetStatus(DllExports::GdipBeginContainerI(nativeGraphics, &dstrect,
  2133. &srcrect, unit, &state));
  2134. return state;
  2135. }
  2136. GraphicsContainer BeginContainer()
  2137. {
  2138. GraphicsContainer state;
  2139. SetStatus(DllExports::GdipBeginContainer2(nativeGraphics, &state));
  2140. return state;
  2141. }
  2142. Status EndContainer(IN GraphicsContainer state)
  2143. {
  2144. return SetStatus(DllExports::GdipEndContainer(nativeGraphics, state));
  2145. }
  2146. // only valid when recording metafiles
  2147. Status AddMetafileComment(IN const BYTE * data,
  2148. IN UINT sizeData)
  2149. {
  2150. return SetStatus(DllExports::GdipComment(nativeGraphics, sizeData, data));
  2151. }
  2152. /**
  2153. * Get/SetLayout
  2154. * Support for Middle East localization (right-to-left mirroring)
  2155. */
  2156. GraphicsLayout GetLayout() const
  2157. {
  2158. GraphicsLayout layout;
  2159. SetStatus(DllExports::GdipGetGraphicsLayout(nativeGraphics, &layout));
  2160. return layout;
  2161. }
  2162. Status SetLayout(IN const GraphicsLayout layout)
  2163. {
  2164. SetStatus(DllExports::GdipSetGraphicsLayout(nativeGraphics, layout));
  2165. }
  2166. static HPALETTE GetHalftonePalette()
  2167. {
  2168. return DllExports::GdipCreateHalftonePalette();
  2169. }
  2170. Status GetLastStatus() const
  2171. {
  2172. Status lastStatus = lastResult;
  2173. lastResult = Ok;
  2174. return lastStatus;
  2175. }
  2176. protected:
  2177. Graphics(const Graphics& graphics)
  2178. {
  2179. graphics;
  2180. SetStatus(NotImplemented);
  2181. }
  2182. Graphics& operator=(const Graphics& graphics)
  2183. {
  2184. graphics;
  2185. SetStatus(NotImplemented);
  2186. return *this;
  2187. }
  2188. Graphics(GpGraphics* graphics)
  2189. {
  2190. lastResult = Ok;
  2191. SetNativeGraphics(graphics);
  2192. }
  2193. VOID SetNativeGraphics(GpGraphics *graphics)
  2194. {
  2195. this->nativeGraphics = graphics;
  2196. }
  2197. Status SetStatus(Status status) const
  2198. {
  2199. if (status != Ok)
  2200. return (lastResult = status);
  2201. else
  2202. return status;
  2203. }
  2204. // Methods necessary to subclass Graphics for extension test.
  2205. GpGraphics* GetNativeGraphics()
  2206. {
  2207. return this->nativeGraphics;
  2208. }
  2209. GpPen* GetNativePen(const Pen* pen)
  2210. {
  2211. return pen->nativePen;
  2212. }
  2213. protected:
  2214. GpGraphics* nativeGraphics;
  2215. mutable Status lastResult;
  2216. };
  2217. //----------------------------------------------------------------------------
  2218. // Extra implementation of GraphicsPath methods that use Graphics
  2219. //----------------------------------------------------------------------------
  2220. /**
  2221. * Get the bounds of the path object with the given transform.
  2222. * This is not always the tightest bounds.
  2223. */
  2224. inline Status
  2225. GraphicsPath::GetBounds(
  2226. OUT RectF* bounds,
  2227. IN const Matrix* matrix,
  2228. IN const Pen* pen) const
  2229. {
  2230. GpMatrix* nativeMatrix = NULL;
  2231. GpPen* nativePen = NULL;
  2232. if (matrix)
  2233. nativeMatrix = matrix->nativeMatrix;
  2234. if (pen)
  2235. nativePen = pen->nativePen;
  2236. return SetStatus(DllExports::GdipGetPathWorldBounds(nativePath, bounds,
  2237. nativeMatrix, nativePen));
  2238. }
  2239. // integer version
  2240. inline Status
  2241. GraphicsPath::GetBounds(
  2242. OUT Rect* bounds,
  2243. IN const Matrix* matrix,
  2244. IN const Pen* pen
  2245. ) const
  2246. {
  2247. GpMatrix* nativeMatrix = NULL;
  2248. GpPen* nativePen = NULL;
  2249. if (matrix)
  2250. nativeMatrix = matrix->nativeMatrix;
  2251. if (pen)
  2252. nativePen = pen->nativePen;
  2253. return SetStatus(DllExports::GdipGetPathWorldBoundsI(nativePath, bounds,
  2254. nativeMatrix, nativePen));
  2255. }
  2256. //----------------------------------------------------------------------------
  2257. // Hit testing operations
  2258. //----------------------------------------------------------------------------
  2259. inline BOOL
  2260. GraphicsPath::IsVisible(
  2261. IN REAL x,
  2262. IN REAL y,
  2263. IN const Graphics* g) const
  2264. {
  2265. BOOL booln = FALSE;
  2266. GpGraphics* nativeGraphics = NULL;
  2267. if (g)
  2268. nativeGraphics = g->nativeGraphics;
  2269. SetStatus(DllExports::GdipIsVisiblePathPoint(nativePath,
  2270. x, y, nativeGraphics,
  2271. &booln));
  2272. return booln;
  2273. }
  2274. inline BOOL
  2275. GraphicsPath::IsVisible(
  2276. IN INT x,
  2277. IN INT y,
  2278. IN const Graphics* g) const
  2279. {
  2280. BOOL booln = FALSE;
  2281. GpGraphics* nativeGraphics = NULL;
  2282. if (g)
  2283. nativeGraphics = g->nativeGraphics;
  2284. SetStatus(DllExports::GdipIsVisiblePathPointI(nativePath,
  2285. x, y, nativeGraphics,
  2286. &booln));
  2287. return booln;
  2288. }
  2289. inline BOOL
  2290. GraphicsPath::IsOutlineVisible(
  2291. IN REAL x,
  2292. IN REAL y,
  2293. IN const Pen* pen,
  2294. IN const Graphics* g) const
  2295. {
  2296. BOOL booln = FALSE;
  2297. GpGraphics* nativeGraphics = NULL;
  2298. GpPen* nativePen = NULL;
  2299. if(g)
  2300. nativeGraphics = g->nativeGraphics;
  2301. if(pen)
  2302. nativePen = pen->nativePen;
  2303. SetStatus(DllExports::GdipIsOutlineVisiblePathPoint(nativePath,
  2304. x, y, nativePen, nativeGraphics,
  2305. &booln));
  2306. return booln;
  2307. }
  2308. inline BOOL
  2309. GraphicsPath::IsOutlineVisible(
  2310. IN INT x,
  2311. IN INT y,
  2312. IN const Pen* pen,
  2313. IN const Graphics* g) const
  2314. {
  2315. BOOL booln = FALSE;
  2316. GpGraphics* nativeGraphics = NULL;
  2317. GpPen* nativePen = NULL;
  2318. if(g)
  2319. nativeGraphics = g->nativeGraphics;
  2320. if(pen)
  2321. nativePen = pen->nativePen;
  2322. SetStatus(DllExports::GdipIsOutlineVisiblePathPointI(nativePath,
  2323. x, y, nativePen, nativeGraphics,
  2324. &booln));
  2325. return booln;
  2326. }
  2327. #endif