Add a .gitattributes with "* text=auto" so that new lines are
[pdfium.git] / core / src / fxge / Microsoft SDK / include / GdiPlusRegion.h
1 /**************************************************************************\
2 *
3 * Copyright (c) 1998-2000, Microsoft Corp.  All Rights Reserved.
4 *
5 * Module Name:
6 *
7 *   GdiplusRegion.h
8 *
9 * Abstract:
10 *
11 *   Region API related declarations
12 *
13 \**************************************************************************/
14
15 #ifndef _GDIPLUSREGION_H
16 #define _GDIPLUSREGION_H
17
18 /**
19  * Construct a new region object
20  */
21
22 inline 
23 Region::Region()
24 {
25     GpRegion *region = NULL;
26
27     lastResult = DllExports::GdipCreateRegion(&region);
28
29     SetNativeRegion(region);
30 }
31
32 inline 
33 Region::Region(IN const RectF& rect)
34 {
35     GpRegion *region = NULL;
36
37     lastResult = DllExports::GdipCreateRegionRect(&rect, &region);
38
39     SetNativeRegion(region);
40 }
41
42 inline 
43 Region::Region(IN const Rect& rect)
44 {
45     GpRegion *region = NULL;
46
47     lastResult = DllExports::GdipCreateRegionRectI(&rect, &region);
48
49     SetNativeRegion(region);
50 }
51
52 inline 
53 Region::Region(IN const GraphicsPath* path)
54 {
55     GpRegion *region = NULL;
56
57     lastResult = DllExports::GdipCreateRegionPath(path->nativePath, &region);
58
59     SetNativeRegion(region);
60 }
61
62 inline 
63 Region::Region(IN const BYTE* regionData, IN INT size)
64 {
65     GpRegion *region = NULL;
66
67     lastResult = DllExports::GdipCreateRegionRgnData(regionData, size, &region);
68
69     SetNativeRegion(region);
70 }
71
72 inline 
73 Region::Region(IN HRGN hRgn)
74 {
75     GpRegion *region = NULL;
76
77     lastResult = DllExports::GdipCreateRegionHrgn(hRgn, &region);
78
79     SetNativeRegion(region);
80 }
81
82 inline 
83 Region* Region::FromHRGN(IN HRGN hRgn)
84 {
85     GpRegion *region = NULL;
86
87     if (DllExports::GdipCreateRegionHrgn(hRgn, &region) == Ok)
88     {
89         Region* newRegion = new Region(region);
90
91         if (newRegion == NULL) 
92         {
93             DllExports::GdipDeleteRegion(region);
94         }
95
96         return newRegion;
97     }
98     else
99         return NULL;
100 }
101
102 inline 
103 Region::~Region()
104 {
105     DllExports::GdipDeleteRegion(nativeRegion);
106 }
107
108 /**
109  * Make a copy of the region object
110  */
111 inline Region* 
112 Region::Clone() const
113 {
114     GpRegion *region = NULL;
115
116     SetStatus(DllExports::GdipCloneRegion(nativeRegion, &region));
117
118     return new Region(region);
119 }
120
121 inline Status 
122 Region::MakeInfinite()
123 {
124     return SetStatus(DllExports::GdipSetInfinite(nativeRegion));
125 }
126
127 inline Status 
128 Region::MakeEmpty()
129 {
130     return SetStatus(DllExports::GdipSetEmpty(nativeRegion));
131 }
132
133 /**
134  * Region operations
135  */
136 inline Status 
137 Region::Intersect(IN const RectF& rect)
138 {
139     return SetStatus(DllExports::GdipCombineRegionRect(nativeRegion, &rect, CombineModeIntersect));
140 }
141
142 inline Status 
143 Region::Intersect(IN const Rect& rect)
144 {
145     return SetStatus(DllExports::GdipCombineRegionRectI(nativeRegion, &rect, CombineModeIntersect));
146 }
147
148 inline Status 
149 Region::Intersect(IN const GraphicsPath* path)
150 {
151     return SetStatus(DllExports::GdipCombineRegionPath(nativeRegion, path->nativePath, CombineModeIntersect));
152 }
153
154 inline Status 
155 Region::Intersect(IN const Region* region)
156 {
157     return SetStatus(DllExports::GdipCombineRegionRegion(nativeRegion, region->nativeRegion, CombineModeIntersect));
158 }
159
160 inline Status 
161 Region::Union(IN const RectF& rect)
162 {
163     return SetStatus(DllExports::GdipCombineRegionRect(nativeRegion, &rect, CombineModeUnion));
164 }
165
166 inline Status 
167 Region::Union(IN const Rect& rect)
168 {
169     return SetStatus(DllExports::GdipCombineRegionRectI(nativeRegion, &rect, CombineModeUnion));
170 }
171
172 inline Status 
173 Region::Union(IN const GraphicsPath* path)
174 {
175     return SetStatus(DllExports::GdipCombineRegionPath(nativeRegion, path->nativePath, CombineModeUnion));
176 }
177
178 inline Status 
179 Region::Union(IN const Region* region)
180 {
181     return SetStatus(DllExports::GdipCombineRegionRegion(nativeRegion, region->nativeRegion, CombineModeUnion));
182 }
183
184 inline Status 
185 Region::Xor(IN const RectF& rect)
186 {
187     return SetStatus(DllExports::GdipCombineRegionRect(nativeRegion, &rect, CombineModeXor));
188 }
189
190 inline Status 
191 Region::Xor(IN const Rect& rect)
192 {
193     return SetStatus(DllExports::GdipCombineRegionRectI(nativeRegion, &rect, CombineModeXor));
194 }
195
196 inline Status 
197 Region::Xor(IN const GraphicsPath* path)
198 {
199     return SetStatus(DllExports::GdipCombineRegionPath(nativeRegion, path->nativePath, CombineModeXor));
200 }
201
202 inline Status 
203 Region::Xor(IN const Region* region)
204 {
205     return SetStatus(DllExports::GdipCombineRegionRegion(nativeRegion, region->nativeRegion, CombineModeXor));
206 }
207
208 inline Status 
209 Region::Exclude(IN const RectF& rect)
210 {
211     return SetStatus(DllExports::GdipCombineRegionRect(nativeRegion, &rect, CombineModeExclude));
212 }
213
214 inline Status 
215 Region::Exclude(IN const Rect& rect)
216 {
217      return SetStatus(DllExports::GdipCombineRegionRectI(nativeRegion, &rect, CombineModeExclude));
218 }
219
220 inline Status 
221 Region::Exclude(IN const GraphicsPath* path)
222 {
223     return SetStatus(DllExports::GdipCombineRegionPath(nativeRegion, path->nativePath, CombineModeExclude));
224 }
225
226 inline Status
227 Region::Exclude(IN const Region* region)
228 {
229     return SetStatus(DllExports::GdipCombineRegionRegion(nativeRegion,
230                                                region->nativeRegion, CombineModeExclude));
231 }
232
233 inline Status 
234 Region::Complement(IN const RectF& rect)
235 {
236     return SetStatus(DllExports::GdipCombineRegionRect(nativeRegion, &rect, CombineModeComplement));
237 }
238
239 inline Status 
240 Region::Complement(IN const Rect& rect)
241 {
242     return SetStatus(DllExports::GdipCombineRegionRectI(nativeRegion, &rect, CombineModeComplement));
243 }
244
245 inline Status 
246 Region::Complement(IN const GraphicsPath* path)
247 {
248     return SetStatus(DllExports::GdipCombineRegionPath(nativeRegion,
249                                                 path->nativePath, CombineModeComplement));
250 }
251
252 inline Status 
253 Region::Complement(IN const Region* region)
254 {
255     return SetStatus(DllExports::GdipCombineRegionRegion(nativeRegion,
256                                                   region->nativeRegion, CombineModeComplement));
257 }
258
259 /**
260  * Transform operations
261  */
262 inline Status 
263 Region::Translate(IN REAL dx, 
264                   IN REAL dy)
265 {
266     return SetStatus(DllExports::GdipTranslateRegion(nativeRegion, dx, dy));
267 }
268
269 inline Status 
270 Region::Translate(IN INT dx, 
271                   IN INT dy)
272 {
273     return SetStatus(DllExports::GdipTranslateRegionI(nativeRegion, dx, dy));
274 }
275
276 inline Status 
277 Region::Transform(IN const Matrix* matrix)
278 {
279     return SetStatus(DllExports::GdipTransformRegion(nativeRegion, matrix->nativeMatrix));
280 }
281
282 /**
283  * Get region attributes
284  */
285 inline Status 
286 Region::GetBounds(OUT RectF* rect,
287                   IN const Graphics* g) const
288 {
289     return SetStatus(DllExports::GdipGetRegionBounds(nativeRegion,
290                                                 g->nativeGraphics,
291                                                 rect));
292 }
293
294 inline Status 
295 Region::GetBounds(OUT Rect* rect,
296                   IN const Graphics* g) const
297 {
298     return SetStatus(DllExports::GdipGetRegionBoundsI(nativeRegion,
299                                                 g->nativeGraphics,
300                                                 rect));
301 }
302
303 inline HRGN
304 Region::GetHRGN(IN const Graphics* g) const
305 {
306     HRGN hrgn;
307
308     SetStatus(DllExports::GdipGetRegionHRgn(nativeRegion,
309                                             g->nativeGraphics,
310                                             &hrgn));
311
312     return hrgn;
313 }
314
315 inline BOOL 
316 Region::IsEmpty(IN const Graphics *g) const
317 {
318     BOOL booln = FALSE;
319    
320     SetStatus(DllExports::GdipIsEmptyRegion(nativeRegion,
321                                             g->nativeGraphics,
322                                             &booln));
323
324     return booln;
325 }
326
327 inline BOOL 
328 Region::IsInfinite(IN const Graphics *g) const
329 {
330     BOOL booln = FALSE;
331
332     SetStatus(DllExports::GdipIsInfiniteRegion(nativeRegion,
333                                                  g->nativeGraphics,
334                                                  &booln));
335
336     return booln;
337 }
338
339 inline BOOL 
340 Region::Equals(IN const Region* region, 
341                IN const Graphics* g) const
342 {
343     BOOL booln = FALSE;
344
345     SetStatus(DllExports::GdipIsEqualRegion(nativeRegion,
346                                               region->nativeRegion,
347                                               g->nativeGraphics,
348                                               &booln));
349     return booln;
350 }
351
352 // Get the size of the buffer needed for the GetData method
353 inline UINT 
354 Region::GetDataSize() const
355 {
356     UINT     bufferSize = 0;
357     
358     SetStatus(DllExports::GdipGetRegionDataSize(nativeRegion, &bufferSize));
359     
360     return bufferSize;
361 }
362
363 // buffer     - where to put the data
364 // bufferSize - how big the buffer is (should be at least as big as GetDataSize())
365 // sizeFilled - if not NULL, this is an OUT param that says how many bytes
366 //              of data were written to the buffer.
367 inline Status 
368 Region::GetData(OUT BYTE* buffer, 
369                 IN UINT bufferSize, 
370                 OUT UINT* sizeFilled) const
371 {
372     return SetStatus(DllExports::GdipGetRegionData(nativeRegion, buffer, bufferSize, sizeFilled));
373 }
374
375 /**
376  * Hit testing operations
377  */
378 inline BOOL 
379 Region::IsVisible(IN const PointF& point, 
380                   IN const Graphics* g) const
381 {
382     BOOL booln = FALSE;
383
384     SetStatus(DllExports::GdipIsVisibleRegionPoint(nativeRegion,
385                                      point.X, point.Y, 
386                                      (g == NULL) ? NULL : g->nativeGraphics,
387                                      &booln));
388     return booln;
389 }
390
391 inline BOOL 
392 Region::IsVisible(IN const RectF& rect, 
393                   IN const Graphics* g) const
394 {
395     BOOL booln = FALSE;
396
397     SetStatus(DllExports::GdipIsVisibleRegionRect(nativeRegion, rect.X,
398                                                     rect.Y, rect.Width,
399                                                     rect.Height,
400                                                     (g == NULL) ? NULL : g->nativeGraphics,
401                                                     &booln));
402     return booln;
403 }
404
405 inline BOOL 
406 Region::IsVisible(IN const Point& point, 
407                   IN const Graphics* g) const
408 {
409     BOOL booln = FALSE;
410
411
412     SetStatus(DllExports::GdipIsVisibleRegionPointI(nativeRegion,
413                                                    point.X,
414                                                    point.Y,
415                                                    (g == NULL) ? NULL : g->nativeGraphics,
416                                                    &booln));
417     return booln;
418 }
419
420 inline BOOL 
421 Region::IsVisible(IN const Rect& rect, 
422                   IN const Graphics* g) const
423 {
424     BOOL booln = FALSE;
425
426     SetStatus(DllExports::GdipIsVisibleRegionRectI(nativeRegion,
427                                                   rect.X,
428                                                   rect.Y,
429                                                   rect.Width,
430                                                   rect.Height,
431                                                   (g == NULL) ? NULL : g->nativeGraphics,
432                                                   &booln));
433     return booln;
434 }
435
436 inline UINT 
437 Region::GetRegionScansCount(IN const Matrix* matrix) const
438 {
439     UINT count = 0;
440
441     SetStatus(DllExports::GdipGetRegionScansCount(nativeRegion,
442                                                   &count,
443                                                   matrix->nativeMatrix));
444     return count;
445 }
446
447 inline Status 
448 Region::GetRegionScans(
449     IN const Matrix* matrix,
450     OUT RectF* rects,
451     IN OUT INT* count) const
452 {
453     return SetStatus(DllExports::GdipGetRegionScans(nativeRegion,
454                                           rects,
455                                           count,
456                                           matrix->nativeMatrix));
457 }
458
459 // If rects is NULL, return the count of rects in the region.
460 // Otherwise, assume rects is big enough to hold all the region rects
461 // and fill them in and return the number of rects filled in.
462 // The rects are returned in the units specified by the matrix
463 // (which is typically a world-to-device transform).
464 // Note that the number of rects returned can vary, depending on the
465 // matrix that is used.
466 inline Status 
467 Region::GetRegionScans(
468     IN const Matrix* matrix,
469     OUT Rect* rects,       // NULL to just get the count
470     IN OUT INT* count) const
471 {
472     return SetStatus(DllExports::GdipGetRegionScansI(nativeRegion,
473                                           rects,
474                                           count,
475                                           matrix->nativeMatrix));
476 }
477
478 // protected method
479 inline Region::Region(GpRegion* nativeRegion)
480 {
481     SetNativeRegion(nativeRegion);
482 }
483
484 // protected method
485 inline VOID Region::SetNativeRegion(GpRegion* nativeRegion)
486 {
487     this->nativeRegion = nativeRegion;
488 }
489
490 inline Status Region::GetLastStatus() const
491 {
492     Status lastStatus = lastResult;
493     lastResult = Ok;
494
495     return lastStatus;
496 }
497
498 #endif // !_GDIPLUSREGION_H