1 #include <Elementary.h>
5 * @defgroup Layout Layout
7 * This takes a standard Edje design file and wraps it very thinly
8 * in a widget and handles swallowing widgets into swallow regions
9 * in the Edje object, allowing Edje to be used as a design and
13 typedef struct _Widget_Data Widget_Data;
14 typedef struct _Subinfo Subinfo;
15 typedef struct _Part_Cursor Part_Cursor;
22 Eina_List *parts_cursors;
23 Eina_Bool needs_size_calc:1;
41 const Evas_Object *reference;
45 unsigned short col, row, colspan, rowspan;
59 Eina_Bool engine_only:1;
62 static const char *widtype = NULL;
63 static void _del_hook(Evas_Object *obj);
64 static void _mirrored_set(Evas_Object *obj, Eina_Bool rtl);
65 static void _theme_hook(Evas_Object *obj);
66 static void _sizing_eval(Widget_Data *wd);
67 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
68 static void _sub_del(void *data, Evas_Object *obj, void *event_info);
69 static void _part_cursor_free(Part_Cursor *pc);
72 _del_hook(Evas_Object *obj)
74 Widget_Data *wd = elm_widget_data_get(obj);
79 EINA_LIST_FREE(wd->subs, si)
81 eina_stringshare_del(si->part);
83 eina_stringshare_del(si->p.text.text);
86 EINA_LIST_FREE(wd->parts_cursors, pc) _part_cursor_free(pc);
91 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
93 Widget_Data *wd = elm_widget_data_get(obj);
95 edje_object_mirrored_set(wd->lay, rtl);
99 _theme_hook(Evas_Object *obj)
101 Widget_Data *wd = elm_widget_data_get(obj);
103 _elm_widget_mirrored_reload(obj);
104 _mirrored_set(obj, elm_widget_mirrored_get(obj));
105 edje_object_scale_set(wd->lay, elm_widget_scale_get(obj) *
111 _changed_hook(Evas_Object *obj)
113 Widget_Data *wd = elm_widget_data_get(obj);
115 if (wd->needs_size_calc)
118 wd->needs_size_calc = 0;
123 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
125 Widget_Data *wd = elm_widget_data_get(obj);
126 edje_object_signal_emit(wd->lay, emission, source);
130 _signal_callback_add_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
132 Widget_Data *wd = elm_widget_data_get(obj);
133 edje_object_signal_callback_add(wd->lay, emission, source, func_cb, data);
137 _signal_callback_del_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
139 Widget_Data *wd = elm_widget_data_get(obj);
140 edje_object_signal_callback_del_full(wd->lay, emission, source, func_cb,
146 _elm_layout_list_data_get(const Eina_List *list)
148 Subinfo *si = eina_list_data_get(list);
153 _elm_layout_focus_next_hook(const Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next)
155 Widget_Data *wd = elm_widget_data_get(obj);
156 const Eina_List *items;
157 void *(*list_data_get) (const Eina_List *list);
159 if ((!wd) || (!wd->subs))
162 /* Focus chain (This block is diferent of elm_win cycle)*/
163 if ((items = elm_widget_focus_custom_chain_get(obj)))
164 list_data_get = eina_list_data_get;
168 list_data_get = _elm_layout_list_data_get;
170 if (!items) return EINA_FALSE;
173 return elm_widget_focus_list_next_get(obj, items, list_data_get, dir,
178 _sizing_eval(Widget_Data *wd)
180 Evas_Coord minw = -1, minh = -1;
181 edje_object_size_min_calc(wd->lay, &minw, &minh);
182 evas_object_size_hint_min_set(wd->obj, minw, minh);
183 evas_object_size_hint_max_set(wd->obj, -1, -1);
187 _request_sizing_eval(Widget_Data *wd)
189 if (wd->needs_size_calc) return;
190 wd->needs_size_calc = 1;
191 evas_object_smart_changed(wd->obj);
195 _part_cursor_free(Part_Cursor *pc)
197 eina_stringshare_del(pc->part);
198 eina_stringshare_del(pc->style);
199 eina_stringshare_del(pc->cursor);
204 _part_cursor_part_apply(const Part_Cursor *pc)
206 elm_object_cursor_set(pc->obj, pc->cursor);
207 elm_object_cursor_style_set(pc->obj, pc->style);
208 elm_object_cursor_engine_only_set(pc->obj, pc->engine_only);
212 _parts_cursors_find(Widget_Data *wd, const char *part)
216 EINA_LIST_FOREACH(wd->parts_cursors, l, pc)
218 if (!strcmp(pc->part, part))
225 _parts_cursors_apply(Widget_Data *wd)
227 const char *file, *group;
231 edje_object_file_get(wd->lay, &file, &group);
233 EINA_LIST_FOREACH(wd->parts_cursors, l, pc)
235 Evas_Object *obj = (Evas_Object *)edje_object_part_object_get
241 WRN("no part '%s' in group '%s' of file '%s'. "
242 "Cannot set cursor '%s'",
243 pc->part, group, file, pc->cursor);
246 else if (evas_object_pass_events_get(obj))
249 WRN("part '%s' in group '%s' of file '%s' has mouse_events: 0. "
250 "Cannot set cursor '%s'",
251 pc->part, group, file, pc->cursor);
256 _part_cursor_part_apply(pc);
261 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
263 _request_sizing_eval(data);
267 _sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info)
269 Widget_Data *wd = elm_widget_data_get(obj);
270 Evas_Object *sub = event_info;
274 EINA_LIST_FOREACH(wd->subs, l, si)
278 evas_object_event_callback_del_full(sub,
279 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
282 wd->subs = eina_list_remove_list(wd->subs, l);
283 eina_stringshare_del(si->part);
291 _signal_size_eval(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
293 _request_sizing_eval(data);
297 _parts_text_fix(Widget_Data *wd)
302 EINA_LIST_FOREACH(wd->subs, l, si)
304 if (si->type == TEXT)
305 edje_object_part_text_set(wd->lay, si->part, si->p.text.text);
310 _elm_layout_label_set(Evas_Object *obj, const char *part, const char *text)
312 Widget_Data *wd = elm_widget_data_get(obj);
315 ELM_CHECK_WIDTYPE(obj, widtype);
316 if (!part) part = "elm.text";
318 EINA_LIST_FOREACH(wd->subs, l, si)
320 if ((si->type == TEXT) && (!strcmp(part, si->part)))
324 eina_stringshare_del(si->part);
325 eina_stringshare_del(si->p.text.text);
327 edje_object_part_text_set(wd->lay, part, NULL);
328 wd->subs = eina_list_remove_list(wd->subs, l);
339 si = ELM_NEW(Subinfo);
342 si->part = eina_stringshare_add(part);
343 wd->subs = eina_list_append(wd->subs, si);
346 eina_stringshare_replace(&si->p.text.text, text);
347 edje_object_part_text_set(wd->lay, part, text);
348 _request_sizing_eval(wd);
352 _elm_layout_label_get(const Evas_Object *obj, const char *part)
354 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
355 Widget_Data *wd = elm_widget_data_get(obj);
356 if (!part) part = "elm.text";
357 return edje_object_part_text_get(wd->lay, part);
361 * Add a new layout to the parent
363 * @param parent The parent object
364 * @return The new object or NULL if it cannot be created
369 elm_layout_add(Evas_Object *parent)
375 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
377 ELM_SET_WIDTYPE(widtype, "layout");
378 elm_widget_type_set(obj, "layout");
379 elm_widget_sub_object_add(parent, obj);
380 elm_widget_data_set(obj, wd);
381 elm_widget_del_hook_set(obj, _del_hook);
382 elm_widget_theme_hook_set(obj, _theme_hook);
383 elm_widget_changed_hook_set(obj, _changed_hook);
384 elm_widget_can_focus_set(obj, EINA_FALSE);
385 elm_widget_focus_next_hook_set(obj, _elm_layout_focus_next_hook);
386 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
387 elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
388 elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
389 elm_widget_label_set_hook_set(obj, _elm_layout_label_set);
390 elm_widget_label_get_hook_set(obj, _elm_layout_label_get);
393 wd->lay = edje_object_add(e);
394 elm_widget_resize_object_set(obj, wd->lay);
395 edje_object_signal_callback_add(wd->lay, "size,eval", "elm",
396 _signal_size_eval, wd);
398 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
400 _mirrored_set(obj, elm_widget_mirrored_get(obj));
401 _request_sizing_eval(wd);
406 * Set the file that will be used as layout
408 * @param obj The layout object
409 * @param file The path to file (edj) that will be used as layout
410 * @param group The group that the layout belongs in edje file
412 * @return (1 = success, 0 = error)
417 elm_layout_file_set(Evas_Object *obj, const char *file, const char *group)
419 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
420 Widget_Data *wd = elm_widget_data_get(obj);
421 if (!wd) return EINA_FALSE;
422 Eina_Bool ret = edje_object_file_set(wd->lay, file, group);
426 _request_sizing_eval(wd);
427 _parts_cursors_apply(wd);
429 else DBG("failed to set edje file '%s', group '%s': %s",
431 edje_load_error_str(edje_object_load_error_get(wd->lay)));
436 * Set the edje group from the elementary theme that will be used as layout
438 * @param obj The layout object
439 * @param clas the clas of the group
440 * @param group the group
441 * @param style the style to used
443 * @return (1 = success, 0 = error)
448 elm_layout_theme_set(Evas_Object *obj, const char *clas, const char *group, const char *style)
450 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
451 Widget_Data *wd = elm_widget_data_get(obj);
452 if (!wd) return EINA_FALSE;
453 Eina_Bool ret = _elm_theme_object_set(obj, wd->lay, clas, group, style);
457 _request_sizing_eval(wd);
458 _parts_cursors_apply(wd);
464 * Set the layout content
466 * Once the content object is set, a previously set one will be deleted.
467 * If you want to keep that old content object, use the
468 * elm_layout_content_unset() function.
470 * @param obj The layout object
471 * @param swallow The swallow group name in the edje file
472 * @param content The content will be filled in this layout object
477 elm_layout_content_set(Evas_Object *obj, const char *swallow, Evas_Object *content)
479 ELM_CHECK_WIDTYPE(obj, widtype);
480 Widget_Data *wd = elm_widget_data_get(obj);
484 EINA_LIST_FOREACH(wd->subs, l, si)
486 if ((si->type == SWALLOW) && (!strcmp(swallow, si->part)))
488 if (content == si->obj) return;
489 evas_object_del(si->obj);
495 elm_widget_sub_object_add(obj, content);
496 evas_object_event_callback_add(content,
497 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
498 _changed_size_hints, wd);
499 if (!edje_object_part_swallow(wd->lay, swallow, content))
500 WRN("could not swallow %p into part '%s'", content, swallow);
501 si = ELM_NEW(Subinfo);
503 si->part = eina_stringshare_add(swallow);
505 wd->subs = eina_list_append(wd->subs, si);
507 _request_sizing_eval(wd);
511 * Get the swallowed object in the given part
513 * @param obj The layout object
514 * @param swallow The SWALLOW part to get its content
516 * @return The swallowed object or NULL if none or an error occurred
521 elm_layout_content_get(const Evas_Object *obj, const char *swallow)
523 Widget_Data *wd = elm_widget_data_get(obj);
526 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
528 EINA_LIST_FOREACH(wd->subs, l, si)
530 if ((si->type == SWALLOW) && !strcmp(swallow, si->part))
537 * Unset the layout content
539 * Unparent and return the content object which was set for this widget
541 * @param obj The layout object
542 * @param swallow The swallow group name in the edje file
543 * @return The content that was being used
548 elm_layout_content_unset(Evas_Object *obj, const char *swallow)
550 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
551 Widget_Data *wd = elm_widget_data_get(obj);
554 if (!wd) return NULL;
555 EINA_LIST_FOREACH(wd->subs, l, si)
557 if ((si->type == SWALLOW) && (!strcmp(swallow, si->part)))
559 Evas_Object *content;
560 if (!si->obj) return NULL;
561 content = si->obj; /* si will die in _sub_del due elm_widget_sub_object_del() */
562 elm_widget_sub_object_del(obj, content);
563 edje_object_part_unswallow(wd->lay, content);
571 * Set the text of the given part
573 * @param obj The layout object
574 * @param part The TEXT part where to set the text
575 * @param text The text to set
578 * @deprecate use elm_object_text_* instead.
581 elm_layout_text_set(Evas_Object *obj, const char *part, const char *text)
583 _elm_layout_label_set(obj, part, text);
587 * Get the text set in the given part
589 * @param obj The layout object
590 * @param part The TEXT part to retrieve the text off
592 * @return The text set in @p part
595 * @deprecate use elm_object_text_* instead.
598 elm_layout_text_get(const Evas_Object *obj, const char *part)
600 return _elm_layout_label_get(obj, part);
604 * Append child to layout box part.
606 * Once the object is appended, its lifetime will be bound to the
607 * layout, whenever the layout dies the child will be deleted
608 * automatically. One should use elm_layout_box_remove() to make this
609 * layout forget about the object.
611 * @param obj the layout object
612 * @param part the box part to append.
613 * @param child the child object to append to box.
618 elm_layout_box_append(Evas_Object *obj, const char *part, Evas_Object *child)
620 ELM_CHECK_WIDTYPE(obj, widtype);
621 Widget_Data *wd = elm_widget_data_get(obj);
625 if (!edje_object_part_box_append(wd->lay, part, child))
626 WRN("child %p could not be appended to box part '%s'", child, part);
627 elm_widget_sub_object_add(obj, child);
628 evas_object_event_callback_add
629 (child, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, wd);
631 si = ELM_NEW(Subinfo);
632 si->type = BOX_APPEND;
633 si->part = eina_stringshare_add(part);
635 wd->subs = eina_list_append(wd->subs, si);
636 _request_sizing_eval(wd);
640 * Prepend child to layout box part.
642 * Once the object is prepended, its lifetime will be bound to the
643 * layout, whenever the layout dies the child will be deleted
644 * automatically. One should use elm_layout_box_remove() to make this
645 * layout forget about the object.
647 * @param obj the layout object
648 * @param part the box part to prepend.
649 * @param child the child object to prepend to box.
654 elm_layout_box_prepend(Evas_Object *obj, const char *part, Evas_Object *child)
656 ELM_CHECK_WIDTYPE(obj, widtype);
657 Widget_Data *wd = elm_widget_data_get(obj);
661 if (!edje_object_part_box_prepend(wd->lay, part, child))
662 WRN("child %p could not be prepended to box part '%s'", child, part);
663 elm_widget_sub_object_add(obj, child);
664 evas_object_event_callback_add
665 (child, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, wd);
667 si = ELM_NEW(Subinfo);
668 si->type = BOX_PREPEND;
669 si->part = eina_stringshare_add(part);
671 wd->subs = eina_list_prepend(wd->subs, si);
672 _request_sizing_eval(wd);
676 _box_reference_del(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
679 si->p.box.reference = NULL;
683 * Insert child to layout box part before a reference object.
685 * Once the object is inserted, its lifetime will be bound to the
686 * layout, whenever the layout dies the child will be deleted
687 * automatically. One should use elm_layout_box_remove() to make this
688 * layout forget about the object.
690 * @param obj the layout object
691 * @param part the box part to insert.
692 * @param child the child object to insert into box.
693 * @param reference another reference object to insert before in box.
698 elm_layout_box_insert_before(Evas_Object *obj, const char *part, Evas_Object *child, const Evas_Object *reference)
700 ELM_CHECK_WIDTYPE(obj, widtype);
701 Widget_Data *wd = elm_widget_data_get(obj);
705 if (!edje_object_part_box_insert_before(wd->lay, part, child, reference))
706 WRN("child %p could not be inserted before %p inf box part '%s'",
707 child, reference, part);
709 si = ELM_NEW(Subinfo);
710 si->type = BOX_INSERT_BEFORE;
711 si->part = eina_stringshare_add(part);
713 si->p.box.reference = reference;
715 elm_widget_sub_object_add(obj, child);
716 evas_object_event_callback_add
717 (child, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, wd);
718 evas_object_event_callback_add
719 ((Evas_Object *)reference, EVAS_CALLBACK_DEL, _box_reference_del, si);
721 wd->subs = eina_list_append(wd->subs, si);
722 _request_sizing_eval(wd);
726 * Insert child to layout box part at a given position.
728 * Once the object is inserted, its lifetime will be bound to the
729 * layout, whenever the layout dies the child will be deleted
730 * automatically. One should use elm_layout_box_remove() to make this
731 * layout forget about the object.
733 * @param obj the layout object
734 * @param part the box part to insert.
735 * @param child the child object to insert into box.
736 * @param pos the numeric position >=0 to insert the child.
741 elm_layout_box_insert_at(Evas_Object *obj, const char *part, Evas_Object *child, unsigned int pos)
743 ELM_CHECK_WIDTYPE(obj, widtype);
744 Widget_Data *wd = elm_widget_data_get(obj);
748 if (!edje_object_part_box_insert_at(wd->lay, part, child, pos))
749 WRN("child %p could not be inserted at %u to box part '%s'",
752 elm_widget_sub_object_add(obj, child);
753 evas_object_event_callback_add
754 (child, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, wd);
756 si = ELM_NEW(Subinfo);
757 si->type = BOX_INSERT_AT;
758 si->part = eina_stringshare_add(part);
761 wd->subs = eina_list_append(wd->subs, si);
762 _request_sizing_eval(wd);
766 _sub_box_remove(Widget_Data *wd, Subinfo *si)
770 if (si->type == BOX_INSERT_BEFORE)
771 evas_object_event_callback_del_full
772 ((Evas_Object *)si->p.box.reference,
773 EVAS_CALLBACK_DEL, _box_reference_del, si);
775 child = si->obj; /* si will die in _sub_del due elm_widget_sub_object_del() */
776 edje_object_part_box_remove(wd->lay, si->part, child);
777 elm_widget_sub_object_del(wd->obj, child);
782 _sub_table_remove(Widget_Data *wd, Subinfo *si)
786 child = si->obj; /* si will die in _sub_del due elm_widget_sub_object_del() */
787 edje_object_part_table_unpack(wd->lay, si->part, child);
788 elm_widget_sub_object_del(wd->obj, child);
793 _sub_box_is(const Subinfo *si)
799 case BOX_INSERT_BEFORE:
808 * Remove a child of the given part box.
810 * The object will be removed from the box part and its lifetime will
811 * not be handled by the layout anymore. This is equivalent to
812 * elm_layout_content_unset() for box.
814 * @param obj The layout object
815 * @param part The box part name to remove child.
816 * @param child The object to remove from box.
817 * @return The object that was being used, or NULL if not found.
822 elm_layout_box_remove(Evas_Object *obj, const char *part, Evas_Object *child)
824 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
825 Widget_Data *wd = elm_widget_data_get(obj);
829 if (!wd) return NULL;
831 EINA_SAFETY_ON_NULL_RETURN_VAL(part, NULL);
832 EINA_SAFETY_ON_NULL_RETURN_VAL(child, NULL);
833 EINA_LIST_FOREACH(wd->subs, l, si)
835 if (!_sub_box_is(si)) continue;
836 if ((si->obj == child) && (!strcmp(si->part, part)))
837 return _sub_box_remove(wd, si);
843 * Remove all child of the given part box.
845 * The objects will be removed from the box part and their lifetime will
846 * not be handled by the layout anymore. This is equivalent to
847 * elm_layout_content_unset() for all box children.
849 * @param obj The layout object
850 * @param part The box part name to remove child.
851 * @param clear If EINA_TRUE, then all objects will be deleted as
852 * well, otherwise they will just be removed and will be
853 * dangling on the canvas.
858 elm_layout_box_remove_all(Evas_Object *obj, const char *part, Eina_Bool clear)
860 ELM_CHECK_WIDTYPE(obj, widtype);
861 Widget_Data *wd = elm_widget_data_get(obj);
866 EINA_SAFETY_ON_NULL_RETURN(part);
868 lst = eina_list_clone(wd->subs);
869 EINA_LIST_FREE(lst, si)
871 if (!_sub_box_is(si)) continue;
872 if (!strcmp(si->part, part))
874 Evas_Object *child = _sub_box_remove(wd, si);
875 if ((clear) && (child)) evas_object_del(child);
878 /* eventually something may not be added with layout, del them as well */
879 edje_object_part_box_remove_all(wd->lay, part, clear);
883 * Insert child to layout table part.
885 * Once the object is inserted, its lifetime will be bound to the
886 * layout, whenever the layout dies the child will be deleted
887 * automatically. One should use elm_layout_box_remove() to make this
888 * layout forget about the object.
890 * @param obj the layout object
891 * @param part the box part to pack child.
892 * @param child the child object to pack into table.
893 * @param reference another reference object to insert before in box.
898 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)
900 ELM_CHECK_WIDTYPE(obj, widtype);
901 Widget_Data *wd = elm_widget_data_get(obj);
905 if (!edje_object_part_table_pack
906 (wd->lay, part, child, col, row, colspan, rowspan))
907 WRN("child %p could not be packed into box part '%s' col=%uh, row=%hu, "
908 "colspan=%hu, rowspan=%hu", child, part, col, row, colspan, rowspan);
910 elm_widget_sub_object_add(obj, child);
911 evas_object_event_callback_add
912 (child, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, wd);
914 si = ELM_NEW(Subinfo);
915 si->type = TABLE_PACK;
916 si->part = eina_stringshare_add(part);
918 si->p.table.col = col;
919 si->p.table.row = row;
920 si->p.table.colspan = colspan;
921 si->p.table.rowspan = rowspan;
922 wd->subs = eina_list_append(wd->subs, si);
923 _request_sizing_eval(wd);
927 * Unpack (remove) a child of the given part table.
929 * The object will be unpacked from the table part and its lifetime
930 * will not be handled by the layout anymore. This is equivalent to
931 * elm_layout_content_unset() for table.
933 * @param obj The layout object
934 * @param part The table part name to remove child.
935 * @param child The object to remove from table.
936 * @return The object that was being used, or NULL if not found.
941 elm_layout_table_unpack(Evas_Object *obj, const char *part, Evas_Object *child)
943 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
944 Widget_Data *wd = elm_widget_data_get(obj);
948 if (!wd) return NULL;
950 EINA_SAFETY_ON_NULL_RETURN_VAL(part, NULL);
951 EINA_SAFETY_ON_NULL_RETURN_VAL(child, NULL);
952 EINA_LIST_FOREACH(wd->subs, l, si)
954 if (si->type != TABLE_PACK) continue;
955 if ((si->obj == child) && (!strcmp(si->part, part)))
956 return _sub_table_remove(wd, si);
962 * Remove all child of the given part table.
964 * The objects will be removed from the table part and their lifetime will
965 * not be handled by the layout anymore. This is equivalent to
966 * elm_layout_content_unset() for all table children.
968 * @param obj The layout object
969 * @param part The table part name to remove child.
970 * @param clear If EINA_TRUE, then all objects will be deleted as
971 * well, otherwise they will just be removed and will be
972 * dangling on the canvas.
977 elm_layout_table_clear(Evas_Object *obj, const char *part, Eina_Bool clear)
979 ELM_CHECK_WIDTYPE(obj, widtype);
980 Widget_Data *wd = elm_widget_data_get(obj);
985 EINA_SAFETY_ON_NULL_RETURN(part);
987 lst = eina_list_clone(wd->subs);
988 EINA_LIST_FREE(lst, si)
990 if (si->type != TABLE_PACK) continue;
991 if (!strcmp(si->part, part))
993 Evas_Object *child = _sub_table_remove(wd, si);
994 if ((clear) && (child)) evas_object_del(child);
997 /* eventually something may not be added with layout, del them as well */
998 edje_object_part_table_clear(wd->lay, part, clear);
1002 * Get the edje layout
1004 * @param obj The layout object
1006 * This returns the edje object. It is not expected to be used to then swallow
1007 * objects via edje_object_part_swallow() for example. Use
1008 * elm_layout_content_set() instead so child object handling and sizing is
1009 * done properly. This is more intended for setting text, emitting signals,
1010 * hooking to signal callbacks etc.
1012 * @return A Evas_Object with the edje layout settings loaded
1013 * with function elm_layout_file_set
1018 elm_layout_edje_get(const Evas_Object *obj)
1020 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1021 Widget_Data *wd = elm_widget_data_get(obj);
1022 if (!wd) return NULL;
1027 * Get the edje data of the given layout
1029 * @param obj The layout object
1030 * @param key The data key
1032 * @return The edje data string
1034 * This function fetches data specified at the object level.
1035 * This function return NULL if data is not found.
1037 * In EDC this comes from a data block within the group block that @a
1038 * obj was loaded from. E.g.
1045 * item: "key1" "value1";
1046 * item: "key2" "value2";
1055 elm_layout_data_get(const Evas_Object *obj, const char *key)
1057 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1058 Widget_Data *wd = elm_widget_data_get(obj);
1059 return edje_object_data_get(wd->lay, key);
1065 * Manually forms a sizing re-evaluation when contents changed state so that
1066 * minimum size might have changed and needs re-evaluation. Also note that
1067 * a standard signal of "size,eval" "elm" emitted by the edje object will
1068 * cause this to happen too
1070 * @param obj The layout object
1075 elm_layout_sizing_eval(Evas_Object *obj)
1077 ELM_CHECK_WIDTYPE(obj, widtype);
1078 Widget_Data *wd = elm_widget_data_get(obj);
1079 EINA_SAFETY_ON_NULL_RETURN(wd);
1080 _request_sizing_eval(wd);
1084 * Sets a specific cursor for an edje part.
1086 * @param obj The layout object.
1087 * @param part_name a part from loaded edje group.
1088 * @param cursor cursor name to use, see Elementary_Cursor.h
1090 * @return EINA_TRUE on success or EINA_FALSE on failure, that may be
1091 * part not exists or it has "mouse_events: 0".
1096 elm_layout_part_cursor_set(Evas_Object *obj, const char *part_name, const char *cursor)
1098 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1099 EINA_SAFETY_ON_NULL_RETURN_VAL(part_name, EINA_FALSE);
1100 Widget_Data *wd = elm_widget_data_get(obj);
1101 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EINA_FALSE);
1102 Evas_Object *part_obj;
1105 part_obj = (Evas_Object *)edje_object_part_object_get(wd->lay, part_name);
1108 const char *group, *file;
1109 edje_object_file_get(wd->lay, &file, &group);
1110 WRN("no part '%s' in group '%s' of file '%s'. Cannot set cursor '%s'",
1111 part_name, group, file, cursor);
1114 if (evas_object_pass_events_get(part_obj))
1116 const char *group, *file;
1117 edje_object_file_get(wd->lay, &file, &group);
1118 WRN("part '%s' in group '%s' of file '%s' has mouse_events: 0. "
1119 "Cannot set cursor '%s'",
1120 part_name, group, file, cursor);
1124 pc = _parts_cursors_find(wd, part_name);
1125 if (pc) eina_stringshare_replace(&pc->cursor, cursor);
1128 pc = calloc(1, sizeof(*pc));
1129 pc->part = eina_stringshare_add(part_name);
1130 pc->cursor = eina_stringshare_add(cursor);
1134 elm_object_sub_cursor_set(part_obj, obj, pc->cursor);
1139 * Get the cursor to be shown when mouse is over an edje part
1141 * @param obj The layout object.
1142 * @param part_name a part from loaded edje group.
1143 * @return the cursor name.
1148 elm_layout_part_cursor_get(const Evas_Object *obj, const char *part_name)
1150 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1151 EINA_SAFETY_ON_NULL_RETURN_VAL(part_name, NULL);
1152 Widget_Data *wd = elm_widget_data_get(obj);
1153 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
1154 Part_Cursor *pc = _parts_cursors_find(wd, part_name);
1155 EINA_SAFETY_ON_NULL_RETURN_VAL(pc, NULL);
1156 EINA_SAFETY_ON_NULL_RETURN_VAL(pc->obj, NULL);
1157 return elm_object_cursor_get(pc->obj);
1161 * Unsets a cursor previously set with elm_layout_part_cursor_set().
1163 * @param obj The layout object.
1164 * @param part_name a part from loaded edje group, that had a cursor set
1165 * with elm_layout_part_cursor_set().
1170 elm_layout_part_cursor_unset(Evas_Object *obj, const char *part_name)
1172 ELM_CHECK_WIDTYPE(obj, widtype);
1173 EINA_SAFETY_ON_NULL_RETURN(part_name);
1174 Widget_Data *wd = elm_widget_data_get(obj);
1175 EINA_SAFETY_ON_NULL_RETURN(wd);
1179 EINA_LIST_FOREACH(wd->parts_cursors, l, pc)
1181 if (!strcmp(part_name, pc->part))
1183 if (pc->obj) elm_object_cursor_unset(pc->obj);
1184 _part_cursor_free(pc);
1185 wd->parts_cursors = eina_list_remove_list(wd->parts_cursors, l);
1192 * Sets a specific cursor style for an edje part.
1194 * @param obj The layout object.
1195 * @param part_name a part from loaded edje group.
1196 * @param style the theme style to use (default, transparent, ...)
1198 * @return EINA_TRUE on success or EINA_FALSE on failure, that may be
1199 * part not exists or it did not had a cursor set.
1204 elm_layout_part_cursor_style_set(Evas_Object *obj, const char *part_name, const char *style)
1206 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1207 EINA_SAFETY_ON_NULL_RETURN_VAL(part_name, EINA_FALSE);
1208 Widget_Data *wd = elm_widget_data_get(obj);
1209 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EINA_FALSE);
1210 Part_Cursor *pc = _parts_cursors_find(wd, part_name);
1211 EINA_SAFETY_ON_NULL_RETURN_VAL(pc, EINA_FALSE);
1212 EINA_SAFETY_ON_NULL_RETURN_VAL(pc->obj, EINA_FALSE);
1214 eina_stringshare_replace(&pc->style, style);
1215 elm_object_cursor_style_set(pc->obj, pc->style);
1220 * Gets a specific cursor style for an edje part.
1222 * @param obj The layout object.
1223 * @param part_name a part from loaded edje group.
1225 * @return the theme style in use, defaults to "default". If the
1226 * object does not have a cursor set, then NULL is returned.
1231 elm_layout_part_cursor_style_get(const Evas_Object *obj, const char *part_name)
1233 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1234 EINA_SAFETY_ON_NULL_RETURN_VAL(part_name, NULL);
1235 Widget_Data *wd = elm_widget_data_get(obj);
1236 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
1237 Part_Cursor *pc = _parts_cursors_find(wd, part_name);
1238 EINA_SAFETY_ON_NULL_RETURN_VAL(pc, NULL);
1239 EINA_SAFETY_ON_NULL_RETURN_VAL(pc->obj, NULL);
1240 return elm_object_cursor_style_get(pc->obj);
1244 * Sets if the cursor set should be searched on the theme or should use
1245 * the provided by the engine, only.
1247 * @note before you set if should look on theme you should define a
1248 * cursor with elm_layout_part_cursor_set(). By default it will only
1249 * look for cursors provided by the engine.
1251 * @param obj The layout object.
1252 * @param part_name a part from loaded edje group.
1253 * @param engine_only if cursors should be just provided by the engine
1254 * or should also search on widget's theme as well
1256 * @return EINA_TRUE on success or EINA_FALSE on failure, that may be
1257 * part not exists or it did not had a cursor set.
1262 elm_layout_part_cursor_engine_only_set(Evas_Object *obj, const char *part_name, Eina_Bool engine_only)
1264 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1265 EINA_SAFETY_ON_NULL_RETURN_VAL(part_name, EINA_FALSE);
1266 Widget_Data *wd = elm_widget_data_get(obj);
1267 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EINA_FALSE);
1268 Part_Cursor *pc = _parts_cursors_find(wd, part_name);
1269 EINA_SAFETY_ON_NULL_RETURN_VAL(pc, EINA_FALSE);
1270 EINA_SAFETY_ON_NULL_RETURN_VAL(pc->obj, EINA_FALSE);
1272 pc->engine_only = !!engine_only;
1273 elm_object_cursor_engine_only_set(pc->obj, pc->engine_only);
1278 * Gets a specific cursor engine_only for an edje part.
1280 * @param obj The layout object.
1281 * @param part_name a part from loaded edje group.
1283 * @return whenever the cursor is just provided by engine or also from theme.
1288 elm_layout_part_cursor_engine_only_get(const Evas_Object *obj, const char *part_name)
1290 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1291 EINA_SAFETY_ON_NULL_RETURN_VAL(part_name, EINA_FALSE);
1292 Widget_Data *wd = elm_widget_data_get(obj);
1293 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EINA_FALSE);
1294 Part_Cursor *pc = _parts_cursors_find(wd, part_name);
1295 EINA_SAFETY_ON_NULL_RETURN_VAL(pc, EINA_FALSE);
1296 EINA_SAFETY_ON_NULL_RETURN_VAL(pc->obj, EINA_FALSE);
1297 return elm_object_cursor_engine_only_get(pc->obj);