user32: Reimplement 16-bit clipboard functions on top of the 32-bit ones.
[wine] / dlls / 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 = GdipAlloc(sizeof(GpCustomLineCap));
42     if(!*to)   return OutOfMemory;
43
44     memcpy(*to, from, sizeof(GpCustomLineCap));
45
46     (*to)->pathdata.Points = GdipAlloc(from->pathdata.Count * sizeof(PointF));
47     (*to)->pathdata.Types = GdipAlloc(from->pathdata.Count);
48
49     if((!(*to)->pathdata.Types  || !(*to)->pathdata.Points) && (*to)->pathdata.Count){
50         GdipFree((*to)->pathdata.Points);
51         GdipFree((*to)->pathdata.Types);
52         GdipFree(*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 = GdipAlloc(sizeof(GpCustomLineCap));
78     if(!*customCap)    return OutOfMemory;
79
80     if(strokePath){
81         (*customCap)->fill = FALSE;
82         pathdata = &strokePath->pathdata;
83     }
84     else{
85         (*customCap)->fill = TRUE;
86         pathdata = &fillPath->pathdata;
87     }
88
89     (*customCap)->pathdata.Points = GdipAlloc(pathdata->Count * sizeof(PointF));
90     (*customCap)->pathdata.Types = GdipAlloc(pathdata->Count);
91
92     if((!(*customCap)->pathdata.Types || !(*customCap)->pathdata.Points) &&
93         pathdata->Count){
94         GdipFree((*customCap)->pathdata.Points);
95         GdipFree((*customCap)->pathdata.Types);
96         GdipFree(*customCap);
97         return OutOfMemory;
98     }
99
100     memcpy((*customCap)->pathdata.Points, pathdata->Points, pathdata->Count
101            * sizeof(PointF));
102     memcpy((*customCap)->pathdata.Types, pathdata->Types, pathdata->Count);
103     (*customCap)->pathdata.Count = pathdata->Count;
104
105     (*customCap)->inset = baseInset;
106     (*customCap)->cap = baseCap;
107     (*customCap)->join = LineJoinMiter;
108     (*customCap)->scale = 1.0;
109
110     TRACE("<-- %p\n", *customCap);
111
112     return Ok;
113 }
114
115 GpStatus WINGDIPAPI GdipDeleteCustomLineCap(GpCustomLineCap *customCap)
116 {
117     TRACE("(%p)\n", customCap);
118
119     if(!customCap)
120         return InvalidParameter;
121
122     GdipFree(customCap->pathdata.Points);
123     GdipFree(customCap->pathdata.Types);
124     GdipFree(customCap);
125
126     return Ok;
127 }
128
129 GpStatus WINGDIPAPI GdipGetCustomLineCapStrokeJoin(GpCustomLineCap* customCap,
130     GpLineJoin* lineJoin)
131 {
132     TRACE("(%p, %p)\n", customCap, lineJoin);
133
134     if(!customCap || !lineJoin)
135         return InvalidParameter;
136
137     *lineJoin = customCap->join;
138
139     return Ok;
140 }
141
142 GpStatus WINGDIPAPI GdipGetCustomLineCapWidthScale(GpCustomLineCap* custom,
143     REAL* widthScale)
144 {
145     TRACE("(%p, %p)\n", custom, widthScale);
146
147     if(!custom || !widthScale)
148         return InvalidParameter;
149
150     *widthScale = custom->scale;
151
152     return Ok;
153 }
154
155 GpStatus WINGDIPAPI GdipSetCustomLineCapStrokeCaps(GpCustomLineCap* custom,
156     GpLineCap start, GpLineCap end)
157 {
158     static int calls;
159
160     if(!custom)
161         return InvalidParameter;
162
163     if(!(calls++))
164         FIXME("not implemented\n");
165
166     return NotImplemented;
167 }
168
169 GpStatus WINGDIPAPI GdipSetCustomLineCapBaseCap(GpCustomLineCap* custom,
170     GpLineCap base)
171 {
172     static int calls;
173
174     if(!(calls++))
175         FIXME("not implemented\n");
176
177     return NotImplemented;
178 }
179
180 GpStatus WINGDIPAPI GdipGetCustomLineCapBaseInset(GpCustomLineCap* custom,
181     REAL* inset)
182 {
183     TRACE("(%p, %p)\n", custom, inset);
184
185     if(!custom || !inset)
186         return InvalidParameter;
187
188     *inset = custom->inset;
189
190     return Ok;
191 }
192
193 GpStatus WINGDIPAPI GdipSetCustomLineCapBaseInset(GpCustomLineCap* custom,
194     REAL inset)
195 {
196     static int calls;
197
198     if(!(calls++))
199         FIXME("not implemented\n");
200
201     return NotImplemented;
202 }
203
204 /*FIXME: LineJoin completely ignored now */
205 GpStatus WINGDIPAPI GdipSetCustomLineCapStrokeJoin(GpCustomLineCap* custom,
206     GpLineJoin join)
207 {
208     TRACE("(%p, %d)\n", custom, join);
209
210     if(!custom)
211         return InvalidParameter;
212
213     custom->join = join;
214
215     return Ok;
216 }
217
218 GpStatus WINGDIPAPI GdipSetCustomLineCapWidthScale(GpCustomLineCap* custom,
219     REAL width)
220 {
221     static int calls;
222
223     if(!(calls++))
224         FIXME("not implemented\n");
225
226     return NotImplemented;
227 }
228
229 GpStatus WINGDIPAPI GdipGetCustomLineCapBaseCap(GpCustomLineCap *customCap, GpLineCap *baseCap)
230 {
231     TRACE("(%p, %p)\n", customCap, baseCap);
232
233     if(!customCap || !baseCap)
234         return InvalidParameter;
235
236     *baseCap = customCap->cap;
237
238     return Ok;
239 }
240
241 GpStatus WINGDIPAPI GdipCreateAdjustableArrowCap(REAL height, REAL width, BOOL fill,
242     GpAdjustableArrowCap **cap)
243 {
244     static int calls;
245
246     if(!(calls++))
247         FIXME("not implemented\n");
248
249     return NotImplemented;
250 }
251
252 GpStatus WINGDIPAPI GdipGetAdjustableArrowCapFillState(GpAdjustableArrowCap* cap, BOOL* fill)
253 {
254     static int calls;
255
256     if(!(calls++))
257         FIXME("not implemented\n");
258
259     return NotImplemented;
260 }
261
262 GpStatus WINGDIPAPI GdipGetAdjustableArrowCapHeight(GpAdjustableArrowCap* cap, REAL* height)
263 {
264     static int calls;
265
266     if(!(calls++))
267         FIXME("not implemented\n");
268
269     return NotImplemented;
270 }
271
272 GpStatus WINGDIPAPI GdipGetAdjustableArrowCapMiddleInset(GpAdjustableArrowCap* cap, REAL* middle)
273 {
274     static int calls;
275
276     if(!(calls++))
277         FIXME("not implemented\n");
278
279     return NotImplemented;
280 }
281
282 GpStatus WINGDIPAPI GdipGetAdjustableArrowCapWidth(GpAdjustableArrowCap* cap, REAL* width)
283 {
284     static int calls;
285
286     if(!(calls++))
287         FIXME("not implemented\n");
288
289     return NotImplemented;
290 }
291
292 GpStatus WINGDIPAPI GdipSetAdjustableArrowCapFillState(GpAdjustableArrowCap* cap, BOOL fill)
293 {
294     static int calls;
295
296     if(!(calls++))
297         FIXME("not implemented\n");
298
299     return NotImplemented;
300 }
301
302 GpStatus WINGDIPAPI GdipSetAdjustableArrowCapHeight(GpAdjustableArrowCap* cap, REAL height)
303 {
304     static int calls;
305
306     if(!(calls++))
307         FIXME("not implemented\n");
308
309     return NotImplemented;
310 }
311
312 GpStatus WINGDIPAPI GdipSetAdjustableArrowCapMiddleInset(GpAdjustableArrowCap* cap, REAL middle)
313 {
314     static int calls;
315
316     if(!(calls++))
317         FIXME("not implemented\n");
318
319     return NotImplemented;
320 }
321
322 GpStatus WINGDIPAPI GdipSetAdjustableArrowCapWidth(GpAdjustableArrowCap* cap, REAL width)
323 {
324     static int calls;
325
326     if(!(calls++))
327         FIXME("not implemented\n");
328
329     return NotImplemented;
330 }