Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gdipluspen.h « gdiplus « include « w32api « winsup - cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d47f7afba16fe0b4aebe1c0f920ae7555c5529cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
/*
 * gdipluspen.h
 *
 * GDI+ Pen class
 *
 * This file is part of the w32api package.
 *
 * Contributors:
 *   Created by Markus Koenig <markus@stber-koenig.de>
 *
 * THIS SOFTWARE IS NOT COPYRIGHTED
 *
 * This source code is offered for use in the public domain. You may
 * use, modify or distribute it freely.
 *
 * This code is distributed in the hope that it will be useful but
 * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
 * DISCLAIMED. This includes but is not limited to warranties of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *
 */

#ifndef __GDIPLUS_PEN_H
#define __GDIPLUS_PEN_H
#if __GNUC__ >=3
#pragma GCC system_header
#endif

#ifndef __cplusplus
#error "A C++ compiler is required to include gdipluspen.h."
#endif

class Pen: public GdiplusBase
{
	friend class Graphics;
	friend class GraphicsPath;

public:
	Pen(const Color& color, REAL width = 1.0f):
		nativePen(NULL), lastStatus(Ok)
	{
		lastStatus = DllExports::GdipCreatePen1(
				color.GetValue(), width, UnitWorld,
				&nativePen);
	}
	Pen(const Brush *brush, REAL width = 1.0f):
		nativePen(NULL), lastStatus(Ok)
	{
		lastStatus = DllExports::GdipCreatePen2(
				brush ? brush->nativeBrush : NULL,
				width, UnitWorld, &nativePen);
	}
	~Pen()
	{
		DllExports::GdipDeletePen(nativePen);
	}
	Pen* Clone() const
	{
		GpPen *clonePen = NULL;
		Status status = updateStatus(DllExports::GdipClonePen(
				nativePen, &clonePen));
		if (status == Ok) {
			Pen *result = new Pen(clonePen, lastStatus);
			if (!result) {
				DllExports::GdipDeletePen(clonePen);
				lastStatus = OutOfMemory;
			}
			return result;
		} else {
			return NULL;
		}
	}

