elementary/elm_widget - oops. recorvered a missing struct and added a macro to verify...
[framework/uifw/elementary.git] / src / lib / elm_widget.h
1 #ifndef ELM_WIDGET_H
2 #define ELM_WIDGET_H
3
4 /* DO NOT USE THIS HEADER UNLESS YOU ARE PREPARED FOR BREAKING OF YOUR
5  * CODE. THIS IS ELEMENTARY'S INTERNAL WIDGET API (for now) AND IS NOT
6  * FINAL. CALL elm_widget_api_check(ELM_INTERNAL_API_VERSION) TO CHECK IT
7  * AT RUNTIME
8  *
9  * How to make your own widget? like this:
10  *
11  * #include <Elementary.h>
12  * #include "elm_priv.h"
13  *
14  * typedef struct _Widget_Data Widget_Data;
15  *
16  * struct _Widget_Data
17  * {
18  *   Evas_Object *sub;
19  *   // add any other widget data here too
20  * };
21  *
22  * static const char *widtype = NULL;
23  * static void _del_hook(Evas_Object *obj);
24  * static void _theme_hook(Evas_Object *obj);
25  * static void _disable_hook(Evas_Object *obj);
26  * static void _sizing_eval(Evas_Object *obj);
27  * static void _on_focus_hook(void *data, Evas_Object *obj);
28  *
29  * static const char SIG_CLICKED[] = "clicked";
30  * static const Evas_Smart_Cb_Description _signals[] = {
31  *   {SIG_CLICKED, ""},
32  *   {NULL, NULL}
33  * };
34  *
35  * static void
36  * _del_hook(Evas_Object *obj)
37  * {
38  *    Widget_Data *wd = elm_widget_data_get(obj);
39  *    if (!wd) return;
40  *    // delete hook - on delete of object delete object struct etc.
41  *    free(wd);
42  * }
43  *
44  * static void
45  * _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
46  * {
47  *    Widget_Data *wd = elm_widget_data_get(obj);
48  *    if (!wd) return;
49  *    // handle focus going in and out - optional, but if you want to, set
50  *    // this hook and handle it (eg emit a signal to an edje obj)
51  *    if (elm_widget_focus_get(obj))
52  *      {
53  *         edje_object_signal_emit(wd->sub, "elm,action,focus", "elm");
54  *         evas_object_focus_set(wd->sub, EINA_TRUE);
55  *      }
56  *    else
57  *      {
58  *         edje_object_signal_emit(wd->sub, "elm,action,unfocus", "elm");
59  *         evas_object_focus_set(wd->sub, EINA_FALSE);
60  *      }
61  * }
62  *
63  * static void
64  * _theme_hook(Evas_Object *obj)
65  * {
66  *    Widget_Data *wd = elm_widget_data_get(obj);
67  *    if (!wd) return;
68  *    // handle change in theme/scale etc.
69  *    elm_widget_theme_object_set(obj, wd->sub, "mywidget", "base",
70  *                                elm_widget_style_get(obj));
71  * }
72  *
73  * static void
74  * _disable_hook(Evas_Object *obj)
75  * {
76  *    Widget_Data *wd = elm_widget_data_get(obj);
77  *    if (!wd) return;
78  *    // optional, but handle if the widget gets disabled or not
79  *    if (elm_widget_disabled_get(obj))
80  *      edje_object_signal_emit(wd->sub, "elm,state,disabled", "elm");
81  *    else
82  *      edje_object_signal_emit(wd->sub, "elm,state,enabled", "elm");
83  * }
84  *
85  * static void
86  * _sizing_eval(Evas_Object *obj)
87  * {
88  *    Widget_Data *wd = elm_widget_data_get(obj);
89  *    Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
90  *    if (!wd) return;
91  *    elm_coords_finger_size_adjust(1, &minw, 1, &minh);
92  *    edje_object_size_min_restricted_calc(wd->sub, &minw, &minh, minw, minh);
93  *    elm_coords_finger_size_adjust(1, &minw, 1, &minh);
94  *    evas_object_size_hint_min_set(obj, minw, minh);
95  *    evas_object_size_hint_max_set(obj, maxw, maxh);
96  * }
97  *
98  * // actual api to create your widget. add more to manipulate it as needed
99  * // mark your calls with EAPI to make them "external api" calls.
100  * EAPI Evas_Object *
101  * elm_mywidget_add(Evas_Object *parent)
102  * {
103  *    Evas_Object *obj;
104  *    Evas *e;
105  *    Widget_Data *wd;
106  *
107  *    // ALWAYS call this - this checks that your widget matches that of
108  *    // elementary and that the api hasn't broken. if it has this returns
109  *    // false and you need to handle this error gracefully
110  *    if (!elm_widget_api_check(ELM_INTERNAL_API_VERSION)) return NULL;
111  *
112  *    // standard widget setup and allocate wd, create obj given parent etc.
113  *    ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
114  *
115  *    // give it a type name and set up a mywidget type string if needed
116  *    ELM_SET_WIDTYPE(widtype, "mywidget");
117  *    elm_widget_type_set(obj, "mywidget");
118  *    // tell the parent widget that we are a sub object
119  *    elm_widget_sub_object_add(parent, obj);
120  *    // setup hooks we need (some are optional)
121  *    elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
122  *    elm_widget_data_set(obj, wd);
123  *    elm_widget_del_hook_set(obj, _del_hook);
124  *    elm_widget_theme_hook_set(obj, _theme_hook);
125  *    elm_widget_disable_hook_set(obj, _disable_hook);
126  *    // this widget can focus (true means yes it can, false means it can't)
127  *    elm_widget_can_focus_set(obj, EINA_TRUE);
128  *
129  *    // for this widget we will add 1 sub object that is an edje object
130  *    wd->sub = edje_object_add(e);
131  *    // set the theme. this follows a scheme for group name like this:
132  *    //   "elm/WIDGETNAME/ELEMENT/STYLE"
133  *    // so here it will be:
134  *    //   "elm/mywidget/base/default"
135  *    // changing style changes style name from default (all widgets start
136  *    // with the default style) and element is for your widget internal
137  *    // structure as you see fit
138  *    elm_widget_theme_object_set(obj, wd->sub, "mywidget", "base", "default");
139  *    // listen to a signal from the edje object to produce widget smart
140  *    // callback (like click)
141  *    edje_object_signal_callback_add(wd->sub, "elm,action,click", "",
142  *                                    _signal_clicked, obj);
143  *    // set this sub object as the "resize object". widgets get 1 resize
144  *    // object that is resized along with the object wrapper.
145  *    elm_widget_resize_object_set(obj, wd->sub);
146  *
147  *    // evaluate sizing of the widget (minimum size calc etc.). optional but
148  *    // not a bad idea to do here. it will get queued for later anyway
149  *    _sizing_eval(obj);
150  *
151  *    // register the smart callback descriptions so we can have some runtime
152  *    // info as to what the smart callback strings mean
153  *    evas_object_smart_callbacks_descriptions_set(obj, _signals);
154  *    return obj;
155  * }
156  *
157  * // example - do "whatever" to the widget (here just emit a signal)
158  * EAPI void
159  * elm_mywidget_whatever(Evas_Object *obj)
160  * {
161  *    // check if type is correct - check will return if it fails
162  *    ELM_CHECK_WIDTYPE(obj, widtype);
163  *    // get widget data - type is correct and sane by this point, so this
164  *    // should never fail
165  *    Widget_Data *wd = elm_widget_data_get(obj);
166  *    // do whatever you like
167  *    edje_object_signal_emit(wd->sub, "elm,state,action,whatever", "elm");
168  * }
169  *
170  * // you can add more - you need to see elementary's code to know how to
171  * // handle all cases. remember this api is not stable and may change. it's
172  * // internal
173  *
174  */
175
176 #ifndef ELM_INTERNAL_API_ARGESFSDFEFC
177 # warning "You are using an internal elementary API. This API is not stable"
178 # warning "and is subject to change. You use this at your own risk."
179 # warning "Remember to call elm_widget_api_check(ELM_INTERNAL_API_VERSION);"
180 # warning "in your widgets before you call any other elm_widget calls to do"
181 # warning "a correct runtime version check. Also remember - you don't NEED"
182 # warning "to make an Elementary widget is almost ALL cases. You can easily"
183 # warning "make a smart object with Evas's API and do everything you need"
184 # warning "there. You only need a widget if you want to seamlessly be part"
185 # warning "of the focus tree and want to transparently become a container"
186 # warning "for any number of child Elementary widgets"
187 # error "ERROR. Compile aborted."
188 #endif
189 #define ELM_INTERNAL_API_VERSION 7000
190
191 typedef struct _Elm_Tooltip Elm_Tooltip;
192 typedef struct _Elm_Cursor Elm_Cursor;
193 typedef struct _Elm_Widget_Item Elm_Widget_Item; /**< base structure for all widget items that are not Elm_Widget themselves */
194
195 struct _Elm_Widget_Item
196 {
197    /* ef1 ~~ efl, el3 ~~ elm */
198 #define ELM_WIDGET_ITEM_MAGIC 0xef1e1301
199    EINA_MAGIC;
200
201    Evas_Object   *widget; /**< the owner widget that owns this item */
202    Evas_Object   *view; /**< the base view object */
203    const void    *data; /**< item specific data */
204    Evas_Smart_Cb  del_cb; /**< used to notify the item is being deleted */
205    void         (*on_content_set_func)(Elm_Widget_Item *item,
206                                        const char *part,
207                                        Evas_Object *content);
208    Evas_Object *(*on_content_get_func)(const Elm_Widget_Item *item,
209                                        const char *part);
210    Evas_Object *(*on_content_unset_func)(Elm_Widget_Item *item,
211                                          const char *part);
212    void         (*on_text_set_func)(Elm_Widget_Item *item,
213                                     const char *part,
214                                     const char *label);
215    const char  *(*on_text_get_func)(const Elm_Widget_Item *item,
216                                     const char *part);
217    /* widget variations should have data from here and on */
218    /* @todo: TODO check if this is enough for 1.0 release, maybe add padding! */
219 };
220
221 struct _Elm_Object_Item
222 {
223    Elm_Widget_Item it;
224 };
225
226 #define ELM_NEW(t) calloc(1, sizeof(t))
227
228 #define ELM_CAST(p) ((void *)(p))
229
230 #define ELM_OBJ_ITEM_CHECK_OR_RETURN(it, ...)                               \
231    ELM_WIDGET_ITEM_CHECK_OR_RETURN((Elm_Widget_Item *) (it), __VA_ARGS__);  \
232    ELM_CHECK_WIDTYPE(it->it.widget, widtype) __VA_ARGS__;
233
234 EAPI Eina_Bool        elm_widget_api_check(int ver);
235 EAPI Evas_Object     *elm_widget_add(Evas *evas);
236 EAPI void             elm_widget_del_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj));
237 EAPI void             elm_widget_del_pre_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj));
238 EAPI void             elm_widget_focus_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj));
239 EAPI void             elm_widget_activate_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj));
240 EAPI void             elm_widget_disable_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj));
241 EAPI void             elm_widget_theme_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj));
242 EAPI void             elm_widget_event_hook_set(Evas_Object *obj, Eina_Bool (*func) (Evas_Object *obj, Evas_Object *source, Evas_Callback_Type type, void *event_info));
243 EAPI void             elm_widget_changed_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj));
244 EAPI void             elm_widget_signal_emit_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj, const char *emission, const char *source));
245 EAPI void             elm_widget_signal_callback_add_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data));
246 EAPI void             elm_widget_signal_callback_del_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data));
247 EAPI void             elm_widget_theme(Evas_Object *obj);
248 EAPI void             elm_widget_theme_specific(Evas_Object *obj, Elm_Theme *th, Eina_Bool force);
249 EAPI void             elm_widget_focus_next_hook_set(Evas_Object *obj, Eina_Bool (*func) (const Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next));
250 EAPI void             elm_widget_on_focus_hook_set(Evas_Object *obj, void (*func) (void *data, Evas_Object *obj), void *data);
251 EAPI void             elm_widget_on_change_hook_set(Evas_Object *obj, void (*func) (void *data, Evas_Object *obj), void *data);
252 EAPI void             elm_widget_on_show_region_hook_set(Evas_Object *obj, void (*func) (void *data, Evas_Object *obj), void *data);
253 EAPI void             elm_widget_focus_region_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h));
254 EAPI void             elm_widget_text_set_hook_set(Evas_Object *obj, void (*func)(Evas_Object *obj, const char *part, const char *text));
255 EAPI void             elm_widget_text_get_hook_set(Evas_Object *obj, const char *(*func)(const Evas_Object *obj, const char *part));
256 EAPI void             elm_widget_content_set_hook_set(Evas_Object *obj, void (*func)(Evas_Object *obj, const char *part, Evas_Object *content));
257 EAPI void             elm_widget_content_get_hook_set(Evas_Object *obj, Evas_Object *(*func)(const Evas_Object *obj, const char *part));
258 EAPI void             elm_widget_content_unset_hook_set(Evas_Object *obj, Evas_Object *(*func)(Evas_Object *obj, const char *part));
259 EAPI void             elm_widget_on_focus_region_hook_set(Evas_Object *obj, void (*func) (const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h));
260 EAPI void             elm_widget_data_set(Evas_Object *obj, void *data);
261 EAPI void            *elm_widget_data_get(const Evas_Object *obj);
262 EAPI void             elm_widget_sub_object_add(Evas_Object *obj, Evas_Object *sobj);
263 EAPI void             elm_widget_sub_object_del(Evas_Object *obj, Evas_Object *sobj);
264 EAPI void             elm_widget_resize_object_set(Evas_Object *obj, Evas_Object *sobj);
265 EAPI void             elm_widget_hover_object_set(Evas_Object *obj, Evas_Object *sobj);
266 EAPI void             elm_widget_signal_emit(Evas_Object *obj, const char *emission, const char *source);
267 EAPI void             elm_widget_signal_callback_add(Evas_Object *obj, const char *emission, const char *source, void (*func) (void *data, Evas_Object *o, const char *emission, const char *source), void *data);
268 EAPI void            *elm_widget_signal_callback_del(Evas_Object *obj, const char *emission, const char *source, void (*func) (void *data, Evas_Object *o, const char *emission, const char *source));
269 EAPI void             elm_widget_can_focus_set(Evas_Object *obj, Eina_Bool can_focus);
270 EAPI Eina_Bool        elm_widget_can_focus_get(const Evas_Object *obj);
271 EAPI Eina_Bool        elm_widget_child_can_focus_get(const Evas_Object *obj);
272 EAPI void             elm_widget_tree_unfocusable_set(Evas_Object *obj, Eina_Bool tree_unfocusable);
273 EAPI Eina_Bool        elm_widget_tree_unfocusable_get(const Evas_Object *obj);
274 EAPI void             elm_widget_highlight_ignore_set(Evas_Object *obj, Eina_Bool ignore);
275 EAPI Eina_Bool        elm_widget_highlight_ignore_get(const Evas_Object *obj);
276 EAPI void             elm_widget_highlight_in_theme_set(Evas_Object *obj, Eina_Bool highlight);
277 EAPI Eina_Bool        elm_widget_highlight_in_theme_get(const Evas_Object *obj);
278 EAPI Eina_Bool        elm_widget_focus_get(const Evas_Object *obj);
279 EAPI Evas_Object     *elm_widget_focused_object_get(const Evas_Object *obj);
280 EAPI Evas_Object     *elm_widget_top_get(const Evas_Object *obj);
281 EAPI Eina_Bool        elm_widget_is(const Evas_Object *obj);
282 EAPI Evas_Object     *elm_widget_parent_widget_get(const Evas_Object *obj);
283 EAPI void             elm_widget_event_callback_add(Evas_Object *obj, Elm_Event_Cb func, const void *data);
284 EAPI void            *elm_widget_event_callback_del(Evas_Object *obj, Elm_Event_Cb func, const void *data);
285 EAPI Eina_Bool        elm_widget_event_propagate(Evas_Object *obj, Evas_Callback_Type type, void *event_info, Evas_Event_Flags *event_flags);
286 EAPI void             elm_widget_focus_custom_chain_set(Evas_Object *obj, Eina_List *objs);
287 EAPI void             elm_widget_focus_custom_chain_unset(Evas_Object *obj);
288 EAPI const Eina_List *elm_widget_focus_custom_chain_get(const Evas_Object *obj);
289 EAPI void             elm_widget_focus_custom_chain_append(Evas_Object *obj, Evas_Object *child, Evas_Object *relative_child);
290 EAPI void             elm_widget_focus_custom_chain_prepend(Evas_Object *obj, Evas_Object *child, Evas_Object *relative_child);
291 EAPI void             elm_widget_focus_cycle(Evas_Object *obj, Elm_Focus_Direction dir);
292 EAPI void             elm_widget_focus_direction_go(Evas_Object *obj, int x, int y);
293 EAPI Eina_Bool        elm_widget_focus_next_get(const Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next);
294 EAPI Eina_Bool        elm_widget_focus_list_next_get(const Evas_Object *obj, const Eina_List *items, void *(*list_data_get) (const Eina_List *list), Elm_Focus_Direction dir, Evas_Object **next);
295 EAPI void             elm_widget_focus_set(Evas_Object *obj, int first);
296 EAPI void             elm_widget_focused_object_clear(Evas_Object *obj);
297 EAPI Evas_Object     *elm_widget_parent_get(const Evas_Object *obj);
298 EAPI Evas_Object     *elm_widget_parent2_get(const Evas_Object *obj);
299 EAPI void             elm_widget_parent2_set(Evas_Object *obj, Evas_Object *parent);
300 EAPI void             elm_widget_focus_steal(Evas_Object *obj);
301 EAPI void             elm_widget_activate(Evas_Object *obj);
302 EAPI void             elm_widget_change(Evas_Object *obj);
303 EAPI void             elm_widget_disabled_set(Evas_Object *obj, Eina_Bool disabled);
304 EAPI Eina_Bool        elm_widget_disabled_get(const Evas_Object *obj);
305 EAPI void             elm_widget_show_region_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h, Eina_Bool forceshow);
306 EAPI void             elm_widget_show_region_get(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h);
307 EAPI void             elm_widget_focus_region_get(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h);
308 EAPI void             elm_widget_scroll_hold_push(Evas_Object *obj);
309 EAPI void             elm_widget_scroll_hold_pop(Evas_Object *obj);
310 EAPI int              elm_widget_scroll_hold_get(const Evas_Object *obj);
311 EAPI void             elm_widget_scroll_freeze_push(Evas_Object *obj);
312 EAPI void             elm_widget_scroll_freeze_pop(Evas_Object *obj);
313 EAPI int              elm_widget_scroll_freeze_get(const Evas_Object *obj);
314 EAPI void             elm_widget_scale_set(Evas_Object *obj, double scale);
315 EAPI double           elm_widget_scale_get(const Evas_Object *obj);
316 EAPI Eina_Bool        elm_widget_mirrored_get(const Evas_Object *obj) EINA_ARG_NONNULL(1);
317 EAPI void             elm_widget_mirrored_set(Evas_Object *obj, Eina_Bool mirrored) EINA_ARG_NONNULL(1);
318 EAPI Eina_Bool        elm_widget_mirrored_automatic_get(const Evas_Object *obj) EINA_ARG_NONNULL(1);
319 EAPI void             elm_widget_mirrored_automatic_set(Evas_Object *obj, Eina_Bool automatic) EINA_ARG_NONNULL(1);
320 EAPI void             elm_widget_theme_set(Evas_Object *obj, Elm_Theme *th);
321 EAPI Elm_Theme       *elm_widget_theme_get(const Evas_Object *obj);
322 EAPI void             elm_widget_style_set(Evas_Object *obj, const char *style);
323 EAPI const char      *elm_widget_style_get(const Evas_Object *obj);
324 EAPI void             elm_widget_type_set(Evas_Object *obj, const char *type);
325 EAPI const char      *elm_widget_type_get(const Evas_Object *obj);
326 EAPI void             elm_widget_tooltip_add(Evas_Object *obj, Elm_Tooltip *tt);
327 EAPI void             elm_widget_tooltip_del(Evas_Object *obj, Elm_Tooltip *tt);
328 EAPI void             elm_widget_cursor_add(Evas_Object *obj, Elm_Cursor *cur);
329 EAPI void             elm_widget_cursor_del(Evas_Object *obj, Elm_Cursor *cur);
330 EAPI void             elm_widget_drag_lock_x_set(Evas_Object *obj, Eina_Bool lock);
331 EAPI void             elm_widget_drag_lock_y_set(Evas_Object *obj, Eina_Bool lock);
332 EAPI Eina_Bool        elm_widget_drag_lock_x_get(const Evas_Object *obj);
333 EAPI Eina_Bool        elm_widget_drag_lock_y_get(const Evas_Object *obj);
334 EAPI int              elm_widget_drag_child_locked_x_get(const Evas_Object *obj);
335 EAPI int              elm_widget_drag_child_locked_y_get(const Evas_Object *obj);
336 EAPI Eina_Bool        elm_widget_theme_object_set(Evas_Object *obj, Evas_Object *edj, const char *wname, const char *welement, const char *wstyle);
337 EAPI void             elm_widget_type_register(const char **ptr);
338 EAPI Eina_Bool        elm_widget_type_check(const Evas_Object *obj, const char *type);
339 EAPI Eina_List       *elm_widget_stringlist_get(const char *str);
340 EAPI void             elm_widget_stringlist_free(Eina_List *list);
341 EAPI void             elm_widget_focus_hide_handle(Evas_Object *obj);
342 EAPI void             elm_widget_focus_mouse_down_handle(Evas_Object *obj);
343 EAPI void             elm_widget_focus_tree_unfocusable_handle(Evas_Object *obj);
344 EAPI void             elm_widget_focus_disabled_handle(Evas_Object *obj);
345 EAPI void             elm_widget_text_part_set(Evas_Object *obj, const char *part, const char *label);
346 EAPI const char      *elm_widget_text_part_get(const Evas_Object *obj, const char *part);
347 EAPI void             elm_widget_content_part_set(Evas_Object *obj, const char *part, Evas_Object *content);
348 EAPI Evas_Object     *elm_widget_content_part_get(const Evas_Object *obj, const char *part);
349 EAPI Evas_Object     *elm_widget_content_part_unset(Evas_Object *obj, const char *part);
350 EAPI Elm_Widget_Item *_elm_widget_item_new(Evas_Object *parent, size_t alloc_size);
351 EAPI void             _elm_widget_item_del(Elm_Widget_Item *item);
352 EAPI void             _elm_widget_item_pre_notify_del(Elm_Widget_Item *item);
353 EAPI void             _elm_widget_item_del_cb_set(Elm_Widget_Item *item, Evas_Smart_Cb del_cb);
354 EAPI void             _elm_widget_item_data_set(Elm_Widget_Item *item, const void *data);
355 EAPI void            *_elm_widget_item_data_get(const Elm_Widget_Item *item);
356 EAPI void             _elm_widget_item_tooltip_text_set(Elm_Widget_Item *item, const char *text);
357 EAPI void             _elm_widget_item_tooltip_content_cb_set(Elm_Widget_Item *item, Elm_Tooltip_Item_Content_Cb func, const void *data, Evas_Smart_Cb del_cb);
358 EAPI void             _elm_widget_item_tooltip_unset(Elm_Widget_Item *item);
359 EAPI void             _elm_widget_item_tooltip_style_set(Elm_Widget_Item *item, const char *style);
360 EAPI Eina_Bool        _elm_widget_item_tooltip_size_restrict_disable(Elm_Widget_Item *item, Eina_Bool disable);
361 EAPI Eina_Bool        _elm_widget_item_tooltip_size_restrict_disabled_get(const Elm_Widget_Item *item);
362 EAPI const char      *_elm_widget_item_tooltip_style_get(const Elm_Widget_Item *item);
363 EAPI void             _elm_widget_item_cursor_set(Elm_Widget_Item *item, const char *cursor);
364 EAPI const char      *_elm_widget_item_cursor_get(const Elm_Widget_Item *item);
365 EAPI void             _elm_widget_item_cursor_unset(Elm_Widget_Item *item);
366 EAPI void             _elm_widget_item_cursor_style_set(Elm_Widget_Item *item, const char *style);
367 EAPI const char      *_elm_widget_item_cursor_style_get(const Elm_Widget_Item *item);
368 EAPI void             _elm_widget_item_cursor_engine_only_set(Elm_Widget_Item *item, Eina_Bool engine_only);
369 EAPI Eina_Bool        _elm_widget_item_cursor_engine_only_get(const Elm_Widget_Item *item);
370 EAPI void             _elm_widget_item_content_part_set(Elm_Widget_Item *item, const char *part, Evas_Object *content);
371 EAPI Evas_Object     *_elm_widget_item_content_part_get(const Elm_Widget_Item *item, const char *part);
372 EAPI Evas_Object     *_elm_widget_item_content_part_unset(Elm_Widget_Item *item, const char *part);
373 EAPI void             _elm_widget_item_text_part_set(Elm_Widget_Item *item, const char *part, const char *label);
374 EAPI const char      *_elm_widget_item_text_part_get(const Elm_Widget_Item *item, const char *part);
375
376
377 /* debug function. don't use it unless you are tracking parenting issues */
378 EAPI void             elm_widget_tree_dump(const Evas_Object *top);
379 EAPI void             elm_widget_tree_dot_dump(const Evas_Object *top, FILE *output);
380
381 /**
382  * Convenience macro to create new widget item, doing casts for you.
383  * @see _elm_widget_item_new()
384  * @param parent a valid elm_widget variant.
385  * @param type the C type that extends Elm_Widget_Item
386  */
387 #define elm_widget_item_new(parent, type) \
388   (type *)_elm_widget_item_new((parent), sizeof(type))
389 /**
390  * Convenience macro to delete widget item, doing casts for you.
391  * @see _elm_widget_item_del()
392  * @param item a valid item.
393  */
394 #define elm_widget_item_del(item) \
395   _elm_widget_item_del((Elm_Widget_Item *)item)
396 /**
397  * Convenience macro to notify deletion of widget item, doing casts for you.
398  * @see _elm_widget_item_pre_notify_del()
399  */
400 #define elm_widget_item_pre_notify_del(item) \
401   _elm_widget_item_pre_notify_del((Elm_Widget_Item *)item)
402 /**
403  * Convenience macro to set deletion callback of widget item, doing casts for you.
404  * @see _elm_widget_item_del_cb_set()
405  */
406 #define elm_widget_item_del_cb_set(item, del_cb) \
407   _elm_widget_item_del_cb_set((Elm_Widget_Item *)item, del_cb)
408
409 /**
410  * Set item's data
411  * @see _elm_widget_item_data_set()
412  */
413 #define elm_widget_item_data_set(item, data) \
414   _elm_widget_item_data_set((Elm_Widget_Item *)item, data)
415 /**
416  * Get item's data
417  * @see _elm_widget_item_data_get()
418  */
419 #define elm_widget_item_data_get(item) \
420   _elm_widget_item_data_get((const Elm_Widget_Item *)item)
421
422 /**
423  * Convenience function to set widget item tooltip as a text string.
424  * @see _elm_widget_item_tooltip_text_set()
425  */
426 #define elm_widget_item_tooltip_text_set(item, text) \
427   _elm_widget_item_tooltip_text_set((Elm_Widget_Item *)item, text)
428 /**
429  * Convenience function to set widget item tooltip.
430  * @see _elm_widget_item_tooltip_content_cb_set()
431  */
432 #define elm_widget_item_tooltip_content_cb_set(item, func, data, del_cb) \
433   _elm_widget_item_tooltip_content_cb_set((Elm_Widget_Item *)item, \
434                                           func, data, del_cb)
435 /**
436  * Convenience function to unset widget item tooltip.
437  * @see _elm_widget_item_tooltip_unset()
438  */
439 #define elm_widget_item_tooltip_unset(item) \
440   _elm_widget_item_tooltip_unset((Elm_Widget_Item *)item)
441 /**
442  * Convenience function to change item's tooltip style.
443  * @see _elm_widget_item_tooltip_style_set()
444  */
445 #define elm_widget_item_tooltip_style_set(item, style) \
446   _elm_widget_item_tooltip_style_set((Elm_Widget_Item *)item, style)
447
448 #define elm_widget_item_tooltip_size_restrict_disable(item, disable) \
449   _elm_widget_item_tooltip_size_restrict_disable((Elm_Widget_Item *)item, disable)
450
451 #define elm_widget_item_tooltip_size_restrict_disabled_get(item) \
452   _elm_widget_item_tooltip_size_restrict_disabled_get((Elm_Widget_Item *)item)
453 /**
454  * Convenience function to query item's tooltip style.
455  * @see _elm_widget_item_tooltip_style_get()
456  */
457 #define elm_widget_item_tooltip_style_get(item) \
458   _elm_widget_item_tooltip_style_get((const Elm_Widget_Item *)item)
459 /**
460  * Convenience function to set widget item cursor.
461  * @see _elm_widget_item_cursor_set()
462  */
463 #define elm_widget_item_cursor_set(item, cursor) \
464   _elm_widget_item_cursor_set((Elm_Widget_Item *)item, cursor)
465 /**
466  * Convenience function to get widget item cursor.
467  * @see _elm_widget_item_cursor_get()
468  */
469 #define elm_widget_item_cursor_get(item) \
470   _elm_widget_item_cursor_get((const Elm_Widget_Item *)item)
471 /**
472  * Convenience function to unset widget item cursor.
473  * @see _elm_widget_item_cursor_unset()
474  */
475 #define elm_widget_item_cursor_unset(item) \
476   _elm_widget_item_cursor_unset((Elm_Widget_Item *)item)
477 /**
478  * Convenience function to change item's cursor style.
479  * @see _elm_widget_item_cursor_style_set()
480  */
481 #define elm_widget_item_cursor_style_set(item, style) \
482   _elm_widget_item_cursor_style_set((Elm_Widget_Item *)item, style)
483 /**
484  * Convenience function to query item's cursor style.
485  * @see _elm_widget_item_cursor_style_get()
486  */
487 #define elm_widget_item_cursor_style_get(item) \
488   _elm_widget_item_cursor_style_get((const Elm_Widget_Item *)item)
489 /**
490  * Convenience function to change item's cursor engine_only.
491  * @see _elm_widget_item_cursor_engine_only_set()
492  */
493 #define elm_widget_item_cursor_engine_only_set(item, engine_only) \
494   _elm_widget_item_cursor_engine_only_set((Elm_Widget_Item *)item, engine_only)
495 /**
496  * Convenience function to query item's cursor engine_only.
497  * @see _elm_widget_item_cursor_engine_only_get()
498  */
499 #define elm_widget_item_cursor_engine_only_get(item) \
500   _elm_widget_item_cursor_engine_only_get((const Elm_Widget_Item *)item)
501 /**
502  * Convenience function to query item's content part set.
503  * @see _elm_widget_item_content_part_set()
504  */
505 #define elm_widget_item_content_part_set(item, part, content) \
506   _elm_widget_item_content_part_set((Elm_Widget_Item *)item, part, content)
507 /**
508  * Convenience function to query item's content part get.
509  * @see _elm_widget_item_content_part_get()
510  */
511 #define elm_widget_item_content_part_get(item, part) \
512   _elm_widget_item_content_part_get((const Elm_Widget_Item *)item, part)
513 /**
514  * Convenience function to query item's content part unset.
515  * @see _elm_widget_item_content_part_unset()
516  */
517 #define elm_widget_item_content_part_unset(item, part) \
518   _elm_widget_item_content_part_unset((Elm_Widget_Item *)item, part)
519 /**
520  * Convenience function to query item's text part set.
521  * @see _elm_widget_item_text_part_set()
522  */
523 #define elm_widget_item_text_part_set(item, part, label) \
524   _elm_widget_item_text_part_set((Elm_Widget_Item *)item, part, label)
525 /**
526  * Convenience function to query item's text part get.
527  * @see _elm_widget_item_text_part_get()
528  */
529 #define elm_widget_item_text_part_get(item, part) \
530   _elm_widget_item_text_part_get((const Elm_Widget_Item *)item, part)
531
532
533 /**
534  * Cast and ensure the given pointer is an Elm_Widget_Item or return NULL.
535  */
536 #define ELM_WIDGET_ITEM(item) \
537    (((item) && (EINA_MAGIC_CHECK(item, ELM_WIDGET_ITEM_MAGIC))) ? \
538        ((Elm_Widget_Item *)(item)) : NULL)
539
540 #define ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, ...) \
541    do { \
542       if (!item) { \
543          CRITICAL("Elm_Widget_Item " # item " is NULL!"); \
544          return __VA_ARGS__; \
545       } \
546       if (!EINA_MAGIC_CHECK(item, ELM_WIDGET_ITEM_MAGIC)) { \
547          EINA_MAGIC_FAIL(item, ELM_WIDGET_ITEM_MAGIC); \
548          return __VA_ARGS__; \
549       } \
550    } while (0)
551
552 #define ELM_WIDGET_ITEM_CHECK_OR_GOTO(item, label) \
553    do { \
554       if (!item) { \
555          CRITICAL("Elm_Widget_Item " # item " is NULL!"); \
556          goto label; \
557       } \
558       if (!EINA_MAGIC_CHECK(item, ELM_WIDGET_ITEM_MAGIC)) { \
559          EINA_MAGIC_FAIL(item, ELM_WIDGET_ITEM_MAGIC); \
560          goto label; \
561       } \
562    } while (0)
563
564 #define ELM_SET_WIDTYPE(widtype, type) \
565    do { \
566       if (!widtype) { \
567          widtype = eina_stringshare_add(type); \
568          elm_widget_type_register(&widtype); \
569       } \
570    } while (0)
571
572 #define ELM_CHECK_WIDTYPE(obj, widtype) \
573    if (!elm_widget_type_check((obj), (widtype))) return
574
575 #define ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, ...)                \
576    ELM_WIDGET_ITEM_CHECK_OR_RETURN((Elm_Widget_Item *)it, __VA_ARGS__); \
577    ELM_CHECK_WIDTYPE(it->base.widget, widtype) __VA_ARGS__;
578
579 #define ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_GOTO(it, label)                \
580    ELM_WIDGET_ITEM_CHECK_OR_GOTO((Elm_Widget_Item *)it, label);         \
581    if (!elm_widget_type_check((it->base.widget), (widtype))) goto label;
582
583 #define ELM_WIDGET_STANDARD_SETUP(wdat, wdtype, par, evas, ob, ret) \
584    do { \
585       EINA_SAFETY_ON_NULL_RETURN_VAL((par), (ret)); \
586       evas = evas_object_evas_get(par); if (!(evas)) return (ret); \
587       wdat = ELM_NEW(wdtype); if (!(wdat)) return (ret); \
588       ob = elm_widget_add(evas); if (!(ob)) { free(wdat); return (ret); } \
589    } while (0)
590
591 /**
592  * The drag and drop API.
593  * Currently experimental, and will change when it does dynamic type
594  * addition RSN.
595  *
596  * Here so applications can start to use it, if they ask elm nicely.
597  *
598  * And yes, elm_widget, should probably be elm_experimental...
599  * Complaints about this code should go to /dev/null, or failing that nash.
600  */
601 typedef struct _Elm_Selection_Data Elm_Selection_Data;
602
603 typedef Eina_Bool (*Elm_Drop_Cb) (void *d, Evas_Object *o, Elm_Selection_Data *data);
604
605 typedef enum _Elm_Sel_Type
606 {
607    ELM_SEL_PRIMARY,
608    ELM_SEL_SECONDARY,
609    ELM_SEL_CLIPBOARD,
610    ELM_SEL_XDND,
611
612    ELM_SEL_MAX,
613 } Elm_Sel_Type;
614
615 typedef enum _Elm_Sel_Format
616 {
617    /** Plain unformated text: Used for things that don't want rich markup */
618    ELM_SEL_FORMAT_TEXT   = 0x01,
619    /** Edje textblock markup, including inline images */
620    ELM_SEL_FORMAT_MARKUP = 0x02,
621    /** Images */
622    ELM_SEL_FORMAT_IMAGE  = 0x04,
623    /** Vcards */
624    ELM_SEL_FORMAT_VCARD =  0x08,
625    /** Raw HTMLish things for widgets that want that stuff (hello webkit!) */
626    ELM_SEL_FORMAT_HTML = 0x10,
627 } Elm_Sel_Format;
628
629 struct _Elm_Selection_Data
630 {
631    int                   x, y;
632    Elm_Sel_Format        format;
633    void                 *data;
634    int                   len;
635 };
636
637 Eina_Bool            elm_selection_set(Elm_Sel_Type selection, Evas_Object *widget, Elm_Sel_Format format, const char *buf);
638 Eina_Bool            elm_selection_clear(Elm_Sel_Type selection, Evas_Object *widget);
639 Eina_Bool            elm_selection_get(Elm_Sel_Type selection, Elm_Sel_Format format, Evas_Object *widget, Elm_Drop_Cb datacb, void *udata);
640 Eina_Bool            elm_drop_target_add(Evas_Object *widget, Elm_Sel_Type, Elm_Drop_Cb, void *);
641 Eina_Bool            elm_drop_target_del(Evas_Object *widget);
642 Eina_Bool            elm_drag_start(Evas_Object *, Elm_Sel_Format, const char *, void (*)(void *,Evas_Object*),void*);
643
644 #endif