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 * Add a new layout to the parent
315 * @param parent The parent object
316 * @return The new object or NULL if it cannot be created
321 elm_layout_add(Evas_Object *parent)
327 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
329 ELM_SET_WIDTYPE(widtype, "layout");
330 elm_widget_type_set(obj, "layout");
331 elm_widget_sub_object_add(parent, obj);
332 elm_widget_data_set(obj, wd);
333 elm_widget_del_hook_set(obj, _del_hook);
334 elm_widget_theme_hook_set(obj, _theme_hook);
335 elm_widget_changed_hook_set(obj, _changed_hook);
336 elm_widget_can_focus_set(obj, EINA_FALSE);
337 elm_widget_focus_next_hook_set(obj, _elm_layout_focus_next_hook);
338 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
339 elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
340 elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
343 wd->lay = edje_object_add(e);
344 elm_widget_resize_object_set(obj, wd->lay);
345 edje_object_signal_callback_add(wd->lay, "size,eval", "elm",
346 _signal_size_eval, wd);
348 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
350 _mirrored_set(obj, elm_widget_mirrored_get(obj));
351 _request_sizing_eval(wd);
356 * Set the file that will be used as layout
358 * @param obj The layout object
359 * @param file The path to file (edj) that will be used as layout
360 * @param group The group that the layout belongs in edje file
362 * @return (1 = success, 0 = error)
367 elm_layout_file_set(Evas_Object *obj, const char *file, const char *group)
369 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
370 Widget_Data *wd = elm_widget_data_get(obj);
371 if (!wd) return EINA_FALSE;
372 Eina_Bool ret = edje_object_file_set(wd->lay, file, group);
376 _request_sizing_eval(wd);
377 _parts_cursors_apply(wd);
379 else DBG("failed to set edje file '%s', group '%s': %s",
381 edje_load_error_str(edje_object_load_error_get(wd->lay)));
386 * Set the edje group from the elementary theme that will be used as layout
388 * @param obj The layout object
389 * @param clas the clas of the group
390 * @param group the group
391 * @param style the style to used
393 * @return (1 = success, 0 = error)
398 elm_layout_theme_set(Evas_Object *obj, const char *clas, const char *group, const char *style)
400 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
401 Widget_Data *wd = elm_widget_data_get(obj);
402 if (!wd) return EINA_FALSE;
403 Eina_Bool ret = _elm_theme_object_set(obj, wd->lay, clas, group, style);
410 _request_sizing_eval(wd);
411 _parts_cursors_apply(wd);
417 * Set the layout content
419 * Once the content object is set, a previously set one will be deleted.
420 * If you want to keep that old content object, use the
421 * elm_layout_content_unset() function.
423 * @param obj The layout object
424 * @param swallow The swallow group name in the edje file
425 * @param content The content will be filled in this layout object
430 elm_layout_content_set(Evas_Object *obj, const char *swallow, Evas_Object *content)
432 ELM_CHECK_WIDTYPE(obj, widtype);
433 Widget_Data *wd = elm_widget_data_get(obj);
437 EINA_LIST_FOREACH(wd->subs, l, si)
439 if ((si->type == SWALLOW) && (!strcmp(swallow, si->part)))
441 if (content == si->obj) return;
442 evas_object_del(si->obj);
448 elm_widget_sub_object_add(obj, content);
449 evas_object_event_callback_add(content,
450 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
451 _changed_size_hints, wd);
452 if (!edje_object_part_swallow(wd->lay, swallow, content))
453 WRN("could not swallow %p into part '%s'", content, swallow);
454 si = ELM_NEW(Subinfo);
456 si->part = eina_stringshare_add(swallow);
458 wd->subs = eina_list_append(wd->subs, si);
460 _request_sizing_eval(wd);
464 * Get the swallowed object in the given part
466 * @param obj The layout object
467 * @param swallow The SWALLOW part to get its content
469 * @return The swallowed object or NULL if none or an error occurred
473 EAPI const Evas_Object *
474 elm_layout_content_get(const Evas_Object *obj, const char *swallow)
476 Widget_Data *wd = elm_widget_data_get(obj);
479 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
481 EINA_LIST_FOREACH(wd->subs, l, si)
483 if ((si->type == SWALLOW) && !strcmp(swallow, si->part))
490 * Unset the layout content
492 * Unparent and return the content object which was set for this widget
494 * @param obj The layout object
495 * @param swallow The swallow group name in the edje file
496 * @return The content that was being used
501 elm_layout_content_unset(Evas_Object *obj, const char *swallow)
503 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
504 Widget_Data *wd = elm_widget_data_get(obj);
507 if (!wd) return NULL;
508 EINA_LIST_FOREACH(wd->subs, l, si)
510 if ((si->type == SWALLOW) && (!strcmp(swallow, si->part)))
512 Evas_Object *content;
513 if (!si->obj) return NULL;
514 content = si->obj; /* si will die in _sub_del due elm_widget_sub_object_del() */
515 elm_widget_sub_object_del(obj, content);
516 edje_object_part_unswallow(wd->lay, content);
524 * Set the text of the given part
526 * @param obj The layout object
527 * @param part The TEXT part where to set the text
528 * @param text The text to set
533 elm_layout_text_set(Evas_Object *obj, const char *part, const char *text)
535 Widget_Data *wd = elm_widget_data_get(obj);
538 ELM_CHECK_WIDTYPE(obj, widtype);
540 EINA_LIST_FOREACH(wd->subs, l, si)
542 if ((si->type == TEXT) && (!strcmp(part, si->part)))
546 eina_stringshare_del(si->part);
547 eina_stringshare_del(si->p.text.text);
549 edje_object_part_text_set(wd->lay, part, NULL);
550 wd->subs = eina_list_remove_list(wd->subs, l);
561 si = ELM_NEW(Subinfo);
564 si->part = eina_stringshare_add(part);
565 wd->subs = eina_list_append(wd->subs, si);
568 eina_stringshare_replace(&si->p.text.text, text);
569 edje_object_part_text_set(wd->lay, part, text);
570 _request_sizing_eval(wd);
574 * Get the text set in the given part
576 * @param obj The layout object
577 * @param part The TEXT part to retrieve the text off
579 * @return The text set in @p part
584 elm_layout_text_get(const Evas_Object *obj, const char *part)
586 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
587 Widget_Data *wd = elm_widget_data_get(obj);
588 return edje_object_part_text_get(wd->lay, part);
592 * Append child to layout box part.
594 * Once the object is appended, its lifetime will be bound to the
595 * layout, whenever the layout dies the child will be deleted
596 * automatically. One should use elm_layout_box_remove() to make this
597 * layout forget about the object.
599 * @param obj the layout object
600 * @param part the box part to append.
601 * @param child the child object to append to box.
606 elm_layout_box_append(Evas_Object *obj, const char *part, Evas_Object *child)
608 ELM_CHECK_WIDTYPE(obj, widtype);
609 Widget_Data *wd = elm_widget_data_get(obj);
613 if (!edje_object_part_box_append(wd->lay, part, child))
614 WRN("child %p could not be appended to box part '%s'", child, part);
615 elm_widget_sub_object_add(obj, child);
616 evas_object_event_callback_add
617 (child, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, wd);
619 si = ELM_NEW(Subinfo);
620 si->type = BOX_APPEND;
621 si->part = eina_stringshare_add(part);
623 wd->subs = eina_list_append(wd->subs, si);
624 _request_sizing_eval(wd);
628 * Prepend child to layout box part.
630 * Once the object is prepended, its lifetime will be bound to the
631 * layout, whenever the layout dies the child will be deleted
632 * automatically. One should use elm_layout_box_remove() to make this
633 * layout forget about the object.
635 * @param obj the layout object
636 * @param part the box part to prepend.
637 * @param child the child object to prepend to box.
642 elm_layout_box_prepend(Evas_Object *obj, const char *part, Evas_Object *child)
644 ELM_CHECK_WIDTYPE(obj, widtype);
645 Widget_Data *wd = elm_widget_data_get(obj);
649 if (!edje_object_part_box_prepend(wd->lay, part, child))
650 WRN("child %p could not be prepended to box part '%s'", child, part);
651 elm_widget_sub_object_add(obj, child);
652 evas_object_event_callback_add
653 (child, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, wd);
655 si = ELM_NEW(Subinfo);
656 si->type = BOX_PREPEND;
657 si->part = eina_stringshare_add(part);
659 wd->subs = eina_list_prepend(wd->subs, si);
660 _request_sizing_eval(wd);
664 _box_reference_del(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
667 si->p.box.reference = NULL;
671 * Insert child to layout box part before a reference object.
673 * Once the object is inserted, its lifetime will be bound to the
674 * layout, whenever the layout dies the child will be deleted
675 * automatically. One should use elm_layout_box_remove() to make this
676 * layout forget about the object.
678 * @param obj the layout object
679 * @param part the box part to insert.
680 * @param child the child object to insert into box.
681 * @param reference another reference object to insert before in box.
686 elm_layout_box_insert_before(Evas_Object *obj, const char *part, Evas_Object *child, const Evas_Object *reference)
688 ELM_CHECK_WIDTYPE(obj, widtype);
689 Widget_Data *wd = elm_widget_data_get(obj);
693 if (!edje_object_part_box_insert_before(wd->lay, part, child, reference))
694 WRN("child %p could not be inserted before %p inf box part '%s'",
695 child, reference, part);
697 si = ELM_NEW(Subinfo);
698 si->type = BOX_INSERT_BEFORE;
699 si->part = eina_stringshare_add(part);
701 si->p.box.reference = reference;
703 elm_widget_sub_object_add(obj, child);
704 evas_object_event_callback_add
705 (child, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, wd);
706 evas_object_event_callback_add
707 ((Evas_Object *)reference, EVAS_CALLBACK_DEL, _box_reference_del, si);
709 wd->subs = eina_list_append(wd->subs, si);
710 _request_sizing_eval(wd);
714 * Insert child to layout box part at a given position.
716 * Once the object is inserted, its lifetime will be bound to the
717 * layout, whenever the layout dies the child will be deleted
718 * automatically. One should use elm_layout_box_remove() to make this
719 * layout forget about the object.
721 * @param obj the layout object
722 * @param part the box part to insert.
723 * @param child the child object to insert into box.
724 * @param pos the numeric position >=0 to insert the child.
729 elm_layout_box_insert_at(Evas_Object *obj, const char *part, Evas_Object *child, unsigned int pos)
731 ELM_CHECK_WIDTYPE(obj, widtype);
732 Widget_Data *wd = elm_widget_data_get(obj);
736 if (!edje_object_part_box_insert_at(wd->lay, part, child, pos))
737 WRN("child %p could not be inserted at %u to box part '%s'",
740 elm_widget_sub_object_add(obj, child);
741 evas_object_event_callback_add
742 (child, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, wd);
744 si = ELM_NEW(Subinfo);
745 si->type = BOX_INSERT_AT;
746 si->part = eina_stringshare_add(part);
749 wd->subs = eina_list_append(wd->subs, si);
750 _request_sizing_eval(wd);
754 _sub_box_remove(Widget_Data *wd, Subinfo *si)
758 if (si->type == BOX_INSERT_BEFORE)
759 evas_object_event_callback_del_full
760 ((Evas_Object *)si->p.box.reference,
761 EVAS_CALLBACK_DEL, _box_reference_del, si);
763 child = si->obj; /* si will die in _sub_del due elm_widget_sub_object_del() */
764 edje_object_part_box_remove(wd->lay, si->part, child);
765 elm_widget_sub_object_del(wd->obj, child);
770 _sub_table_remove(Widget_Data *wd, Subinfo *si)
774 child = si->obj; /* si will die in _sub_del due elm_widget_sub_object_del() */
775 edje_object_part_table_unpack(wd->lay, si->part, child);
776 elm_widget_sub_object_del(wd->obj, child);
781 _sub_box_is(const Subinfo *si)
787 case BOX_INSERT_BEFORE:
796 * Remove a child of the given part box.
798 * The object will be removed from the box part and its lifetime will
799 * not be handled by the layout anymore. This is equivalent to
800 * elm_layout_content_unset() for box.
802 * @param obj The layout object
803 * @param part The box part name to remove child.
804 * @param child The object to remove from box.
805 * @return The object that was being used, or NULL if not found.
810 elm_layout_box_remove(Evas_Object *obj, const char *part, Evas_Object *child)
812 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
813 Widget_Data *wd = elm_widget_data_get(obj);
817 if (!wd) return NULL;
819 EINA_SAFETY_ON_NULL_RETURN_VAL(part, NULL);
820 EINA_SAFETY_ON_NULL_RETURN_VAL(child, NULL);
821 EINA_LIST_FOREACH(wd->subs, l, si)
823 if (!_sub_box_is(si)) continue;
824 if ((si->obj == child) && (!strcmp(si->part, part)))
825 return _sub_box_remove(wd, si);
831 * Remove all child of the given part box.
833 * The objects will be removed from the box part and their lifetime will
834 * not be handled by the layout anymore. This is equivalent to
835 * elm_layout_content_unset() for all box children.
837 * @param obj The layout object
838 * @param part The box part name to remove child.
839 * @param clear If EINA_TRUE, then all objects will be deleted as
840 * well, otherwise they will just be removed and will be
841 * dangling on the canvas.
846 elm_layout_box_remove_all(Evas_Object *obj, const char *part, Eina_Bool clear)
848 ELM_CHECK_WIDTYPE(obj, widtype);
849 Widget_Data *wd = elm_widget_data_get(obj);
854 EINA_SAFETY_ON_NULL_RETURN(part);
856 lst = eina_list_clone(wd->subs);
857 EINA_LIST_FREE(lst, si)
859 if (!_sub_box_is(si)) continue;
860 if (!strcmp(si->part, part))
862 Evas_Object *child = _sub_box_remove(wd, si);
863 if ((clear) && (child)) evas_object_del(child);
866 /* eventually something may not be added with layout, del them as well */
867 edje_object_part_box_remove_all(wd->lay, part, clear);
871 * Insert child to layout table part.
873 * Once the object is inserted, its lifetime will be bound to the
874 * layout, whenever the layout dies the child will be deleted
875 * automatically. One should use elm_layout_box_remove() to make this
876 * layout forget about the object.
878 * @param obj the layout object
879 * @param part the box part to pack child.
880 * @param child the child object to pack into table.
881 * @param reference another reference object to insert before in box.
886 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)
888 ELM_CHECK_WIDTYPE(obj, widtype);
889 Widget_Data *wd = elm_widget_data_get(obj);
893 if (!edje_object_part_table_pack
894 (wd->lay, part, child, col, row, colspan, rowspan))
895 WRN("child %p could not be packed into box part '%s' col=%uh, row=%hu, "
896 "colspan=%hu, rowspan=%hu", child, part, col, row, colspan, rowspan);
898 elm_widget_sub_object_add(obj, child);
899 evas_object_event_callback_add
900 (child, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, wd);
902 si = ELM_NEW(Subinfo);
903 si->type = TABLE_PACK;
904 si->part = eina_stringshare_add(part);
906 si->p.table.col = col;
907 si->p.table.row = row;
908 si->p.table.colspan = colspan;
909 si->p.table.rowspan = rowspan;
910 wd->subs = eina_list_append(wd->subs, si);
911 _request_sizing_eval(wd);
915 * Unpack (remove) a child of the given part table.
917 * The object will be unpacked from the table part and its lifetime
918 * will not be handled by the layout anymore. This is equivalent to
919 * elm_layout_content_unset() for table.
921 * @param obj The layout object
922 * @param part The table part name to remove child.
923 * @param child The object to remove from table.
924 * @return The object that was being used, or NULL if not found.
929 elm_layout_table_unpack(Evas_Object *obj, const char *part, Evas_Object *child)
931 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
932 Widget_Data *wd = elm_widget_data_get(obj);
936 if (!wd) return NULL;
938 EINA_SAFETY_ON_NULL_RETURN_VAL(part, NULL);
939 EINA_SAFETY_ON_NULL_RETURN_VAL(child, NULL);
940 EINA_LIST_FOREACH(wd->subs, l, si)
942 if (si->type != TABLE_PACK) continue;
943 if ((si->obj == child) && (!strcmp(si->part, part)))
944 return _sub_table_remove(wd, si);
950 * Remove all child of the given part table.
952 * The objects will be removed from the table part and their lifetime will
953 * not be handled by the layout anymore. This is equivalent to
954 * elm_layout_content_unset() for all table children.
956 * @param obj The layout object
957 * @param part The table part name to remove child.
958 * @param clear If EINA_TRUE, then all objects will be deleted as
959 * well, otherwise they will just be removed and will be
960 * dangling on the canvas.
965 elm_layout_table_clear(Evas_Object *obj, const char *part, Eina_Bool clear)
967 ELM_CHECK_WIDTYPE(obj, widtype);
968 Widget_Data *wd = elm_widget_data_get(obj);
973 EINA_SAFETY_ON_NULL_RETURN(part);
975 lst = eina_list_clone(wd->subs);
976 EINA_LIST_FREE(lst, si)
978 if (si->type != TABLE_PACK) continue;
979 if (!strcmp(si->part, part))
981 Evas_Object *child = _sub_table_remove(wd, si);
982 if ((clear) && (child)) evas_object_del(child);
985 /* eventually something may not be added with layout, del them as well */
986 edje_object_part_table_clear(wd->lay, part, clear);
990 * Get the edje layout
992 * @param obj The layout object
994 * This returns the edje object. It is not expected to be used to then swallow
995 * objects via edje_object_part_swallow() for example. Use
996 * elm_layout_content_set() instead so child object handling and sizing is
997 * done properly. This is more intended for setting text, emitting signals,
998 * hooking to signal callbacks etc.
1000 * @return A Evas_Object with the edje layout settings loaded
1001 * with function elm_layout_file_set
1006 elm_layout_edje_get(const Evas_Object *obj)
1008 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1009 Widget_Data *wd = elm_widget_data_get(obj);
1010 if (!wd) return NULL;
1015 * Get the edje data of the given layout
1017 * @param obj The layout object
1018 * @param key The data key
1020 * @return The edje data string
1022 * This function fetches data specified at the object level.
1023 * This function return NULL if data is not found.
1025 * In EDC this comes from a data block within the group block that @a
1026 * obj was loaded from. E.g.
1033 * item: "key1" "value1";
1034 * item: "key2" "value2";
1043 elm_layout_data_get(const Evas_Object *obj, const char *key)
1045 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1046 Widget_Data *wd = elm_widget_data_get(obj);
1047 return edje_object_data_get(wd->lay, key);
1053 * Manually forms a sizing re-evaluation when contents changed state so that
1054 * minimum size might have changed and needs re-evaluation. Also note that
1055 * a standard signal of "size,eval" "elm" emitted by the edje object will
1056 * cause this to happen too
1058 * @param obj The layout object
1063 elm_layout_sizing_eval(Evas_Object *obj)
1065 ELM_CHECK_WIDTYPE(obj, widtype);
1066 Widget_Data *wd = elm_widget_data_get(obj);
1067 EINA_SAFETY_ON_NULL_RETURN(wd);
1068 _request_sizing_eval(wd);
1072 * Sets a specific cursor for an edje part.
1074 * @param obj The layout object.
1075 * @param part_name a part from loaded edje group.
1076 * @param cursor cursor name to use, see Elementary_Cursor.h
1078 * @return EINA_TRUE on success or EINA_FALSE on failure, that may be
1079 * part not exists or it has "mouse_events: 0".
1084 elm_layout_part_cursor_set(Evas_Object *obj, const char *part_name, const char *cursor)
1086 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1087 EINA_SAFETY_ON_NULL_RETURN_VAL(part_name, EINA_FALSE);
1088 Widget_Data *wd = elm_widget_data_get(obj);
1089 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EINA_FALSE);
1090 Evas_Object *part_obj;
1093 part_obj = (Evas_Object *)edje_object_part_object_get(wd->lay, part_name);
1096 const char *group, *file;
1097 edje_object_file_get(wd->lay, &file, &group);
1098 WRN("no part '%s' in group '%s' of file '%s'. Cannot set cursor '%s'",
1099 part_name, group, file, cursor);
1102 if (evas_object_pass_events_get(part_obj))
1104 const char *group, *file;
1105 edje_object_file_get(wd->lay, &file, &group);
1106 WRN("part '%s' in group '%s' of file '%s' has mouse_events: 0. "
1107 "Cannot set cursor '%s'",
1108 part_name, group, file, cursor);
1112 pc = _parts_cursors_find(wd, part_name);
1113 if (pc) eina_stringshare_replace(&pc->cursor, cursor);
1116 pc = calloc(1, sizeof(*pc));
1117 pc->part = eina_stringshare_add(part_name);
1118 pc->cursor = eina_stringshare_add(cursor);
1122 elm_object_sub_cursor_set(part_obj, obj, pc->cursor);
1127 * Get the cursor to be shown when mouse is over an edje part
1129 * @param obj The layout object.
1130 * @param part_name a part from loaded edje group.
1131 * @return the cursor name.
1136 elm_layout_part_cursor_get(const Evas_Object *obj, const char *part_name)
1138 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1139 EINA_SAFETY_ON_NULL_RETURN_VAL(part_name, NULL);
1140 Widget_Data *wd = elm_widget_data_get(obj);
1141 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
1142 Part_Cursor *pc = _parts_cursors_find(wd, part_name);
1143 EINA_SAFETY_ON_NULL_RETURN_VAL(pc, NULL);
1144 EINA_SAFETY_ON_NULL_RETURN_VAL(pc->obj, NULL);
1145 return elm_object_cursor_get(pc->obj);
1149 * Unsets a cursor previously set with elm_layout_part_cursor_set().
1151 * @param obj The layout object.
1152 * @param part_name a part from loaded edje group, that had a cursor set
1153 * with elm_layout_part_cursor_set().
1158 elm_layout_part_cursor_unset(Evas_Object *obj, const char *part_name)
1160 ELM_CHECK_WIDTYPE(obj, widtype);
1161 EINA_SAFETY_ON_NULL_RETURN(part_name);
1162 Widget_Data *wd = elm_widget_data_get(obj);
1163 EINA_SAFETY_ON_NULL_RETURN(wd);
1167 EINA_LIST_FOREACH(wd->parts_cursors, l, pc)
1169 if (!strcmp(part_name, pc->part))
1171 if (pc->obj) elm_object_cursor_unset(pc->obj);
1172 _part_cursor_free(pc);
1173 wd->parts_cursors = eina_list_remove_list(wd->parts_cursors, l);
1180 * Sets a specific cursor style for an edje part.
1182 * @param obj The layout object.
1183 * @param part_name a part from loaded edje group.
1184 * @param style the theme style to use (default, transparent, ...)
1186 * @return EINA_TRUE on success or EINA_FALSE on failure, that may be
1187 * part not exists or it did not had a cursor set.
1192 elm_layout_part_cursor_style_set(Evas_Object *obj, const char *part_name, const char *style)
1194 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1195 EINA_SAFETY_ON_NULL_RETURN_VAL(part_name, EINA_FALSE);
1196 Widget_Data *wd = elm_widget_data_get(obj);
1197 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EINA_FALSE);
1198 Part_Cursor *pc = _parts_cursors_find(wd, part_name);
1199 EINA_SAFETY_ON_NULL_RETURN_VAL(pc, EINA_FALSE);
1200 EINA_SAFETY_ON_NULL_RETURN_VAL(pc->obj, EINA_FALSE);
1202 eina_stringshare_replace(&pc->style, style);
1203 elm_object_cursor_style_set(pc->obj, pc->style);
1208 * Gets a specific cursor style for an edje part.
1210 * @param obj The layout object.
1211 * @param part_name a part from loaded edje group.
1213 * @return the theme style in use, defaults to "default". If the
1214 * object does not have a cursor set, then NULL is returned.
1219 elm_layout_part_cursor_style_get(const Evas_Object *obj, const char *part_name)
1221 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1222 EINA_SAFETY_ON_NULL_RETURN_VAL(part_name, NULL);
1223 Widget_Data *wd = elm_widget_data_get(obj);
1224 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
1225 Part_Cursor *pc = _parts_cursors_find(wd, part_name);
1226 EINA_SAFETY_ON_NULL_RETURN_VAL(pc, NULL);
1227 EINA_SAFETY_ON_NULL_RETURN_VAL(pc->obj, NULL);
1228 return elm_object_cursor_style_get(pc->obj);
1232 * Sets if the cursor set should be searched on the theme or should use
1233 * the provided by the engine, only.
1235 * @note before you set if should look on theme you should define a
1236 * cursor with elm_layout_part_cursor_set(). By default it will only
1237 * look for cursors provided by the engine.
1239 * @param obj The layout object.
1240 * @param part_name a part from loaded edje group.
1241 * @param engine_only if cursors should be just provided by the engine
1242 * or should also search on widget's theme as well
1244 * @return EINA_TRUE on success or EINA_FALSE on failure, that may be
1245 * part not exists or it did not had a cursor set.
1250 elm_layout_part_cursor_engine_only_set(Evas_Object *obj, const char *part_name, Eina_Bool engine_only)
1252 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1253 EINA_SAFETY_ON_NULL_RETURN_VAL(part_name, EINA_FALSE);
1254 Widget_Data *wd = elm_widget_data_get(obj);
1255 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EINA_FALSE);
1256 Part_Cursor *pc = _parts_cursors_find(wd, part_name);
1257 EINA_SAFETY_ON_NULL_RETURN_VAL(pc, EINA_FALSE);
1258 EINA_SAFETY_ON_NULL_RETURN_VAL(pc->obj, EINA_FALSE);
1260 pc->engine_only = !!engine_only;
1261 elm_object_cursor_engine_only_set(pc->obj, pc->engine_only);
1266 * Gets a specific cursor engine_only for an edje part.
1268 * @param obj The layout object.
1269 * @param part_name a part from loaded edje group.
1271 * @return whenever the cursor is just provided by engine or also from theme.
1276 elm_layout_part_cursor_engine_only_get(const Evas_Object *obj, const char *part_name)
1278 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1279 EINA_SAFETY_ON_NULL_RETURN_VAL(part_name, EINA_FALSE);
1280 Widget_Data *wd = elm_widget_data_get(obj);
1281 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EINA_FALSE);
1282 Part_Cursor *pc = _parts_cursors_find(wd, part_name);
1283 EINA_SAFETY_ON_NULL_RETURN_VAL(pc, EINA_FALSE);
1284 EINA_SAFETY_ON_NULL_RETURN_VAL(pc->obj, EINA_FALSE);
1285 return elm_object_cursor_engine_only_get(pc->obj);