ca785db1506eba55b11c2b2df8c1cb8b35c8269f
[reactos.git] / reactos / 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 public:
25 Matrix(const RectF &rect, const PointF *dstplg)
26 {
27 status = DllExports::GdipCreateMatrix3(&rect, dstplg, &matrix);
28 }
29
30 Matrix(const Rect &rect, const Point *dstplg)
31 {
32 status = DllExports::GdipCreateMatrix3I(&rect, dstplg, &matrix);
33 }
34
35 Matrix(VOID)
36 {
37 status = DllExports::GdipCreateMatrix(&matrix);
38 }
39
40 Matrix(REAL m11, REAL m12, REAL m21, REAL m22, REAL dx, REAL dy)
41 {
42 status = DllExports::GdipCreateMatrix2(m11, m12, m21, m22, dx, dy, &matrix);
43 }
44
45 Matrix *Clone(VOID)
46 {
47 Matrix *cloneMatrix = new Matrix(); // FIXME: Matrix::matrix already initialized --> potential memory leak
48 cloneMatrix->status = DllExports::GdipCloneMatrix(matrix, &cloneMatrix);
49 return cloneMatrix;
50 }
51
52 ~Matrix(VOID)
53 {
54 DllExports::GdipDeleteMatrix(matrix);
55 }
56
57 BOOL Equals(const Matrix* matrix)
58 {
59 BOOL result;
60 SetStatus(DllExports::GdipIsMatrixEqual(this->matrix, matrix->matrix, &result));
61 return result;
62 }
63
64 Status GetElements(REAL *m) const
65 {
66 return SetStatus(DllExports::GdipGetMatrixElements(matrix, m));
67 }
68
69 Status GetLastStatus(VOID)
70 {
71 return status;
72 }
73
74 Status Invert(VOID)
75 {
76 return SetStatus(DllExports::GdipInvertMatrix(matrix));
77 }
78
79 BOOL IsIdentity(VOID)
80 {
81 BOOL result;
82 SetStatus(DllExports::GdipIsMatrixIdentity(matrix, &result));
83 return result;
84 }
85
86 BOOL IsInvertible(VOID)
87 {
88 BOOL result;
89 SetStatus(DllExports::GdipIsMatrixInvertible(matrix, &result));
90 return result;
91 }
92
93 Status Multiply(const Matrix *matrix, MatrixOrder order)
94 {
95 return SetStatus(DllExports::GdipMultiplyMatrix(this->matrix, matrix->matrix, order));
96 }
97
98 REAL OffsetX(VOID)
99 {
100 return 0;
101 }
102
103 REAL OffsetY(VOID)
104 {
105 return 0;
106 }
107
108 Status Reset(VOID)
109 {
110 return NotImplemented;
111 }
112
113 Status Rotate(REAL angle, MatrixOrder order)
114 {
115 return SetStatus(DllExports::GdipRotateMatrix(matrix, angle, order));
116 }
117
118 Status RotateAt(REAL angle, const PointF &center, MatrixOrder order)
119 {
120 return NotImplemented;
121 }
122
123 Status Scale(REAL scaleX, REAL scaleY, MatrixOrder order)
124 {
125 return SetStatus(DllExports::GdipScaleMatrix(matrix, scaleX, scaleY, order));
126 }
127
128 Status SetElements(REAL m11, REAL m12, REAL m21, REAL m22, REAL dx, REAL dy)
129 {
130 return SetStatus(DllExports::GdipSetMatrixElements(matrix, m11, m12, m21, m22, dx, dy));
131 }
132
133 Status Shear(REAL shearX, REAL shearY, REAL order)
134 {
135 return SetStatus(DllExports::GdipShearMatrix(matrix, shearX, shearY, order));
136 }
137
138 Status TransformPoints(Point *pts, INT count)
139 {
140 return SetStatus(DllExports::GdipTransformMatrixPointsI(matrix, pts, count));
141 }
142
143 Status TransformPoints(PointF *pts, INT count)
144 {
145 return SetStatus(DllExports::GdipTransformMatrixPoints(matrix, pts, count));
146 }
147
148 Status TransformVectors(Point *pts, INT count)
149 {
150 return SetStatus(DllExports::GdipVectorTransformMatrixPointsI(matrix, pts, count));
151 }
152
153 Status TransformVectors(PointF *pts, INT count)
154 {
155 return SetStatus(DllExports::GdipVectorTransformMatrixPoints(matrix, pts, count));
156 }
157
158 Status Translate(REAL offsetX, REAL offsetY, REAL order)
159 {
160 return SetStatus(DllExports::GdipTranslateMatrix(matrix, offsetX, offsetY, order));
161 }
162
163 private:
164 mutable Status status;
165 GpMatrix *matrix;
166
167 Status SetStatus(Status status) const
168 {
169 if (status == Ok)
170 return status;
171 this->status = status;
172 return status;
173 }
174 };
175
176 #endif /* _GDIPLUSMATRIX_H */