您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 
 

952 行
30 KiB

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