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