- Sync gdiplus with Wine head
[reactos.git] / reactos / dll / win32 / gdiplus / brush.c
index a24f54e..f0c9b20 100644 (file)
@@ -51,6 +51,14 @@ GpStatus WINGDIPAPI GdipCloneBrush(GpBrush *brush, GpBrush **clone)
 
             memcpy(*clone, brush, sizeof(GpSolidFill));
 
 
             memcpy(*clone, brush, sizeof(GpSolidFill));
 
+            (*clone)->gdibrush = CreateBrushIndirect(&(*clone)->lb);
+            break;
+        case BrushTypeHatchFill:
+            *clone = GdipAlloc(sizeof(GpHatch));
+            if (!*clone) return OutOfMemory;
+
+            memcpy(*clone, brush, sizeof(GpHatch));
+
             (*clone)->gdibrush = CreateBrushIndirect(&(*clone)->lb);
             break;
         case BrushTypePathGradient:{
             (*clone)->gdibrush = CreateBrushIndirect(&(*clone)->lb);
             break;
         case BrushTypePathGradient:{
@@ -124,6 +132,67 @@ GpStatus WINGDIPAPI GdipCloneBrush(GpBrush *brush, GpBrush **clone)
     return Ok;
 }
 
     return Ok;
 }
 
+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;
+}
+
 /******************************************************************************
  * GdipCreateLineBrush [GDIPLUS.@]
  */
 /******************************************************************************
  * GdipCreateLineBrush [GDIPLUS.@]
  */
@@ -648,6 +717,39 @@ GpStatus WINGDIPAPI GdipGetBrushType(GpBrush *brush, GpBrushType *type)
     return Ok;
 }
 
     return Ok;
 }
 
+GpStatus WINGDIPAPI GdipGetHatchBackgroundColor(GpHatch *brush, ARGB *backcol)
+{
+    TRACE("(%p, %p)\n", brush, backcol);
+
+    if(!brush || !backcol)  return InvalidParameter;
+
+    *backcol = brush->backcol;
+
+    return Ok;
+}
+
+GpStatus WINGDIPAPI GdipGetHatchForegroundColor(GpHatch *brush, ARGB *forecol)
+{
+    TRACE("(%p, %p)\n", brush, forecol);
+
+    if(!brush || !forecol)  return InvalidParameter;
+
+    *forecol = brush->forecol;
+
+    return Ok;
+}
+
+GpStatus WINGDIPAPI GdipGetHatchStyle(GpHatch *brush, HatchStyle *hatchstyle)
+{
+    TRACE("(%p, %p)\n", brush, hatchstyle);
+
+    if(!brush || !hatchstyle)  return InvalidParameter;
+
+    *hatchstyle = brush->hatchstyle;
+
+    return Ok;
+}
+
 GpStatus WINGDIPAPI GdipDeleteBrush(GpBrush *brush)
 {
     TRACE("(%p)\n", brush);
 GpStatus WINGDIPAPI GdipDeleteBrush(GpBrush *brush)
 {
     TRACE("(%p)\n", brush);
@@ -1331,3 +1433,17 @@ GpStatus WINGDIPAPI GdipGetLineRectI(GpLineGradient *brush, GpRect *rect)
 
     return ret;
 }
 
     return ret;
 }
+
+GpStatus WINGDIPAPI GdipRotateLineTransform(GpLineGradient* brush,
+    REAL angle, GpMatrixOrder order)
+{
+    static int calls;
+
+    if(!brush)
+        return InvalidParameter;
+
+    if(!(calls++))
+        FIXME("(%p, %.2f, %d) stub\n", brush, angle, order);
+
+    return NotImplemented;
+}