Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

915 lines
29 KiB

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