/usr/i686-w64-mingw32/include/gdiplus/gdiplusbrush.h is in mingw-w64-i686-dev 2.0.3-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 | /*
* gdiplusbrush.h
*
* GDI+ brush classes
*
* This file is part of the w32api package.
*
* Contributors:
* Created by Markus Koenig <markus@stber-koenig.de>
*
* THIS SOFTWARE IS NOT COPYRIGHTED
*
* This source code is offered for use in the public domain. You may
* use, modify or distribute it freely.
*
* This code is distributed in the hope that it will be useful but
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
* DISCLAIMED. This includes but is not limited to warranties of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
*/
#ifndef __GDIPLUS_BRUSH_H
#define __GDIPLUS_BRUSH_H
#if __GNUC__ >=3
#pragma GCC system_header
#endif
#ifndef __cplusplus
#error "A C++ compiler is required to include gdiplusbrush.h."
#endif
class Brush: public GdiplusBase
{
friend class HatchBrush;
friend class LinearGradientBrush;
friend class PathGradientBrush;
friend class SolidBrush;
friend class TextureBrush;
friend class Graphics;
friend class Pen;
public:
virtual ~Brush()
{
DllExports::GdipDeleteBrush(nativeBrush);
}
virtual Brush* Clone() const // each subclass must implement this
{
lastStatus = NotImplemented;
return NULL;
}
Status GetLastStatus() const
{
Status result = lastStatus;
lastStatus = Ok;
return result;
}
BrushType GetType() const
{
BrushType result = BrushTypeSolidColor;
updateStatus(DllExports::GdipGetBrushType(nativeBrush, &result));
return result;
}
private:
Brush(): nativeBrush(NULL), lastStatus(Ok) {}
Brush(GpBrush *brush, Status status):
nativeBrush(brush), lastStatus(status) {}
Brush(const Brush& brush);
Brush& operator=(const Brush&);
Status updateStatus(Status newStatus) const
{
if (newStatus != Ok) lastStatus = newStatus;
return newStatus;
}
GpBrush *nativeBrush;
mutable Status lastStatus;
};
class HatchBrush: public Brush
{
public:
HatchBrush(HatchStyle hatchStyle,
const Color& foreColor,
const Color& backColor = Color())
{
GpHatch *nativeHatch = NULL;
lastStatus = DllExports::GdipCreateHatchBrush(hatchStyle,
foreColor.GetValue(), backColor.GetValue(),
&nativeHatch);
nativeBrush = nativeHatch;
}
virtual HatchBrush* Clone() const
{
GpBrush *cloneBrush = NULL;
Status status = updateStatus(DllExports::GdipCloneBrush(
nativeBrush, &cloneBrush));
if (status == Ok) {
HatchBrush *result =
new HatchBrush(cloneBrush, lastStatus);
if (!result) {
DllExports::GdipDeleteBrush(cloneBrush);
updateStatus(OutOfMemory);
}
return result;
} else {
return NULL;
}
}
Status GetBackgroundColor(Color *color) const
{
return updateStatus(DllExports::GdipGetHatchBackgroundColor(
(GpHatch*) nativeBrush,
color ? &color->Value : NULL));
}
Status GetForegroundColor(Color *color) const
{
return updateStatus(DllExports::GdipGetHatchForegroundColor(
(GpHatch*) nativeBrush,
color ? &color->Value : NULL));
}
HatchStyle GetHatchStyle() const
{
HatchStyle result;
updateStatus(DllExports::GdipGetHatchStyle(
(GpHatch*) nativeBrush, &result));
return result;
}
private:
HatchBrush(GpBrush *brush, Status status): Brush(brush, status) {}
HatchBrush(const HatchBrush& brush);
HatchBrush& operator=(const HatchBrush&);
};
class LinearGradientBrush: public Brush
{
public:
LinearGradientBrush(const PointF& point1, const PointF& point2,
const Color& color1, const Color& color2)
{
GpLineGradient *nativeLineGradient = NULL;
lastStatus = DllExports::GdipCreateLineBrush(
&point1, &point2,
color1.GetValue(), color2.GetValue(),
WrapModeTile, &nativeLineGradient);
nativeBrush = nativeLineGradient;
}
LinearGradientBrush(const Point& point1, const Point& point2,
const Color& color1, const Color& color2)
{
GpLineGradient *nativeLineGradient = NULL;
lastStatus = DllExports::GdipCreateLineBrushI(
&point1, &point2,
color1.GetValue(), color2.GetValue(),
WrapModeTile, &nativeLineGradient);
nativeBrush = nativeLineGradient;
}
LinearGradientBrush(const RectF& rect, const Color& color1,
const Color& color2, LinearGradientMode mode)
{
GpLineGradient *nativeLineGradient = NULL;
lastStatus = DllExports::GdipCreateLineBrushFromRect(
&rect, color1.GetValue(), color2.GetValue(),
mode, WrapModeTile, &nativeLineGradient);
nativeBrush = nativeLineGradient;
}
LinearGradientBrush(const Rect& rect, const Color& color1,
const Color& color2, LinearGradientMode mode)
{
GpLineGradient *nativeLineGradient = NULL;
lastStatus = DllExports::GdipCreateLineBrushFromRectI(
&rect, color1.GetValue(), color2.GetValue(),
mode, WrapModeTile, &nativeLineGradient);
nativeBrush = nativeLineGradient;
}
LinearGradientBrush(const RectF& rect, const Color& color1,
const Color& color2, REAL angle,
BOOL isAngleScalable = FALSE)
{
GpLineGradient *nativeLineGradient = NULL;
lastStatus = DllExports::GdipCreateLineBrushFromRectWithAngle(
&rect, color1.GetValue(), color2.GetValue(),
angle, isAngleScalable, WrapModeTile,
&nativeLineGradient);
nativeBrush = nativeLineGradient;
}
LinearGradientBrush(const Rect& rect, const Color& color1,
const Color& color2, REAL angle,
BOOL isAngleScalable = FALSE)
{
GpLineGradient *nativeLineGradient = NULL;
lastStatus = DllExports::GdipCreateLineBrushFromRectWithAngleI(
&rect, color1.GetValue(), color2.GetValue(),
angle, isAngleScalable, WrapModeTile,
&nativeLineGradient);
nativeBrush = nativeLineGradient;
}
virtual LinearGradientBrush* Clone() const
{
GpBrush *cloneBrush = NULL;
Status status = updateStatus(DllExports::GdipCloneBrush(
nativeBrush, &cloneBrush));
if (status == Ok) {
LinearGradientBrush *result =
new LinearGradientBrush(cloneBrush, lastStatus);
if (!result) {
DllExports::GdipDeleteBrush(cloneBrush);
updateStatus(OutOfMemory);
}
return result;
} else {
return NULL;
}
}
Status GetBlend(REAL *blendFactors, REAL *blendPositions,
INT count) const
{
return updateStatus(DllExports::GdipGetLineBlend(
(GpLineGradient*) nativeBrush,
blendFactors, blendPositions, count));
}
INT GetBlendCount() const
{
INT result = 0;
updateStatus(DllExports::GdipGetLineBlendCount(
(GpLineGradient*) nativeBrush, &result));
return result;
}
BOOL GetGammaCorrection() const
{
BOOL result = FALSE;
updateStatus(DllExports::GdipGetLineGammaCorrection(
(GpLineGradient*) nativeBrush, &result));
return result;
}
INT GetInterpolationColorCount() const
{
INT result = 0;
updateStatus(DllExports::GdipGetLinePresetBlendCount(
(GpLineGradient*) nativeBrush, &result));
return result;
}
Status GetInterpolationColors(Color *presetColors,
REAL *blendPositions, INT count) const
{
if (!presetColors || count <= 0)
return lastStatus = InvalidParameter;
ARGB *presetArgb =
(ARGB*) DllExports::GdipAlloc(count * sizeof(ARGB));
if (!presetArgb)
return lastStatus = OutOfMemory;
Status status = updateStatus(DllExports::GdipGetLinePresetBlend(
(GpLineGradient*) nativeBrush, presetArgb,
blendPositions, count));
for (INT i = 0; i < count; ++i) {
presetColors[i].SetValue(presetArgb[i]);
}
DllExports::GdipFree((void*) presetArgb);
return status;
}
Status GetLinearColors(Color *colors) const
{
if (!colors) return lastStatus = InvalidParameter;
ARGB colorsArgb[2];
Status status = updateStatus(DllExports::GdipGetLineColors(
(GpLineGradient*) nativeBrush, colorsArgb));
colors[0].SetValue(colorsArgb[0]);
colors[1].SetValue(colorsArgb[1]);
return status;
}
Status GetRectangle(RectF *rect) const
{
return updateStatus(DllExports::GdipGetLineRect(
(GpLineGradient*) nativeBrush, rect));
}
Status GetRectangle(Rect *rect) const
{
return updateStatus(DllExports::GdipGetLineRectI(
(GpLineGradient*) nativeBrush, rect));
}
Status GetTransform(Matrix *matrix) const
{
return updateStatus(DllExports::GdipGetLineTransform(
(GpLineGradient*) nativeBrush,
matrix ? matrix->nativeMatrix : NULL));
}
WrapMode GetWrapMode() const
{
WrapMode wrapMode = WrapModeTile;
updateStatus(DllExports::GdipGetLineWrapMode(
(GpLineGradient*) nativeBrush, &wrapMode));
return wrapMode;
}
Status MultiplyTransform(const Matrix *matrix,
MatrixOrder order = MatrixOrderPrepend)
{
return updateStatus(DllExports::GdipMultiplyLineTransform(
(GpLineGradient*) nativeBrush,
matrix ? matrix->nativeMatrix : NULL, order));
}
Status ResetTransform()
{
return updateStatus(DllExports::GdipResetLineTransform(
(GpLineGradient*) nativeBrush));
}
Status RotateTranform(REAL angle, MatrixOrder order = MatrixOrderPrepend)
{
return updateStatus(DllExports::GdipRotateLineTransform(
(GpLineGradient*) nativeBrush, angle, order));
}
Status ScaleTransform(REAL sx, REAL sy,
MatrixOrder order = MatrixOrderPrepend)
{
return updateStatus(DllExports::GdipScaleLineTransform(
(GpLineGradient*) nativeBrush, sx, sy, order));
}
Status SetBlend(const REAL *blendFactors,
const REAL *blendPositions, INT count)
{
return updateStatus(DllExports::GdipSetLineBlend(
(GpLineGradient*) nativeBrush,
blendFactors, blendPositions, count));
}
Status SetBlendBellShape(REAL focus, REAL scale = 1.0f)
{
return updateStatus(DllExports::GdipSetLineSigmaBlend(
(GpLineGradient*) nativeBrush,
focus, scale));
}
Status SetBlendTriangularShape(REAL focus, REAL scale = 1.0f)
{
return updateStatus(DllExports::GdipSetLineLinearBlend(
(GpLineGradient*) nativeBrush,
focus, scale));
}
Status SetGammaCorrection(BOOL useGammaCorrection)
{
return updateStatus(DllExports::GdipSetLineGammaCorrection(
(GpLineGradient*) nativeBrush,
useGammaCorrection));
}
Status SetInterpolationColors(const Color *presetColors,
const REAL *blendPositions, INT count)
{
if (!presetColors || count < 0)
return lastStatus = InvalidParameter;
ARGB *presetArgb =
(ARGB*) DllExports::GdipAlloc(count * sizeof(ARGB));
if (!presetArgb)
return lastStatus = OutOfMemory;
for (INT i = 0; i < count; ++i) {
presetArgb[i] = presetColors[i].GetValue();
}
Status status = updateStatus(DllExports::GdipSetLinePresetBlend(
(GpLineGradient*) nativeBrush,
presetArgb, blendPositions, count));
DllExports::GdipFree((void*) presetArgb);
return status;
}
Status SetLinearColors(const Color& color1, const Color& color2)
{
return updateStatus(DllExports::GdipSetLineColors(
(GpLineGradient*) nativeBrush,
color1.GetValue(), color2.GetValue()));
}
Status SetTransform(const Matrix *matrix)
{
return updateStatus(DllExports::GdipSetLineTransform(
(GpLineGradient*) nativeBrush,
matrix ? matrix->nativeMatrix : NULL));
}
Status SetWrapMode(WrapMode wrapMode)
{
return updateStatus(DllExports::GdipSetLineWrapMode(
(GpLineGradient*) nativeBrush, wrapMode));
}
Status TranslateTransform(REAL dx, REAL dy,
MatrixOrder order = MatrixOrderPrepend)
{
return updateStatus(DllExports::GdipTranslateLineTransform(
(GpLineGradient*) nativeBrush, dx, dy, order));
}
private:
LinearGradientBrush(GpBrush *brush, Status status): Brush(brush, status) {}
LinearGradientBrush(const LinearGradientBrush& brush);
LinearGradientBrush& operator=(const LinearGradientBrush&);
};
class SolidBrush: public Brush
{
public:
SolidBrush(const Color& color)
{
GpSolidFill *nativeSolidFill = NULL;
lastStatus = DllExports::GdipCreateSolidFill(
color.GetValue(), &nativeSolidFill);
nativeBrush = nativeSolidFill;
}
virtual SolidBrush* Clone() const
{
GpBrush *cloneBrush = NULL;
Status status = updateStatus(DllExports::GdipCloneBrush(
nativeBrush, &cloneBrush));
if (status == Ok) {
SolidBrush *result =
new SolidBrush(cloneBrush, lastStatus);
if (!result) {
DllExports::GdipDeleteBrush(cloneBrush);
updateStatus(OutOfMemory);
}
return result;
} else {
return NULL;
}
}
Status GetColor(Color *color) const
{
return updateStatus(DllExports::GdipGetSolidFillColor(
(GpSolidFill*) nativeBrush,
color ? &color->Value : NULL));
}
Status SetColor(const Color& color)
{
return updateStatus(DllExports::GdipSetSolidFillColor(
(GpSolidFill*) nativeBrush, color.GetValue()));
}
private:
SolidBrush(GpBrush *brush, Status status): Brush(brush, status) {}
SolidBrush(const SolidBrush&);
SolidBrush& operator=(const SolidBrush&);
};
class TextureBrush: public Brush
{
public:
TextureBrush(Image *image, WrapMode wrapMode = WrapModeTile)
{
GpTexture *nativeTexture = NULL;
lastStatus = DllExports::GdipCreateTexture(
image ? image->nativeImage : NULL,
wrapMode, &nativeTexture);
nativeBrush = nativeTexture;
}
TextureBrush(Image *image, WrapMode wrapMode,
REAL dstX, REAL dstY, REAL dstWidth, REAL dstHeight)
{
GpTexture *nativeTexture = NULL;
lastStatus = DllExports::GdipCreateTexture2(
image ? image->nativeImage : NULL,
wrapMode, dstX, dstY, dstWidth, dstHeight,
&nativeTexture);
nativeBrush = nativeTexture;
}
TextureBrush(Image *image, WrapMode wrapMode,
INT dstX, INT dstY, INT dstWidth, INT dstHeight)
{
GpTexture *nativeTexture = NULL;
lastStatus = DllExports::GdipCreateTexture2I(
image ? image->nativeImage : NULL,
wrapMode, dstX, dstY, dstWidth, dstHeight,
&nativeTexture);
nativeBrush = nativeTexture;
}
TextureBrush(Image *image, WrapMode wrapMode, const RectF& dstRect)
{
GpTexture *nativeTexture = NULL;
lastStatus = DllExports::GdipCreateTexture2(
image ? image->nativeImage : NULL, wrapMode,
dstRect.X, dstRect.Y,
dstRect.Width, dstRect.Height, &nativeTexture);
nativeBrush = nativeTexture;
}
TextureBrush(Image *image, WrapMode wrapMode, const Rect& dstRect)
{
GpTexture *nativeTexture = NULL;
lastStatus = DllExports::GdipCreateTexture2I(
image ? image->nativeImage : NULL, wrapMode,
dstRect.X, dstRect.Y,
dstRect.Width, dstRect.Height, &nativeTexture);
nativeBrush = nativeTexture;
}
TextureBrush(Image *image, const RectF& dstRect,
ImageAttributes *imageAttributes = NULL)
{
GpTexture *nativeTexture = NULL;
lastStatus = DllExports::GdipCreateTextureIA(
image ? image->nativeImage : NULL,
imageAttributes ? imageAttributes->nativeImageAttributes : NULL,
dstRect.X, dstRect.Y,
dstRect.Width, dstRect.Height, &nativeTexture);
nativeBrush = nativeTexture;
}
TextureBrush(Image *image, const Rect& dstRect,
ImageAttributes *imageAttributes = NULL)
{
GpTexture *nativeTexture = NULL;
lastStatus = DllExports::GdipCreateTextureIAI(
image ? image->nativeImage : NULL,
imageAttributes ? imageAttributes->nativeImageAttributes : NULL,
dstRect.X, dstRect.Y,
dstRect.Width, dstRect.Height, &nativeTexture);
nativeBrush = nativeTexture;
}
virtual TextureBrush* Clone() const
{
GpBrush *cloneBrush = NULL;
Status status = updateStatus(DllExports::GdipCloneBrush(
nativeBrush, &cloneBrush));
if (status == Ok) {
TextureBrush *result =
new TextureBrush(cloneBrush, lastStatus);
if (!result) {
DllExports::GdipDeleteBrush(cloneBrush);
updateStatus(OutOfMemory);
}
return result;
} else {
return NULL;
}
}
//TODO: implement TextureBrush::GetImage()
//Image *GetImage() const
//{
// // where is the Image allocated (static,member,new,other)?
// // GdipGetTextureImage just returns a GpImage*
// updateStatus(NotImplemented);
// return NULL;
//}
Status GetTransfrom(Matrix *matrix) const
{
return updateStatus(DllExports::GdipGetTextureTransform(
(GpTexture*) nativeBrush,
matrix ? matrix->nativeMatrix : NULL));
}
WrapMode GetWrapMode() const
{
WrapMode result = WrapModeTile;
updateStatus(DllExports::GdipGetTextureWrapMode(
(GpTexture*) nativeBrush, &result));
return result;
}
Status MultiplyTransform(const Matrix *matrix,
MatrixOrder order = MatrixOrderPrepend)
{
return updateStatus(DllExports::GdipMultiplyTextureTransform(
(GpTexture*) nativeBrush,
matrix ? matrix->nativeMatrix : NULL, order));
}
Status ResetTransform()
{
return updateStatus(DllExports::GdipResetTextureTransform(
(GpTexture*) nativeBrush));
}
Status RotateTransform(REAL angle,
MatrixOrder order = MatrixOrderPrepend)
{
return updateStatus(DllExports::GdipRotateTextureTransform(
(GpTexture*) nativeBrush, angle, order));
}
Status ScaleTransform(REAL sx, REAL sy,
MatrixOrder order = MatrixOrderPrepend)
{
return updateStatus(DllExports::GdipScaleTextureTransform(
(GpTexture*) nativeBrush, sx, sy, order));
}
Status SetTransform(const Matrix *matrix)
{
return updateStatus(DllExports::GdipSetTextureTransform(
(GpTexture*) nativeBrush,
matrix ? matrix->nativeMatrix : NULL));
}
Status SetWrapMode(WrapMode wrapMode)
{
return updateStatus(DllExports::GdipSetTextureWrapMode(
(GpTexture*) nativeBrush, wrapMode));
}
Status TranslateTransform(REAL dx, REAL dy,
MatrixOrder order = MatrixOrderPrepend)
{
return updateStatus(DllExports::GdipTranslateTextureTransform(
(GpTexture*) nativeBrush, dx, dy, order));
}
private:
TextureBrush(GpBrush *brush, Status status): Brush(brush, status) {}
TextureBrush(const TextureBrush&);
TextureBrush& operator=(const TextureBrush&);
};
#endif /* __GDIPLUS_BRUSH_H */
|