6 * This file is part of the w32api package.
\r
9 * Created by Markus Koenig <markus@stber-koenig.de>
\r
11 * THIS SOFTWARE IS NOT COPYRIGHTED
\r
13 * This source code is offered for use in the public domain. You may
\r
14 * use, modify or distribute it freely.
\r
16 * This code is distributed in the hope that it will be useful but
\r
17 * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
\r
18 * DISCLAIMED. This includes but is not limited to warranties of
\r
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
\r
23 #ifndef __GDIPLUS_PEN_H
\r
24 #define __GDIPLUS_PEN_H
\r
26 #pragma GCC system_header
\r
30 #error "A C++ compiler is required to include gdipluspen.h."
\r
33 class Pen: public GdiplusBase
\r
35 friend class Graphics;
\r
36 friend class GraphicsPath;
\r
39 Pen(const Color& color, REAL width = 1.0f):
\r
40 nativePen(NULL), lastStatus(Ok)
\r
42 lastStatus = DllExports::GdipCreatePen1(
\r
43 color.GetValue(), width, UnitWorld,
\r
46 Pen(const Brush *brush, REAL width = 1.0f):
\r
47 nativePen(NULL), lastStatus(Ok)
\r
49 lastStatus = DllExports::GdipCreatePen2(
\r
50 brush ? brush->nativeBrush : NULL,
\r
51 width, UnitWorld, &nativePen);
\r
55 DllExports::GdipDeletePen(nativePen);
\r
59 GpPen *clonePen = NULL;
\r
60 Status status = updateStatus(DllExports::GdipClonePen(
\r
61 nativePen, &clonePen));
\r
63 Pen *result = new Pen(clonePen, lastStatus);
\r
65 DllExports::GdipDeletePen(clonePen);
\r
66 lastStatus = OutOfMemory;
\r
74 PenAlignment GetAlignment() const
\r
76 PenAlignment result = PenAlignmentCenter;
\r
77 updateStatus(DllExports::GdipGetPenMode(nativePen, &result));
\r
80 // TODO: implement Pen::GetBrush()
\r
81 //Brush *GetBrush() const
\r
83 // // where is the pen brush allocated (static,member,new,other)?
\r
84 // // GdipGetPenBrushFill just returns a GpBrush*
\r
85 // updateStatus(NotImplemented);
\r
88 Status GetColor(Color *color) const
\r
90 return updateStatus(DllExports::GdipGetPenColor(
\r
91 nativePen, color ? &color->Value : NULL));
\r
93 Status GetCompoundArray(REAL *compoundArray, INT count) const
\r
95 return updateStatus(DllExports::GdipGetPenCompoundArray(
\r
96 nativePen, compoundArray, count));
\r
98 INT GetCompoundArrayCount() const
\r
101 updateStatus(DllExports::GdipGetPenCompoundCount(
\r
102 nativePen, &result));
\r
105 Status GetCustomEndCap(CustomLineCap *customCap) const
\r
107 if (!customCap) return lastStatus = InvalidParameter;
\r
108 // FIXME: do we need to call GdipDeleteCustomLineCap first?
\r
109 return updateStatus(DllExports::GdipGetPenCustomEndCap(
\r
110 nativePen, &customCap->nativeCustomLineCap));
\r
112 Status GetCustomStartCap(CustomLineCap *customCap) const
\r
114 if (!customCap) return lastStatus = InvalidParameter;
\r
115 // FIXME: do we need to call GdipDeleteCustomLineCap first?
\r
116 return updateStatus(DllExports::GdipGetPenCustomStartCap(
\r
117 nativePen, &customCap->nativeCustomLineCap));
\r
119 DashCap GetDashCap() const
\r
121 DashCap result = DashCapFlat;
\r
122 updateStatus(DllExports::GdipGetPenDashCap197819(
\r
123 nativePen, &result));
\r
126 REAL GetDashOffset() const
\r
128 REAL result = 0.0f;
\r
129 updateStatus(DllExports::GdipGetPenDashOffset(
\r
130 nativePen, &result));
\r
133 Status GetDashPattern(REAL *dashArray, INT count) const
\r
135 return updateStatus(DllExports::GdipGetPenDashArray(
\r
136 nativePen, dashArray, count));
\r
138 INT GetDashPatternCount() const
\r
141 updateStatus(DllExports::GdipGetPenDashCount(
\r
142 nativePen, &result));
\r
145 DashStyle GetDashStyle() const
\r
147 DashStyle result = DashStyleSolid;
\r
148 updateStatus(DllExports::GdipGetPenDashStyle(
\r
149 nativePen, &result));
\r
152 LineCap GetEndCap() const
\r
154 LineCap result = LineCapFlat;
\r
155 updateStatus(DllExports::GdipGetPenEndCap(nativePen, &result));
\r
158 Status GetLastStatus() const
\r
160 Status result = lastStatus;
\r
164 LineJoin GetLineJoin() const
\r
166 LineJoin result = LineJoinMiter;
\r
167 updateStatus(DllExports::GdipGetPenLineJoin(
\r
168 nativePen, &result));
\r
171 REAL GetMiterLimit() const
\r
173 REAL result = 10.0f;
\r
174 updateStatus(DllExports::GdipGetPenMiterLimit(
\r
175 nativePen, &result));
\r
178 PenType GetPenType() const
\r
180 PenType result = PenTypeUnknown;
\r
181 updateStatus(DllExports::GdipGetPenFillType(
\r
182 nativePen, &result));
\r
185 LineCap GetStartCap() const
\r
187 LineCap result = LineCapFlat;
\r
188 updateStatus(DllExports::GdipGetPenStartCap(
\r
189 nativePen, &result));
\r
192 Status GetTransform(Matrix *matrix) const
\r
194 return updateStatus(DllExports::GdipGetPenTransform(
\r
196 matrix ? matrix->nativeMatrix : NULL));
\r
198 REAL GetWidth() const
\r
200 REAL result = 1.0f;
\r
201 updateStatus(DllExports::GdipGetPenWidth(nativePen, &result));
\r
204 Status MultiplyTransform(const Matrix *matrix,
\r
205 MatrixOrder order = MatrixOrderPrepend)
\r
207 return updateStatus(DllExports::GdipMultiplyPenTransform(
\r
209 matrix ? matrix->nativeMatrix : NULL, order));
\r
211 Status ResetTransform()
\r
213 return updateStatus(DllExports::GdipResetPenTransform(
\r
216 Status RotateTransform(REAL angle,
\r
217 MatrixOrder order = MatrixOrderPrepend)
\r
219 return updateStatus(DllExports::GdipRotatePenTransform(
\r
220 nativePen, angle, order));
\r
222 Status ScaleTransform(REAL sx, REAL sy,
\r
223 MatrixOrder order = MatrixOrderPrepend)
\r
225 return updateStatus(DllExports::GdipScalePenTransform(
\r
226 nativePen, sx, sy, order));
\r
228 Status SetAlignment(PenAlignment penAlignment)
\r
230 return updateStatus(DllExports::GdipSetPenMode(
\r
231 nativePen, penAlignment));
\r
233 Status SetBrush(const Brush *brush)
\r
235 return updateStatus(DllExports::GdipSetPenBrushFill(
\r
236 nativePen, brush ? brush->nativeBrush : NULL));
\r
238 Status SetColor(const Color& color)
\r
240 return updateStatus(DllExports::GdipSetPenColor(
\r
241 nativePen, color.GetValue()));
\r
243 Status SetCompoundArray(const REAL *compoundArray, INT count)
\r
245 return updateStatus(DllExports::GdipSetPenCompoundArray(
\r
246 nativePen, compoundArray, count));
\r
248 Status SetCustomEndCap(const CustomLineCap *customCap)
\r
250 return updateStatus(DllExports::GdipSetPenCustomEndCap(
\r
252 customCap ? customCap->nativeCustomLineCap : NULL));
\r
254 Status SetCustomStartCap(const CustomLineCap *customCap)
\r
256 return updateStatus(DllExports::GdipSetPenCustomStartCap(
\r
258 customCap ? customCap->nativeCustomLineCap : NULL));
\r
260 Status SetDashCap(DashCap dashCap)
\r
262 return updateStatus(DllExports::GdipSetPenDashCap197819(
\r
263 nativePen, dashCap));
\r
265 Status SetDashOffset(REAL dashOffset)
\r
267 return updateStatus(DllExports::GdipSetPenDashOffset(
\r
268 nativePen, dashOffset));
\r
270 Status SetDashPattern(const REAL *dashArray, INT count)
\r
272 return updateStatus(DllExports::GdipSetPenDashArray(
\r
273 nativePen, dashArray, count));
\r
275 Status SetDashStyle(DashStyle dashStyle)
\r
277 return updateStatus(DllExports::GdipSetPenDashStyle(
\r
278 nativePen, dashStyle));
\r
280 Status SetEndCap(LineCap endCap)
\r
282 return updateStatus(DllExports::GdipSetPenEndCap(
\r
283 nativePen, endCap));
\r
285 Status SetLineCap(LineCap startCap, LineCap endCap, DashCap dashCap)
\r
287 return updateStatus(DllExports::GdipSetPenLineCap197819(
\r
288 nativePen, startCap, endCap, dashCap));
\r
290 Status SetLineJoin(LineJoin lineJoin)
\r
292 return updateStatus(DllExports::GdipSetPenLineJoin(
\r
293 nativePen, lineJoin));
\r
295 Status SetMiterLimit(REAL miterLimit)
\r
297 return updateStatus(DllExports::GdipSetPenMiterLimit(
\r
298 nativePen, miterLimit));
\r
300 Status SetStartCap(LineCap startCap)
\r
302 return updateStatus(DllExports::GdipSetPenStartCap(
\r
303 nativePen, startCap));
\r
305 Status SetTransform(const Matrix *matrix)
\r
307 return updateStatus(DllExports::GdipSetPenTransform(
\r
309 matrix ? matrix->nativeMatrix : NULL));
\r
311 Status SetWidth(REAL width)
\r
313 return updateStatus(DllExports::GdipSetPenWidth(
\r
314 nativePen, width));
\r
316 Status TranslateTransform(REAL dx, REAL dy,
\r
317 MatrixOrder order = MatrixOrderPrepend)
\r
319 return updateStatus(DllExports::GdipTranslatePenTransform(
\r
320 nativePen, dx, dy, order));
\r
324 Pen(GpPen *pen, Status status): nativePen(pen), lastStatus(status) {}
\r
325 Pen(const Pen& pen);
\r
326 Pen& operator=(const Pen&);
\r
328 Status updateStatus(Status newStatus) const
\r
330 if (newStatus != Ok) lastStatus = newStatus;
\r
335 mutable Status lastStatus;
\r
338 #endif /* __GDIPLUS_PEN_H */
\r