Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 
 
 

1687 wiersze
49 KiB

  1. /**************************************************************************\
  2. *
  3. * Copyright (c) 1998-2000, Microsoft Corp. All Rights Reserved.
  4. *
  5. * Module Name:
  6. *
  7. * GdiplusPath.h
  8. *
  9. * Abstract:
  10. *
  11. * Path related declarations
  12. *
  13. \**************************************************************************/
  14. #ifndef _GDIPLUSPATH_H
  15. #define _GDIPLUSPATH_H
  16. class GraphicsPath : public GdiplusBase
  17. {
  18. public:
  19. friend class Graphics;
  20. friend class Region;
  21. friend class PathGradientBrush;
  22. friend class GraphicsPathIterator;
  23. friend class CustomLineCap;
  24. // Path constructors
  25. GraphicsPath(IN FillMode fillMode = FillModeAlternate)
  26. {
  27. nativePath = NULL;
  28. lastResult = DllExports::GdipCreatePath(fillMode, &nativePath);
  29. }
  30. GraphicsPath(IN const PointF* points,
  31. IN const BYTE* types,
  32. IN INT count,
  33. IN FillMode fillMode = FillModeAlternate)
  34. {
  35. nativePath = NULL;
  36. lastResult = DllExports::GdipCreatePath2(points,
  37. types,
  38. count,
  39. fillMode,
  40. &nativePath);
  41. }
  42. GraphicsPath(IN const Point* points,
  43. IN const BYTE* types,
  44. IN INT count,
  45. IN FillMode fillMode = FillModeAlternate)
  46. {
  47. nativePath = NULL;
  48. lastResult = DllExports::GdipCreatePath2I(points,
  49. types,
  50. count,
  51. fillMode,
  52. &nativePath);
  53. }
  54. ~GraphicsPath()
  55. {
  56. DllExports::GdipDeletePath(nativePath);
  57. }
  58. /**
  59. * Make a copy of the current path object
  60. */
  61. GraphicsPath* Clone() const
  62. {
  63. GpPath *clonepath = NULL;
  64. SetStatus(DllExports::GdipClonePath(nativePath, &clonepath));
  65. return new GraphicsPath(clonepath);
  66. }
  67. /**
  68. * Reset the path object to empty (and fill mode to FillModeAlternate)
  69. */
  70. Status Reset()
  71. {
  72. return SetStatus(DllExports::GdipResetPath(nativePath));
  73. }
  74. /**
  75. * Get path fill mode information
  76. */
  77. FillMode GetFillMode() const
  78. {
  79. FillMode fillmode = FillModeAlternate;
  80. SetStatus(DllExports::GdipGetPathFillMode(nativePath, &fillmode));
  81. return fillmode;
  82. }
  83. /**
  84. * Set path fill mode information
  85. */
  86. Status SetFillMode(IN FillMode fillmode)
  87. {
  88. return SetStatus(DllExports::GdipSetPathFillMode(nativePath, fillmode));
  89. }
  90. /**
  91. * Set/get path data
  92. */
  93. Status GetPathData(OUT PathData* pathData) const
  94. {
  95. if (pathData == NULL)
  96. {
  97. return SetStatus(InvalidParameter);
  98. }
  99. INT count = GetPointCount();
  100. if ((count <= 0) || (pathData->Count>0 && pathData->Count<count))
  101. {
  102. pathData->Count = 0;
  103. if (pathData->Points)
  104. {
  105. delete pathData->Points;
  106. pathData->Points = NULL;
  107. }
  108. if (pathData->Types)
  109. {
  110. delete pathData->Types;
  111. pathData->Types = NULL;
  112. }
  113. if (count <= 0)
  114. {
  115. return lastResult;
  116. }
  117. }
  118. if (pathData->Count == 0)
  119. {
  120. pathData->Points = new PointF[count];
  121. if (pathData->Points == NULL)
  122. {
  123. return SetStatus(OutOfMemory);
  124. }
  125. pathData->Types = new byte[count];
  126. if (pathData->Types == NULL)
  127. {
  128. delete pathData->Points;
  129. pathData->Points = NULL;
  130. return SetStatus(OutOfMemory);
  131. }
  132. pathData->Count = count;
  133. }
  134. return SetStatus(DllExports::GdipGetPathData(nativePath, pathData));
  135. }
  136. /**
  137. * Start/end a subpath
  138. */
  139. Status StartFigure()
  140. {
  141. return SetStatus(DllExports::GdipStartPathFigure(nativePath));
  142. }
  143. Status CloseFigure()
  144. {
  145. return SetStatus(DllExports::GdipClosePathFigure(nativePath));
  146. }
  147. Status CloseAllFigures()
  148. {
  149. return SetStatus(DllExports::GdipClosePathFigures(nativePath));
  150. }
  151. Status SetMarker()
  152. {
  153. return SetStatus(DllExports::GdipSetPathMarker(nativePath));
  154. }
  155. Status ClearMarkers()
  156. {
  157. return SetStatus(DllExports::GdipClearPathMarkers(nativePath));
  158. }
  159. Status Reverse()
  160. {
  161. return SetStatus(DllExports::GdipReversePath(nativePath));
  162. }
  163. Status GetLastPoint(OUT PointF* lastPoint) const
  164. {
  165. return SetStatus(DllExports::GdipGetPathLastPoint(nativePath, lastPoint));
  166. }
  167. /**
  168. * Add lines to the path object
  169. */
  170. // float version
  171. Status AddLine(IN const PointF& pt1,
  172. IN const PointF& pt2)
  173. {
  174. return AddLine(pt1.X, pt1.Y, pt2.X, pt2.Y);
  175. }
  176. Status AddLine(IN REAL x1,
  177. IN REAL y1,
  178. IN REAL x2,
  179. IN REAL y2)
  180. {
  181. return SetStatus(DllExports::GdipAddPathLine(nativePath, x1, y1, x2, y2));
  182. }
  183. Status AddLines(IN const PointF* points,
  184. IN INT count)
  185. {
  186. return SetStatus(DllExports::GdipAddPathLine2(nativePath, points, count));
  187. }
  188. // integer version
  189. Status AddLine(IN const Point& pt1,
  190. IN const Point& pt2)
  191. {
  192. return AddLine(pt1.X,
  193. pt1.Y,
  194. pt2.X,
  195. pt2.Y);
  196. }
  197. Status AddLine(IN INT x1,
  198. IN INT y1,
  199. IN INT x2,
  200. IN INT y2)
  201. {
  202. return SetStatus(DllExports::GdipAddPathLineI(nativePath,
  203. x1,
  204. y1,
  205. x2,
  206. y2));
  207. }
  208. Status AddLines(IN const Point* points,
  209. IN INT count)
  210. {
  211. return SetStatus(DllExports::GdipAddPathLine2I(nativePath,
  212. points,
  213. count));
  214. }
  215. /**
  216. * Add an arc to the path object
  217. */
  218. // float version
  219. Status AddArc(IN const RectF& rect,
  220. IN REAL startAngle,
  221. IN REAL sweepAngle)
  222. {
  223. return AddArc(rect.X, rect.Y, rect.Width, rect.Height,
  224. startAngle, sweepAngle);
  225. }
  226. Status AddArc(IN REAL x,
  227. IN REAL y,
  228. IN REAL width,
  229. IN REAL height,
  230. IN REAL startAngle,
  231. IN REAL sweepAngle)
  232. {
  233. return SetStatus(DllExports::GdipAddPathArc(nativePath, x, y, width, height,
  234. startAngle, sweepAngle));
  235. }
  236. // integer version
  237. Status AddArc(IN const Rect& rect,
  238. IN REAL startAngle,
  239. IN REAL sweepAngle)
  240. {
  241. return AddArc(rect.X, rect.Y, rect.Width, rect.Height,
  242. startAngle, sweepAngle);
  243. }
  244. Status AddArc(IN INT x,
  245. IN INT y,
  246. IN INT width,
  247. IN INT height,
  248. IN REAL startAngle,
  249. IN REAL sweepAngle)
  250. {
  251. return SetStatus(DllExports::GdipAddPathArcI(nativePath,
  252. x,
  253. y,
  254. width,
  255. height,
  256. startAngle,
  257. sweepAngle));
  258. }
  259. /**
  260. * Add Bezier curves to the path object
  261. */
  262. // float version
  263. Status AddBezier(IN const PointF& pt1,
  264. IN const PointF& pt2,
  265. IN const PointF& pt3,
  266. IN const PointF& pt4)
  267. {
  268. return AddBezier(pt1.X, pt1.Y, pt2.X, pt2.Y, pt3.X, pt3.Y, pt4.X,
  269. pt4.Y);
  270. }
  271. Status AddBezier(IN REAL x1,
  272. IN REAL y1,
  273. IN REAL x2,
  274. IN REAL y2,
  275. IN REAL x3,
  276. IN REAL y3,
  277. IN REAL x4,
  278. IN REAL y4)
  279. {
  280. return SetStatus(DllExports::GdipAddPathBezier(nativePath, x1, y1, x2, y2,
  281. x3, y3, x4, y4));
  282. }
  283. Status AddBeziers(IN const PointF* points,
  284. IN INT count)
  285. {
  286. return SetStatus(DllExports::GdipAddPathBeziers(nativePath, points, count));
  287. }
  288. // integer version
  289. Status AddBezier(IN const Point& pt1,
  290. IN const Point& pt2,
  291. IN const Point& pt3,
  292. IN const Point& pt4)
  293. {
  294. return AddBezier(pt1.X, pt1.Y, pt2.X, pt2.Y, pt3.X, pt3.Y, pt4.X,
  295. pt4.Y);
  296. }
  297. Status AddBezier(IN INT x1,
  298. IN INT y1,
  299. IN INT x2,
  300. IN INT y2,
  301. IN INT x3,
  302. IN INT y3,
  303. IN INT x4,
  304. IN INT y4)
  305. {
  306. return SetStatus(DllExports::GdipAddPathBezierI(nativePath,
  307. x1,
  308. y1,
  309. x2,
  310. y2,
  311. x3,
  312. y3,
  313. x4,
  314. y4));
  315. }
  316. Status AddBeziers(IN const Point* points,
  317. IN INT count)
  318. {
  319. return SetStatus(DllExports::GdipAddPathBeziersI(nativePath,
  320. points,
  321. count));
  322. }
  323. // float version
  324. Status AddCurve(IN const PointF* points,
  325. IN INT count)
  326. {
  327. return SetStatus(DllExports::GdipAddPathCurve(nativePath,
  328. points,
  329. count));
  330. }
  331. Status AddCurve(IN const PointF* points,
  332. IN INT count,
  333. IN REAL tension)
  334. {
  335. return SetStatus(DllExports::GdipAddPathCurve2(nativePath,
  336. points,
  337. count,
  338. tension));
  339. }
  340. Status AddCurve(IN const PointF* points,
  341. IN INT count,
  342. IN INT offset,
  343. IN INT numberOfSegments,
  344. IN REAL tension)
  345. {
  346. return SetStatus(DllExports::GdipAddPathCurve3(nativePath,
  347. points,
  348. count,
  349. offset,
  350. numberOfSegments,
  351. tension));
  352. }
  353. // integer version
  354. Status AddCurve(IN const Point* points,
  355. IN INT count)
  356. {
  357. return SetStatus(DllExports::GdipAddPathCurveI(nativePath,
  358. points,
  359. count));
  360. }
  361. Status AddCurve(IN const Point* points,
  362. IN INT count,
  363. IN REAL tension)
  364. {
  365. return SetStatus(DllExports::GdipAddPathCurve2I(nativePath,
  366. points,
  367. count,
  368. tension));
  369. }
  370. Status AddCurve(IN const Point* points,
  371. IN INT count,
  372. IN INT offset,
  373. IN INT numberOfSegments,
  374. IN REAL tension)
  375. {
  376. return SetStatus(DllExports::GdipAddPathCurve3I(nativePath,
  377. points,
  378. count,
  379. offset,
  380. numberOfSegments,
  381. tension));
  382. }
  383. // float version
  384. Status AddClosedCurve(IN const PointF* points,
  385. IN INT count)
  386. {
  387. return SetStatus(DllExports::GdipAddPathClosedCurve(nativePath,
  388. points,
  389. count));
  390. }
  391. Status AddClosedCurve(IN const PointF* points,
  392. IN INT count,
  393. IN REAL tension)
  394. {
  395. return SetStatus(DllExports::GdipAddPathClosedCurve2(nativePath,
  396. points,
  397. count,
  398. tension));
  399. }
  400. // integer version
  401. Status AddClosedCurve(IN const Point* points,
  402. IN INT count)
  403. {
  404. return SetStatus(DllExports::GdipAddPathClosedCurveI(nativePath,
  405. points,
  406. count));
  407. }
  408. Status AddClosedCurve(IN const Point* points,
  409. IN INT count,
  410. IN REAL tension)
  411. {
  412. return SetStatus(DllExports::GdipAddPathClosedCurve2I(nativePath,
  413. points,
  414. count,
  415. tension));
  416. }
  417. /**
  418. * Add closed shapes to the path object
  419. */
  420. // float version
  421. Status AddRectangle(IN const RectF& rect)
  422. {
  423. return SetStatus(DllExports::GdipAddPathRectangle(nativePath,
  424. rect.X,
  425. rect.Y,
  426. rect.Width,
  427. rect.Height));
  428. }
  429. Status AddRectangles(IN const RectF* rects,
  430. IN INT count)
  431. {
  432. return SetStatus(DllExports::GdipAddPathRectangles(nativePath,
  433. rects,
  434. count));
  435. }
  436. // integer version
  437. Status AddRectangle(IN const Rect& rect)
  438. {
  439. return SetStatus(DllExports::GdipAddPathRectangleI(nativePath,
  440. rect.X,
  441. rect.Y,
  442. rect.Width,
  443. rect.Height));
  444. }
  445. Status AddRectangles(IN const Rect* rects, INT count)
  446. {
  447. return SetStatus(DllExports::GdipAddPathRectanglesI(nativePath,
  448. rects,
  449. count));
  450. }
  451. // float version
  452. Status AddEllipse(IN const RectF& rect)
  453. {
  454. return AddEllipse(rect.X, rect.Y, rect.Width, rect.Height);
  455. }
  456. Status AddEllipse(IN REAL x,
  457. IN REAL y,
  458. IN REAL width,
  459. IN REAL height)
  460. {
  461. return SetStatus(DllExports::GdipAddPathEllipse(nativePath,
  462. x,
  463. y,
  464. width,
  465. height));
  466. }
  467. // integer version
  468. Status AddEllipse(IN const Rect& rect)
  469. {
  470. return AddEllipse(rect.X, rect.Y, rect.Width, rect.Height);
  471. }
  472. Status AddEllipse(IN INT x,
  473. IN INT y,
  474. IN INT width,
  475. IN INT height)
  476. {
  477. return SetStatus(DllExports::GdipAddPathEllipseI(nativePath,
  478. x,
  479. y,
  480. width,
  481. height));
  482. }
  483. // float version
  484. Status AddPie(IN const RectF& rect,
  485. IN REAL startAngle,
  486. IN REAL sweepAngle)
  487. {
  488. return AddPie(rect.X, rect.Y, rect.Width, rect.Height, startAngle,
  489. sweepAngle);
  490. }
  491. Status AddPie(IN REAL x,
  492. IN REAL y,
  493. IN REAL width,
  494. IN REAL height,
  495. IN REAL startAngle,
  496. IN REAL sweepAngle)
  497. {
  498. return SetStatus(DllExports::GdipAddPathPie(nativePath, x, y, width, height,
  499. startAngle, sweepAngle));
  500. }
  501. // integer version
  502. Status AddPie(IN const Rect& rect,
  503. IN REAL startAngle,
  504. IN REAL sweepAngle)
  505. {
  506. return AddPie(rect.X,
  507. rect.Y,
  508. rect.Width,
  509. rect.Height,
  510. startAngle,
  511. sweepAngle);
  512. }
  513. Status AddPie(IN INT x,
  514. IN INT y,
  515. IN INT width,
  516. IN INT height,
  517. IN REAL startAngle,
  518. IN REAL sweepAngle)
  519. {
  520. return SetStatus(DllExports::GdipAddPathPieI(nativePath,
  521. x,
  522. y,
  523. width,
  524. height,
  525. startAngle,
  526. sweepAngle));
  527. }
  528. // float version
  529. Status AddPolygon(IN const PointF* points,
  530. IN INT count)
  531. {
  532. return SetStatus(DllExports::GdipAddPathPolygon(nativePath, points, count));
  533. }
  534. // integer version
  535. Status AddPolygon(IN const Point* points,
  536. IN INT count)
  537. {
  538. return SetStatus(DllExports::GdipAddPathPolygonI(nativePath, points, count));
  539. }
  540. Status AddPath(IN const GraphicsPath* addingPath,
  541. IN BOOL connect)
  542. {
  543. GpPath* nativePath2 = NULL;
  544. if(addingPath)
  545. nativePath2 = addingPath->nativePath;
  546. return SetStatus(DllExports::GdipAddPathPath(nativePath, nativePath2, connect));
  547. }
  548. // AddString point version
  549. Status AddString(
  550. IN const WCHAR *string,
  551. IN INT length,
  552. IN const FontFamily *family,
  553. IN INT style,
  554. IN REAL emSize, // In world units
  555. IN const PointF &origin,
  556. IN const StringFormat *format
  557. )
  558. {
  559. RectF rect(origin.X, origin.Y, 0.0f, 0.0f);
  560. return SetStatus(DllExports::GdipAddPathString(
  561. nativePath,
  562. string,
  563. length,
  564. family ? family->nativeFamily : NULL,
  565. style,
  566. emSize,
  567. &rect,
  568. format ? format->nativeFormat : NULL
  569. ));
  570. }
  571. // AddString rectangle version
  572. Status AddString(
  573. IN const WCHAR *string,
  574. IN INT length,
  575. IN const FontFamily *family,
  576. IN INT style,
  577. IN REAL emSize, // In world units
  578. IN const RectF &layoutRect,
  579. IN const StringFormat *format
  580. )
  581. {
  582. return SetStatus(DllExports::GdipAddPathString(
  583. nativePath,
  584. string,
  585. length,
  586. family ? family->nativeFamily : NULL,
  587. style,
  588. emSize,
  589. &layoutRect,
  590. format ? format->nativeFormat : NULL
  591. ));
  592. }
  593. Status AddString(
  594. IN const WCHAR *string,
  595. IN INT length,
  596. IN const FontFamily *family,
  597. IN INT style,
  598. IN REAL emSize, // In world units
  599. IN const Point &origin,
  600. IN const StringFormat *format
  601. )
  602. {
  603. Rect rect(origin.X, origin.Y, 0, 0);
  604. return SetStatus(DllExports::GdipAddPathStringI(
  605. nativePath,
  606. string,
  607. length,
  608. family ? family->nativeFamily : NULL,
  609. style,
  610. emSize,
  611. &rect,
  612. format ? format->nativeFormat : NULL
  613. ));
  614. }
  615. // AddString rectangle version
  616. Status AddString(
  617. IN const WCHAR *string,
  618. IN INT length,
  619. IN const FontFamily *family,
  620. IN INT style,
  621. IN REAL emSize, // In world units
  622. IN const Rect &layoutRect,
  623. IN const StringFormat *format
  624. )
  625. {
  626. return SetStatus(DllExports::GdipAddPathStringI(
  627. nativePath,
  628. string,
  629. length,
  630. family ? family->nativeFamily : NULL,
  631. style,
  632. emSize,
  633. &layoutRect,
  634. format ? format->nativeFormat : NULL
  635. ));
  636. }
  637. /**
  638. * Transforms the path object
  639. */
  640. Status Transform(IN const Matrix* matrix)
  641. {
  642. if(matrix)
  643. return SetStatus(DllExports::GdipTransformPath(nativePath, matrix->nativeMatrix));
  644. else
  645. return Ok; // No need to transform.
  646. }
  647. /**
  648. * Get the bounds of the path object with the given transform.
  649. * This is not always the tightest bounds.
  650. *
  651. * Defined in GdiplusGraphics.h.
  652. */
  653. Status GetBounds(OUT RectF* bounds,
  654. IN const Matrix* matrix = NULL,
  655. IN const Pen* pen = NULL) const;
  656. // integer version (defined in GdiplusGraphics.h)
  657. Status GetBounds(OUT Rect* bounds,
  658. IN const Matrix* matrix = NULL,
  659. IN const Pen* pen = NULL) const;
  660. /**
  661. * Flatten the path object
  662. * Once this is called, the resultant path is made of line segments and
  663. * the original path information is lost.
  664. * When matrix = NULL, the identity matrix is assumed.
  665. */
  666. Status Flatten(IN const Matrix* matrix = NULL,
  667. IN REAL flatness = FlatnessDefault)
  668. {
  669. GpMatrix* nativeMatrix = NULL;
  670. if(matrix)
  671. {
  672. nativeMatrix = matrix->nativeMatrix;
  673. }
  674. return SetStatus(DllExports::GdipFlattenPath(
  675. nativePath,
  676. nativeMatrix,
  677. flatness
  678. ));
  679. }
  680. #ifdef DCR_USE_NEW_202903
  681. Status Widen(
  682. IN const Pen* pen,
  683. IN const Matrix* matrix = NULL,
  684. IN REAL flatness = FlatnessDefault
  685. )
  686. {
  687. GpMatrix* nativeMatrix = NULL;
  688. if(matrix)
  689. nativeMatrix = matrix->nativeMatrix;
  690. return SetStatus(DllExports::GdipWidenPath(
  691. nativePath,
  692. pen->nativePen,
  693. nativeMatrix,
  694. flatness
  695. ));
  696. }
  697. #else
  698. /**
  699. * Widen the path object
  700. * When removeSelfIntersects is TRUE, this returns the widened path
  701. * without self intersections.
  702. * When it is FALSE, it returns the widened path with selfintersections.
  703. * The latter is faster and is usually safficient for filling.
  704. */
  705. Status Widen(IN const Pen* pen,
  706. IN const Matrix* matrix = NULL,
  707. IN BOOL removeSelfIntersects = TRUE)
  708. {
  709. GpMatrix* nativeMatrix = NULL;
  710. if(matrix)
  711. nativeMatrix = matrix->nativeMatrix;
  712. return SetStatus(DllExports::GdipWidenPathWithMinimumResolutions(nativePath, pen->nativePen,
  713. 0, 0, nativeMatrix, removeSelfIntersects));
  714. }
  715. /**
  716. * Widen the path object
  717. * This is equivalent to Widen() method except that
  718. * The widths of the widened path are larger than the given
  719. * minimum resolutions in x and y coordinates after the transform.
  720. * This is usefull when widening a path with the limited device resolutions.
  721. */
  722. Status Widen(IN const Pen* pen,
  723. IN REAL minXres,
  724. IN REAL minYres,
  725. IN const Matrix* matrix = NULL,
  726. IN BOOL removeSelfIntersects = TRUE)
  727. {
  728. GpMatrix* nativeMatrix = NULL;
  729. if(matrix)
  730. nativeMatrix = matrix->nativeMatrix;
  731. return SetStatus(DllExports::GdipWidenPathWithMinimumResolutions(nativePath, pen->nativePen,
  732. minXres, minYres, nativeMatrix, removeSelfIntersects));
  733. }
  734. #endif // DCR_USE_NEW_202903
  735. Status Outline(
  736. IN const Matrix *matrix = NULL,
  737. IN REAL flatness = FlatnessDefault
  738. )
  739. {
  740. GpMatrix* nativeMatrix = NULL;
  741. if(matrix)
  742. {
  743. nativeMatrix = matrix->nativeMatrix;
  744. }
  745. return SetStatus(DllExports::GdipWindingModeOutline(
  746. nativePath, nativeMatrix, flatness
  747. ));
  748. }
  749. /**
  750. * Warp the path object
  751. * Once this is called, the resultant path is made of line segments and
  752. * the original path information is lost.
  753. * When matrix = NULL, the identity matrix is assumed.
  754. */
  755. Status Warp(IN const PointF* destPoints,
  756. IN INT count,
  757. IN const RectF& srcRect,
  758. IN const Matrix* matrix = NULL,
  759. IN WarpMode warpMode = WarpModePerspective,
  760. IN REAL flatness = FlatnessDefault)
  761. {
  762. GpMatrix* nativeMatrix = NULL;
  763. if(matrix)
  764. nativeMatrix = matrix->nativeMatrix;
  765. return SetStatus(DllExports::GdipWarpPath(
  766. nativePath,
  767. nativeMatrix,
  768. destPoints,
  769. count,
  770. srcRect.X,
  771. srcRect.Y,
  772. srcRect.Width,
  773. srcRect.Height,
  774. warpMode,
  775. flatness));
  776. }
  777. /**
  778. * Return the number of points in the current path
  779. */
  780. INT GetPointCount() const
  781. {
  782. INT count = 0;
  783. SetStatus(DllExports::GdipGetPointCount(nativePath, &count));
  784. return count;
  785. }
  786. /**
  787. * Return the path point type information
  788. */
  789. Status GetPathTypes(OUT BYTE* types,
  790. IN INT count) const
  791. {
  792. return SetStatus(DllExports::GdipGetPathTypes(nativePath, types, count));
  793. }
  794. /**
  795. * Return the path point coordinate information
  796. * @notes Should there be PathData that contains types[] and points[]
  797. * for get & set purposes.
  798. */
  799. Status GetPathPoints(OUT PointF* points,
  800. IN INT count) const
  801. {
  802. return SetStatus(DllExports::GdipGetPathPoints(nativePath, points, count));
  803. }
  804. // integer version
  805. Status GetPathPoints(OUT Point* points,
  806. IN INT count) const
  807. {
  808. return SetStatus(DllExports::GdipGetPathPointsI(nativePath, points, count));
  809. }
  810. Status GetLastStatus() const
  811. {
  812. Status lastStatus = lastResult;
  813. lastResult = Ok;
  814. return lastStatus;
  815. }
  816. /**
  817. * Hit testing operations
  818. *
  819. * inline implementation is in gdiplusgraphics.h.
  820. */
  821. BOOL IsVisible(IN const PointF& point,
  822. IN const Graphics* g = NULL) const
  823. {
  824. return IsVisible(point.X, point.Y, g);
  825. }
  826. BOOL IsVisible(IN REAL x,
  827. IN REAL y,
  828. IN const Graphics* g = NULL) const;
  829. BOOL IsVisible(IN const Point& point,
  830. IN const Graphics* g = NULL) const
  831. {
  832. return IsVisible(point.X, point.Y, g);
  833. }
  834. BOOL IsVisible(IN INT x,
  835. IN INT y,
  836. IN const Graphics* g = NULL) const;
  837. BOOL IsOutlineVisible(IN const PointF& point,
  838. IN const Pen* pen,
  839. IN const Graphics* g = NULL) const
  840. {
  841. return IsOutlineVisible(point.X, point.Y, pen, g);
  842. }
  843. BOOL IsOutlineVisible(IN REAL x,
  844. IN REAL y,
  845. IN const Pen* pen,
  846. IN const Graphics* g = NULL) const;
  847. BOOL IsOutlineVisible(IN const Point& point,
  848. IN const Pen* pen,
  849. IN const Graphics* g = NULL) const
  850. {
  851. return IsOutlineVisible(point.X, point.Y, pen, g);
  852. }
  853. BOOL IsOutlineVisible(IN INT x,
  854. IN INT y,
  855. IN const Pen* pen,
  856. IN const Graphics* g = NULL) const;
  857. protected:
  858. GraphicsPath(const GraphicsPath& path)
  859. {
  860. GpPath *clonepath = NULL;
  861. SetStatus(DllExports::GdipClonePath(path.nativePath, &clonepath));
  862. SetNativePath(clonepath);
  863. }
  864. #ifdef DCR_USE_NEW_250932
  865. private:
  866. GraphicsPath& operator=(const GraphicsPath &);
  867. protected:
  868. #else
  869. GraphicsPath& operator=(const GraphicsPath& path)
  870. {
  871. path;
  872. SetStatus(NotImplemented);
  873. return *this;
  874. }
  875. #endif
  876. GraphicsPath(GpPath* nativePath)
  877. {
  878. lastResult = Ok;
  879. SetNativePath(nativePath);
  880. }
  881. VOID SetNativePath(GpPath *nativePath)
  882. {
  883. this->nativePath = nativePath;
  884. }
  885. Status SetStatus(Status status) const
  886. {
  887. if (status != Ok)
  888. return (lastResult = status);
  889. else
  890. return status;
  891. }
  892. protected:
  893. GpPath* nativePath;
  894. mutable Status lastResult;
  895. };
  896. //--------------------------------------------------------------------------
  897. // GraphisPathIterator class
  898. //--------------------------------------------------------------------------
  899. class GraphicsPathIterator : public GdiplusBase
  900. {
  901. public:
  902. GraphicsPathIterator(IN const GraphicsPath* path)
  903. {
  904. GpPath* nativePath = NULL;
  905. if(path)
  906. nativePath = path->nativePath;
  907. GpPathIterator *iter = NULL;
  908. lastResult = DllExports::GdipCreatePathIter(&iter, nativePath);
  909. SetNativeIterator(iter);
  910. }
  911. ~GraphicsPathIterator()
  912. {
  913. DllExports::GdipDeletePathIter(nativeIterator);
  914. }
  915. INT NextSubpath(OUT INT* startIndex,
  916. OUT INT* endIndex,
  917. OUT BOOL* isClosed)
  918. {
  919. INT resultCount;
  920. SetStatus(DllExports::GdipPathIterNextSubpath(nativeIterator,
  921. &resultCount, startIndex, endIndex, isClosed));
  922. return resultCount;
  923. }
  924. INT NextSubpath(IN const GraphicsPath* path,
  925. OUT BOOL* isClosed)
  926. {
  927. GpPath* nativePath = NULL;
  928. INT resultCount;
  929. if(path)
  930. nativePath= path->nativePath;
  931. SetStatus(DllExports::GdipPathIterNextSubpathPath(nativeIterator,
  932. &resultCount, nativePath, isClosed));
  933. return resultCount;
  934. }
  935. INT NextPathType(OUT BYTE* pathType,
  936. OUT INT* startIndex,
  937. OUT INT* endIndex)
  938. {
  939. INT resultCount;
  940. SetStatus(DllExports::GdipPathIterNextPathType(nativeIterator,
  941. &resultCount, pathType, startIndex, endIndex));
  942. return resultCount;
  943. }
  944. INT NextMarker(OUT INT* startIndex,
  945. OUT INT* endIndex)
  946. {
  947. INT resultCount;
  948. SetStatus(DllExports::GdipPathIterNextMarker(nativeIterator,
  949. &resultCount, startIndex, endIndex));
  950. return resultCount;
  951. }
  952. INT NextMarker(IN const GraphicsPath* path)
  953. {
  954. GpPath* nativePath = NULL;
  955. INT resultCount;
  956. if(path)
  957. nativePath= path->nativePath;
  958. SetStatus(DllExports::GdipPathIterNextMarkerPath(nativeIterator,
  959. &resultCount, nativePath));
  960. return resultCount;
  961. }
  962. INT GetCount() const
  963. {
  964. INT resultCount;
  965. SetStatus(DllExports::GdipPathIterGetCount(nativeIterator, &resultCount));
  966. return resultCount;
  967. }
  968. INT GetSubpathCount() const
  969. {
  970. INT resultCount;
  971. SetStatus(DllExports::GdipPathIterGetSubpathCount(nativeIterator, &resultCount));
  972. return resultCount;
  973. }
  974. BOOL HasCurve() const
  975. {
  976. BOOL hasCurve;
  977. SetStatus(DllExports::GdipPathIterHasCurve(nativeIterator, &hasCurve));
  978. return hasCurve;
  979. }
  980. VOID Rewind()
  981. {
  982. SetStatus(DllExports::GdipPathIterRewind(nativeIterator));
  983. }
  984. INT Enumerate(OUT PointF *points,
  985. OUT BYTE *types,
  986. IN INT count)
  987. {
  988. INT resultCount;
  989. SetStatus(DllExports::GdipPathIterEnumerate(nativeIterator,
  990. &resultCount, points, types, count));
  991. return resultCount;
  992. }
  993. INT CopyData(OUT PointF* points,
  994. OUT BYTE* types,
  995. IN INT startIndex,
  996. IN INT endIndex)
  997. {
  998. INT resultCount;
  999. SetStatus(DllExports::GdipPathIterCopyData(nativeIterator,
  1000. &resultCount, points, types, startIndex, endIndex));
  1001. return resultCount;
  1002. }
  1003. Status GetLastStatus() const
  1004. {
  1005. Status lastStatus = lastResult;
  1006. lastResult = Ok;
  1007. return lastStatus;
  1008. }
  1009. #ifdef DCR_USE_NEW_250932
  1010. private:
  1011. GraphicsPathIterator(const GraphicsPathIterator &);
  1012. GraphicsPathIterator& operator=(const GraphicsPathIterator &);
  1013. #endif
  1014. protected:
  1015. VOID SetNativeIterator(GpPathIterator *nativeIterator)
  1016. {
  1017. this->nativeIterator = nativeIterator;
  1018. }
  1019. Status SetStatus(Status status) const
  1020. {
  1021. if (status != Ok)
  1022. return (lastResult = status);
  1023. else
  1024. return status;
  1025. }
  1026. protected:
  1027. GpPathIterator* nativeIterator;
  1028. mutable Status lastResult;
  1029. };
  1030. //--------------------------------------------------------------------------
  1031. // Represent polygon gradient brush object
  1032. //--------------------------------------------------------------------------
  1033. class PathGradientBrush : public Brush
  1034. {
  1035. public:
  1036. friend class Pen;
  1037. PathGradientBrush(
  1038. IN const PointF* points,
  1039. IN INT count,
  1040. IN WrapMode wrapMode = WrapModeClamp)
  1041. {
  1042. GpPathGradient *brush = NULL;
  1043. lastResult = DllExports::GdipCreatePathGradient(
  1044. points, count,
  1045. wrapMode, &brush);
  1046. SetNativeBrush(brush);
  1047. }
  1048. PathGradientBrush(
  1049. IN const Point* points,
  1050. IN INT count,
  1051. IN WrapMode wrapMode = WrapModeClamp)
  1052. {
  1053. GpPathGradient *brush = NULL;
  1054. lastResult = DllExports::GdipCreatePathGradientI(
  1055. points, count,
  1056. wrapMode, &brush);
  1057. SetNativeBrush(brush);
  1058. }
  1059. PathGradientBrush(
  1060. IN const GraphicsPath* path
  1061. )
  1062. {
  1063. GpPathGradient *brush = NULL;
  1064. lastResult = DllExports::GdipCreatePathGradientFromPath(
  1065. path->nativePath, &brush);
  1066. SetNativeBrush(brush);
  1067. }
  1068. // Get/set colors
  1069. Status GetCenterColor(OUT Color* color) const
  1070. {
  1071. ARGB argb;
  1072. if (color == NULL)
  1073. {
  1074. return SetStatus(InvalidParameter);
  1075. }
  1076. SetStatus(DllExports::GdipGetPathGradientCenterColor(
  1077. (GpPathGradient*) nativeBrush, &argb));
  1078. color->SetValue(argb);
  1079. return lastResult;
  1080. }
  1081. Status SetCenterColor(IN const Color& color)
  1082. {
  1083. SetStatus(DllExports::GdipSetPathGradientCenterColor(
  1084. (GpPathGradient*) nativeBrush,
  1085. color.GetValue()));
  1086. return lastResult;
  1087. }
  1088. INT GetPointCount() const
  1089. {
  1090. INT count;
  1091. SetStatus(DllExports::GdipGetPathGradientPointCount(
  1092. (GpPathGradient*) nativeBrush, &count));
  1093. return count;
  1094. }
  1095. INT GetSurroundColorCount() const
  1096. {
  1097. INT count;
  1098. SetStatus(DllExports::GdipGetPathGradientSurroundColorCount(
  1099. (GpPathGradient*) nativeBrush, &count));
  1100. return count;
  1101. }
  1102. Status GetSurroundColors(OUT Color* colors,
  1103. IN OUT INT* count) const
  1104. {
  1105. if(colors == NULL || count == NULL)
  1106. {
  1107. return SetStatus(InvalidParameter);
  1108. }
  1109. INT count1;
  1110. SetStatus(DllExports::GdipGetPathGradientSurroundColorCount(
  1111. (GpPathGradient*) nativeBrush, &count1));
  1112. if(lastResult != Ok)
  1113. return lastResult;
  1114. if((*count < count1) || (count1 <= 0))
  1115. return SetStatus(InsufficientBuffer);
  1116. ARGB* argbs = (ARGB*) new ARGB[count1];
  1117. if(argbs == NULL)
  1118. return SetStatus(OutOfMemory);
  1119. SetStatus(DllExports::GdipGetPathGradientSurroundColorsWithCount(
  1120. (GpPathGradient*)nativeBrush, argbs, &count1));
  1121. if(lastResult == Ok)
  1122. {
  1123. for(INT i = 0; i < count1; i++)
  1124. {
  1125. colors[i].SetValue(argbs[i]);
  1126. }
  1127. *count = count1;
  1128. }
  1129. delete [] argbs;
  1130. return lastResult;
  1131. }
  1132. Status SetSurroundColors(IN const Color* colors,
  1133. IN OUT INT* count)
  1134. {
  1135. if(colors == NULL || count == NULL)
  1136. {
  1137. return SetStatus(InvalidParameter);
  1138. }
  1139. INT count1 = GetPointCount();
  1140. if((*count > count1) || (count1 <= 0))
  1141. return SetStatus(InvalidParameter);
  1142. count1 = *count;
  1143. ARGB* argbs = (ARGB*) new ARGB[count1];
  1144. if(argbs == NULL)
  1145. return SetStatus(OutOfMemory);
  1146. for(INT i = 0; i < count1; i++)
  1147. {
  1148. argbs[i] = colors[i].GetValue();
  1149. }
  1150. SetStatus(DllExports::GdipSetPathGradientSurroundColorsWithCount(
  1151. (GpPathGradient*)nativeBrush, argbs, &count1));
  1152. if(lastResult == Ok)
  1153. *count = count1;
  1154. delete [] argbs;
  1155. return lastResult;
  1156. }
  1157. Status GetGraphicsPath(OUT GraphicsPath* path) const
  1158. {
  1159. if(path == NULL)
  1160. return SetStatus(InvalidParameter);
  1161. return SetStatus(DllExports::GdipGetPathGradientPath(
  1162. (GpPathGradient*)nativeBrush, path->nativePath));
  1163. }
  1164. Status SetGraphicsPath(IN const GraphicsPath* path)
  1165. {
  1166. if(path == NULL)
  1167. return SetStatus(InvalidParameter);
  1168. return SetStatus(DllExports::GdipSetPathGradientPath(
  1169. (GpPathGradient*)nativeBrush, path->nativePath));
  1170. }
  1171. Status GetCenterPoint(OUT PointF* point) const
  1172. {
  1173. return SetStatus(DllExports::GdipGetPathGradientCenterPoint(
  1174. (GpPathGradient*)nativeBrush,
  1175. point));
  1176. }
  1177. Status GetCenterPoint(OUT Point* point) const
  1178. {
  1179. return SetStatus(DllExports::GdipGetPathGradientCenterPointI(
  1180. (GpPathGradient*)nativeBrush,
  1181. point));
  1182. }
  1183. Status SetCenterPoint(IN const PointF& point)
  1184. {
  1185. return SetStatus(DllExports::GdipSetPathGradientCenterPoint(
  1186. (GpPathGradient*)nativeBrush,
  1187. &point));
  1188. }
  1189. Status SetCenterPoint(IN const Point& point)
  1190. {
  1191. return SetStatus(DllExports::GdipSetPathGradientCenterPointI(
  1192. (GpPathGradient*)nativeBrush,
  1193. &point));
  1194. }
  1195. Status GetRectangle(OUT RectF* rect) const
  1196. {
  1197. return SetStatus(DllExports::GdipGetPathGradientRect(
  1198. (GpPathGradient*)nativeBrush, rect));
  1199. }
  1200. Status GetRectangle(OUT Rect* rect) const
  1201. {
  1202. return SetStatus(DllExports::GdipGetPathGradientRectI(
  1203. (GpPathGradient*)nativeBrush, rect));
  1204. }
  1205. // Gamma correction.
  1206. Status SetGammaCorrection(IN BOOL useGammaCorrection)
  1207. {
  1208. return SetStatus(DllExports::GdipSetPathGradientGammaCorrection(
  1209. (GpPathGradient*)nativeBrush, useGammaCorrection));
  1210. }
  1211. BOOL GetGammaCorrection() const
  1212. {
  1213. BOOL useGammaCorrection;
  1214. SetStatus(DllExports::GdipGetPathGradientGammaCorrection(
  1215. (GpPathGradient*)nativeBrush, &useGammaCorrection));
  1216. return useGammaCorrection;
  1217. }
  1218. INT GetBlendCount() const
  1219. {
  1220. INT count = 0;
  1221. SetStatus(DllExports::GdipGetPathGradientBlendCount(
  1222. (GpPathGradient*) nativeBrush, &count));
  1223. return count;
  1224. }
  1225. Status GetBlend(OUT REAL* blendFactors,
  1226. OUT REAL* blendPositions,
  1227. IN INT count) const
  1228. {
  1229. return SetStatus(DllExports::GdipGetPathGradientBlend(
  1230. (GpPathGradient*)nativeBrush,
  1231. blendFactors, blendPositions, count));
  1232. }
  1233. Status SetBlend(IN const REAL* blendFactors,
  1234. IN const REAL* blendPositions,
  1235. IN INT count)
  1236. {
  1237. return SetStatus(DllExports::GdipSetPathGradientBlend(
  1238. (GpPathGradient*)nativeBrush,
  1239. blendFactors, blendPositions, count));
  1240. }
  1241. INT GetInterpolationColorCount() const
  1242. {
  1243. INT count = 0;
  1244. SetStatus(DllExports::GdipGetPathGradientPresetBlendCount(
  1245. (GpPathGradient*) nativeBrush, &count));
  1246. return count;
  1247. }
  1248. Status SetInterpolationColors(IN const Color* presetColors,
  1249. IN const REAL* blendPositions,
  1250. IN INT count)
  1251. {
  1252. if ((count <= 0) || !presetColors)
  1253. {
  1254. return SetStatus(InvalidParameter);
  1255. }
  1256. ARGB* argbs = (ARGB*) new ARGB[count];
  1257. if(argbs)
  1258. {
  1259. for(INT i = 0; i < count; i++)
  1260. {
  1261. argbs[i] = presetColors[i].GetValue();
  1262. }
  1263. Status status = SetStatus(DllExports::GdipSetPathGradientPresetBlend(
  1264. (GpPathGradient*) nativeBrush,
  1265. argbs,
  1266. blendPositions,
  1267. count));
  1268. delete[] argbs;
  1269. return status;
  1270. }
  1271. else
  1272. {
  1273. return SetStatus(OutOfMemory);
  1274. }
  1275. }
  1276. Status GetInterpolationColors(OUT Color* presetColors,
  1277. OUT REAL* blendPositions,
  1278. IN INT count) const
  1279. {
  1280. if ((count <= 0) || !presetColors)
  1281. {
  1282. return SetStatus(InvalidParameter);
  1283. }
  1284. ARGB* argbs = (ARGB*) new ARGB[count];
  1285. if (!argbs)
  1286. {
  1287. return SetStatus(OutOfMemory);
  1288. }
  1289. GpStatus status = SetStatus(DllExports::GdipGetPathGradientPresetBlend(
  1290. (GpPathGradient*)nativeBrush,
  1291. argbs,
  1292. blendPositions,
  1293. count));
  1294. for(INT i = 0; i < count; i++)
  1295. {
  1296. presetColors[i] = Color(argbs[i]);
  1297. }
  1298. delete [] argbs;
  1299. return status;
  1300. }
  1301. Status SetBlendBellShape(IN REAL focus,
  1302. IN REAL scale = 1.0)
  1303. {
  1304. return SetStatus(DllExports::GdipSetPathGradientSigmaBlend(
  1305. (GpPathGradient*)nativeBrush, focus, scale));
  1306. }
  1307. #ifdef DCR_USE_NEW_145135
  1308. Status SetBlendTriangularShape(
  1309. IN REAL focus,
  1310. IN REAL scale = 1.0
  1311. )
  1312. #else
  1313. Status SetBlendTrianglarShape(IN REAL focus,
  1314. IN REAL scale = 1.0)
  1315. #endif
  1316. {
  1317. return SetStatus(DllExports::GdipSetPathGradientLinearBlend(
  1318. (GpPathGradient*)nativeBrush, focus, scale));
  1319. }
  1320. /**
  1321. * Get/set brush transform
  1322. */
  1323. Status GetTransform(OUT Matrix *matrix) const
  1324. {
  1325. return SetStatus(DllExports::GdipGetPathGradientTransform(
  1326. (GpPathGradient*) nativeBrush, matrix->nativeMatrix));
  1327. }
  1328. Status SetTransform(IN const Matrix* matrix)
  1329. {
  1330. return SetStatus(DllExports::GdipSetPathGradientTransform(
  1331. (GpPathGradient*) nativeBrush, matrix->nativeMatrix));
  1332. }
  1333. Status ResetTransform()
  1334. {
  1335. return SetStatus(DllExports::GdipResetPathGradientTransform((GpPathGradient*)nativeBrush));
  1336. }
  1337. Status MultiplyTransform(IN const Matrix* matrix,
  1338. IN MatrixOrder order = MatrixOrderPrepend)
  1339. {
  1340. return SetStatus(DllExports::GdipMultiplyPathGradientTransform((GpPathGradient*)nativeBrush,
  1341. matrix->nativeMatrix,
  1342. order));
  1343. }
  1344. Status TranslateTransform(IN REAL dx,
  1345. IN REAL dy,
  1346. IN MatrixOrder order = MatrixOrderPrepend)
  1347. {
  1348. return SetStatus(DllExports::GdipTranslatePathGradientTransform((GpPathGradient*)nativeBrush,
  1349. dx, dy, order));
  1350. }
  1351. Status ScaleTransform(IN REAL sx,
  1352. IN REAL sy,
  1353. IN MatrixOrder order = MatrixOrderPrepend)
  1354. {
  1355. return SetStatus(DllExports::GdipScalePathGradientTransform((GpPathGradient*)nativeBrush,
  1356. sx, sy, order));
  1357. }
  1358. Status RotateTransform(IN REAL angle,
  1359. IN MatrixOrder order = MatrixOrderPrepend)
  1360. {
  1361. return SetStatus(DllExports::GdipRotatePathGradientTransform((GpPathGradient*)nativeBrush,
  1362. angle, order));
  1363. }
  1364. /**
  1365. * Get/set brush focus scales
  1366. */
  1367. Status GetFocusScales(OUT REAL* xScale,
  1368. OUT REAL* yScale) const
  1369. {
  1370. return SetStatus(DllExports::GdipGetPathGradientFocusScales(
  1371. (GpPathGradient*) nativeBrush, xScale, yScale));
  1372. }
  1373. Status SetFocusScales(IN REAL xScale,
  1374. IN REAL yScale)
  1375. {
  1376. return SetStatus(DllExports::GdipSetPathGradientFocusScales(
  1377. (GpPathGradient*) nativeBrush, xScale, yScale));
  1378. }
  1379. /**
  1380. * Get/set brush wrapping mode
  1381. */
  1382. WrapMode GetWrapMode() const
  1383. {
  1384. WrapMode wrapMode;
  1385. SetStatus(DllExports::GdipGetPathGradientWrapMode(
  1386. (GpPathGradient*) nativeBrush, &wrapMode));
  1387. return wrapMode;
  1388. }
  1389. Status SetWrapMode(IN WrapMode wrapMode)
  1390. {
  1391. return SetStatus(DllExports::GdipSetPathGradientWrapMode(
  1392. (GpPathGradient*) nativeBrush, wrapMode));
  1393. }
  1394. #ifdef DCR_USE_NEW_250932
  1395. private:
  1396. PathGradientBrush(const PathGradientBrush &);
  1397. PathGradientBrush& operator=(const PathGradientBrush &);
  1398. #endif
  1399. protected:
  1400. PathGradientBrush()
  1401. {
  1402. }
  1403. };
  1404. #endif // !_GRAPHICSPATH_HPP