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