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