GdiPlusLineCaps.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. //Download by http://www.NewXing.com
  2. /**************************************************************************\
  3. *
  4. * Copyright (c) 2000-2001, Microsoft Corp. All Rights Reserved.
  5. *
  6. * Module Name:
  7. *
  8. * GdiplusLineCaps.h
  9. *
  10. * Abstract:
  11. *
  12. * GDI+ CustomLineCap APIs
  13. *
  14. \**************************************************************************/
  15. #ifndef _GDIPLUSLINECAPS_H
  16. #define _GDIPLUSLINECAPS_H
  17. inline
  18. CustomLineCap::CustomLineCap(
  19. IN const GraphicsPath* fillPath,
  20. IN const GraphicsPath* strokePath,
  21. IN LineCap baseCap,
  22. IN REAL baseInset
  23. )
  24. {
  25. nativeCap = NULL;
  26. GpPath* nativeFillPath = NULL;
  27. GpPath* nativeStrokePath = NULL;
  28. if(fillPath)
  29. nativeFillPath = fillPath->nativePath;
  30. if(strokePath)
  31. nativeStrokePath = strokePath->nativePath;
  32. lastResult = DllExports::GdipCreateCustomLineCap(
  33. nativeFillPath, nativeStrokePath,
  34. baseCap, baseInset, &nativeCap);
  35. }
  36. inline
  37. CustomLineCap::CustomLineCap()
  38. {
  39. nativeCap = NULL;
  40. lastResult = Ok;
  41. }
  42. inline
  43. CustomLineCap::~CustomLineCap()
  44. {
  45. DllExports::GdipDeleteCustomLineCap(nativeCap);
  46. }
  47. inline Status
  48. CustomLineCap::SetStrokeCaps(
  49. IN LineCap startCap,
  50. IN LineCap endCap)
  51. {
  52. return SetStatus(DllExports::GdipSetCustomLineCapStrokeCaps(nativeCap,
  53. startCap, endCap));
  54. }
  55. inline Status
  56. CustomLineCap::GetStrokeCaps(
  57. OUT LineCap* startCap,
  58. OUT LineCap* endCap) const
  59. {
  60. return SetStatus(DllExports::GdipGetCustomLineCapStrokeCaps(nativeCap,
  61. startCap, endCap));
  62. }
  63. inline Status
  64. CustomLineCap::SetStrokeJoin(
  65. IN LineJoin lineJoin)
  66. {
  67. return SetStatus(DllExports::GdipSetCustomLineCapStrokeJoin(nativeCap,
  68. lineJoin));
  69. }
  70. inline LineJoin
  71. CustomLineCap::GetStrokeJoin() const
  72. {
  73. LineJoin lineJoin;
  74. SetStatus(DllExports::GdipGetCustomLineCapStrokeJoin(nativeCap,
  75. &lineJoin));
  76. return lineJoin;
  77. }
  78. inline Status
  79. CustomLineCap::SetBaseCap(IN LineCap baseCap)
  80. {
  81. return SetStatus(DllExports::GdipSetCustomLineCapBaseCap(nativeCap,
  82. baseCap));
  83. }
  84. inline LineCap
  85. CustomLineCap::GetBaseCap() const
  86. {
  87. LineCap baseCap;
  88. SetStatus(DllExports::GdipGetCustomLineCapBaseCap(nativeCap, &baseCap));
  89. return baseCap;
  90. }
  91. inline Status
  92. CustomLineCap::SetBaseInset(IN REAL inset)
  93. {
  94. return SetStatus(DllExports::GdipSetCustomLineCapBaseInset(nativeCap,
  95. inset));
  96. }
  97. inline REAL
  98. CustomLineCap::GetBaseInset() const
  99. {
  100. REAL inset;
  101. SetStatus(DllExports::GdipGetCustomLineCapBaseInset(nativeCap, &inset));
  102. return inset;
  103. }
  104. inline Status
  105. CustomLineCap::SetWidthScale(IN REAL widthScale)
  106. {
  107. return SetStatus(DllExports::GdipSetCustomLineCapWidthScale(nativeCap,
  108. widthScale));
  109. }
  110. inline REAL
  111. CustomLineCap::GetWidthScale() const
  112. {
  113. REAL widthScale;
  114. SetStatus(DllExports::GdipGetCustomLineCapWidthScale(nativeCap,
  115. &widthScale));
  116. return widthScale;
  117. }
  118. inline CustomLineCap*
  119. CustomLineCap::Clone() const
  120. {
  121. GpCustomLineCap *newNativeLineCap = NULL;
  122. SetStatus(DllExports::GdipCloneCustomLineCap(nativeCap,
  123. &newNativeLineCap));
  124. if (lastResult == Ok)
  125. {
  126. CustomLineCap *newLineCap = new CustomLineCap(newNativeLineCap,
  127. lastResult);
  128. if (newLineCap == NULL)
  129. {
  130. SetStatus(DllExports::GdipDeleteCustomLineCap(newNativeLineCap));
  131. }
  132. return newLineCap;
  133. }
  134. return NULL;
  135. }
  136. inline Status
  137. CustomLineCap::GetLastStatus() const
  138. {
  139. Status lastStatus = lastResult;
  140. lastResult = Ok;
  141. return (lastStatus);
  142. }
  143. class AdjustableArrowCap : public CustomLineCap
  144. {
  145. public:
  146. AdjustableArrowCap(
  147. IN REAL height,
  148. IN REAL width,
  149. IN BOOL isFilled = TRUE
  150. )
  151. {
  152. GpAdjustableArrowCap* cap = NULL;
  153. lastResult = DllExports::GdipCreateAdjustableArrowCap(
  154. height, width, isFilled, &cap);
  155. SetNativeCap(cap);
  156. }
  157. Status SetHeight(IN REAL height)
  158. {
  159. GpAdjustableArrowCap* cap = (GpAdjustableArrowCap*) nativeCap;
  160. return SetStatus(DllExports::GdipSetAdjustableArrowCapHeight(
  161. cap, height));
  162. }
  163. REAL GetHeight() const
  164. {
  165. GpAdjustableArrowCap* cap = (GpAdjustableArrowCap*) nativeCap;
  166. REAL height;
  167. SetStatus(DllExports::GdipGetAdjustableArrowCapHeight(
  168. cap, &height));
  169. return height;
  170. }
  171. Status SetWidth(IN REAL width)
  172. {
  173. GpAdjustableArrowCap* cap = (GpAdjustableArrowCap*) nativeCap;
  174. return SetStatus(DllExports::GdipSetAdjustableArrowCapWidth(
  175. cap, width));
  176. }
  177. REAL GetWidth() const
  178. {
  179. GpAdjustableArrowCap* cap = (GpAdjustableArrowCap*) nativeCap;
  180. REAL width;
  181. SetStatus(DllExports::GdipGetAdjustableArrowCapWidth(
  182. cap, &width));
  183. return width;
  184. }
  185. Status SetMiddleInset(IN REAL middleInset)
  186. {
  187. GpAdjustableArrowCap* cap = (GpAdjustableArrowCap*) nativeCap;
  188. return SetStatus(DllExports::GdipSetAdjustableArrowCapMiddleInset(
  189. cap, middleInset));
  190. }
  191. REAL GetMiddleInset() const
  192. {
  193. GpAdjustableArrowCap* cap = (GpAdjustableArrowCap*) nativeCap;
  194. REAL middleInset;
  195. SetStatus(DllExports::GdipGetAdjustableArrowCapMiddleInset(
  196. cap, &middleInset));
  197. return middleInset;
  198. }
  199. Status SetFillState(IN BOOL isFilled)
  200. {
  201. GpAdjustableArrowCap* cap = (GpAdjustableArrowCap*) nativeCap;
  202. return SetStatus(DllExports::GdipSetAdjustableArrowCapFillState(
  203. cap, isFilled));
  204. }
  205. BOOL IsFilled() const
  206. {
  207. GpAdjustableArrowCap* cap = (GpAdjustableArrowCap*) nativeCap;
  208. BOOL isFilled;
  209. SetStatus(DllExports::GdipGetAdjustableArrowCapFillState(
  210. cap, &isFilled));
  211. return isFilled;
  212. }
  213. private:
  214. AdjustableArrowCap(const AdjustableArrowCap &);
  215. AdjustableArrowCap& operator=(const AdjustableArrowCap &);
  216. };
  217. #endif