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.
 
 
 
 
 
 

2727 regels
92 KiB

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