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 _mirrored_set(obj, elm_widget_mirrored_get(obj));
104 edje_object_scale_set(wd->lay, elm_widget_scale_get(obj) *
110 _changed_hook(Evas_Object *obj)
112 Widget_Data *wd = elm_widget_data_get(obj);
114 if (wd->needs_size_calc)
117 wd->needs_size_calc = 0;
122 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
124 Widget_Data *wd = elm_widget_data_get(obj);
125 edje_object_signal_emit(wd->lay, emission, source);
129 _signal_callback_add_hook(Evas_Object *obj, const char *emission, const char *source, void (*func_cb) (void *data, Evas_Object *o, const char *emission, const char *source), void *data)
131 Widget_Data *wd = elm_widget_data_get(obj);
132 edje_object_signal_callback_add(wd->lay, emission, source, func_cb, data);
136 _signal_callback_del_hook(Evas_Object *obj, const char *emission, const char *source, void (*func_cb) (void *data, Evas_Object *o, const char *emission, const char *source), void *data)
138 Widget_Data *wd = elm_widget_data_get(obj);
139 edje_object_signal_callback_del_full(wd->lay, emission, source, func_cb,
145 _elm_layout_list_data_get(const Eina_List *list)
147 Subinfo *si = eina_list_data_get(list);
152 _elm_layout_focus_next_hook(const Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next)
154 Widget_Data *wd = elm_widget_data_get(obj);
155 const Eina_List *items;
156 void *(*list_data_get) (const Eina_List *list);
158 if ((!wd) || (!wd->subs))
161 /* Focus chain (This block is diferent of elm_win cycle)*/
162 if ((items = elm_widget_focus_custom_chain_get(obj)))
163 list_data_get = eina_list_data_get;
167 list_data_get = _elm_layout_list_data_get;
169 if (!items) return EINA_FALSE;
172 return elm_widget_focus_list_next_get(obj, items, list_data_get, dir,
177 _sizing_eval(Widget_Data *wd)
179 Evas_Coord minw = -1, minh = -1;
180 edje_object_size_min_calc(wd->lay, &minw, &minh);
181 evas_object_size_hint_min_set(wd->obj, minw, minh);
182 evas_object_size_hint_max_set(wd->obj, -1, -1);
186 _request_sizing_eval(Widget_Data *wd)
188 if (wd->needs_size_calc) return;
189 wd->needs_size_calc = 1;
190 evas_object_smart_changed(wd->obj);
194 _part_cursor_free(Part_Cursor *pc)
196 eina_stringshare_del(pc->part);
197 eina_stringshare_del(pc->style);
198 eina_stringshare_del(pc->cursor);
203 _part_cursor_part_apply(const Part_Cursor *pc)
205 elm_object_cursor_set(pc->obj, pc->cursor);
206 elm_object_cursor_style_set(pc->obj, pc->style);
207 elm_object_cursor_engine_only_set(pc->obj, pc->engine_only);
211 _parts_cursors_find(Widget_Data *wd, const char *part)
215 EINA_LIST_FOREACH(wd->parts_cursors, l, pc)
217 if (!strcmp(pc->part, part))
224 _parts_cursors_apply(Widget_Data *wd)
226 const char *file, *group;
230 edje_object_file_get(wd->lay, &file, &group);
232 EINA_LIST_FOREACH(wd->parts_cursors, l, pc)
234 Evas_Object *obj = (Evas_Object *)edje_object_part_object_get
240 WRN("no part '%s' in group '%s' of file '%s'. "
241 "Cannot set cursor '%s'",
242 pc->part, group, file, pc->cursor);
245 else if (evas_object_pass_events_get(obj))
248 WRN("part '%s' in group '%s' of file '%s' has mouse_events: 0. "
249 "Cannot set cursor '%s'",
250 pc->part, group, file, pc->cursor);
255 _part_cursor_part_apply(pc);
260 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
262 _request_sizing_eval(data);
266 _sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info)
268 Widget_Data *wd = elm_widget_data_get(obj);
269 Evas_Object *sub = event_info;
273 EINA_LIST_FOREACH(wd->subs, l, si)
277 evas_object_event_callback_del_full(sub,
278 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
281 wd->subs = eina_list_remove_list(wd->subs, l);
282 eina_stringshare_del(si->part);
290 _signal_size_eval(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
292 _request_sizing_eval(data);
296 _parts_text_fix(Widget_Data *wd)
301 EINA_LIST_FOREACH(wd->subs, l, si)
303 if (si->type == TEXT)
304 edje_object_part_text_set(wd->lay, si->part, si->p.text.text);
309 * Add a new layout to the parent
311 * @param parent The parent object
312 * @return The new object or NULL if it cannot be created
317 elm_layout_add(Evas_Object *parent)
323 EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
325 wd = ELM_NEW(Widget_Data);
326 e = evas_object_evas_get(parent);
328 wd->obj = obj = elm_widget_add(e);
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);
342 wd->lay = edje_object_add(e);
343 elm_widget_resize_object_set(obj, wd->lay);
344 edje_object_signal_callback_add(wd->lay, "size,eval", "elm",
345 _signal_size_eval, wd);
347 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
349 _mirrored_set(obj, elm_widget_mirrored_get(obj));
350 _request_sizing_eval(wd);
355 * Set the file that will be used as layout
357 * @param obj The layout object
358 * @param file The path to file (edj) that will be used as layout
359 * @param group The group that the layout belongs in edje file
361 * @return (1 = success, 0 = error)
366 elm_layout_file_set(Evas_Object *obj, const char *file, const char *group)
368 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
369 Widget_Data *wd = elm_widget_data_get(obj);
370 if (!wd) return EINA_FALSE;
371 Eina_Bool ret = edje_object_file_set(wd->lay, file, group);
375 _request_sizing_eval(wd);
376 _parts_cursors_apply(wd);
378 else DBG("failed to set edje file '%s', group '%s': %s",
380 edje_load_error_str(edje_object_load_error_get(wd->lay)));
385 * Set the edje group from the elementary theme that will be used as layout
387 * @param obj The layout object
388 * @param clas the clas of the group
389 * @param group the group
390 * @param style the style to used
392 * @return (1 = success, 0 = error)
397 elm_layout_theme_set(Evas_Object *obj, const char *clas, const char *group, const char *style)
399 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
400 Widget_Data *wd = elm_widget_data_get(obj);
401 if (!wd) return EINA_FALSE;
402 Eina_Bool ret = _elm_theme_object_set(obj, wd->lay, clas, group, style);
406 _request_sizing_eval(wd);
407 _parts_cursors_apply(wd);
413 * Set the layout content
415 * Once the content object is set, a previously set one will be deleted.
416 * If you want to keep that old content object, use the
417 * elm_layout_content_unset() function.
419 * @param obj The layout object
420 * @param swallow The swallow group name in the edje file
421 * @param content The content will be filled in this layout object
426 elm_layout_content_set(Evas_Object *obj, const char *swallow, Evas_Object *content)
428 ELM_CHECK_WIDTYPE(obj, widtype);
429 Widget_Data *wd = elm_widget_data_get(obj);
433 EINA_LIST_FOREACH(wd->subs, l, si)
435 if ((si->type == SWALLOW) && (!strcmp(swallow, si->part)))
437 if (content == si->obj) return;
438 evas_object_del(si->obj);
444 elm_widget_sub_object_add(obj, content);
445 evas_object_event_callback_add(content,
446 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
447 _changed_size_hints, wd);
448 if (!edje_object_part_swallow(wd->lay, swallow, content))
449 WRN("could not swallow %p into part '%s'", content, swallow);
450 si = ELM_NEW(Subinfo);
452 si->part = eina_stringshare_add(swallow);
454 wd->subs = eina_list_append(wd->subs, si);
456 _request_sizing_eval(wd);
460 * Get the swallowed object in the given part
462 * @param obj The layout object
463 * @param swallow The SWALLOW part to get its content
465 * @return The swallowed object or NULL if none or an error occurred
469 EAPI const Evas_Object *
470 elm_layout_content_get(const Evas_Object *obj, const char *swallow)
472 Widget_Data *wd = elm_widget_data_get(obj);
475 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
477 EINA_LIST_FOREACH(wd->subs, l, si)
479 if ((si->type == SWALLOW) && !strcmp(swallow, si->part))
486 * Unset the layout content
488 * Unparent and return the content object which was set for this widget
490 * @param obj The layout object
491 * @param swallow The swallow group name in the edje file
492 * @return The content that was being used
497 elm_layout_content_unset(Evas_Object *obj, const char *swallow)
499 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
500 Widget_Data *wd = elm_widget_data_get(obj);
503 if (!wd) return NULL;
504 EINA_LIST_FOREACH(wd->subs, l, si)
506 if ((si->type == SWALLOW) && (!strcmp(swallow, si->part)))
508 Evas_Object *content;
509 if (!si->obj) return NULL;
510 content = si->obj; /* si will die in _sub_del due elm_widget_sub_object_del() */
511 elm_widget_sub_object_del(obj, content);
512 edje_object_part_unswallow(wd->lay, content);
520 * Set the text of the given part
522 * @param obj The layout object
523 * @param part The TEXT part where to set the text
524 * @param text The text to set
529 elm_layout_text_set(Evas_Object *obj, const char *part, const char *text)
531 Widget_Data *wd = elm_widget_data_get(obj);
534 ELM_CHECK_WIDTYPE(obj, widtype);
536 EINA_LIST_FOREACH(wd->subs, l, si)
538 if ((si->type == TEXT) && (!strcmp(part, si->part)))
542 eina_stringshare_del(si->part);
543 eina_stringshare_del(si->p.text.text);
545 edje_object_part_text_set(wd->lay, part, NULL);
546 wd->subs = eina_list_remove_list(wd->subs, l);
557 si = ELM_NEW(Subinfo);
560 si->part = eina_stringshare_add(part);
561 wd->subs = eina_list_append(wd->subs, si);
564 eina_stringshare_replace(&si->p.text.text, text);
565 edje_object_part_text_set(wd->lay, part, text);
566 _request_sizing_eval(wd);
570 * Get the text set in the given part
572 * @param obj The layout object
573 * @param part The TEXT part to retrieve the text off
575 * @return The text set in @p part
580 elm_layout_text_get(const Evas_Object *obj, const char *part)
582 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
583 Widget_Data *wd = elm_widget_data_get(obj);
584 return edje_object_part_text_get(wd->lay, part);
588 * Append child to layout box part.
590 * Once the object is appended, its lifetime will be bound to the
591 * layout, whenever the layout dies the child will be deleted
592 * automatically. One should use elm_layout_box_remove() to make this
593 * layout forget about the object.
595 * @param obj the layout object
596 * @param part the box part to append.
597 * @param child the child object to append to box.
602 elm_layout_box_append(Evas_Object *obj, const char *part, Evas_Object *child)
604 ELM_CHECK_WIDTYPE(obj, widtype);
605 Widget_Data *wd = elm_widget_data_get(obj);
609 if (!edje_object_part_box_append(wd->lay, part, child))
610 WRN("child %p could not be appended to box part '%s'", child, part);
611 elm_widget_sub_object_add(obj, child);
612 evas_object_event_callback_add
613 (child, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, wd);
615 si = ELM_NEW(Subinfo);
616 si->type = BOX_APPEND;
617 si->part = eina_stringshare_add(part);
619 wd->subs = eina_list_append(wd->subs, si);
620 _request_sizing_eval(wd);
624 * Prepend child to layout box part.
626 * Once the object is prepended, its lifetime will be bound to the
627 * layout, whenever the layout dies the child will be deleted
628 * automatically. One should use elm_layout_box_remove() to make this
629 * layout forget about the object.
631 * @param obj the layout object
632 * @param part the box part to prepend.
633 * @param child the child object to prepend to box.
638 elm_layout_box_prepend(Evas_Object *obj, const char *part, Evas_Object *child)
640 ELM_CHECK_WIDTYPE(obj, widtype);
641 Widget_Data *wd = elm_widget_data_get(obj);
645 if (!edje_object_part_box_prepend(wd->lay, part, child))
646 WRN("child %p could not be prepended to box part '%s'", child, part);
647 elm_widget_sub_object_add(obj, child);
648 evas_object_event_callback_add
649 (child, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, wd);
651 si = ELM_NEW(Subinfo);
652 si->type = BOX_PREPEND;
653 si->part = eina_stringshare_add(part);
655 wd->subs = eina_list_prepend(wd->subs, si);
656 _request_sizing_eval(wd);
660 _box_reference_del(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
663 si->p.box.reference = NULL;
667 * Insert child to layout box part before a reference object.
669 * Once the object is inserted, its lifetime will be bound to the
670 * layout, whenever the layout dies the child will be deleted
671 * automatically. One should use elm_layout_box_remove() to make this
672 * layout forget about the object.
674 * @param obj the layout object
675 * @param part the box part to insert.
676 * @param child the child object to insert into box.
677 * @param reference another reference object to insert before in box.
682 elm_layout_box_insert_before(Evas_Object *obj, const char *part, Evas_Object *child, const Evas_Object *reference)
684 ELM_CHECK_WIDTYPE(obj, widtype);
685 Widget_Data *wd = elm_widget_data_get(obj);
689 if (!edje_object_part_box_insert_before(wd->lay, part, child, reference))
690 WRN("child %p could not be inserted before %p inf box part '%s'",
691 child, reference, part);
693 si = ELM_NEW(Subinfo);
694 si->type = BOX_INSERT_BEFORE;
695 si->part = eina_stringshare_add(part);
697 si->p.box.reference = reference;
699 elm_widget_sub_object_add(obj, child);
700 evas_object_event_callback_add
701 (child, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, wd);
702 evas_object_event_callback_add
703 ((Evas_Object *)reference, EVAS_CALLBACK_DEL, _box_reference_del, si);
705 wd->subs = eina_list_append(wd->subs, si);
706 _request_sizing_eval(wd);
710 * Insert child to layout box part at a given position.
712 * Once the object is inserted, its lifetime will be bound to the
713 * layout, whenever the layout dies the child will be deleted
714 * automatically. One should use elm_layout_box_remove() to make this
715 * layout forget about the object.
717 * @param obj the layout object
718 * @param part the box part to insert.
719 * @param child the child object to insert into box.
720 * @param pos the numeric position >=0 to insert the child.
725 elm_layout_box_insert_at(Evas_Object *obj, const char *part, Evas_Object *child, unsigned int pos)
727 ELM_CHECK_WIDTYPE(obj, widtype);
728 Widget_Data *wd = elm_widget_data_get(obj);
732 if (!edje_object_part_box_insert_at(wd->lay, part, child, pos))
733 WRN("child %p could not be inserted at %u to box part '%s'",
736 elm_widget_sub_object_add(obj, child);
737 evas_object_event_callback_add
738 (child, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, wd);
740 si = ELM_NEW(Subinfo);
741 si->type = BOX_INSERT_AT;
742 si->part = eina_stringshare_add(part);
745 wd->subs = eina_list_append(wd->subs, si);
746 _request_sizing_eval(wd);
750 _sub_box_remove(Widget_Data *wd, Subinfo *si)
754 if (si->type == BOX_INSERT_BEFORE)
755 evas_object_event_callback_del_full
756 ((Evas_Object *)si->p.box.reference,
757 EVAS_CALLBACK_DEL, _box_reference_del, si);
759 child = si->obj; /* si will die in _sub_del due elm_widget_sub_object_del() */
760 edje_object_part_box_remove(wd->lay, si->part, child);
761 elm_widget_sub_object_del(wd->obj, child);
766 _sub_table_remove(Widget_Data *wd, Subinfo *si)
770 child = si->obj; /* si will die in _sub_del due elm_widget_sub_object_del() */
771 edje_object_part_table_unpack(wd->lay, si->part, child);
772 elm_widget_sub_object_del(wd->obj, child);
777 _sub_box_is(const Subinfo *si)
783 case BOX_INSERT_BEFORE:
792 * Remove a child of the given part box.
794 * The object will be removed from the box part and its lifetime will
795 * not be handled by the layout anymore. This is equivalent to
796 * elm_layout_content_unset() for box.
798 * @param obj The layout object
799 * @param part The box part name to remove child.
800 * @param child The object to remove from box.
801 * @return The object that was being used, or NULL if not found.
806 elm_layout_box_remove(Evas_Object *obj, const char *part, Evas_Object *child)
808 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
809 Widget_Data *wd = elm_widget_data_get(obj);
813 if (!wd) return NULL;
815 EINA_SAFETY_ON_NULL_RETURN_VAL(part, NULL);
816 EINA_SAFETY_ON_NULL_RETURN_VAL(child, NULL);
817 EINA_LIST_FOREACH(wd->subs, l, si)
819 if (!_sub_box_is(si)) continue;
820 if ((si->obj == child) && (!strcmp(si->part, part)))
821 return _sub_box_remove(wd, si);
827 * Remove all child of the given part box.
829 * The objects will be removed from the box part and their lifetime will
830 * not be handled by the layout anymore. This is equivalent to
831 * elm_layout_content_unset() for all box children.
833 * @param obj The layout object
834 * @param part The box part name to remove child.
835 * @param clear If EINA_TRUE, then all objects will be deleted as
836 * well, otherwise they will just be removed and will be
837 * dangling on the canvas.
842 elm_layout_box_remove_all(Evas_Object *obj, const char *part, Eina_Bool clear)
844 ELM_CHECK_WIDTYPE(obj, widtype);
845 Widget_Data *wd = elm_widget_data_get(obj);
850 EINA_SAFETY_ON_NULL_RETURN(part);
852 lst = eina_list_clone(wd->subs);
853 EINA_LIST_FREE(lst, si)
855 if (!_sub_box_is(si)) continue;
856 if (!strcmp(si->part, part))
858 Evas_Object *child = _sub_box_remove(wd, si);
859 if ((clear) && (child)) evas_object_del(child);
862 /* eventually something may not be added with layout, del them as well */
863 edje_object_part_box_remove_all(wd->lay, part, clear);
867 * Insert child to layout table part.
869 * Once the object is inserted, its lifetime will be bound to the
870 * layout, whenever the layout dies the child will be deleted
871 * automatically. One should use elm_layout_box_remove() to make this
872 * layout forget about the object.
874 * @param obj the layout object
875 * @param part the box part to pack child.
876 * @param child the child object to pack into table.
877 * @param reference another reference object to insert before in box.
882 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)
884 ELM_CHECK_WIDTYPE(obj, widtype);
885 Widget_Data *wd = elm_widget_data_get(obj);
889 if (!edje_object_part_table_pack
890 (wd->lay, part, child, col, row, colspan, rowspan))
891 WRN("child %p could not be packed into box part '%s' col=%uh, row=%hu, "
892 "colspan=%hu, rowspan=%hu", child, part, col, row, colspan, rowspan);
894 elm_widget_sub_object_add(obj, child);
895 evas_object_event_callback_add
896 (child, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, wd);
898 si = ELM_NEW(Subinfo);
899 si->type = TABLE_PACK;
900 si->part = eina_stringshare_add(part);
902 si->p.table.col = col;
903 si->p.table.row = row;
904 si->p.table.colspan = colspan;
905 si->p.table.rowspan = rowspan;
906 wd->subs = eina_list_append(wd->subs, si);
907 _request_sizing_eval(wd);
911 * Unpack (remove) a child of the given part table.
913 * The object will be unpacked from the table part and its lifetime
914 * will not be handled by the layout anymore. This is equivalent to
915 * elm_layout_content_unset() for table.
917 * @param obj The layout object
918 * @param part The table part name to remove child.
919 * @param child The object to remove from table.
920 * @return The object that was being used, or NULL if not found.
925 elm_layout_table_unpack(Evas_Object *obj, const char *part, Evas_Object *child)
927 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
928 Widget_Data *wd = elm_widget_data_get(obj);
932 if (!wd) return NULL;
934 EINA_SAFETY_ON_NULL_RETURN_VAL(part, NULL);
935 EINA_SAFETY_ON_NULL_RETURN_VAL(child, NULL);
936 EINA_LIST_FOREACH(wd->subs, l, si)
938 if (si->type != TABLE_PACK) continue;
939 if ((si->obj == child) && (!strcmp(si->part, part)))
940 return _sub_table_remove(wd, si);
946 * Remove all child of the given part table.
948 * The objects will be removed from the table part and their lifetime will
949 * not be handled by the layout anymore. This is equivalent to
950 * elm_layout_content_unset() for all table children.
952 * @param obj The layout object
953 * @param part The table part name to remove child.
954 * @param clear If EINA_TRUE, then all objects will be deleted as
955 * well, otherwise they will just be removed and will be
956 * dangling on the canvas.
961 elm_layout_table_clear(Evas_Object *obj, const char *part, Eina_Bool clear)
963 ELM_CHECK_WIDTYPE(obj, widtype);
964 Widget_Data *wd = elm_widget_data_get(obj);
969 EINA_SAFETY_ON_NULL_RETURN(part);
971 lst = eina_list_clone(wd->subs);
972 EINA_LIST_FREE(lst, si)
974 if (si->type != TABLE_PACK) continue;
975 if (!strcmp(si->part, part))
977 Evas_Object *child = _sub_table_remove(wd, si);
978 if ((clear) && (child)) evas_object_del(child);
981 /* eventually something may not be added with layout, del them as well */
982 edje_object_part_table_clear(wd->lay, part, clear);
986 * Get the edje layout
988 * @param obj The layout object
990 * This returns the edje object. It is not expected to be used to then swallow
991 * objects via edje_object_part_swallow() for example. Use
992 * elm_layout_content_set() instead so child object handling and sizing is
993 * done properly. This is more intended for setting text, emitting signals,
994 * hooking to signal callbacks etc.
996 * @return A Evas_Object with the edje layout settings loaded
997 * with function elm_layout_file_set
1002 elm_layout_edje_get(const Evas_Object *obj)
1004 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1005 Widget_Data *wd = elm_widget_data_get(obj);
1006 if (!wd) return NULL;
1011 * Get the edje data of the given layout
1013 * @param obj The layout object
1014 * @param key The data key
1016 * @return The edje data string
1018 * This function fetches data specified at the object level.
1019 * This function return NULL if data is not found.
1021 * In EDC this comes from a data block within the group block that @a
1022 * obj was loaded from. E.g.
1029 * item: "key1" "value1";
1030 * item: "key2" "value2";
1039 elm_layout_data_get(const Evas_Object *obj, const char *key)
1041 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1042 Widget_Data *wd = elm_widget_data_get(obj);
1043 return edje_object_data_get(wd->lay, key);
1049 * Manually forms a sizing re-evaluation when contents changed state so that
1050 * minimum size might have changed and needs re-evaluation. Also note that
1051 * a standard signal of "size,eval" "elm" emitted by the edje object will
1052 * cause this to happen too
1054 * @param obj The layout object
1059 elm_layout_sizing_eval(Evas_Object *obj)
1061 ELM_CHECK_WIDTYPE(obj, widtype);
1062 Widget_Data *wd = elm_widget_data_get(obj);
1063 EINA_SAFETY_ON_NULL_RETURN(wd);
1064 _request_sizing_eval(wd);
1068 * Sets a specific cursor for an edje part.
1070 * @param obj The layout object.
1071 * @param part_name a part from loaded edje group.
1072 * @param cursor cursor name to use, see Elementary_Cursor.h
1074 * @return EINA_TRUE on success or EINA_FALSE on failure, that may be
1075 * part not exists or it has "mouse_events: 0".
1080 elm_layout_part_cursor_set(Evas_Object *obj, const char *part_name, const char *cursor)
1082 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1083 EINA_SAFETY_ON_NULL_RETURN_VAL(part_name, EINA_FALSE);
1084 Widget_Data *wd = elm_widget_data_get(obj);
1085 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EINA_FALSE);
1086 Evas_Object *part_obj;
1089 part_obj = (Evas_Object *)edje_object_part_object_get(wd->lay, part_name);
1092 const char *group, *file;
1093 edje_object_file_get(wd->lay, &file, &group);
1094 WRN("no part '%s' in group '%s' of file '%s'. Cannot set cursor '%s'",
1095 part_name, group, file, cursor);
1098 if (evas_object_pass_events_get(part_obj))
1100 const char *group, *file;
1101 edje_object_file_get(wd->lay, &file, &group);
1102 WRN("part '%s' in group '%s' of file '%s' has mouse_events: 0. "
1103 "Cannot set cursor '%s'",
1104 part_name, group, file, cursor);
1108 pc = _parts_cursors_find(wd, part_name);
1109 if (pc) eina_stringshare_replace(&pc->cursor, cursor);
1112 pc = calloc(1, sizeof(*pc));
1113 pc->part = eina_stringshare_add(part_name);
1114 pc->cursor = eina_stringshare_add(cursor);
1118 elm_object_sub_cursor_set(part_obj, obj, pc->cursor);
1123 * Get the cursor to be shown when mouse is over an edje part
1125 * @param obj The layout object.
1126 * @param part_name a part from loaded edje group.
1127 * @return the cursor name.
1132 elm_layout_part_cursor_get(const Evas_Object *obj, const char *part_name)
1134 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1135 EINA_SAFETY_ON_NULL_RETURN_VAL(part_name, NULL);
1136 Widget_Data *wd = elm_widget_data_get(obj);
1137 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
1138 Part_Cursor *pc = _parts_cursors_find(wd, part_name);
1139 EINA_SAFETY_ON_NULL_RETURN_VAL(pc, NULL);
1140 EINA_SAFETY_ON_NULL_RETURN_VAL(pc->obj, NULL);
1141 return elm_object_cursor_get(pc->obj);
1145 * Unsets a cursor previously set with elm_layout_part_cursor_set().
1147 * @param obj The layout object.
1148 * @param part_name a part from loaded edje group, that had a cursor set
1149 * with elm_layout_part_cursor_set().
1154 elm_layout_part_cursor_unset(Evas_Object *obj, const char *part_name)
1156 ELM_CHECK_WIDTYPE(obj, widtype);
1157 EINA_SAFETY_ON_NULL_RETURN(part_name);
1158 Widget_Data *wd = elm_widget_data_get(obj);
1159 EINA_SAFETY_ON_NULL_RETURN(wd);
1163 EINA_LIST_FOREACH(wd->parts_cursors, l, pc)
1165 if (!strcmp(part_name, pc->part))
1167 if (pc->obj) elm_object_cursor_unset(pc->obj);
1168 _part_cursor_free(pc);
1169 wd->parts_cursors = eina_list_remove_list(wd->parts_cursors, l);
1176 * Sets a specific cursor style for an edje part.
1178 * @param obj The layout object.
1179 * @param part_name a part from loaded edje group.
1180 * @param style the theme style to use (default, transparent, ...)
1182 * @return EINA_TRUE on success or EINA_FALSE on failure, that may be
1183 * part not exists or it did not had a cursor set.
1188 elm_layout_part_cursor_style_set(Evas_Object *obj, const char *part_name, const char *style)
1190 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1191 EINA_SAFETY_ON_NULL_RETURN_VAL(part_name, EINA_FALSE);
1192 Widget_Data *wd = elm_widget_data_get(obj);
1193 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EINA_FALSE);
1194 Part_Cursor *pc = _parts_cursors_find(wd, part_name);
1195 EINA_SAFETY_ON_NULL_RETURN_VAL(pc, EINA_FALSE);
1196 EINA_SAFETY_ON_NULL_RETURN_VAL(pc->obj, EINA_FALSE);
1198 eina_stringshare_replace(&pc->style, style);
1199 elm_object_cursor_style_set(pc->obj, pc->style);
1204 * Gets a specific cursor style for an edje part.
1206 * @param obj The layout object.
1207 * @param part_name a part from loaded edje group.
1209 * @return the theme style in use, defaults to "default". If the
1210 * object does not have a cursor set, then NULL is returned.
1215 elm_layout_part_cursor_style_get(const Evas_Object *obj, const char *part_name)
1217 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1218 EINA_SAFETY_ON_NULL_RETURN_VAL(part_name, NULL);
1219 Widget_Data *wd = elm_widget_data_get(obj);
1220 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
1221 Part_Cursor *pc = _parts_cursors_find(wd, part_name);
1222 EINA_SAFETY_ON_NULL_RETURN_VAL(pc, NULL);
1223 EINA_SAFETY_ON_NULL_RETURN_VAL(pc->obj, NULL);
1224 return elm_object_cursor_style_get(pc->obj);
1228 * Sets if the cursor set should be searched on the theme or should use
1229 * the provided by the engine, only.
1231 * @note before you set if should look on theme you should define a
1232 * cursor with elm_layout_part_cursor_set(). By default it will only
1233 * look for cursors provided by the engine.
1235 * @param obj The layout object.
1236 * @param part_name a part from loaded edje group.
1237 * @param engine_only if cursors should be just provided by the engine
1238 * or should also search on widget's theme as well
1240 * @return EINA_TRUE on success or EINA_FALSE on failure, that may be
1241 * part not exists or it did not had a cursor set.
1246 elm_layout_part_cursor_engine_only_set(Evas_Object *obj, const char *part_name, Eina_Bool engine_only)
1248 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1249 EINA_SAFETY_ON_NULL_RETURN_VAL(part_name, EINA_FALSE);
1250 Widget_Data *wd = elm_widget_data_get(obj);
1251 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EINA_FALSE);
1252 Part_Cursor *pc = _parts_cursors_find(wd, part_name);
1253 EINA_SAFETY_ON_NULL_RETURN_VAL(pc, EINA_FALSE);
1254 EINA_SAFETY_ON_NULL_RETURN_VAL(pc->obj, EINA_FALSE);
1256 pc->engine_only = !!engine_only;
1257 elm_object_cursor_engine_only_set(pc->obj, pc->engine_only);
1262 * Gets a specific cursor engine_only for an edje part.
1264 * @param obj The layout object.
1265 * @param part_name a part from loaded edje group.
1267 * @return whenever the cursor is just provided by engine or also from theme.
1272 elm_layout_part_cursor_engine_only_get(const Evas_Object *obj, const char *part_name)
1274 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1275 EINA_SAFETY_ON_NULL_RETURN_VAL(part_name, EINA_FALSE);
1276 Widget_Data *wd = elm_widget_data_get(obj);
1277 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EINA_FALSE);
1278 Part_Cursor *pc = _parts_cursors_find(wd, part_name);
1279 EINA_SAFETY_ON_NULL_RETURN_VAL(pc, EINA_FALSE);
1280 EINA_SAFETY_ON_NULL_RETURN_VAL(pc->obj, EINA_FALSE);
1281 return elm_object_cursor_engine_only_get(pc->obj);