Tizen 2.1 base
[framework/uifw/ecore.git] / src / lib / ecore_x / xlib / ecore_x_drawable.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  * @defgroup Ecore_X_Drawable_Group X Drawable Functions
9  *
10  * Functions that operate on drawables.
11  */
12
13 /**
14  * Retrieves the geometry of the given drawable.
15  * @param d The given drawable.
16  * @param x Pointer to an integer into which the X position is to be stored.
17  * @param y Pointer to an integer into which the Y position is to be stored.
18  * @param w Pointer to an integer into which the width is to be stored.
19  * @param h Pointer to an integer into which the height is to be stored.
20  * @ingroup Ecore_X_Drawable_Group
21  */
22 EAPI void
23 ecore_x_drawable_geometry_get(Ecore_X_Drawable d,
24                               int *x,
25                               int *y,
26                               int *w,
27                               int *h)
28 {
29    Window dummy_win;
30    int ret_x, ret_y;
31    unsigned int ret_w, ret_h, dummy_border, dummy_depth;
32
33    LOGFN(__FILE__, __LINE__, __FUNCTION__);
34    if (!XGetGeometry(_ecore_x_disp, d, &dummy_win, &ret_x, &ret_y,
35                      &ret_w, &ret_h, &dummy_border, &dummy_depth))
36      {
37         ret_x = 0;
38         ret_y = 0;
39         ret_w = 0;
40         ret_h = 0;
41      }
42
43    if (x)
44      *x = ret_x;
45
46    if (y)
47      *y = ret_y;
48
49    if (w)
50      *w = (int)ret_w;
51
52    if (h)
53      *h = (int)ret_h;
54 }
55
56 /**
57  * Retrieves the width of the border of the given drawable.
58  * @param  d The given drawable.
59  * @return The border width of the given drawable.
60  * @ingroup Ecore_X_Drawable_Group
61  */
62 EAPI int
63 ecore_x_drawable_border_width_get(Ecore_X_Drawable d)
64 {
65    Window dummy_win;
66    int dummy_x, dummy_y;
67    unsigned int dummy_w, dummy_h, border_ret, dummy_depth;
68
69    LOGFN(__FILE__, __LINE__, __FUNCTION__);
70    if (!XGetGeometry(_ecore_x_disp, d, &dummy_win, &dummy_x, &dummy_y,
71                      &dummy_w, &dummy_h, &border_ret, &dummy_depth))
72      border_ret = 0;
73
74    return (int)border_ret;
75 }
76
77 /**
78  * Retrieves the depth of the given drawable.
79  * @param  d The given drawable.
80  * @return The depth of the given drawable.
81  * @ingroup Ecore_X_Drawable_Group
82  */
83 EAPI int
84 ecore_x_drawable_depth_get(Ecore_X_Drawable d)
85 {
86    Window dummy_win;
87    int dummy_x, dummy_y;
88    unsigned int dummy_w, dummy_h, dummy_border, depth_ret;
89
90    LOGFN(__FILE__, __LINE__, __FUNCTION__);
91    if (!XGetGeometry(_ecore_x_disp, d, &dummy_win, &dummy_x, &dummy_y,
92                      &dummy_w, &dummy_h, &dummy_border, &depth_ret))
93      depth_ret = 0;
94
95    return (int)depth_ret;
96 }
97
98 /**
99  * Fill the specified rectangle on a drawable.
100  * @param d The given drawable.
101  * @param gc The graphic context that controls the fill rules.
102  * @param x The X coordinate of the top-left corner of the rectangle.
103  * @param y The Y coordinate of the top-left corner of the rectangle.
104  * @param width The width of the rectangle.
105  * @param height The height of the rectangle.
106  */
107 EAPI void
108 ecore_x_drawable_rectangle_fill(Ecore_X_Drawable d,
109                                 Ecore_X_GC gc,
110                                 int x,
111                                 int y,
112                                 int width,
113                                 int height)
114 {
115    LOGFN(__FILE__, __LINE__, __FUNCTION__);
116    XFillRectangle(_ecore_x_disp, d, gc, x, y, width, height);
117 }
118