[8/9] gdiplus: added GdipSetPenDashStyle
Evan Stade
estade at gmail.com
Mon Jul 16 21:45:16 CDT 2007
Hi,
Note that this patch does not allow gdiplus to render dashed lines
correctly because gdi does not allow dashed lines greater than width
1.
Changelog:
*added GdipSetPenDashStyle
*explicitly set default pen as solid
*added necessary types
dlls/gdiplus/gdiplus.spec | 2 +-
dlls/gdiplus/gdiplus_private.h | 3 ++-
dlls/gdiplus/pen.c | 44 ++++++++++++++++++++++++++++++++++++++++
include/gdiplusenums.h | 11 ++++++++++
include/gdiplusflat.h | 1 +
include/gdiplusgpstubs.h | 1 +
6 files changed, 60 insertions(+), 2 deletions(-)
--
Evan Stade
-------------- next part --------------
diff --git a/dlls/gdiplus/gdiplus.spec b/dlls/gdiplus/gdiplus.spec
index aea3a72..81e5940 100644
--- a/dlls/gdiplus/gdiplus.spec
+++ b/dlls/gdiplus/gdiplus.spec
@@ -549,7 +549,7 @@
@ stub GdipSetPenDashArray
@ stub GdipSetPenDashCap197819
@ stub GdipSetPenDashOffset
-@ stub GdipSetPenDashStyle
+@ stdcall GdipSetPenDashStyle(ptr long)
@ stdcall GdipSetPenEndCap(ptr long)
@ stdcall GdipSetPenLineCap197819(ptr long long long)
@ stdcall GdipSetPenLineJoin(ptr long)
diff --git a/dlls/gdiplus/gdiplus_private.h b/dlls/gdiplus/gdiplus_private.h
index b0a9dd1..299806b 100644
--- a/dlls/gdiplus/gdiplus_private.h
+++ b/dlls/gdiplus/gdiplus_private.h
@@ -23,7 +23,7 @@ #include <math.h>
#include "windef.h"
#include "gdiplus.h"
-#define GP_DEFAULT_PENSTYLE (PS_GEOMETRIC | PS_ENDCAP_FLAT | PS_JOIN_MITER)
+#define GP_DEFAULT_PENSTYLE (PS_GEOMETRIC | PS_SOLID | PS_ENDCAP_FLAT | PS_JOIN_MITER)
#define MAX_ARC_PTS (13)
COLORREF ARGB2COLORREF(ARGB color);
@@ -51,6 +51,7 @@ struct GpPen{
GpDashCap dashcap;
GpLineJoin join;
REAL miterlimit;
+ GpDashStyle dash;
};
struct GpGraphics{
diff --git a/dlls/gdiplus/pen.c b/dlls/gdiplus/pen.c
index 1b37e13..53559bd 100644
--- a/dlls/gdiplus/pen.c
+++ b/dlls/gdiplus/pen.c
@@ -27,6 +27,28 @@ #include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(gdiplus);
+static DWORD gdip_to_gdi_dash(GpDashStyle dash)
+{
+ switch(dash){
+ case DashStyleSolid:
+ return PS_SOLID;
+ case DashStyleDash:
+ return PS_DASH;
+ case DashStyleDot:
+ return PS_DOT;
+ case DashStyleDashDot:
+ return PS_DASHDOT;
+ case DashStyleDashDotDot:
+ return PS_DASHDOTDOT;
+ case DashStyleCustom:
+ FIXME("DashStyleCustom not implemented\n");
+ return PS_SOLID;
+ default:
+ ERR("Not a member of GpDashStyle enumeration\n");
+ return 0;
+ }
+}
+
static DWORD gdip_to_gdi_join(GpLineJoin join)
{
switch(join){
@@ -91,6 +113,28 @@ GpStatus WINGDIPAPI GdipDeletePen(GpPen
return Ok;
}
+GpStatus WINGDIPAPI GdipSetPenDashStyle(GpPen *pen, GpDashStyle dash)
+{
+ LOGBRUSH lb;
+
+ if(!pen)
+ return InvalidParameter;
+
+ DeleteObject(pen->gdipen);
+ pen->dash = dash;
+ pen->style &= ~(PS_ALTERNATE | PS_SOLID | PS_DASH | PS_DOT | PS_DASHDOT |
+ PS_DASHDOTDOT | PS_NULL | PS_USERSTYLE | PS_INSIDEFRAME);
+ pen->style |= gdip_to_gdi_dash(dash);
+
+ lb.lbStyle = BS_SOLID;
+ lb.lbColor = pen->color;
+ lb.lbHatch = 0;
+
+ pen->gdipen = ExtCreatePen(pen->style, (INT) pen->width, &lb, 0, NULL);
+
+ return Ok;
+}
+
GpStatus WINGDIPAPI GdipSetPenEndCap(GpPen *pen, GpLineCap cap)
{
if(!pen) return InvalidParameter;
diff --git a/include/gdiplusenums.h b/include/gdiplusenums.h
index 7bf5eb6..4f5b193 100644
--- a/include/gdiplusenums.h
+++ b/include/gdiplusenums.h
@@ -141,6 +141,16 @@ enum DashCap
DashCapTriangle = 3
};
+enum DashStyle
+{
+ DashStyleSolid,
+ DashStyleDash,
+ DashStyleDot,
+ DashStyleDashDot,
+ DashStyleDashDotDot,
+ DashStyleCustom
+};
+
#ifndef __cplusplus
typedef enum Unit Unit;
@@ -155,6 +165,7 @@ typedef enum CompositingQuality Composit
typedef enum InterpolationMode InterpolationMode;
typedef enum PixelOffsetMode PixelOffsetMode;
typedef enum DashCap DashCap;
+typedef enum DashStyle DashStyle;
#endif /* end of c typedefs */
diff --git a/include/gdiplusflat.h b/include/gdiplusflat.h
index fa56952..35a6058 100644
--- a/include/gdiplusflat.h
+++ b/include/gdiplusflat.h
@@ -29,6 +29,7 @@ #endif
GpStatus WINGDIPAPI GdipCreatePen1(ARGB,REAL,GpUnit,GpPen**);
GpStatus WINGDIPAPI GdipDeletePen(GpPen*);
+GpStatus WINGDIPAPI GdipSetPenDashStyle(GpPen*,GpDashStyle);
GpStatus WINGDIPAPI GdipSetPenEndCap(GpPen*,GpLineCap);
GpStatus WINGDIPAPI GdipSetPenLineCap197819(GpPen*,GpLineCap,GpLineCap,GpDashCap);
GpStatus WINGDIPAPI GdipSetPenLineJoin(GpPen*,GpLineJoin);
diff --git a/include/gdiplusgpstubs.h b/include/gdiplusgpstubs.h
index e847e0e..7cb1888 100644
--- a/include/gdiplusgpstubs.h
+++ b/include/gdiplusgpstubs.h
@@ -51,5 +51,6 @@ typedef LineCap GpLineCap;
typedef RectF GpRectF;
typedef LineJoin GpLineJoin;
typedef DashCap GpDashCap;
+typedef DashStyle GpDashStyle;
#endif
--
1.4.1
More information about the wine-patches
mailing list