124b070a9e446284a0128749da9c6675b525473f
[reactos.git] / sdk / include / psdk / gdiplusmatrix.h
1 /*
2 * GdiPlusMatrix.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 _GDIPLUSMATRIX_H
20 #define _GDIPLUSMATRIX_H
21
22 class Matrix : public GdiplusBase
23 {
24 friend class Pen;
25 friend class Region;
26 friend class GraphicsPath;
27 friend class Brush;
28 friend class LinearGradientBrush;
29 friend class TextureBrush;
30
31 public:
32 Matrix(const RectF &rect, const PointF *dstplg)
33 {
34 lastStatus = DllExports::GdipCreateMatrix3(&rect, dstplg, &nativeMatrix);
35 }
36
37 Matrix(const Rect &rect, const Point *dstplg)
38 {
39 lastStatus = DllExports::GdipCreateMatrix3I(&rect, dstplg, &nativeMatrix);
40 }
41
42 Matrix()
43 {
44 lastStatus = DllExports::GdipCreateMatrix(&nativeMatrix);
45 }
46
47 Matrix(REAL m11, REAL m12, REAL m21, REAL m22, REAL dx, REAL dy)
48 {
49 lastStatus = DllExports::GdipCreateMatrix2(m11, m12, m21, m22, dx, dy, &nativeMatrix);
50 }
51
52 Matrix *
53 Clone()
54 {
55 GpMatrix *cloneMatrix = NULL;
56 SetStatus(DllExports::GdipCloneMatrix(nativeMatrix, &cloneMatrix));
57
58 if (lastStatus != Ok)
59 return NULL;
60
61 return new Matrix(cloneMatrix);
62 }
63
64 ~Matrix()
65 {
66 DllExports::GdipDeleteMatrix(nativeMatrix);
67 }
68
69 BOOL
70 Equals(const Matrix *matrix)
71 {
72 BOOL result;
73 SetStatus(DllExports::GdipIsMatrixEqual(nativeMatrix, matrix ? getNat(matrix) : NULL, &result));
74 return result;
75 }
76
77 Status
78 GetElements(REAL *m) const
79 {
80 return SetStatus(DllExports::GdipGetMatrixElements(nativeMatrix, m));
81 }
82
83 Status
84 GetLastStatus() const
85 {
86 return lastStatus;
87 }
88
89 Status
90 Invert()
91 {
92 return SetStatus(DllExports::GdipInvertMatrix(nativeMatrix));
93 }
94
95 BOOL
96 IsIdentity()
97 {
98 BOOL result;
99 SetStatus(DllExports::GdipIsMatrixIdentity(nativeMatrix, &result));
100 return result;
101 }
102
103 BOOL
104 IsInvertible()
105 {
106 BOOL result;
107 SetStatus(DllExports::GdipIsMatrixInvertible(nativeMatrix, &result));
108 return result;
109 }
110
111 Status
112 Multiply(const Matrix *matrix, MatrixOrder order)
113 {
114 return SetStatus(DllExports::GdipMultiplyMatrix(nativeMatrix, matrix ? getNat(matrix) : NULL, order));
115 }
116
117 REAL OffsetX(VOID)
118 {
119 return 0;
120 }
121
122 REAL OffsetY(VOID)
123 {
124 return 0;
125 }
126
127 Status Reset(VOID)
128 {
129 return NotImplemented;
130 }
131
132 Status
133 Rotate(REAL angle, MatrixOrder order)
134 {
135 return SetStatus(DllExports::GdipRotateMatrix(nativeMatrix, angle, order));
136 }
137
138 Status
139 RotateAt(REAL angle, const PointF &center, MatrixOrder order)
140 {
141 return NotImplemented;
142 }
143
144 Status
145 Scale(REAL scaleX, REAL scaleY, MatrixOrder order)
146 {
147 return SetStatus(DllExports::GdipScaleMatrix(nativeMatrix, scaleX, scaleY, order));
148 }
149
150 Status
151 SetElements(REAL m11, REAL m12, REAL m21, REAL m22, REAL dx, REAL dy)
152 {
153 return SetStatus(DllExports::GdipSetMatrixElements(nativeMatrix, m11, m12, m21, m22, dx, dy));
154 }
155
156 Status
157 Shear(REAL shearX, REAL shearY, MatrixOrder order)
158 {
159 return SetStatus(DllExports::GdipShearMatrix(nativeMatrix, shearX, shearY, order));
160 }
161
162 Status
163 TransformPoints(Point *pts, INT count)
164 {
165 return SetStatus(DllExports::GdipTransformMatrixPointsI(nativeMatrix, pts, count));
166 }
167
168 Status
169 TransformPoints(PointF *pts, INT count)
170 {
171 return SetStatus(DllExports::GdipTransformMatrixPoints(nativeMatrix, pts, count));
172 }
173
174 Status
175 TransformVectors(Point *pts, INT count)
176 {
177 return SetStatus(DllExports::GdipVectorTransformMatrixPointsI(nativeMatrix, pts, count));
178 }
179
180 Status
181 TransformVectors(PointF *pts, INT count)
182 {
183 return SetStatus(DllExports::GdipVectorTransformMatrixPoints(nativeMatrix, pts, count));
184 }
185
186 Status
187 Translate(REAL offsetX, REAL offsetY, MatrixOrder order)
188 {
189 return SetStatus(DllExports::GdipTranslateMatrix(nativeMatrix, offsetX, offsetY, order));
190 }
191
192 protected:
193 GpMatrix *nativeMatrix;
194 mutable Status lastStatus;
195
196 Matrix(GpMatrix *matrix) : nativeMatrix(matrix), lastStatus(Ok)
197 {
198 }
199
200 Status
201 SetStatus(Status status) const
202 {
203 if (status != Ok)
204 lastStatus = status;
205 return status;
206 }
207
208 // get native
209 friend inline GpMatrix *&
210 getNat(const Matrix *matrix)
211 {
212 return const_cast<Matrix *>(matrix)->nativeMatrix;
213 }
214 };
215
216 #endif /* _GDIPLUSMATRIX_H */