1/**************************************************************************\
2*
3* Copyright (c) 1998-2000, Microsoft Corp.  All Rights Reserved.
4*
5* Module Name:
6*
7*   GdiplusBrush.h
8*
9* Abstract:
10*
11*   Brush API related declarations
12*
13\**************************************************************************/
14
15#ifndef _GDIPLUSBRUSH_H
16#define _GDIPLUSBRUSH_H
17
18//--------------------------------------------------------------------------
19// Abstract base class for various brush types
20//--------------------------------------------------------------------------
21
22class GraphicsPath;
23
24class Brush : public GdiplusBase
25{
26public:
27    friend class Pen;
28    friend class Graphics;
29
30    virtual ~Brush()
31    {
32        DllExports::GdipDeleteBrush(nativeBrush);
33    }
34
35    virtual Brush* Clone() const
36    {
37        GpBrush *brush = NULL;
38
39        SetStatus(DllExports::GdipCloneBrush(nativeBrush, &brush));
40
41        Brush *newBrush = new Brush(brush, lastResult);
42
43        if (newBrush == NULL)
44        {
45            DllExports::GdipDeleteBrush(brush);
46        }
47
48        return newBrush;
49    }
50
51    BrushType GetType() const
52    {
53        BrushType type = static_cast<BrushType>(-1);
54
55        SetStatus(DllExports::GdipGetBrushType(nativeBrush, &type));
56
57        return type;
58    }
59
60    Status GetLastStatus() const
61    {
62        Status lastStatus = lastResult;
63        lastResult = Ok;
64
65        return lastStatus;
66    }
67
68protected:
69
70    Brush()
71    {
72        SetStatus(NotImplemented);
73    }
74
75#ifdef DCR_USE_NEW_250932
76
77private:
78    Brush(const Brush& brush);
79    Brush& operator=(const Brush& brush);
80protected:
81
82#else
83
84    Brush(const Brush& brush)
85    {
86        brush;
87        SetStatus(NotImplemented);
88    }
89
90    Brush& operator=(const Brush& brush)
91    {
92        brush;
93        SetStatus(NotImplemented);
94        return *this;
95    }
96
97#endif
98
99    Brush(GpBrush* nativeBrush, Status status)
100    {
101        lastResult = status;
102        SetNativeBrush(nativeBrush);
103    }
104
105    VOID SetNativeBrush(GpBrush* nativeBrush)
106    {
107        this->nativeBrush = nativeBrush;
108    }
109
110    Status SetStatus(Status status) const
111    {
112        if (status != Ok)
113            return (lastResult = status);
114        else
115            return status;
116    }
117
118    GpBrush* nativeBrush;
119    mutable Status lastResult;
120};
121
122//--------------------------------------------------------------------------
123// Represent solid fill brush object
124//--------------------------------------------------------------------------
125
126class SolidBrush : public Brush
127{
128public:
129    friend class Pen;
130
131    SolidBrush(IN const Color& color)
132    {
133        GpSolidFill *brush = NULL;
134
135        lastResult = DllExports::GdipCreateSolidFill(color.GetValue(), &brush);
136
137        SetNativeBrush(brush);
138    }
139
140    Status GetColor(OUT Color* color) const
141    {
142        ARGB argb;
143
144        if (color == NULL)
145        {
146            return SetStatus(InvalidParameter);
147        }
148
149        SetStatus(DllExports::GdipGetSolidFillColor((GpSolidFill*)nativeBrush,
150                                                    &argb));
151
152        *color = Color(argb);
153
154        return lastResult;
155    }
156
157    Status SetColor(IN const Color& color)
158    {
159        return SetStatus(DllExports::GdipSetSolidFillColor((GpSolidFill*)nativeBrush,
160                                                           color.GetValue()));
161    }
162
163#ifdef DCR_USE_NEW_250932
164
165private:
166    SolidBrush(const SolidBrush &);
167    SolidBrush& operator=(const SolidBrush &);
168
169#endif
170
171protected:
172
173    SolidBrush()
174    {
175    }
176};
177
178class TextureBrush : public Brush
179{
180public:
181    friend class Pen;
182
183    TextureBrush(IN Image* image,
184                 IN WrapMode wrapMode = WrapModeTile)
185    {
186        GpTexture *texture = NULL;
187
188        lastResult = DllExports::GdipCreateTexture(
189                                                  image->nativeImage,
190                                                  wrapMode, &texture);
191
192        SetNativeBrush(texture);
193    }
194
195    // When creating a texture brush from a metafile image, the dstRect
196    // is used to specify the size that the metafile image should be
197    // rendered at in the device units of the destination graphics.
198    // It is NOT used to crop the metafile image, so only the width
199    // and height values matter for metafiles.
200    TextureBrush(IN Image* image,
201                 IN WrapMode wrapMode,
202                 IN const RectF &dstRect)
203    {
204        GpTexture *texture = NULL;
205
206        lastResult = DllExports::GdipCreateTexture2(
207                                                   image->nativeImage,
208                                                   wrapMode,
209                                                   dstRect.X,
210                                                   dstRect.Y,
211                                                   dstRect.Width,
212                                                   dstRect.Height,
213                                                   &texture);
214
215        SetNativeBrush(texture);
216    }
217
218    // When creating a texture brush from a metafile image, the dstRect
219    // is used to specify the size that the metafile image should be
220    // rendered at in the device units of the destination graphics.
221    // It is NOT used to crop the metafile image, so only the width
222    // and height values matter for metafiles.
223
224    TextureBrush(IN Image *image,
225                 IN const RectF &dstRect,
226                 IN const ImageAttributes *imageAttributes = NULL)
227    {
228        GpTexture *texture = NULL;
229
230        lastResult = DllExports::GdipCreateTextureIA(
231            image->nativeImage,
232            (imageAttributes)?imageAttributes->nativeImageAttr:NULL,
233            dstRect.X,
234            dstRect.Y,
235            dstRect.Width,
236            dstRect.Height,
237            &texture
238        );
239
240        SetNativeBrush(texture);
241    }
242
243    #ifdef DCR_USE_NEW_145138
244    TextureBrush(IN Image *image,
245                 IN const Rect &dstRect,
246                 IN const ImageAttributes *imageAttributes = NULL)
247    {
248        GpTexture *texture = NULL;
249
250        lastResult = DllExports::GdipCreateTextureIAI(
251            image->nativeImage,
252            (imageAttributes)?imageAttributes->nativeImageAttr:NULL,
253            dstRect.X,
254            dstRect.Y,
255            dstRect.Width,
256            dstRect.Height,
257            &texture
258        );
259
260        SetNativeBrush(texture);
261    }
262    #endif
263
264    // When creating a texture brush from a metafile image, the dstRect
265    // is used to specify the size that the metafile image should be
266    // rendered at in the device units of the destination graphics.
267    // It is NOT used to crop the metafile image, so only the width
268    // and height values matter for metafiles.
269
270    TextureBrush(
271        IN Image* image,
272        IN WrapMode wrapMode,
273
274        #ifdef DCR_USE_NEW_145138
275        const IN Rect &dstRect
276        #else
277        IN Rect &dstRect
278        #endif
279    )
280    {
281        GpTexture *texture = NULL;
282
283        lastResult = DllExports::GdipCreateTexture2I(
284                                                    image->nativeImage,
285                                                    wrapMode,
286                                                    dstRect.X,
287                                                    dstRect.Y,
288                                                    dstRect.Width,
289                                                    dstRect.Height,
290                                                    &texture);
291
292        SetNativeBrush(texture);
293    }
294
295    // When creating a texture brush from a metafile image, the dstRect
296    // is used to specify the size that the metafile image should be
297    // rendered at in the device units of the destination graphics.
298    // It is NOT used to crop the metafile image, so only the width
299    // and height values matter for metafiles.
300    TextureBrush(IN Image* image,
301                 IN WrapMode wrapMode,
302                 IN REAL dstX,
303                 IN REAL dstY,
304                 IN REAL dstWidth,
305                 IN REAL dstHeight)
306    {
307        GpTexture *texture = NULL;
308
309        lastResult = DllExports::GdipCreateTexture2(
310                                                   image->nativeImage,
311                                                   wrapMode,
312                                                   dstX,
313                                                   dstY,
314                                                   dstWidth,
315                                                   dstHeight,
316                                                   &texture);
317
318        SetNativeBrush(texture);
319    }
320
321    // When creating a texture brush from a metafile image, the dstRect
322    // is used to specify the size that the metafile image should be
323    // rendered at in the device units of the destination graphics.
324    // It is NOT used to crop the metafile image, so only the width
325    // and height values matter for metafiles.
326    TextureBrush(IN Image* image,
327                 IN WrapMode wrapMode,
328                 IN INT dstX,
329                 IN INT dstY,
330                 IN INT dstWidth,
331                 IN INT dstHeight)
332    {
333        GpTexture *texture = NULL;
334
335        lastResult = DllExports::GdipCreateTexture2I(
336                                                    image->nativeImage,
337                                                    wrapMode,
338                                                    dstX,
339                                                    dstY,
340                                                    dstWidth,
341                                                    dstHeight,
342                                                    &texture);
343
344        SetNativeBrush(texture);
345    }
346
347    /**
348     * Set/get brush transform
349     */
350    Status SetTransform(IN const Matrix* matrix)
351    {
352        return SetStatus(DllExports::GdipSetTextureTransform((GpTexture*)nativeBrush,
353                                                             matrix->nativeMatrix));
354    }
355
356    Status GetTransform(OUT Matrix* matrix) const
357    {
358        return SetStatus(DllExports::GdipGetTextureTransform((GpTexture*)nativeBrush,
359                                                             matrix->nativeMatrix));
360    }
361
362    Status ResetTransform()
363    {
364        return SetStatus(DllExports::GdipResetTextureTransform((GpTexture*)nativeBrush));
365    }
366
367    Status MultiplyTransform(IN const Matrix* matrix,
368                             IN MatrixOrder order = MatrixOrderPrepend)
369    {
370        return SetStatus(DllExports::GdipMultiplyTextureTransform((GpTexture*)nativeBrush,
371                                                                matrix->nativeMatrix,
372                                                                order));
373    }
374
375    Status TranslateTransform(IN REAL dx,
376                              IN REAL dy,
377                              IN MatrixOrder order = MatrixOrderPrepend)
378    {
379        return SetStatus(DllExports::GdipTranslateTextureTransform((GpTexture*)nativeBrush,
380                                                               dx, dy, order));
381    }
382
383    Status ScaleTransform(IN REAL sx,
384                          IN REAL sy,
385                          IN MatrixOrder order = MatrixOrderPrepend)
386    {
387        return SetStatus(DllExports::GdipScaleTextureTransform((GpTexture*)nativeBrush,
388                                                             sx, sy, order));
389    }
390
391    Status RotateTransform(IN REAL angle,
392                           IN MatrixOrder order = MatrixOrderPrepend)
393    {
394        return SetStatus(DllExports::GdipRotateTextureTransform((GpTexture*)nativeBrush,
395                                                              angle, order));
396    }
397
398    /**
399     * Set/get brush wrapping mode
400     */
401    Status SetWrapMode(IN WrapMode wrapMode)
402    {
403        return SetStatus(DllExports::GdipSetTextureWrapMode((GpTexture*)nativeBrush,
404                                                            wrapMode));
405    }
406
407    WrapMode GetWrapMode() const
408    {
409        WrapMode wrapMode;
410
411        SetStatus(DllExports::GdipGetTextureWrapMode((GpTexture*)nativeBrush,
412                                                     &wrapMode));
413        return wrapMode;
414    }
415
416    // Get texture brush attributes
417
418    Image *GetImage() const
419    {
420        GpImage *image;
421
422        SetStatus(DllExports::GdipGetTextureImage((GpTexture *)nativeBrush,
423                                                  &image));
424
425        Image *retimage = new Image(image, lastResult);
426
427        if (retimage == NULL)
428        {
429            DllExports::GdipDisposeImage(image);
430        }
431
432        return retimage;
433    }
434
435#ifdef DCR_USE_NEW_250932
436
437private:
438    TextureBrush(const TextureBrush &);
439    TextureBrush& operator=(const TextureBrush &);
440
441#endif
442
443protected:
444
445    TextureBrush()
446    {
447    }
448};
449
450//--------------------------------------------------------------------------
451// Represent line gradient brush object
452//--------------------------------------------------------------------------
453
454class LinearGradientBrush : public Brush
455{
456public:
457    friend class Pen;
458
459    LinearGradientBrush(IN const PointF& point1,
460                        IN const PointF& point2,
461                        IN const Color& color1,
462                        IN const Color& color2)
463    {
464        GpLineGradient *brush = NULL;
465
466        lastResult = DllExports::GdipCreateLineBrush(&point1,
467                                                     &point2,
468                                                     color1.GetValue(),
469                                                     color2.GetValue(),
470                                                     WrapModeTile,
471                                                     &brush);
472
473        SetNativeBrush(brush);
474    }
475
476    LinearGradientBrush(IN const Point& point1,
477                        IN const Point& point2,
478                        IN const Color& color1,
479                        IN const Color& color2)
480    {
481        GpLineGradient *brush = NULL;
482
483        lastResult = DllExports::GdipCreateLineBrushI(&point1,
484                                                      &point2,
485                                                      color1.GetValue(),
486                                                      color2.GetValue(),
487                                                      WrapModeTile,
488                                                      &brush);
489
490        SetNativeBrush(brush);
491    }
492
493    LinearGradientBrush(IN const RectF& rect,
494                        IN const Color& color1,
495                        IN const Color& color2,
496                        IN LinearGradientMode mode)
497    {
498        GpLineGradient *brush = NULL;
499
500        lastResult = DllExports::GdipCreateLineBrushFromRect(&rect,
501                                                             color1.GetValue(),
502                                                             color2.GetValue(),
503                                                             mode,
504                                                             WrapModeTile,
505                                                             &brush);
506
507        SetNativeBrush(brush);
508    }
509
510    LinearGradientBrush(IN const Rect& rect,
511                        IN const Color& color1,
512                        IN const Color& color2,
513                        IN LinearGradientMode mode)
514    {
515        GpLineGradient *brush = NULL;
516
517        lastResult = DllExports::GdipCreateLineBrushFromRectI(&rect,
518                                                              color1.GetValue(),
519                                                              color2.GetValue(),
520                                                              mode,
521                                                              WrapModeTile,
522                                                              &brush);
523
524        SetNativeBrush(brush);
525    }
526
527    LinearGradientBrush(IN const RectF& rect,
528                        IN const Color& color1,
529                        IN const Color& color2,
530                        IN REAL angle,
531                        IN BOOL isAngleScalable = FALSE)
532    {
533        GpLineGradient *brush = NULL;
534
535        lastResult = DllExports::GdipCreateLineBrushFromRectWithAngle(&rect,
536                                                                      color1.GetValue(),
537                                                                      color2.GetValue(),
538                                                                      angle,
539                                                                      isAngleScalable,
540                                                                      WrapModeTile,
541                                                                      &brush);
542
543        SetNativeBrush(brush);
544    }
545
546    LinearGradientBrush(IN const Rect& rect,
547                        IN const Color& color1,
548                        IN const Color& color2,
549                        IN REAL angle,
550                        IN BOOL isAngleScalable = FALSE)
551    {
552        GpLineGradient *brush = NULL;
553
554        lastResult = DllExports::GdipCreateLineBrushFromRectWithAngleI(&rect,
555                                                                       color1.GetValue(),
556                                                                       color2.GetValue(),
557                                                                       angle,
558                                                                       isAngleScalable,
559                                                                       WrapModeTile,
560                                                                       &brush);
561
562        SetNativeBrush(brush);
563    }
564
565    // Get/set point attributes
566
567    Status SetLinearPoints(IN const PointF& point1,
568                           IN const PointF& point2)
569    {
570        return SetStatus(DllExports::GdipSetLinePoints((GpLineGradient*)nativeBrush,
571                                                       &point1, &point2));
572    }
573
574    Status GetLinearPoints(OUT PointF* points) const
575    {
576        return SetStatus(DllExports::GdipGetLinePoints((GpLineGradient*) nativeBrush,
577                                                       points));
578    }
579
580    Status SetLinearPoints(IN const Point& point1,
581                           IN const Point& point2)
582    {
583        return SetStatus(DllExports::GdipSetLinePointsI((GpLineGradient*)nativeBrush,
584                                                        &point1, &point2));
585    }
586
587    Status GetLinearPoints(OUT Point* points) const
588    {
589        return SetStatus(DllExports::GdipGetLinePointsI((GpLineGradient*) nativeBrush,
590                                                        points));
591    }
592    // Get/set color attributes
593
594    Status SetLinearColors(IN const Color& color1,
595                           IN const Color& color2)
596    {
597        return SetStatus(DllExports::GdipSetLineColors((GpLineGradient*)nativeBrush,
598                                                       color1.GetValue(),
599                                                       color2.GetValue()));
600    }
601
602    Status GetLinearColors(OUT Color* colors) const
603    {
604        ARGB argb[2];
605
606        if (colors == NULL)
607        {
608            return SetStatus(InvalidParameter);
609        }
610
611        SetStatus(DllExports::GdipGetLineColors((GpLineGradient*) nativeBrush, argb));
612
613        if (lastResult == Ok)
614        {
615            // use bitwise copy operator for Color copy
616            colors[0] = Color(argb[0]);
617            colors[1] = Color(argb[1]);
618        }
619
620        return lastResult;
621    }
622
623    Status GetRectangle(OUT RectF* rect) const
624    {
625        return SetStatus(DllExports::GdipGetLineRect((GpLineGradient*)nativeBrush, rect));
626    }
627
628    // integer version
629    Status GetRectangle(OUT Rect* rect) const
630    {
631        return SetStatus(DllExports::GdipGetLineRectI((GpLineGradient*)nativeBrush, rect));
632    }
633
634    // Gamma correction in interporlation.
635
636    Status SetGammaCorrection(IN BOOL useGammaCorrection)
637    {
638        return SetStatus(DllExports::GdipSetLineGammaCorrection((GpLineGradient*)nativeBrush,
639                    useGammaCorrection));
640    }
641
642    BOOL GetGammaCorrection() const
643    {
644        BOOL useGammaCorrection;
645
646        SetStatus(DllExports::GdipGetLineGammaCorrection((GpLineGradient*)nativeBrush,
647                    &useGammaCorrection));
648
649        return useGammaCorrection;
650    }
651
652    INT GetBlendCount() const
653    {
654        INT count = 0;
655
656        SetStatus(DllExports::GdipGetLineBlendCount((GpLineGradient*)
657                                                    nativeBrush,
658                                                    &count));
659
660        return count;
661    }
662
663    Status SetBlend(IN const REAL* blendFactors,
664                    IN const REAL* blendPositions,
665                    IN INT count)
666    {
667        return SetStatus(DllExports::GdipSetLineBlend((GpLineGradient*)
668                                                      nativeBrush,
669                                                      blendFactors,
670                                                      blendPositions,
671                                                      count));
672    }
673
674    Status GetBlend(OUT REAL* blendFactors,
675                    OUT REAL* blendPositions,
676                    IN INT count) const
677    {
678        return SetStatus(DllExports::GdipGetLineBlend((GpLineGradient*)nativeBrush,
679                                                      blendFactors,
680                                                      blendPositions,
681                                                      count));
682    }
683
684    INT GetInterpolationColorCount() const
685    {
686        INT count = 0;
687
688        SetStatus(DllExports::GdipGetLinePresetBlendCount((GpLineGradient*)
689                                                          nativeBrush,
690                                                          &count));
691
692        return count;
693    }
694
695    Status SetInterpolationColors(IN const Color* presetColors,
696                                  IN const REAL* blendPositions,
697                                  IN INT count)
698    {
699        if ((count <= 0) || !presetColors)
700            return SetStatus(InvalidParameter);
701
702        ARGB *argbs = (ARGB*) new BYTE[count*sizeof(ARGB)];
703
704        if (argbs)
705        {
706            for (INT i = 0; i < count; i++)
707            {
708                argbs[i] = presetColors[i].GetValue();
709            }
710
711            Status status = SetStatus(DllExports::GdipSetLinePresetBlend(
712                                                                        (GpLineGradient*) nativeBrush,
713                                                                        argbs,
714                                                                        blendPositions,
715                                                                        count));
716            delete [] argbs;
717            return status;
718        }
719        else
720        {
721            return SetStatus(OutOfMemory);
722        }
723    }
724
725    Status GetInterpolationColors(OUT Color* presetColors,
726                                  OUT REAL* blendPositions,
727                                  IN INT count) const
728    {
729        if ((count <= 0) || !presetColors)
730            return SetStatus(InvalidParameter);
731
732        ARGB* argbs = (ARGB*) new BYTE[count*sizeof(ARGB)];
733
734        if (!argbs)
735        {
736            return SetStatus(OutOfMemory);
737        }
738
739        Status status = SetStatus(DllExports::GdipGetLinePresetBlend((GpLineGradient*)nativeBrush,
740                                                                     argbs,
741                                                                     blendPositions,
742                                                                     count));
743        if (status == Ok)
744        {
745            for (INT i = 0; i < count; i++)
746            {
747                presetColors[i] = Color(argbs[i]);
748            }
749        }
750
751        delete [] argbs;
752
753        return status;
754    }
755
756    Status SetBlendBellShape(IN REAL focus,
757                             IN REAL scale = 1.0)
758    {
759        return SetStatus(DllExports::GdipSetLineSigmaBlend((GpLineGradient*)nativeBrush, focus, scale));
760    }
761
762    #ifdef DCR_USE_NEW_145135
763    Status SetBlendTriangularShape(
764        IN REAL focus,
765        IN REAL scale = 1.0
766    )
767    #else
768    Status SetBlendTrianglarShape(IN REAL focus,
769                                  IN REAL scale = 1.0)
770    #endif
771    {
772        return SetStatus(DllExports::GdipSetLineLinearBlend((GpLineGradient*)nativeBrush, focus, scale));
773    }
774
775    /**
776     * Set/get brush transform
777     */
778    Status SetTransform(IN const Matrix* matrix)
779    {
780        return SetStatus(DllExports::GdipSetLineTransform((GpLineGradient*)nativeBrush,
781                                                          matrix->nativeMatrix));
782    }
783
784    Status GetTransform(OUT Matrix *matrix) const
785    {
786        return SetStatus(DllExports::GdipGetLineTransform((GpLineGradient*)nativeBrush,
787                                                          matrix->nativeMatrix));
788    }
789
790    Status ResetTransform()
791    {
792        return SetStatus(DllExports::GdipResetLineTransform((GpLineGradient*)nativeBrush));
793    }
794
795    Status MultiplyTransform(IN const Matrix* matrix,
796                             IN MatrixOrder order = MatrixOrderPrepend)
797    {
798        return SetStatus(DllExports::GdipMultiplyLineTransform((GpLineGradient*)nativeBrush,
799                                                                matrix->nativeMatrix,
800                                                                order));
801    }
802
803    Status TranslateTransform(IN REAL dx,
804                              IN REAL dy,
805                              IN MatrixOrder order = MatrixOrderPrepend)
806    {
807        return SetStatus(DllExports::GdipTranslateLineTransform((GpLineGradient*)nativeBrush,
808                                                               dx, dy, order));
809    }
810
811    Status ScaleTransform(IN REAL sx,
812                          IN REAL sy,
813                          IN MatrixOrder order = MatrixOrderPrepend)
814    {
815        return SetStatus(DllExports::GdipScaleLineTransform((GpLineGradient*)nativeBrush,
816                                                             sx, sy, order));
817    }
818
819    Status RotateTransform(IN REAL angle,
820                           IN MatrixOrder order = MatrixOrderPrepend)
821    {
822        return SetStatus(DllExports::GdipRotateLineTransform((GpLineGradient*)nativeBrush,
823                                                              angle, order));
824    }
825
826    /**
827     * Set/get brush wrapping mode
828     */
829    Status SetWrapMode(IN WrapMode wrapMode)
830    {
831        return SetStatus(DllExports::GdipSetLineWrapMode((GpLineGradient*)nativeBrush,
832                                                         wrapMode));
833    }
834
835    WrapMode GetWrapMode() const
836    {
837        WrapMode wrapMode;
838
839        SetStatus(DllExports::GdipGetLineWrapMode((GpLineGradient*)
840                                                  nativeBrush,
841                                                  &wrapMode));
842
843        return wrapMode;
844    }
845
846#ifdef DCR_USE_NEW_250932
847
848private:
849    LinearGradientBrush(const LinearGradientBrush &);
850    LinearGradientBrush& operator=(const LinearGradientBrush &);
851
852#endif
853
854protected:
855
856    LinearGradientBrush()
857    {
858    }
859};
860
861//--------------------------------------------------------------------------
862// PathGradientBrush object is defined
863// in gdipluspath.h.
864//--------------------------------------------------------------------------
865
866//--------------------------------------------------------------------------
867// Represent hatch brush object
868//--------------------------------------------------------------------------
869
870class HatchBrush : public Brush
871{
872public:
873    friend class Pen;
874
875    // Constructors
876
877    HatchBrush(IN HatchStyle hatchStyle,
878               IN const Color& foreColor,
879               IN const Color& backColor = Color())
880    {
881        GpHatch *brush = NULL;
882
883        lastResult = DllExports::GdipCreateHatchBrush(hatchStyle,
884                                                      foreColor.GetValue(),
885                                                      backColor.GetValue(),
886                                                      &brush);
887        SetNativeBrush(brush);
888    }
889
890    HatchStyle GetHatchStyle() const
891    {
892        HatchStyle hatchStyle;
893
894        SetStatus(DllExports::GdipGetHatchStyle((GpHatch*)nativeBrush,
895                                                &hatchStyle));
896
897        return hatchStyle;
898    }
899
900    Status GetForegroundColor(OUT Color* color) const
901    {
902        ARGB argb;
903
904        if (color == NULL)
905        {
906            return SetStatus(InvalidParameter);
907        }
908
909        Status status = SetStatus(DllExports::GdipGetHatchForegroundColor(
910                                                        (GpHatch*)nativeBrush,
911                                                        &argb));
912
913        color->SetValue(argb);
914
915        return status;
916    }
917
918    Status GetBackgroundColor(OUT Color *color) const
919    {
920        ARGB argb;
921
922        if (color == NULL)
923        {
924            return SetStatus(InvalidParameter);
925        }
926
927        Status status = SetStatus(DllExports::GdipGetHatchBackgroundColor(
928                                                        (GpHatch*)nativeBrush,
929                                                        &argb));
930
931        color->SetValue(argb);
932
933        return status;
934    }
935
936#ifdef DCR_USE_NEW_250932
937
938private:
939    HatchBrush(const HatchBrush &);
940    HatchBrush& operator=(const HatchBrush &);
941
942#endif
943
944protected:
945
946    HatchBrush()
947    {
948    }
949};
950
951#endif
952