From 9f25eb35b75129beeffc85dcd588a34cad66fb6c Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Wed, 3 Dec 2008 18:22:55 +0300 Subject: [PATCH] gdiplus: Added GdipGetPenFillType. --- dlls/gdiplus/gdiplus.spec | 2 +- dlls/gdiplus/pen.c | 30 +++++++++++++++++++++++ dlls/gdiplus/tests/pen.c | 51 +++++++++++++++++++++++++++++++++++++++ include/gdiplusenums.h | 11 +++++++++ include/gdiplusflat.h | 1 + include/gdiplusgpstubs.h | 1 + 6 files changed, 95 insertions(+), 1 deletion(-) diff --git a/dlls/gdiplus/gdiplus.spec b/dlls/gdiplus/gdiplus.spec index 1dce580d6da..b5a5aabfa9a 100644 --- a/dlls/gdiplus/gdiplus.spec +++ b/dlls/gdiplus/gdiplus.spec @@ -360,7 +360,7 @@ @ stdcall GdipGetPenDashOffset(ptr ptr) @ stdcall GdipGetPenDashStyle(ptr ptr) @ stdcall GdipGetPenEndCap(ptr ptr) -@ stub GdipGetPenFillType +@ stdcall GdipGetPenFillType(ptr ptr) @ stdcall GdipGetPenLineJoin(ptr ptr) @ stdcall GdipGetPenMiterLimit(ptr ptr) @ stdcall GdipGetPenMode(ptr ptr) diff --git a/dlls/gdiplus/pen.c b/dlls/gdiplus/pen.c index 61f18989abd..2804b141fe0 100644 --- a/dlls/gdiplus/pen.c +++ b/dlls/gdiplus/pen.c @@ -67,6 +67,24 @@ static DWORD gdip_to_gdi_join(GpLineJoin join) } } +static GpPenType bt_to_pt(GpBrushType bt) +{ + switch(bt){ + case BrushTypeSolidColor: + return PenTypeSolidColor; + case BrushTypeHatchFill: + return PenTypeHatchFill; + case BrushTypeTextureFill: + return PenTypeTextureFill; + case BrushTypePathGradient: + return PenTypePathGradient; + case BrushTypeLinearGradient: + return PenTypeLinearGradient; + default: + return PenTypeUnknown; + } +} + GpStatus WINGDIPAPI GdipClonePen(GpPen *pen, GpPen **clonepen) { TRACE("(%p, %p)\n", pen, clonepen); @@ -283,6 +301,18 @@ GpStatus WINGDIPAPI GdipGetPenEndCap(GpPen *pen, GpLineCap *endCap) return Ok; } +GpStatus WINGDIPAPI GdipGetPenFillType(GpPen *pen, GpPenType* type) +{ + TRACE("(%p, %p)\n", pen, type); + + if(!pen || !type) + return InvalidParameter; + + *type = bt_to_pt(pen->brush->bt); + + return Ok; +} + GpStatus WINGDIPAPI GdipGetPenLineJoin(GpPen *pen, GpLineJoin *lineJoin) { TRACE("(%p, %p)\n", pen, lineJoin); diff --git a/dlls/gdiplus/tests/pen.c b/dlls/gdiplus/tests/pen.c index d75e510f9e4..263d0a711e2 100644 --- a/dlls/gdiplus/tests/pen.c +++ b/dlls/gdiplus/tests/pen.c @@ -275,6 +275,56 @@ static void test_customcap(void) GdipDeletePen(pen); } +static void test_penfilltype(void) +{ + GpPen *pen; + GpSolidFill *solid; + GpLineGradient *line; + GpPointF a, b; + GpStatus status; + GpPenType type; + + /* NULL */ + status = GdipGetPenFillType(NULL, NULL); + expect(InvalidParameter, status); + + status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen); + expect(Ok, status); + status = GdipGetPenFillType(pen, NULL); + expect(InvalidParameter, status); + + /* created with GdipCreatePen1() */ + status = GdipGetPenFillType(pen, &type); + expect(Ok, status); + expect(PenTypeSolidColor, type); + GdipDeletePen(pen); + + /* based on SolidBrush */ + status = GdipCreateSolidFill((ARGB)0xffff00ff, &solid); + expect(Ok, status); + status = GdipCreatePen2((GpBrush*)solid, 10.0f, UnitPixel, &pen); + expect(Ok, status); + status = GdipGetPenFillType(pen, &type); + expect(Ok, status); + expect(PenTypeSolidColor, type); + GdipDeletePen(pen); + GdipDeleteBrush((GpBrush*)solid); + + /* based on LinearGradientBrush */ + a.X = a.Y = 0.0; + b.X = b.Y = 10.0; + status = GdipCreateLineBrush(&a, &b, (ARGB)0xffff00ff, (ARGB)0xffff0000, + WrapModeTile, &line); + expect(Ok, status); + status = GdipCreatePen2((GpBrush*)line, 10.0f, UnitPixel, &pen); + expect(Ok, status); + status = GdipGetPenFillType(pen, &type); + expect(Ok, status); + expect(PenTypeLinearGradient, type); + GdipDeletePen(pen); + GdipDeleteBrush((GpBrush*)line); +} + START_TEST(pen) { struct GdiplusStartupInput gdiplusStartupInput; @@ -294,6 +344,7 @@ START_TEST(pen) test_brushfill(); test_dasharray(); test_customcap(); + test_penfilltype(); GdiplusShutdown(gdiplusToken); } diff --git a/include/gdiplusenums.h b/include/gdiplusenums.h index 3138b8cecad..8f7470d5dbe 100644 --- a/include/gdiplusenums.h +++ b/include/gdiplusenums.h @@ -76,6 +76,16 @@ enum PathPointType{ PathPointTypeBezier3 = 3 }; +enum PenType +{ + PenTypeSolidColor = BrushTypeSolidColor, + PenTypeHatchFill = BrushTypeHatchFill, + PenTypeTextureFill = BrushTypeTextureFill, + PenTypePathGradient = BrushTypePathGradient, + PenTypeLinearGradient = BrushTypeLinearGradient, + PenTypeUnknown = -1 +}; + enum LineJoin { LineJoinMiter = 0, @@ -384,6 +394,7 @@ typedef enum FlushIntention FlushIntention; typedef enum CoordinateSpace CoordinateSpace; typedef enum GpTestControlEnum GpTestControlEnum; typedef enum MetafileFrameUnit MetafileFrameUnit; +typedef enum PenType PenType; #endif /* end of c typedefs */ diff --git a/include/gdiplusflat.h b/include/gdiplusflat.h index ea4bec5940e..ef6ba7d62da 100644 --- a/include/gdiplusflat.h +++ b/include/gdiplusflat.h @@ -487,6 +487,7 @@ GpStatus WINGDIPAPI GdipSetPenDashCap197819(GpPen*,GpDashCap); GpStatus WINGDIPAPI GdipSetPenDashOffset(GpPen*,REAL); GpStatus WINGDIPAPI GdipSetPenDashStyle(GpPen*,GpDashStyle); GpStatus WINGDIPAPI GdipSetPenEndCap(GpPen*,GpLineCap); +GpStatus WINGDIPAPI GdipGetPenFillType(GpPen*,GpPenType*); GpStatus WINGDIPAPI GdipSetPenLineCap197819(GpPen*,GpLineCap,GpLineCap,GpDashCap); GpStatus WINGDIPAPI GdipSetPenLineJoin(GpPen*,GpLineJoin); GpStatus WINGDIPAPI GdipSetPenMode(GpPen*,GpPenAlignment); diff --git a/include/gdiplusgpstubs.h b/include/gdiplusgpstubs.h index e1d1706edb0..a768638e0ad 100644 --- a/include/gdiplusgpstubs.h +++ b/include/gdiplusgpstubs.h @@ -90,5 +90,6 @@ typedef WrapMode GpWrapMode; typedef Color GpColor; typedef FlushIntention GpFlushIntention; typedef CoordinateSpace GpCoordinateSpace; +typedef PenType GpPenType; #endif