gdiplus: Associate a brush with a pen.
This commit is contained in:
parent
85b5df42a7
commit
7af2e97a4a
|
@ -30,6 +30,10 @@ GpStatus WINGDIPAPI GdipCreateSolidFill(ARGB color, GpSolidFill **sf)
|
||||||
*sf = GdipAlloc(sizeof(GpSolidFill));
|
*sf = GdipAlloc(sizeof(GpSolidFill));
|
||||||
if (!*sf) return OutOfMemory;
|
if (!*sf) return OutOfMemory;
|
||||||
|
|
||||||
|
(*sf)->brush.lb.lbStyle = BS_SOLID;
|
||||||
|
(*sf)->brush.lb.lbColor = col;
|
||||||
|
(*sf)->brush.lb.lbHatch = 0;
|
||||||
|
|
||||||
(*sf)->brush.gdibrush = CreateSolidBrush(col);
|
(*sf)->brush.gdibrush = CreateSolidBrush(col);
|
||||||
(*sf)->brush.bt = BrushTypeSolidColor;
|
(*sf)->brush.bt = BrushTypeSolidColor;
|
||||||
(*sf)->brush.color = col;
|
(*sf)->brush.color = col;
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include "windef.h"
|
#include "windef.h"
|
||||||
|
#include "wingdi.h"
|
||||||
#include "gdiplus.h"
|
#include "gdiplus.h"
|
||||||
|
|
||||||
#define GP_DEFAULT_PENSTYLE (PS_GEOMETRIC | PS_SOLID | PS_ENDCAP_FLAT | PS_JOIN_MITER)
|
#define GP_DEFAULT_PENSTYLE (PS_GEOMETRIC | PS_SOLID | PS_ENDCAP_FLAT | PS_JOIN_MITER)
|
||||||
|
@ -54,6 +55,7 @@ struct GpPen{
|
||||||
GpLineJoin join;
|
GpLineJoin join;
|
||||||
REAL miterlimit;
|
REAL miterlimit;
|
||||||
GpDashStyle dash;
|
GpDashStyle dash;
|
||||||
|
GpBrush *brush;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct GpGraphics{
|
struct GpGraphics{
|
||||||
|
@ -69,6 +71,7 @@ struct GpBrush{
|
||||||
HBRUSH gdibrush;
|
HBRUSH gdibrush;
|
||||||
GpBrushType bt;
|
GpBrushType bt;
|
||||||
COLORREF color;
|
COLORREF color;
|
||||||
|
LOGBRUSH lb;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct GpSolidFill{
|
struct GpSolidFill{
|
||||||
|
|
|
@ -90,7 +90,6 @@ GpStatus WINGDIPAPI GdipClonePen(GpPen *pen, GpPen **clonepen)
|
||||||
GpStatus WINGDIPAPI GdipCreatePen1(ARGB color, FLOAT width, GpUnit unit,
|
GpStatus WINGDIPAPI GdipCreatePen1(ARGB color, FLOAT width, GpUnit unit,
|
||||||
GpPen **pen)
|
GpPen **pen)
|
||||||
{
|
{
|
||||||
LOGBRUSH lb;
|
|
||||||
GpPen *gp_pen;
|
GpPen *gp_pen;
|
||||||
|
|
||||||
if(!pen)
|
if(!pen)
|
||||||
|
@ -107,14 +106,11 @@ GpStatus WINGDIPAPI GdipCreatePen1(ARGB color, FLOAT width, GpUnit unit,
|
||||||
gp_pen->join = LineJoinMiter;
|
gp_pen->join = LineJoinMiter;
|
||||||
gp_pen->miterlimit = 10.0;
|
gp_pen->miterlimit = 10.0;
|
||||||
gp_pen->dash = DashStyleSolid;
|
gp_pen->dash = DashStyleSolid;
|
||||||
|
GdipCreateSolidFill(color, (GpSolidFill **)(&gp_pen->brush));
|
||||||
lb.lbStyle = BS_SOLID;
|
|
||||||
lb.lbColor = gp_pen->color;
|
|
||||||
lb.lbHatch = 0;
|
|
||||||
|
|
||||||
if((gp_pen->unit == UnitWorld) || (gp_pen->unit == UnitPixel)) {
|
if((gp_pen->unit == UnitWorld) || (gp_pen->unit == UnitPixel)) {
|
||||||
gp_pen->gdipen = ExtCreatePen(gp_pen->style, (INT) gp_pen->width, &lb,
|
gp_pen->gdipen = ExtCreatePen(gp_pen->style, (INT) gp_pen->width,
|
||||||
0, NULL);
|
&gp_pen->brush->lb, 0, NULL);
|
||||||
} else {
|
} else {
|
||||||
FIXME("UnitWorld, UnitPixel only supported units\n");
|
FIXME("UnitWorld, UnitPixel only supported units\n");
|
||||||
GdipFree(gp_pen);
|
GdipFree(gp_pen);
|
||||||
|
@ -131,6 +127,7 @@ GpStatus WINGDIPAPI GdipDeletePen(GpPen *pen)
|
||||||
if(!pen) return InvalidParameter;
|
if(!pen) return InvalidParameter;
|
||||||
DeleteObject(pen->gdipen);
|
DeleteObject(pen->gdipen);
|
||||||
|
|
||||||
|
GdipDeleteBrush(pen->brush);
|
||||||
GdipDeleteCustomLineCap(pen->customstart);
|
GdipDeleteCustomLineCap(pen->customstart);
|
||||||
GdipDeleteCustomLineCap(pen->customend);
|
GdipDeleteCustomLineCap(pen->customend);
|
||||||
GdipFree(pen);
|
GdipFree(pen);
|
||||||
|
@ -182,8 +179,6 @@ GpStatus WINGDIPAPI GdipSetPenCustomStartCap(GpPen *pen, GpCustomLineCap* custom
|
||||||
|
|
||||||
GpStatus WINGDIPAPI GdipSetPenDashStyle(GpPen *pen, GpDashStyle dash)
|
GpStatus WINGDIPAPI GdipSetPenDashStyle(GpPen *pen, GpDashStyle dash)
|
||||||
{
|
{
|
||||||
LOGBRUSH lb;
|
|
||||||
|
|
||||||
if(!pen)
|
if(!pen)
|
||||||
return InvalidParameter;
|
return InvalidParameter;
|
||||||
|
|
||||||
|
@ -193,11 +188,7 @@ GpStatus WINGDIPAPI GdipSetPenDashStyle(GpPen *pen, GpDashStyle dash)
|
||||||
PS_DASHDOTDOT | PS_NULL | PS_USERSTYLE | PS_INSIDEFRAME);
|
PS_DASHDOTDOT | PS_NULL | PS_USERSTYLE | PS_INSIDEFRAME);
|
||||||
pen->style |= gdip_to_gdi_dash(dash);
|
pen->style |= gdip_to_gdi_dash(dash);
|
||||||
|
|
||||||
lb.lbStyle = BS_SOLID;
|
pen->gdipen = ExtCreatePen(pen->style, (INT) pen->width, &pen->brush->lb, 0, NULL);
|
||||||
lb.lbColor = pen->color;
|
|
||||||
lb.lbHatch = 0;
|
|
||||||
|
|
||||||
pen->gdipen = ExtCreatePen(pen->style, (INT) pen->width, &lb, 0, NULL);
|
|
||||||
|
|
||||||
return Ok;
|
return Ok;
|
||||||
}
|
}
|
||||||
|
@ -237,8 +228,6 @@ GpStatus WINGDIPAPI GdipSetPenLineCap197819(GpPen *pen, GpLineCap start,
|
||||||
* Both kinds of miter joins clip if the angle is less than 11 degrees. */
|
* Both kinds of miter joins clip if the angle is less than 11 degrees. */
|
||||||
GpStatus WINGDIPAPI GdipSetPenLineJoin(GpPen *pen, GpLineJoin join)
|
GpStatus WINGDIPAPI GdipSetPenLineJoin(GpPen *pen, GpLineJoin join)
|
||||||
{
|
{
|
||||||
LOGBRUSH lb;
|
|
||||||
|
|
||||||
if(!pen) return InvalidParameter;
|
if(!pen) return InvalidParameter;
|
||||||
|
|
||||||
DeleteObject(pen->gdipen);
|
DeleteObject(pen->gdipen);
|
||||||
|
@ -246,11 +235,7 @@ GpStatus WINGDIPAPI GdipSetPenLineJoin(GpPen *pen, GpLineJoin join)
|
||||||
pen->style &= ~(PS_JOIN_ROUND | PS_JOIN_BEVEL | PS_JOIN_MITER);
|
pen->style &= ~(PS_JOIN_ROUND | PS_JOIN_BEVEL | PS_JOIN_MITER);
|
||||||
pen->style |= gdip_to_gdi_join(join);
|
pen->style |= gdip_to_gdi_join(join);
|
||||||
|
|
||||||
lb.lbStyle = BS_SOLID;
|
pen->gdipen = ExtCreatePen(pen->style, (INT) pen->width, &pen->brush->lb, 0, NULL);
|
||||||
lb.lbColor = pen->color;
|
|
||||||
lb.lbHatch = 0;
|
|
||||||
|
|
||||||
pen->gdipen = ExtCreatePen(pen->style, (INT) pen->width, &lb, 0, NULL);
|
|
||||||
|
|
||||||
return Ok;
|
return Ok;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue