1 #include <Elementary.h>
5 * @defgroup Layout Layout
8 * This takes a standard Edje design file and wraps it very thinly
9 * in a widget and handles swallowing widgets into swallow regions
10 * in the Edje object, allowing Edje to be used as a design and
14 typedef struct _Widget_Data Widget_Data;
15 typedef struct _Subinfo Subinfo;
16 typedef struct _Part_Cursor Part_Cursor;
23 Eina_List *parts_cursors;
24 Eina_Bool needs_size_calc:1;
25 const char *clas, *group, *style;
43 const Evas_Object *reference;
47 unsigned short col, row, colspan, rowspan;
61 Eina_Bool engine_only:1;
64 static const char *widtype = NULL;
65 static void _del_hook(Evas_Object *obj);
66 static void _mirrored_set(Evas_Object *obj, Eina_Bool rtl);
67 static void _theme_hook(Evas_Object *obj);
68 static void _sizing_eval(Widget_Data *wd);
69 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
70 static void _sub_del(void *data, Evas_Object *obj, void *event_info);
71 static void _part_cursor_free(Part_Cursor *pc);
74 _del_hook(Evas_Object *obj)
76 Widget_Data *wd = elm_widget_data_get(obj);
81 EINA_LIST_FREE(wd->subs, si)
83 eina_stringshare_del(si->part);
85 eina_stringshare_del(si->p.text.text);
88 EINA_LIST_FREE(wd->parts_cursors, pc) _part_cursor_free(pc);
93 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
95 Widget_Data *wd = elm_widget_data_get(obj);
97 edje_object_mirrored_set(wd->lay, rtl);
101 _theme_hook(Evas_Object *obj)
103 Widget_Data *wd = elm_widget_data_get(obj);
105 _elm_widget_mirrored_reload(obj);
106 _mirrored_set(obj, elm_widget_mirrored_get(obj));
107 _elm_theme_object_set(obj, wd->lay, wd->clas, wd->group, wd->style);
108 edje_object_scale_set(wd->lay, elm_widget_scale_get(obj) *
114 _changed_hook(Evas_Object *obj)
116 Widget_Data *wd = elm_widget_data_get(obj);
118 if (wd->needs_size_calc)
121 wd->needs_size_calc = 0;
126 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
128 Widget_Data *wd = elm_widget_data_get(obj);
129 edje_object_signal_emit(wd->lay, emission, source);
133 _signal_callback_add_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
135 Widget_Data *wd = elm_widget_data_get(obj);
136 edje_object_signal_callback_add(wd->lay, emission, source, func_cb, data);
140 _signal_callback_del_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
142 Widget_Data *wd = elm_widget_data_get(obj);
143 edje_object_signal_callback_del_full(wd->lay, emission, source, func_cb,
149 _elm_layout_list_data_get(const Eina_List *list)
151 Subinfo *si = eina_list_data_get(list);
156 _elm_layout_focus_next_hook(const Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next)
158 Widget_Data *wd = elm_widget_data_get(obj);
159 const Eina_List *items;
160 void *(*list_data_get) (const Eina_List *list);
162 if ((!wd) || (!wd->subs))
165 /* Focus chain (This block is diferent of elm_win cycle)*/
166 if ((items = elm_widget_focus_custom_chain_get(obj)))
167 list_data_get = eina_list_data_get;
171 list_data_get = _elm_layout_list_data_get;
173 if (!items) return EINA_FALSE;
176 return elm_widget_focus_list_next_get(obj, items, list_data_get, dir,
181 _sizing_eval(Widget_Data *wd)
183 Evas_Coord minw = -1, minh = -1;
184 edje_object_size_min_calc(wd->lay, &minw, &minh);
185 evas_object_size_hint_min_set(wd->obj, minw, minh);
186 evas_object_size_hint_max_set(wd->obj, -1, -1);
190 _request_sizing_eval(Widget_Data *wd)
192 if (wd->needs_size_calc) return;
193 wd->needs_size_calc = 1;
194 evas_object_smart_changed(wd->obj);
198 _part_cursor_free(Part_Cursor *pc)
200 eina_stringshare_del(pc->part);
201 eina_stringshare_del(pc->style);
202 eina_stringshare_del(pc->cursor);
207 _part_cursor_part_apply(const Part_Cursor *pc)
209 elm_object_cursor_set(pc->obj, pc->cursor);
210 elm_object_cursor_style_set(pc->obj, pc->style);
211 elm_object_cursor_engine_only_set(pc->obj, pc->engine_only);
215 _parts_cursors_find(Widget_Data *wd, const char *part)
219 EINA_LIST_FOREACH(wd->parts_cursors, l, pc)
221 if (!strcmp(pc->part, part))
228 _parts_cursors_apply(Widget_Data *wd)
230 const char *file, *group;
234 edje_object_file_get(wd->lay, &file, &group);
236 EINA_LIST_FOREACH(wd->parts_cursors, l, pc)
238 Evas_Object *obj = (Evas_Object *)edje_object_part_object_get
244 WRN("no part '%s' in group '%s' of file '%s'. "
245 "Cannot set cursor '%s'",
246 pc->part, group, file, pc->cursor);
249 else if (evas_object_pass_events_get(obj))
252 WRN("part '%s' in group '%s' of file '%s' has mouse_events: 0. "
253 "Cannot set cursor '%s'",
254 pc->part, group, file, pc->cursor);
259 _part_cursor_part_apply(pc);
264 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
266 _request_sizing_eval(data);
270 _sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info)
272 Widget_Data *wd = elm_widget_data_get(obj);
273 Evas_Object *sub = event_info;
277 EINA_LIST_FOREACH(wd->subs, l, si)
281 evas_object_event_callback_del_full(sub,
282 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
285 wd->subs = eina_list_remove_list(wd->subs, l);
286 eina_stringshare_del(si->part);
294 _signal_size_eval(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
296 _request_sizing_eval(data);
300 _parts_text_fix(Widget_Data *wd)
305 EINA_LIST_FOREACH(wd->subs, l, si)
307 if (si->type == TEXT)
308 edje_object_part_text_set(wd->lay, si->part, si->p.text.text);
313 _elm_layout_label_set(Evas_Object *obj, const char *part, const char *text)
315 Widget_Data *wd = elm_widget_data_get(obj);
318 ELM_CHECK_WIDTYPE(obj, widtype);
319 if (!part) part = "elm.text";
321 EINA_LIST_FOREACH(wd->subs, l, si)
323 if ((si->type == TEXT) && (!strcmp(part, si->part)))
327 eina_stringshare_del(si->part);
328 eina_stringshare_del(si->p.text.text);
330 edje_object_part_text_set(wd->lay, part, NULL);
331 wd->subs = eina_list_remove_list(wd->subs, l);
342 si = ELM_NEW(Subinfo);
345 si->part = eina_stringshare_add(part);
346 wd->subs = eina_list_append(wd->subs, si);
349 eina_stringshare_replace(&si->p.text.text, text);
350 edje_object_part_text_set(wd->lay, part, text);
351 _request_sizing_eval(wd);
355 _elm_layout_label_get(const Evas_Object *obj, const char *part)
357 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
358 Widget_Data *wd = elm_widget_data_get(obj);
359 if (!part) part = "elm.text";
360 return edje_object_part_text_get(wd->lay, part);
364 * Add a new layout to the parent
366 * @param parent The parent object
367 * @return The new object or NULL if it cannot be created
372 elm_layout_add(Evas_Object *parent)
378 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
380 ELM_SET_WIDTYPE(widtype, "layout");
381 elm_widget_type_set(obj, "layout");
382 elm_widget_sub_object_add(parent, obj);
383 elm_widget_data_set(obj, wd);
384 elm_widget_del_hook_set(obj, _del_hook);
385 elm_widget_theme_hook_set(obj, _theme_hook);
386 elm_widget_changed_hook_set(obj, _changed_hook);
387 elm_widget_can_focus_set(obj, EINA_FALSE);
388 elm_widget_focus_next_hook_set(obj, _elm_layout_focus_next_hook);
389 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
390 elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
391 elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
392 elm_widget_text_set_hook_set(obj, _elm_layout_label_set);
393 elm_widget_text_get_hook_set(obj, _elm_layout_label_get);
396 wd->lay = edje_object_add(e);
397 elm_widget_resize_object_set(obj, wd->lay);
398 edje_object_signal_callback_add(wd->lay, "size,eval", "elm",
399 _signal_size_eval, wd);
401 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
403 _mirrored_set(obj, elm_widget_mirrored_get(obj));
404 _request_sizing_eval(wd);
409 * Set the file that will be used as layout
411 * @param obj The layout object
412 * @param file The path to file (edj) that will be used as layout
413 * @param group The group that the layout belongs in edje file
415 * @return (1 = success, 0 = error)
420 elm_layout_file_set(Evas_Object *obj, const char *file, const char *group)
422 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
423 Widget_Data *wd = elm_widget_data_get(obj);
424 if (!wd) return EINA_FALSE;
425 Eina_Bool ret = edje_object_file_set(wd->lay, file, group);
429 _request_sizing_eval(wd);
430 _parts_cursors_apply(wd);
432 else DBG("failed to set edje file '%s', group '%s': %s",
434 edje_load_error_str(edje_object_load_error_get(wd->lay)));
439 * Set the edje group from the elementary theme that will be used as layout
441 * @param obj The layout object
442 * @param clas the clas of the group
443 * @param group the group
444 * @param style the style to used
446 * @return (1 = success, 0 = error)
451 elm_layout_theme_set(Evas_Object *obj, const char *clas, const char *group, const char *style)
453 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
454 Widget_Data *wd = elm_widget_data_get(obj);
455 if (!wd) return EINA_FALSE;
456 Eina_Bool ret = _elm_theme_object_set(obj, wd->lay, clas, group, style);
463 _request_sizing_eval(wd);
464 _parts_cursors_apply(wd);
470 * Set the layout content
472 * Once the content object is set, a previously set one will be deleted.
473 * If you want to keep that old content object, use the
474 * elm_layout_content_unset() function.
476 * @param obj The layout object
477 * @param swallow The swallow group name in the edje file
478 * @param content The content will be filled in this layout object
483 elm_layout_content_set(Evas_Object *obj, const char *swallow, Evas_Object *content)
485 ELM_CHECK_WIDTYPE(obj, widtype);
486 Widget_Data *wd = elm_widget_data_get(obj);
490 EINA_LIST_FOREACH(wd->subs, l, si)
492 if ((si->type == SWALLOW) && (!strcmp(swallow, si->part)))
494 if (content == si->obj) return;
495 evas_object_del(si->obj);
501 elm_widget_sub_object_add(obj, content);
502 evas_object_event_callback_add(content,
503 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
504 _changed_size_hints, wd);
505 if (!edje_object_part_swallow(wd->lay, swallow, content))
506 WRN("could not swallow %p into part '%s'", content, swallow);
507 si = ELM_NEW(Subinfo);
509 si->part = eina_stringshare_add(swallow);
511 wd->subs = eina_list_append(wd->subs, si);
513 _request_sizing_eval(wd);
517 * Get the swallowed object in the given part
519 * @param obj The layout object
520 * @param swallow The SWALLOW part to get its content
522 * @return The swallowed object or NULL if none or an error occurred
527 elm_layout_content_get(const Evas_Object *obj, const char *swallow)
529 Widget_Data *wd = elm_widget_data_get(obj);
532 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
534 EINA_LIST_FOREACH(wd->subs, l, si)
536 if ((si->type == SWALLOW) && !strcmp(swallow, si->part))
543 * Unset the layout content
545 * Unparent and return the content object which was set for this widget
547 * @param obj The layout object
548 * @param swallow The swallow group name in the edje file
549 * @return The content that was being used
554 elm_layout_content_unset(Evas_Object *obj, const char *swallow)
556 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
557 Widget_Data *wd = elm_widget_data_get(obj);
560 if (!wd) return NULL;
561 EINA_LIST_FOREACH(wd->subs, l, si)
563 if ((si->type == SWALLOW) && (!strcmp(swallow, si->part)))
565 Evas_Object *content;
566 if (!si->obj) return NULL;
567 content = si->obj; /* si will die in _sub_del due elm_widget_sub_object_del() */
568 elm_widget_sub_object_del(obj, content);
569 edje_object_part_unswallow(wd->lay, content);
577 * Set the text of the given part
579 * @param obj The layout object
580 * @param part The TEXT part where to set the text
581 * @param text The text to set
584 * @deprecate use elm_object_text_* instead.
587 elm_layout_text_set(Evas_Object *obj, const char *part, const char *text)
589 _elm_layout_label_set(obj, part, text);
593 * Get the text set in the given part
595 * @param obj The layout object
596 * @param part The TEXT part to retrieve the text off
598 * @return The text set in @p part
601 * @deprecate use elm_object_text_* instead.
604 elm_layout_text_get(const Evas_Object *obj, const char *part)
606 return _elm_layout_label_get(obj, part);
610 * Append child to layout box part.
612 * Once the object is appended, its lifetime will be bound to the
613 * layout, whenever the layout dies the child will be deleted
614 * automatically. One should use elm_layout_box_remove() to make this
615 * layout forget about the object.
617 * @param obj the layout object
618 * @param part the box part to append.
619 * @param child the child object to append to box.
624 elm_layout_box_append(Evas_Object *obj, const char *part, Evas_Object *child)
626 ELM_CHECK_WIDTYPE(obj, widtype);
627 Widget_Data *wd = elm_widget_data_get(obj);
631 if (!edje_object_part_box_append(wd->lay, part, child))
632 WRN("child %p could not be appended to box part '%s'", child, part);
633 elm_widget_sub_object_add(obj, child);
634 evas_object_event_callback_add
635 (child, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, wd);
637 si = ELM_NEW(Subinfo);
638 si->type = BOX_APPEND;
639 si->part = eina_stringshare_add(part);
641 wd->subs = eina_list_append(wd->subs, si);
642 _request_sizing_eval(wd);
646 * Prepend child to layout box part.
648 * Once the object is prepended, its lifetime will be bound to the
649 * layout, whenever the layout dies the child will be deleted
650 * automatically. One should use elm_layout_box_remove() to make this
651 * layout forget about the object.
653 * @param obj the layout object
654 * @param part the box part to prepend.
655 * @param child the child object to prepend to box.
660 elm_layout_box_prepend(Evas_Object *obj, const char *part, Evas_Object *child)
662 ELM_CHECK_WIDTYPE(obj, widtype);
663 Widget_Data *wd = elm_widget_data_get(obj);
667 if (!edje_object_part_box_prepend(wd->lay, part, child))
668 WRN("child %p could not be prepended to box part '%s'", child, part);
669 elm_widget_sub_object_add(obj, child);
670 evas_object_event_callback_add
671 (child, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, wd);
673 si = ELM_NEW(Subinfo);
674 si->type = BOX_PREPEND;
675 si->part = eina_stringshare_add(part);
677 wd->subs = eina_list_prepend(wd->subs, si);
678 _request_sizing_eval(wd);
682 _box_reference_del(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
685 si->p.box.reference = NULL;
689 * Insert child to layout box part before a reference object.
691 * Once the object is inserted, its lifetime will be bound to the
692 * layout, whenever the layout dies the child will be deleted
693 * automatically. One should use elm_layout_box_remove() to make this
694 * layout forget about the object.
696 * @param obj the layout object
697 * @param part the box part to insert.
698 * @param child the child object to insert into box.
699 * @param reference another reference object to insert before in box.
704 elm_layout_box_insert_before(Evas_Object *obj, const char *part, Evas_Object *child, const Evas_Object *reference)
706 ELM_CHECK_WIDTYPE(obj, widtype);
707 Widget_Data *wd = elm_widget_data_get(obj);
711 if (!edje_object_part_box_insert_before(wd->lay, part, child, reference))
712 WRN("child %p could not be inserted before %p inf box part '%s'",
713 child, reference, part);
715 si = ELM_NEW(Subinfo);
716 si->type = BOX_INSERT_BEFORE;
717 si->part = eina_stringshare_add(part);
719 si->p.box.reference = reference;
721 elm_widget_sub_object_add(obj, child);
722 evas_object_event_callback_add
723 (child, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, wd);
724 evas_object_event_callback_add
725 ((Evas_Object *)reference, EVAS_CALLBACK_DEL, _box_reference_del, si);
727 wd->subs = eina_list_append(wd->subs, si);
728 _request_sizing_eval(wd);
732 * Insert child to layout box part at a given position.
734 * Once the object is inserted, its lifetime will be bound to the
735 * layout, whenever the layout dies the child will be deleted
736 * automatically. One should use elm_layout_box_remove() to make this
737 * layout forget about the object.
739 * @param obj the layout object
740 * @param part the box part to insert.
741 * @param child the child object to insert into box.
742 * @param pos the numeric position >=0 to insert the child.
747 elm_layout_box_insert_at(Evas_Object *obj, const char *part, Evas_Object *child, unsigned int pos)
749 ELM_CHECK_WIDTYPE(obj, widtype);
750 Widget_Data *wd = elm_widget_data_get(obj);
754 if (!edje_object_part_box_insert_at(wd->lay, part, child, pos))
755 WRN("child %p could not be inserted at %u to box part '%s'",
758 elm_widget_sub_object_add(obj, child);
759 evas_object_event_callback_add
760 (child, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, wd);
762 si = ELM_NEW(Subinfo);
763 si->type = BOX_INSERT_AT;
764 si->part = eina_stringshare_add(part);
767 wd->subs = eina_list_append(wd->subs, si);
768 _request_sizing_eval(wd);
772 _sub_box_remove(Widget_Data *wd, Subinfo *si)
776 if (si->type == BOX_INSERT_BEFORE)
777 evas_object_event_callback_del_full
778 ((Evas_Object *)si->p.box.reference,
779 EVAS_CALLBACK_DEL, _box_reference_del, si);
781 child = si->obj; /* si will die in _sub_del due elm_widget_sub_object_del() */
782 edje_object_part_box_remove(wd->lay, si->part, child);
783 elm_widget_sub_object_del(wd->obj, child);
788 _sub_table_remove(Widget_Data *wd, Subinfo *si)
792 child = si->obj; /* si will die in _sub_del due elm_widget_sub_object_del() */
793 edje_object_part_table_unpack(wd->lay, si->part, child);
794 elm_widget_sub_object_del(wd->obj, child);
799 _sub_box_is(const Subinfo *si)
805 case BOX_INSERT_BEFORE:
814 * Remove a child of the given part box.
816 * The object will be removed from the box part and its lifetime will
817 * not be handled by the layout anymore. This is equivalent to
818 * elm_layout_content_unset() for box.
820 * @param obj The layout object
821 * @param part The box part name to remove child.
822 * @param child The object to remove from box.
823 * @return The object that was being used, or NULL if not found.
828 elm_layout_box_remove(Evas_Object *obj, const char *part, Evas_Object *child)
830 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
831 Widget_Data *wd = elm_widget_data_get(obj);
835 if (!wd) return NULL;
837 EINA_SAFETY_ON_NULL_RETURN_VAL(part, NULL);
838 EINA_SAFETY_ON_NULL_RETURN_VAL(child, NULL);
839 EINA_LIST_FOREACH(wd->subs, l, si)
841 if (!_sub_box_is(si)) continue;
842 if ((si->obj == child) && (!strcmp(si->part, part)))
843 return _sub_box_remove(wd, si);
849 * Remove all child of the given part box.
851 * The objects will be removed from the box part and their lifetime will
852 * not be handled by the layout anymore. This is equivalent to
853 * elm_layout_content_unset() for all box children.
855 * @param obj The layout object
856 * @param part The box part name to remove child.
857 * @param clear If EINA_TRUE, then all objects will be deleted as
858 * well, otherwise they will just be removed and will be
859 * dangling on the canvas.
864 elm_layout_box_remove_all(Evas_Object *obj, const char *part, Eina_Bool clear)
866 ELM_CHECK_WIDTYPE(obj, widtype);
867 Widget_Data *wd = elm_widget_data_get(obj);
872 EINA_SAFETY_ON_NULL_RETURN(part);
874 lst = eina_list_clone(wd->subs);
875 EINA_LIST_FREE(lst, si)
877 if (!_sub_box_is(si)) continue;
878 if (!strcmp(si->part, part))
880 Evas_Object *child = _sub_box_remove(wd, si);
881 if ((clear) && (child)) evas_object_del(child);
884 /* eventually something may not be added with layout, del them as well */
885 edje_object_part_box_remove_all(wd->lay, part, clear);
889 * Insert child to layout table part.
891 * Once the object is inserted, its lifetime will be bound to the
892 * layout, whenever the layout dies the child will be deleted
893 * automatically. One should use elm_layout_box_remove() to make this
894 * layout forget about the object.
896 * @param obj the layout object
897 * @param part the box part to pack child.
898 * @param child the child object to pack into table.
899 * @param reference another reference object to insert before in box.
904 elm_layout_table_pack(Evas_Object *obj, const char *part, Evas_Object *child, unsigned short col, unsigned short row, unsigned short colspan, unsigned short rowspan)
906 ELM_CHECK_WIDTYPE(obj, widtype);
907 Widget_Data *wd = elm_widget_data_get(obj);
911 if (!edje_object_part_table_pack
912 (wd->lay, part, child, col, row, colspan, rowspan))
913 WRN("child %p could not be packed into box part '%s' col=%uh, row=%hu, "
914 "colspan=%hu, rowspan=%hu", child, part, col, row, colspan, rowspan);
916 elm_widget_sub_object_add(obj, child);
917 evas_object_event_callback_add
918 (child, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, wd);
920 si = ELM_NEW(Subinfo);
921 si->type = TABLE_PACK;
922 si->part = eina_stringshare_add(part);
924 si->p.table.col = col;
925 si->p.table.row = row;
926 si->p.table.colspan = colspan;
927 si->p.table.rowspan = rowspan;
928 wd->subs = eina_list_append(wd->subs, si);
929 _request_sizing_eval(wd);
933 * Unpack (remove) a child of the given part table.
935 * The object will be unpacked from the table part and its lifetime
936 * will not be handled by the layout anymore. This is equivalent to
937 * elm_layout_content_unset() for table.
939 * @param obj The layout object
940 * @param part The table part name to remove child.
941 * @param child The object to remove from table.
942 * @return The object that was being used, or NULL if not found.
947 elm_layout_table_unpack(Evas_Object *obj, const char *part, Evas_Object *child)
949 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
950 Widget_Data *wd = elm_widget_data_get(obj);
954 if (!wd) return NULL;
956 EINA_SAFETY_ON_NULL_RETURN_VAL(part, NULL);
957 EINA_SAFETY_ON_NULL_RETURN_VAL(child, NULL);
958 EINA_LIST_FOREACH(wd->subs, l, si)
960 if (si->type != TABLE_PACK) continue;
961 if ((si->obj == child) && (!strcmp(si->part, part)))
962 return _sub_table_remove(wd, si);
968 * Remove all child of the given part table.
970 * The objects will be removed from the table part and their lifetime will
971 * not be handled by the layout anymore. This is equivalent to
972 * elm_layout_content_unset() for all table children.
974 * @param obj The layout object
975 * @param part The table part name to remove child.
976 * @param clear If EINA_TRUE, then all objects will be deleted as
977 * well, otherwise they will just be removed and will be
978 * dangling on the canvas.
983 elm_layout_table_clear(Evas_Object *obj, const char *part, Eina_Bool clear)
985 ELM_CHECK_WIDTYPE(obj, widtype);
986 Widget_Data *wd = elm_widget_data_get(obj);
991 EINA_SAFETY_ON_NULL_RETURN(part);
993 lst = eina_list_clone(wd->subs);
994 EINA_LIST_FREE(lst, si)
996 if (si->type != TABLE_PACK) continue;
997 if (!strcmp(si->part, part))
999 Evas_Object *child = _sub_table_remove(wd, si);
1000 if ((clear) && (child)) evas_object_del(child);
1003 /* eventually something may not be added with layout, del them as well */
1004 edje_object_part_table_clear(wd->lay, part, clear);
1008 * Get the edje layout
1010 * @param obj The layout object
1012 * This returns the edje object. It is not expected to be used to then swallow
1013 * objects via edje_object_part_swallow() for example. Use
1014 * elm_layout_content_set() instead so child object handling and sizing is
1015 * done properly. This is more intended for setting text, emitting signals,
1016 * hooking to signal callbacks etc.
1018 * @return A Evas_Object with the edje layout settings loaded
1019 * with function elm_layout_file_set
1024 elm_layout_edje_get(const Evas_Object *obj)
1026 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1027 Widget_Data *wd = elm_widget_data_get(obj);
1028 if (!wd) return NULL;
1033 * Get the edje data of the given layout
1035 * @param obj The layout object
1036 * @param key The data key
1038 * @return The edje data string
1040 * This function fetches data specified at the object level.
1041 * This function return NULL if data is not found.
1043 * In EDC this comes from a data block within the group block that @a
1044 * obj was loaded from. E.g.
1051 * item: "key1" "value1";
1052 * item: "key2" "value2";
1061 elm_layout_data_get(const Evas_Object *obj, const char *key)
1063 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1064 Widget_Data *wd = elm_widget_data_get(obj);
1065 return edje_object_data_get(wd->lay, key);
1071 * Manually forms a sizing re-evaluation when contents changed state so that
1072 * minimum size might have changed and needs re-evaluation. Also note that
1073 * a standard signal of "size,eval" "elm" emitted by the edje object will
1074 * cause this to happen too
1076 * @param obj The layout object
1081 elm_layout_sizing_eval(Evas_Object *obj)
1083 ELM_CHECK_WIDTYPE(obj, widtype);
1084 Widget_Data *wd = elm_widget_data_get(obj);
1085 EINA_SAFETY_ON_NULL_RETURN(wd);
1086 _request_sizing_eval(wd);
1090 * Sets a specific cursor for an edje part.
1092 * @param obj The layout object.
1093 * @param part_name a part from loaded edje group.
1094 * @param cursor cursor name to use, see Elementary_Cursor.h
1096 * @return EINA_TRUE on success or EINA_FALSE on failure, that may be
1097 * part not exists or it has "mouse_events: 0".
1102 elm_layout_part_cursor_set(Evas_Object *obj, const char *part_name, const char *cursor)
1104 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1105 EINA_SAFETY_ON_NULL_RETURN_VAL(part_name, EINA_FALSE);
1106 Widget_Data *wd = elm_widget_data_get(obj);
1107 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EINA_FALSE);
1108 Evas_Object *part_obj;
1111 part_obj = (Evas_Object *)edje_object_part_object_get(wd->lay, part_name);
1114 const char *group, *file;
1115 edje_object_file_get(wd->lay, &file, &group);
1116 WRN("no part '%s' in group '%s' of file '%s'. Cannot set cursor '%s'",
1117 part_name, group, file, cursor);
1120 if (evas_object_pass_events_get(part_obj))
1122 const char *group, *file;
1123 edje_object_file_get(wd->lay, &file, &group);
1124 WRN("part '%s' in group '%s' of file '%s' has mouse_events: 0. "
1125 "Cannot set cursor '%s'",
1126 part_name, group, file, cursor);
1130 pc = _parts_cursors_find(wd, part_name);
1131 if (pc) eina_stringshare_replace(&pc->cursor, cursor);
1134 pc = calloc(1, sizeof(*pc));
1135 pc->part = eina_stringshare_add(part_name);
1136 pc->cursor = eina_stringshare_add(cursor);
1140 elm_object_sub_cursor_set(part_obj, obj, pc->cursor);
1145 * Get the cursor to be shown when mouse is over an edje part
1147 * @param obj The layout object.
1148 * @param part_name a part from loaded edje group.
1149 * @return the cursor name.
1154 elm_layout_part_cursor_get(const Evas_Object *obj, const char *part_name)
1156 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1157 EINA_SAFETY_ON_NULL_RETURN_VAL(part_name, NULL);
1158 Widget_Data *wd = elm_widget_data_get(obj);
1159 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
1160 Part_Cursor *pc = _parts_cursors_find(wd, part_name);
1161 EINA_SAFETY_ON_NULL_RETURN_VAL(pc, NULL);
1162 EINA_SAFETY_ON_NULL_RETURN_VAL(pc->obj, NULL);
1163 return elm_object_cursor_get(pc->obj);
1167 * Unsets a cursor previously set with elm_layout_part_cursor_set().
1169 * @param obj The layout object.
1170 * @param part_name a part from loaded edje group, that had a cursor set
1171 * with elm_layout_part_cursor_set().
1176 elm_layout_part_cursor_unset(Evas_Object *obj, const char *part_name)
1178 ELM_CHECK_WIDTYPE(obj, widtype);
1179 EINA_SAFETY_ON_NULL_RETURN(part_name);
1180 Widget_Data *wd = elm_widget_data_get(obj);
1181 EINA_SAFETY_ON_NULL_RETURN(wd);
1185 EINA_LIST_FOREACH(wd->parts_cursors, l, pc)
1187 if (!strcmp(part_name, pc->part))
1189 if (pc->obj) elm_object_cursor_unset(pc->obj);
1190 _part_cursor_free(pc);
1191 wd->parts_cursors = eina_list_remove_list(wd->parts_cursors, l);
1198 * Sets a specific cursor style for an edje part.
1200 * @param obj The layout object.
1201 * @param part_name a part from loaded edje group.
1202 * @param style the theme style to use (default, transparent, ...)
1204 * @return EINA_TRUE on success or EINA_FALSE on failure, that may be
1205 * part not exists or it did not had a cursor set.
1210 elm_layout_part_cursor_style_set(Evas_Object *obj, const char *part_name, const char *style)
1212 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1213 EINA_SAFETY_ON_NULL_RETURN_VAL(part_name, EINA_FALSE);
1214 Widget_Data *wd = elm_widget_data_get(obj);
1215 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EINA_FALSE);
1216 Part_Cursor *pc = _parts_cursors_find(wd, part_name);
1217 EINA_SAFETY_ON_NULL_RETURN_VAL(pc, EINA_FALSE);
1218 EINA_SAFETY_ON_NULL_RETURN_VAL(pc->obj, EINA_FALSE);
1220 eina_stringshare_replace(&pc->style, style);
1221 elm_object_cursor_style_set(pc->obj, pc->style);
1226 * Gets a specific cursor style for an edje part.
1228 * @param obj The layout object.
1229 * @param part_name a part from loaded edje group.
1231 * @return the theme style in use, defaults to "default". If the
1232 * object does not have a cursor set, then NULL is returned.
1237 elm_layout_part_cursor_style_get(const Evas_Object *obj, const char *part_name)
1239 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1240 EINA_SAFETY_ON_NULL_RETURN_VAL(part_name, NULL);
1241 Widget_Data *wd = elm_widget_data_get(obj);
1242 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
1243 Part_Cursor *pc = _parts_cursors_find(wd, part_name);
1244 EINA_SAFETY_ON_NULL_RETURN_VAL(pc, NULL);
1245 EINA_SAFETY_ON_NULL_RETURN_VAL(pc->obj, NULL);
1246 return elm_object_cursor_style_get(pc->obj);
1250 * Sets if the cursor set should be searched on the theme or should use
1251 * the provided by the engine, only.
1253 * @note before you set if should look on theme you should define a
1254 * cursor with elm_layout_part_cursor_set(). By default it will only
1255 * look for cursors provided by the engine.
1257 * @param obj The layout object.
1258 * @param part_name a part from loaded edje group.
1259 * @param engine_only if cursors should be just provided by the engine
1260 * or should also search on widget's theme as well
1262 * @return EINA_TRUE on success or EINA_FALSE on failure, that may be
1263 * part not exists or it did not had a cursor set.
1268 elm_layout_part_cursor_engine_only_set(Evas_Object *obj, const char *part_name, Eina_Bool engine_only)
1270 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1271 EINA_SAFETY_ON_NULL_RETURN_VAL(part_name, EINA_FALSE);
1272 Widget_Data *wd = elm_widget_data_get(obj);
1273 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EINA_FALSE);
1274 Part_Cursor *pc = _parts_cursors_find(wd, part_name);
1275 EINA_SAFETY_ON_NULL_RETURN_VAL(pc, EINA_FALSE);
1276 EINA_SAFETY_ON_NULL_RETURN_VAL(pc->obj, EINA_FALSE);
1278 pc->engine_only = !!engine_only;
1279 elm_object_cursor_engine_only_set(pc->obj, pc->engine_only);
1284 * Gets a specific cursor engine_only for an edje part.
1286 * @param obj The layout object.
1287 * @param part_name a part from loaded edje group.
1289 * @return whenever the cursor is just provided by engine or also from theme.
1294 elm_layout_part_cursor_engine_only_get(const Evas_Object *obj, const char *part_name)
1296 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1297 EINA_SAFETY_ON_NULL_RETURN_VAL(part_name, EINA_FALSE);
1298 Widget_Data *wd = elm_widget_data_get(obj);
1299 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EINA_FALSE);
1300 Part_Cursor *pc = _parts_cursors_find(wd, part_name);
1301 EINA_SAFETY_ON_NULL_RETURN_VAL(pc, EINA_FALSE);
1302 EINA_SAFETY_ON_NULL_RETURN_VAL(pc->obj, EINA_FALSE);
1303 return elm_object_cursor_engine_only_get(pc->obj);