+static LONG HatchStyleToHatch(HatchStyle hatchstyle)
+{
+ switch (hatchstyle)
+ {
+ case HatchStyleHorizontal: return HS_HORIZONTAL;
+ case HatchStyleVertical: return HS_VERTICAL;
+ case HatchStyleForwardDiagonal: return HS_FDIAGONAL;
+ case HatchStyleBackwardDiagonal: return HS_BDIAGONAL;
+ case HatchStyleCross: return HS_CROSS;
+ case HatchStyleDiagonalCross: return HS_DIAGCROSS;
+ default: return 0;
+ }
+}
+
+/******************************************************************************
+ * GdipCreateHatchBrush [GDIPLUS.@]
+ */
+GpStatus WINGDIPAPI GdipCreateHatchBrush(HatchStyle hatchstyle, ARGB forecol, ARGB backcol, GpHatch **brush)
+{
+ COLORREF fgcol = ARGB2COLORREF(forecol);
+
+ TRACE("(%d, %d, %d, %p)\n", hatchstyle, forecol, backcol, brush);
+
+ if(!brush) return InvalidParameter;
+
+ *brush = GdipAlloc(sizeof(GpHatch));
+ if (!*brush) return OutOfMemory;
+
+ switch (hatchstyle)
+ {
+ case HatchStyleHorizontal:
+ case HatchStyleVertical:
+ case HatchStyleForwardDiagonal:
+ case HatchStyleBackwardDiagonal:
+ case HatchStyleCross:
+ case HatchStyleDiagonalCross:
+ /* Brushes that map to BS_HATCHED */
+ (*brush)->brush.lb.lbStyle = BS_HATCHED;
+ (*brush)->brush.lb.lbColor = fgcol;
+ (*brush)->brush.lb.lbHatch = HatchStyleToHatch(hatchstyle);
+ break;
+
+ default:
+ FIXME("Unimplemented hatch style %d\n", hatchstyle);
+
+ (*brush)->brush.lb.lbStyle = BS_SOLID;
+ (*brush)->brush.lb.lbColor = fgcol;
+ (*brush)->brush.lb.lbHatch = 0;
+ break;
+ }
+
+
+ (*brush)->brush.gdibrush = CreateBrushIndirect(&(*brush)->brush.lb);
+ (*brush)->brush.bt = BrushTypeHatchFill;
+ (*brush)->forecol = forecol;
+ (*brush)->backcol = backcol;
+ (*brush)->hatchstyle = hatchstyle;
+
+ return Ok;
+}
+