GdiPlusPath.h
上传用户:dzyhzl
上传日期:2019-04-29
资源大小:56270k
文件大小:46k
源码类别:

模拟服务器

开发平台:

C/C++

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