GdiPlusLineCaps.h
上传用户:jinlangri
上传日期:2022-07-17
资源大小:10774k
文件大小:6k
源码类别:

GDI/图象编程

开发平台:

Visual C++

  1. /**************************************************************************
  2. * Copyright (c) 2000, Microsoft Corp.  All Rights Reserved.
  3. *
  4. * Module Name:
  5. *    GdiplusLineCaps.h
  6. *
  7. * Abstract:
  8. *
  9. *   APIs for Custom Line Caps
  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.     // This is used for default constructor for subclasses.
  37.     // So don't create a nativeCap.
  38.     nativeCap = NULL;
  39.     lastResult = Ok;
  40. }
  41. inline 
  42. CustomLineCap::~CustomLineCap()
  43. {
  44.     DllExports::GdipDeleteCustomLineCap(nativeCap);
  45. }
  46. inline Status 
  47. CustomLineCap::SetStrokeCaps(
  48.     IN LineCap startCap, 
  49.     IN LineCap endCap)
  50. {
  51.     return SetStatus(DllExports::GdipSetCustomLineCapStrokeCaps(nativeCap,
  52.                 startCap, endCap));
  53. }
  54. inline Status 
  55. CustomLineCap::GetStrokeCaps(
  56.     OUT LineCap* startCap, 
  57.     OUT LineCap* endCap) const
  58. {
  59.     return SetStatus(DllExports::GdipGetCustomLineCapStrokeCaps(nativeCap,
  60.                  startCap, endCap));
  61. }
  62. inline Status 
  63. CustomLineCap::SetStrokeJoin(
  64.     IN LineJoin lineJoin)
  65. {
  66.     return SetStatus(DllExports::GdipSetCustomLineCapStrokeJoin(nativeCap, lineJoin));
  67. }
  68. inline LineJoin 
  69. CustomLineCap::GetStrokeJoin() const
  70. {
  71.     LineJoin lineJoin;
  72.     SetStatus(DllExports::GdipGetCustomLineCapStrokeJoin(nativeCap, &lineJoin));
  73.     return lineJoin;
  74. }
  75. inline Status 
  76. CustomLineCap::SetBaseCap(IN LineCap baseCap)
  77. {
  78.     return SetStatus(DllExports::GdipSetCustomLineCapBaseCap(nativeCap, baseCap));
  79. }
  80. inline LineCap 
  81. CustomLineCap::GetBaseCap() const
  82. {
  83.     LineCap baseCap;
  84.     SetStatus(DllExports::GdipGetCustomLineCapBaseCap(nativeCap, &baseCap));
  85.     return baseCap;
  86. }
  87. inline Status 
  88. CustomLineCap::SetBaseInset(IN REAL inset)
  89. {
  90.     return SetStatus(DllExports::GdipSetCustomLineCapBaseInset(nativeCap, inset));
  91. }
  92. inline REAL 
  93. CustomLineCap::GetBaseInset() const
  94. {
  95.     REAL inset;
  96.     SetStatus(DllExports::GdipGetCustomLineCapBaseInset(nativeCap, &inset));
  97.     return inset;
  98. }
  99. inline Status 
  100. CustomLineCap::SetWidthScale(IN REAL widthScale)
  101. {
  102.     return SetStatus(DllExports::GdipSetCustomLineCapWidthScale(nativeCap, widthScale));
  103. }
  104. inline REAL 
  105. CustomLineCap::GetWidthScale() const
  106. {
  107.     REAL widthScale;
  108.     SetStatus(DllExports::GdipGetCustomLineCapWidthScale(nativeCap, &widthScale));
  109.     return widthScale;
  110. }
  111. inline CustomLineCap* 
  112. CustomLineCap::Clone() const
  113. {
  114.     GpCustomLineCap *newNativeLineCap = NULL;
  115.     
  116.     SetStatus(DllExports::GdipCloneCustomLineCap(nativeCap, &newNativeLineCap));
  117.     if (lastResult == Ok) 
  118.     {
  119.         CustomLineCap *newLineCap = new CustomLineCap(newNativeLineCap, lastResult);
  120.         if (newLineCap == NULL) 
  121.         {
  122.             SetStatus(DllExports::GdipDeleteCustomLineCap(newNativeLineCap));
  123.         }
  124.         return newLineCap;
  125.     }
  126.     return NULL;
  127. }
  128. class AdjustableArrowCap : public CustomLineCap
  129. {
  130. public:
  131.     AdjustableArrowCap(
  132.         IN REAL height,
  133.         IN REAL width,
  134.         IN BOOL isFilled = TRUE
  135.         )
  136.     {
  137.         GpAdjustableArrowCap* cap = NULL;
  138.         lastResult = DllExports::GdipCreateAdjustableArrowCap(
  139.                         height, width, isFilled, &cap);
  140.         SetNativeCap(cap);
  141.     }
  142.     Status SetHeight(IN REAL height)
  143.     {
  144.         GpAdjustableArrowCap* cap = (GpAdjustableArrowCap*) nativeCap;
  145.         return SetStatus(DllExports::GdipSetAdjustableArrowCapHeight(
  146.                             cap, height));
  147.     }
  148.     REAL GetHeight() const
  149.     {
  150.         GpAdjustableArrowCap* cap = (GpAdjustableArrowCap*) nativeCap;
  151.         REAL height;
  152.         SetStatus(DllExports::GdipGetAdjustableArrowCapHeight(
  153.                             cap, &height));
  154.         return height;
  155.     }
  156.     Status SetWidth(IN REAL width)
  157.     {
  158.         GpAdjustableArrowCap* cap = (GpAdjustableArrowCap*) nativeCap;
  159.         return SetStatus(DllExports::GdipSetAdjustableArrowCapWidth(
  160.                             cap, width));
  161.     }
  162.     REAL GetWidth() const
  163.     {
  164.         GpAdjustableArrowCap* cap = (GpAdjustableArrowCap*) nativeCap;
  165.         REAL width;
  166.         SetStatus(DllExports::GdipGetAdjustableArrowCapWidth(
  167.                             cap, &width));
  168.         return width;
  169.     }
  170.     Status SetMiddleInset(IN REAL middleInset)
  171.     {
  172.         GpAdjustableArrowCap* cap = (GpAdjustableArrowCap*) nativeCap;
  173.         return SetStatus(DllExports::GdipSetAdjustableArrowCapMiddleInset(
  174.                             cap, middleInset));
  175.     }
  176.     REAL GetMiddleInset() const
  177.     {
  178.         GpAdjustableArrowCap* cap = (GpAdjustableArrowCap*) nativeCap;
  179.         REAL middleInset;
  180.         SetStatus(DllExports::GdipGetAdjustableArrowCapMiddleInset(
  181.                             cap, &middleInset));
  182.         return middleInset;
  183.     }
  184.     Status SetFillState(IN BOOL isFilled)
  185.     {
  186.         GpAdjustableArrowCap* cap = (GpAdjustableArrowCap*) nativeCap;
  187.         return SetStatus(DllExports::GdipSetAdjustableArrowCapFillState(
  188.                             cap, isFilled));
  189.     }
  190.     BOOL IsFilled() const
  191.     {
  192.         GpAdjustableArrowCap* cap = (GpAdjustableArrowCap*) nativeCap;
  193.         BOOL isFilled;
  194.         SetStatus(DllExports::GdipGetAdjustableArrowCapFillState(
  195.                             cap, &isFilled));
  196.         return isFilled;
  197.     }
  198. #ifdef DCR_USE_NEW_250932
  199. private:
  200.     AdjustableArrowCap(const AdjustableArrowCap &);
  201.     AdjustableArrowCap& operator=(const AdjustableArrowCap &);
  202. #endif
  203. };
  204. #endif