xref: /reactos/sdk/include/psdk/gdipluslinecaps.h (revision 019f21ee)
1 /*
2  * GdiPlusLineCaps.h
3  *
4  * Windows GDI+
5  *
6  * This file is part of the w32api package.
7  *
8  * THIS SOFTWARE IS NOT COPYRIGHTED
9  *
10  * This source code is offered for use in the public domain. You may
11  * use, modify or distribute it freely.
12  *
13  * This code is distributed in the hope that it will be useful but
14  * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
15  * DISCLAIMED. This includes but is not limited to warranties of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17  */
18 
19 #ifndef _GDIPLUSLINECAPS_H
20 #define _GDIPLUSLINECAPS_H
21 
22 inline CustomLineCap::CustomLineCap(
23     const GraphicsPath *fillPath,
24     const GraphicsPath *strokePath,
25     LineCap baseCap,
26     REAL baseInset)
27     : nativeCap(NULL)
28 {
29     nativeCap = NULL;
30     GpPath *nativeFillPath = fillPath ? getNat(fillPath) : NULL;
31     GpPath *nativeStrokePath = strokePath ? getNat(strokePath) : NULL;
32     lastStatus = DllExports::GdipCreateCustomLineCap(nativeFillPath, nativeStrokePath, baseCap, baseInset, &nativeCap);
33 }
34 
35 inline CustomLineCap::~CustomLineCap()
36 {
37     DllExports::GdipDeleteCustomLineCap(nativeCap);
38 }
39 
40 inline CustomLineCap *
41 CustomLineCap::Clone()
42 {
43     GpCustomLineCap *cap = NULL;
44     SetStatus(DllExports::GdipCloneCustomLineCap(nativeCap, &cap));
45     if (lastStatus != Ok)
46         return NULL;
47 
48     CustomLineCap *newLineCap = new CustomLineCap(cap, lastStatus);
49     if (newLineCap == NULL)
50     {
51         SetStatus(DllExports::GdipDeleteCustomLineCap(cap));
52     }
53 
54     return newLineCap;
55 }
56 
57 inline LineCap
58 CustomLineCap::GetBaseCap()
59 {
60     LineCap baseCap;
61     SetStatus(DllExports::GdipGetCustomLineCapBaseCap(nativeCap, &baseCap));
62     return baseCap;
63 }
64 
65 inline REAL
66 CustomLineCap::GetBaseInset()
67 {
68     REAL inset;
69     SetStatus(DllExports::GdipGetCustomLineCapBaseInset(nativeCap, &inset));
70     return inset;
71 }
72 
73 inline Status
74 CustomLineCap::GetLastStatus()
75 {
76     return lastStatus;
77 }
78 
79 inline Status
80 CustomLineCap::GetStrokeCaps(LineCap *startCap, LineCap *endCap)
81 {
82 #if 1
83     return SetStatus(NotImplemented);
84 #else
85     return SetStatus(DllExports::GdipGetCustomLineCapStrokeCaps(nativeCap, startCap, endCap));
86 #endif
87 }
88 
89 inline LineJoin
90 CustomLineCap::GetStrokeJoin()
91 {
92     LineJoin lineJoin;
93     SetStatus(DllExports::GdipGetCustomLineCapStrokeJoin(nativeCap, &lineJoin));
94     return lineJoin;
95 }
96 
97 inline REAL
98 CustomLineCap::GetWidthScale()
99 {
100     REAL widthScale;
101     SetStatus(DllExports::GdipGetCustomLineCapWidthScale(nativeCap, &widthScale));
102     return widthScale;
103 }
104 
105 inline Status
106 CustomLineCap::SetBaseCap(LineCap baseCap)
107 {
108     return SetStatus(DllExports::GdipSetCustomLineCapBaseCap(nativeCap, baseCap));
109 }
110 
111 inline Status
112 CustomLineCap::SetBaseInset(REAL inset)
113 {
114     return SetStatus(DllExports::GdipSetCustomLineCapBaseInset(nativeCap, inset));
115 }
116 
117 inline Status
118 CustomLineCap::SetStrokeCap(LineCap strokeCap)
119 {
120     return SetStrokeCaps(strokeCap, strokeCap);
121 }
122 
123 inline Status
124 CustomLineCap::SetStrokeCaps(LineCap startCap, LineCap endCap)
125 {
126     return SetStatus(DllExports::GdipSetCustomLineCapStrokeCaps(nativeCap, startCap, endCap));
127 }
128 
129 inline Status
130 CustomLineCap::SetStrokeJoin(LineJoin lineJoin)
131 {
132     return SetStatus(DllExports::GdipSetCustomLineCapStrokeJoin(nativeCap, lineJoin));
133 }
134 
135 inline Status
136 CustomLineCap::SetWidthScale(IN REAL widthScale)
137 {
138     return SetStatus(DllExports::GdipSetCustomLineCapWidthScale(nativeCap, widthScale));
139 }
140 
141 class AdjustableArrowCap : public CustomLineCap
142 {
143   public:
144     AdjustableArrowCap(REAL height, REAL width, BOOL isFilled)
145     {
146         GpAdjustableArrowCap *cap = NULL;
147         lastStatus = DllExports::GdipCreateAdjustableArrowCap(height, width, isFilled, &cap);
148         SetNativeCap(cap);
149     }
150 
151     REAL
152     GetHeight()
153     {
154         REAL height;
155         GpAdjustableArrowCap *cap = GetNativeAdjustableArrowCap();
156         SetStatus(DllExports::GdipGetAdjustableArrowCapHeight(cap, &height));
157         return height;
158     }
159 
160     REAL
161     GetMiddleInset()
162     {
163         GpAdjustableArrowCap *cap = GetNativeAdjustableArrowCap();
164         REAL middleInset;
165         SetStatus(DllExports::GdipGetAdjustableArrowCapMiddleInset(cap, &middleInset));
166         return middleInset;
167     }
168 
169     REAL
170     GetWidth()
171     {
172         GpAdjustableArrowCap *cap = GetNativeAdjustableArrowCap();
173         REAL width;
174         SetStatus(DllExports::GdipGetAdjustableArrowCapWidth(cap, &width));
175         return width;
176     }
177 
178     BOOL
179     IsFilled()
180     {
181         GpAdjustableArrowCap *cap = GetNativeAdjustableArrowCap();
182         BOOL isFilled;
183         SetStatus(DllExports::GdipGetAdjustableArrowCapFillState(cap, &isFilled));
184         return isFilled;
185     }
186 
187     Status
188     SetFillState(BOOL isFilled)
189     {
190         GpAdjustableArrowCap *cap = GetNativeAdjustableArrowCap();
191         return SetStatus(DllExports::GdipSetAdjustableArrowCapFillState(cap, isFilled));
192     }
193 
194     Status
195     SetHeight(REAL height)
196     {
197         GpAdjustableArrowCap *cap = GetNativeAdjustableArrowCap();
198         return SetStatus(DllExports::GdipSetAdjustableArrowCapHeight(cap, height));
199     }
200 
201     Status
202     SetMiddleInset(REAL middleInset)
203     {
204         GpAdjustableArrowCap *cap = GetNativeAdjustableArrowCap();
205         return SetStatus(DllExports::GdipSetAdjustableArrowCapMiddleInset(cap, middleInset));
206     }
207 
208     Status
209     SetWidth(REAL width)
210     {
211         GpAdjustableArrowCap *cap = GetNativeAdjustableArrowCap();
212         return SetStatus(DllExports::GdipSetAdjustableArrowCapWidth(cap, width));
213     }
214 
215   protected:
216     GpAdjustableArrowCap *
217     GetNativeAdjustableArrowCap() const
218     {
219         return static_cast<GpAdjustableArrowCap *>(nativeCap);
220     }
221 
222   private:
223     // AdjustableArrowCap is not copyable
224     AdjustableArrowCap(const AdjustableArrowCap &);
225     AdjustableArrowCap &
226     operator=(const AdjustableArrowCap &);
227 };
228 
229 #endif /* _GDIPLUSLINECAPS_H */
230