GdiPlusLineCaps.h
上传用户:dzyhzl
上传日期:2019-04-29
资源大小:56270k
文件大小:7k
源码类别:

模拟服务器

开发平台:

C/C++

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