Merge PR #283 "[USBPORT] Transaction Translator (TT) support bringup"
[reactos.git] / dll / win32 / gdiplus / customlinecap.c
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 #include <stdarg.h>
20
21 #include "windef.h"
22 #include "winbase.h"
23 #include "wingdi.h"
24
25 #include "objbase.h"
26
27 #include "gdiplus.h"
28 #include "gdiplus_private.h"
29 #include "wine/debug.h"
30
31 WINE_DEFAULT_DEBUG_CHANNEL(gdiplus);
32
33 GpStatus WINGDIPAPI GdipCloneCustomLineCap(GpCustomLineCap* from,
34 GpCustomLineCap** to)
35 {
36 TRACE("(%p, %p)\n", from, to);
37
38 if(!from || !to)
39 return InvalidParameter;
40
41 *to = heap_alloc_zero(sizeof(GpCustomLineCap));
42 if(!*to) return OutOfMemory;
43
44 memcpy(*to, from, sizeof(GpCustomLineCap));
45
46 (*to)->pathdata.Points = heap_alloc_zero(from->pathdata.Count * sizeof(PointF));
47 (*to)->pathdata.Types = heap_alloc_zero(from->pathdata.Count);
48
49 if((!(*to)->pathdata.Types || !(*to)->pathdata.Points) && (*to)->pathdata.Count){
50 heap_free((*to)->pathdata.Points);
51 heap_free((*to)->pathdata.Types);
52 heap_free(*to);
53 return OutOfMemory;
54 }
55
56 memcpy((*to)->pathdata.Points, from->pathdata.Points, from->pathdata.Count
57 * sizeof(PointF));
58 memcpy((*to)->pathdata.Types, from->pathdata.Types, from->pathdata.Count);
59
60 TRACE("<-- %p\n", *to);
61
62 return Ok;
63 }
64
65 /* FIXME: Sometimes when fillPath is non-null and stroke path is null, the native
66 * version of this function returns NotImplemented. I cannot figure out why. */
67 GpStatus WINGDIPAPI GdipCreateCustomLineCap(GpPath* fillPath, GpPath* strokePath,
68 GpLineCap baseCap, REAL baseInset, GpCustomLineCap **customCap)
69 {
70 GpPathData *pathdata;
71
72 TRACE("%p %p %d %f %p\n", fillPath, strokePath, baseCap, baseInset, customCap);
73
74 if(!customCap || !(fillPath || strokePath))
75 return InvalidParameter;
76
77 *customCap = heap_alloc_zero(sizeof(GpCustomLineCap));
78 if(!*customCap) return OutOfMemory;
79
80 (*customCap)->type = CustomLineCapTypeDefault;
81 if(strokePath){
82 (*customCap)->fill = FALSE;
83 pathdata = &strokePath->pathdata;
84 }
85 else{
86 (*customCap)->fill = TRUE;
87 pathdata = &fillPath->pathdata;
88 }
89
90 (*customCap)->pathdata.Points = heap_alloc_zero(pathdata->Count * sizeof(PointF));
91 (*customCap)->pathdata.Types = heap_alloc_zero(pathdata->Count);
92
93 if((!(*customCap)->pathdata.Types || !(*customCap)->pathdata.Points) &&
94 pathdata->Count){
95 heap_free((*customCap)->pathdata.Points);
96 heap_free((*customCap)->pathdata.Types);
97 heap_free(*customCap);
98 return OutOfMemory;
99 }
100
101 memcpy((*customCap)->pathdata.Points, pathdata->Points, pathdata->Count
102 * sizeof(PointF));
103 memcpy((*customCap)->pathdata.Types, pathdata->Types, pathdata->Count);
104 (*customCap)->pathdata.Count = pathdata->Count;
105
106 (*customCap)->inset = baseInset;
107 (*customCap)->cap = baseCap;
108 (*customCap)->join = LineJoinMiter;
109 (*customCap)->scale = 1.0;
110
111 TRACE("<-- %p\n", *customCap);
112
113 return Ok;
114 }
115
116 GpStatus WINGDIPAPI GdipDeleteCustomLineCap(GpCustomLineCap *customCap)
117 {
118 TRACE("(%p)\n", customCap);
119
120 if(!customCap)
121 return InvalidParameter;
122
123 heap_free(customCap->pathdata.Points);
124 heap_free(customCap->pathdata.Types);
125 heap_free(customCap);
126
127 return Ok;
128 }
129
130 GpStatus WINGDIPAPI GdipGetCustomLineCapStrokeJoin(GpCustomLineCap* customCap,
131 GpLineJoin* lineJoin)
132 {
133 TRACE("(%p, %p)\n", customCap, lineJoin);
134
135 if(!customCap || !lineJoin)
136 return InvalidParameter;
137
138 *lineJoin = customCap->join;
139
140 return Ok;
141 }
142
143 GpStatus WINGDIPAPI GdipGetCustomLineCapWidthScale(GpCustomLineCap* custom,
144 REAL* widthScale)
145 {
146 TRACE("(%p, %p)\n", custom, widthScale);
147
148 if(!custom || !widthScale)
149 return InvalidParameter;
150
151 *widthScale = custom->scale;
152
153 return Ok;
154 }
155
156 GpStatus WINGDIPAPI GdipSetCustomLineCapStrokeCaps(GpCustomLineCap* custom,
157 GpLineCap start, GpLineCap end)
158 {
159 static int calls;
160
161 TRACE("(%p,%u,%u)\n", custom, start, end);
162
163 if(!custom)
164 return InvalidParameter;
165
166 if(!(calls++))
167 FIXME("not implemented\n");
168
169 return NotImplemented;
170 }
171
172 GpStatus WINGDIPAPI GdipSetCustomLineCapBaseCap(GpCustomLineCap* custom,
173 GpLineCap base)
174 {
175 static int calls;
176
177 TRACE("(%p,%u)\n", custom, base);
178
179 if(!(calls++))
180 FIXME("not implemented\n");
181
182 return NotImplemented;
183 }
184
185 GpStatus WINGDIPAPI GdipGetCustomLineCapBaseInset(GpCustomLineCap* custom,
186 REAL* inset)
187 {
188 TRACE("(%p, %p)\n", custom, inset);
189
190 if(!custom || !inset)
191 return InvalidParameter;
192
193 *inset = custom->inset;
194
195 return Ok;
196 }
197
198 GpStatus WINGDIPAPI GdipSetCustomLineCapBaseInset(GpCustomLineCap* custom,
199 REAL inset)
200 {
201 static int calls;
202
203 TRACE("(%p,%0.2f)\n", custom, inset);
204
205 if(!(calls++))
206 FIXME("not implemented\n");
207
208 return NotImplemented;
209 }
210
211 /*FIXME: LineJoin completely ignored now */
212 GpStatus WINGDIPAPI GdipSetCustomLineCapStrokeJoin(GpCustomLineCap* custom,
213 GpLineJoin join)
214 {
215 TRACE("(%p, %d)\n", custom, join);
216
217 if(!custom)
218 return InvalidParameter;
219
220 custom->join = join;
221
222 return Ok;
223 }
224
225 GpStatus WINGDIPAPI GdipSetCustomLineCapWidthScale(GpCustomLineCap* custom, REAL width)
226 {
227 TRACE("(%p,%0.2f)\n", custom, width);
228
229 if(!custom)
230 return InvalidParameter;
231
232 custom->scale = width;
233
234 return Ok;
235 }
236
237 GpStatus WINGDIPAPI GdipGetCustomLineCapBaseCap(GpCustomLineCap *customCap, GpLineCap *baseCap)
238 {
239 TRACE("(%p, %p)\n", customCap, baseCap);
240
241 if(!customCap || !baseCap)
242 return InvalidParameter;
243
244 *baseCap = customCap->cap;
245
246 return Ok;
247 }
248
249 GpStatus WINGDIPAPI GdipGetCustomLineCapType(GpCustomLineCap *customCap, CustomLineCapType *type)
250 {
251 TRACE("(%p, %p)\n", customCap, type);
252
253 if(!customCap || !type)
254 return InvalidParameter;
255
256 *type = customCap->type;
257 return Ok;
258 }
259
260 GpStatus WINGDIPAPI GdipCreateAdjustableArrowCap(REAL height, REAL width, BOOL fill,
261 GpAdjustableArrowCap **cap)
262 {
263 static int calls;
264
265 TRACE("(%0.2f,%0.2f,%i,%p)\n", height, width, fill, cap);
266
267 if(!(calls++))
268 FIXME("not implemented\n");
269
270 return NotImplemented;
271 }
272
273 GpStatus WINGDIPAPI GdipGetAdjustableArrowCapFillState(GpAdjustableArrowCap* cap, BOOL* fill)
274 {
275 static int calls;
276
277 TRACE("(%p,%p)\n", cap, fill);
278
279 if(!(calls++))
280 FIXME("not implemented\n");
281
282 return NotImplemented;
283 }
284
285 GpStatus WINGDIPAPI GdipGetAdjustableArrowCapHeight(GpAdjustableArrowCap* cap, REAL* height)
286 {
287 static int calls;
288
289 TRACE("(%p,%p)\n", cap, height);
290
291 if(!(calls++))
292 FIXME("not implemented\n");
293
294 return NotImplemented;
295 }
296
297 GpStatus WINGDIPAPI GdipGetAdjustableArrowCapMiddleInset(GpAdjustableArrowCap* cap, REAL* middle)
298 {
299 static int calls;
300
301 TRACE("(%p,%p)\n", cap, middle);
302
303 if(!(calls++))
304 FIXME("not implemented\n");
305
306 return NotImplemented;
307 }
308
309 GpStatus WINGDIPAPI GdipGetAdjustableArrowCapWidth(GpAdjustableArrowCap* cap, REAL* width)
310 {
311 static int calls;
312
313 TRACE("(%p,%p)\n", cap, width);
314
315 if(!(calls++))
316 FIXME("not implemented\n");
317
318 return NotImplemented;
319 }
320
321 GpStatus WINGDIPAPI GdipSetAdjustableArrowCapFillState(GpAdjustableArrowCap* cap, BOOL fill)
322 {
323 static int calls;
324
325 TRACE("(%p,%i)\n", cap, fill);
326
327 if(!(calls++))
328 FIXME("not implemented\n");
329
330 return NotImplemented;
331 }
332
333 GpStatus WINGDIPAPI GdipSetAdjustableArrowCapHeight(GpAdjustableArrowCap* cap, REAL height)
334 {
335 static int calls;
336
337 TRACE("(%p,%0.2f)\n", cap, height);
338
339 if(!(calls++))
340 FIXME("not implemented\n");
341
342 return NotImplemented;
343 }
344
345 GpStatus WINGDIPAPI GdipSetAdjustableArrowCapMiddleInset(GpAdjustableArrowCap* cap, REAL middle)
346 {
347 static int calls;
348
349 TRACE("(%p,%0.2f)\n", cap, middle);
350
351 if(!(calls++))
352 FIXME("not implemented\n");
353
354 return NotImplemented;
355 }
356
357 GpStatus WINGDIPAPI GdipSetAdjustableArrowCapWidth(GpAdjustableArrowCap* cap, REAL width)
358 {
359 static int calls;
360
361 TRACE("(%p,%0.2f)\n", cap, width);
362
363 if(!(calls++))
364 FIXME("not implemented\n");
365
366 return NotImplemented;
367 }