Evan Stade : gdiplus: Implemented GdipSetPenColor.

Alexandre Julliard julliard at wine.codeweavers.com
Tue Jul 24 07:06:23 CDT 2007


Module: wine
Branch: master
Commit: 27124d5d327c5fe9a975fd174c47b31bc72d3c25
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=27124d5d327c5fe9a975fd174c47b31bc72d3c25

Author: Evan Stade <estade at gmail.com>
Date:   Mon Jul 23 20:24:29 2007 -0700

gdiplus: Implemented GdipSetPenColor.

---

 dlls/gdiplus/gdiplus.spec      |    2 +-
 dlls/gdiplus/gdiplus_private.h |    1 -
 dlls/gdiplus/graphics.c        |   16 ++++++++--------
 dlls/gdiplus/pen.c             |   17 +++++++++++++++--
 dlls/gdiplus/tests/pen.c       |    6 ++----
 include/gdiplusflat.h          |    1 +
 6 files changed, 27 insertions(+), 16 deletions(-)

diff --git a/dlls/gdiplus/gdiplus.spec b/dlls/gdiplus/gdiplus.spec
index 82e2b76..c2880e8 100644
--- a/dlls/gdiplus/gdiplus.spec
+++ b/dlls/gdiplus/gdiplus.spec
@@ -542,7 +542,7 @@
 @ stub GdipSetPathGradientWrapMode
 @ stub GdipSetPathMarker
 @ stdcall GdipSetPenBrushFill(ptr ptr)
-@ stub GdipSetPenColor
+@ stdcall GdipSetPenColor(ptr long)
 @ stub GdipSetPenCompoundArray
 @ stdcall GdipSetPenCustomEndCap(ptr ptr)
 @ stdcall GdipSetPenCustomStartCap(ptr ptr)
