user32: Add an ASCII window procedure for scrollbars.
[wine/wine64.git] / dlls / gdiplus / pathiterator.c
blobd1e4e88bf97c35b2ec5083283292238df2d5dc7c
1 /*
2 * Copyright (C) 2007 Google (Evan Stade)
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.
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.
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
19 #include <stdarg.h>
21 #include "windef.h"
22 #include "winbase.h"
23 #include "wingdi.h"
25 #include "objbase.h"
27 #include "gdiplus.h"
28 #include "gdiplus_private.h"
30 GpStatus WINGDIPAPI GdipCreatePathIter(GpPathIterator **iterator, GpPath* path)
32 INT size;
34 if(!iterator || !path)
35 return InvalidParameter;
37 size = path->pathdata.Count;
39 *iterator = GdipAlloc(sizeof(GpPathIterator));
40 if(!*iterator) return OutOfMemory;
42 (*iterator)->pathdata.Types = GdipAlloc(size);
43 (*iterator)->pathdata.Points = GdipAlloc(size * sizeof(PointF));
45 memcpy((*iterator)->pathdata.Types, path->pathdata.Types, size);
46 memcpy((*iterator)->pathdata.Points, path->pathdata.Points,
47 size * sizeof(PointF));
48 (*iterator)->pathdata.Count = size;
50 (*iterator)->subpath_pos = 0;
51 (*iterator)->marker_pos = 0;
52 (*iterator)->pathtype_pos = 0;
54 return Ok;
57 GpStatus WINGDIPAPI GdipDeletePathIter(GpPathIterator *iter)
59 if(!iter)
60 return InvalidParameter;
62 GdipFree(iter->pathdata.Types);
63 GdipFree(iter->pathdata.Points);
64 GdipFree(iter);
66 return Ok;
69 GpStatus WINGDIPAPI GdipPathIterCopyData(GpPathIterator* iterator,
70 INT* resultCount, GpPointF* points, BYTE* types, INT startIndex, INT endIndex)
72 if(!iterator || !types || !points)
73 return InvalidParameter;
75 if(endIndex > iterator->pathdata.Count - 1 || startIndex < 0 ||
76 endIndex < startIndex){
77 *resultCount = 0;
78 return Ok;
81 *resultCount = endIndex - startIndex + 1;
83 memcpy(types, &(iterator->pathdata.Types[startIndex]), *resultCount);
84 memcpy(points, &(iterator->pathdata.Points[startIndex]),
85 *resultCount * sizeof(PointF));
87 return Ok;
90 GpStatus WINGDIPAPI GdipPathIterNextSubpath(GpPathIterator* iterator,
91 INT *resultCount, INT* startIndex, INT* endIndex, BOOL* isClosed)
93 INT i, count;
95 if(!iterator)
96 return InvalidParameter;
98 count = iterator->pathdata.Count;
100 if(iterator->subpath_pos == count){
101 *startIndex = *endIndex = *resultCount = 0;
102 *isClosed = 1;
103 return Ok;
106 *startIndex = iterator->subpath_pos;
108 for(i = iterator->subpath_pos + 1; i < count &&
109 !(iterator->pathdata.Types[i] == PathPointTypeStart); i++);
111 *endIndex = i - 1;
112 iterator->subpath_pos = i;
114 *resultCount = *endIndex - *startIndex + 1;
116 if(iterator->pathdata.Types[*endIndex] & PathPointTypeCloseSubpath)
117 *isClosed = TRUE;
118 else
119 *isClosed = FALSE;
121 return Ok;
123 GpStatus WINGDIPAPI GdipPathIterRewind(GpPathIterator *iterator)
125 if(!iterator)
126 return InvalidParameter;
128 iterator->subpath_pos = 0;
129 iterator->marker_pos = 0;
130 iterator->pathtype_pos = 0;
132 return Ok;