add signal emit elm,action,more_func when ea_naviframe_more_cb is called
[platform/core/uifw/efl-assist.git] / src / include / efl_assist_events.h
1 /*
2  * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *  Licensed under the Apache License, Version 2.0 (the "License");
5  *  you may not use this file except in compliance with the License.
6  *  You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *  Unless required by applicable law or agreed to in writing, software
11  *  distributed under the License is distributed on an "AS IS" BASIS,
12  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *  See the License for the specific language governing permissions and
14  *  limitations under the License.
15  *
16  */
17
18 #ifndef __EFL_ASSIST_EVENTS_H__
19 #define __EFL_ASSIST_EVENTS_H__
20
21 #include <Elementary.h>
22
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26
27 /**
28  * @brief Convenient macro function that sends back key events to the popup
29  *        to be removed.
30  *
31  * @see   ea_object_event_callback_add()
32  */
33 static inline void
34 ea_popup_back_cb(void *data, Evas_Object *obj, void *event_info)
35 {
36    evas_object_del(obj);
37 }
38
39 /**
40  * @brief Convenient macro function that sends back key events to the ctxpopup
41  *        to be dismissed.
42  *
43  * @see   ea_object_event_callback_add()
44  */
45 static inline void
46 ea_ctxpopup_back_cb(void *data, Evas_Object *obj, void *event_info)
47 {
48    elm_ctxpopup_dismiss(obj);
49 }
50
51 /**
52  * @brief Convenient macro function that sends more key events to the naviframe
53  *        top item.
54  * @see   ea_object_event_callback_add()
55  */
56 static inline void
57 ea_naviframe_more_cb(void *data, Evas_Object *obj, void *event_info)
58 {
59    Elm_Object_Item *top = elm_naviframe_top_item_get(obj);
60    if (!top) return;
61    Evas_Object *more_btn = elm_object_item_part_content_get(top, "toolbar_more_btn");
62    if (more_btn)
63      evas_object_smart_callback_call(more_btn, "clicked", NULL);
64    else
65      elm_object_item_signal_emit(top, "elm,action,more_event", "");
66 }
67
68 /**
69  * @brief Convenient macro function that pop the naviframe item.
70  * @see   ea_object_event_callback_add()
71  */
72 static inline void
73 ea_naviframe_back_cb(void *data, Evas_Object *obj, void *event_info)
74 {
75    elm_naviframe_item_pop(obj);
76 }
77
78 /**
79  * Identifier of callbacks to be set for Ea events.
80  *
81  * @see ea_object_event_callback_add()
82  * @see ea_object_event_callback_del()
83  */
84 typedef enum _Ea_Callback_Type
85 {
86    EA_CALLBACK_BACK,
87    EA_CALLBACK_MORE,
88    EA_CALLBACK_LAST
89 } Ea_Callback_Type;
90
91 /** <Ea event callback function signature */
92 typedef void (*Ea_Event_Cb)(void *data, Evas_Object *obj, void *event_info);
93
94 /**
95  * Delete a callback function from an object.
96  *
97  * @param[in] obj Object to remove a callback from.
98  * @param[in] type The type of event that was triggering the callback.
99  * @param[in] func The function that was to be called when the event was
100  *            triggered
101  * @return    data The data pointer that was to be passed to the callback.
102  *
103  * @brief     This function removes the most recently added callback from the
104  *            object @p obj which was triggered by the type @p type and
105  *            was calling the function @p func when triggered. If the removal is
106  *            successful it will also return the data pointer that was passed to
107  *            ea_object_event_callback_add() when the callback was added to
108  *            the object. If not successful @c NULl will be returned.
109  *
110  * @see ea_object_event_callback_add()
111  */
112
113 EAPI void *ea_object_event_callback_del(Evas_Object *obj, Ea_Callback_Type type, Ea_Event_Cb);
114
115 /**
116  * Add (register) a callback function to a given evas object.
117  *
118  * @param[in] obj evas object.
119  * @param[in] type The type of event that will trigger the callback.
120  * @param[in] func The function to be called when the key event is triggered.
121  * @param[in] data The data pointer to be passed to @p func.
122  *
123  * @brief This function adds a function callback to an object when the key event
124  *        occurs on object @p obj. The key event on the object is only triggered
125  *        when the object is the most top in objects stack and visible. This
126  *        means, like the naviframe widget, if your application needs to have
127  *        the events based on the view but not focus, you can use this callback.
128  *
129  *        A callback function must have the Ea_Event_Cb prototype definition.
130  *        The first parameter (@p data) in this definition will have the same
131  *        value passed to ea_object_event_callback_add() as the @p data
132  *        parameter, at runtime. The second parameter @p obj is the evas object
133  *        on which event occurred. Finally, the third parameter @p event_info is
134  *        a pointer to a data structure that may or may not be passed to the
135  *        callback, depending on the event type that triggered the callback.
136  *        This is so because some events don't carry extra context with them,
137  *        but others do.
138  *
139  * @see ea_object_event_callback_del()
140  */
141
142 EAPI void ea_object_event_callback_add(Evas_Object *obj, Ea_Callback_Type type, Ea_Event_Cb func, void *data);
143
144 #ifdef __cplusplus
145 }
146 #endif
147
148 #endif /* __EFL_ASSIST_EVENTS_H__ */