Leaked source code of windows server 2003
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.

284 lines
6.5 KiB

  1. /**************************************************************************\
  2. *
  3. * Copyright (c) 2000 Microsoft Corporation
  4. *
  5. * Module Name:
  6. *
  7. * CustomLineCap.hpp
  8. *
  9. * Abstract:
  10. *
  11. * Class used for the custom line caps.
  12. *
  13. * Revision History:
  14. *
  15. * 02/21/00 ikkof
  16. * Created it.
  17. *
  18. \**************************************************************************/
  19. #ifndef _CUSTOMLINECAP_HPP
  20. #define _CUSTOMLINECAP_HPP
  21. #define CLCAP_BUFFER_SIZE 16
  22. class GpCustomLineCap : public DpCustomLineCap
  23. {
  24. friend class GpObject;
  25. protected:
  26. // This is used by the object factory
  27. GpCustomLineCap(
  28. ) : GpFillPath (NULL, 0, PointsBuffer1, TypesBuffer1, CLCAP_BUFFER_SIZE, FillModeWinding, DpPath::PossiblyNonConvex),
  29. GpStrokePath(NULL, 0, PointsBuffer2, TypesBuffer2, CLCAP_BUFFER_SIZE, FillModeWinding, DpPath::PossiblyNonConvex)
  30. {
  31. Initialize();
  32. }
  33. public:
  34. GpCustomLineCap(
  35. const DpPath* fillPath,
  36. const DpPath* strokePath,
  37. GpLineCap baseCap = LineCapFlat,
  38. REAL baseInset = 0
  39. );
  40. virtual ObjectType GetObjectType() const;
  41. virtual UINT GetDataSize() const;
  42. virtual GpStatus GetData(IStream * stream) const;
  43. virtual GpStatus SetData(const BYTE * dataBuffer, UINT size);
  44. virtual CustomLineCapType GetType() const
  45. {
  46. return CustomLineCapTypeDefault;
  47. }
  48. GpStatus SetFillPath(const DpPath* path);
  49. GpStatus SetFillPath(
  50. const GpPointF* fillPoints,
  51. const BYTE* fillTypes,
  52. INT fillCount);
  53. GpStatus GetFillPath(GpPath* fillPath) const;
  54. GpStatus SetStrokePath(const DpPath* path);
  55. GpStatus SetStrokePath(
  56. const GpPointF* strokePoints,
  57. const BYTE* strokeTypes,
  58. INT strokeCount);
  59. GpStatus GetStrokePath(GpPath* strokePath) const;
  60. virtual BOOL IsEqual(const DpCustomLineCap* customLineCap) const;
  61. virtual INT GetTransformedFillCap(
  62. GpPointF* points,
  63. BYTE* types,
  64. INT count,
  65. const GpPointF& origin,
  66. const GpPointF& tangent,
  67. REAL lineWidth,
  68. REAL minimumWidth
  69. ) const;
  70. virtual INT GetTransformedStrokeCap(
  71. INT cCapacity, // In, initial pPoints & pTypes capacity
  72. GpPointF ** pPoints, // In/out, may be reallocated here
  73. BYTE ** pTypes, // In/out, may be reallocated here
  74. INT * pCount, // In/out, may change here if flattened
  75. const GpPointF& origin,
  76. const GpPointF& tangent,
  77. REAL lineWidth,
  78. REAL minimumWidth
  79. ) const;
  80. virtual REAL GetRadius(
  81. REAL lineWidth,
  82. REAL minimumWidth
  83. ) const;
  84. ~GpCustomLineCap();
  85. virtual GpCustomLineCap* Clone() const
  86. {
  87. return new GpCustomLineCap(this);
  88. }
  89. // Get the lock object
  90. GpLockable *GetObjectLock()
  91. {
  92. return &Lockable;
  93. }
  94. VOID ReverseFillPath();
  95. VOID ReverseStrokePath();
  96. GpStatus GetCreationStatus()
  97. {
  98. return m_creationStatus;
  99. }
  100. protected:
  101. GpCustomLineCap(const GpCustomLineCap* customCap);
  102. VOID Initialize()
  103. {
  104. FillPath = &GpFillPath;
  105. StrokePath = &GpStrokePath;
  106. FillLength = 0.0f;
  107. StrokeLength = 0.0f;
  108. BaseCap = LineCapFlat;
  109. BaseInset = 0;
  110. StrokeStartCap = LineCapFlat;
  111. StrokeEndCap = LineCapFlat;
  112. StrokeJoin = LineJoinMiter;
  113. StrokeMiterLimit = 10;
  114. WidthScale = 1;
  115. FillHotSpot.X = 0;
  116. FillHotSpot.Y = 0;
  117. StrokeHotSpot.X = 0;
  118. StrokeHotSpot.Y = 0;
  119. m_creationStatus = Ok;
  120. SetValid(TRUE);
  121. }
  122. VOID Reset();
  123. VOID ResetFillPath();
  124. VOID ResetStrokePath();
  125. GpStatus ComputeFillCapLength();
  126. GpStatus ComputeStrokeCapLength();
  127. protected:
  128. GpLockable Lockable;
  129. GpPath GpFillPath;
  130. GpPath GpStrokePath;
  131. GpPointF PointsBuffer1[CLCAP_BUFFER_SIZE];
  132. GpPointF PointsBuffer2[CLCAP_BUFFER_SIZE];
  133. BYTE TypesBuffer1[CLCAP_BUFFER_SIZE];
  134. BYTE TypesBuffer2[CLCAP_BUFFER_SIZE];
  135. GpStatus m_creationStatus; // check this if IsValid() == FALSE
  136. };
  137. class GpAdjustableArrowCap : public GpCustomLineCap
  138. {
  139. friend class GpObject;
  140. private:
  141. // This is only used by the object factory
  142. GpAdjustableArrowCap()
  143. {
  144. SetDefaultValue();
  145. Update();
  146. }
  147. public:
  148. GpAdjustableArrowCap(REAL height, REAL width, BOOL isFilled = TRUE)
  149. {
  150. Height = height;
  151. Width = width;
  152. MiddleInset = 0;
  153. FillState = isFilled;
  154. Update();
  155. }
  156. virtual UINT GetDataSize() const;
  157. virtual GpStatus GetData(IStream * stream) const;
  158. virtual GpStatus SetData(const BYTE * dataBuffer, UINT size);
  159. CustomLineCapType GetType() const
  160. {
  161. return CustomLineCapTypeAdjustableArrow;
  162. }
  163. GpStatus SetHeight(REAL height)
  164. {
  165. if(Height == height)
  166. return Ok;
  167. Height = height;
  168. return Update();
  169. }
  170. REAL GetHeight() const { return Height; }
  171. GpStatus SetWidth(REAL width)
  172. {
  173. if(Width == width)
  174. return Ok;
  175. Width = width;
  176. return Update();
  177. }
  178. REAL GetWidth() const { return Width; }
  179. GpStatus SetMiddleInset(REAL middleInset)
  180. {
  181. if(MiddleInset == middleInset)
  182. return Ok;
  183. MiddleInset = middleInset;
  184. return Update();
  185. }
  186. REAL GetMiddleInset() const { return MiddleInset; }
  187. GpStatus SetFillState(BOOL isFilled)
  188. {
  189. if(FillState == isFilled)
  190. return Ok;
  191. FillState = isFilled;
  192. return Update();
  193. }
  194. BOOL IsFilled() const {return FillState;}
  195. virtual GpCustomLineCap* Clone() const
  196. {
  197. return new GpAdjustableArrowCap(this);
  198. }
  199. protected:
  200. GpAdjustableArrowCap(const GpAdjustableArrowCap* customCap);
  201. VOID SetDefaultValue()
  202. {
  203. Height = 2;
  204. Width = 2;
  205. MiddleInset = 0;
  206. FillState = TRUE;
  207. }
  208. GpStatus GetPathData(
  209. GpPathData* pathData,
  210. REAL height,
  211. REAL width,
  212. REAL middleInset,
  213. BOOL isFilled
  214. );
  215. GpStatus Update();
  216. protected:
  217. REAL Width;
  218. REAL Height;
  219. REAL MiddleInset;
  220. BOOL FillState;
  221. };
  222. #endif