svn update: 48958 (latest:48959)
[framework/uifw/ecore.git] / src / lib / ecore_x / xlib / ecore_x_region.c
1 /*
2  * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
3  */
4
5 #ifdef HAVE_CONFIG_H
6 # include <config.h>
7 #endif
8
9 #include "ecore_x_private.h"
10
11
12 /*
13  * [x] XCreateRegion
14  * [ ] XPolygonRegion
15  * [x] XSetRegion
16  * [x] XDestroyRegion
17  *
18  * [x] XOffsetRegion
19  * [ ] XShrinkRegion
20  *
21  * [ ] XClipBox
22  * [x] XIntersectRegion
23  * [x] XUnionRegion
24  * [x] XUnionRectWithRegion
25  * [x] XSubtractRegion
26  * [ ] XXorRegion
27  *
28  * [x] XEmptyRegion
29  * [x] XEqualRegion
30  *
31  * [x] XPointInRegion
32  * [x] XRectInRegion
33  */
34
35 EAPI Ecore_X_XRegion *
36 ecore_x_xregion_new()
37 {
38    LOGFN(__FILE__, __LINE__, __FUNCTION__);
39    return (Ecore_X_XRegion *)XCreateRegion();
40 }
41
42 EAPI void
43 ecore_x_xregion_free(Ecore_X_XRegion *region)
44 {
45    LOGFN(__FILE__, __LINE__, __FUNCTION__);
46    if (!region)
47      return;
48
49    XDestroyRegion((Region)region);
50 }
51
52 EAPI int
53 ecore_x_xregion_set(Ecore_X_XRegion *region, Ecore_X_GC gc)
54 {
55    LOGFN(__FILE__, __LINE__, __FUNCTION__);
56    return XSetRegion(_ecore_x_disp, gc, (Region)region);
57 }
58
59 EAPI void
60 ecore_x_xregion_translate(Ecore_X_XRegion *region, int x, int y)
61 {
62    LOGFN(__FILE__, __LINE__, __FUNCTION__);
63    if (!region)
64      return;
65
66    /* return value not used */
67    XOffsetRegion((Region)region, x, y);
68 }
69
70 EAPI int
71 ecore_x_xregion_intersect(Ecore_X_XRegion *dst, Ecore_X_XRegion *r1, Ecore_X_XRegion *r2)
72 {
73    LOGFN(__FILE__, __LINE__, __FUNCTION__);
74    return XIntersectRegion((Region)r1, (Region)r2, (Region)dst);
75 }
76
77 EAPI int
78 ecore_x_xregion_union(Ecore_X_XRegion *dst, Ecore_X_XRegion *r1, Ecore_X_XRegion *r2)
79 {
80    LOGFN(__FILE__, __LINE__, __FUNCTION__);
81    return XUnionRegion((Region)r1, (Region)r2, (Region)dst);
82 }
83
84 EAPI int
85 ecore_x_xregion_union_rect(Ecore_X_XRegion *dst, Ecore_X_XRegion *src, Ecore_X_Rectangle *rect)
86 {
87    XRectangle xr;
88
89    LOGFN(__FILE__, __LINE__, __FUNCTION__);
90    xr.x = rect->x;
91    xr.y = rect->y;
92    xr.width = rect->width;
93    xr.height = rect->height;
94
95    return XUnionRectWithRegion(&xr, (Region)src, (Region)dst);
96 }
97
98 EAPI int
99 ecore_x_xregion_subtract(Ecore_X_XRegion *dst, Ecore_X_XRegion *rm, Ecore_X_XRegion *rs)
100 {
101    LOGFN(__FILE__, __LINE__, __FUNCTION__);
102    return XSubtractRegion((Region)rm, (Region)rs, (Region)dst);
103 }
104
105 EAPI int
106 ecore_x_xregion_is_empty(Ecore_X_XRegion *region)
107 {
108    if (!region)
109      return 1;
110
111    LOGFN(__FILE__, __LINE__, __FUNCTION__);
112    return !XEmptyRegion((Region)region);
113 }
114
115 EAPI int
116 ecore_x_xregion_is_equal(Ecore_X_XRegion *r1, Ecore_X_XRegion *r2)
117 {
118    if (!r1 || !r2)
119      return 0;
120
121    LOGFN(__FILE__, __LINE__, __FUNCTION__);
122    return XEqualRegion((Region)r1, (Region)r1);
123 }
124
125 EAPI int
126 ecore_x_xregion_point_contain(Ecore_X_XRegion *region, int x, int y)
127 {
128    if (!region)
129      return 0;
130
131    LOGFN(__FILE__, __LINE__, __FUNCTION__);
132    return XPointInRegion((Region)region, x, y);
133 }
134
135 EAPI int
136 ecore_x_xregion_rect_contain(Ecore_X_XRegion *region, Ecore_X_Rectangle *rect)
137 {
138    if (!region || !rect)
139      return 0;
140
141    LOGFN(__FILE__, __LINE__, __FUNCTION__);
142    return XRectInRegion((Region)region, rect->x, rect->y, rect->width, rect->height);
143 }