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);
73 static const char SIG_THEME_CHANGED[] = "theme,changed";
75 static const Evas_Smart_Cb_Description _signals[] = {
76 {SIG_THEME_CHANGED, ""},
81 _del_hook(Evas_Object *obj)
83 Widget_Data *wd = elm_widget_data_get(obj);
88 EINA_LIST_FREE(wd->subs, si)
90 eina_stringshare_del(si->part);
92 eina_stringshare_del(si->p.text.text);
95 EINA_LIST_FREE(wd->parts_cursors, pc) _part_cursor_free(pc);
100 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
102 Widget_Data *wd = elm_widget_data_get(obj);
104 edje_object_mirrored_set(wd->lay, rtl);
108 _theme_hook(Evas_Object *obj)
110 Widget_Data *wd = elm_widget_data_get(obj);
112 _elm_widget_mirrored_reload(obj);
113 _mirrored_set(obj, elm_widget_mirrored_get(obj));
114 _elm_theme_object_set(obj, wd->lay, wd->clas, wd->group, wd->style);
115 edje_object_scale_set(wd->lay, elm_widget_scale_get(obj) *
117 evas_object_smart_callback_call(obj, SIG_THEME_CHANGED, NULL);
122 _changed_hook(Evas_Object *obj)
124 Widget_Data *wd = elm_widget_data_get(obj);
126 if (wd->needs_size_calc)
129 wd->needs_size_calc = 0;
134 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
136 Widget_Data *wd = elm_widget_data_get(obj);
137 edje_object_signal_emit(wd->lay, emission, source);
141 _signal_callback_add_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
143 Widget_Data *wd = elm_widget_data_get(obj);
144 edje_object_signal_callback_add(wd->lay, emission, source, func_cb, data);
148 _signal_callback_del_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
150 Widget_Data *wd = elm_widget_data_get(obj);
151 edje_object_signal_callback_del_full(wd->lay, emission, source, func_cb,
157 _elm_layout_list_data_get(const Eina_List *list)
159 Subinfo *si = eina_list_data_get(list);
164 _elm_layout_focus_next_hook(const Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next)
166 Widget_Data *wd = elm_widget_data_get(obj);
167 const Eina_List *items;
168 void *(*list_data_get) (const Eina_List *list);
170 if ((!wd) || (!wd->subs))
173 /* Focus chain (This block is diferent of elm_win cycle)*/
174 if ((items = elm_widget_focus_custom_chain_get(obj)))
175 list_data_get = eina_list_data_get;
179 list_data_get = _elm_layout_list_data_get;
181 if (!items) return EINA_FALSE;
184 return elm_widget_focus_list_next_get(obj, items, list_data_get, dir,
189 _sizing_eval(Widget_Data *wd)
191 Evas_Coord minw = -1, minh = -1;
192 edje_object_size_min_calc(wd->lay, &minw, &minh);
193 evas_object_size_hint_min_set(wd->obj, minw, minh);
194 evas_object_size_hint_max_set(wd->obj, -1, -1);
198 _request_sizing_eval(Widget_Data *wd)
200 if (wd->needs_size_calc) return;
201 wd->needs_size_calc = 1;
202 evas_object_smart_changed(wd->obj);
206 _part_cursor_free(Part_Cursor *pc)
208 eina_stringshare_del(pc->part);
209 eina_stringshare_del(pc->style);
210 eina_stringshare_del(pc->cursor);
215 _part_cursor_part_apply(const Part_Cursor *pc)
217 elm_object_cursor_set(pc->obj, pc->cursor);
218 elm_object_cursor_style_set(pc->obj, pc->style);
219 elm_object_cursor_engine_only_set(pc->obj, pc->engine_only);
223 _parts_cursors_find(Widget_Data *wd, const char *part)
227 EINA_LIST_FOREACH(wd->parts_cursors, l, pc)
229 if (!strcmp(pc->part, part))
236 _parts_cursors_apply(Widget_Data *wd)
238 const char *file, *group;
242 edje_object_file_get(wd->lay, &file, &group);
244 EINA_LIST_FOREACH(wd->parts_cursors, l, pc)
246 Evas_Object *obj = (Evas_Object *)edje_object_part_object_get
252 WRN("no part '%s' in group '%s' of file '%s'. "
253 "Cannot set cursor '%s'",
254 pc->part, group, file, pc->cursor);
257 else if (evas_object_pass_events_get(obj))
260 WRN("part '%s' in group '%s' of file '%s' has mouse_events: 0. "
261 "Cannot set cursor '%s'",
262 pc->part, group, file, pc->cursor);
267 _part_cursor_part_apply(pc);
272 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
274 _request_sizing_eval(data);
278 _sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info)
280 Widget_Data *wd = elm_widget_data_get(obj);
281 Evas_Object *sub = event_info;
285 EINA_LIST_FOREACH(wd->subs, l, si)
289 evas_object_event_callback_del_full(sub,
290 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
293 wd->subs = eina_list_remove_list(wd->subs, l);
294 eina_stringshare_del(si->part);
302 _signal_size_eval(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
304 _request_sizing_eval(data);
308 _parts_text_fix(Widget_Data *wd)
313 EINA_LIST_FOREACH(wd->subs, l, si)
315 if (si->type == TEXT)
316 edje_object_part_text_set(wd->lay, si->part, si->p.text.text);
321 _elm_layout_label_set(Evas_Object *obj, const char *part, const char *text)
323 Widget_Data *wd = elm_widget_data_get(obj);
326 ELM_CHECK_WIDTYPE(obj, widtype);
327 if (!part) part = "elm.text";
329 EINA_LIST_FOREACH(wd->subs, l, si)
331 if ((si->type == TEXT) && (!strcmp(part, si->part)))
335 eina_stringshare_del(si->part);
336 eina_stringshare_del(si->p.text.text);
338 edje_object_part_text_set(wd->lay, part, NULL);
339 wd->subs = eina_list_remove_list(wd->subs, l);
350 si = ELM_NEW(Subinfo);
353 si->part = eina_stringshare_add(part);
354 wd->subs = eina_list_append(wd->subs, si);
357 eina_stringshare_replace(&si->p.text.text, text);
358 edje_object_part_text_set(wd->lay, part, text);
359 _request_sizing_eval(wd);
363 _elm_layout_label_get(const Evas_Object *obj, const char *part)
365 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
366 Widget_Data *wd = elm_widget_data_get(obj);
367 if (!part) part = "elm.text";
368 return edje_object_part_text_get(wd->lay, part);
372 * Add a new layout to the parent
374 * @param parent The parent object
375 * @return The new object or NULL if it cannot be created
380 elm_layout_add(Evas_Object *parent)
386 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
388 ELM_SET_WIDTYPE(widtype, "layout");
389 elm_widget_type_set(obj, "layout");
390 elm_widget_sub_object_add(parent, obj);
391 elm_widget_data_set(obj, wd);
392 elm_widget_del_hook_set(obj, _del_hook);
393 elm_widget_theme_hook_set(obj, _theme_hook);
394 elm_widget_changed_hook_set(obj, _changed_hook);
395 elm_widget_can_focus_set(obj, EINA_FALSE);
396 elm_widget_focus_next_hook_set(obj, _elm_layout_focus_next_hook);
397 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
398 elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
399 elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
400 elm_widget_text_set_hook_set(obj, _elm_layout_label_set);
401 elm_widget_text_get_hook_set(obj, _elm_layout_label_get);
404 wd->lay = edje_object_add(e);
405 elm_widget_resize_object_set(obj, wd->lay);
406 edje_object_signal_callback_add(wd->lay, "size,eval", "elm",
407 _signal_size_eval, wd);
409 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
410 evas_object_smart_callbacks_descriptions_set(obj, _signals);
412 _mirrored_set(obj, elm_widget_mirrored_get(obj));
413 _request_sizing_eval(wd);
418 * Set the file that will be used as layout
420 * @param obj The layout object
421 * @param file The path to file (edj) that will be used as layout
422 * @param group The group that the layout belongs in edje file
424 * @return (1 = success, 0 = error)
429 elm_layout_file_set(Evas_Object *obj, const char *file, const char *group)
431 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
432 Widget_Data *wd = elm_widget_data_get(obj);
433 if (!wd) return EINA_FALSE;
434 Eina_Bool ret = edje_object_file_set(wd->lay, file, group);
438 _request_sizing_eval(wd);
439 _parts_cursors_apply(wd);
441 else DBG("failed to set edje file '%s', group '%s': %s",
443 edje_load_error_str(edje_object_load_error_get(wd->lay)));
448 * Set the edje group from the elementary theme that will be used as layout
450 * @param obj The layout object
451 * @param clas the clas of the group
452 * @param group the group
453 * @param style the style to used
455 * @return (1 = success, 0 = error)
460 elm_layout_theme_set(Evas_Object *obj, const char *clas, const char *group, const char *style)
462 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
463 Widget_Data *wd = elm_widget_data_get(obj);
464 if (!wd) return EINA_FALSE;
465 Eina_Bool ret = _elm_theme_object_set(obj, wd->lay, clas, group, style);
472 _request_sizing_eval(wd);
473 _parts_cursors_apply(wd);
479 * Set the layout content
481 * Once the content object is set, a previously set one will be deleted.
482 * If you want to keep that old content object, use the
483 * elm_layout_content_unset() function.
485 * @param obj The layout object
486 * @param swallow The swallow group name in the edje file
487 * @param content The content will be filled in this layout object
492 elm_layout_content_set(Evas_Object *obj, const char *swallow, Evas_Object *content)
494 ELM_CHECK_WIDTYPE(obj, widtype);
495 Widget_Data *wd = elm_widget_data_get(obj);
499 EINA_LIST_FOREACH(wd->subs, l, si)
501 if ((si->type == SWALLOW) && (!strcmp(swallow, si->part)))
503 if (content == si->obj) return;
504 evas_object_del(si->obj);
510 elm_widget_sub_object_add(obj, content);
511 evas_object_event_callback_add(content,
512 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
513 _changed_size_hints, wd);
514 if (!edje_object_part_swallow(wd->lay, swallow, content))
515 WRN("could not swallow %p into part '%s'", content, swallow);
516 si = ELM_NEW(Subinfo);
518 si->part = eina_stringshare_add(swallow);
520 wd->subs = eina_list_append(wd->subs, si);
522 _request_sizing_eval(wd);
526 * Get the swallowed object in the given part
528 * @param obj The layout object
529 * @param swallow The SWALLOW part to get its content
531 * @return The swallowed object or NULL if none or an error occurred
536 elm_layout_content_get(const Evas_Object *obj, const char *swallow)
538 Widget_Data *wd = elm_widget_data_get(obj);
541 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
543 EINA_LIST_FOREACH(wd->subs, l, si)
545 if ((si->type == SWALLOW) && !strcmp(swallow, si->part))
552 * Unset the layout content
554 * Unparent and return the content object which was set for this widget
556 * @param obj The layout object
557 * @param swallow The swallow group name in the edje file
558 * @return The content that was being used
563 elm_layout_content_unset(Evas_Object *obj, const char *swallow)
565 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
566 Widget_Data *wd = elm_widget_data_get(obj);
569 if (!wd) return NULL;
570 EINA_LIST_FOREACH(wd->subs, l, si)
572 if ((si->type == SWALLOW) && (!strcmp(swallow, si->part)))
574 Evas_Object *content;
575 if (!si->obj) return NULL;
576 content = si->obj; /* si will die in _sub_del due elm_widget_sub_object_del() */
577 elm_widget_sub_object_del(obj, content);
578 edje_object_part_unswallow(wd->lay, content);
586 * Set the text of the given part
588 * @param obj The layout object
589 * @param part The TEXT part where to set the text
590 * @param text The text to set
593 * @deprecate use elm_object_text_* instead.
596 elm_layout_text_set(Evas_Object *obj, const char *part, const char *text)
598 _elm_layout_label_set(obj, part, text);
602 * Get the text set in the given part
604 * @param obj The layout object
605 * @param part The TEXT part to retrieve the text off
607 * @return The text set in @p part
610 * @deprecate use elm_object_text_* instead.
613 elm_layout_text_get(const Evas_Object *obj, const char *part)
615 return _elm_layout_label_get(obj, part);
619 * Append child to layout box part.
621 * Once the object is appended, its lifetime will be bound to the
622 * layout, whenever the layout dies the child will be deleted
623 * automatically. One should use elm_layout_box_remove() to make this
624 * layout forget about the object.
626 * @param obj the layout object
627 * @param part the box part to append.
628 * @param child the child object to append to box.
633 elm_layout_box_append(Evas_Object *obj, const char *part, Evas_Object *child)
635 ELM_CHECK_WIDTYPE(obj, widtype);
636 Widget_Data *wd = elm_widget_data_get(obj);
640 if (!edje_object_part_box_append(wd->lay, part, child))
641 WRN("child %p could not be appended to box part '%s'", child, part);
642 elm_widget_sub_object_add(obj, child);
643 evas_object_event_callback_add
644 (child, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, wd);
646 si = ELM_NEW(Subinfo);
647 si->type = BOX_APPEND;
648 si->part = eina_stringshare_add(part);
650 wd->subs = eina_list_append(wd->subs, si);
651 _request_sizing_eval(wd);
655 * Prepend child to layout box part.
657 * Once the object is prepended, its lifetime will be bound to the
658 * layout, whenever the layout dies the child will be deleted
659 * automatically. One should use elm_layout_box_remove() to make this
660 * layout forget about the object.
662 * @param obj the layout object
663 * @param part the box part to prepend.
664 * @param child the child object to prepend to box.
669 elm_layout_box_prepend(Evas_Object *obj, const char *part, Evas_Object *child)
671 ELM_CHECK_WIDTYPE(obj, widtype);
672 Widget_Data *wd = elm_widget_data_get(obj);
676 if (!edje_object_part_box_prepend(wd->lay, part, child))
677 WRN("child %p could not be prepended to box part '%s'", child, part);
678 elm_widget_sub_object_add(obj, child);
679 evas_object_event_callback_add
680 (child, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, wd);
682 si = ELM_NEW(Subinfo);
683 si->type = BOX_PREPEND;
684 si->part = eina_stringshare_add(part);
686 wd->subs = eina_list_prepend(wd->subs, si);
687 _request_sizing_eval(wd);
691 _box_reference_del(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
694 si->p.box.reference = NULL;
698 * Insert child to layout box part before a reference object.
700 * Once the object is inserted, its lifetime will be bound to the
701 * layout, whenever the layout dies the child will be deleted
702 * automatically. One should use elm_layout_box_remove() to make this
703 * layout forget about the object.
705 * @param obj the layout object
706 * @param part the box part to insert.
707 * @param child the child object to insert into box.
708 * @param reference another reference object to insert before in box.
713 elm_layout_box_insert_before(Evas_Object *obj, const char *part, Evas_Object *child, const Evas_Object *reference)
715 ELM_CHECK_WIDTYPE(obj, widtype);
716 Widget_Data *wd = elm_widget_data_get(obj);
720 if (!edje_object_part_box_insert_before(wd->lay, part, child, reference))
721 WRN("child %p could not be inserted before %p inf box part '%s'",
722 child, reference, part);
724 si = ELM_NEW(Subinfo);
725 si->type = BOX_INSERT_BEFORE;
726 si->part = eina_stringshare_add(part);
728 si->p.box.reference = reference;
730 elm_widget_sub_object_add(obj, child);
731 evas_object_event_callback_add
732 (child, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, wd);
733 evas_object_event_callback_add
734 ((Evas_Object *)reference, EVAS_CALLBACK_DEL, _box_reference_del, si);
736 wd->subs = eina_list_append(wd->subs, si);
737 _request_sizing_eval(wd);
741 * Insert child to layout box part at a given position.
743 * Once the object is inserted, its lifetime will be bound to the
744 * layout, whenever the layout dies the child will be deleted
745 * automatically. One should use elm_layout_box_remove() to make this
746 * layout forget about the object.
748 * @param obj the layout object
749 * @param part the box part to insert.
750 * @param child the child object to insert into box.
751 * @param pos the numeric position >=0 to insert the child.
756 elm_layout_box_insert_at(Evas_Object *obj, const char *part, Evas_Object *child, unsigned int pos)
758 ELM_CHECK_WIDTYPE(obj, widtype);
759 Widget_Data *wd = elm_widget_data_get(obj);
763 if (!edje_object_part_box_insert_at(wd->lay, part, child, pos))
764 WRN("child %p could not be inserted at %u to box part '%s'",
767 elm_widget_sub_object_add(obj, child);
768 evas_object_event_callback_add
769 (child, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, wd);
771 si = ELM_NEW(Subinfo);
772 si->type = BOX_INSERT_AT;
773 si->part = eina_stringshare_add(part);
776 wd->subs = eina_list_append(wd->subs, si);
777 _request_sizing_eval(wd);
781 _sub_box_remove(Widget_Data *wd, Subinfo *si)
785 if (si->type == BOX_INSERT_BEFORE)
786 evas_object_event_callback_del_full
787 ((Evas_Object *)si->p.box.reference,
788 EVAS_CALLBACK_DEL, _box_reference_del, si);
790 child = si->obj; /* si will die in _sub_del due elm_widget_sub_object_del() */
791 edje_object_part_box_remove(wd->lay, si->part, child);
792 elm_widget_sub_object_del(wd->obj, child);
797 _sub_table_remove(Widget_Data *wd, Subinfo *si)
801 child = si->obj; /* si will die in _sub_del due elm_widget_sub_object_del() */
802 edje_object_part_table_unpack(wd->lay, si->part, child);
803 elm_widget_sub_object_del(wd->obj, child);
808 _sub_box_is(const Subinfo *si)
814 case BOX_INSERT_BEFORE:
823 * Remove a child of the given part box.
825 * The object will be removed from the box part and its lifetime will
826 * not be handled by the layout anymore. This is equivalent to
827 * elm_layout_content_unset() for box.
829 * @param obj The layout object
830 * @param part The box part name to remove child.
831 * @param child The object to remove from box.
832 * @return The object that was being used, or NULL if not found.
837 elm_layout_box_remove(Evas_Object *obj, const char *part, Evas_Object *child)
839 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
840 Widget_Data *wd = elm_widget_data_get(obj);
844 if (!wd) return NULL;
846 EINA_SAFETY_ON_NULL_RETURN_VAL(part, NULL);
847 EINA_SAFETY_ON_NULL_RETURN_VAL(child, NULL);
848 EINA_LIST_FOREACH(wd->subs, l, si)
850 if (!_sub_box_is(si)) continue;
851 if ((si->obj == child) && (!strcmp(si->part, part)))
852 return _sub_box_remove(wd, si);
858 * Remove all child of the given part box.
860 * The objects will be removed from the box part and their lifetime will
861 * not be handled by the layout anymore. This is equivalent to
862 * elm_layout_content_unset() for all box children.
864 * @param obj The layout object
865 * @param part The box part name to remove child.
866 * @param clear If EINA_TRUE, then all objects will be deleted as
867 * well, otherwise they will just be removed and will be
868 * dangling on the canvas.
873 elm_layout_box_remove_all(Evas_Object *obj, const char *part, Eina_Bool clear)
875 ELM_CHECK_WIDTYPE(obj, widtype);
876 Widget_Data *wd = elm_widget_data_get(obj);
881 EINA_SAFETY_ON_NULL_RETURN(part);
883 lst = eina_list_clone(wd->subs);
884 EINA_LIST_FREE(lst, si)
886 if (!_sub_box_is(si)) continue;
887 if (!strcmp(si->part, part))
889 Evas_Object *child = _sub_box_remove(wd, si);
890 if ((clear) && (child)) evas_object_del(child);
893 /* eventually something may not be added with layout, del them as well */
894 edje_object_part_box_remove_all(wd->lay, part, clear);
898 * Insert child to layout table part.
900 * Once the object is inserted, its lifetime will be bound to the
901 * layout, whenever the layout dies the child will be deleted
902 * automatically. One should use elm_layout_box_remove() to make this
903 * layout forget about the object.
905 * @param obj the layout object
906 * @param part the box part to pack child.
907 * @param child the child object to pack into table.
908 * @param reference another reference object to insert before in box.
913 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)
915 ELM_CHECK_WIDTYPE(obj, widtype);
916 Widget_Data *wd = elm_widget_data_get(obj);
920 if (!edje_object_part_table_pack
921 (wd->lay, part, child, col, row, colspan, rowspan))
922 WRN("child %p could not be packed into box part '%s' col=%uh, row=%hu, "
923 "colspan=%hu, rowspan=%hu", child, part, col, row, colspan, rowspan);
925 elm_widget_sub_object_add(obj, child);
926 evas_object_event_callback_add
927 (child, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, wd);
929 si = ELM_NEW(Subinfo);
930 si->type = TABLE_PACK;
931 si->part = eina_stringshare_add(part);
933 si->p.table.col = col;
934 si->p.table.row = row;
935 si->p.table.colspan = colspan;
936 si->p.table.rowspan = rowspan;
937 wd->subs = eina_list_append(wd->subs, si);
938 _request_sizing_eval(wd);
942 * Unpack (remove) a child of the given part table.
944 * The object will be unpacked from the table part and its lifetime
945 * will not be handled by the layout anymore. This is equivalent to
946 * elm_layout_content_unset() for table.
948 * @param obj The layout object
949 * @param part The table part name to remove child.
950 * @param child The object to remove from table.
951 * @return The object that was being used, or NULL if not found.
956 elm_layout_table_unpack(Evas_Object *obj, const char *part, Evas_Object *child)
958 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
959 Widget_Data *wd = elm_widget_data_get(obj);
963 if (!wd) return NULL;
965 EINA_SAFETY_ON_NULL_RETURN_VAL(part, NULL);
966 EINA_SAFETY_ON_NULL_RETURN_VAL(child, NULL);
967 EINA_LIST_FOREACH(wd->subs, l, si)
969 if (si->type != TABLE_PACK) continue;
970 if ((si->obj == child) && (!strcmp(si->part, part)))
971 return _sub_table_remove(wd, si);
977 * Remove all child of the given part table.
979 * The objects will be removed from the table part and their lifetime will
980 * not be handled by the layout anymore. This is equivalent to
981 * elm_layout_content_unset() for all table children.
983 * @param obj The layout object
984 * @param part The table part name to remove child.
985 * @param clear If EINA_TRUE, then all objects will be deleted as
986 * well, otherwise they will just be removed and will be
987 * dangling on the canvas.
992 elm_layout_table_clear(Evas_Object *obj, const char *part, Eina_Bool clear)
994 ELM_CHECK_WIDTYPE(obj, widtype);
995 Widget_Data *wd = elm_widget_data_get(obj);
1000 EINA_SAFETY_ON_NULL_RETURN(part);
1002 lst = eina_list_clone(wd->subs);
1003 EINA_LIST_FREE(lst, si)
1005 if (si->type != TABLE_PACK) continue;
1006 if (!strcmp(si->part, part))
1008 Evas_Object *child = _sub_table_remove(wd, si);
1009 if ((clear) && (child)) evas_object_del(child);
1012 /* eventually something may not be added with layout, del them as well */
1013 edje_object_part_table_clear(wd->lay, part, clear);
1017 * Get the edje layout
1019 * @param obj The layout object
1021 * This returns the edje object. It is not expected to be used to then swallow
1022 * objects via edje_object_part_swallow() for example. Use
1023 * elm_layout_content_set() instead so child object handling and sizing is
1024 * done properly. This is more intended for setting text, emitting signals,
1025 * hooking to signal callbacks etc.
1027 * @return A Evas_Object with the edje layout settings loaded
1028 * with function elm_layout_file_set
1033 elm_layout_edje_get(const Evas_Object *obj)
1035 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1036 Widget_Data *wd = elm_widget_data_get(obj);
1037 if (!wd) return NULL;
1042 * Get the edje data of the given layout
1044 * @param obj The layout object
1045 * @param key The data key
1047 * @return The edje data string
1049 * This function fetches data specified at the object level.
1050 * This function return NULL if data is not found.
1052 * In EDC this comes from a data block within the group block that @a
1053 * obj was loaded from. E.g.
1060 * item: "key1" "value1";
1061 * item: "key2" "value2";
1070 elm_layout_data_get(const Evas_Object *obj, const char *key)
1072 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1073 Widget_Data *wd = elm_widget_data_get(obj);
1074 return edje_object_data_get(wd->lay, key);
1080 * Manually forms a sizing re-evaluation when contents changed state so that
1081 * minimum size might have changed and needs re-evaluation. Also note that
1082 * a standard signal of "size,eval" "elm" emitted by the edje object will
1083 * cause this to happen too
1085 * @param obj The layout object
1090 elm_layout_sizing_eval(Evas_Object *obj)
1092 ELM_CHECK_WIDTYPE(obj, widtype);
1093 Widget_Data *wd = elm_widget_data_get(obj);
1094 EINA_SAFETY_ON_NULL_RETURN(wd);
1095 _request_sizing_eval(wd);
1099 * Sets a specific cursor for an edje part.
1101 * @param obj The layout object.
1102 * @param part_name a part from loaded edje group.
1103 * @param cursor cursor name to use, see Elementary_Cursor.h
1105 * @return EINA_TRUE on success or EINA_FALSE on failure, that may be
1106 * part not exists or it has "mouse_events: 0".
1111 elm_layout_part_cursor_set(Evas_Object *obj, const char *part_name, const char *cursor)
1113 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1114 EINA_SAFETY_ON_NULL_RETURN_VAL(part_name, EINA_FALSE);
1115 Widget_Data *wd = elm_widget_data_get(obj);
1116 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EINA_FALSE);
1117 Evas_Object *part_obj;
1120 part_obj = (Evas_Object *)edje_object_part_object_get(wd->lay, part_name);
1123 const char *group, *file;
1124 edje_object_file_get(wd->lay, &file, &group);
1125 WRN("no part '%s' in group '%s' of file '%s'. Cannot set cursor '%s'",
1126 part_name, group, file, cursor);
1129 if (evas_object_pass_events_get(part_obj))
1131 const char *group, *file;
1132 edje_object_file_get(wd->lay, &file, &group);
1133 WRN("part '%s' in group '%s' of file '%s' has mouse_events: 0. "
1134 "Cannot set cursor '%s'",
1135 part_name, group, file, cursor);
1139 pc = _parts_cursors_find(wd, part_name);
1140 if (pc) eina_stringshare_replace(&pc->cursor, cursor);
1143 pc = calloc(1, sizeof(*pc));
1144 pc->part = eina_stringshare_add(part_name);
1145 pc->cursor = eina_stringshare_add(cursor);
1149 elm_object_sub_cursor_set(part_obj, obj, pc->cursor);
1154 * Get the cursor to be shown when mouse is over an edje part
1156 * @param obj The layout object.
1157 * @param part_name a part from loaded edje group.
1158 * @return the cursor name.
1163 elm_layout_part_cursor_get(const Evas_Object *obj, const char *part_name)
1165 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1166 EINA_SAFETY_ON_NULL_RETURN_VAL(part_name, NULL);
1167 Widget_Data *wd = elm_widget_data_get(obj);
1168 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
1169 Part_Cursor *pc = _parts_cursors_find(wd, part_name);
1170 EINA_SAFETY_ON_NULL_RETURN_VAL(pc, NULL);
1171 EINA_SAFETY_ON_NULL_RETURN_VAL(pc->obj, NULL);
1172 return elm_object_cursor_get(pc->obj);
1176 * Unsets a cursor previously set with elm_layout_part_cursor_set().
1178 * @param obj The layout object.
1179 * @param part_name a part from loaded edje group, that had a cursor set
1180 * with elm_layout_part_cursor_set().
1185 elm_layout_part_cursor_unset(Evas_Object *obj, const char *part_name)
1187 ELM_CHECK_WIDTYPE(obj, widtype);
1188 EINA_SAFETY_ON_NULL_RETURN(part_name);
1189 Widget_Data *wd = elm_widget_data_get(obj);
1190 EINA_SAFETY_ON_NULL_RETURN(wd);
1194 EINA_LIST_FOREACH(wd->parts_cursors, l, pc)
1196 if (!strcmp(part_name, pc->part))
1198 if (pc->obj) elm_object_cursor_unset(pc->obj);
1199 _part_cursor_free(pc);
1200 wd->parts_cursors = eina_list_remove_list(wd->parts_cursors, l);
1207 * Sets a specific cursor style for an edje part.
1209 * @param obj The layout object.
1210 * @param part_name a part from loaded edje group.
1211 * @param style the theme style to use (default, transparent, ...)
1213 * @return EINA_TRUE on success or EINA_FALSE on failure, that may be
1214 * part not exists or it did not had a cursor set.
1219 elm_layout_part_cursor_style_set(Evas_Object *obj, const char *part_name, const char *style)
1221 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1222 EINA_SAFETY_ON_NULL_RETURN_VAL(part_name, EINA_FALSE);
1223 Widget_Data *wd = elm_widget_data_get(obj);
1224 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EINA_FALSE);
1225 Part_Cursor *pc = _parts_cursors_find(wd, part_name);
1226 EINA_SAFETY_ON_NULL_RETURN_VAL(pc, EINA_FALSE);
1227 EINA_SAFETY_ON_NULL_RETURN_VAL(pc->obj, EINA_FALSE);
1229 eina_stringshare_replace(&pc->style, style);
1230 elm_object_cursor_style_set(pc->obj, pc->style);
1235 * Gets a specific cursor style for an edje part.
1237 * @param obj The layout object.
1238 * @param part_name a part from loaded edje group.
1240 * @return the theme style in use, defaults to "default". If the
1241 * object does not have a cursor set, then NULL is returned.
1246 elm_layout_part_cursor_style_get(const Evas_Object *obj, const char *part_name)
1248 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1249 EINA_SAFETY_ON_NULL_RETURN_VAL(part_name, NULL);
1250 Widget_Data *wd = elm_widget_data_get(obj);
1251 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
1252 Part_Cursor *pc = _parts_cursors_find(wd, part_name);
1253 EINA_SAFETY_ON_NULL_RETURN_VAL(pc, NULL);
1254 EINA_SAFETY_ON_NULL_RETURN_VAL(pc->obj, NULL);
1255 return elm_object_cursor_style_get(pc->obj);
1259 * Sets if the cursor set should be searched on the theme or should use
1260 * the provided by the engine, only.
1262 * @note before you set if should look on theme you should define a
1263 * cursor with elm_layout_part_cursor_set(). By default it will only
1264 * look for cursors provided by the engine.
1266 * @param obj The layout object.
1267 * @param part_name a part from loaded edje group.
1268 * @param engine_only if cursors should be just provided by the engine
1269 * or should also search on widget's theme as well
1271 * @return EINA_TRUE on success or EINA_FALSE on failure, that may be
1272 * part not exists or it did not had a cursor set.
1277 elm_layout_part_cursor_engine_only_set(Evas_Object *obj, const char *part_name, Eina_Bool engine_only)
1279 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1280 EINA_SAFETY_ON_NULL_RETURN_VAL(part_name, EINA_FALSE);
1281 Widget_Data *wd = elm_widget_data_get(obj);
1282 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EINA_FALSE);
1283 Part_Cursor *pc = _parts_cursors_find(wd, part_name);
1284 EINA_SAFETY_ON_NULL_RETURN_VAL(pc, EINA_FALSE);
1285 EINA_SAFETY_ON_NULL_RETURN_VAL(pc->obj, EINA_FALSE);
1287 pc->engine_only = !!engine_only;
1288 elm_object_cursor_engine_only_set(pc->obj, pc->engine_only);
1293 * Gets a specific cursor engine_only for an edje part.
1295 * @param obj The layout object.
1296 * @param part_name a part from loaded edje group.
1298 * @return whenever the cursor is just provided by engine or also from theme.
1303 elm_layout_part_cursor_engine_only_get(const Evas_Object *obj, const char *part_name)
1305 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1306 EINA_SAFETY_ON_NULL_RETURN_VAL(part_name, EINA_FALSE);
1307 Widget_Data *wd = elm_widget_data_get(obj);
1308 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EINA_FALSE);
1309 Part_Cursor *pc = _parts_cursors_find(wd, part_name);
1310 EINA_SAFETY_ON_NULL_RETURN_VAL(pc, EINA_FALSE);
1311 EINA_SAFETY_ON_NULL_RETURN_VAL(pc->obj, EINA_FALSE);
1312 return elm_object_cursor_engine_only_get(pc->obj);