/* Try use hook */
if (_elm_widget_focus_chain_manager_is(obj))
- return sd->api->focus_next(obj, dir, next);
+ {
+ Eina_Bool ret;
+ ret = sd->api->focus_next(obj, dir, next);
+ if (!ret && elm_widget_focus_get(obj))
+ {
+ Evas_Object *o = NULL;
+ if (dir == ELM_FOCUS_PREVIOUS)
+ o = sd->focus_previous;
+ else if (dir == ELM_FOCUS_NEXT)
+ o = sd->focus_next;
+ else if (dir == ELM_FOCUS_UP)
+ o = sd->focus_up;
+ else if (dir == ELM_FOCUS_DOWN)
+ o = sd->focus_down;
+ else if (dir == ELM_FOCUS_RIGHT)
+ o = sd->focus_right;
+ else if (dir == ELM_FOCUS_LEFT)
+ o = sd->focus_left;
+
+ if (o)
+ {
+ *next = o;
+ return EINA_TRUE;
+ }
+ }
+ else
+ return ret;
+ }
if (!elm_widget_can_focus_get(obj))
return EINA_FALSE;
if (!_elm_access_object_get(obj)) return EINA_FALSE;
}
+ if (elm_widget_focus_get(obj))
+ {
+ if (dir == ELM_FOCUS_PREVIOUS)
+ *next = sd->focus_previous;
+ else if (dir == ELM_FOCUS_NEXT)
+ *next = sd->focus_next;
+ else if (dir == ELM_FOCUS_UP)
+ *next = sd->focus_up;
+ else if (dir == ELM_FOCUS_DOWN)
+ *next = sd->focus_down;
+ else if (dir == ELM_FOCUS_RIGHT)
+ *next = sd->focus_right;
+ else if (dir == ELM_FOCUS_LEFT)
+ *next = sd->focus_left;
+
+ if (*next)
+ return EINA_TRUE;
+ }
/* Return */
*next = (Evas_Object *)obj;
return !ELM_WIDGET_FOCUS_GET(obj);
Evas_Object **next)
{
Eina_List *(*list_next)(const Eina_List *list) = NULL;
+ Evas_Object *focused_object = NULL;
if (!next)
return EINA_FALSE;
if (!items)
return EINA_FALSE;
+ /* When Up, Down, Right, or Left, try direction_get first. */
+ focused_object = elm_widget_focused_object_get(obj);
+ if (focused_object)
+ {
+ if((dir == ELM_FOCUS_UP)
+ || (dir == ELM_FOCUS_DOWN)
+ || (dir == ELM_FOCUS_RIGHT)
+ || (dir == ELM_FOCUS_LEFT))
+ {
+ *next = elm_widget_focus_next_object_get(focused_object, dir);
+ if (*next)
+ return EINA_TRUE;
+ else
+ {
+ Evas_Object *n;
+ double degree;
+ double weight;
+
+ if (dir == ELM_FOCUS_UP) degree = 0.0;
+ else if (dir == ELM_FOCUS_DOWN) degree = 180.0;
+ else if (dir == ELM_FOCUS_RIGHT) degree = 90.0;
+ else if (dir == ELM_FOCUS_LEFT) degree = 270.0;
+
+ if (elm_widget_focus_list_direction_get(obj, focused_object,
+ items, list_data_get,
+ degree, &n, &weight))
+ {
+ *next = n;
+ return EINA_TRUE;
+ }
+ }
+ }
+ }
+
/* Direction */
if (dir == ELM_FOCUS_PREVIOUS)
{
items = eina_list_last(items);
list_next = eina_list_prev;
}
- else if (dir == ELM_FOCUS_NEXT)
+ else if ((dir == ELM_FOCUS_NEXT)
+ || (dir == ELM_FOCUS_UP)
+ || (dir == ELM_FOCUS_DOWN)
+ || (dir == ELM_FOCUS_RIGHT)
+ || (dir == ELM_FOCUS_LEFT))
list_next = eina_list_next;
else
return EINA_FALSE;
*next = tmp;
return EINA_TRUE;
}
+ else if ((dir == ELM_FOCUS_UP)
+ || (dir == ELM_FOCUS_DOWN)
+ || (dir == ELM_FOCUS_RIGHT)
+ || (dir == ELM_FOCUS_LEFT))
+ {
+ if (tmp && elm_widget_focus_get(cur))
+ {
+ *next = tmp;
+ return EINA_FALSE;
+ }
+ }
else if ((tmp) && (!to_focus))
to_focus = tmp;
}
return EINA_FALSE;
}
+
+/**
+ * @internal
+ *
+ * Get next object which was set with specific focus direction.
+ *
+ * Get next object which was set by elm_widget_focus_next_object_set
+ * with specific focus directioin.
+ *
+ * @param obj The widget
+ * @param dir Direction of focus
+ * @return Widget which was registered with sepecific focus direction.
+ *
+ * @ingroup Widget
+ */
+EAPI Evas_Object *
+elm_widget_focus_next_object_get(const Evas_Object *obj, Elm_Focus_Direction dir)
+{
+ API_ENTRY return NULL;
+
+ if (dir == ELM_FOCUS_PREVIOUS)
+ return sd->focus_previous;
+ else if (dir == ELM_FOCUS_NEXT)
+ return sd->focus_next;
+ else if (dir == ELM_FOCUS_UP)
+ return sd->focus_up;
+ else if (dir == ELM_FOCUS_DOWN)
+ return sd->focus_down;
+ else if (dir == ELM_FOCUS_RIGHT)
+ return sd->focus_right;
+ else if (dir == ELM_FOCUS_LEFT)
+ return sd->focus_left;
+
+ return NULL;
+}
+
+/**
+ * @internal
+ *
+ * Set next object with specific focus direction.
+ *
+ * When a widget is set with specific focus direction, this widget will be
+ * the first candidate when finding the next focus object.
+ * Focus next object can be registered with six directions that are previous,
+ * next, up, down, right, and left.
+ *
+ * @param obj The widget
+ * @param next Next focus object
+ * @param dir Direction of focus
+ *
+ * @ingroup Widget
+ */
+EAPI void
+elm_widget_focus_next_object_set(Evas_Object *obj, Evas_Object *next, Elm_Focus_Direction dir)
+{
+ API_ENTRY return;
+
+ if (dir == ELM_FOCUS_PREVIOUS)
+ sd->focus_previous = next;
+ else if (dir == ELM_FOCUS_NEXT)
+ sd->focus_next = next;
+ else if (dir == ELM_FOCUS_UP)
+ sd->focus_up = next;
+ else if (dir == ELM_FOCUS_DOWN)
+ sd->focus_down = next;
+ else if (dir == ELM_FOCUS_RIGHT)
+ sd->focus_right = next;
+ else if (dir == ELM_FOCUS_LEFT)
+ sd->focus_left = next;
+}
+
+
EAPI Eina_Bool
elm_widget_highlight_get(const Evas_Object *obj)
{
return NULL;
}
-EAPI void
-elm_widget_domain_translatable_text_part_set(Evas_Object *obj,
- const char *part,
- const char *domain,
- const char *label)
+static Eina_Bool
+_translatable_part_text_set(Eina_List **translate_strings, const char *part, const char *domain, const char *label)
{
const char *str;
- Eina_List *l;
+ Eina_List *t, *l;
Elm_Translate_String_Data *ts = NULL;
- API_ENTRY return;
+ t = *translate_strings;
str = eina_stringshare_add(part);
- EINA_LIST_FOREACH(sd->translate_strings, l, ts)
- if (ts->id == str)
- break;
- else
- ts = NULL;
+ EINA_LIST_FOREACH(t, l, ts)
+ {
+ if (ts->id == str) break;
+ else ts = NULL;
+ }
if (!ts && !label)
eina_stringshare_del(str);
else if (!ts)
{
ts = malloc(sizeof(Elm_Translate_String_Data));
- if (!ts) return;
+ if (!ts) return EINA_FALSE;
ts->id = str;
ts->domain = eina_stringshare_add(domain);
ts->string = eina_stringshare_add(label);
- sd->translate_strings = eina_list_append(sd->translate_strings, ts);
+ t = eina_list_append(t, ts);
}
else
{
}
else
{
- sd->translate_strings = eina_list_remove_list(
- sd->translate_strings, l);
+ t = eina_list_remove_list(t, l);
eina_stringshare_del(ts->id);
eina_stringshare_del(ts->domain);
eina_stringshare_del(ts->string);
eina_stringshare_del(str);
}
+ *translate_strings = t;
+ return EINA_TRUE;
+}
+
+EAPI void
+elm_widget_domain_translatable_part_text_set(Evas_Object *obj,
+ const char *part,
+ const char *domain,
+ const char *label)
+{
+ API_ENTRY return;
+
+ if (!_translatable_part_text_set(&sd->translate_strings, part, domain,
+ label)) return;
#ifdef HAVE_GETTEXT
if (label && label[0])
label = dgettext(domain, label);
elm_widget_text_part_set(obj, part, label);
}
-EAPI const char *
-elm_widget_translatable_text_part_get(const Evas_Object *obj,
- const char *part)
+static const char *
+_translatable_part_text_get(Eina_List *translate_strings, const char *part)
{
- const char *str, *ret = NULL;
- Eina_List *l;
Elm_Translate_String_Data *ts;
- API_ENTRY return NULL;
+ const char*ret = NULL, *str;
+ Eina_List *l;
str = eina_stringshare_add(part);
- EINA_LIST_FOREACH(sd->translate_strings, l, ts)
+ EINA_LIST_FOREACH(translate_strings, l, ts)
if (ts->id == str)
{
ret = ts->string;
break;
}
eina_stringshare_del(str);
+
return ret;
}
+EAPI const char *
+elm_widget_translatable_part_text_get(const Evas_Object *obj,
+ const char *part)
+{
+ API_ENTRY return NULL;
+ return _translatable_part_text_get(sd->translate_strings, part);
+}
+
EAPI void
elm_widget_translate(Evas_Object *obj)
{
{
API_ENTRY return EINA_FALSE;
char buf[128];
- int ret;
if (!_elm_theme_object_set(obj, edj, wname, welement, wstyle))
return EINA_FALSE;
if (sd->orient_mode != -1)
{
- snprintf(buf, sizeof(buf), "elm,state,orient,%d", ret);
+ snprintf(buf, sizeof(buf), "elm,state,orient,%d", sd->orient_mode);
elm_widget_signal_emit(obj, buf, "elm");
}
EAPI void
_elm_widget_item_free(Elm_Widget_Item *item)
{
+ Elm_Translate_String_Data *ts;
+ Elm_Widget_Item_Signal_Data *wisd;
+
ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
if (item->del_func)
if (item->access_info)
eina_stringshare_del(item->access_info);
+ EINA_LIST_FREE(item->signals, wisd)
+ {
+ eina_stringshare_del(wisd->emission);
+ eina_stringshare_del(wisd->source);
+ free(wisd);
+ }
+
+ EINA_LIST_FREE(item->translate_strings, ts)
+ {
+ eina_stringshare_del(ts->id);
+ eina_stringshare_del(ts->domain);
+ eina_stringshare_del(ts->string);
+ free(ts);
+ }
+
EINA_MAGIC_SET(item, EINA_MAGIC_NONE);
free(item);
}
//Widget item delete callback
if (item->del_pre_func)
- if (item->del_pre_func((Elm_Object_Item *)item))
- _elm_widget_item_free(item);
+ {
+ if (item->del_pre_func((Elm_Object_Item *)item))
+ _elm_widget_item_free(item);
+ }
+ else
+ _elm_widget_item_free(item);
}
/**
item->disable_func = func;
}
+EAPI void
+_elm_widget_item_domain_translatable_part_text_set(Elm_Widget_Item *item,
+ const char *part,
+ const char *domain,
+ const char *label)
+{
+ ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
+
+ if (!_translatable_part_text_set(&item->translate_strings, part, domain,
+ label)) return;
+#ifdef HAVE_GETTEXT
+ if (label && label[0])
+ label = dgettext(domain, label);
+#endif
+ _elm_widget_item_part_text_set(item, part, label);
+}
+
+EAPI const char *
+_elm_widget_item_translatable_part_text_get(const Elm_Widget_Item *item,
+ const char *part)
+{
+ ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
+ return _translatable_part_text_get(item->translate_strings, part);
+}
+
typedef struct _Elm_Widget_Item_Tooltip Elm_Widget_Item_Tooltip;
struct _Elm_Widget_Item_Tooltip
item->signal_emit_func = func;
}
+
+static void
+_elm_widget_item_signal_cb(void *data, Evas_Object *obj __UNUSED__, const char *emission,
+ const char *source)
+{
+ Elm_Widget_Item_Signal_Data *wisd = data;
+ wisd->func(wisd->data, wisd->item, emission, source);
+}
+
+EAPI void
+_elm_widget_item_signal_callback_add(Elm_Widget_Item *item,
+ const char *emission,
+ const char *source,
+ Elm_Widget_Item_Signal_Cb func,
+ void *data)
+{
+ ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
+ EINA_SAFETY_ON_NULL_RETURN(func);
+
+ Elm_Widget_Item_Signal_Data *wisd;
+
+ wisd = malloc(sizeof(Elm_Widget_Item_Signal_Data));
+ if (!wisd) return;
+
+ wisd->item = item;
+ wisd->func = func;
+ wisd->data = data;
+ wisd->emission = eina_stringshare_add(emission);
+ wisd->source = eina_stringshare_add(source);
+
+ if (_elm_widget_is(item->view))
+ elm_object_signal_callback_add(item->view, emission, source, _elm_widget_item_signal_cb, wisd);
+ else if (!strcmp(evas_object_type_get(item->view), "edje"))
+ edje_object_signal_callback_add(item->view, emission, source, _elm_widget_item_signal_cb, wisd);
+ else
+ {
+ WRN("The %s widget item doesn't support signal callback add!",
+ evas_object_type_get(item->widget));
+ free(wisd);
+ return;
+ }
+
+ item->signals = eina_list_append(item->signals, wisd);
+}
+
+EAPI void *
+_elm_widget_item_signal_callback_del(Elm_Widget_Item *item,
+ const char *emission,
+ const char *source,
+ Elm_Widget_Item_Signal_Cb func)
+{
+ ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(func, NULL);
+
+ Elm_Widget_Item_Signal_Data *wisd;
+ Eina_List *l;
+ void *data = NULL;
+
+ EINA_LIST_FOREACH(item->signals, l, wisd)
+ {
+ if ((wisd->func == func) && !strcmp(wisd->emission, emission) &&
+ !strcmp(wisd->source, source))
+ {
+ item->signals = eina_list_remove_list(item->signals, l);
+ eina_stringshare_del(wisd->emission);
+ eina_stringshare_del(wisd->source);
+ data = wisd->data;
+
+ if (_elm_widget_is(item->view))
+ elm_object_signal_callback_del(item->view, emission, source,
+ _elm_widget_item_signal_cb);
+ else if (!strcmp(evas_object_type_get(item->view), "edje"))
+ edje_object_signal_callback_del_full(item->view, emission,
+ source,
+ _elm_widget_item_signal_cb,
+ data);
+ }
+ }
+
+ return data;
+}
+
EAPI void
_elm_widget_item_access_info_set(Elm_Widget_Item *item,
const char *txt)