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 * Add a new layout to the parent
312 * @param parent The parent object
313 * @return The new object or NULL if it cannot be created
318 elm_layout_add(Evas_Object *parent)
324 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
326 ELM_SET_WIDTYPE(widtype, "layout");
327 elm_widget_type_set(obj, "layout");
328 elm_widget_sub_object_add(parent, obj);
329 elm_widget_data_set(obj, wd);
330 elm_widget_del_hook_set(obj, _del_hook);
331 elm_widget_theme_hook_set(obj, _theme_hook);
332 elm_widget_changed_hook_set(obj, _changed_hook);
333 elm_widget_can_focus_set(obj, EINA_FALSE);
334 elm_widget_focus_next_hook_set(obj, _elm_layout_focus_next_hook);
335 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
336 elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
337 elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
340 wd->lay = edje_object_add(e);
341 elm_widget_resize_object_set(obj, wd->lay);
342 edje_object_signal_callback_add(wd->lay, "size,eval", "elm",
343 _signal_size_eval, wd);
345 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
347 _mirrored_set(obj, elm_widget_mirrored_get(obj));
348 _request_sizing_eval(wd);
353 * Set the file that will be used as layout
355 * @param obj The layout object
356 * @param file The path to file (edj) that will be used as layout
357 * @param group The group that the layout belongs in edje file
359 * @return (1 = success, 0 = error)
364 elm_layout_file_set(Evas_Object *obj, const char *file, const char *group)
366 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
367 Widget_Data *wd = elm_widget_data_get(obj);
368 if (!wd) return EINA_FALSE;
369 Eina_Bool ret = edje_object_file_set(wd->lay, file, group);
373 _request_sizing_eval(wd);
374 _parts_cursors_apply(wd);
376 else DBG("failed to set edje file '%s', group '%s': %s",
378 edje_load_error_str(edje_object_load_error_get(wd->lay)));
383 * Set the edje group from the elementary theme that will be used as layout
385 * @param obj The layout object
386 * @param clas the clas of the group
387 * @param group the group
388 * @param style the style to used
390 * @return (1 = success, 0 = error)
395 elm_layout_theme_set(Evas_Object *obj, const char *clas, const char *group, const char *style)
397 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
398 Widget_Data *wd = elm_widget_data_get(obj);
399 if (!wd) return EINA_FALSE;
400 Eina_Bool ret = _elm_theme_object_set(obj, wd->lay, clas, group, style);
404 _request_sizing_eval(wd);
405 _parts_cursors_apply(wd);
411 * Set the layout content
413 * Once the content object is set, a previously set one will be deleted.
414 * If you want to keep that old content object, use the
415 * elm_layout_content_unset() function.
417 * @param obj The layout object
418 * @param swallow The swallow group name in the edje file
419 * @param content The content will be filled in this layout object
424 elm_layout_content_set(Evas_Object *obj, const char *swallow, Evas_Object *content)
426 ELM_CHECK_WIDTYPE(obj, widtype);
427 Widget_Data *wd = elm_widget_data_get(obj);
431 EINA_LIST_FOREACH(wd->subs, l, si)
433 if ((si->type == SWALLOW) && (!strcmp(swallow, si->part)))
435 if (content == si->obj) return;
436 evas_object_del(si->obj);
442 elm_widget_sub_object_add(obj, content);
443 evas_object_event_callback_add(content,
444 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
445 _changed_size_hints, wd);
446 if (!edje_object_part_swallow(wd->lay, swallow, content))
447 WRN("could not swallow %p into part '%s'", content, swallow);
448 si = ELM_NEW(Subinfo);
450 si->part = eina_stringshare_add(swallow);
452 wd->subs = eina_list_append(wd->subs, si);
454 _request_sizing_eval(wd);
458 * Get the swallowed object in the given part
460 * @param obj The layout object
461 * @param swallow The SWALLOW part to get its content
463 * @return The swallowed object or NULL if none or an error occurred
467 EAPI const Evas_Object *
468 elm_layout_content_get(const Evas_Object *obj, const char *swallow)
470 Widget_Data *wd = elm_widget_data_get(obj);
473 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
475 EINA_LIST_FOREACH(wd->subs, l, si)
477 if ((si->type == SWALLOW) && !strcmp(swallow, si->part))
484 * Unset the layout content
486 * Unparent and return the content object which was set for this widget
488 * @param obj The layout object
489 * @param swallow The swallow group name in the edje file
490 * @return The content that was being used
495 elm_layout_content_unset(Evas_Object *obj, const char *swallow)
497 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
498 Widget_Data *wd = elm_widget_data_get(obj);
501 if (!wd) return NULL;
502 EINA_LIST_FOREACH(wd->subs, l, si)
504 if ((si->type == SWALLOW) && (!strcmp(swallow, si->part)))
506 Evas_Object *content;
507 if (!si->obj) return NULL;
508 content = si->obj; /* si will die in _sub_del due elm_widget_sub_object_del() */
509 elm_widget_sub_object_del(obj, content);
510 edje_object_part_unswallow(wd->lay, content);
518 * Set the text of the given part
520 * @param obj The layout object
521 * @param part The TEXT part where to set the text
522 * @param text The text to set
527 elm_layout_text_set(Evas_Object *obj, const char *part, const char *text)
529 Widget_Data *wd = elm_widget_data_get(obj);
532 ELM_CHECK_WIDTYPE(obj, widtype);
534 EINA_LIST_FOREACH(wd->subs, l, si)
536 if ((si->type == TEXT) && (!strcmp(part, si->part)))
540 eina_stringshare_del(si->part);
541 eina_stringshare_del(si->p.text.text);
543 edje_object_part_text_set(wd->lay, part, NULL);
544 wd->subs = eina_list_remove_list(wd->subs, l);
555 si = ELM_NEW(Subinfo);
558 si->part = eina_stringshare_add(part);
559 wd->subs = eina_list_append(wd->subs, si);
562 eina_stringshare_replace(&si->p.text.text, text);
563 edje_object_part_text_set(wd->lay, part, text);
564 _request_sizing_eval(wd);
568 * Get the text set in the given part
570 * @param obj The layout object
571 * @param part The TEXT part to retrieve the text off
573 * @return The text set in @p part
578 elm_layout_text_get(const Evas_Object *obj, const char *part)
580 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
581 Widget_Data *wd = elm_widget_data_get(obj);
582 return edje_object_part_text_get(wd->lay, part);
586 * Append child to layout box part.
588 * Once the object is appended, its lifetime will be bound to the
589 * layout, whenever the layout dies the child will be deleted
590 * automatically. One should use elm_layout_box_remove() to make this
591 * layout forget about the object.
593 * @param obj the layout object
594 * @param part the box part to append.
595 * @param child the child object to append to box.
600 elm_layout_box_append(Evas_Object *obj, const char *part, Evas_Object *child)
602 ELM_CHECK_WIDTYPE(obj, widtype);
603 Widget_Data *wd = elm_widget_data_get(obj);
607 if (!edje_object_part_box_append(wd->lay, part, child))
608 WRN("child %p could not be appended to box part '%s'", child, part);
609 elm_widget_sub_object_add(obj, child);
610 evas_object_event_callback_add
611 (child, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, wd);
613 si = ELM_NEW(Subinfo);
614 si->type = BOX_APPEND;
615 si->part = eina_stringshare_add(part);
617 wd->subs = eina_list_append(wd->subs, si);
618 _request_sizing_eval(wd);
622 * Prepend child to layout box part.
624 * Once the object is prepended, its lifetime will be bound to the
625 * layout, whenever the layout dies the child will be deleted
626 * automatically. One should use elm_layout_box_remove() to make this
627 * layout forget about the object.
629 * @param obj the layout object
630 * @param part the box part to prepend.
631 * @param child the child object to prepend to box.
636 elm_layout_box_prepend(Evas_Object *obj, const char *part, Evas_Object *child)
638 ELM_CHECK_WIDTYPE(obj, widtype);
639 Widget_Data *wd = elm_widget_data_get(obj);
643 if (!edje_object_part_box_prepend(wd->lay, part, child))
644 WRN("child %p could not be prepended to box part '%s'", child, part);
645 elm_widget_sub_object_add(obj, child);
646 evas_object_event_callback_add
647 (child, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, wd);
649 si = ELM_NEW(Subinfo);
650 si->type = BOX_PREPEND;
651 si->part = eina_stringshare_add(part);
653 wd->subs = eina_list_prepend(wd->subs, si);
654 _request_sizing_eval(wd);
658 _box_reference_del(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
661 si->p.box.reference = NULL;
665 * Insert child to layout box part before a reference object.
667 * Once the object is inserted, its lifetime will be bound to the
668 * layout, whenever the layout dies the child will be deleted
669 * automatically. One should use elm_layout_box_remove() to make this
670 * layout forget about the object.
672 * @param obj the layout object
673 * @param part the box part to insert.
674 * @param child the child object to insert into box.
675 * @param reference another reference object to insert before in box.
680 elm_layout_box_insert_before(Evas_Object *obj, const char *part, Evas_Object *child, const Evas_Object *reference)
682 ELM_CHECK_WIDTYPE(obj, widtype);
683 Widget_Data *wd = elm_widget_data_get(obj);
687 if (!edje_object_part_box_insert_before(wd->lay, part, child, reference))
688 WRN("child %p could not be inserted before %p inf box part '%s'",
689 child, reference, part);
691 si = ELM_NEW(Subinfo);
692 si->type = BOX_INSERT_BEFORE;
693 si->part = eina_stringshare_add(part);
695 si->p.box.reference = reference;
697 elm_widget_sub_object_add(obj, child);
698 evas_object_event_callback_add
699 (child, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, wd);
700 evas_object_event_callback_add
701 ((Evas_Object *)reference, EVAS_CALLBACK_DEL, _box_reference_del, si);
703 wd->subs = eina_list_append(wd->subs, si);
704 _request_sizing_eval(wd);
708 * Insert child to layout box part at a given position.
710 * Once the object is inserted, its lifetime will be bound to the
711 * layout, whenever the layout dies the child will be deleted
712 * automatically. One should use elm_layout_box_remove() to make this
713 * layout forget about the object.
715 * @param obj the layout object
716 * @param part the box part to insert.
717 * @param child the child object to insert into box.
718 * @param pos the numeric position >=0 to insert the child.
723 elm_layout_box_insert_at(Evas_Object *obj, const char *part, Evas_Object *child, unsigned int pos)
725 ELM_CHECK_WIDTYPE(obj, widtype);
726 Widget_Data *wd = elm_widget_data_get(obj);
730 if (!edje_object_part_box_insert_at(wd->lay, part, child, pos))
731 WRN("child %p could not be inserted at %u to box part '%s'",
734 elm_widget_sub_object_add(obj, child);
735 evas_object_event_callback_add
736 (child, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, wd);
738 si = ELM_NEW(Subinfo);
739 si->type = BOX_INSERT_AT;
740 si->part = eina_stringshare_add(part);
743 wd->subs = eina_list_append(wd->subs, si);
744 _request_sizing_eval(wd);
748 _sub_box_remove(Widget_Data *wd, Subinfo *si)
752 if (si->type == BOX_INSERT_BEFORE)
753 evas_object_event_callback_del_full
754 ((Evas_Object *)si->p.box.reference,
755 EVAS_CALLBACK_DEL, _box_reference_del, si);
757 child = si->obj; /* si will die in _sub_del due elm_widget_sub_object_del() */
758 edje_object_part_box_remove(wd->lay, si->part, child);
759 elm_widget_sub_object_del(wd->obj, child);
764 _sub_table_remove(Widget_Data *wd, Subinfo *si)
768 child = si->obj; /* si will die in _sub_del due elm_widget_sub_object_del() */
769 edje_object_part_table_unpack(wd->lay, si->part, child);
770 elm_widget_sub_object_del(wd->obj, child);
775 _sub_box_is(const Subinfo *si)
781 case BOX_INSERT_BEFORE:
790 * Remove a child of the given part box.
792 * The object will be removed from the box part and its lifetime will
793 * not be handled by the layout anymore. This is equivalent to
794 * elm_layout_content_unset() for box.
796 * @param obj The layout object
797 * @param part The box part name to remove child.
798 * @param child The object to remove from box.
799 * @return The object that was being used, or NULL if not found.
804 elm_layout_box_remove(Evas_Object *obj, const char *part, Evas_Object *child)
806 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
807 Widget_Data *wd = elm_widget_data_get(obj);
811 if (!wd) return NULL;
813 EINA_SAFETY_ON_NULL_RETURN_VAL(part, NULL);
814 EINA_SAFETY_ON_NULL_RETURN_VAL(child, NULL);
815 EINA_LIST_FOREACH(wd->subs, l, si)
817 if (!_sub_box_is(si)) continue;
818 if ((si->obj == child) && (!strcmp(si->part, part)))
819 return _sub_box_remove(wd, si);
825 * Remove all child of the given part box.
827 * The objects will be removed from the box part and their lifetime will
828 * not be handled by the layout anymore. This is equivalent to
829 * elm_layout_content_unset() for all box children.
831 * @param obj The layout object
832 * @param part The box part name to remove child.
833 * @param clear If EINA_TRUE, then all objects will be deleted as
834 * well, otherwise they will just be removed and will be
835 * dangling on the canvas.
840 elm_layout_box_remove_all(Evas_Object *obj, const char *part, Eina_Bool clear)
842 ELM_CHECK_WIDTYPE(obj, widtype);
843 Widget_Data *wd = elm_widget_data_get(obj);
848 EINA_SAFETY_ON_NULL_RETURN(part);
850 lst = eina_list_clone(wd->subs);
851 EINA_LIST_FREE(lst, si)
853 if (!_sub_box_is(si)) continue;
854 if (!strcmp(si->part, part))
856 Evas_Object *child = _sub_box_remove(wd, si);
857 if ((clear) && (child)) evas_object_del(child);
860 /* eventually something may not be added with layout, del them as well */
861 edje_object_part_box_remove_all(wd->lay, part, clear);
865 * Insert child to layout table part.
867 * Once the object is inserted, its lifetime will be bound to the
868 * layout, whenever the layout dies the child will be deleted
869 * automatically. One should use elm_layout_box_remove() to make this
870 * layout forget about the object.
872 * @param obj the layout object
873 * @param part the box part to pack child.
874 * @param child the child object to pack into table.
875 * @param reference another reference object to insert before in box.
880 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)
882 ELM_CHECK_WIDTYPE(obj, widtype);
883 Widget_Data *wd = elm_widget_data_get(obj);
887 if (!edje_object_part_table_pack
888 (wd->lay, part, child, col, row, colspan, rowspan))
889 WRN("child %p could not be packed into box part '%s' col=%uh, row=%hu, "
890 "colspan=%hu, rowspan=%hu", child, part, col, row, colspan, rowspan);
892 elm_widget_sub_object_add(obj, child);
893 evas_object_event_callback_add
894 (child, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, wd);
896 si = ELM_NEW(Subinfo);
897 si->type = TABLE_PACK;
898 si->part = eina_stringshare_add(part);
900 si->p.table.col = col;
901 si->p.table.row = row;
902 si->p.table.colspan = colspan;
903 si->p.table.rowspan = rowspan;
904 wd->subs = eina_list_append(wd->subs, si);
905 _request_sizing_eval(wd);
909 * Unpack (remove) a child of the given part table.
911 * The object will be unpacked from the table part and its lifetime
912 * will not be handled by the layout anymore. This is equivalent to
913 * elm_layout_content_unset() for table.
915 * @param obj The layout object
916 * @param part The table part name to remove child.
917 * @param child The object to remove from table.
918 * @return The object that was being used, or NULL if not found.
923 elm_layout_table_unpack(Evas_Object *obj, const char *part, Evas_Object *child)
925 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
926 Widget_Data *wd = elm_widget_data_get(obj);
930 if (!wd) return NULL;
932 EINA_SAFETY_ON_NULL_RETURN_VAL(part, NULL);
933 EINA_SAFETY_ON_NULL_RETURN_VAL(child, NULL);
934 EINA_LIST_FOREACH(wd->subs, l, si)
936 if (si->type != TABLE_PACK) continue;
937 if ((si->obj == child) && (!strcmp(si->part, part)))
938 return _sub_table_remove(wd, si);
944 * Remove all child of the given part table.
946 * The objects will be removed from the table part and their lifetime will
947 * not be handled by the layout anymore. This is equivalent to
948 * elm_layout_content_unset() for all table children.
950 * @param obj The layout object
951 * @param part The table part name to remove child.
952 * @param clear If EINA_TRUE, then all objects will be deleted as
953 * well, otherwise they will just be removed and will be
954 * dangling on the canvas.
959 elm_layout_table_clear(Evas_Object *obj, const char *part, Eina_Bool clear)
961 ELM_CHECK_WIDTYPE(obj, widtype);
962 Widget_Data *wd = elm_widget_data_get(obj);
967 EINA_SAFETY_ON_NULL_RETURN(part);
969 lst = eina_list_clone(wd->subs);
970 EINA_LIST_FREE(lst, si)
972 if (si->type != TABLE_PACK) continue;
973 if (!strcmp(si->part, part))
975 Evas_Object *child = _sub_table_remove(wd, si);
976 if ((clear) && (child)) evas_object_del(child);
979 /* eventually something may not be added with layout, del them as well */
980 edje_object_part_table_clear(wd->lay, part, clear);
984 * Get the edje layout
986 * @param obj The layout object
988 * This returns the edje object. It is not expected to be used to then swallow
989 * objects via edje_object_part_swallow() for example. Use
990 * elm_layout_content_set() instead so child object handling and sizing is
991 * done properly. This is more intended for setting text, emitting signals,
992 * hooking to signal callbacks etc.
994 * @return A Evas_Object with the edje layout settings loaded
995 * with function elm_layout_file_set
1000 elm_layout_edje_get(const Evas_Object *obj)
1002 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1003 Widget_Data *wd = elm_widget_data_get(obj);
1004 if (!wd) return NULL;
1009 * Get the edje data of the given layout
1011 * @param obj The layout object
1012 * @param key The data key
1014 * @return The edje data string
1016 * This function fetches data specified at the object level.
1017 * This function return NULL if data is not found.
1019 * In EDC this comes from a data block within the group block that @a
1020 * obj was loaded from. E.g.
1027 * item: "key1" "value1";
1028 * item: "key2" "value2";
1037 elm_layout_data_get(const Evas_Object *obj, const char *key)
1039 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1040 Widget_Data *wd = elm_widget_data_get(obj);
1041 return edje_object_data_get(wd->lay, key);
1047 * Manually forms a sizing re-evaluation when contents changed state so that
1048 * minimum size might have changed and needs re-evaluation. Also note that
1049 * a standard signal of "size,eval" "elm" emitted by the edje object will
1050 * cause this to happen too
1052 * @param obj The layout object
1057 elm_layout_sizing_eval(Evas_Object *obj)
1059 ELM_CHECK_WIDTYPE(obj, widtype);
1060 Widget_Data *wd = elm_widget_data_get(obj);
1061 EINA_SAFETY_ON_NULL_RETURN(wd);
1062 _request_sizing_eval(wd);
1066 * Sets a specific cursor for an edje part.
1068 * @param obj The layout object.
1069 * @param part_name a part from loaded edje group.
1070 * @param cursor cursor name to use, see Elementary_Cursor.h
1072 * @return EINA_TRUE on success or EINA_FALSE on failure, that may be
1073 * part not exists or it has "mouse_events: 0".
1078 elm_layout_part_cursor_set(Evas_Object *obj, const char *part_name, const char *cursor)
1080 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1081 EINA_SAFETY_ON_NULL_RETURN_VAL(part_name, EINA_FALSE);
1082 Widget_Data *wd = elm_widget_data_get(obj);
1083 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EINA_FALSE);
1084 Evas_Object *part_obj;
1087 part_obj = (Evas_Object *)edje_object_part_object_get(wd->lay, part_name);
1090 const char *group, *file;
1091 edje_object_file_get(wd->lay, &file, &group);
1092 WRN("no part '%s' in group '%s' of file '%s'. Cannot set cursor '%s'",
1093 part_name, group, file, cursor);
1096 if (evas_object_pass_events_get(part_obj))
1098 const char *group, *file;
1099 edje_object_file_get(wd->lay, &file, &group);
1100 WRN("part '%s' in group '%s' of file '%s' has mouse_events: 0. "
1101 "Cannot set cursor '%s'",
1102 part_name, group, file, cursor);
1106 pc = _parts_cursors_find(wd, part_name);
1107 if (pc) eina_stringshare_replace(&pc->cursor, cursor);
1110 pc = calloc(1, sizeof(*pc));
1111 pc->part = eina_stringshare_add(part_name);
1112 pc->cursor = eina_stringshare_add(cursor);
1116 elm_object_sub_cursor_set(part_obj, obj, pc->cursor);
1121 * Get the cursor to be shown when mouse is over an edje part
1123 * @param obj The layout object.
1124 * @param part_name a part from loaded edje group.
1125 * @return the cursor name.
1130 elm_layout_part_cursor_get(const Evas_Object *obj, const char *part_name)
1132 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1133 EINA_SAFETY_ON_NULL_RETURN_VAL(part_name, NULL);
1134 Widget_Data *wd = elm_widget_data_get(obj);
1135 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
1136 Part_Cursor *pc = _parts_cursors_find(wd, part_name);
1137 EINA_SAFETY_ON_NULL_RETURN_VAL(pc, NULL);
1138 EINA_SAFETY_ON_NULL_RETURN_VAL(pc->obj, NULL);
1139 return elm_object_cursor_get(pc->obj);
1143 * Unsets a cursor previously set with elm_layout_part_cursor_set().
1145 * @param obj The layout object.
1146 * @param part_name a part from loaded edje group, that had a cursor set
1147 * with elm_layout_part_cursor_set().
1152 elm_layout_part_cursor_unset(Evas_Object *obj, const char *part_name)
1154 ELM_CHECK_WIDTYPE(obj, widtype);
1155 EINA_SAFETY_ON_NULL_RETURN(part_name);
1156 Widget_Data *wd = elm_widget_data_get(obj);
1157 EINA_SAFETY_ON_NULL_RETURN(wd);
1161 EINA_LIST_FOREACH(wd->parts_cursors, l, pc)
1163 if (!strcmp(part_name, pc->part))
1165 if (pc->obj) elm_object_cursor_unset(pc->obj);
1166 _part_cursor_free(pc);
1167 wd->parts_cursors = eina_list_remove_list(wd->parts_cursors, l);
1174 * Sets a specific cursor style for an edje part.
1176 * @param obj The layout object.
1177 * @param part_name a part from loaded edje group.
1178 * @param style the theme style to use (default, transparent, ...)
1180 * @return EINA_TRUE on success or EINA_FALSE on failure, that may be
1181 * part not exists or it did not had a cursor set.
1186 elm_layout_part_cursor_style_set(Evas_Object *obj, const char *part_name, const char *style)
1188 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1189 EINA_SAFETY_ON_NULL_RETURN_VAL(part_name, EINA_FALSE);
1190 Widget_Data *wd = elm_widget_data_get(obj);
1191 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EINA_FALSE);
1192 Part_Cursor *pc = _parts_cursors_find(wd, part_name);
1193 EINA_SAFETY_ON_NULL_RETURN_VAL(pc, EINA_FALSE);
1194 EINA_SAFETY_ON_NULL_RETURN_VAL(pc->obj, EINA_FALSE);
1196 eina_stringshare_replace(&pc->style, style);
1197 elm_object_cursor_style_set(pc->obj, pc->style);
1202 * Gets a specific cursor style for an edje part.
1204 * @param obj The layout object.
1205 * @param part_name a part from loaded edje group.
1207 * @return the theme style in use, defaults to "default". If the
1208 * object does not have a cursor set, then NULL is returned.
1213 elm_layout_part_cursor_style_get(const Evas_Object *obj, const char *part_name)
1215 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1216 EINA_SAFETY_ON_NULL_RETURN_VAL(part_name, NULL);
1217 Widget_Data *wd = elm_widget_data_get(obj);
1218 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
1219 Part_Cursor *pc = _parts_cursors_find(wd, part_name);
1220 EINA_SAFETY_ON_NULL_RETURN_VAL(pc, NULL);
1221 EINA_SAFETY_ON_NULL_RETURN_VAL(pc->obj, NULL);
1222 return elm_object_cursor_style_get(pc->obj);
1226 * Sets if the cursor set should be searched on the theme or should use
1227 * the provided by the engine, only.
1229 * @note before you set if should look on theme you should define a
1230 * cursor with elm_layout_part_cursor_set(). By default it will only
1231 * look for cursors provided by the engine.
1233 * @param obj The layout object.
1234 * @param part_name a part from loaded edje group.
1235 * @param engine_only if cursors should be just provided by the engine
1236 * or should also search on widget's theme as well
1238 * @return EINA_TRUE on success or EINA_FALSE on failure, that may be
1239 * part not exists or it did not had a cursor set.
1244 elm_layout_part_cursor_engine_only_set(Evas_Object *obj, const char *part_name, Eina_Bool engine_only)
1246 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1247 EINA_SAFETY_ON_NULL_RETURN_VAL(part_name, EINA_FALSE);
1248 Widget_Data *wd = elm_widget_data_get(obj);
1249 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EINA_FALSE);
1250 Part_Cursor *pc = _parts_cursors_find(wd, part_name);
1251 EINA_SAFETY_ON_NULL_RETURN_VAL(pc, EINA_FALSE);
1252 EINA_SAFETY_ON_NULL_RETURN_VAL(pc->obj, EINA_FALSE);
1254 pc->engine_only = !!engine_only;
1255 elm_object_cursor_engine_only_set(pc->obj, pc->engine_only);
1260 * Gets a specific cursor engine_only for an edje part.
1262 * @param obj The layout object.
1263 * @param part_name a part from loaded edje group.
1265 * @return whenever the cursor is just provided by engine or also from theme.
1270 elm_layout_part_cursor_engine_only_get(const Evas_Object *obj, const char *part_name)
1272 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1273 EINA_SAFETY_ON_NULL_RETURN_VAL(part_name, EINA_FALSE);
1274 Widget_Data *wd = elm_widget_data_get(obj);
1275 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EINA_FALSE);
1276 Part_Cursor *pc = _parts_cursors_find(wd, part_name);
1277 EINA_SAFETY_ON_NULL_RETURN_VAL(pc, EINA_FALSE);
1278 EINA_SAFETY_ON_NULL_RETURN_VAL(pc->obj, EINA_FALSE);
1279 return elm_object_cursor_engine_only_get(pc->obj);