summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWooHyun Jung <wh0705.jung@samsung.com>2017-07-17 13:45:08 +0900
committerWooHyun Jung <wh0705.jung@samsung.com>2017-07-17 13:45:08 +0900
commit245940c09333897168a9a3d0cc7194ab8dfe4862 (patch)
treeda75a5df7ad887dd000a51ad436910e19539d791
parent4f8d20c8265385f5eb7412dc96327b273cadd0b6 (diff)
Revert "elm_widget: separate elm_widget_item codes from elm_widget.c"
This reverts commit 4f8d20c8265385f5eb7412dc96327b273cadd0b6. I'll apply this after finishing of release. Thanks JP to give notification.
-rw-r--r--src/Makefile_Elementary.am1
-rw-r--r--src/lib/elementary/elm_widget.c1309
-rw-r--r--src/lib/elementary/elm_widget_item.c1422
3 files changed, 1309 insertions, 1423 deletions
diff --git a/src/Makefile_Elementary.am b/src/Makefile_Elementary.am
index fb3c3d774d..993e13032e 100644
--- a/src/Makefile_Elementary.am
+++ b/src/Makefile_Elementary.am
@@ -661,7 +661,6 @@ lib_elementary_libelementary_la_SOURCES = \
661 lib/elementary/elm_view_form.c \ 661 lib/elementary/elm_view_form.c \
662 lib/elementary/elm_web2.c \ 662 lib/elementary/elm_web2.c \
663 lib/elementary/elm_widget.c \ 663 lib/elementary/elm_widget.c \
664 lib/elementary/elm_widget_item.c \
665 lib/elementary/efl_ui_win.c \ 664 lib/elementary/efl_ui_win.c \
666 lib/elementary/elm_helper.c \ 665 lib/elementary/elm_helper.c \
667 lib/elementary/els_box.c \ 666 lib/elementary/els_box.c \
diff --git a/src/lib/elementary/elm_widget.c b/src/lib/elementary/elm_widget.c
index 691d8f9d93..9a3da4e83d 100644
--- a/src/lib/elementary/elm_widget.c
+++ b/src/lib/elementary/elm_widget.c
@@ -48,6 +48,7 @@ const char SIG_WIDGET_LANG_CHANGED[] = "language,changed";
48const char SIG_WIDGET_ACCESS_CHANGED[] = "access,changed"; 48const char SIG_WIDGET_ACCESS_CHANGED[] = "access,changed";
49 49
50typedef struct _Elm_Event_Cb_Data Elm_Event_Cb_Data; 50typedef struct _Elm_Event_Cb_Data Elm_Event_Cb_Data;
51typedef struct _Elm_Label_Data Elm_Label_Data;
51typedef struct _Elm_Translate_String_Data Elm_Translate_String_Data; 52typedef struct _Elm_Translate_String_Data Elm_Translate_String_Data;
52 53
53struct _Elm_Event_Cb_Data 54struct _Elm_Event_Cb_Data
@@ -56,6 +57,12 @@ struct _Elm_Event_Cb_Data
56 const void *data; 57 const void *data;
57}; 58};
58 59
60struct _Elm_Label_Data
61{
62 const char *part;
63 const char *text;
64};
65
59struct _Elm_Translate_String_Data 66struct _Elm_Translate_String_Data
60{ 67{
61 EINA_INLIST; 68 EINA_INLIST;
@@ -4734,6 +4741,304 @@ _elm_widget_focus_move_policy_automatic_set(Eo *obj, Elm_Widget_Smart_Data *sd,
4734 } 4741 }
4735} 4742}
4736 4743
4744static void
4745_track_obj_del(void *data, Evas *e, Evas_Object *obj, void *event_info);
4746
4747static void
4748_track_obj_update(Evas_Object *track, Evas_Object *obj)
4749{
4750 //Geometry
4751 Evas_Coord x, y, w, h;
4752 evas_object_geometry_get(obj, &x, &y, &w, &h);
4753 evas_object_move(track, x, y);
4754 evas_object_resize(track, w, h);
4755
4756 //Visibility
4757 if (evas_object_visible_get(obj)) evas_object_show(track);
4758 else evas_object_hide(track);
4759}
4760
4761static void
4762_track_obj_view_update(void *data, const Efl_Event *event)
4763{
4764 Elm_Widget_Item_Data *item = data;
4765 _track_obj_update(item->track_obj, event->object);
4766}
4767
4768static void
4769_track_obj_view_del(void *data, const Efl_Event *event);
4770
4771EFL_CALLBACKS_ARRAY_DEFINE(tracker_callbacks,
4772 { EFL_GFX_EVENT_RESIZE, _track_obj_view_update },
4773 { EFL_GFX_EVENT_MOVE, _track_obj_view_update },
4774 { EFL_GFX_EVENT_SHOW, _track_obj_view_update },
4775 { EFL_GFX_EVENT_HIDE, _track_obj_view_update },
4776 { EFL_EVENT_DEL, _track_obj_view_del });
4777
4778static void
4779_track_obj_view_del(void *data, const Efl_Event *event EINA_UNUSED)
4780{
4781 Elm_Widget_Item_Data *item = data;
4782
4783 while (evas_object_ref_get(item->track_obj) > 0)
4784 evas_object_unref(item->track_obj);
4785
4786 evas_object_event_callback_del(item->track_obj, EVAS_CALLBACK_DEL,
4787 _track_obj_del);
4788 evas_object_del(item->track_obj);
4789 item->track_obj = NULL;
4790}
4791
4792static void
4793_track_obj_del(void *data, Evas *e EINA_UNUSED,
4794 Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
4795{
4796 Elm_Widget_Item_Data *item = data;
4797 item->track_obj = NULL;
4798
4799 if (!item->view) return;
4800
4801 efl_event_callback_array_del(item->view, tracker_callbacks(), item);
4802}
4803
4804static void
4805_elm_widget_item_signal_cb(void *data, Evas_Object *obj EINA_UNUSED, const char *emission,
4806 const char *source)
4807{
4808 Elm_Widget_Item_Signal_Data *wisd = data;
4809 wisd->func(wisd->data, wisd->item, emission, source);
4810}
4811
4812static void *
4813_elm_widget_item_signal_callback_list_get(Elm_Widget_Item_Data *item, Eina_List *position)
4814{
4815 Elm_Widget_Item_Signal_Data *wisd = eina_list_data_get(position);
4816 void *data;
4817
4818 item->signals = eina_list_remove_list(item->signals, position);
4819 data = wisd->data;
4820
4821 if (_elm_widget_is(item->view))
4822 elm_object_signal_callback_del(item->view,
4823 wisd->emission, wisd->source,
4824 _elm_widget_item_signal_cb);
4825 else if (efl_isa(item->view, EDJE_OBJECT_CLASS))
4826 edje_object_signal_callback_del_full(item->view,
4827 wisd->emission, wisd->source,
4828 _elm_widget_item_signal_cb, wisd);
4829
4830 eina_stringshare_del(wisd->emission);
4831 eina_stringshare_del(wisd->source);
4832 free(wisd);
4833
4834 return data;
4835}
4836
4837#define ERR_NOT_SUPPORTED(item, method) ERR("%s does not support %s API.", elm_widget_type_get(item->widget), method);
4838
4839static void
4840_efl_del_cb(void *data EINA_UNUSED, const Efl_Event *event)
4841{
4842 Elm_Widget_Item_Data *item = efl_data_scope_get(event->object, ELM_WIDGET_ITEM_CLASS);
4843 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4844 if (item->del_func)
4845 item->del_func((void *) WIDGET_ITEM_DATA_GET(event->object), item->widget, item->eo_obj);
4846}
4847
4848/**
4849 * @internal
4850 *
4851 * Allocate a new Elm_Widget_Item-derived structure.
4852 *
4853 * The goal of this structure is to provide common ground for actions
4854 * that a widget item have, such as the owner widget, callback to
4855 * notify deletion, data pointer and maybe more.
4856 *
4857 * @param widget the owner widget that holds this item, must be an elm_widget!
4858 * @param alloc_size any number greater than sizeof(Elm_Widget_Item) that will
4859 * be used to allocate memory.
4860 *
4861 * @return allocated memory that is already zeroed out, or NULL on errors.
4862 *
4863 * @see elm_widget_item_new() convenience macro.
4864 * @see elm_widget_item_del() to release memory.
4865 * @ingroup Widget
4866 */
4867EOLIAN static Eo *
4868_elm_widget_item_efl_object_constructor(Eo *eo_item, Elm_Widget_Item_Data *item)
4869{
4870 Evas_Object *widget;
4871 widget = efl_parent_get(eo_item);
4872
4873 if (!_elm_widget_is(widget))
4874 {
4875 ERR("Failed");
4876 return NULL;
4877 }
4878
4879 eo_item = efl_constructor(efl_super(eo_item, ELM_WIDGET_ITEM_CLASS));
4880
4881 EINA_MAGIC_SET(item, ELM_WIDGET_ITEM_MAGIC);
4882
4883 item->widget = widget;
4884 item->eo_obj = eo_item;
4885 efl_event_callback_add(eo_item, EFL_EVENT_DEL, _efl_del_cb, NULL);
4886
4887 return eo_item;
4888}
4889
4890EOLIAN static void
4891_elm_widget_item_efl_object_destructor(Eo *eo_item, Elm_Widget_Item_Data *item)
4892{
4893 Elm_Translate_String_Data *ts;
4894
4895 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4896
4897 evas_object_del(item->view);
4898
4899 eina_stringshare_del(item->access_info);
4900 eina_stringshare_del(item->accessible_name);
4901
4902 while (item->signals)
4903 _elm_widget_item_signal_callback_list_get(item, item->signals);
4904
4905 while (item->translate_strings)
4906 {
4907 ts = EINA_INLIST_CONTAINER_GET(item->translate_strings,
4908 Elm_Translate_String_Data);
4909 eina_stringshare_del(ts->id);
4910 eina_stringshare_del(ts->domain);
4911 eina_stringshare_del(ts->string);
4912 item->translate_strings = eina_inlist_remove(item->translate_strings,
4913 item->translate_strings);
4914 free(ts);
4915 }
4916 eina_hash_free(item->labels);
4917
4918 elm_interface_atspi_accessible_removed(eo_item);
4919
4920 EINA_MAGIC_SET(item, EINA_MAGIC_NONE);
4921
4922 efl_destructor(efl_super(eo_item, ELM_WIDGET_ITEM_CLASS));
4923}
4924
4925/**
4926 * @internal
4927 *
4928 * Releases widget item memory, calling back item_del_pre_hook() and
4929 * item_del_cb() if they exist.
4930 *
4931 * @param item a valid #Elm_Widget_Item to be deleted.
4932 *
4933 * If there is an Elm_Widget_Item::del_cb, then it will be called prior
4934 * to memory release. Note that elm_widget_item_pre_notify_del() calls
4935 * this function and then unset it, thus being useful for 2 step
4936 * cleanup whenever the del_cb may use any of the data that must be
4937 * deleted from item.
4938 *
4939 * The Elm_Widget_Item::view will be deleted (evas_object_del()) if it
4940 * is presented!
4941 *
4942 * Note that if item_del_pre_hook() returns @c EINA_TRUE, item free will be
4943 * deferred, or item will be freed here if it returns @c EINA_FALSE.
4944 *
4945 * @see elm_widget_item_del() convenience macro.
4946 * @ingroup Widget
4947 */
4948EOLIAN static void
4949_elm_widget_item_del(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
4950{
4951 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4952 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
4953 item->on_deletion = EINA_TRUE;
4954
4955 //Widget item delete callback
4956 Eina_Bool del_ok;
4957 del_ok = elm_wdg_item_del_pre(item->eo_obj);
4958 if (del_ok)
4959 efl_del(item->eo_obj);
4960 return;
4961}
4962
4963EOLIAN static Eina_Bool
4964_elm_widget_item_del_pre(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item EINA_UNUSED)
4965{
4966 return EINA_TRUE;
4967}
4968
4969/**
4970 * @internal
4971 *
4972 * Notify object will be deleted without actually deleting it.
4973 *
4974 * This function will callback Elm_Widget_Item::del_cb if it is set
4975 * and then unset it so it is not called twice (ie: from
4976 * elm_widget_item_del()).
4977 *
4978 * @param item a valid #Elm_Widget_Item to be notified
4979 * @see elm_widget_item_pre_notify_del() convenience macro.
4980 * @ingroup Widget
4981 */
4982EOLIAN static void
4983_elm_widget_item_pre_notify_del(Eo *eo_item, Elm_Widget_Item_Data *item)
4984{
4985 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
4986 if (!item->del_func) return;
4987 item->del_func((void *)WIDGET_ITEM_DATA_GET(eo_item), item->widget, item->eo_obj);
4988 item->del_func = NULL;
4989}
4990
4991/**
4992 * @internal
4993 *
4994 * Set the function to notify when item is being deleted.
4995 *
4996 * This function will complain if there was a callback set already,
4997 * however it will set the new one.
4998 *
4999 * The callback will be called from elm_widget_item_pre_notify_del()
5000 * or elm_widget_item_del() will be called with:
5001 * - data: the Elm_Widget_Item::data value.
5002 * - obj: the Elm_Widget_Item::widget evas object.
5003 * - event_info: the item being deleted.
5004 *
5005 * @param item a valid #Elm_Widget_Item to be notified
5006 * @see elm_widget_item_del_cb_set() convenience macro.
5007 * @ingroup Widget
5008 */
5009EOLIAN static void
5010_elm_widget_item_del_cb_set(Eo *eo_item EINA_UNUSED,
5011 Elm_Widget_Item_Data *item,
5012 Evas_Smart_Cb func)
5013{
5014 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
5015 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
5016
5017 if ((item->del_func) && (item->del_func != func))
5018 WRN("You're replacing a previously set del_cb %p of item %p with %p",
5019 item->del_func, item->eo_obj, func);
5020
5021 item->del_func = func;
5022}
5023
5024/**
5025 * @internal
5026 *
5027 * Get owner widget of this item.
5028 *
5029 * @param item a valid #Elm_Widget_Item to get data from.
5030 * @return owner widget of this item.
5031 * @ingroup Widget
5032 */
5033EOLIAN static Evas_Object *
5034_elm_widget_item_widget_get(const Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
5035{
5036 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
5037 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item, NULL);
5038
5039 return item->widget;
5040}
5041
4737EAPI Eina_Bool 5042EAPI Eina_Bool
4738_elm_widget_onscreen_is(Evas_Object *widget) 5043_elm_widget_onscreen_is(Evas_Object *widget)
4739{ 5044{
@@ -4792,6 +5097,953 @@ _elm_widget_item_onscreen_is(Elm_Object_Item *item)
4792 return EINA_TRUE; 5097 return EINA_TRUE;
4793} 5098}
4794 5099
5100EOLIAN static Elm_Atspi_State_Set
5101_elm_widget_item_elm_interface_atspi_accessible_state_set_get(Eo *eo_item,
5102 Elm_Widget_Item_Data *item EINA_UNUSED)
5103{
5104 Elm_Atspi_State_Set states = 0;
5105
5106 STATE_TYPE_SET(states, ELM_ATSPI_STATE_FOCUSABLE);
5107
5108 if (elm_object_item_focus_get(eo_item))
5109 STATE_TYPE_SET(states, ELM_ATSPI_STATE_FOCUSED);
5110 if (!elm_object_item_disabled_get(eo_item))
5111 {
5112 STATE_TYPE_SET(states, ELM_ATSPI_STATE_ENABLED);
5113 STATE_TYPE_SET(states, ELM_ATSPI_STATE_SENSITIVE);
5114 STATE_TYPE_SET(states, ELM_ATSPI_STATE_VISIBLE);
5115 }
5116 if (_elm_widget_item_onscreen_is(eo_item))
5117 STATE_TYPE_SET(states, ELM_ATSPI_STATE_SHOWING);
5118
5119 return states;
5120}
5121
5122EAPI void
5123elm_object_item_data_set(Elm_Object_Item *it, void *data)
5124{
5125 WIDGET_ITEM_DATA_SET(it, data);
5126}
5127
5128EAPI void *
5129elm_object_item_data_get(const Elm_Object_Item *it)
5130{
5131 return (void *) WIDGET_ITEM_DATA_GET(it);
5132}
5133
5134EOLIAN static void
5135_elm_widget_item_disabled_set(Eo *eo_item EINA_UNUSED,
5136 Elm_Widget_Item_Data *item,
5137 Eina_Bool disabled)
5138{
5139 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
5140 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
5141
5142 if (item->disabled == disabled) return;
5143 item->disabled = !!disabled;
5144 elm_wdg_item_disable(item->eo_obj);
5145}
5146
5147EOLIAN static Eina_Bool
5148_elm_widget_item_disabled_get(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
5149{
5150 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
5151 return item->disabled;
5152}
5153
5154EOLIAN static void
5155_elm_widget_item_style_set(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item, const char *style EINA_UNUSED)
5156{
5157 ERR_NOT_SUPPORTED(item, "elm_object_style_set()");
5158}
5159
5160EOLIAN static const char *
5161_elm_widget_item_style_get(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
5162{
5163 ERR_NOT_SUPPORTED(item, "elm_object_style_get()");
5164 return NULL;
5165}
5166
5167EOLIAN static void
5168_elm_widget_item_disable(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item EINA_UNUSED)
5169{
5170}
5171
5172EOLIAN static void
5173_elm_widget_item_focus_set(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item, Eina_Bool focused EINA_UNUSED)
5174{
5175 ERR_NOT_SUPPORTED(item, "elm_object_item_focus_set");
5176}
5177
5178EOLIAN static Eina_Bool
5179_elm_widget_item_focus_get(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
5180{
5181 ERR_NOT_SUPPORTED(item, "elm_object_item_focus_get");
5182 return EINA_FALSE;
5183}
5184
5185EOLIAN static void
5186_elm_widget_item_domain_translatable_part_text_set(Eo *eo_item EINA_UNUSED,
5187 Elm_Widget_Item_Data *item,
5188 const char *part,
5189 const char *domain,
5190 const char *label)
5191{
5192 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
5193 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
5194 Elm_Translate_String_Data *ts;
5195
5196 if (!label)
5197 {
5198 _part_text_translatable_set(&item->translate_strings, part, EINA_FALSE,
5199 EINA_FALSE);
5200 }
5201 else
5202 {
5203 ts = _part_text_translatable_set(&item->translate_strings, part,
5204 EINA_TRUE, EINA_FALSE);
5205 if (!ts) return;
5206 if (!ts->string) ts->string = eina_stringshare_add(label);
5207 else eina_stringshare_replace(&ts->string, label);
5208 if (!ts->domain) ts->domain = eina_stringshare_add(domain);
5209 else eina_stringshare_replace(&ts->domain, domain);
5210#ifdef HAVE_GETTEXT
5211 if (label[0]) label = dgettext(domain, label);
5212#endif
5213 }
5214 item->on_translate = EINA_TRUE;
5215 elm_wdg_item_part_text_set(item->eo_obj, part, label);
5216 item->on_translate = EINA_FALSE;
5217}
5218
5219EOLIAN static const char *
5220_elm_widget_item_translatable_part_text_get(const Eo *eo_item EINA_UNUSED,
5221 Elm_Widget_Item_Data *item,
5222 const char *part)
5223{
5224 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
5225 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item, NULL);
5226
5227 Elm_Translate_String_Data *ts;
5228 ts = _translate_string_data_get(item->translate_strings, part);
5229 if (ts) return ts->string;
5230 return NULL;
5231}
5232
5233EOLIAN static void
5234_elm_widget_item_domain_part_text_translatable_set(Eo *eo_item EINA_UNUSED,
5235 Elm_Widget_Item_Data *item,
5236 const char *part,
5237 const char *domain,
5238 Eina_Bool translatable)
5239{
5240 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
5241 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
5242 Elm_Translate_String_Data *ts;
5243 const char *text;
5244
5245 ts = _part_text_translatable_set(&item->translate_strings, part,
5246 translatable, EINA_TRUE);
5247 if (!ts) return;
5248 if (!ts->domain) ts->domain = eina_stringshare_add(domain);
5249 else eina_stringshare_replace(&ts->domain, domain);
5250
5251 text = elm_wdg_item_part_text_get(item->eo_obj, part);
5252
5253 if (!text || !text[0]) return;
5254
5255 if (!ts->string) ts->string = eina_stringshare_add(text);
5256
5257//Try to translate text since we don't know the text is already translated.
5258#ifdef HAVE_GETTEXT
5259 text = dgettext(domain, text);
5260#endif
5261 item->on_translate = EINA_TRUE;
5262 elm_wdg_item_part_text_set(item->eo_obj, part, text);
5263 item->on_translate = EINA_FALSE;
5264}
5265
5266EOLIAN static void
5267_elm_widget_item_track_cancel(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
5268{
5269 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
5270 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
5271
5272 if (!item->track_obj) return;
5273
5274 while (evas_object_ref_get(item->track_obj) > 0)
5275 evas_object_unref(item->track_obj);
5276
5277 evas_object_del(item->track_obj);
5278}
5279
5280EOLIAN static Evas_Object *
5281_elm_widget_item_track(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
5282{
5283 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
5284 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item, NULL);
5285
5286 if (item->track_obj)
5287 {
5288 evas_object_ref(item->track_obj);
5289 return item->track_obj;
5290 }
5291
5292 if (!item->view)
5293 {
5294 WRN("view obj of the item(%p) is invalid. Please make sure the view obj is created!", item);
5295 return NULL;
5296 }
5297
5298 Evas_Object *track =
5299 evas_object_rectangle_add(evas_object_evas_get(item->widget));
5300 evas_object_color_set(track, 0, 0, 0, 0);
5301 evas_object_pass_events_set(track, EINA_TRUE);
5302 _track_obj_update(track, item->view);
5303 evas_object_event_callback_add(track, EVAS_CALLBACK_DEL, _track_obj_del,
5304 item);
5305
5306 efl_event_callback_array_add(item->view, tracker_callbacks(), item);
5307
5308 evas_object_ref(track);
5309
5310 item->track_obj = track;
5311
5312 return track;
5313}
5314
5315EOLIAN static void
5316_elm_widget_item_untrack(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
5317{
5318 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
5319 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
5320
5321 if (!item->track_obj) return;
5322 evas_object_unref(item->track_obj);
5323
5324 if (evas_object_ref_get(item->track_obj) == 0)
5325 evas_object_del(item->track_obj);
5326}
5327
5328EOLIAN static int
5329_elm_widget_item_track_get(const Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
5330{
5331 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, 0);
5332 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item, 0);
5333
5334 if (!item->track_obj) return 0;
5335 return evas_object_ref_get(item->track_obj);
5336}
5337
5338typedef struct _Elm_Widget_Item_Tooltip Elm_Widget_Item_Tooltip;
5339
5340struct _Elm_Widget_Item_Tooltip
5341{
5342 Elm_Widget_Item_Data *item;
5343 Elm_Tooltip_Item_Content_Cb func;
5344 Evas_Smart_Cb del_cb;
5345 const void *data;
5346};
5347
5348static Evas_Object *
5349_elm_widget_item_tooltip_label_create(void *data,
5350 Evas_Object *obj EINA_UNUSED,
5351 Evas_Object *tooltip,
5352 void *item EINA_UNUSED)
5353{
5354 Evas_Object *label = elm_label_add(tooltip);
5355 if (!label)
5356 return NULL;
5357 elm_object_style_set(label, "tooltip");
5358 elm_object_text_set(label, data);
5359 return label;
5360}
5361
5362static Evas_Object *
5363_elm_widget_item_tooltip_trans_label_create(void *data,
5364 Evas_Object *obj EINA_UNUSED,
5365 Evas_Object *tooltip,
5366 void *item EINA_UNUSED)
5367{
5368 Evas_Object *label = elm_label_add(tooltip);
5369 if (!label)
5370 return NULL;
5371 elm_object_style_set(label, "tooltip");
5372 elm_object_translatable_text_set(label, data);
5373 return label;
5374}
5375
5376static void
5377_elm_widget_item_tooltip_label_del_cb(void *data,
5378 Evas_Object *obj EINA_UNUSED,
5379 void *event_info EINA_UNUSED)
5380{
5381 eina_stringshare_del(data);
5382}
5383
5384/**
5385 * @internal
5386 *
5387 * Set the text to be shown in the widget item.
5388 *
5389 * @param item Target item
5390 * @param text The text to set in the content
5391 *
5392 * Setup the text as tooltip to object. The item can have only one tooltip,
5393 * so any previous tooltip data is removed.
5394 *
5395 * @ingroup Widget
5396 */
5397EOLIAN static void
5398_elm_widget_item_tooltip_text_set(Eo *eo_item EINA_UNUSED,
5399 Elm_Widget_Item_Data *item EINA_UNUSED,
5400 const char *text)
5401{
5402 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
5403 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
5404 EINA_SAFETY_ON_NULL_RETURN(text);
5405
5406 text = eina_stringshare_add(text);
5407 elm_wdg_item_tooltip_content_cb_set(item->eo_obj, _elm_widget_item_tooltip_label_create, text, _elm_widget_item_tooltip_label_del_cb);
5408}
5409
5410EOLIAN static void
5411_elm_widget_item_tooltip_translatable_text_set(Eo *eo_item EINA_UNUSED,
5412 Elm_Widget_Item_Data *item EINA_UNUSED,
5413 const char *text)
5414{
5415 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
5416 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
5417 EINA_SAFETY_ON_NULL_RETURN(text);
5418
5419 text = eina_stringshare_add(text);
5420 elm_wdg_item_tooltip_content_cb_set(item->eo_obj, _elm_widget_item_tooltip_trans_label_create, text, _elm_widget_item_tooltip_label_del_cb);
5421}
5422
5423static Evas_Object *
5424_elm_widget_item_tooltip_create(void *data,
5425 Evas_Object *obj,
5426 Evas_Object *tooltip)
5427{
5428 Elm_Widget_Item_Tooltip *wit = data;
5429 return wit->func((void *)wit->data, obj, tooltip, wit->item->eo_obj);
5430}
5431
5432static void
5433_elm_widget_item_tooltip_del_cb(void *data,
5434 Evas_Object *obj,
5435 void *event_info EINA_UNUSED)
5436{
5437 Elm_Widget_Item_Tooltip *wit = data;
5438 if (wit->del_cb) wit->del_cb((void *)wit->data, obj, wit->item->eo_obj);
5439 free(wit);
5440}
5441
5442/**
5443 * @internal
5444 *
5445 * Set the content to be shown in the tooltip item
5446 *
5447 * Setup the tooltip to item. The item can have only one tooltip,
5448 * so any previous tooltip data is removed. @p func(with @p data) will
5449 * be called every time that need show the tooltip and it should
5450 * return a valid Evas_Object. This object is then managed fully by
5451 * tooltip system and is deleted when the tooltip is gone.
5452 *
5453 * @param item the widget item being attached a tooltip.
5454 * @param func the function used to create the tooltip contents.
5455 * @param data what to provide to @a func as callback data/context.
5456 * @param del_cb called when data is not needed anymore, either when
5457 * another callback replaces @func, the tooltip is unset with
5458 * elm_widget_item_tooltip_unset() or the owner @a item
5459 * dies. This callback receives as the first parameter the
5460 * given @a data, and @c event_info is the item.
5461 *
5462 * @ingroup Widget
5463 */
5464EOLIAN static void
5465_elm_widget_item_tooltip_content_cb_set(Eo *eo_item EINA_UNUSED,
5466 Elm_Widget_Item_Data *item,
5467 Elm_Tooltip_Item_Content_Cb func,
5468 const void *data,
5469 Evas_Smart_Cb del_cb)
5470{
5471 Elm_Widget_Item_Tooltip *wit;
5472
5473 ELM_WIDGET_ITEM_CHECK_OR_GOTO(item, error_noitem);
5474 //ELM_WIDGET_ITEM_RETURN_IF_GOTO(item, error_noitem);
5475
5476 if (!func)
5477 {
5478 elm_wdg_item_tooltip_unset(item->eo_obj);
5479 return;
5480 }
5481
5482 wit = ELM_NEW(Elm_Widget_Item_Tooltip);
5483 if (!wit) goto error;
5484 wit->item = item;
5485 wit->func = func;
5486 wit->data = data;
5487 wit->del_cb = del_cb;
5488
5489 elm_object_sub_tooltip_content_cb_set
5490 (item->view, item->widget, _elm_widget_item_tooltip_create, wit,
5491 _elm_widget_item_tooltip_del_cb);
5492
5493 return;
5494
5495error_noitem:
5496 if (del_cb) del_cb((void *)data, NULL, item);
5497 return;
5498error:
5499 if (del_cb) del_cb((void *)data, item->widget, item);
5500}
5501
5502/**
5503 * @internal
5504 *
5505 * Unset tooltip from item
5506 *
5507 * @param item widget item to remove previously set tooltip.
5508 *
5509 * Remove tooltip from item. The callback provided as del_cb to
5510 * elm_widget_item_tooltip_content_cb_set() will be called to notify
5511 * it is not used anymore.
5512 *
5513 * @see elm_widget_item_tooltip_content_cb_set()
5514 *
5515 * @ingroup Widget
5516 */
5517EOLIAN static void
5518_elm_widget_item_tooltip_unset(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
5519{
5520 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
5521 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
5522
5523 elm_object_tooltip_unset(item->view);
5524}
5525
5526/**
5527 * @internal
5528 *
5529 * Sets a different style for this item tooltip.
5530 *
5531 * @note before you set a style you should define a tooltip with
5532 * elm_widget_item_tooltip_content_cb_set() or
5533 * elm_widget_item_tooltip_text_set()
5534 *
5535 * @param item widget item with tooltip already set.
5536 * @param style the theme style to use (default, transparent, ...)
5537 *
5538 * @ingroup Widget
5539 */
5540EOLIAN static void
5541_elm_widget_item_tooltip_style_set(Eo *eo_item EINA_UNUSED,
5542 Elm_Widget_Item_Data *item,
5543 const char *style)
5544{
5545 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
5546 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
5547
5548 elm_object_tooltip_style_set(item->view, style);
5549}
5550
5551EOLIAN static Eina_Bool
5552_elm_widget_item_tooltip_window_mode_set(Eo *eo_item EINA_UNUSED,
5553 Elm_Widget_Item_Data *item,
5554 Eina_Bool disable)
5555{
5556 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
5557 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item, EINA_FALSE);
5558
5559 return elm_object_tooltip_window_mode_set(item->view, disable);
5560}
5561
5562EOLIAN static Eina_Bool
5563_elm_widget_item_tooltip_window_mode_get(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
5564{
5565 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
5566 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item, EINA_FALSE);
5567
5568 return elm_object_tooltip_window_mode_get(item->view);
5569}
5570
5571/**
5572 * @internal
5573 *
5574 * Get the style for this item tooltip.
5575 *
5576 * @param item widget item with tooltip already set.
5577 * @return style the theme style in use, defaults to "default". If the
5578 * object does not have a tooltip set, then NULL is returned.
5579 *
5580 * @ingroup Widget
5581 */
5582EOLIAN static const char *
5583_elm_widget_item_tooltip_style_get(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
5584{
5585 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
5586
5587 return elm_object_tooltip_style_get(item->view);
5588}
5589
5590EOLIAN static void
5591_elm_widget_item_cursor_set(Eo *eo_item EINA_UNUSED,
5592 Elm_Widget_Item_Data *item,
5593 const char *cursor)
5594{
5595 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
5596 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
5597
5598 elm_object_sub_cursor_set(item->view, item->widget, cursor);
5599}
5600
5601EOLIAN static const char *
5602_elm_widget_item_cursor_get(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
5603{
5604 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
5605 return elm_object_cursor_get(item->view);
5606}
5607
5608EOLIAN static void
5609_elm_widget_item_cursor_unset(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
5610{
5611 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
5612 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
5613
5614 elm_object_cursor_unset(item->view);
5615}
5616
5617/**
5618 * @internal
5619 *
5620 * Sets a different style for this item cursor.
5621 *
5622 * @note before you set a style you should define a cursor with
5623 * elm_widget_item_cursor_set()
5624 *
5625 * @param item widget item with cursor already set.
5626 * @param style the theme style to use (default, transparent, ...)
5627 *
5628 * @ingroup Widget
5629 */
5630EOLIAN static void
5631_elm_widget_item_cursor_style_set(Eo *eo_item EINA_UNUSED,
5632 Elm_Widget_Item_Data *item,
5633 const char *style)
5634{
5635 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
5636 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
5637
5638 elm_object_cursor_style_set(item->view, style);
5639}
5640
5641/**
5642 * @internal
5643 *
5644 * Get the style for this item cursor.
5645 *
5646 * @param item widget item with cursor already set.
5647 * @return style the theme style in use, defaults to "default". If the
5648 * object does not have a cursor set, then NULL is returned.
5649 *
5650 * @ingroup Widget
5651 */
5652EOLIAN static const char *
5653_elm_widget_item_cursor_style_get(Eo *eo_item EINA_UNUSED,
5654 Elm_Widget_Item_Data *item)
5655{
5656 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
5657 return elm_object_cursor_style_get(item->view);
5658}
5659
5660/**
5661 * @internal
5662 *
5663 * Set if the cursor set should be searched on the theme or should use
5664 * the provided by the engine, only.
5665 *
5666 * @note before you set if should look on theme you should define a cursor
5667 * with elm_object_cursor_set(). By default it will only look for cursors
5668 * provided by the engine.
5669 *
5670 * @param item widget item with cursor already set.
5671 * @param engine_only boolean to define it cursors should be looked only
5672 * between the provided by the engine or searched on widget's theme as well.
5673 *
5674 * @ingroup Widget
5675 */
5676EOLIAN static void
5677_elm_widget_item_cursor_engine_only_set(Eo *eo_item EINA_UNUSED,
5678 Elm_Widget_Item_Data *item,
5679 Eina_Bool engine_only)
5680{
5681 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
5682 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
5683
5684 elm_object_cursor_theme_search_enabled_set(item->view, !engine_only);
5685}
5686
5687/**
5688 * @internal
5689 *
5690 * Get the cursor engine only usage for this item cursor.
5691 *
5692 * @param item widget item with cursor already set.
5693 * @return engine_only boolean to define it cursors should be looked only
5694 * between the provided by the engine or searched on widget's theme as well. If
5695 * the object does not have a cursor set, then EINA_FALSE is returned.
5696 *
5697 * @ingroup Widget
5698 */
5699EOLIAN static Eina_Bool
5700_elm_widget_item_cursor_engine_only_get(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
5701{
5702 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
5703 return !elm_object_cursor_theme_search_enabled_get(item->view);
5704}
5705
5706EOLIAN static void
5707_elm_widget_item_part_content_set(Eo *eo_item EINA_UNUSED,
5708 Elm_Widget_Item_Data *item,
5709 const char *part EINA_UNUSED,
5710 Evas_Object *content EINA_UNUSED)
5711{
5712 ERR_NOT_SUPPORTED(item, "elm_object_part_content_set()");
5713}
5714
5715EOLIAN static Evas_Object *
5716_elm_widget_item_part_content_get(Eo *eo_item EINA_UNUSED,
5717 Elm_Widget_Item_Data *item,
5718 const char *part EINA_UNUSED)
5719{
5720 ERR_NOT_SUPPORTED(item, "elm_object_part_content_get()");
5721 return NULL;
5722}
5723
5724EOLIAN static Evas_Object *
5725_elm_widget_item_part_content_unset(Eo *eo_item EINA_UNUSED,
5726 Elm_Widget_Item_Data *item,
5727 const char *part EINA_UNUSED)
5728{
5729 ERR_NOT_SUPPORTED(item, "elm_object_part_content_unset()");
5730 return NULL;
5731}
5732
5733EOLIAN static void
5734_elm_widget_item_part_text_set(Eo *eo_item EINA_UNUSED,
5735 Elm_Widget_Item_Data *item,
5736 const char *part EINA_UNUSED,
5737 const char *label EINA_UNUSED)
5738{
5739 ERR_NOT_SUPPORTED(item, "elm_object_part_text_set()");
5740}
5741
5742EOLIAN static const char *
5743_elm_widget_item_part_text_get(Eo *eo_item EINA_UNUSED,
5744 Elm_Widget_Item_Data *item,
5745 const char *part EINA_UNUSED)
5746{
5747 ERR_NOT_SUPPORTED(item, "elm_object_part_text_get()");
5748 return NULL;
5749}
5750
5751static void
5752_elm_widget_item_part_text_custom_free(void *data)
5753{
5754 Elm_Label_Data *label;
5755 label = data;
5756 eina_stringshare_del(label->part);
5757 eina_stringshare_del(label->text);
5758 free(label);
5759}
5760
5761EOLIAN static void
5762_elm_widget_item_part_text_custom_set(Eo *eo_item EINA_UNUSED,
5763 Elm_Widget_Item_Data *item,
5764 const char *part,
5765 const char *text)
5766{
5767 Elm_Label_Data *label;
5768 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
5769 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
5770
5771 if (!item->labels)
5772 item->labels =
5773 eina_hash_stringshared_new(_elm_widget_item_part_text_custom_free);
5774 label = eina_hash_find(item->labels, part);
5775 if (!label)
5776 {
5777 label = malloc(sizeof(Elm_Label_Data));
5778 if (!label)
5779 {
5780 ERR("Failed to allocate memory");
5781 return;
5782 }
5783 label->part = eina_stringshare_add(part);
5784 label->text = eina_stringshare_add(text);
5785 eina_hash_add(item->labels, part, label);
5786 }
5787 else
5788 eina_stringshare_replace(&label->text, text);
5789}
5790
5791EOLIAN static const char *
5792_elm_widget_item_part_text_custom_get(Eo *eo_item EINA_UNUSED,
5793 Elm_Widget_Item_Data *item,
5794 const char *part)
5795{
5796 Elm_Label_Data *label;
5797 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
5798 label = eina_hash_find(item->labels, part);
5799 return label ? label->text : NULL;
5800}
5801
5802static Eina_Bool
5803_elm_widget_item_part_text_custom_foreach(const Eina_Hash *labels EINA_UNUSED,
5804 const void *key EINA_UNUSED,
5805 void *data,
5806 void *func_data)
5807{
5808 Elm_Label_Data *label;
5809 Elm_Widget_Item_Data *item;
5810 label = data;
5811 item = func_data;
5812
5813 elm_wdg_item_part_text_set(item->eo_obj, label->part, label->text);
5814
5815 return EINA_TRUE;
5816}
5817
5818EOLIAN static void
5819_elm_widget_item_part_text_custom_update(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
5820{
5821 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
5822 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
5823 if (item->labels)
5824 eina_hash_foreach(item->labels,
5825 _elm_widget_item_part_text_custom_foreach, item);
5826}
5827
5828EOLIAN static void
5829_elm_widget_item_signal_emit(Eo *eo_item EINA_UNUSED,
5830 Elm_Widget_Item_Data *item EINA_UNUSED,
5831 const char *emission EINA_UNUSED,
5832 const char *source EINA_UNUSED)
5833{
5834
5835}
5836
5837EOLIAN static void
5838_elm_widget_item_signal_callback_add(Eo *eo_item,
5839 Elm_Widget_Item_Data *item,
5840 const char *emission,
5841 const char *source,
5842 Elm_Object_Item_Signal_Cb func,
5843 void *data)
5844{
5845 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
5846 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
5847 EINA_SAFETY_ON_NULL_RETURN(func);
5848
5849 Elm_Widget_Item_Signal_Data *wisd;
5850
5851 wisd = malloc(sizeof(Elm_Widget_Item_Signal_Data));
5852 if (!wisd) return;
5853
5854 wisd->item = eo_item;
5855 wisd->func = (Elm_Widget_Item_Signal_Cb)func;
5856 wisd->data = data;
5857 wisd->emission = eina_stringshare_add(emission);
5858 wisd->source = eina_stringshare_add(source);
5859
5860 if (_elm_widget_is(item->view))
5861 elm_object_signal_callback_add(item->view, emission, source, _elm_widget_item_signal_cb, wisd);
5862 else if (efl_isa(item->view, EDJE_OBJECT_CLASS))
5863 edje_object_signal_callback_add(item->view, emission, source, _elm_widget_item_signal_cb, wisd);
5864 else
5865 {
5866 WRN("The %s widget item doesn't support signal callback add!",
5867 efl_class_name_get(efl_class_get(item->widget)));
5868 free(wisd);
5869 return;
5870 }
5871
5872 item->signals = eina_list_append(item->signals, wisd);
5873}
5874
5875EOLIAN static void *
5876_elm_widget_item_signal_callback_del(Eo *eo_item EINA_UNUSED,
5877 Elm_Widget_Item_Data *item,
5878 const char *emission,
5879 const char *source,
5880 Elm_Object_Item_Signal_Cb func)
5881{
5882 Elm_Widget_Item_Signal_Data *wisd;
5883 Eina_List *l;
5884
5885 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
5886 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item, NULL);
5887 EINA_SAFETY_ON_NULL_RETURN_VAL(func, NULL);
5888
5889 EINA_LIST_FOREACH(item->signals, l, wisd)
5890 {
5891 if ((wisd->func == (Elm_Widget_Item_Signal_Cb)func) &&
5892 !strcmp(wisd->emission, emission) &&
5893 !strcmp(wisd->source, source))
5894 return _elm_widget_item_signal_callback_list_get(item, l);
5895 }
5896
5897 return NULL;
5898}
5899
5900EOLIAN static void
5901_elm_widget_item_access_info_set(Eo *eo_item EINA_UNUSED,
5902 Elm_Widget_Item_Data *item,
5903 const char *txt)
5904{
5905 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
5906 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
5907
5908 eina_stringshare_del(item->access_info);
5909 if (!txt) item->access_info = NULL;
5910 else item->access_info = eina_stringshare_add(txt);
5911}
5912
5913EOLIAN static void
5914_elm_widget_item_translate(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
5915{
5916 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
5917 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
5918
5919#ifdef HAVE_GETTEXT
5920 Elm_Translate_String_Data *ts;
5921 EINA_INLIST_FOREACH(item->translate_strings, ts)
5922 {
5923 if (!ts->string) continue;
5924 const char *s = dgettext(ts->domain, ts->string);
5925 item->on_translate = EINA_TRUE;
5926 elm_wdg_item_part_text_set(item->eo_obj, ts->id, s);
5927 item->on_translate = EINA_FALSE;
5928 }
5929#endif
5930}
5931
5932EOLIAN static void
5933_elm_widget_item_access_order_set(Eo *eo_item EINA_UNUSED,
5934 Elm_Widget_Item_Data *item,
5935 Eina_List *objs)
5936{
5937 _elm_access_widget_item_access_order_set(item, objs);
5938}
5939
5940EOLIAN static const Eina_List *
5941_elm_widget_item_access_order_get(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
5942{
5943 return _elm_access_widget_item_access_order_get(item);
5944}
5945
5946EOLIAN static void
5947_elm_widget_item_access_order_unset(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
5948{
5949 _elm_access_widget_item_access_order_unset(item);
5950}
5951
5952EOLIAN static Evas_Object*
5953_elm_widget_item_access_register(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
5954{
5955 _elm_access_widget_item_register(item);
5956 return item->access_obj;
5957}
5958
5959EOLIAN static void
5960_elm_widget_item_access_unregister(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
5961{
5962 _elm_access_widget_item_unregister(item);
5963}
5964
5965EOLIAN static Evas_Object*
5966_elm_widget_item_access_object_get(const Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
5967{
5968 return item->access_obj;
5969}
5970
5971EOLIAN static Evas_Object *
5972_elm_widget_item_focus_next_object_get(const Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item, Elm_Focus_Direction dir)
5973{
5974 Evas_Object *ret = NULL;
5975
5976 if (dir == ELM_FOCUS_PREVIOUS)
5977 ret = item->focus_previous;
5978 else if (dir == ELM_FOCUS_NEXT)
5979 ret = item->focus_next;
5980 else if (dir == ELM_FOCUS_UP)
5981 ret = item->focus_up;
5982 else if (dir == ELM_FOCUS_DOWN)
5983 ret = item->focus_down;
5984 else if (dir == ELM_FOCUS_RIGHT)
5985 ret = item->focus_right;
5986 else if (dir == ELM_FOCUS_LEFT)
5987 ret = item->focus_left;
5988
5989 return ret;
5990}
5991
5992EOLIAN static void
5993_elm_widget_item_focus_next_object_set(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item, Evas_Object *next, Elm_Focus_Direction dir)
5994{
5995 if (dir == ELM_FOCUS_PREVIOUS)
5996 item->focus_previous = next;
5997 else if (dir == ELM_FOCUS_NEXT)
5998 item->focus_next = next;
5999 else if (dir == ELM_FOCUS_UP)
6000 item->focus_up = next;
6001 else if (dir == ELM_FOCUS_DOWN)
6002 item->focus_down = next;
6003 else if (dir == ELM_FOCUS_RIGHT)
6004 item->focus_right = next;
6005 else if (dir == ELM_FOCUS_LEFT)
6006 item->focus_left = next;
6007}
6008
6009EOLIAN static Elm_Object_Item*
6010_elm_widget_item_focus_next_item_get(const Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item, Elm_Focus_Direction dir)
6011{
6012 Elm_Object_Item *ret = NULL;
6013
6014 if (dir == ELM_FOCUS_PREVIOUS)
6015 ret = item->item_focus_previous;
6016 else if (dir == ELM_FOCUS_NEXT)
6017 ret = item->item_focus_next;
6018 else if (dir == ELM_FOCUS_UP)
6019 ret = item->item_focus_up;
6020 else if (dir == ELM_FOCUS_DOWN)
6021 ret = item->item_focus_down;
6022 else if (dir == ELM_FOCUS_RIGHT)
6023 ret = item->item_focus_right;
6024 else if (dir == ELM_FOCUS_LEFT)
6025 ret = item->item_focus_left;
6026
6027 return ret;
6028}
6029
6030EOLIAN static void
6031_elm_widget_item_focus_next_item_set(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item, Elm_Object_Item *next_item, Elm_Focus_Direction dir)
6032{
6033 if (dir == ELM_FOCUS_PREVIOUS)
6034 item->item_focus_previous = next_item;
6035 else if (dir == ELM_FOCUS_NEXT)
6036 item->item_focus_next = next_item;
6037 else if (dir == ELM_FOCUS_UP)
6038 item->item_focus_up = next_item;
6039 else if (dir == ELM_FOCUS_DOWN)
6040 item->item_focus_down = next_item;
6041 else if (dir == ELM_FOCUS_RIGHT)
6042 item->item_focus_right = next_item;
6043 else if (dir == ELM_FOCUS_LEFT)
6044 item->item_focus_left = next_item;
6045}
6046
4795/* happy debug functions */ 6047/* happy debug functions */
4796#ifdef ELM_DEBUG 6048#ifdef ELM_DEBUG
4797static void 6049static void
@@ -5128,6 +6380,62 @@ _elm_widget_elm_interface_atspi_accessible_attributes_get(Eo *obj, Elm_Widget_Sm
5128 return ret; 6380 return ret;
5129} 6381}
5130 6382
6383EOLIAN static void
6384_elm_widget_item_elm_interface_atspi_component_extents_get(Eo *obj EINA_UNUSED, Elm_Widget_Item_Data *sd EINA_UNUSED, Eina_Bool screen_coords, int *x, int *y, int *w, int *h)
6385{
6386 int ee_x, ee_y;
6387
6388 if (!sd->view)
6389 {
6390 if (x) *x = -1;
6391 if (y) *y = -1;
6392 if (w) *w = -1;
6393 if (h) *h = -1;
6394 return;
6395 }
6396
6397 evas_object_geometry_get(sd->view, x, y, w, h);
6398 if (screen_coords)
6399 {
6400 Ecore_Evas *ee = ecore_evas_ecore_evas_get(evas_object_evas_get(sd->view));
6401 if (!ee) return;
6402 ecore_evas_geometry_get(ee, &ee_x, &ee_y, NULL, NULL);
6403 if (x) *x += ee_x;
6404 if (y) *y += ee_y;
6405 }
6406}
6407
6408EOLIAN static Eina_Bool
6409_elm_widget_item_elm_interface_atspi_component_extents_set(Eo *obj EINA_UNUSED, Elm_Widget_Item_Data *sd EINA_UNUSED, Eina_Bool screen_coords EINA_UNUSED, int x EINA_UNUSED, int y EINA_UNUSED, int w EINA_UNUSED, int h EINA_UNUSED)
6410{
6411 return EINA_FALSE;
6412}
6413
6414EOLIAN static int
6415_elm_widget_item_elm_interface_atspi_component_layer_get(Eo *obj EINA_UNUSED, Elm_Widget_Item_Data *sd EINA_UNUSED)
6416{
6417 if (!sd->view)
6418 return -1;
6419 return evas_object_layer_get(sd->view);
6420}
6421
6422EOLIAN static Eina_Bool
6423_elm_widget_item_elm_interface_atspi_component_focus_grab(Eo *obj EINA_UNUSED, Elm_Widget_Item_Data *_pd EINA_UNUSED)
6424{
6425 elm_object_item_focus_set(obj, EINA_TRUE);
6426 return elm_object_item_focus_get(obj);
6427}
6428
6429EOLIAN static double
6430_elm_widget_item_elm_interface_atspi_component_alpha_get(Eo *obj EINA_UNUSED, Elm_Widget_Item_Data *sd EINA_UNUSED)
6431{
6432 int alpha;
6433
6434 if (!sd->view) return -1.0;
6435 evas_object_color_get(sd->view, NULL, NULL, NULL, &alpha);
6436 return (double)alpha / 255.0;
6437}
6438
5131EOLIAN static Efl_Object * 6439EOLIAN static Efl_Object *
5132_elm_widget_efl_object_provider_find(Eo *obj, Elm_Widget_Smart_Data *pd, const Efl_Object *klass) 6440_elm_widget_efl_object_provider_find(Eo *obj, Elm_Widget_Smart_Data *pd, const Efl_Object *klass)
5133{ 6441{
@@ -5249,4 +6557,5 @@ ELM_PART_TEXT_DEFAULT_GET(elm_widget, NULL)
5249 ELM_PART_TEXT_DEFAULT_OPS(elm_widget), \ 6557 ELM_PART_TEXT_DEFAULT_OPS(elm_widget), \
5250 EFL_OBJECT_OP_FUNC(efl_dbg_info_get, _elm_widget_efl_object_dbg_info_get) 6558 EFL_OBJECT_OP_FUNC(efl_dbg_info_get, _elm_widget_efl_object_dbg_info_get)
5251 6559
6560#include "elm_widget_item.eo.c"
5252#include "elm_widget.eo.c" 6561#include "elm_widget.eo.c"
diff --git a/src/lib/elementary/elm_widget_item.c b/src/lib/elementary/elm_widget_item.c
deleted file mode 100644
index 81ae6fd149..0000000000
--- a/src/lib/elementary/elm_widget_item.c
+++ /dev/null
@@ -1,1422 +0,0 @@
1#ifdef HAVE_CONFIG_H
2# include "elementary_config.h"
3#endif
4
5#define ELM_INTERFACE_ATSPI_ACCESSIBLE_PROTECTED
6#define ELM_INTERFACE_ATSPI_COMPONENT_PROTECTED
7#define ELM_WIDGET_PROTECTED
8#define ELM_WIDGET_ITEM_PROTECTED
9#define EFL_CANVAS_OBJECT_BETA
10#define EFL_INPUT_EVENT_PROTECTED
11
12#include <Elementary.h>
13
14#include "elm_priv.h"
15#include "elm_widget_container.h"
16
17/* FIXME: remove this when we don't rely on evas event structs anymore */
18#define EFL_INTERNAL_UNSTABLE
19#include "interfaces/efl_common_internal.h"
20
21#define ERR_NOT_SUPPORTED(item, method) ERR("%s does not support %s API.", elm_widget_type_get(item->widget), method);
22
23typedef struct _Elm_Label_Data Elm_Label_Data;
24typedef struct _Elm_Translate_String_Data Elm_Translate_String_Data;
25
26struct _Elm_Label_Data
27{
28 const char *part;
29 const char *text;
30};
31
32struct _Elm_Translate_String_Data
33{
34 EINA_INLIST;
35 Eina_Stringshare *id;
36 Eina_Stringshare *domain;
37 Eina_Stringshare *string;
38 Eina_Bool preset : 1;
39};
40
41// methods
42
43/**
44 * @internal
45 *
46 * Sets a different style for this item tooltip.
47 *
48 * @note before you set a style you should define a tooltip with
49 * elm_widget_item_tooltip_content_cb_set() or
50 * elm_widget_item_tooltip_text_set()
51 *
52 * @param item widget item with tooltip already set.
53 * @param style the theme style to use (default, transparent, ...)
54 *
55 * @ingroup Widget
56 */
57EOLIAN static void
58_elm_widget_item_tooltip_style_set(Eo *eo_item EINA_UNUSED,
59 Elm_Widget_Item_Data *item,
60 const char *style)
61{
62 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
63 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
64
65 elm_object_tooltip_style_set(item->view, style);
66}
67
68EOLIAN static Eina_Bool
69_elm_widget_item_tooltip_window_mode_set(Eo *eo_item EINA_UNUSED,
70 Elm_Widget_Item_Data *item,
71 Eina_Bool disable)
72{
73 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
74 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item, EINA_FALSE);
75
76 return elm_object_tooltip_window_mode_set(item->view, disable);
77}
78
79EOLIAN static Eina_Bool
80_elm_widget_item_tooltip_window_mode_get(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
81{
82 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
83 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item, EINA_FALSE);
84
85 return elm_object_tooltip_window_mode_get(item->view);
86}
87
88/**
89 * @internal
90 *
91 * Get the style for this item tooltip.
92 *
93 * @param item widget item with tooltip already set.
94 * @return style the theme style in use, defaults to "default". If the
95 * object does not have a tooltip set, then NULL is returned.
96 *
97 * @ingroup Widget
98 */
99EOLIAN static const char *
100_elm_widget_item_tooltip_style_get(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
101{
102 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
103
104 return elm_object_tooltip_style_get(item->view);
105}
106
107EOLIAN static void
108_elm_widget_item_cursor_set(Eo *eo_item EINA_UNUSED,
109 Elm_Widget_Item_Data *item,
110 const char *cursor)
111{
112 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
113 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
114
115 elm_object_sub_cursor_set(item->view, item->widget, cursor);
116}
117
118EOLIAN static const char *
119_elm_widget_item_cursor_get(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
120{
121 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
122 return elm_object_cursor_get(item->view);
123}
124
125/**
126 * @internal
127 *
128 * Sets a different style for this item cursor.
129 *
130 * @note before you set a style you should define a cursor with
131 * elm_widget_item_cursor_set()
132 *
133 * @param item widget item with cursor already set.
134 * @param style the theme style to use (default, transparent, ...)
135 *
136 * @ingroup Widget
137 */
138EOLIAN static void
139_elm_widget_item_cursor_style_set(Eo *eo_item EINA_UNUSED,
140 Elm_Widget_Item_Data *item,
141 const char *style)
142{
143 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
144 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
145
146 elm_object_cursor_style_set(item->view, style);
147}
148
149/**
150 * @internal
151 *
152 * Get the style for this item cursor.
153 *
154 * @param item widget item with cursor already set.
155 * @return style the theme style in use, defaults to "default". If the
156 * object does not have a cursor set, then NULL is returned.
157 *
158 * @ingroup Widget
159 */
160EOLIAN static const char *
161_elm_widget_item_cursor_style_get(Eo *eo_item EINA_UNUSED,
162 Elm_Widget_Item_Data *item)
163{
164 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
165 return elm_object_cursor_style_get(item->view);
166}
167
168/**
169 * @internal
170 *
171 * Set if the cursor set should be searched on the theme or should use
172 * the provided by the engine, only.
173 *
174 * @note before you set if should look on theme you should define a cursor
175 * with elm_object_cursor_set(). By default it will only look for cursors
176 * provided by the engine.
177 *
178 * @param item widget item with cursor already set.
179 * @param engine_only boolean to define it cursors should be looked only
180 * between the provided by the engine or searched on widget's theme as well.
181 *
182 * @ingroup Widget
183 */
184EOLIAN static void
185_elm_widget_item_cursor_engine_only_set(Eo *eo_item EINA_UNUSED,
186 Elm_Widget_Item_Data *item,
187 Eina_Bool engine_only)
188{
189 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
190 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
191
192 elm_object_cursor_theme_search_enabled_set(item->view, !engine_only);
193}/**
194 * @internal
195 *
196 * Get the cursor engine only usage for this item cursor.
197 *
198 * @param item widget item with cursor already set.
199 * @return engine_only boolean to define it cursors should be looked only
200 * between the provided by the engine or searched on widget's theme as well. If
201 * the object does not have a cursor set, then EINA_FALSE is returned.
202 *
203 * @ingroup Widget
204 */
205EOLIAN static Eina_Bool
206_elm_widget_item_cursor_engine_only_get(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
207{
208 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
209 return !elm_object_cursor_theme_search_enabled_get(item->view);
210}
211
212
213EOLIAN static void
214_elm_widget_item_part_content_set(Eo *eo_item EINA_UNUSED,
215 Elm_Widget_Item_Data *item,
216 const char *part EINA_UNUSED,
217 Evas_Object *content EINA_UNUSED)
218{
219 ERR_NOT_SUPPORTED(item, "elm_object_part_content_set()");
220}
221
222EOLIAN static Evas_Object *
223_elm_widget_item_part_content_get(Eo *eo_item EINA_UNUSED,
224 Elm_Widget_Item_Data *item,
225 const char *part EINA_UNUSED)
226{
227 ERR_NOT_SUPPORTED(item, "elm_object_part_content_get()");
228 return NULL;
229}
230
231EOLIAN static void
232_elm_widget_item_part_text_set(Eo *eo_item EINA_UNUSED,
233 Elm_Widget_Item_Data *item,
234 const char *part EINA_UNUSED,
235 const char *label EINA_UNUSED)
236{
237 ERR_NOT_SUPPORTED(item, "elm_object_part_text_set()");
238}
239
240EOLIAN static const char *
241_elm_widget_item_part_text_get(Eo *eo_item EINA_UNUSED,
242 Elm_Widget_Item_Data *item,
243 const char *part EINA_UNUSED)
244{
245 ERR_NOT_SUPPORTED(item, "elm_object_part_text_get()");
246 return NULL;
247}
248
249static void
250_elm_widget_item_part_text_custom_free(void *data)
251{
252 Elm_Label_Data *label;
253 label = data;
254 eina_stringshare_del(label->part);
255 eina_stringshare_del(label->text);
256 free(label);
257}
258
259EOLIAN static void
260_elm_widget_item_part_text_custom_set(Eo *eo_item EINA_UNUSED,
261 Elm_Widget_Item_Data *item,
262 const char *part,
263 const char *text)
264{
265 Elm_Label_Data *label;
266 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
267 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
268
269 if (!item->labels)
270 item->labels =
271 eina_hash_stringshared_new(_elm_widget_item_part_text_custom_free);
272 label = eina_hash_find(item->labels, part);
273 if (!label)
274 {
275 label = malloc(sizeof(Elm_Label_Data));
276 if (!label)
277 {
278 ERR("Failed to allocate memory");
279 return;
280 }
281 label->part = eina_stringshare_add(part);
282 label->text = eina_stringshare_add(text);
283 eina_hash_add(item->labels, part, label);
284 }
285 else
286 eina_stringshare_replace(&label->text, text);
287}
288
289EOLIAN static const char *
290_elm_widget_item_part_text_custom_get(Eo *eo_item EINA_UNUSED,
291 Elm_Widget_Item_Data *item,
292 const char *part)
293{
294 Elm_Label_Data *label;
295 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
296 label = eina_hash_find(item->labels, part);
297 return label ? label->text : NULL;
298}
299
300EOLIAN static void
301_elm_widget_item_focus_set(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item, Eina_Bool focused EINA_UNUSED)
302{
303 ERR_NOT_SUPPORTED(item, "elm_object_item_focus_set");
304}
305
306EOLIAN static Eina_Bool
307_elm_widget_item_focus_get(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
308{
309 ERR_NOT_SUPPORTED(item, "elm_object_item_focus_get");
310 return EINA_FALSE;
311}
312
313EOLIAN static void
314_elm_widget_item_style_set(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item, const char *style EINA_UNUSED)
315{
316 ERR_NOT_SUPPORTED(item, "elm_object_style_set()");
317}
318
319EOLIAN static const char *
320_elm_widget_item_style_get(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
321{
322 ERR_NOT_SUPPORTED(item, "elm_object_style_get()");
323 return NULL;
324}
325
326EOLIAN static void
327_elm_widget_item_disable(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item EINA_UNUSED)
328{
329}
330
331EAPI void
332elm_object_item_data_set(Elm_Object_Item *it, void *data)
333{
334 WIDGET_ITEM_DATA_SET(it, data);
335}
336
337EAPI void *
338elm_object_item_data_get(const Elm_Object_Item *it)
339{
340 return (void *) WIDGET_ITEM_DATA_GET(it);
341}
342
343EOLIAN static void
344_elm_widget_item_disabled_set(Eo *eo_item EINA_UNUSED,
345 Elm_Widget_Item_Data *item,
346 Eina_Bool disabled)
347{
348 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
349 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
350
351 if (item->disabled == disabled) return;
352 item->disabled = !!disabled;
353 elm_wdg_item_disable(item->eo_obj);
354}
355
356EOLIAN static Eina_Bool
357_elm_widget_item_disabled_get(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
358{
359 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
360 return item->disabled;
361}
362
363EOLIAN static void
364_elm_widget_item_access_order_set(Eo *eo_item EINA_UNUSED,
365 Elm_Widget_Item_Data *item,
366 Eina_List *objs)
367{
368 _elm_access_widget_item_access_order_set(item, objs);
369}
370
371EOLIAN static const Eina_List *
372_elm_widget_item_access_order_get(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
373{
374 return _elm_access_widget_item_access_order_get(item);
375}
376
377/**
378 * @internal
379 *
380 * Get owner widget of this item.
381 *
382 * @param item a valid #Elm_Widget_Item to get data from.
383 * @return owner widget of this item.
384 * @ingroup Widget
385 */
386EOLIAN static Evas_Object *
387_elm_widget_item_widget_get(const Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
388{
389 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
390 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item, NULL);
391
392 return item->widget;
393}
394
395/**
396 * @internal
397 *
398 * Releases widget item memory, calling back item_del_pre_hook() and
399 * item_del_cb() if they exist.
400 *
401 * @param item a valid #Elm_Widget_Item to be deleted.
402 *
403 * If there is an Elm_Widget_Item::del_cb, then it will be called prior
404 * to memory release. Note that elm_widget_item_pre_notify_del() calls
405 * this function and then unset it, thus being useful for 2 step
406 * cleanup whenever the del_cb may use any of the data that must be
407 * deleted from item.
408 *
409 * The Elm_Widget_Item::view will be deleted (evas_object_del()) if it
410 * is presented!
411 *
412 * Note that if item_del_pre_hook() returns @c EINA_TRUE, item free will be
413 * deferred, or item will be freed here if it returns @c EINA_FALSE.
414 *
415 * @see elm_widget_item_del() convenience macro.
416 * @ingroup Widget
417 */
418EOLIAN static void
419_elm_widget_item_del(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
420{
421 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
422 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
423 item->on_deletion = EINA_TRUE;
424
425 //Widget item delete callback
426 Eina_Bool del_ok;
427 del_ok = elm_wdg_item_del_pre(item->eo_obj);
428 if (del_ok)
429 efl_del(item->eo_obj);
430 return;
431}
432
433/**
434 * @internal
435 *
436 * Notify object will be deleted without actually deleting it.
437 *
438 * This function will callback Elm_Widget_Item::del_cb if it is set
439 * and then unset it so it is not called twice (ie: from
440 * elm_widget_item_del()).
441 *
442 * @param item a valid #Elm_Widget_Item to be notified
443 * @see elm_widget_item_pre_notify_del() convenience macro.
444 * @ingroup Widget
445 */
446EOLIAN static void
447_elm_widget_item_pre_notify_del(Eo *eo_item, Elm_Widget_Item_Data *item)
448{
449 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
450 if (!item->del_func) return;
451 item->del_func((void *)WIDGET_ITEM_DATA_GET(eo_item), item->widget, item->eo_obj);
452 item->del_func = NULL;
453}
454
455static Evas_Object *
456_elm_widget_item_tooltip_label_create(void *data,
457 Evas_Object *obj EINA_UNUSED,
458 Evas_Object *tooltip,
459 void *item EINA_UNUSED)
460{
461 Evas_Object *label = elm_label_add(tooltip);
462 if (!label)
463 return NULL;
464 elm_object_style_set(label, "tooltip");
465 elm_object_text_set(label, data);
466 return label;
467}
468
469static void
470_elm_widget_item_tooltip_label_del_cb(void *data,
471 Evas_Object *obj EINA_UNUSED,
472 void *event_info EINA_UNUSED)
473{
474 eina_stringshare_del(data);
475}
476
477/**
478 * @internal
479 *
480 * Set the text to be shown in the widget item.
481 *
482 * @param item Target item
483 * @param text The text to set in the content
484 *
485 * Setup the text as tooltip to object. The item can have only one tooltip,
486 * so any previous tooltip data is removed.
487 *
488 * @ingroup Widget
489 */
490EOLIAN static void
491_elm_widget_item_tooltip_text_set(Eo *eo_item EINA_UNUSED,
492 Elm_Widget_Item_Data *item EINA_UNUSED,
493 const char *text)
494{
495 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
496 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
497 EINA_SAFETY_ON_NULL_RETURN(text);
498
499 text = eina_stringshare_add(text);
500 elm_wdg_item_tooltip_content_cb_set(item->eo_obj, _elm_widget_item_tooltip_label_create, text, _elm_widget_item_tooltip_label_del_cb);
501}
502
503typedef struct _Elm_Widget_Item_Tooltip Elm_Widget_Item_Tooltip;
504
505struct _Elm_Widget_Item_Tooltip
506{
507 Elm_Widget_Item_Data *item;
508 Elm_Tooltip_Item_Content_Cb func;
509 Evas_Smart_Cb del_cb;
510 const void *data;
511};
512
513static Evas_Object *
514_elm_widget_item_tooltip_trans_label_create(void *data,
515 Evas_Object *obj EINA_UNUSED,
516 Evas_Object *tooltip,
517 void *item EINA_UNUSED)
518{
519 Evas_Object *label = elm_label_add(tooltip);
520 if (!label)
521 return NULL;
522 elm_object_style_set(label, "tooltip");
523 elm_object_translatable_text_set(label, data);
524 return label;
525}
526
527static Evas_Object *
528_elm_widget_item_tooltip_create(void *data,
529 Evas_Object *obj,
530 Evas_Object *tooltip)
531{
532 Elm_Widget_Item_Tooltip *wit = data;
533 return wit->func((void *)wit->data, obj, tooltip, wit->item->eo_obj);
534}
535
536static void
537_elm_widget_item_tooltip_del_cb(void *data,
538 Evas_Object *obj,
539 void *event_info EINA_UNUSED)
540{
541 Elm_Widget_Item_Tooltip *wit = data;
542 if (wit->del_cb) wit->del_cb((void *)wit->data, obj, wit->item->eo_obj);
543 free(wit);
544}
545
546EOLIAN static void
547_elm_widget_item_tooltip_translatable_text_set(Eo *eo_item EINA_UNUSED,
548 Elm_Widget_Item_Data *item EINA_UNUSED,
549 const char *text)
550{
551 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
552 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
553 EINA_SAFETY_ON_NULL_RETURN(text);
554
555 text = eina_stringshare_add(text);
556 elm_wdg_item_tooltip_content_cb_set(item->eo_obj, _elm_widget_item_tooltip_trans_label_create, text, _elm_widget_item_tooltip_label_del_cb);
557}
558
559/**
560 * @internal
561 *
562 * Unset tooltip from item
563 *
564 * @param item widget item to remove previously set tooltip.
565 *
566 * Remove tooltip from item. The callback provided as del_cb to
567 * elm_widget_item_tooltip_content_cb_set() will be called to notify
568 * it is not used anymore.
569 *
570 * @see elm_widget_item_tooltip_content_cb_set()
571 *
572 * @ingroup Widget
573 */
574EOLIAN static void
575_elm_widget_item_tooltip_unset(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
576{
577 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
578 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
579
580 elm_object_tooltip_unset(item->view);
581}
582
583EOLIAN static void
584_elm_widget_item_cursor_unset(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
585{
586 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
587 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
588
589 elm_object_cursor_unset(item->view);
590}
591
592EOLIAN static Evas_Object *
593_elm_widget_item_part_content_unset(Eo *eo_item EINA_UNUSED,
594 Elm_Widget_Item_Data *item,
595 const char *part EINA_UNUSED)
596{
597 ERR_NOT_SUPPORTED(item, "elm_object_part_content_unset()");
598 return NULL;
599}
600
601static Eina_Bool
602_elm_widget_item_part_text_custom_foreach(const Eina_Hash *labels EINA_UNUSED,
603 const void *key EINA_UNUSED,
604 void *data,
605 void *func_data)
606{
607 Elm_Label_Data *label;
608 Elm_Widget_Item_Data *item;
609 label = data;
610 item = func_data;
611
612 elm_wdg_item_part_text_set(item->eo_obj, label->part, label->text);
613
614 return EINA_TRUE;
615}
616
617EOLIAN static void
618_elm_widget_item_part_text_custom_update(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
619{
620 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
621 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
622 if (item->labels)
623 eina_hash_foreach(item->labels,
624 _elm_widget_item_part_text_custom_foreach, item);
625}
626
627static void
628_elm_widget_item_signal_cb(void *data, Evas_Object *obj EINA_UNUSED, const char *emission,
629 const char *source)
630{
631 Elm_Widget_Item_Signal_Data *wisd = data;
632 wisd->func(wisd->data, wisd->item, emission, source);
633}
634
635EOLIAN static void
636_elm_widget_item_signal_callback_add(Eo *eo_item,
637 Elm_Widget_Item_Data *item,
638 const char *emission,
639 const char *source,
640 Elm_Object_Item_Signal_Cb func,
641 void *data)
642{
643 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
644 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
645 EINA_SAFETY_ON_NULL_RETURN(func);
646
647 Elm_Widget_Item_Signal_Data *wisd;
648
649 wisd = malloc(sizeof(Elm_Widget_Item_Signal_Data));
650 if (!wisd) return;
651
652 wisd->item = eo_item;
653 wisd->func = (Elm_Widget_Item_Signal_Cb)func;
654 wisd->data = data;
655 wisd->emission = eina_stringshare_add(emission);
656 wisd->source = eina_stringshare_add(source);
657
658 if (elm_widget_is(item->view))
659 elm_object_signal_callback_add(item->view, emission, source, _elm_widget_item_signal_cb, wisd);
660 else if (efl_isa(item->view, EDJE_OBJECT_CLASS))
661 edje_object_signal_callback_add(item->view, emission, source, _elm_widget_item_signal_cb, wisd);
662 else
663 {
664 WRN("The %s widget item doesn't support signal callback add!",
665 efl_class_name_get(efl_class_get(item->widget)));
666 free(wisd);
667 return;
668 }
669
670 item->signals = eina_list_append(item->signals, wisd);
671}
672
673static void *
674_elm_widget_item_signal_callback_list_get(Elm_Widget_Item_Data *item, Eina_List *position)
675{
676 Elm_Widget_Item_Signal_Data *wisd = eina_list_data_get(position);
677 void *data;
678
679 item->signals = eina_list_remove_list(item->signals, position);
680 data = wisd->data;
681
682 if (elm_widget_is(item->view))
683 elm_object_signal_callback_del(item->view,
684 wisd->emission, wisd->source,
685 _elm_widget_item_signal_cb);
686 else if (efl_isa(item->view, EDJE_OBJECT_CLASS))
687 edje_object_signal_callback_del_full(item->view,
688 wisd->emission, wisd->source,
689 _elm_widget_item_signal_cb, wisd);
690
691 eina_stringshare_del(wisd->emission);
692 eina_stringshare_del(wisd->source);
693 free(wisd);
694
695 return data;
696}
697
698
699EOLIAN static void *
700_elm_widget_item_signal_callback_del(Eo *eo_item EINA_UNUSED,
701 Elm_Widget_Item_Data *item,
702 const char *emission,
703 const char *source,
704 Elm_Object_Item_Signal_Cb func)
705{
706 Elm_Widget_Item_Signal_Data *wisd;
707 Eina_List *l;
708
709 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
710 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item, NULL);
711 EINA_SAFETY_ON_NULL_RETURN_VAL(func, NULL);
712
713 EINA_LIST_FOREACH(item->signals, l, wisd)
714 {
715 if ((wisd->func == (Elm_Widget_Item_Signal_Cb)func) &&
716 !strcmp(wisd->emission, emission) &&
717 !strcmp(wisd->source, source))
718 return _elm_widget_item_signal_callback_list_get(item, l);
719 }
720
721 return NULL;
722}
723
724EOLIAN static void
725_elm_widget_item_signal_emit(Eo *eo_item EINA_UNUSED,
726 Elm_Widget_Item_Data *item EINA_UNUSED,
727 const char *emission EINA_UNUSED,
728 const char *source EINA_UNUSED)
729{
730
731}
732
733EOLIAN static void
734_elm_widget_item_access_info_set(Eo *eo_item EINA_UNUSED,
735 Elm_Widget_Item_Data *item,
736 const char *txt)
737{
738 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
739 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
740
741 eina_stringshare_del(item->access_info);
742 if (!txt) item->access_info = NULL;
743 else item->access_info = eina_stringshare_add(txt);
744}
745
746EOLIAN static Evas_Object*
747_elm_widget_item_access_object_get(const Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
748{
749 return item->access_obj;
750}
751
752static Elm_Translate_String_Data *
753_translate_string_data_get(Eina_Inlist *translate_strings, const char *part)
754{
755 Elm_Translate_String_Data *ts;
756 Eina_Stringshare *str;
757
758 if (!translate_strings) return NULL;
759
760 str = eina_stringshare_add(part);
761 EINA_INLIST_FOREACH(translate_strings, ts)
762 {
763 if (ts->id == str) break;
764 }
765
766 eina_stringshare_del(str);
767
768 return ts;
769}
770
771static Elm_Translate_String_Data *
772_part_text_translatable_set(Eina_Inlist **translate_strings, const char *part, Eina_Bool translatable, Eina_Bool preset)
773{
774 Eina_Inlist *t;
775 Elm_Translate_String_Data *ts;
776 t = *translate_strings;
777 ts = _translate_string_data_get(t, part);
778
779 if (translatable)
780 {
781 if (!ts)
782 {
783 ts = ELM_NEW(Elm_Translate_String_Data);
784 if (!ts) return NULL;
785
786 ts->id = eina_stringshare_add(part);
787 t = eina_inlist_append(t, (Eina_Inlist*) ts);
788 }
789 if (preset) ts->preset = EINA_TRUE;
790 }
791 //Delete this exist one if this part has been not preset.
792 //see elm_widget_part_text_translatable_set()
793 else if (ts && ((preset) || (!ts->preset)))
794 {
795 t = eina_inlist_remove(t, EINA_INLIST_GET(ts));
796 eina_stringshare_del(ts->id);
797 eina_stringshare_del(ts->domain);
798 eina_stringshare_del(ts->string);
799 ELM_SAFE_FREE(ts, free);
800 }
801
802 *translate_strings = t;
803
804 return ts;
805}
806
807EOLIAN static void
808_elm_widget_item_domain_translatable_part_text_set(Eo *eo_item EINA_UNUSED,
809 Elm_Widget_Item_Data *item,
810 const char *part,
811 const char *domain,
812 const char *label)
813{
814 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
815 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
816 Elm_Translate_String_Data *ts;
817
818 if (!label)
819 {
820 _part_text_translatable_set(&item->translate_strings, part, EINA_FALSE,
821 EINA_FALSE);
822 }
823 else
824 {
825 ts = _part_text_translatable_set(&item->translate_strings, part,
826 EINA_TRUE, EINA_FALSE);
827 if (!ts) return;
828 if (!ts->string) ts->string = eina_stringshare_add(label);
829 else eina_stringshare_replace(&ts->string, label);
830 if (!ts->domain) ts->domain = eina_stringshare_add(domain);
831 else eina_stringshare_replace(&ts->domain, domain);
832#ifdef HAVE_GETTEXT
833 if (label[0]) label = dgettext(domain, label);
834#endif
835 }
836 item->on_translate = EINA_TRUE;
837 elm_wdg_item_part_text_set(item->eo_obj, part, label);
838 item->on_translate = EINA_FALSE;
839}
840
841EOLIAN static const char *
842_elm_widget_item_translatable_part_text_get(const Eo *eo_item EINA_UNUSED,
843 Elm_Widget_Item_Data *item,
844 const char *part)
845{
846 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
847 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item, NULL);
848
849 Elm_Translate_String_Data *ts;
850 ts = _translate_string_data_get(item->translate_strings, part);
851 if (ts) return ts->string;
852 return NULL;
853}
854
855EOLIAN static void
856_elm_widget_item_translate(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
857{
858 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
859 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
860
861#ifdef HAVE_GETTEXT
862 Elm_Translate_String_Data *ts;
863 EINA_INLIST_FOREACH(item->translate_strings, ts)
864 {
865 if (!ts->string) continue;
866 const char *s = dgettext(ts->domain, ts->string);
867 item->on_translate = EINA_TRUE;
868 elm_wdg_item_part_text_set(item->eo_obj, ts->id, s);
869 item->on_translate = EINA_FALSE;
870 }
871#endif
872}
873
874EOLIAN static void
875_elm_widget_item_domain_part_text_translatable_set(Eo *eo_item EINA_UNUSED,
876 Elm_Widget_Item_Data *item,
877 const char *part,
878 const char *domain,
879 Eina_Bool translatable)
880{
881 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
882 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
883 Elm_Translate_String_Data *ts;
884 const char *text;
885
886 ts = _part_text_translatable_set(&item->translate_strings, part,
887 translatable, EINA_TRUE);
888 if (!ts) return;
889 if (!ts->domain) ts->domain = eina_stringshare_add(domain);
890 else eina_stringshare_replace(&ts->domain, domain);
891
892 text = elm_wdg_item_part_text_get(item->eo_obj, part);
893
894 if (!text || !text[0]) return;
895
896 if (!ts->string) ts->string = eina_stringshare_add(text);
897
898//Try to translate text since we don't know the text is already translated.
899#ifdef HAVE_GETTEXT
900 text = dgettext(domain, text);
901#endif
902 item->on_translate = EINA_TRUE;
903 elm_wdg_item_part_text_set(item->eo_obj, part, text);
904 item->on_translate = EINA_FALSE;
905}
906
907EOLIAN static void
908_elm_widget_item_track_cancel(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
909{
910 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
911 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
912
913 if (!item->track_obj) return;
914
915 while (evas_object_ref_get(item->track_obj) > 0)
916 evas_object_unref(item->track_obj);
917
918 evas_object_del(item->track_obj);
919}
920
921static void
922_track_obj_del(void *data, Evas *e, Evas_Object *obj, void *event_info);
923
924static void
925_track_obj_update(Evas_Object *track, Evas_Object *obj)
926{
927 //Geometry
928 Evas_Coord x, y, w, h;
929 evas_object_geometry_get(obj, &x, &y, &w, &h);
930 evas_object_move(track, x, y);
931 evas_object_resize(track, w, h);
932
933 //Visibility
934 if (evas_object_visible_get(obj)) evas_object_show(track);
935 else evas_object_hide(track);
936}
937
938static void
939_track_obj_view_update(void *data, const Efl_Event *event)
940{
941 Elm_Widget_Item_Data *item = data;
942 _track_obj_update(item->track_obj, event->object);
943}
944
945static void
946_track_obj_view_del(void *data, const Efl_Event *event);
947
948EFL_CALLBACKS_ARRAY_DEFINE(tracker_callbacks,
949 { EFL_GFX_EVENT_RESIZE, _track_obj_view_update },
950 { EFL_GFX_EVENT_MOVE, _track_obj_view_update },
951 { EFL_GFX_EVENT_SHOW, _track_obj_view_update },
952 { EFL_GFX_EVENT_HIDE, _track_obj_view_update },
953 { EFL_EVENT_DEL, _track_obj_view_del });
954
955static void
956_track_obj_view_del(void *data, const Efl_Event *event EINA_UNUSED)
957{
958 Elm_Widget_Item_Data *item = data;
959
960 while (evas_object_ref_get(item->track_obj) > 0)
961 evas_object_unref(item->track_obj);
962
963 evas_object_event_callback_del(item->track_obj, EVAS_CALLBACK_DEL,
964 _track_obj_del);
965 evas_object_del(item->track_obj);
966 item->track_obj = NULL;
967}
968
969static void
970_track_obj_del(void *data, Evas *e EINA_UNUSED,
971 Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
972{
973 Elm_Widget_Item_Data *item = data;
974 item->track_obj = NULL;
975
976 if (!item->view) return;
977
978 efl_event_callback_array_del(item->view, tracker_callbacks(), item);
979}
980
981EOLIAN static Evas_Object *
982_elm_widget_item_track(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
983{
984 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
985 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item, NULL);
986
987 if (item->track_obj)
988 {
989 evas_object_ref(item->track_obj);
990 return item->track_obj;
991 }
992
993 if (!item->view)
994 {
995 WRN("view obj of the item(%p) is invalid. Please make sure the view obj is created!", item);
996 return NULL;
997 }
998
999 Evas_Object *track =
1000 evas_object_rectangle_add(evas_object_evas_get(item->widget));
1001 evas_object_color_set(track, 0, 0, 0, 0);
1002 evas_object_pass_events_set(track, EINA_TRUE);
1003 _track_obj_update(track, item->view);
1004 evas_object_event_callback_add(track, EVAS_CALLBACK_DEL, _track_obj_del,
1005 item);
1006
1007 efl_event_callback_array_add(item->view, tracker_callbacks(), item);
1008
1009 evas_object_ref(track);
1010
1011 item->track_obj = track;
1012
1013 return track;
1014}
1015
1016EOLIAN static void
1017_elm_widget_item_untrack(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
1018{
1019 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
1020 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
1021
1022 if (!item->track_obj) return;
1023 evas_object_unref(item->track_obj);
1024
1025 if (evas_object_ref_get(item->track_obj) == 0)
1026 evas_object_del(item->track_obj);
1027}
1028
1029EOLIAN static int
1030_elm_widget_item_track_get(const Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
1031{
1032 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, 0);
1033 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item, 0);
1034
1035 if (!item->track_obj) return 0;
1036 return evas_object_ref_get(item->track_obj);
1037}
1038
1039/**
1040 * @internal
1041 *
1042 * Set the function to notify when item is being deleted.
1043 *
1044 * This function will complain if there was a callback set already,
1045 * however it will set the new one.
1046 *
1047 * The callback will be called from elm_widget_item_pre_notify_del()
1048 * or elm_widget_item_del() will be called with:
1049 * - data: the Elm_Widget_Item::data value.
1050 * - obj: the Elm_Widget_Item::widget evas object.
1051 * - event_info: the item being deleted.
1052 *
1053 * @param item a valid #Elm_Widget_Item to be notified
1054 * @see elm_widget_item_del_cb_set() convenience macro.
1055 * @ingroup Widget
1056 */
1057EOLIAN static void
1058_elm_widget_item_del_cb_set(Eo *eo_item EINA_UNUSED,
1059 Elm_Widget_Item_Data *item,
1060 Evas_Smart_Cb func)
1061{
1062 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
1063 ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item);
1064
1065 if ((item->del_func) && (item->del_func != func))
1066 WRN("You're replacing a previously set del_cb %p of item %p with %p",
1067 item->del_func, item->eo_obj, func);
1068
1069 item->del_func = func;
1070}
1071
1072/**
1073 * @internal
1074 *
1075 * Set the content to be shown in the tooltip item
1076 *
1077 * Setup the tooltip to item. The item can have only one tooltip,
1078 * so any previous tooltip data is removed. @p func(with @p data) will
1079 * be called every time that need show the tooltip and it should
1080 * return a valid Evas_Object. This object is then managed fully by
1081 * tooltip system and is deleted when the tooltip is gone.
1082 *
1083 * @param item the widget item being attached a tooltip.
1084 * @param func the function used to create the tooltip contents.
1085 * @param data what to provide to @a func as callback data/context.
1086 * @param del_cb called when data is not needed anymore, either when
1087 * another callback replaces @func, the tooltip is unset with
1088 * elm_widget_item_tooltip_unset() or the owner @a item
1089 * dies. This callback receives as the first parameter the
1090 * given @a data, and @c event_info is the item.
1091 *
1092 * @ingroup Widget
1093 */
1094EOLIAN static void
1095_elm_widget_item_tooltip_content_cb_set(Eo *eo_item EINA_UNUSED,
1096 Elm_Widget_Item_Data *item,
1097 Elm_Tooltip_Item_Content_Cb func,
1098 const void *data,
1099 Evas_Smart_Cb del_cb)
1100{
1101 Elm_Widget_Item_Tooltip *wit;
1102
1103 ELM_WIDGET_ITEM_CHECK_OR_GOTO(item, error_noitem);
1104 //ELM_WIDGET_ITEM_RETURN_IF_GOTO(item, error_noitem);
1105
1106 if (!func)
1107 {
1108 elm_wdg_item_tooltip_unset(item->eo_obj);
1109 return;
1110 }
1111
1112 wit = ELM_NEW(Elm_Widget_Item_Tooltip);
1113 if (!wit) goto error;
1114 wit->item = item;
1115 wit->func = func;
1116 wit->data = data;
1117 wit->del_cb = del_cb;
1118
1119 elm_object_sub_tooltip_content_cb_set
1120 (item->view, item->widget, _elm_widget_item_tooltip_create, wit,
1121 _elm_widget_item_tooltip_del_cb);
1122
1123 return;
1124
1125error_noitem:
1126 if (del_cb) del_cb((void *)data, NULL, item);
1127 return;
1128error:
1129 if (del_cb) del_cb((void *)data, item->widget, item);
1130}
1131
1132EOLIAN static void
1133_elm_widget_item_access_order_unset(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
1134{
1135 _elm_access_widget_item_access_order_unset(item);
1136}
1137
1138EOLIAN static Evas_Object*
1139_elm_widget_item_access_register(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
1140{
1141 _elm_access_widget_item_register(item);
1142 return item->access_obj;
1143}
1144
1145EOLIAN static void
1146_elm_widget_item_access_unregister(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item)
1147{
1148 _elm_access_widget_item_unregister(item);
1149}
1150
1151EOLIAN static Eina_Bool
1152_elm_widget_item_del_pre(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item EINA_UNUSED)
1153{
1154 return EINA_TRUE;
1155}
1156
1157EOLIAN static Evas_Object *
1158_elm_widget_item_focus_next_object_get(const Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item, Elm_Focus_Direction dir)
1159{
1160 Evas_Object *ret = NULL;
1161
1162 if (dir == ELM_FOCUS_PREVIOUS)
1163 ret = item->focus_previous;
1164 else if (dir == ELM_FOCUS_NEXT)
1165 ret = item->focus_next;
1166 else if (dir == ELM_FOCUS_UP)
1167 ret = item->focus_up;
1168 else if (dir == ELM_FOCUS_DOWN)
1169 ret = item->focus_down;
1170 else if (dir == ELM_FOCUS_RIGHT)
1171 ret = item->focus_right;
1172 else if (dir == ELM_FOCUS_LEFT)
1173 ret = item->focus_left;
1174
1175 return ret;
1176}
1177
1178EOLIAN static void
1179_elm_widget_item_focus_next_object_set(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item, Evas_Object *next, Elm_Focus_Direction dir)
1180{
1181 if (dir == ELM_FOCUS_PREVIOUS)
1182 item->focus_previous = next;
1183 else if (dir == ELM_FOCUS_NEXT)
1184 item->focus_next = next;
1185 else if (dir == ELM_FOCUS_UP)
1186 item->focus_up = next;
1187 else if (dir == ELM_FOCUS_DOWN)
1188 item->focus_down = next;
1189 else if (dir == ELM_FOCUS_RIGHT)
1190 item->focus_right = next;
1191 else if (dir == ELM_FOCUS_LEFT)
1192 item->focus_left = next;
1193}
1194
1195EOLIAN static Elm_Object_Item*
1196_elm_widget_item_focus_next_item_get(const Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item, Elm_Focus_Direction dir)
1197{
1198 Elm_Object_Item *ret = NULL;
1199
1200 if (dir == ELM_FOCUS_PREVIOUS)
1201 ret = item->item_focus_previous;
1202 else if (dir == ELM_FOCUS_NEXT)
1203 ret = item->item_focus_next;
1204 else if (dir == ELM_FOCUS_UP)
1205 ret = item->item_focus_up;
1206 else if (dir == ELM_FOCUS_DOWN)
1207 ret = item->item_focus_down;
1208 else if (dir == ELM_FOCUS_RIGHT)
1209 ret = item->item_focus_right;
1210 else if (dir == ELM_FOCUS_LEFT)
1211 ret = item->item_focus_left;
1212
1213 return ret;
1214}
1215
1216EOLIAN static void
1217_elm_widget_item_focus_next_item_set(Eo *eo_item EINA_UNUSED, Elm_Widget_Item_Data *item, Elm_Object_Item *next_item, Elm_Focus_Direction dir)
1218{
1219 if (dir == ELM_FOCUS_PREVIOUS)
1220 item->item_focus_previous = next_item;
1221 else if (dir == ELM_FOCUS_NEXT)
1222 item->item_focus_next = next_item;
1223 else if (dir == ELM_FOCUS_UP)
1224 item->item_focus_up = next_item;
1225 else if (dir == ELM_FOCUS_DOWN)
1226 item->item_focus_down = next_item;
1227 else if (dir == ELM_FOCUS_RIGHT)
1228 item->item_focus_right = next_item;
1229 else if (dir == ELM_FOCUS_LEFT)
1230 item->item_focus_left = next_item;
1231}
1232
1233// implements
1234static void
1235_efl_del_cb(void *data EINA_UNUSED, const Efl_Event *event)
1236{
1237 Elm_Widget_Item_Data *item = efl_data_scope_get(event->object, ELM_WIDGET_ITEM_CLASS);
1238 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
1239 if (item->del_func)
1240 item->del_func((void *) WIDGET_ITEM_DATA_GET(event->object), item->widget, item->eo_obj);
1241}
1242
1243/**
1244 * @internal
1245 *
1246 * Allocate a new Elm_Widget_Item-derived structure.
1247 *
1248 * The goal of this structure is to provide common ground for actions
1249 * that a widget item have, such as the owner widget, callback to
1250 * notify deletion, data pointer and maybe more.
1251 *
1252 * @param widget the owner widget that holds this item, must be an elm_widget!
1253 * @param alloc_size any number greater than sizeof(Elm_Widget_Item) that will
1254 * be used to allocate memory.
1255 *
1256 * @return allocated memory that is already zeroed out, or NULL on errors.
1257 *
1258 * @see elm_widget_item_new() convenience macro.
1259 * @see elm_widget_item_del() to release memory.
1260 * @ingroup Widget
1261 */
1262EOLIAN static Eo *
1263_elm_widget_item_efl_object_constructor(Eo *eo_item, Elm_Widget_Item_Data *item)
1264{
1265 Evas_Object *widget;
1266 widget = efl_parent_get(eo_item);
1267
1268 if (!elm_widget_is(widget))
1269 {
1270 ERR("Failed");
1271 return NULL;
1272 }
1273
1274 eo_item = efl_constructor(efl_super(eo_item, ELM_WIDGET_ITEM_CLASS));
1275
1276 EINA_MAGIC_SET(item, ELM_WIDGET_ITEM_MAGIC);
1277
1278 item->widget = widget;
1279 item->eo_obj = eo_item;
1280 efl_event_callback_add(eo_item, EFL_EVENT_DEL, _efl_del_cb, NULL);
1281
1282 return eo_item;
1283}
1284
1285EOLIAN static void
1286_elm_widget_item_efl_object_destructor(Eo *eo_item, Elm_Widget_Item_Data *item)
1287{
1288 Elm_Translate_String_Data *ts;
1289
1290 ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
1291
1292 evas_object_del(item->view);
1293
1294 eina_stringshare_del(item->access_info);
1295 eina_stringshare_del(item->accessible_name);
1296
1297 while (item->signals)
1298 _elm_widget_item_signal_callback_list_get(item, item->signals);
1299
1300 while (item->translate_strings)
1301 {
1302 ts = EINA_INLIST_CONTAINER_GET(item->translate_strings,
1303 Elm_Translate_String_Data);
1304 eina_stringshare_del(ts->id);
1305 eina_stringshare_del(ts->domain);
1306 eina_stringshare_del(ts->string);
1307 item->translate_strings = eina_inlist_remove(item->translate_strings,
1308 item->translate_strings);
1309 free(ts);
1310 }
1311 eina_hash_free(item->labels);
1312
1313 elm_interface_atspi_accessible_removed(eo_item);
1314
1315 EINA_MAGIC_SET(item, EINA_MAGIC_NONE);
1316
1317 efl_destructor(efl_super(eo_item, ELM_WIDGET_ITEM_CLASS));
1318}
1319
1320static Eina_Bool
1321_item_onscreen_is(Elm_Object_Item *item)
1322{
1323 Eina_Rectangle r1, r2;
1324 Elm_Widget_Item_Data *id = efl_data_scope_get(item, ELM_WIDGET_ITEM_CLASS);
1325 if (!id || !id->view) return EINA_FALSE;
1326
1327 if (!evas_object_visible_get(id->view))
1328 return EINA_FALSE;
1329
1330 if (!_elm_widget_onscreen_is(id->widget))
1331 return EINA_FALSE;
1332
1333 evas_object_geometry_get(id->view, &r1.x, &r1.y, &r1.w, &r1.h);
1334 if (eina_rectangle_is_empty(&r1))
1335 return EINA_FALSE;
1336
1337 evas_object_geometry_get(id->widget, &r2.x, &r2.y, &r2.w, &r2.h);
1338 if (!eina_rectangles_intersect(&r1, &r2))
1339 return EINA_FALSE;
1340
1341 return EINA_TRUE;
1342}
1343
1344EOLIAN static Elm_Atspi_State_Set
1345_elm_widget_item_elm_interface_atspi_accessible_state_set_get(Eo *eo_item,
1346 Elm_Widget_Item_Data *item EINA_UNUSED)
1347{
1348 Elm_Atspi_State_Set states = 0;
1349
1350 STATE_TYPE_SET(states, ELM_ATSPI_STATE_FOCUSABLE);
1351
1352 if (elm_object_item_focus_get(eo_item))
1353 STATE_TYPE_SET(states, ELM_ATSPI_STATE_FOCUSED);
1354 if (!elm_object_item_disabled_get(eo_item))
1355 {
1356 STATE_TYPE_SET(states, ELM_ATSPI_STATE_ENABLED);
1357 STATE_TYPE_SET(states, ELM_ATSPI_STATE_SENSITIVE);
1358 STATE_TYPE_SET(states, ELM_ATSPI_STATE_VISIBLE);
1359 }
1360 if (_item_onscreen_is(eo_item))
1361 STATE_TYPE_SET(states, ELM_ATSPI_STATE_SHOWING);
1362
1363 return states;
1364}
1365
1366EOLIAN static void
1367_elm_widget_item_elm_interface_atspi_component_extents_get(Eo *obj EINA_UNUSED, Elm_Widget_Item_Data *sd EINA_UNUSED, Eina_Bool screen_coords, int *x, int *y, int *w, int *h)
1368{
1369 int ee_x, ee_y;
1370
1371 if (!sd->view)
1372 {
1373 if (x) *x = -1;
1374 if (y) *y = -1;
1375 if (w) *w = -1;
1376 if (h) *h = -1;
1377 return;
1378 }
1379
1380 evas_object_geometry_get(sd->view, x, y, w, h);
1381 if (screen_coords)
1382 {
1383 Ecore_Evas *ee = ecore_evas_ecore_evas_get(evas_object_evas_get(sd->view));
1384 if (!ee) return;
1385 ecore_evas_geometry_get(ee, &ee_x, &ee_y, NULL, NULL);
1386 if (x) *x += ee_x;
1387 if (y) *y += ee_y;
1388 }
1389}
1390
1391EOLIAN static Eina_Bool
1392_elm_widget_item_elm_interface_atspi_component_extents_set(Eo *obj EINA_UNUSED, Elm_Widget_Item_Data *sd EINA_UNUSED, Eina_Bool screen_coords EINA_UNUSED, int x EINA_UNUSED, int y EINA_UNUSED, int w EINA_UNUSED, int h EINA_UNUSED)
1393{
1394 return EINA_FALSE;
1395}
1396
1397EOLIAN static int
1398_elm_widget_item_elm_interface_atspi_component_layer_get(Eo *obj EINA_UNUSED, Elm_Widget_Item_Data *sd EINA_UNUSED)
1399{
1400 if (!sd->view)
1401 return -1;
1402 return evas_object_layer_get(sd->view);
1403}
1404
1405EOLIAN static Eina_Bool
1406_elm_widget_item_elm_interface_atspi_component_focus_grab(Eo *obj EINA_UNUSED, Elm_Widget_Item_Data *_pd EINA_UNUSED)
1407{
1408 elm_object_item_focus_set(obj, EINA_TRUE);
1409 return elm_object_item_focus_get(obj);
1410}
1411
1412EOLIAN static double
1413_elm_widget_item_elm_interface_atspi_component_alpha_get(Eo *obj EINA_UNUSED, Elm_Widget_Item_Data *sd EINA_UNUSED)
1414{
1415 int alpha;
1416
1417 if (!sd->view) return -1.0;
1418 evas_object_color_get(sd->view, NULL, NULL, NULL, &alpha);
1419 return (double)alpha / 255.0;
1420}
1421
1422#include "elm_widget_item.eo.c"