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