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