95133ca2d881339d7b2ab4e291686cf130fe7cb1
[reactos.git] / reactos / dll / win32 / gdiplus / gdiplus_private.h
1 /*
2 * Copyright (C) 2007 Google (Evan Stade)
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17 */
18
19 #ifndef __WINE_GP_PRIVATE_H_
20 #define __WINE_GP_PRIVATE_H_
21
22 #include <math.h>
23 #include <stdarg.h>
24
25 #include "windef.h"
26 #include "wingdi.h"
27 #include "winbase.h"
28 #include "winuser.h"
29
30 #include "objbase.h"
31 #include "ocidl.h"
32
33 #include "gdiplus.h"
34
35 #define GP_DEFAULT_PENSTYLE (PS_GEOMETRIC | PS_SOLID | PS_ENDCAP_FLAT | PS_JOIN_MITER)
36 #define MAX_ARC_PTS (13)
37 #define MAX_DASHLEN (16) /* this is a limitation of gdi */
38 #define INCH_HIMETRIC (2540)
39
40 #define VERSION_MAGIC 0xdbc01001
41 #define TENSION_CONST (0.3)
42
43 COLORREF ARGB2COLORREF(ARGB color);
44 HBITMAP ARGB2BMP(ARGB color);
45 extern INT arc2polybezier(GpPointF * points, REAL x1, REAL y1, REAL x2, REAL y2,
46 REAL startAngle, REAL sweepAngle);
47 extern REAL gdiplus_atan2(REAL dy, REAL dx);
48 extern GpStatus hresult_to_status(HRESULT res);
49 extern REAL convert_unit(HDC hdc, GpUnit unit);
50
51 extern void calc_curve_bezier(CONST GpPointF *pts, REAL tension, REAL *x1,
52 REAL *y1, REAL *x2, REAL *y2);
53 extern void calc_curve_bezier_endp(REAL xend, REAL yend, REAL xadj, REAL yadj,
54 REAL tension, REAL *x, REAL *y);
55
56 extern void free_installed_fonts(void);
57
58 extern BOOL lengthen_path(GpPath *path, INT len);
59
60 extern GpStatus trace_path(GpGraphics *graphics, GpPath *path);
61
62 typedef struct region_element region_element;
63 extern inline void delete_element(region_element *element);
64
65 static inline INT roundr(REAL x)
66 {
67 return (INT) floorf(x + 0.5);
68 }
69
70 static inline REAL deg2rad(REAL degrees)
71 {
72 return M_PI * degrees / 180.0;
73 }
74
75 extern const char *debugstr_rectf(CONST RectF* rc);
76
77 struct GpPen{
78 UINT style;
79 GpUnit unit;
80 REAL width;
81 GpLineCap endcap;
82 GpLineCap startcap;
83 GpDashCap dashcap;
84 GpCustomLineCap *customstart;
85 GpCustomLineCap *customend;
86 GpLineJoin join;
87 REAL miterlimit;
88 GpDashStyle dash;
89 REAL *dashes;
90 INT numdashes;
91 REAL offset; /* dash offset */
92 GpBrush *brush;
93 GpPenAlignment align;
94 };
95
96 struct GpGraphics{
97 HDC hdc;
98 HWND hwnd;
99 BOOL owndc;
100 SmoothingMode smoothing;
101 CompositingQuality compqual;
102 InterpolationMode interpolation;
103 PixelOffsetMode pixeloffset;
104 CompositingMode compmode;
105 TextRenderingHint texthint;
106 GpUnit unit; /* page unit */
107 REAL scale; /* page scale */
108 GpMatrix * worldtrans; /* world transform */
109 BOOL busy; /* hdc handle obtained by GdipGetDC */
110 GpRegion *clip;
111 UINT textcontrast; /* not used yet. get/set only */
112 };
113
114 struct GpBrush{
115 HBRUSH gdibrush;
116 GpBrushType bt;
117 LOGBRUSH lb;
118 };
119
120 struct GpHatch{
121 GpBrush brush;
122 HatchStyle hatchstyle;
123 ARGB forecol;
124 ARGB backcol;
125 };
126
127 struct GpSolidFill{
128 GpBrush brush;
129 ARGB color;
130 HBITMAP bmp;
131 };
132
133 struct GpPathGradient{
134 GpBrush brush;
135 PathData pathdata;
136 ARGB centercolor;
137 GpWrapMode wrap;
138 BOOL gamma;
139 GpPointF center;
140 GpPointF focus;
141 REAL* blendfac; /* blend factors */
142 REAL* blendpos; /* blend positions */
143 INT blendcount;
144 };
145
146 struct GpLineGradient{
147 GpBrush brush;
148 GpPointF startpoint;
149 GpPointF endpoint;
150 ARGB startcolor;
151 ARGB endcolor;
152 RectF rect;
153 GpWrapMode wrap;
154 BOOL gamma;
155 REAL* blendfac; /* blend factors */
156 REAL* blendpos; /* blend positions */
157 INT blendcount;
158 };
159
160 struct GpTexture{
161 GpBrush brush;
162 GpMatrix *transform;
163 WrapMode wrap; /* not used yet */
164 };
165
166 struct GpPath{
167 GpFillMode fill;
168 GpPathData pathdata;
169 BOOL newfigure; /* whether the next drawing action starts a new figure */
170 INT datalen; /* size of the arrays in pathdata */
171 };
172
173 struct GpMatrix{
174 REAL matrix[6];
175 };
176
177 struct GpPathIterator{
178 GpPathData pathdata;
179 INT subpath_pos; /* for NextSubpath methods */
180 INT marker_pos; /* for NextMarker methods */
181 INT pathtype_pos; /* for NextPathType methods */
182 };
183
184 struct GpCustomLineCap{
185 GpPathData pathdata;
186 BOOL fill; /* TRUE for fill, FALSE for stroke */
187 GpLineCap cap; /* as far as I can tell, this value is ignored */
188 REAL inset; /* how much to adjust the end of the line */
189 GpLineJoin join;
190 REAL scale;
191 };
192
193 struct GpAdustableArrowCap{
194 GpCustomLineCap cap;
195 };
196
197 struct GpImage{
198 IPicture* picture;
199 ImageType type;
200 UINT flags;
201 };
202
203 struct GpMetafile{
204 GpImage image;
205 GpRectF bounds;
206 GpUnit unit;
207 };
208
209 struct GpBitmap{
210 GpImage image;
211 INT width;
212 INT height;
213 PixelFormat format;
214 ImageLockMode lockmode;
215 INT numlocks;
216 BYTE *bitmapbits; /* pointer to the buffer we passed in BitmapLockBits */
217 };
218
219 struct GpCachedBitmap{
220 GpImage *image;
221 };
222
223 struct GpImageAttributes{
224 WrapMode wrap;
225 };
226
227 struct GpFont{
228 LOGFONTW lfw;
229 REAL emSize;
230 UINT height;
231 LONG line_spacing;
232 Unit unit;
233 };
234
235 struct GpStringFormat{
236 INT attr;
237 LANGID lang;
238 LANGID digitlang;
239 StringAlignment align;
240 StringTrimming trimming;
241 HotkeyPrefix hkprefix;
242 StringAlignment vertalign;
243 StringDigitSubstitute digitsub;
244 INT tabcount;
245 REAL firsttab;
246 REAL *tabs;
247 };
248
249 struct GpFontCollection{
250 GpFontFamily **FontFamilies;
251 INT count;
252 INT allocated;
253 };
254
255 struct GpFontFamily{
256 NEWTEXTMETRICW tmw;
257 WCHAR FamilyName[LF_FACESIZE];
258 };
259
260 /* internal use */
261 typedef enum RegionType
262 {
263 RegionDataRect = 0x10000000,
264 RegionDataPath = 0x10000001,
265 RegionDataEmptyRect = 0x10000002,
266 RegionDataInfiniteRect = 0x10000003,
267 } RegionType;
268
269 struct region_element
270 {
271 DWORD type; /* Rectangle, Path, SpecialRectangle, or CombineMode */
272 union
273 {
274 GpRectF rect;
275 struct
276 {
277 GpPath* path;
278 struct
279 {
280 DWORD size;
281 DWORD magic;
282 DWORD count;
283 DWORD flags;
284 } pathheader;
285 } pathdata;
286 struct
287 {
288 struct region_element *left; /* the original region */
289 struct region_element *right; /* what *left was combined with */
290 } combine;
291 } elementdata;
292 };
293
294 struct GpRegion{
295 struct
296 {
297 DWORD size;
298 DWORD checksum;
299 DWORD magic;
300 DWORD num_children;
301 } header;
302 region_element node;
303 };
304
305 #endif