	PenAlignment GetAlignment() const
	{
		PenAlignment result = PenAlignmentCenter;
		updateStatus(DllExports::GdipGetPenMode(nativePen, &result));
		return result;
	}
	// TODO: implement Pen::GetBrush()
	//Brush *GetBrush() const
	//{
	//	// where is the pen brush allocated (static,member,new,other)?
	//	// GdipGetPenBrushFill just returns a GpBrush*
	//	updateStatus(NotImplemented);
	//	return NULL;
	//}
	Status GetColor(Color *color) const
	{
		return updateStatus(DllExports::GdipGetPenColor(
				nativePen, color ? &color->Value : NULL));
	}
	Status GetCompoundArray(REAL *compoundArray, INT count) const
	{
		return updateStatus(DllExports::GdipGetPenCompoundArray(
				nativePen, compoundArray, count));
	}
	INT GetCompoundArrayCount() const
	{
		INT result = 0;
		updateStatus(DllExports::GdipGetPenCompoundCount(
				nativePen, &result));
		return result;
	}
	Status GetCustomEndCap(CustomLineCap *customCap) const
	{
		if (!customCap) return lastStatus = InvalidParameter;
		// FIXME: do we need to call GdipDeleteCustomLineCap first?
		return updateStatus(DllExports::GdipGetPenCustomEndCap(
				nativePen, &customCap->nativeCustomLineCap));
	}
	Status GetCustomStartCap(CustomLineCap *customCap) const
	{
		if (!customCap) return lastStatus = InvalidParameter;
		// FIXME: do we need to call GdipDeleteCustomLineCap first?
		return updateStatus(DllExports::GdipGetPenCustomStartCap(
				nativePen, &customCap->nativeCustomLineCap));
	}
	DashCap GetDashCap() const
	{
		DashCap result = DashCapFlat;
		updateStatus(DllExports::GdipGetPenDashCap197819(
				nativePen, &result));
		return result;
	}
	REAL GetDashOffset() const
	{
		REAL result = 0.0f;
		updateStatus(DllExports::GdipGetPenDashOffset(
				nativePen, &result));
		return result;
	}
	Status GetDashPattern(REAL *dashArray, INT count) const
	{
		return updateStatus(DllExports::GdipGetPenDashArray(
				nativePen, dashArray, count));
	}
	INT GetDashPatternCount() const
	{
		INT result = 0;
		updateStatus(DllExports::GdipGetPenDashCount(
				nativePen, &result));
		return result;
	}
	DashStyle GetDashStyle() const
	{
		DashStyle result = DashStyleSolid;
		updateStatus(DllExports::GdipGetPenDashStyle(
				nativePen, &result));
		return result;
	}
	LineCap GetEndCap() const
	{
		LineCap result = LineCapFlat;
		updateStatus(DllExports::GdipGetPenEndCap(nativePen, &result));
		return result;
	}
	Status GetLastStatus() const
	{
		Status result = lastStatus;
		lastStatus = Ok;
		return result;
	}
	LineJoin GetLineJoin() const
	{
		LineJoin result = LineJoinMiter;
		updateStatus(DllExports::GdipGetPenLineJoin(
				nativePen, &result));
		return result;
	}
	REAL GetMiterLimit() const
	{
		REAL result = 10.0f;
		updateStatus(DllExports::GdipGetPenMiterLimit(
				nativePen, &result));
		return result;
	}
	PenType GetPenType() const
	{
		PenType result = PenTypeUnknown;
		updateStatus(DllExports::GdipGetPenFillType(
				nativePen, &result));
		return result;
	}
	LineCap GetStartCap() const
	{
		LineCap result = LineCapFlat;
		updateStatus(DllExports::GdipGetPenStartCap(
				nativePen, &result));
		return result;
	}
	Status GetTransform(Matrix *matrix) const
	{
		return updateStatus(DllExports::GdipGetPenTransform(
				nativePen,
				matrix ? matrix->nativeMatrix : NULL));
	}
	REAL GetWidth() const
	{
		REAL result = 1.0f;
		updateStatus(DllExports::GdipGetPenWidth(nativePen, &result));
		return result;
	}
	Status MultiplyTransform(const Matrix *matrix,
			MatrixOrder order = MatrixOrderPrepend)
	{
		return updateStatus(DllExports::GdipMultiplyPenTransform(
				nativePen,
				matrix ? matrix->nativeMatrix : NULL, order));
	}
	Status ResetTransform()
	{
		return updateStatus(DllExports::GdipResetPenTransform(
				nativePen));
	}
	Status RotateTransform(REAL angle,
			MatrixOrder order = MatrixOrderPrepend)
	{
		return updateStatus(DllExports::GdipRotatePenTransform(
				nativePen, angle, order));
	}
	Status ScaleTransform(REAL sx, REAL sy,
			MatrixOrder order = MatrixOrderPrepend)
	{
		return updateStatus(DllExports::GdipScalePenTransform(
				nativePen, sx, sy, order));
	}
	Status SetAlignment(PenAlignment penAlignment)
	{
		return updateStatus(DllExports::GdipSetPenMode(
				nativePen, penAlignment));
	}
	Status SetBrush(const Brush *brush)
	{
		return updateStatus(DllExports::GdipSetPenBrushFill(
				nativePen, brush ? brush->nativeBrush : NULL));
	}
	Status SetColor(const Color& color)
	{
		return updateStatus(DllExports::GdipSetPenColor(
				nativePen, color.GetValue()));
	}
	Status SetCompoundArray(const REAL *compoundArray, INT count)
	{
		return updateStatus(DllExports::GdipSetPenCompoundArray(
				nativePen, compoundArray, count));
	}
	Status SetCustomEndCap(const CustomLineCap *customCap)
	{
		return updateStatus(DllExports::GdipSetPenCustomEndCap(
				nativePen,
				customCap ? customCap->nativeCustomLineCap : NULL));
	}
	Status SetCustomStartCap(const CustomLineCap *customCap)
	{
		return updateStatus(DllExports::GdipSetPenCustomStartCap(
				nativePen,
				customCap ? customCap->nativeCustomLineCap : NULL));
	}
	Status SetDashCap(DashCap dashCap)
	{
		return updateStatus(DllExports::GdipSetPenDashCap197819(
				nativePen, dashCap));
	}
	Status SetDashOffset(REAL dashOffset)
	{
		return updateStatus(DllExports::GdipSetPenDashOffset(
				nativePen, dashOffset));
	}
	Status SetDashPattern(const REAL *dashArray, INT count)
	{
		return updateStatus(DllExports::GdipSetPenDashArray(
				nativePen, dashArray, count));
	}
	Status SetDashStyle(DashStyle dashStyle)
	{
		return updateStatus(DllExports::GdipSetPenDashStyle(
				nativePen, dashStyle));
	}
	Status SetEndCap(LineCap endCap)
	{
		return updateStatus(DllExports::GdipSetPenEndCap(
				nativePen, endCap));
	}
	Status SetLineCap(LineCap startCap, LineCap endCap, DashCap dashCap)
	{
		return updateStatus(DllExports::GdipSetPenLineCap197819(
				nativePen, startCap, endCap, dashCap));
	}
	Status SetLineJoin(LineJoin lineJoin)
	{
		return updateStatus(DllExports::GdipSetPenLineJoin(
				nativePen, lineJoin));
	}
	Status SetMiterLimit(REAL miterLimit)
	{
		return updateStatus(DllExports::GdipSetPenMiterLimit(
				nativePen, miterLimit));
	}
	Status SetStartCap(LineCap startCap)
	{
		return updateStatus(DllExports::GdipSetPenStartCap(
				nativePen, startCap));
	}
	Status SetTransform(const Matrix *matrix)
	{
		return updateStatus(DllExports::GdipSetPenTransform(
				nativePen,
				matrix ? matrix->nativeMatrix : NULL));
	}
	Status SetWidth(REAL width)
	{
		return updateStatus(DllExports::GdipSetPenWidth(
				nativePen, width));
	}
	Status TranslateTransform(REAL dx, REAL dy,
			MatrixOrder order = MatrixOrderPrepend)
	{
		return updateStatus(DllExports::GdipTranslatePenTransform(
				nativePen, dx, dy, order));
	}

private:
	Pen(GpPen *pen, Status status): nativePen(pen), lastStatus(status) {}
	Pen(const Pen& pen);
	Pen& operator=(const Pen&);

	Status updateStatus(Status newStatus) const
	{
		if (newStatus != Ok) lastStatus = newStatus;
		return newStatus;
	}

	GpPen *nativePen;
	mutable Status lastStatus;
};

#endif /* __GDIPLUS_PEN_H */