diff --git a/dlls/gdiplus/gdiplus_private.h b/dlls/gdiplus/gdiplus_private.h
index 0338042..aac3278 100644
--- a/dlls/gdiplus/gdiplus_private.h
+++ b/dlls/gdiplus/gdiplus_private.h
@@ -44,7 +44,6 @@ static inline REAL deg2rad(REAL degrees)
 
 struct GpPen{
     UINT style;
-    COLORREF color;
     GpUnit unit;
     REAL width;
     HPEN gdipen;
diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c
index 0594c57..93b2079 100644
--- a/dlls/gdiplus/graphics.c
+++ b/dlls/gdiplus/graphics.c
@@ -394,9 +394,9 @@ static GpStatus draw_polyline(HDC hdc, GpPen *pen, GDIPCONST GpPointF * pt,
                              &ptcopy[0].X, &ptcopy[0].Y,
                              pen->customend->inset * pen->width);
 
-        draw_cap(hdc, pen->color, pen->endcap, pen->width, pen->customend,
+        draw_cap(hdc, pen->brush->lb.lbColor, pen->endcap, pen->width, pen->customend,
                  pt[count - 2].X, pt[count - 2].Y, pt[count - 1].X, pt[count - 1].Y);
-        draw_cap(hdc, pen->color, pen->startcap, pen->width, pen->customstart,
+        draw_cap(hdc, pen->brush->lb.lbColor, pen->startcap, pen->width, pen->customstart,
                          pt[1].X, pt[1].Y, pt[0].X, pt[0].Y);
     }
 
@@ -512,12 +512,12 @@ static GpStatus draw_polybezier(HDC hdc, GpPen *pen, GDIPCONST GpPointF * pt,
         /* the direction of the line cap is parallel to the direction at the
          * end of the bezier (which, if it has been shortened, is not the same
          * as the direction from pt[count-2] to pt[count-1]) */
-        draw_cap(hdc, pen->color, pen->endcap, pen->width, pen->customend,
+        draw_cap(hdc, pen->brush->lb.lbColor, pen->endcap, pen->width, pen->customend,
             pt[count - 1].X - (ptcopy[count - 1].X - ptcopy[count - 2].X),
             pt[count - 1].Y - (ptcopy[count - 1].Y - ptcopy[count - 2].Y),
             pt[count - 1].X, pt[count - 1].Y);
 
-        draw_cap(hdc, pen->color, pen->startcap, pen->width, pen->customstart,
+        draw_cap(hdc, pen->brush->lb.lbColor, pen->startcap, pen->width, pen->customstart,
             pt[0].X - (ptcopy[0].X - ptcopy[1].X),
             pt[0].Y - (ptcopy[0].Y - ptcopy[1].Y), pt[0].X, pt[0].Y);
     }
@@ -588,7 +588,7 @@ static GpStatus draw_poly(HDC hdc, GpPen *pen, GDIPCONST GpPointF * pt,
                     MoveToEx(hdc, curpos.x, curpos.y, NULL);
                 }
 
-                draw_cap(hdc, pen->color, pen->endcap, pen->width, pen->customend,
+                draw_cap(hdc, pen->brush->lb.lbColor, pen->endcap, pen->width, pen->customend,
                     pt[count - 1].X - (ptcopy[count - 1].X - ptcopy[count - 2].X),
                     pt[count - 1].Y - (ptcopy[count - 1].Y - ptcopy[count - 2].Y),
                     pt[count - 1].X, pt[count - 1].Y);
@@ -604,7 +604,7 @@ static GpStatus draw_poly(HDC hdc, GpPen *pen, GDIPCONST GpPointF * pt,
                                      &ptcopy[count - 1].X, &ptcopy[count - 1].Y,
                                      pen->customend->inset * pen->width);
 
-                draw_cap(hdc, pen->color, pen->endcap, pen->width, pen->customend,
+                draw_cap(hdc, pen->brush->lb.lbColor, pen->endcap, pen->width, pen->customend,
                          pt[count - 2].X, pt[count - 2].Y, pt[count - 1].X,
                          pt[count - 1].Y);
 
@@ -632,7 +632,7 @@ static GpStatus draw_poly(HDC hdc, GpPen *pen, GDIPCONST GpPointF * pt,
                     MoveToEx(hdc, curpos.x, curpos.y, NULL);
                 }
 
-                draw_cap(hdc, pen->color, pen->startcap, pen->width, pen->customstart,
+                draw_cap(hdc, pen->brush->lb.lbColor, pen->startcap, pen->width, pen->customstart,
                     pt[j - 1].X - (ptcopy[j - 1].X - ptcopy[j].X),
                     pt[j - 1].Y - (ptcopy[j - 1].Y - ptcopy[j].Y),
                     pt[j - 1].X, pt[j - 1].Y);
@@ -648,7 +648,7 @@ static GpStatus draw_poly(HDC hdc, GpPen *pen, GDIPCONST GpPointF * pt,
                                      &ptcopy[j - 1].X, &ptcopy[j - 1].Y,
                                      pen->customstart->inset * pen->width);
 
-                draw_cap(hdc, pen->color, pen->endcap, pen->width, pen->customstart,
+                draw_cap(hdc, pen->brush->lb.lbColor, pen->endcap, pen->width, pen->customstart,
                          pt[j].X, pt[j].Y, pt[j - 1].X,
                          pt[j - 1].Y);
 
diff --git a/dlls/gdiplus/pen.c b/dlls/gdiplus/pen.c
index d68df33..0f58b25 100644
--- a/dlls/gdiplus/pen.c
+++ b/dlls/gdiplus/pen.c
@@ -98,7 +98,6 @@ GpStatus WINGDIPAPI GdipCreatePen1(ARGB color, FLOAT width, GpUnit unit,
     if(!gp_pen)    return OutOfMemory;
 
     gp_pen->style = GP_DEFAULT_PENSTYLE;
-    gp_pen->color = ARGB2COLORREF(color);
     gp_pen->width = width;
     gp_pen->unit = unit;
     gp_pen->endcap = LineCapFlat;
@@ -147,7 +146,10 @@ GpStatus WINGDIPAPI GdipGetPenColor(GpPen *pen, ARGB *argb)
     if(!pen || !argb)
         return InvalidParameter;
 
-    return NotImplemented;
+    if(pen->brush->bt != BrushTypeSolidColor)
+        return NotImplemented;
+
+    return GdipGetSolidFillColor(((GpSolidFill*)pen->brush), argb);
 }
 
 GpStatus WINGDIPAPI GdipGetPenDashStyle(GpPen *pen, GpDashStyle *dash)
@@ -179,6 +181,17 @@ GpStatus WINGDIPAPI GdipSetPenBrushFill(GpPen *pen, GpBrush *brush)
     return Ok;
 }
 
+GpStatus WINGDIPAPI GdipSetPenColor(GpPen *pen, ARGB argb)
+{
+    if(!pen)
+        return InvalidParameter;
+
+    if(pen->brush->bt != BrushTypeSolidColor)
+        return NotImplemented;
+
+    return GdipSetSolidFillColor(((GpSolidFill*)pen->brush), argb);
+}
+
 GpStatus WINGDIPAPI GdipSetPenCustomEndCap(GpPen *pen, GpCustomLineCap* customCap)
 {
     GpCustomLineCap * cap;
diff --git a/dlls/gdiplus/tests/pen.c b/dlls/gdiplus/tests/pen.c
index 16a9356..0238aac 100644
--- a/dlls/gdiplus/tests/pen.c
+++ b/dlls/gdiplus/tests/pen.c
@@ -87,8 +87,7 @@ static void test_brushfill(void)
     GdipGetBrushType(brush, &type);
     expect(BrushTypeSolidColor, type);
     GdipGetPenColor(pen, &color);
-    todo_wine
-        expect(0xdeadbeef, color);
+    expect(0xdeadbeef, color);
     GdipDeleteBrush(brush);
 
     /* color controlled by brush */
@@ -96,8 +95,7 @@ static void test_brushfill(void)
     status = GdipSetPenBrushFill(pen, brush);
     expect(Ok, status);
     GdipGetPenColor(pen, &color);
-    todo_wine
-        expect(0xabaddeed, color);
+    expect(0xabaddeed, color);
     GdipDeleteBrush(brush);
     color = 0;
 
diff --git a/include/gdiplusflat.h b/include/gdiplusflat.h
index bfd1211..446cb98 100644
--- a/include/gdiplusflat.h
+++ b/include/gdiplusflat.h
@@ -34,6 +34,7 @@ GpStatus WINGDIPAPI GdipGetPenBrushFill(GpPen*,GpBrush**);
 GpStatus WINGDIPAPI GdipGetPenColor(GpPen*,ARGB*);
 GpStatus WINGDIPAPI GdipGetPenDashStyle(GpPen*,GpDashStyle*);
 GpStatus WINGDIPAPI GdipSetPenBrushFill(GpPen*,GpBrush*);
+GpStatus WINGDIPAPI GdipSetPenColor(GpPen*,ARGB);
 GpStatus WINGDIPAPI GdipSetPenCustomEndCap(GpPen*,GpCustomLineCap*);
 GpStatus WINGDIPAPI GdipSetPenCustomStartCap(GpPen*,GpCustomLineCap*);
 GpStatus WINGDIPAPI GdipSetPenDashStyle(GpPen*,GpDashStyle);




More information about the wine-cvs mailing list