move around - flatter.
[profile/ivi/evas.git] / src / lib / canvas / evas_focus.c
1 #include "evas_common.h"
2 #include "evas_private.h"
3
4 /* private calls */
5
6 /* local calls */
7
8 /* public calls */
9
10 /**
11  * Sets focus to the given object.
12  * 
13  * @param obj The object to be focused or unfocused.
14  * @param focus set or remove focus to the object.
15  *
16  * Changing focus only affects where key events go.
17  * There can be only one object focused at any time.
18  * <p>
19  * If the parameter (@p focus) is set, the passed object will be set as the
20  * currently focused object.  It will receive all keyboard events that are not
21  * exclusive key grabs on other objects.
22  *
23  * @see evas_object_focus_get
24  * @see evas_focus_get
25  * @see evas_object_key_grab
26  * @see evas_object_key_ungrab
27  */
28 EAPI void
29 evas_object_focus_set(Evas_Object *obj, Evas_Bool focus)
30 {
31    MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
32    return;
33    MAGIC_CHECK_END();
34
35    if (focus)
36      {
37         if (obj->focused) return;
38         if (obj->layer->evas->focused)
39           evas_object_focus_set(obj->layer->evas->focused, 0);
40         obj->focused = 1;
41         obj->layer->evas->focused = obj;
42         evas_object_event_callback_call(obj, EVAS_CALLBACK_FOCUS_IN, NULL);
43      }
44    else
45      {
46         if (!obj->focused) return;
47         obj->focused = 0;
48         obj->layer->evas->focused = NULL;
49         evas_object_event_callback_call(obj, EVAS_CALLBACK_FOCUS_OUT, NULL);
50      }
51 }
52
53 /**
54  * Test if the object has focus.
55  *
56  * @param obj The object to be tested.
57  * 
58  * If the passed object is the currently focused object 1 is returned,
59  * 0 otherwise.
60  * 
61  * @see evas_object_focus_set
62  * @see evas_focus_get
63  * @see evas_object_key_grab
64  * @see evas_object_key_ungrab
65  *
66  * @return 1 if the object has the focus, 0 otherwise.
67  */
68 EAPI Evas_Bool
69 evas_object_focus_get(const Evas_Object *obj)
70 {
71    MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
72    return 0;
73    MAGIC_CHECK_END();
74    return obj->focused;
75 }
76
77 /**
78  * Retrieve the object that currently has focus.
79  *
80  * @param e The @c Evas canvas to query focus on.
81  * 
82  * Returns the object that currently has focus, NULL otherwise.
83  * 
84  * @see evas_object_focus_set
85  * @see evas_object_focus_get
86  * @see evas_object_key_grab
87  * @see evas_object_key_ungrab
88  *
89  * @return The object that has focus or NULL is there is not one.
90  */
91 EAPI Evas_Object *
92 evas_focus_get(const Evas *e)
93 {
94    MAGIC_CHECK(e, Evas, MAGIC_EVAS);
95    return NULL;
96    MAGIC_CHECK_END();
97    return e->focused;
98 }