elementary/elm_widget - added minor exceptions.
[framework/uifw/elementary.git] / src / lib / elm_widget.c
1 #include <Elementary.h>
2 #include "elm_priv.h"
3
4 static const char SMART_NAME[] = "elm_widget";
5
6 #define API_ENTRY \
7    Smart_Data *sd = evas_object_smart_data_get(obj); \
8    if ((!obj) || (!sd) || (!_elm_widget_is(obj)))
9 #define INTERNAL_ENTRY \
10    Smart_Data *sd = evas_object_smart_data_get(obj); \
11    if (!sd) return;
12
13 typedef struct _Smart_Data Smart_Data;
14 typedef struct _Edje_Signal_Data Edje_Signal_Data;
15 typedef struct _Elm_Event_Cb_Data Elm_Event_Cb_Data;
16
17 struct _Smart_Data
18 {
19    Evas_Object   *obj;
20    const char    *type;
21    Evas_Object   *parent_obj;
22    Evas_Coord     x, y, w, h;
23    Eina_List     *subobjs;
24    Evas_Object   *resize_obj;
25    Evas_Object   *hover_obj;
26    Eina_List     *tooltips, *cursors;
27    void         (*del_func) (Evas_Object *obj);
28    void         (*del_pre_func) (Evas_Object *obj);
29    void         (*focus_func) (Evas_Object *obj);
30    void         (*activate_func) (Evas_Object *obj);
31    void         (*disable_func) (Evas_Object *obj);
32    void         (*theme_func) (Evas_Object *obj);
33    Eina_Bool    (*event_func) (Evas_Object *obj, Evas_Object *source, Evas_Callback_Type type, void *event_info);
34    void         (*signal_func) (Evas_Object *obj, const char *emission,
35                                 const char *source);
36    void         (*callback_add_func) (Evas_Object *obj, const char *emission,
37                                 const char *source, void (*func) (void *data,
38                                    Evas_Object *o, const char *emission,
39                                    const char *source), void *data);
40    void         (*callback_del_func) (Evas_Object *obj, const char *emission,
41                                   const char *source, void (*func) (void *data,
42                                      Evas_Object *o, const char *emission,
43                                      const char *source), void *data);
44    void         (*changed_func) (Evas_Object *obj);
45    Eina_Bool    (*focus_next_func) (const Evas_Object *obj, Elm_Focus_Direction dir,
46                                     Evas_Object **next);
47    void         (*on_focus_func) (void *data, Evas_Object *obj);
48    void          *on_focus_data;
49    void         (*on_change_func) (void *data, Evas_Object *obj);
50    void          *on_change_data;
51    void         (*on_show_region_func) (void *data, Evas_Object *obj);
52    void          *on_show_region_data;
53    void         (*focus_region_func) (Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h);
54    void         (*on_focus_region_func) (const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h);
55    void          *data;
56    Evas_Coord     rx, ry, rw, rh;
57    int            scroll_hold;
58    int            scroll_freeze;
59    double         scale;
60    Elm_Theme     *theme;
61    const char    *style;
62    unsigned int   focus_order;
63    Eina_Bool      focus_order_on_calc;
64
65    int            child_drag_x_locked;
66    int            child_drag_y_locked;
67
68    Eina_List     *edje_signals;
69
70    Eina_Bool      drag_x_locked : 1;
71    Eina_Bool      drag_y_locked : 1;
72
73    Eina_Bool      can_focus : 1;
74    Eina_Bool      child_can_focus : 1;
75    Eina_Bool      focused : 1;
76    Eina_Bool      highlight_ignore : 1;
77    Eina_Bool      highlight_in_theme : 1;
78    Eina_Bool      disabled : 1;
79    Eina_Bool      is_mirrored : 1;
80    Eina_Bool      mirrored_auto_mode : 1; /* This is TRUE by default */
81
82    Eina_List     *focus_chain;
83    Eina_List     *event_cb;
84 };
85
86 struct _Edje_Signal_Data
87 {
88    Evas_Object *obj;
89    Edje_Signal_Cb func;
90    const char *emission;
91    const char *source;
92    void *data;
93 };
94
95 struct _Elm_Event_Cb_Data {
96      Elm_Event_Cb func;
97      const void *data;
98 };
99
100 /* local subsystem functions */
101 static void _smart_reconfigure(Smart_Data *sd);
102 static void _smart_add(Evas_Object *obj);
103 static void _smart_del(Evas_Object *obj);
104 static void _smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y);
105 static void _smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h);
106 static void _smart_show(Evas_Object *obj);
107 static void _smart_hide(Evas_Object *obj);
108 static void _smart_color_set(Evas_Object *obj, int r, int g, int b, int a);
109 static void _smart_clip_set(Evas_Object *obj, Evas_Object * clip);
110 static void _smart_clip_unset(Evas_Object *obj);
111 static void _smart_calculate(Evas_Object *obj);
112 static void _smart_init(void);
113
114 static void _if_focused_revert(Evas_Object *obj, Eina_Bool can_focus_only);
115 static Evas_Object *_newest_focus_order_get(Evas_Object *obj, unsigned int *newest_focus_order, Eina_Bool can_focus_only);
116
117 /* local subsystem globals */
118 static Evas_Smart *_e_smart = NULL;
119 static Eina_List  *widtypes = NULL;
120
121 static unsigned int focus_order = 0;
122
123 // internal funcs
124 static inline Eina_Bool
125 _elm_widget_is(const Evas_Object *obj)
126 {
127    const char *type = evas_object_type_get(obj);
128    return type == SMART_NAME;
129 }
130
131 static inline Eina_Bool
132 _is_focusable(Evas_Object *obj)
133 {
134    API_ENTRY return EINA_FALSE;
135    return sd->can_focus || (sd->child_can_focus);
136 }
137
138 static void
139 _unfocus_parents(Evas_Object *obj)
140 {
141    for (; obj; obj = elm_widget_parent_get(obj))
142      {
143         Smart_Data *sd = evas_object_smart_data_get(obj);
144         if (!sd) return;
145         if (!sd->focused) return;
146         sd->focused = 0;
147      }
148 }
149
150 static void
151 _focus_parents(Evas_Object *obj)
152 {
153    for (; obj; obj = elm_widget_parent_get(obj))
154      {
155         Smart_Data *sd = evas_object_smart_data_get(obj);
156         if (!sd) return;
157         if (sd->focused) return;
158         sd->focused = 1;
159      }
160 }
161
162 static void
163 _sub_obj_del(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
164 {
165    Smart_Data *sd = data;
166
167    if (_elm_widget_is(obj))
168      {
169         if (elm_widget_focus_get(obj)) _unfocus_parents(sd->obj);
170      }
171    if (obj == sd->resize_obj)
172      sd->resize_obj = NULL;
173    else if (obj == sd->hover_obj)
174      sd->hover_obj = NULL;
175    else
176      sd->subobjs = eina_list_remove(sd->subobjs, obj);
177    evas_object_smart_callback_call(sd->obj, "sub-object-del", obj);
178 }
179
180 static void
181 _sub_obj_mouse_down(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
182 {
183    Evas_Object *o = obj;
184    do
185      {
186         if (_elm_widget_is(o)) break;
187         o = evas_object_smart_parent_get(o);
188      }
189    while (o);
190    if (!o) return;
191    if (!_is_focusable(o)) return;
192    elm_widget_focus_steal(o);
193 }
194
195 static void
196 _propagate_x_drag_lock(Evas_Object *obj, int dir)
197 {
198    Smart_Data *sd = evas_object_smart_data_get(obj);
199    if (sd->parent_obj)
200      {
201         Smart_Data *sd2 = evas_object_smart_data_get(sd->parent_obj);
202         if (sd2)
203           {
204              sd2->child_drag_x_locked += dir;
205              _propagate_x_drag_lock(sd->parent_obj, dir);
206           }
207      }
208 }
209
210 static void
211 _propagate_y_drag_lock(Evas_Object *obj, int dir)
212 {
213    Smart_Data *sd = evas_object_smart_data_get(obj);
214    if (sd->parent_obj)
215      {
216         Smart_Data *sd2 = evas_object_smart_data_get(sd->parent_obj);
217         if (sd2)
218           {
219              sd2->child_drag_y_locked += dir;
220              _propagate_y_drag_lock(sd->parent_obj, dir);
221           }
222      }
223 }
224
225 static void
226 _propagate_event(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info)
227 {
228    INTERNAL_ENTRY;
229    Evas_Callback_Type type = (Evas_Callback_Type)(long) data;
230    Evas_Event_Flags *event_flags = NULL;
231
232    switch (type)
233      {
234      case EVAS_CALLBACK_KEY_DOWN:
235           {
236              Evas_Event_Key_Down *ev = event_info;
237              event_flags = &(ev->event_flags);
238              break;
239           }
240      case EVAS_CALLBACK_KEY_UP:
241           {
242              Evas_Event_Key_Up *ev = event_info;
243              event_flags = &(ev->event_flags);
244              break;
245           }
246      case EVAS_CALLBACK_MOUSE_WHEEL:
247           {
248              Evas_Event_Mouse_Wheel *ev = event_info;
249              event_flags = &(ev->event_flags);
250              break;
251           }
252      default:
253         break;
254      }
255
256    elm_widget_event_propagate(obj, type, event_info, event_flags);
257 }
258
259 static void
260 _parent_focus(Evas_Object *obj)
261 {
262    API_ENTRY return;
263
264    Evas_Object *o = elm_widget_parent_get(obj);
265    sd->focus_order_on_calc = EINA_TRUE;
266
267    if (sd->focused) return;
268    if (o)
269      {
270         unsigned int i = 0;
271         Evas_Object *ret;
272
273         ret = _newest_focus_order_get(o, &i, EINA_TRUE);
274
275         /* we don't want to bump a common widget ancestor's
276            focus_order *twice* while parent focusing */
277         if (!ret || (!i) || (i != focus_order))
278           _parent_focus(o);
279      }
280
281    if (!sd->focus_order_on_calc)
282      return; /* we don't want to override it if by means of any of the
283                 callbacks below one gets to calculate our order
284                 first. */
285
286    focus_order++;
287    sd->focus_order = focus_order;
288    sd->focused = EINA_TRUE;
289    if (sd->on_focus_func) sd->on_focus_func(sd->on_focus_data, obj);
290    if (sd->focus_func) sd->focus_func(obj);
291
292    _elm_widget_focus_region_show(obj);
293
294    sd->focus_order_on_calc = EINA_FALSE;
295 }
296
297 static void
298 _elm_object_focus_chain_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
299 {
300    Smart_Data *sd = data;
301
302    sd->focus_chain = eina_list_remove(sd->focus_chain, obj);
303 }
304
305 // exposed util funcs to elm
306 void
307 _elm_widget_type_clear(void)
308 {
309    const char **ptr;
310
311    EINA_LIST_FREE(widtypes, ptr)
312      {
313         eina_stringshare_del(*ptr);
314         *ptr = NULL;
315      }
316 }
317
318 void
319 _elm_widget_focus_region_show(const Evas_Object *obj)
320 {
321    Evas_Coord x, y, w, h, ox, oy;
322    Smart_Data *sd2;
323    Evas_Object *o;
324
325    API_ENTRY return;
326
327    o = elm_widget_parent_get(obj);
328    if (!o) return;
329
330    elm_widget_focus_region_get(obj, &x, &y, &w, &h);
331    evas_object_geometry_get(obj, &ox, &oy, NULL, NULL);
332    while (o)
333      {
334         Evas_Coord px, py;
335         sd2 = evas_object_smart_data_get(o);
336         if (sd2->focus_region_func)
337           {
338              sd2->focus_region_func(o, x, y, w, h);
339              elm_widget_focus_region_get(o, &x, &y, &w, &h);
340           }
341         else
342           {
343              evas_object_geometry_get(o, &px, &py, NULL, NULL);
344              x += ox - px;
345              y += oy - py;
346              ox = px;
347              oy = py;
348           }
349         o = elm_widget_parent_get(o);
350      }
351 }
352
353 /**
354  * @defgroup Widget Widget
355  *
356  * @internal
357  * Exposed api for making widgets
358  */
359 EAPI void
360 elm_widget_type_register(const char **ptr)
361 {
362    widtypes = eina_list_append(widtypes, (void *)ptr);
363 }
364
365 EAPI Eina_Bool
366 elm_widget_api_check(int ver)
367 {
368    if (ver != ELM_INTERNAL_API_VERSION)
369      {
370         CRITICAL("Elementary widget api versions do not match");
371         return EINA_FALSE;
372      }
373    return EINA_TRUE;
374 }
375
376 EAPI Evas_Object *
377 elm_widget_add(Evas *evas)
378 {
379    Evas_Object *obj;
380    _smart_init();
381    obj = evas_object_smart_add(evas, _e_smart);
382    elm_widget_mirrored_set(obj, elm_mirrored_get());
383    return obj;
384 }
385
386 EAPI void
387 elm_widget_del_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj))
388 {
389    API_ENTRY return;
390    sd->del_func = func;
391 }
392
393 EAPI void
394 elm_widget_del_pre_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj))
395 {
396    API_ENTRY return;
397    sd->del_pre_func = func;
398 }
399
400 EAPI void
401 elm_widget_focus_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj))
402 {
403    API_ENTRY return;
404    sd->focus_func = func;
405 }
406
407 EAPI void
408 elm_widget_activate_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj))
409 {
410    API_ENTRY return;
411    sd->activate_func = func;
412 }
413
414 EAPI void
415 elm_widget_disable_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj))
416 {
417    API_ENTRY return;
418    sd->disable_func = func;
419 }
420
421 EAPI void
422 elm_widget_theme_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj))
423 {
424    API_ENTRY return;
425    sd->theme_func = func;
426 }
427
428 EAPI void
429 elm_widget_event_hook_set(Evas_Object *obj, Eina_Bool (*func) (Evas_Object *obj, Evas_Object *source, Evas_Callback_Type type, void *event_info))
430 {
431    API_ENTRY return;
432    sd->event_func = func;
433 }
434
435 EAPI void
436 elm_widget_changed_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj))
437 {
438    API_ENTRY return;
439    sd->changed_func = func;
440 }
441
442 EAPI void
443 elm_widget_signal_emit_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj, const char *emission, const char *source))
444 {
445    API_ENTRY return;
446    sd->signal_func = func;
447 }
448
449 EAPI void
450 elm_widget_signal_callback_add_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj, const char *emission, const char *source, void (*func_cb) (void *data, Evas_Object *o, const char *emission, const char *source), void *data))
451 {
452    API_ENTRY return;
453    sd->callback_add_func = func;
454 }
455
456 EAPI void
457 elm_widget_signal_callback_del_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj, const char *emission, const char *source, void (*func_cb) (void *data, Evas_Object *o, const char *emission, const char *source), void *data))
458 {
459    API_ENTRY return;
460    sd->callback_del_func = func;
461 }
462
463 EAPI void
464 elm_widget_theme(Evas_Object *obj)
465 {
466    const Eina_List *l;
467    Evas_Object *child;
468    Elm_Tooltip *tt;
469    Elm_Cursor *cur;
470
471    API_ENTRY return;
472    EINA_LIST_FOREACH(sd->subobjs, l, child) elm_widget_theme(child);
473    if (sd->resize_obj) elm_widget_theme(sd->resize_obj);
474    if (sd->hover_obj) elm_widget_theme(sd->hover_obj);
475    EINA_LIST_FOREACH(sd->tooltips, l, tt) elm_tooltip_theme(tt);
476    EINA_LIST_FOREACH(sd->cursors, l, cur) elm_cursor_theme(cur);
477    if (sd->theme_func) sd->theme_func(obj);
478 }
479
480 EAPI void
481 elm_widget_theme_specific(Evas_Object *obj, Elm_Theme *th, Eina_Bool force)
482 {
483    const Eina_List *l;
484    Evas_Object *child;
485    Elm_Tooltip *tt;
486    Elm_Cursor *cur;
487    Elm_Theme *th2, *thdef;
488
489    API_ENTRY return;
490    thdef = elm_theme_default_get();
491    if (!th) th = thdef;
492    if (!force)
493      {
494         th2 = sd->theme;
495         if (!th2) th2 = thdef;
496         while (th2)
497           {
498              if (th2 == th)
499                {
500                   force = EINA_TRUE;
501                   break;
502                }
503              if (th2 == thdef) break;
504              th2 = th2->ref_theme;
505              if (!th2) th2 = thdef;
506           }
507      }
508    if (!force) return;
509    EINA_LIST_FOREACH(sd->subobjs, l, child)
510      elm_widget_theme_specific(child, th, force);
511    if (sd->resize_obj) elm_widget_theme(sd->resize_obj);
512    if (sd->hover_obj) elm_widget_theme(sd->hover_obj);
513    EINA_LIST_FOREACH(sd->tooltips, l, tt) elm_tooltip_theme(tt);
514    EINA_LIST_FOREACH(sd->cursors, l, cur) elm_cursor_theme(cur);
515    if (sd->theme_func) sd->theme_func(obj);
516 }
517
518 /**
519  * @internal
520  *
521  * Set hook to get next object in object focus chain.
522  *
523  * @param obj The widget object.
524  * @param func The hook to be used with this widget.
525  *
526  * @ingroup Widget
527  */
528 EAPI void
529 elm_widget_focus_next_hook_set(Evas_Object *obj, Eina_Bool (*func) (const Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next))
530 {
531    API_ENTRY return;
532    sd->focus_next_func = func;
533 }
534
535 /**
536  * Returns the widget's mirrored mode.
537  *
538  * @param obj The widget.
539  * @return mirrored mode of the object.
540  *
541  **/
542 EAPI Eina_Bool
543 elm_widget_mirrored_get(const Evas_Object *obj)
544 {
545    API_ENTRY return EINA_FALSE;
546    return sd->is_mirrored;
547 }
548
549 /**
550  * Sets the widget's mirrored mode.
551  *
552  * @param obj The widget.
553  * @param mirrored EINA_TRUE to set mirrored mode. EINA_FALSE to unset.
554  */
555 EAPI void
556 elm_widget_mirrored_set(Evas_Object *obj, Eina_Bool mirrored)
557 {
558    API_ENTRY return;
559    if (sd->is_mirrored != mirrored)
560      {
561         sd->is_mirrored = mirrored;
562         elm_widget_theme(obj);
563      }
564 }
565
566 /**
567  * @internal
568  * Resets the mirrored mode from the system mirror mode for widgets that are in
569  * automatic mirroring mode. This function does not call elm_widget_theme.
570  *
571  * @param obj The widget.
572  * @param mirrored EINA_TRUE to set mirrored mode. EINA_FALSE to unset.
573  */
574 void
575 _elm_widget_mirrored_reload(Evas_Object *obj)
576 {
577    API_ENTRY return;
578    Eina_Bool mirrored = elm_mirrored_get();
579    if (elm_widget_mirrored_automatic_get(obj) && (sd->is_mirrored != mirrored))
580      {
581         sd->is_mirrored = mirrored;
582      }
583 }
584
585 /**
586  * Returns the widget's mirrored mode setting.
587  *
588  * @param obj The widget.
589  * @return mirrored mode setting of the object.
590  *
591  **/
592 EAPI Eina_Bool
593 elm_widget_mirrored_automatic_get(const Evas_Object *obj)
594 {
595    API_ENTRY return EINA_FALSE;
596    return sd->mirrored_auto_mode;
597 }
598
599 /**
600  * Sets the widget's mirrored mode setting.
601  * When widget in automatic mode, it follows the system mirrored mode set by
602  * elm_mirrored_set().
603  * @param obj The widget.
604  * @param automatic EINA_TRUE for auto mirrored mode. EINA_FALSE for manual.
605  */
606 EAPI void
607 elm_widget_mirrored_automatic_set(Evas_Object *obj, Eina_Bool automatic)
608 {
609    API_ENTRY return;
610    if (sd->mirrored_auto_mode != automatic)
611      {
612         sd->mirrored_auto_mode = automatic;
613
614         if (automatic)
615           {
616              elm_widget_mirrored_set(obj, elm_mirrored_get());
617           }
618      }
619 }
620
621 EAPI void
622 elm_widget_on_focus_hook_set(Evas_Object *obj, void (*func) (void *data, Evas_Object *obj), void *data)
623 {
624    API_ENTRY return;
625    sd->on_focus_func = func;
626    sd->on_focus_data = data;
627 }
628
629 EAPI void
630 elm_widget_on_change_hook_set(Evas_Object *obj, void (*func) (void *data, Evas_Object *obj), void *data)
631 {
632    API_ENTRY return;
633    sd->on_change_func = func;
634    sd->on_change_data = data;
635 }
636
637 EAPI void
638 elm_widget_on_show_region_hook_set(Evas_Object *obj, void (*func) (void *data, Evas_Object *obj), void *data)
639 {
640    API_ENTRY return;
641    sd->on_show_region_func = func;
642    sd->on_show_region_data = data;
643 }
644
645 /**
646  * @internal
647  *
648  * Set the hook to use to show the focused region.
649  *
650  * Whenever a new widget gets focused or it's needed to show the focused
651  * area of the current one, this hook will be called on objects that may
652  * want to move their children into their visible area.
653  * The area given in the hook function is relative to the @p obj widget.
654  *
655  * @param obj The widget object
656  * @param func The function to call to show the specified area.
657  *
658  * @ingroup Widget
659  */
660 EAPI void
661 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))
662 {
663    API_ENTRY return;
664    sd->focus_region_func = func;
665 }
666
667 /**
668  * @internal
669  *
670  * Set the hook to retrieve the focused region of a widget.
671  *
672  * This hook will be called by elm_widget_focus_region_get() whenever
673  * it's needed to get the focused area of a widget. The area must be relative
674  * to the widget itself and if no hook is set, it will default to the entire
675  * object.
676  *
677  * @param obj The widget object
678  * @param func The function used to retrieve the focus region.
679  *
680  * @ingroup Widget
681  */
682 EAPI void
683 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))
684 {
685    API_ENTRY return;
686    sd->on_focus_region_func = func;
687 }
688
689 EAPI void
690 elm_widget_data_set(Evas_Object *obj, void *data)
691 {
692    API_ENTRY return;
693    sd->data = data;
694 }
695
696 EAPI void *
697 elm_widget_data_get(const Evas_Object *obj)
698 {
699    API_ENTRY return NULL;
700    return sd->data;
701 }
702
703 EAPI void
704 elm_widget_sub_object_add(Evas_Object *obj, Evas_Object *sobj)
705 {
706    API_ENTRY return;
707    double scale, pscale = elm_widget_scale_get(sobj);
708    Elm_Theme *th, *pth = elm_widget_theme_get(sobj);
709    Eina_Bool mirrored, pmirrored = elm_widget_mirrored_get(obj);
710
711    if (_elm_widget_is(sobj))
712      {
713         Smart_Data *sd2 = evas_object_smart_data_get(sobj);
714         if (sd2)
715           {
716              if (sd2->parent_obj == obj)
717                return;
718              if (sd2->parent_obj)
719                elm_widget_sub_object_del(sd2->parent_obj, sobj);
720              sd2->parent_obj = obj;
721              if (!sd->child_can_focus && (_is_focusable(sobj)))
722                sd->child_can_focus = EINA_TRUE;
723           }
724      }
725    else
726      {
727         void *data = evas_object_data_get(sobj, "elm-parent");
728         if (data)
729           {
730              if (data == obj) return;
731              evas_object_event_callback_del(sobj, EVAS_CALLBACK_DEL,
732                                             _sub_obj_del);
733           }
734      }
735
736    sd->subobjs = eina_list_append(sd->subobjs, sobj);
737    evas_object_data_set(sobj, "elm-parent", obj);
738    evas_object_event_callback_add(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
739    evas_object_smart_callback_call(obj, "sub-object-add", sobj);
740    scale = elm_widget_scale_get(sobj);
741    th = elm_widget_theme_get(sobj);
742    mirrored = elm_widget_mirrored_get(sobj);
743    if ((scale != pscale) || (th != pth) || (pmirrored != mirrored)) elm_widget_theme(sobj);
744    if (elm_widget_focus_get(sobj)) _focus_parents(obj);
745 }
746
747 EAPI void
748 elm_widget_sub_object_del(Evas_Object *obj, Evas_Object *sobj)
749 {
750    Evas_Object *sobj_parent;
751    API_ENTRY return;
752    if (!sobj) return;
753
754    sobj_parent = evas_object_data_del(sobj, "elm-parent");
755    if (sobj_parent != obj)
756      {
757         static int abort_on_warn = -1;
758         ERR("removing sub object %p from parent %p, "
759             "but elm-parent is different %p!",
760             sobj, obj, sobj_parent);
761         if (EINA_UNLIKELY(abort_on_warn == -1))
762           {
763              if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
764              else abort_on_warn = 0;
765           }
766         if (abort_on_warn == 1) abort();
767      }
768    if (!sd->child_can_focus)
769      {
770         if (_is_focusable(sobj)) sd->child_can_focus = 0;
771      }
772    if (_elm_widget_is(sobj))
773      {
774         Smart_Data *sd2 = evas_object_smart_data_get(sobj);
775         if (sd2)
776           {
777              sd2->parent_obj = NULL;
778              if (sd2->resize_obj == sobj)
779                sd2->resize_obj = NULL;
780              else
781                sd->subobjs = eina_list_remove(sd->subobjs, sobj);
782           }
783         else
784           sd->subobjs = eina_list_remove(sd->subobjs, sobj);
785         if (elm_widget_focus_get(sobj)) _unfocus_parents(obj);
786      }
787    else
788      sd->subobjs = eina_list_remove(sd->subobjs, sobj);
789    evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL,
790                                        _sub_obj_del, sd);
791    evas_object_smart_callback_call(obj, "sub-object-del", sobj);
792 }
793
794 EAPI void
795 elm_widget_resize_object_set(Evas_Object *obj, Evas_Object *sobj)
796 {
797    API_ENTRY return;
798    // orphan previous resize obj
799    if (sd->resize_obj)
800      {
801         evas_object_clip_unset(sd->resize_obj);
802         evas_object_data_del(sd->resize_obj, "elm-parent");
803         if (_elm_widget_is(sd->resize_obj))
804           {
805              Smart_Data *sd2 = evas_object_smart_data_get(sd->resize_obj);
806              if (sd2) sd2->parent_obj = NULL;
807           }
808         evas_object_event_callback_del_full(sd->resize_obj, EVAS_CALLBACK_DEL,
809                                             _sub_obj_del, sd);
810         evas_object_event_callback_del_full(sd->resize_obj, EVAS_CALLBACK_MOUSE_DOWN,
811                                             _sub_obj_mouse_down, sd);
812         evas_object_smart_member_del(sd->resize_obj);
813         if (_elm_widget_is(sd->resize_obj))
814           {
815              if (elm_widget_focus_get(sd->resize_obj)) _unfocus_parents(obj);
816           }
817      }
818    // orphan new resize obj
819    if (sobj)
820      {
821         evas_object_data_del(sobj, "elm-parent");
822         if (_elm_widget_is(sobj))
823           {
824              Smart_Data *sd2 = evas_object_smart_data_get(sobj);
825              if (sd2) sd2->parent_obj = NULL;
826           }
827         evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL,
828                                             _sub_obj_del, sd);
829         evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_MOUSE_DOWN,
830                                             _sub_obj_mouse_down, sd);
831         evas_object_smart_member_del(sobj);
832         if (_elm_widget_is(sobj))
833           {
834              if (elm_widget_focus_get(sobj)) _unfocus_parents(obj);
835           }
836      }
837    // set the resize obj up
838    sd->resize_obj = sobj;
839    if (sd->resize_obj)
840      {
841         if (_elm_widget_is(sd->resize_obj))
842           {
843              Smart_Data *sd2 = evas_object_smart_data_get(sd->resize_obj);
844              if (sd2) sd2->parent_obj = obj;
845           }
846         evas_object_clip_set(sobj, evas_object_clip_get(obj));
847         evas_object_smart_member_add(sobj, obj);
848         evas_object_event_callback_add(sobj, EVAS_CALLBACK_DEL,
849                                        _sub_obj_del, sd);
850         evas_object_event_callback_add(sobj, EVAS_CALLBACK_MOUSE_DOWN,
851                                        _sub_obj_mouse_down, sd);
852         _smart_reconfigure(sd);
853         evas_object_data_set(sobj, "elm-parent", obj);
854         evas_object_smart_callback_call(obj, "sub-object-add", sobj);
855         if (_elm_widget_is(sobj))
856           {
857              if (elm_widget_focus_get(sobj)) _focus_parents(obj);
858           }
859      }
860 }
861
862 EAPI void
863 elm_widget_hover_object_set(Evas_Object *obj, Evas_Object *sobj)
864 {
865    API_ENTRY return;
866    if (sd->hover_obj)
867      {
868         evas_object_event_callback_del_full(sd->hover_obj, EVAS_CALLBACK_DEL,
869            _sub_obj_del, sd);
870      }
871    sd->hover_obj = sobj;
872    if (sd->hover_obj)
873      {
874         evas_object_event_callback_add(sobj, EVAS_CALLBACK_DEL,
875                                        _sub_obj_del, sd);
876         _smart_reconfigure(sd);
877      }
878 }
879
880 EAPI void
881 elm_widget_can_focus_set(Evas_Object *obj, Eina_Bool can_focus)
882 {
883    API_ENTRY return;
884    sd->can_focus = can_focus;
885    if (can_focus)
886      {
887         evas_object_event_callback_add(obj, EVAS_CALLBACK_KEY_DOWN,
888                                        _propagate_event,
889                                        (void *)(long) EVAS_CALLBACK_KEY_DOWN);
890         evas_object_event_callback_add(obj, EVAS_CALLBACK_KEY_UP,
891                                        _propagate_event,
892                                        (void *)(long) EVAS_CALLBACK_KEY_UP);
893         evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_WHEEL,
894                                        _propagate_event,
895                                        (void *)(long)EVAS_CALLBACK_MOUSE_WHEEL);
896      }
897    else
898      {
899         evas_object_event_callback_del(obj, EVAS_CALLBACK_KEY_DOWN,
900                                        _propagate_event);
901         evas_object_event_callback_del(obj, EVAS_CALLBACK_KEY_UP,
902                                        _propagate_event);
903         evas_object_event_callback_del(obj, EVAS_CALLBACK_MOUSE_WHEEL,
904                                        _propagate_event);
905      }
906 }
907
908 EAPI Eina_Bool
909 elm_widget_can_focus_get(const Evas_Object *obj)
910 {
911    API_ENTRY return EINA_FALSE;
912    return sd->can_focus;
913 }
914
915 EAPI Eina_Bool
916 elm_widget_child_can_focus_get(const Evas_Object *obj)
917 {
918    API_ENTRY return EINA_FALSE;
919    return sd->child_can_focus;
920 }
921
922 EAPI void
923 elm_widget_highlight_ignore_set(Evas_Object *obj, Eina_Bool ignore)
924 {
925    API_ENTRY return;
926    sd->highlight_ignore = !!ignore;
927 }
928
929 EAPI Eina_Bool
930 elm_widget_highlight_ignore_get(const Evas_Object *obj)
931 {
932    API_ENTRY return EINA_FALSE;
933    return sd->highlight_ignore;
934 }
935
936 EAPI void
937 elm_widget_highlight_in_theme_set(Evas_Object *obj, Eina_Bool highlight)
938 {
939    API_ENTRY return;
940    sd->highlight_in_theme = !!highlight;
941    /* FIXME: if focused, it should switch from one mode to the other */
942 }
943
944 EAPI Eina_Bool
945 elm_widget_highlight_in_theme_get(const Evas_Object *obj)
946 {
947    API_ENTRY return EINA_FALSE;
948    return sd->highlight_in_theme;
949 }
950
951 EAPI Eina_Bool
952 elm_widget_focus_get(const Evas_Object *obj)
953 {
954    API_ENTRY return EINA_FALSE;
955    return sd->focused;
956 }
957
958 EAPI Evas_Object *
959 elm_widget_focused_object_get(const Evas_Object *obj)
960 {
961    const Evas_Object *subobj;
962    const Eina_List *l;
963    API_ENTRY return NULL;
964
965    if (!sd->focused) return NULL;
966    EINA_LIST_FOREACH(sd->subobjs, l, subobj)
967      {
968         Evas_Object *fobj = elm_widget_focused_object_get(subobj);
969         if (fobj) return fobj;
970      }
971    return (Evas_Object *)obj;
972 }
973
974 EAPI Evas_Object *
975 elm_widget_top_get(const Evas_Object *obj)
976 {
977    API_ENTRY return NULL;
978    if (sd->parent_obj) return elm_widget_top_get(sd->parent_obj);
979    return (Evas_Object *)obj;
980 }
981
982 EAPI Eina_Bool
983 elm_widget_is(const Evas_Object *obj)
984 {
985    return _elm_widget_is(obj);
986 }
987
988 EAPI Evas_Object *
989 elm_widget_parent_widget_get(const Evas_Object *obj)
990 {
991    Evas_Object *parent;
992
993    if (_elm_widget_is(obj))
994      {
995         Smart_Data *sd = evas_object_smart_data_get(obj);
996         if (!sd) return NULL;
997         parent = sd->parent_obj;
998      }
999    else
1000      {
1001         parent = evas_object_data_get(obj, "elm-parent");
1002         if (!parent) parent = evas_object_smart_parent_get(obj);
1003      }
1004
1005    while (parent)
1006      {
1007         Evas_Object *elm_parent;
1008         if (_elm_widget_is(parent)) break;
1009         elm_parent = evas_object_data_get(parent, "elm-parent");
1010         if (elm_parent) parent = elm_parent;
1011         else parent = evas_object_smart_parent_get(parent);
1012      }
1013    return parent;
1014 }
1015
1016 EAPI void
1017 elm_widget_event_callback_add(Evas_Object *obj, Elm_Event_Cb func, const void *data)
1018 {
1019    API_ENTRY return;
1020    EINA_SAFETY_ON_NULL_RETURN(func);
1021    Elm_Event_Cb_Data *ecb = ELM_NEW(Elm_Event_Cb_Data);
1022    ecb->func = func;
1023    ecb->data = data;
1024    sd->event_cb = eina_list_append(sd->event_cb, ecb);
1025 }
1026
1027 EAPI void *
1028 elm_widget_event_callback_del(Evas_Object *obj, Elm_Event_Cb func, const void *data)
1029 {
1030    API_ENTRY return NULL;
1031    EINA_SAFETY_ON_NULL_RETURN_VAL(func, NULL);
1032    Eina_List *l;
1033    Elm_Event_Cb_Data *ecd;
1034    EINA_LIST_FOREACH(sd->event_cb, l, ecd)
1035       if ((ecd->func == func) && (ecd->data == data))
1036         {
1037            free(ecd);
1038            sd->event_cb = eina_list_remove_list(sd->event_cb, l);
1039            return (void *)data;
1040         }
1041    return NULL;
1042 }
1043
1044 EAPI Eina_Bool
1045 elm_widget_event_propagate(Evas_Object *obj, Evas_Callback_Type type, void *event_info, Evas_Event_Flags *event_flags)
1046 {
1047    API_ENTRY return EINA_FALSE; //TODO reduce.
1048    if (!_elm_widget_is(obj)) return EINA_FALSE;
1049    Evas_Object *parent = obj;
1050    Elm_Event_Cb_Data *ecd;
1051    Eina_List *l, *l_prev;
1052
1053    while (parent &&
1054           (!(event_flags && ((*event_flags) & EVAS_EVENT_FLAG_ON_HOLD))))
1055      {
1056         sd = evas_object_smart_data_get(parent);
1057         if ((!sd) || (!_elm_widget_is(obj)))
1058           return EINA_FALSE; //Not Elm Widget
1059
1060         if (sd->event_func && (sd->event_func(parent, obj, type, event_info)))
1061           return EINA_TRUE;
1062
1063         EINA_LIST_FOREACH_SAFE(sd->event_cb, l, l_prev, ecd)
1064           {
1065              if (ecd->func((void *)ecd->data, parent, obj, type, event_info) ||
1066                  (event_flags && ((*event_flags) & EVAS_EVENT_FLAG_ON_HOLD)))
1067                  return EINA_TRUE;
1068           }
1069         parent = sd->parent_obj;
1070      }
1071
1072    return EINA_FALSE;
1073 }
1074
1075 /**
1076  * @internal
1077  *
1078  * Set custom focus chain.
1079  *
1080  * This function i set one new and overwrite any previous custom focus chain
1081  * with the list of objects. The previous list will be deleted and this list
1082  * will be managed. After setted, don't modity it.
1083  *
1084  * @note On focus cycle, only will be evaluated children of this container.
1085  *
1086  * @param obj The container widget
1087  * @param objs Chain of objects to pass focus
1088  * @ingroup Widget
1089  */
1090 EAPI void
1091 elm_widget_focus_custom_chain_set(Evas_Object *obj, Eina_List *objs)
1092 {
1093    API_ENTRY return;
1094    if (!sd->focus_next_func)
1095      return;
1096
1097    elm_widget_focus_custom_chain_unset(obj);
1098
1099    Eina_List *l;
1100    Evas_Object *o;
1101
1102    EINA_LIST_FOREACH(objs, l, o)
1103      {
1104         evas_object_event_callback_add(o, EVAS_CALLBACK_DEL,
1105                                        _elm_object_focus_chain_del_cb, sd);
1106      }
1107
1108    sd->focus_chain = objs;
1109 }
1110
1111 /**
1112  * @internal
1113  *
1114  * Get custom focus chain
1115  *
1116  * @param obj The container widget
1117  * @ingroup Widget
1118  */
1119 EAPI const Eina_List *
1120 elm_widget_focus_custom_chain_get(const Evas_Object *obj)
1121 {
1122    API_ENTRY return NULL;
1123    return (const Eina_List *) sd->focus_chain;
1124 }
1125
1126 /**
1127  * @internal
1128  *
1129  * Unset custom focus chain
1130  *
1131  * @param obj The container widget
1132  * @ingroup Widget
1133  */
1134 EAPI void
1135 elm_widget_focus_custom_chain_unset(Evas_Object *obj)
1136 {
1137    API_ENTRY return;
1138    Eina_List *l, *l_next;
1139    Evas_Object *o;
1140
1141    EINA_LIST_FOREACH_SAFE(sd->focus_chain, l, l_next, o)
1142      {
1143         evas_object_event_callback_del_full(o, EVAS_CALLBACK_DEL,
1144                                             _elm_object_focus_chain_del_cb, sd);
1145         sd->focus_chain = eina_list_remove_list(sd->focus_chain, l);
1146      }
1147 }
1148
1149 /**
1150  * @internal
1151  *
1152  * Append object to custom focus chain.
1153  *
1154  * @note If relative_child equal to NULL or not in custom chain, the object
1155  * will be added in end.
1156  *
1157  * @note On focus cycle, only will be evaluated children of this container.
1158  *
1159  * @param obj The container widget
1160  * @param child The child to be added in custom chain
1161  * @param relative_child The relative object to position the child
1162  * @ingroup Widget
1163  */
1164 EAPI void
1165 elm_widget_focus_custom_chain_append(Evas_Object *obj, Evas_Object *child, Evas_Object *relative_child)
1166 {
1167    API_ENTRY return;
1168    EINA_SAFETY_ON_NULL_RETURN(child);
1169    if (!sd->focus_next_func)
1170      return;
1171
1172    evas_object_event_callback_del_full(child, EVAS_CALLBACK_DEL,
1173                                        _elm_object_focus_chain_del_cb, sd);
1174
1175    if (!relative_child)
1176      {
1177         sd->focus_chain = eina_list_append(sd->focus_chain, child);
1178         return;
1179      }
1180
1181    sd->focus_chain = eina_list_append_relative(sd->focus_chain, child, relative_child);
1182    return;
1183 }
1184
1185 /**
1186  * @internal
1187  *
1188  * Prepend object to custom focus chain.
1189  *
1190  * @note If relative_child equal to NULL or not in custom chain, the object
1191  * will be added in begin.
1192  *
1193  * @note On focus cycle, only will be evaluated children of this container.
1194  *
1195  * @param obj The container widget
1196  * @param child The child to be added in custom chain
1197  * @param relative_child The relative object to position the child
1198  * @ingroup Widget
1199  */
1200 EAPI void
1201 elm_widget_focus_custom_chain_prepend(Evas_Object *obj, Evas_Object *child, Evas_Object *relative_child)
1202 {
1203    API_ENTRY return;
1204    EINA_SAFETY_ON_NULL_RETURN(child);
1205    if (!sd->focus_next_func)
1206      return;
1207
1208    evas_object_event_callback_del_full(child, EVAS_CALLBACK_DEL,
1209                                        _elm_object_focus_chain_del_cb, sd);
1210
1211    if (!relative_child)
1212      {
1213         sd->focus_chain = eina_list_prepend(sd->focus_chain, child);
1214         return;
1215      }
1216
1217    sd->focus_chain = eina_list_prepend_relative(sd->focus_chain, child, relative_child);
1218    return;
1219 }
1220
1221 /**
1222  * @internal
1223  *
1224  * Give focus to next object in object tree.
1225  *
1226  * Give focus to next object in focus chain of one object sub-tree.
1227  * If the last object of chain already have focus, the focus will go to the
1228  * first object of chain.
1229  *
1230  * @param obj The widget root of sub-tree
1231  * @param dir Direction to cycle the focus
1232  *
1233  * @ingroup Widget
1234  */
1235 EAPI void
1236 elm_widget_focus_cycle(Evas_Object *obj, Elm_Focus_Direction dir)
1237 {
1238    Evas_Object *target = NULL;
1239    if (!_elm_widget_is(obj))
1240      return;
1241    elm_widget_focus_next_get(obj, dir, &target);
1242    if (target)
1243      elm_widget_focus_steal(target);
1244 }
1245
1246 /**
1247  * @internal
1248  *
1249  * Give focus to near object in one direction.
1250  *
1251  * Give focus to near object in direction of one object.
1252  * If none focusable object in given direction, the focus will not change.
1253  *
1254  * @param obj The reference widget
1255  * @param x Horizontal component of direction to focus
1256  * @param y Vertical component of direction to focus
1257  *
1258  * @ingroup Widget
1259  */
1260 EAPI void
1261 elm_widget_focus_direction_go(Evas_Object *obj __UNUSED__, int x __UNUSED__, int y __UNUSED__)
1262 {
1263    return; /* TODO */
1264 }
1265
1266 /**
1267  * @internal
1268  *
1269  * Get next object in focus chain of object tree.
1270  *
1271  * Get next object in focus chain of one object sub-tree.
1272  * Return the next object by reference. If don't have any candidate to receive
1273  * focus before chain end, the first candidate will be returned.
1274  *
1275  * @param obj The widget root of sub-tree
1276  * @param dir Direction os focus chain
1277  * @param next The next object in focus chain
1278  * @return EINA_TRUE if don't need focus chain restart/loop back
1279  *         to use 'next' obj.
1280  *
1281  * @ingroup Widget
1282  */
1283 EAPI Eina_Bool
1284 elm_widget_focus_next_get(const Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next)
1285 {
1286    if (!next)
1287      return EINA_FALSE;
1288    *next = NULL;
1289
1290    API_ENTRY return EINA_FALSE;
1291
1292    /* Ignore if disabled */
1293    if ((!evas_object_visible_get(obj)) || (elm_widget_disabled_get(obj)))
1294      return EINA_FALSE;
1295
1296    /* Try use hook */
1297    if (sd->focus_next_func)
1298      return sd->focus_next_func(obj, dir, next);
1299
1300    if (!elm_widget_can_focus_get(obj))
1301      return EINA_FALSE;
1302
1303    /* Return */
1304    *next = (Evas_Object *)obj;
1305    return !elm_widget_focus_get(obj);
1306 }
1307
1308
1309 /**
1310  * @internal
1311  *
1312  * Get next object in focus chain of object tree in list.
1313  *
1314  * Get next object in focus chain of one object sub-tree ordered by one list.
1315  * Return the next object by reference. If don't have any candidate to receive
1316  * focus before list end, the first candidate will be returned.
1317  *
1318  * @param obj The widget root of sub-tree
1319  * @param dir Direction os focus chain
1320  * @param items list with ordered objects
1321  * @param list_data_get function to get the object from one item of list
1322  * @param next The next object in focus chain
1323  * @return EINA_TRUE if don't need focus chain restart/loop back
1324  *         to use 'next' obj.
1325  *
1326  * @ingroup Widget
1327  */
1328 EAPI Eina_Bool
1329 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)
1330 {
1331    Eina_List *(*list_next) (const Eina_List *list);
1332
1333    if (!next)
1334      return EINA_FALSE;
1335    *next = NULL;
1336
1337    if (!_elm_widget_is(obj))
1338      return EINA_FALSE;
1339
1340    if (!items)
1341      return EINA_FALSE;
1342
1343    /* Direction */
1344    if (dir == ELM_FOCUS_PREVIOUS)
1345      {
1346         items = eina_list_last(items);
1347         list_next = eina_list_prev;
1348      }
1349    else if (dir == ELM_FOCUS_NEXT)
1350      list_next = eina_list_next;
1351    else
1352      return EINA_FALSE;
1353
1354    const Eina_List *l = items;
1355
1356    /* Recovery last focused sub item */
1357    if (elm_widget_focus_get(obj))
1358      for (; l; l = list_next(l))
1359        {
1360           Evas_Object *cur = list_data_get(l);
1361           if (elm_widget_focus_get(cur)) break;
1362        }
1363
1364    const Eina_List *start = l;
1365    Evas_Object *to_focus = NULL;
1366
1367    /* Interate sub items */
1368    /* Go to end of list */
1369    for (; l; l = list_next(l))
1370      {
1371         Evas_Object *tmp = NULL;
1372         Evas_Object *cur = list_data_get(l);
1373
1374         if (elm_widget_parent_get(cur) != obj)
1375           continue;
1376
1377         /* Try Focus cycle in subitem */
1378         if (elm_widget_focus_next_get(cur, dir, &tmp))
1379           {
1380              *next = tmp;
1381              return EINA_TRUE;
1382           }
1383         else if ((tmp) && (!to_focus))
1384           to_focus = tmp;
1385      }
1386
1387    l = items;
1388
1389    /* Get First possible */
1390    for (;l != start; l = list_next(l))
1391      {
1392         Evas_Object *tmp = NULL;
1393         Evas_Object *cur = list_data_get(l);
1394
1395         if (elm_widget_parent_get(cur) != obj)
1396           continue;
1397
1398         /* Try Focus cycle in subitem */
1399         elm_widget_focus_next_get(cur, dir, &tmp);
1400         if (tmp)
1401           {
1402              *next = tmp;
1403              return EINA_FALSE;
1404           }
1405      }
1406
1407    *next = to_focus;
1408    return EINA_FALSE;
1409 }
1410
1411 EAPI void
1412 elm_widget_signal_emit(Evas_Object *obj, const char *emission, const char *source)
1413 {
1414    API_ENTRY return;
1415    if (!sd->signal_func) return;
1416    sd->signal_func(obj, emission, source);
1417 }
1418
1419 static void
1420 _edje_signal_callback(void *data, Evas_Object *obj __UNUSED__, const char *emission, const char *source)
1421 {
1422    Edje_Signal_Data *esd = data;
1423    esd->func(esd->data, esd->obj, emission, source);
1424 }
1425
1426 EAPI void
1427 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)
1428 {
1429    Edje_Signal_Data *esd;
1430    API_ENTRY return;
1431    if (!sd->callback_add_func) return;
1432    EINA_SAFETY_ON_NULL_RETURN(func);
1433
1434    esd = ELM_NEW(Edje_Signal_Data);
1435    if (!esd) return;
1436
1437    esd->obj = obj;
1438    esd->func = func;
1439    esd->emission = eina_stringshare_add(emission);
1440    esd->source = eina_stringshare_add(source);
1441    esd->data = data;
1442    sd->edje_signals = eina_list_append(sd->edje_signals, esd);
1443    sd->callback_add_func(obj, emission, source, _edje_signal_callback, esd);
1444 }
1445
1446 EAPI void *
1447 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))
1448 {
1449    Edje_Signal_Data *esd;
1450    Eina_List *l;
1451    void *data = NULL;
1452    API_ENTRY return NULL;
1453    if (!sd->callback_del_func) return NULL;
1454
1455    EINA_LIST_FOREACH(sd->edje_signals, l, esd)
1456      {
1457         if ((esd->func == func) && (!strcmp(esd->emission, emission)) &&
1458             (!strcmp(esd->source, source)))
1459           {
1460              sd->edje_signals = eina_list_remove_list(sd->edje_signals, l);
1461              eina_stringshare_del(esd->emission);
1462              eina_stringshare_del(esd->source);
1463              data = esd->data;
1464              free(esd);
1465              break;
1466           }
1467      }
1468    sd->callback_del_func(obj, emission, source, _edje_signal_callback, esd);
1469    return data;
1470 }
1471
1472 EAPI void
1473 elm_widget_focus_set(Evas_Object *obj, int first)
1474 {
1475    API_ENTRY return;
1476    if (!sd->focused)
1477      {
1478         focus_order++;
1479         sd->focus_order = focus_order;
1480         sd->focused = EINA_TRUE;
1481         if (sd->on_focus_func) sd->on_focus_func(sd->on_focus_data, obj);
1482      }
1483    if (sd->focus_func)
1484      {
1485         sd->focus_func(obj);
1486         return;
1487      }
1488    else
1489      {
1490         if (first)
1491           {
1492              if ((_is_focusable(sd->resize_obj)) &&
1493                  (!elm_widget_disabled_get(sd->resize_obj)))
1494                {
1495                   elm_widget_focus_set(sd->resize_obj, first);
1496                }
1497              else
1498                {
1499                   const Eina_List *l;
1500                   Evas_Object *child;
1501                   EINA_LIST_FOREACH(sd->subobjs, l, child)
1502                     {
1503                        if ((_is_focusable(child)) &&
1504                            (!elm_widget_disabled_get(child)))
1505                          {
1506                             elm_widget_focus_set(child, first);
1507                             break;
1508                          }
1509                     }
1510                }
1511           }
1512         else
1513           {
1514              const Eina_List *l;
1515              Evas_Object *child;
1516              EINA_LIST_REVERSE_FOREACH(sd->subobjs, l, child)
1517                {
1518                   if ((_is_focusable(child)) &&
1519                       (!elm_widget_disabled_get(child)))
1520                     {
1521                        elm_widget_focus_set(child, first);
1522                        break;
1523                     }
1524                }
1525              if (!l)
1526                {
1527                   if ((_is_focusable(sd->resize_obj)) &&
1528                       (!elm_widget_disabled_get(sd->resize_obj)))
1529                     {
1530                        elm_widget_focus_set(sd->resize_obj, first);
1531                     }
1532                }
1533           }
1534      }
1535 }
1536
1537 EAPI Evas_Object *
1538 elm_widget_parent_get(const Evas_Object *obj)
1539 {
1540    API_ENTRY return NULL;
1541    return sd->parent_obj;
1542 }
1543
1544 EAPI void
1545 elm_widget_focused_object_clear(Evas_Object *obj)
1546 {
1547    API_ENTRY return;
1548    if (!sd->focused) return;
1549    if (elm_widget_focus_get(sd->resize_obj))
1550       elm_widget_focused_object_clear(sd->resize_obj);
1551    else
1552      {
1553         const Eina_List *l;
1554         Evas_Object *child;
1555         EINA_LIST_FOREACH(sd->subobjs, l, child)
1556           {
1557              if (elm_widget_focus_get(child))
1558                {
1559                   elm_widget_focused_object_clear(child);
1560                   break;
1561                }
1562           }
1563      }
1564    sd->focused = EINA_FALSE;
1565    if (sd->on_focus_func) sd->on_focus_func(sd->on_focus_data, obj);
1566    if (sd->focus_func) sd->focus_func(obj);
1567 }
1568
1569 EAPI void
1570 elm_widget_focus_steal(Evas_Object *obj)
1571 {
1572    Evas_Object *parent, *o;
1573    API_ENTRY return;
1574
1575    if (sd->focused) return;
1576    if (sd->disabled) return;
1577    parent = obj;
1578    for (;;)
1579      {
1580         o = elm_widget_parent_get(parent);
1581         if (!o) break;
1582         sd = evas_object_smart_data_get(o);
1583         if (sd->focused) break;
1584         parent = o;
1585      }
1586    if (!elm_widget_parent_get(parent))
1587      elm_widget_focused_object_clear(parent);
1588    else
1589      {
1590         parent = elm_widget_parent_get(parent);
1591         sd = evas_object_smart_data_get(parent);
1592         if (sd->resize_obj)
1593           {
1594              if (elm_widget_focus_get(sd->resize_obj))
1595                elm_widget_focused_object_clear(sd->resize_obj);
1596           }
1597         else
1598           {
1599              const Eina_List *l;
1600              Evas_Object *child;
1601              EINA_LIST_FOREACH(sd->subobjs, l, child)
1602                {
1603                   if (elm_widget_focus_get(child))
1604                     {
1605                        elm_widget_focused_object_clear(child);
1606                        break;
1607                     }
1608                }
1609           }
1610      }
1611    _parent_focus(obj);
1612    return;
1613 }
1614
1615 EAPI void
1616 elm_widget_activate(Evas_Object *obj)
1617 {
1618    API_ENTRY return;
1619    elm_widget_change(obj);
1620    if (sd->activate_func) sd->activate_func(obj);
1621 }
1622
1623 EAPI void
1624 elm_widget_change(Evas_Object *obj)
1625 {
1626    API_ENTRY return;
1627    elm_widget_change(elm_widget_parent_get(obj));
1628    if (sd->on_change_func) sd->on_change_func(sd->on_change_data, obj);
1629 }
1630
1631 EAPI void
1632 elm_widget_disabled_set(Evas_Object *obj, int disabled)
1633 {
1634    API_ENTRY return;
1635
1636    if (sd->disabled == disabled) return;
1637    sd->disabled = disabled;
1638    if (sd->focused)
1639      {
1640         Evas_Object *o, *parent;
1641
1642         parent = obj;
1643         for (;;)
1644           {
1645              o = elm_widget_parent_get(parent);
1646              if (!o) break;
1647              parent = o;
1648           }
1649         if (elm_widget_focus_get(obj))
1650           elm_widget_focus_cycle(parent, ELM_FOCUS_NEXT);
1651      }
1652    if (sd->disable_func) sd->disable_func(obj);
1653 }
1654
1655 EAPI int
1656 elm_widget_disabled_get(const Evas_Object *obj)
1657 {
1658    API_ENTRY return 0;
1659    return sd->disabled;
1660 }
1661
1662 EAPI void
1663 elm_widget_show_region_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
1664 {
1665    Evas_Object *parent_obj, *child_obj;
1666    Evas_Coord px, py, cx, cy;
1667
1668    API_ENTRY return;
1669    if ((x == sd->rx) && (y == sd->ry) && (w == sd->rw) && (h == sd->rh)) return;
1670    sd->rx = x;
1671    sd->ry = y;
1672    sd->rw = w;
1673    sd->rh = h;
1674    if (sd->on_show_region_func)
1675       sd->on_show_region_func(sd->on_show_region_data, obj);
1676
1677    do
1678      {
1679         parent_obj = sd->parent_obj;
1680         child_obj = sd->obj;
1681         sd = evas_object_smart_data_get(parent_obj);
1682
1683         if ((!parent_obj) || (!sd) || (!_elm_widget_is(parent_obj))) break;
1684
1685         evas_object_geometry_get(parent_obj, &px, &py, NULL, NULL);
1686         evas_object_geometry_get(child_obj, &cx, &cy, NULL, NULL);
1687
1688         x += (cx - px);
1689         y += (cy - py);
1690         sd->rx = x;
1691         sd->ry = y;
1692         sd->rw = w;
1693         sd->rh = h;
1694
1695         if (sd->on_show_region_func)
1696           {
1697              sd->on_show_region_func(sd->on_show_region_data, parent_obj);
1698           }
1699      }
1700    while (parent_obj);
1701 }
1702
1703 EAPI void
1704 elm_widget_show_region_get(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
1705 {
1706    API_ENTRY return;
1707    if (x) *x = sd->rx;
1708    if (y) *y = sd->ry;
1709    if (w) *w = sd->rw;
1710    if (h) *h = sd->rh;
1711 }
1712
1713 /**
1714  * @internal
1715  *
1716  * Get the focus region of the given widget.
1717  *
1718  * The focus region is the area of a widget that should brought into the
1719  * visible area when the widget is focused. Mostly used to show the part of
1720  * an entry where the cursor is, for example. The area returned is relative
1721  * to the object @p obj.
1722  * If the @p obj doesn't have the proper on_focus_region_hook set, this
1723  * function will return the full size of the object.
1724  *
1725  * @param obj The widget object
1726  * @param x Where to store the x coordinate of the area
1727  * @param y Where to store the y coordinate of the area
1728  * @param w Where to store the width of the area
1729  * @param h Where to store the height of the area
1730  *
1731  * @ingroup Widget
1732  */
1733 EAPI void
1734 elm_widget_focus_region_get(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
1735 {
1736    Smart_Data *sd;
1737
1738    if (!obj) return;
1739
1740    sd = evas_object_smart_data_get(obj);
1741    if (!sd || !_elm_widget_is(obj) || !sd->on_focus_region_func)
1742      {
1743         evas_object_geometry_get(obj, NULL, NULL, w, h);
1744         if (x) *x = 0;
1745         if (y) *y = 0;
1746         return;
1747      }
1748    sd->on_focus_region_func(obj, x, y, w, h);
1749 }
1750
1751 EAPI void
1752 elm_widget_scroll_hold_push(Evas_Object *obj)
1753 {
1754    API_ENTRY return;
1755    sd->scroll_hold++;
1756    if (sd->scroll_hold == 1)
1757       evas_object_smart_callback_call(obj, "scroll-hold-on", obj);
1758    if (sd->parent_obj) elm_widget_scroll_hold_push(sd->parent_obj);
1759    // FIXME: on delete/reparent hold pop
1760 }
1761
1762 EAPI void
1763 elm_widget_scroll_hold_pop(Evas_Object *obj)
1764 {
1765    API_ENTRY return;
1766    sd->scroll_hold--;
1767    if (sd->scroll_hold < 0) sd->scroll_hold = 0;
1768    if (!sd->scroll_hold)
1769       evas_object_smart_callback_call(obj, "scroll-hold-off", obj);
1770    if (sd->parent_obj) elm_widget_scroll_hold_pop(sd->parent_obj);
1771 }
1772
1773 EAPI int
1774 elm_widget_scroll_hold_get(const Evas_Object *obj)
1775 {
1776    API_ENTRY return 0;
1777    return sd->scroll_hold;
1778 }
1779
1780 EAPI void
1781 elm_widget_scroll_freeze_push(Evas_Object *obj)
1782 {
1783    API_ENTRY return;
1784    sd->scroll_freeze++;
1785    if (sd->scroll_freeze == 1)
1786       evas_object_smart_callback_call(obj, "scroll-freeze-on", obj);
1787    if (sd->parent_obj) elm_widget_scroll_freeze_push(sd->parent_obj);
1788    // FIXME: on delete/reparent freeze pop
1789 }
1790
1791 EAPI void
1792 elm_widget_scroll_freeze_pop(Evas_Object *obj)
1793 {
1794    API_ENTRY return;
1795    sd->scroll_freeze--;
1796    if (sd->scroll_freeze < 0) sd->scroll_freeze = 0;
1797    if (!sd->scroll_freeze)
1798       evas_object_smart_callback_call(obj, "scroll-freeze-off", obj);
1799    if (sd->parent_obj) elm_widget_scroll_freeze_pop(sd->parent_obj);
1800 }
1801
1802 EAPI int
1803 elm_widget_scroll_freeze_get(const Evas_Object *obj)
1804 {
1805    API_ENTRY return 0;
1806    return sd->scroll_freeze;
1807 }
1808
1809 EAPI void
1810 elm_widget_scale_set(Evas_Object *obj, double scale)
1811 {
1812    API_ENTRY return;
1813    if (scale <= 0.0) scale = 0.0;
1814    if (sd->scale != scale)
1815      {
1816         sd->scale = scale;
1817         elm_widget_theme(obj);
1818      }
1819 }
1820
1821 EAPI double
1822 elm_widget_scale_get(const Evas_Object *obj)
1823 {
1824    API_ENTRY return 1.0;
1825    // FIXME: save walking up the tree by storing/caching parent scale
1826    if (sd->scale == 0.0)
1827      {
1828         if (sd->parent_obj)
1829            return elm_widget_scale_get(sd->parent_obj);
1830         else
1831            return 1.0;
1832      }
1833    return sd->scale;
1834 }
1835
1836 EAPI void
1837 elm_widget_theme_set(Evas_Object *obj, Elm_Theme *th)
1838 {
1839    API_ENTRY return;
1840    if (sd->theme != th)
1841      {
1842         if (sd->theme) elm_theme_free(sd->theme);
1843         sd->theme = th;
1844         if (th) th->ref++;
1845         elm_widget_theme(obj);
1846      }
1847 }
1848
1849 EAPI Elm_Theme *
1850 elm_widget_theme_get(const Evas_Object *obj)
1851 {
1852    API_ENTRY return NULL;
1853    if (!sd->theme)
1854      {
1855         if (sd->parent_obj)
1856            return elm_widget_theme_get(sd->parent_obj);
1857         else
1858            return NULL;
1859      }
1860    return sd->theme;
1861 }
1862
1863 EAPI void
1864 elm_widget_style_set(Evas_Object *obj, const char *style)
1865 {
1866    API_ENTRY return;
1867
1868    if (eina_stringshare_replace(&sd->style, style))
1869       elm_widget_theme(obj);
1870 }
1871
1872 EAPI const char *
1873 elm_widget_style_get(const Evas_Object *obj)
1874 {
1875    API_ENTRY return NULL;
1876    if (sd->style) return sd->style;
1877    return "default";
1878 }
1879
1880 EAPI void
1881 elm_widget_type_set(Evas_Object *obj, const char *type)
1882 {
1883    API_ENTRY return;
1884    eina_stringshare_replace(&sd->type, type);
1885 }
1886
1887 EAPI const char *
1888 elm_widget_type_get(const Evas_Object *obj)
1889 {
1890    API_ENTRY return NULL;
1891    if (sd->type) return sd->type;
1892    return "";
1893 }
1894
1895 EAPI void
1896 elm_widget_tooltip_add(Evas_Object *obj, Elm_Tooltip *tt)
1897 {
1898    API_ENTRY return;
1899    sd->tooltips = eina_list_append(sd->tooltips, tt);
1900 }
1901
1902 EAPI void
1903 elm_widget_tooltip_del(Evas_Object *obj, Elm_Tooltip *tt)
1904 {
1905    API_ENTRY return;
1906    sd->tooltips = eina_list_remove(sd->tooltips, tt);
1907 }
1908
1909 EAPI void
1910 elm_widget_cursor_add(Evas_Object *obj, Elm_Cursor *cur)
1911 {
1912    API_ENTRY return;
1913    sd->cursors = eina_list_append(sd->cursors, cur);
1914 }
1915
1916 EAPI void
1917 elm_widget_cursor_del(Evas_Object *obj, Elm_Cursor *cur)
1918 {
1919    API_ENTRY return;
1920    sd->cursors = eina_list_remove(sd->cursors, cur);
1921 }
1922
1923 EAPI void
1924 elm_widget_drag_lock_x_set(Evas_Object *obj, Eina_Bool lock)
1925 {
1926    API_ENTRY return;
1927    if (sd->drag_x_locked == lock) return;
1928    sd->drag_x_locked = lock;
1929    if (sd->drag_x_locked) _propagate_x_drag_lock(obj, 1);
1930    else _propagate_x_drag_lock(obj, -1);
1931 }
1932
1933 EAPI void
1934 elm_widget_drag_lock_y_set(Evas_Object *obj, Eina_Bool lock)
1935 {
1936    API_ENTRY return;
1937    if (sd->drag_y_locked == lock) return;
1938    sd->drag_y_locked = lock;
1939    if (sd->drag_y_locked) _propagate_y_drag_lock(obj, 1);
1940    else _propagate_y_drag_lock(obj, -1);
1941 }
1942
1943 EAPI Eina_Bool
1944 elm_widget_drag_lock_x_get(const Evas_Object *obj)
1945 {
1946    API_ENTRY return EINA_FALSE;
1947    return sd->drag_x_locked;
1948 }
1949
1950 EAPI Eina_Bool
1951 elm_widget_drag_lock_y_get(const Evas_Object *obj)
1952 {
1953    API_ENTRY return EINA_FALSE;
1954    return sd->drag_y_locked;
1955 }
1956
1957 EAPI int
1958 elm_widget_drag_child_locked_x_get(const Evas_Object *obj)
1959 {
1960    API_ENTRY return 0;
1961    return sd->child_drag_x_locked;
1962 }
1963
1964 EAPI int
1965 elm_widget_drag_child_locked_y_get(const Evas_Object *obj)
1966 {
1967    API_ENTRY return 0;
1968    return sd->child_drag_y_locked;
1969 }
1970
1971 EAPI Eina_Bool
1972 elm_widget_theme_object_set(Evas_Object *obj, Evas_Object *edj, const char *wname, const char *welement, const char *wstyle)
1973 {
1974    API_ENTRY return EINA_FALSE;
1975    return _elm_theme_object_set(obj, edj, wname, welement, wstyle);
1976 }
1977
1978 EAPI Eina_Bool
1979 elm_widget_type_check(const Evas_Object *obj, const char *type)
1980 {
1981    const char *provided, *expected = "(unknown)";
1982    static int abort_on_warn = -1;
1983    provided = elm_widget_type_get(obj);
1984    if (EINA_LIKELY(provided == type)) return EINA_TRUE;
1985    if (type) expected = type;
1986    if ((!provided) || (!provided[0]))
1987      {
1988         provided = evas_object_type_get(obj);
1989         if ((!provided) || (!provided[0]))
1990            provided = "(unknown)";
1991      }
1992    ERR("Passing Object: %p, of type: '%s' when expecting type: '%s'", obj, provided, expected);
1993    if (abort_on_warn == -1)
1994      {
1995         if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1;
1996         else abort_on_warn = 0;
1997      }
1998    if (abort_on_warn == 1) abort();
1999    return EINA_FALSE;
2000 }
2001
2002 /**
2003  * @internal
2004  *
2005  * Split string in words
2006  *
2007  * @param str Source string
2008  * @return List of const words
2009  *
2010  * @see elm_widget_stringlist_free()
2011  * @ingroup Widget
2012  */
2013 EAPI Eina_List *
2014 elm_widget_stringlist_get(const char *str)
2015 {
2016    Eina_List *list = NULL;
2017    const char *s, *b;
2018    if (!str) return NULL;
2019    for (b = s = str; 1; s++)
2020      {
2021         if ((*s == ' ') || (!*s))
2022           {
2023              char *t = malloc(s - b + 1);
2024              if (t)
2025                {
2026                   strncpy(t, b, s - b);
2027                   t[s - b] = 0;
2028                   list = eina_list_append(list, eina_stringshare_add(t));
2029                   free(t);
2030                }
2031              b = s + 1;
2032           }
2033         if (!*s) break;
2034      }
2035    return list;
2036 }
2037
2038 EAPI void
2039 elm_widget_stringlist_free(Eina_List *list)
2040 {
2041    const char *s;
2042    EINA_LIST_FREE(list, s) eina_stringshare_del(s);
2043 }
2044
2045 /**
2046  * @internal
2047  *
2048  * Allocate a new Elm_Widget_Item-derived structure.
2049  *
2050  * The goal of this structure is to provide common ground for actions
2051  * that a widget item have, such as the owner widget, callback to
2052  * notify deletion, data pointer and maybe more.
2053  *
2054  * @param widget the owner widget that holds this item, must be an elm_widget!
2055  * @param alloc_size any number greater than sizeof(Elm_Widget_Item) that will
2056  *        be used to allocate memory.
2057  *
2058  * @return allocated memory that is already zeroed out, or NULL on errors.
2059  *
2060  * @see elm_widget_item_new() convenience macro.
2061  * @see elm_widget_item_del() to release memory.
2062  * @ingroup Widget
2063  */
2064 EAPI Elm_Widget_Item *
2065 _elm_widget_item_new(Evas_Object *widget, size_t alloc_size)
2066 {
2067    if (!_elm_widget_is(widget))
2068      return NULL;
2069
2070    Elm_Widget_Item *item;
2071
2072    EINA_SAFETY_ON_TRUE_RETURN_VAL(alloc_size < sizeof(Elm_Widget_Item), NULL);
2073    EINA_SAFETY_ON_TRUE_RETURN_VAL(!_elm_widget_is(widget), NULL);
2074
2075    item = calloc(1, alloc_size);
2076    EINA_SAFETY_ON_NULL_RETURN_VAL(item, NULL);
2077
2078    EINA_MAGIC_SET(item, ELM_WIDGET_ITEM_MAGIC);
2079    item->widget = widget;
2080    return item;
2081 }
2082
2083 /**
2084  * @internal
2085  *
2086  * Releases widget item memory, calling back del_cb() if it exists.
2087  *
2088  * If there is a Elm_Widget_Item::del_cb, then it will be called prior
2089  * to memory release. Note that elm_widget_item_pre_notify_del() calls
2090  * this function and then unset it, thus being useful for 2 step
2091  * cleanup whenever the del_cb may use any of the data that must be
2092  * deleted from item.
2093  *
2094  * The Elm_Widget_Item::view will be deleted (evas_object_del()) if it
2095  * is presented!
2096  *
2097  * @param item a valid #Elm_Widget_Item to be deleted.
2098  * @see elm_widget_item_del() convenience macro.
2099  * @ingroup Widget
2100  */
2101 EAPI void
2102 _elm_widget_item_del(Elm_Widget_Item *item)
2103 {
2104    ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2105
2106    if (item->del_cb)
2107      item->del_cb((void *)item->data, item->widget, item);
2108
2109    if (item->view)
2110      evas_object_del(item->view);
2111
2112    EINA_MAGIC_SET(item, EINA_MAGIC_NONE);
2113    free(item);
2114 }
2115
2116 /**
2117  * @internal
2118  *
2119  * Notify object will be deleted without actually deleting it.
2120  *
2121  * This function will callback Elm_Widget_Item::del_cb if it is set
2122  * and then unset it so it is not called twice (ie: from
2123  * elm_widget_item_del()).
2124  *
2125  * @param item a valid #Elm_Widget_Item to be notified
2126  * @see elm_widget_item_pre_notify_del() convenience macro.
2127  * @ingroup Widget
2128  */
2129 EAPI void
2130 _elm_widget_item_pre_notify_del(Elm_Widget_Item *item)
2131 {
2132    ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2133    if (!item->del_cb) return;
2134    item->del_cb((void *)item->data, item->widget, item);
2135    item->del_cb = NULL;
2136 }
2137
2138 /**
2139  * @internal
2140  *
2141  * Set the function to notify when item is being deleted.
2142  *
2143  * This function will complain if there was a callback set already,
2144  * however it will set the new one.
2145  *
2146  * The callback will be called from elm_widget_item_pre_notify_del()
2147  * or elm_widget_item_del() will be called with:
2148  *   - data: the Elm_Widget_Item::data value.
2149  *   - obj: the Elm_Widget_Item::widget evas object.
2150  *   - event_info: the item being deleted.
2151  *
2152  * @param item a valid #Elm_Widget_Item to be notified
2153  * @see elm_widget_item_del_cb_set() convenience macro.
2154  * @ingroup Widget
2155  */
2156 EAPI void
2157 _elm_widget_item_del_cb_set(Elm_Widget_Item *item, Evas_Smart_Cb del_cb)
2158 {
2159    ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2160
2161    if ((item->del_cb) && (item->del_cb != del_cb))
2162      WRN("You're replacing a previously set del_cb %p of item %p with %p",
2163          item->del_cb, item, del_cb);
2164
2165    item->del_cb = del_cb;
2166 }
2167
2168 /**
2169  * @internal
2170  *
2171  * Set user-data in this item.
2172  *
2173  * User data may be used to identify this item or just store any
2174  * application data. It is automatically given as the first parameter
2175  * of the deletion notify callback.
2176  *
2177  * @param item a valid #Elm_Widget_Item to store data in.
2178  * @param data user data to store.
2179  * @see elm_widget_item_del_cb_set() convenience macro.
2180  * @ingroup Widget
2181  */
2182 EAPI void
2183 _elm_widget_item_data_set(Elm_Widget_Item *item, const void *data)
2184 {
2185    ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2186    if ((item->data) && (item->data != data))
2187      DBG("Replacing item %p data %p with %p", item, item->data, data);
2188    item->data = data;
2189 }
2190
2191 /**
2192  * @internal
2193  *
2194  * Retrieves user-data of this item.
2195  *
2196  * @param item a valid #Elm_Widget_Item to get data from.
2197  * @see elm_widget_item_data_set()
2198  * @ingroup Widget
2199  */
2200 EAPI void *
2201 _elm_widget_item_data_get(const Elm_Widget_Item *item)
2202 {
2203    ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
2204    return (void *)item->data;
2205 }
2206
2207 typedef struct _Elm_Widget_Item_Tooltip Elm_Widget_Item_Tooltip;
2208
2209 struct _Elm_Widget_Item_Tooltip
2210 {
2211    Elm_Widget_Item             *item;
2212    Elm_Tooltip_Item_Content_Cb  func;
2213    Evas_Smart_Cb                del_cb;
2214    const void                  *data;
2215 };
2216
2217 static Evas_Object *
2218 _elm_widget_item_tooltip_label_create(void *data, Evas_Object *obj, void *item __UNUSED__)
2219 {
2220    Evas_Object *label = elm_label_add(obj);
2221    if (!label)
2222      return NULL;
2223    elm_object_style_set(label, "tooltip");
2224    elm_label_label_set(label, data);
2225    return label;
2226 }
2227
2228 static void
2229 _elm_widget_item_tooltip_label_del_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2230 {
2231    eina_stringshare_del(data);
2232 }
2233
2234 /**
2235  * @internal
2236  *
2237  * Set the text to be shown in the widget item.
2238  *
2239  * @param item Target item
2240  * @param text The text to set in the content
2241  *
2242  * Setup the text as tooltip to object. The item can have only one tooltip,
2243  * so any previous tooltip data is removed.
2244  *
2245  * @ingroup Widget
2246  */
2247 EAPI void
2248 _elm_widget_item_tooltip_text_set(Elm_Widget_Item *item, const char *text)
2249 {
2250    ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2251    EINA_SAFETY_ON_NULL_RETURN(text);
2252
2253    text = eina_stringshare_add(text);
2254    _elm_widget_item_tooltip_content_cb_set
2255      (item, _elm_widget_item_tooltip_label_create, text,
2256       _elm_widget_item_tooltip_label_del_cb);
2257 }
2258
2259 static Evas_Object *
2260 _elm_widget_item_tooltip_create(void *data, Evas_Object *obj)
2261 {
2262    Elm_Widget_Item_Tooltip *wit = data;
2263    return wit->func((void *)wit->data, obj, wit->item);
2264 }
2265
2266 static void
2267 _elm_widget_item_tooltip_del_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__)
2268 {
2269    Elm_Widget_Item_Tooltip *wit = data;
2270    if (wit->del_cb) wit->del_cb((void *)wit->data, obj, wit->item);
2271    free(wit);
2272 }
2273
2274 /**
2275  * @internal
2276  *
2277  * Set the content to be shown in the tooltip item
2278  *
2279  * Setup the tooltip to item. The item can have only one tooltip,
2280  * so any previous tooltip data is removed. @p func(with @p data) will
2281  * be called every time that need show the tooltip and it should
2282  * return a valid Evas_Object. This object is then managed fully by
2283  * tooltip system and is deleted when the tooltip is gone.
2284  *
2285  * @param item the widget item being attached a tooltip.
2286  * @param func the function used to create the tooltip contents.
2287  * @param data what to provide to @a func as callback data/context.
2288  * @param del_cb called when data is not needed anymore, either when
2289  *        another callback replaces @func, the tooltip is unset with
2290  *        elm_widget_item_tooltip_unset() or the owner @a item
2291  *        dies. This callback receives as the first parameter the
2292  *        given @a data, and @c event_info is the item.
2293  *
2294  * @ingroup Widget
2295  */
2296 EAPI void
2297 _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)
2298 {
2299    Elm_Widget_Item_Tooltip *wit;
2300
2301    ELM_WIDGET_ITEM_CHECK_OR_GOTO(item, error_noitem);
2302
2303    if (!func)
2304      {
2305         _elm_widget_item_tooltip_unset(item);
2306         return;
2307      }
2308
2309    wit = ELM_NEW(Elm_Widget_Item_Tooltip);
2310    if (!wit) goto error;
2311    wit->item = item;
2312    wit->func = func;
2313    wit->data = data;
2314    wit->del_cb = del_cb;
2315
2316    elm_object_sub_tooltip_content_cb_set
2317      (item->view, item->widget, _elm_widget_item_tooltip_create, wit,
2318       _elm_widget_item_tooltip_del_cb);
2319
2320    return;
2321
2322  error_noitem:
2323    if (del_cb) del_cb((void *)data, NULL, item);
2324    return;
2325  error:
2326    if (del_cb) del_cb((void *)data, item->widget, item);
2327 }
2328
2329 /**
2330  * @internal
2331  *
2332  * Unset tooltip from item
2333  *
2334  * @param item widget item to remove previously set tooltip.
2335  *
2336  * Remove tooltip from item. The callback provided as del_cb to
2337  * elm_widget_item_tooltip_content_cb_set() will be called to notify
2338  * it is not used anymore.
2339  *
2340  * @see elm_widget_item_tooltip_content_cb_set()
2341  *
2342  * @ingroup Widget
2343  */
2344 EAPI void
2345 _elm_widget_item_tooltip_unset(Elm_Widget_Item *item)
2346 {
2347    ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2348    elm_object_tooltip_unset(item->view);
2349 }
2350
2351 /**
2352  * @internal
2353  *
2354  * Sets a different style for this item tooltip.
2355  *
2356  * @note before you set a style you should define a tooltip with
2357  *       elm_widget_item_tooltip_content_cb_set() or
2358  *       elm_widget_item_tooltip_text_set()
2359  *
2360  * @param item widget item with tooltip already set.
2361  * @param style the theme style to use (default, transparent, ...)
2362  *
2363  * @ingroup Widget
2364  */
2365 EAPI void
2366 _elm_widget_item_tooltip_style_set(Elm_Widget_Item *item, const char *style)
2367 {
2368    ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2369    elm_object_tooltip_style_set(item->view, style);
2370 }
2371
2372 /**
2373  * @internal
2374  *
2375  * Get the style for this item tooltip.
2376  *
2377  * @param item widget item with tooltip already set.
2378  * @return style the theme style in use, defaults to "default". If the
2379  *         object does not have a tooltip set, then NULL is returned.
2380  *
2381  * @ingroup Widget
2382  */
2383 EAPI const char *
2384 _elm_widget_item_tooltip_style_get(const Elm_Widget_Item *item)
2385 {
2386    ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
2387    return elm_object_tooltip_style_get(item->view);
2388 }
2389
2390 EAPI void
2391 _elm_widget_item_cursor_set(Elm_Widget_Item *item, const char *cursor)
2392 {
2393    ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2394    elm_object_sub_cursor_set(item->view, item->widget, cursor);
2395 }
2396
2397 EAPI const char *
2398 _elm_widget_item_cursor_get(const Elm_Widget_Item *item)
2399 {
2400    ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
2401    return elm_object_cursor_get(item->view);
2402 }
2403
2404 EAPI void
2405 _elm_widget_item_cursor_unset(Elm_Widget_Item *item)
2406 {
2407    ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2408    elm_object_cursor_unset(item->view);
2409 }
2410
2411 /**
2412  * @internal
2413  *
2414  * Sets a different style for this item cursor.
2415  *
2416  * @note before you set a style you should define a cursor with
2417  *       elm_widget_item_cursor_set()
2418  *
2419  * @param item widget item with cursor already set.
2420  * @param style the theme style to use (default, transparent, ...)
2421  *
2422  * @ingroup Widget
2423  */
2424 EAPI void
2425 _elm_widget_item_cursor_style_set(Elm_Widget_Item *item, const char *style)
2426 {
2427    ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2428    elm_object_cursor_style_set(item->view, style);
2429 }
2430
2431 /**
2432  * @internal
2433  *
2434  * Get the style for this item cursor.
2435  *
2436  * @param item widget item with cursor already set.
2437  * @return style the theme style in use, defaults to "default". If the
2438  *         object does not have a cursor set, then NULL is returned.
2439  *
2440  * @ingroup Widget
2441  */
2442 EAPI const char *
2443 _elm_widget_item_cursor_style_get(const Elm_Widget_Item *item)
2444 {
2445    ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
2446    return elm_object_cursor_style_get(item->view);
2447 }
2448
2449 /**
2450  * @internal
2451  *
2452  * Set if the cursor set should be searched on the theme or should use
2453  * the provided by the engine, only.
2454  *
2455  * @note before you set if should look on theme you should define a cursor
2456  * with elm_object_cursor_set(). By default it will only look for cursors
2457  * provided by the engine.
2458  *
2459  * @param item widget item with cursor already set.
2460  * @param engine_only boolean to define it cursors should be looked only
2461  * between the provided by the engine or searched on widget's theme as well.
2462  *
2463  * @ingroup Widget
2464  */
2465 EAPI void
2466 _elm_widget_item_cursor_engine_only_set(Elm_Widget_Item *item, Eina_Bool engine_only)
2467 {
2468    ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
2469    elm_object_cursor_engine_only_set(item->view, engine_only);
2470 }
2471
2472 /**
2473  * @internal
2474  *
2475  * Get the cursor engine only usage for this item cursor.
2476  *
2477  * @param item widget item with cursor already set.
2478  * @return engine_only boolean to define it cursors should be looked only
2479  * between the provided by the engine or searched on widget's theme as well. If
2480  *         the object does not have a cursor set, then EINA_FALSE is returned.
2481  *
2482  * @ingroup Widget
2483  */
2484 EAPI Eina_Bool
2485 _elm_widget_item_cursor_engine_only_get(const Elm_Widget_Item *item)
2486 {
2487    ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
2488    return elm_object_cursor_engine_only_get(item->view);
2489 }
2490
2491 // smart object funcs
2492 static void
2493 _smart_reconfigure(Smart_Data *sd)
2494 {
2495    if (sd->resize_obj)
2496      {
2497         evas_object_move(sd->resize_obj, sd->x, sd->y);
2498         evas_object_resize(sd->resize_obj, sd->w, sd->h);
2499      }
2500    if (sd->hover_obj)
2501      {
2502         evas_object_move(sd->hover_obj, sd->x, sd->y);
2503         evas_object_resize(sd->hover_obj, sd->w, sd->h);
2504      }
2505 }
2506
2507 static void
2508 _smart_add(Evas_Object *obj)
2509 {
2510    Smart_Data *sd;
2511
2512    sd = calloc(1, sizeof(Smart_Data));
2513    if (!sd) return;
2514    sd->obj = obj;
2515    sd->x = sd->y = sd->w = sd->h = 0;
2516    sd->can_focus = 1;
2517    sd->mirrored_auto_mode = EINA_TRUE; /* will follow system locale settings */
2518    evas_object_smart_data_set(obj, sd);
2519 }
2520
2521 static Evas_Object *
2522 _newest_focus_order_get(Evas_Object *obj, unsigned int *newest_focus_order, Eina_Bool can_focus_only)
2523 {
2524    const Eina_List *l;
2525    Evas_Object *child, *ret, *best;
2526
2527    API_ENTRY return NULL;
2528    if (!evas_object_visible_get(obj)) return NULL;
2529    best = NULL;
2530    if (*newest_focus_order < sd->focus_order)
2531      {
2532         *newest_focus_order = sd->focus_order;
2533         best = obj;
2534      }
2535    EINA_LIST_FOREACH(sd->subobjs, l, child)
2536      {
2537         ret = _newest_focus_order_get(child, newest_focus_order, can_focus_only);
2538         if (!ret) continue;
2539         best = ret;
2540      }
2541    if (can_focus_only)
2542      {
2543         if ((!best) || (!elm_widget_can_focus_get(best)))
2544           return NULL;
2545      }
2546    return best;
2547 }
2548
2549 static void
2550 _if_focused_revert(Evas_Object *obj, Eina_Bool can_focus_only)
2551 {
2552    Evas_Object *top;
2553    Evas_Object *newest = NULL;
2554    unsigned int newest_focus_order = 0;
2555
2556    INTERNAL_ENTRY;
2557
2558    if (!sd->focused) return;
2559    if (!sd->parent_obj) return;
2560
2561    top = elm_widget_top_get(sd->parent_obj);
2562    if (top)
2563      {
2564         newest = _newest_focus_order_get(top, &newest_focus_order, can_focus_only);
2565         if (newest)
2566           {
2567              elm_object_unfocus(newest);
2568              elm_object_focus(newest);
2569           }
2570      }
2571 }
2572
2573 static void
2574 _smart_del(Evas_Object *obj)
2575 {
2576    Evas_Object *sobj;
2577    Edje_Signal_Data *esd;
2578
2579    INTERNAL_ENTRY;
2580
2581    if (sd->del_pre_func) sd->del_pre_func(obj);
2582    if (sd->resize_obj)
2583      {
2584         sobj = sd->resize_obj;
2585         sd->resize_obj = NULL;
2586         evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
2587         evas_object_smart_callback_call(sd->obj, "sub-object-del", sobj);
2588         evas_object_del(sobj);
2589      }
2590    if (sd->hover_obj)
2591      {
2592         sobj = sd->hover_obj;
2593         sd->hover_obj = NULL;
2594         evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
2595         evas_object_smart_callback_call(sd->obj, "sub-object-del", sobj);
2596         evas_object_del(sobj);
2597      }
2598    EINA_LIST_FREE(sd->subobjs, sobj)
2599      {
2600         evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
2601         evas_object_smart_callback_call(sd->obj, "sub-object-del", sobj);
2602         evas_object_del(sobj);
2603      }
2604    eina_list_free(sd->tooltips); /* should be empty anyway */
2605    eina_list_free(sd->cursors); /* should be empty anyway */
2606    EINA_LIST_FREE(sd->edje_signals, esd)
2607      {
2608         eina_stringshare_del(esd->emission);
2609         eina_stringshare_del(esd->source);
2610         free(esd);
2611      }
2612    eina_list_free(sd->event_cb); /* should be empty anyway */
2613    if (sd->del_func) sd->del_func(obj);
2614    if (sd->style) eina_stringshare_del(sd->style);
2615    if (sd->type) eina_stringshare_del(sd->type);
2616    if (sd->theme) elm_theme_free(sd->theme);
2617    _if_focused_revert(obj, EINA_TRUE);
2618    free(sd);
2619 }
2620
2621 static void
2622 _smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
2623 {
2624    INTERNAL_ENTRY;
2625    sd->x = x;
2626    sd->y = y;
2627    _smart_reconfigure(sd);
2628 }
2629
2630 static void
2631 _smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
2632 {
2633    INTERNAL_ENTRY;
2634    sd->w = w;
2635    sd->h = h;
2636    _smart_reconfigure(sd);
2637 }
2638
2639 static void
2640 _smart_show(Evas_Object *obj)
2641 {
2642    Eina_List *list;
2643    Evas_Object *o;
2644    INTERNAL_ENTRY;
2645    if ((list = evas_object_smart_members_get(obj)))
2646      {
2647         EINA_LIST_FREE(list, o)
2648           {
2649              if (evas_object_data_get(o, "_elm_leaveme")) continue;
2650              evas_object_show(o);
2651           }
2652      }
2653 }
2654
2655 static void
2656 _smart_hide(Evas_Object *obj)
2657 {
2658    Eina_List *list;
2659    Evas_Object *o;
2660    INTERNAL_ENTRY;
2661    list = evas_object_smart_members_get(obj);
2662    EINA_LIST_FREE(list, o)
2663      {
2664         if (evas_object_data_get(o, "_elm_leaveme")) continue;
2665         evas_object_hide(o);
2666      }
2667    _if_focused_revert(obj, EINA_TRUE);
2668 }
2669
2670 static void
2671 _smart_color_set(Evas_Object *obj, int r, int g, int b, int a)
2672 {
2673    Eina_List *list;
2674    Evas_Object *o;
2675    INTERNAL_ENTRY;
2676    if ((list = evas_object_smart_members_get(obj)))
2677      {
2678         EINA_LIST_FREE(list, o)
2679           {
2680              if (evas_object_data_get(o, "_elm_leaveme")) continue;
2681              evas_object_color_set(o, r, g, b, a);
2682           }
2683      }
2684 }
2685
2686 static void
2687 _smart_clip_set(Evas_Object *obj, Evas_Object *clip)
2688 {
2689    Eina_List *list;
2690    Evas_Object *o;
2691    INTERNAL_ENTRY;
2692    if ((list = evas_object_smart_members_get(obj)))
2693      {
2694         EINA_LIST_FREE(list, o)
2695           {
2696              if (evas_object_data_get(o, "_elm_leaveme")) continue;
2697              evas_object_clip_set(o, clip);
2698           }
2699      }
2700 }
2701
2702 static void
2703 _smart_clip_unset(Evas_Object *obj)
2704 {
2705    Eina_List *list;
2706    Evas_Object *o;
2707    INTERNAL_ENTRY;
2708    if ((list = evas_object_smart_members_get(obj)))
2709      {
2710         EINA_LIST_FREE(list, o)
2711           {
2712              if (evas_object_data_get(o, "_elm_leaveme")) continue;
2713              evas_object_clip_unset(o);
2714           }
2715      }
2716 }
2717
2718 static void
2719 _smart_calculate(Evas_Object *obj)
2720 {
2721    INTERNAL_ENTRY;
2722    if (sd->changed_func) sd->changed_func(obj);
2723 }
2724
2725 /* never need to touch this */
2726 static void
2727 _smart_init(void)
2728 {
2729    if (_e_smart) return;
2730      {
2731         static const Evas_Smart_Class sc =
2732           {
2733              SMART_NAME,
2734              EVAS_SMART_CLASS_VERSION,
2735              _smart_add,
2736              _smart_del,
2737              _smart_move,
2738              _smart_resize,
2739              _smart_show,
2740              _smart_hide,
2741              _smart_color_set,
2742              _smart_clip_set,
2743              _smart_clip_unset,
2744              _smart_calculate,
2745              NULL,
2746              NULL,
2747              NULL,
2748              NULL,
2749              NULL,
2750              NULL
2751           };
2752         _e_smart = evas_smart_class_new(&sc);
2753      }
2754 }
2755
2756 /* happy debug functions */
2757 #ifdef ELM_DEBUG
2758 static void
2759 _sub_obj_tree_dump(const Evas_Object *o, int lvl)
2760 {
2761    int i;
2762
2763    for (i = 0; i < lvl*3; i++)
2764      putchar(' ');
2765
2766    if (_elm_widget_is(o))
2767      {
2768         Eina_List *l;
2769         Smart_Data *sd = evas_object_smart_data_get(o);
2770         printf("+ %s(%p)\n", sd->type, o);
2771         if (sd->resize_obj)
2772           _sub_obj_tree_dump(sd->resize_obj, lvl + 1);
2773         EINA_LIST_FOREACH(sd->subobjs, l, o)
2774           {
2775              if (o != sd->resize_obj)
2776                _sub_obj_tree_dump(o, lvl + 1);
2777           }
2778      }
2779    else
2780      printf("+ %s(%p)\n", evas_object_type_get(o), o);
2781 }
2782
2783 static void
2784 _sub_obj_tree_dot_dump(const Evas_Object *obj, FILE *output)
2785 {
2786    if (!_elm_widget_is(obj))
2787      return;
2788
2789    Smart_Data *sd = evas_object_smart_data_get(obj);
2790
2791    Eina_Bool visible = evas_object_visible_get(obj);
2792    Eina_Bool disabled = elm_widget_disabled_get(obj);
2793    Eina_Bool focused = elm_widget_focus_get(obj);
2794    Eina_Bool can_focus = elm_widget_can_focus_get(obj);
2795
2796    if (sd->parent_obj)
2797      {
2798         fprintf(output, "\"%p\" -- \"%p\" [ color=black", sd->parent_obj, obj);
2799
2800         if (focused)
2801           fprintf(output, ", style=bold");
2802
2803         if (!visible)
2804           fprintf(output, ", color=gray28");
2805
2806         fprintf(output, " ];\n");
2807      }
2808
2809    fprintf(output, "\"%p\" [ label = \"{%p|%s|%s|visible: %d|"
2810            "disabled: %d|focused: %d/%d|focus order:%d}\"", obj, obj, sd->type,
2811            evas_object_name_get(obj), visible, disabled, focused, can_focus,
2812            sd->focus_order);
2813
2814    if (focused)
2815         fprintf(output, ", style=bold");
2816
2817    if (!visible)
2818         fprintf(output, ", fontcolor=gray28");
2819
2820    if ((disabled) || (!visible))
2821         fprintf(output, ", color=gray");
2822
2823
2824    fprintf(output, " ];\n");
2825
2826    Eina_List *l;
2827    Evas_Object *o;
2828    EINA_LIST_FOREACH(sd->subobjs, l, o)
2829       _sub_obj_tree_dot_dump(o, output);
2830 }
2831 #endif
2832
2833 EAPI void
2834 elm_widget_tree_dump(const Evas_Object *top)
2835 {
2836 #ifdef ELM_DEBUG
2837    _sub_obj_tree_dump(top, 0);
2838 #else
2839    return;
2840    (void)top;
2841 #endif
2842 }
2843
2844 EAPI void
2845 elm_widget_tree_dot_dump(const Evas_Object *top, FILE *output)
2846 {
2847 #ifdef ELM_DEBUG
2848    if (!_elm_widget_is(top))
2849      return;
2850    fprintf(output, "graph "" { node [shape=record];\n");
2851    _sub_obj_tree_dot_dump(top, output);
2852    fprintf(output, "}\n");
2853 #else
2854    return;
2855    (void)top;
2856    (void)output;
2857 #endif
2858 }