2013-04-25 22:13:00 -07:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "elementary_config.h"
|
|
|
|
#endif
|
|
|
|
|
2014-10-17 08:56:11 -07:00
|
|
|
#define ELM_INTERFACE_ATSPI_ACCESSIBLE_PROTECTED
|
|
|
|
|
2014-09-27 22:14:10 -07:00
|
|
|
#define ELM_WIDGET_ITEM_PROTECTED
|
2011-04-07 09:44:54 -07:00
|
|
|
#include <Elementary.h>
|
2013-04-25 22:13:00 -07:00
|
|
|
|
2011-04-07 09:44:54 -07:00
|
|
|
#include "elm_priv.h"
|
2012-08-01 14:02:49 -07:00
|
|
|
#include "elm_widget_segment_control.h"
|
2011-04-07 09:44:54 -07:00
|
|
|
|
2014-06-03 03:35:28 -07:00
|
|
|
#define MY_CLASS ELM_SEGMENT_CONTROL_CLASS
|
2012-11-25 22:32:53 -08:00
|
|
|
|
2013-11-07 03:44:22 -08:00
|
|
|
#define MY_CLASS_NAME "Elm_Segment_Control"
|
|
|
|
#define MY_CLASS_NAME_LEGACY "elm_segment_control"
|
2011-04-07 09:44:54 -07:00
|
|
|
|
2011-04-21 17:42:32 -07:00
|
|
|
static const char SIG_CHANGED[] = "changed";
|
2012-05-03 15:43:26 -07:00
|
|
|
static const Evas_Smart_Cb_Description _smart_callbacks[] = {
|
2011-04-21 17:42:32 -07:00
|
|
|
{SIG_CHANGED, ""},
|
2014-01-23 03:07:20 -08:00
|
|
|
{SIG_WIDGET_LANG_CHANGED, ""}, /**< handled by elm_widget */
|
2014-02-07 21:05:06 -08:00
|
|
|
{SIG_WIDGET_ACCESS_CHANGED, ""}, /**< handled by elm_widget */
|
2011-04-21 17:42:32 -07:00
|
|
|
{NULL, NULL}
|
|
|
|
};
|
|
|
|
|
2014-03-26 02:04:37 -07:00
|
|
|
EOLIAN static Eina_Bool
|
|
|
|
_elm_segment_control_elm_widget_translate(Eo *obj EINA_UNUSED, Elm_Segment_Control_Data *sd)
|
2013-04-23 04:30:15 -07:00
|
|
|
{
|
2014-09-27 22:14:10 -07:00
|
|
|
Elm_Object_Item *it;
|
2013-04-23 04:30:15 -07:00
|
|
|
Eina_List *l;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(sd->items, l, it)
|
2014-08-19 00:52:24 -07:00
|
|
|
eo_do(it, elm_wdg_item_translate());
|
2013-04-23 04:30:15 -07:00
|
|
|
|
2014-04-03 08:51:11 -07:00
|
|
|
eo_do_super(obj, MY_CLASS, elm_obj_widget_translate());
|
2014-01-23 03:20:43 -08:00
|
|
|
|
2014-03-26 02:04:37 -07:00
|
|
|
return EINA_TRUE;
|
2013-04-23 04:30:15 -07:00
|
|
|
}
|
|
|
|
|
2014-03-26 02:04:37 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_segment_control_elm_layout_sizing_eval(Eo *obj, Elm_Segment_Control_Data *sd)
|
2011-04-07 09:44:54 -07:00
|
|
|
{
|
|
|
|
Evas_Coord minw = -1, minh = -1;
|
|
|
|
Evas_Coord w, h;
|
2012-05-03 15:43:26 -07:00
|
|
|
int item_count;
|
2011-04-07 09:44:54 -07:00
|
|
|
|
2013-10-05 01:15:37 -07:00
|
|
|
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
|
2011-04-07 09:44:54 -07:00
|
|
|
|
2012-05-03 15:43:26 -07:00
|
|
|
item_count = eina_list_count(sd->items);
|
|
|
|
|
|
|
|
elm_coords_finger_size_adjust(item_count, &minw, 1, &minh);
|
|
|
|
edje_object_size_min_restricted_calc
|
2012-11-25 22:32:53 -08:00
|
|
|
(wd->resize_obj, &minw, &minh, minw, minh);
|
2011-04-07 09:44:54 -07:00
|
|
|
|
|
|
|
evas_object_size_hint_min_get(obj, &w, &h);
|
2012-05-03 15:43:26 -07:00
|
|
|
|
2011-04-07 09:44:54 -07:00
|
|
|
if (w > minw) minw = w;
|
|
|
|
if (h > minh) minh = h;
|
2012-05-03 15:43:26 -07:00
|
|
|
|
2011-04-07 09:44:54 -07:00
|
|
|
evas_object_size_hint_min_set(obj, minw, minh);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-09-27 22:14:10 -07:00
|
|
|
_item_free(Elm_Segment_Control_Item_Data *it)
|
2012-05-03 15:43:26 -07:00
|
|
|
{
|
2012-07-01 18:39:10 -07:00
|
|
|
ELM_SEGMENT_CONTROL_DATA_GET(WIDGET(it), sd);
|
2012-05-03 15:43:26 -07:00
|
|
|
|
|
|
|
if (sd->selected_item == it) sd->selected_item = NULL;
|
2014-09-27 22:14:10 -07:00
|
|
|
if (sd->items) sd->items = eina_list_remove(sd->items, EO_OBJ(it));
|
2012-05-03 15:43:26 -07:00
|
|
|
|
2014-01-21 17:12:44 -08:00
|
|
|
evas_object_del(it->icon);
|
|
|
|
eina_stringshare_del(it->label);
|
2012-05-03 15:43:26 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-03-26 02:04:37 -07:00
|
|
|
_position_items(Elm_Segment_Control_Data *sd)
|
2011-04-07 09:44:54 -07:00
|
|
|
{
|
2012-05-03 15:43:26 -07:00
|
|
|
Eina_List *l;
|
|
|
|
Eina_Bool rtl;
|
|
|
|
int item_count;
|
2014-09-27 22:14:10 -07:00
|
|
|
Elm_Object_Item *eo_item;
|
2012-05-03 15:43:26 -07:00
|
|
|
int bx, by, bw, bh, pos;
|
2013-10-05 01:15:37 -07:00
|
|
|
ELM_WIDGET_DATA_GET_OR_RETURN(sd->obj, wd);
|
2012-11-25 22:32:53 -08:00
|
|
|
|
2012-05-03 15:43:26 -07:00
|
|
|
item_count = eina_list_count(sd->items);
|
|
|
|
if (item_count <= 0) return;
|
|
|
|
|
|
|
|
evas_object_geometry_get
|
2012-11-25 22:32:53 -08:00
|
|
|
(wd->resize_obj, &bx, &by, &bw, &bh);
|
2012-05-03 15:43:26 -07:00
|
|
|
sd->item_width = bw / item_count;
|
2012-11-25 22:32:53 -08:00
|
|
|
rtl = elm_widget_mirrored_get(sd->obj);
|
2011-04-07 09:44:54 -07:00
|
|
|
|
2012-05-03 15:43:26 -07:00
|
|
|
if (rtl) pos = bx + bw - sd->item_width;
|
|
|
|
else pos = bx;
|
2011-04-07 09:44:54 -07:00
|
|
|
|
2014-09-27 22:14:10 -07:00
|
|
|
EINA_LIST_FOREACH(sd->items, l, eo_item)
|
elementary/menu, ctxpopup, index, segment_control, diskselector, multibuttonentry, toolbar, naviframe, slideshow, hoversel, filpselector - deprecated xxxx_item_del() APIs.
But instead, made to use the elm_object_item_del() APIs
for this, elm_widget_item needed to provide elm_widget_item_del_pre_hook.
SVN revision: 67010
2012-01-09 21:02:11 -08:00
|
|
|
{
|
2014-09-27 22:14:10 -07:00
|
|
|
ELM_SEGMENT_ITEM_DATA_GET(eo_item, it);
|
2012-05-03 15:43:26 -07:00
|
|
|
evas_object_move(VIEW(it), pos, by);
|
|
|
|
evas_object_resize(VIEW(it), sd->item_width, bh);
|
|
|
|
if (rtl) pos -= sd->item_width;
|
|
|
|
else pos += sd->item_width;
|
|
|
|
}
|
|
|
|
|
2012-11-25 22:32:53 -08:00
|
|
|
elm_layout_sizing_eval(sd->obj);
|
2012-05-03 15:43:26 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-09-27 22:14:10 -07:00
|
|
|
_swallow_item_objects(Elm_Segment_Control_Item_Data *it)
|
2012-05-03 15:43:26 -07:00
|
|
|
{
|
|
|
|
if (!it) return;
|
|
|
|
|
|
|
|
if (it->icon)
|
|
|
|
{
|
|
|
|
edje_object_part_swallow(VIEW(it), "elm.swallow.icon", it->icon);
|
|
|
|
edje_object_signal_emit(VIEW(it), "elm,state,icon,visible", "elm");
|
2012-05-02 10:00:24 -07:00
|
|
|
}
|
2012-05-03 15:43:26 -07:00
|
|
|
else edje_object_signal_emit(VIEW(it), "elm,state,icon,hidden", "elm");
|
|
|
|
|
|
|
|
if (it->label)
|
|
|
|
{
|
|
|
|
edje_object_part_text_escaped_set(VIEW(it), "elm.text", it->label);
|
|
|
|
edje_object_signal_emit(VIEW(it), "elm,state,text,visible", "elm");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
edje_object_signal_emit(VIEW(it), "elm,state,text,hidden", "elm");
|
2012-05-02 10:00:24 -07:00
|
|
|
|
2012-05-03 15:43:26 -07:00
|
|
|
edje_object_message_signal_process(VIEW(it));
|
2012-05-02 10:00:24 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-03-26 02:04:37 -07:00
|
|
|
_update_list(Elm_Segment_Control_Data *sd)
|
2012-05-02 10:00:24 -07:00
|
|
|
{
|
2012-05-03 15:43:26 -07:00
|
|
|
int idx = 0;
|
2012-05-02 10:00:24 -07:00
|
|
|
Eina_List *l;
|
|
|
|
Eina_Bool rtl;
|
2012-05-03 15:43:26 -07:00
|
|
|
int item_count;
|
2014-09-27 22:14:10 -07:00
|
|
|
Elm_Object_Item *eo_it;
|
2011-04-07 09:44:54 -07:00
|
|
|
|
2012-05-03 15:43:26 -07:00
|
|
|
_position_items(sd);
|
2012-05-02 10:00:24 -07:00
|
|
|
|
2012-05-03 15:43:26 -07:00
|
|
|
item_count = eina_list_count(sd->items);
|
|
|
|
|
|
|
|
if (item_count == 1)
|
|
|
|
{
|
2014-09-27 22:14:10 -07:00
|
|
|
eo_it = eina_list_nth(sd->items, 0);
|
|
|
|
ELM_SEGMENT_ITEM_DATA_GET(eo_it, it);
|
|
|
|
|
2012-05-03 15:43:26 -07:00
|
|
|
it->seg_index = 0;
|
|
|
|
|
|
|
|
//Set the segment type
|
|
|
|
edje_object_signal_emit(VIEW(it), "elm,type,segment,single", "elm");
|
2012-05-02 18:19:05 -07:00
|
|
|
|
2012-05-03 15:43:26 -07:00
|
|
|
//Set the segment state
|
|
|
|
if (sd->selected_item == it)
|
|
|
|
edje_object_signal_emit
|
|
|
|
(VIEW(it), "elm,state,segment,selected", "elm");
|
|
|
|
else
|
|
|
|
edje_object_signal_emit(VIEW(it), "elm,state,segment,normal", "elm");
|
2012-05-02 10:00:24 -07:00
|
|
|
|
2012-11-25 22:32:53 -08:00
|
|
|
if (elm_widget_disabled_get(sd->obj))
|
2012-05-03 15:43:26 -07:00
|
|
|
edje_object_signal_emit(VIEW(it), "elm,state,disabled", "elm");
|
|
|
|
else
|
|
|
|
edje_object_signal_emit(VIEW(it), "elm,state,enabled", "elm");
|
|
|
|
|
|
|
|
_swallow_item_objects(it);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-11-25 22:32:53 -08:00
|
|
|
rtl = elm_widget_mirrored_get(sd->obj);
|
2014-09-27 22:14:10 -07:00
|
|
|
EINA_LIST_FOREACH(sd->items, l, eo_it)
|
2011-04-07 09:44:54 -07:00
|
|
|
{
|
2014-09-27 22:14:10 -07:00
|
|
|
ELM_SEGMENT_ITEM_DATA_GET(eo_it, it);
|
2012-05-03 15:43:26 -07:00
|
|
|
it->seg_index = idx;
|
|
|
|
|
|
|
|
//Set the segment type
|
|
|
|
if (idx == 0)
|
|
|
|
{
|
|
|
|
if (rtl)
|
|
|
|
edje_object_signal_emit
|
|
|
|
(VIEW(it), "elm,type,segment,right", "elm");
|
|
|
|
else
|
|
|
|
edje_object_signal_emit
|
|
|
|
(VIEW(it), "elm,type,segment,left", "elm");
|
|
|
|
}
|
|
|
|
else if (idx == (item_count - 1))
|
|
|
|
{
|
|
|
|
if (rtl)
|
|
|
|
edje_object_signal_emit
|
|
|
|
(VIEW(it), "elm,type,segment,left", "elm");
|
|
|
|
else
|
|
|
|
edje_object_signal_emit
|
|
|
|
(VIEW(it), "elm,type,segment,right", "elm");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
edje_object_signal_emit(VIEW(it), "elm,type,segment,middle", "elm");
|
|
|
|
|
|
|
|
//Set the segment state
|
|
|
|
if (sd->selected_item == it)
|
|
|
|
edje_object_signal_emit
|
|
|
|
(VIEW(it), "elm,state,segment,selected", "elm");
|
|
|
|
else
|
|
|
|
edje_object_signal_emit(VIEW(it), "elm,state,segment,normal", "elm");
|
|
|
|
|
2012-11-25 22:32:53 -08:00
|
|
|
if (elm_widget_disabled_get(sd->obj))
|
2012-05-03 15:43:26 -07:00
|
|
|
edje_object_signal_emit(VIEW(it), "elm,state,disabled", "elm");
|
|
|
|
else
|
|
|
|
edje_object_signal_emit(VIEW(it), "elm,state,enabled", "elm");
|
|
|
|
|
|
|
|
_swallow_item_objects(it);
|
|
|
|
idx++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-26 02:04:37 -07:00
|
|
|
EOLIAN static Eina_Bool
|
|
|
|
_elm_segment_control_elm_widget_theme_apply(Eo *obj, Elm_Segment_Control_Data *sd)
|
2012-05-03 15:43:26 -07:00
|
|
|
{
|
|
|
|
Eina_List *l;
|
|
|
|
Eina_Bool rtl;
|
2014-09-27 22:14:10 -07:00
|
|
|
Elm_Object_Item *eo_item;
|
2012-05-03 15:43:26 -07:00
|
|
|
|
2014-04-03 08:51:11 -07:00
|
|
|
Eina_Bool int_ret = EINA_FALSE;
|
|
|
|
eo_do_super(obj, MY_CLASS, int_ret = elm_obj_widget_theme_apply());
|
2014-03-26 02:04:37 -07:00
|
|
|
if (!int_ret) return EINA_FALSE;
|
2012-05-03 15:43:26 -07:00
|
|
|
|
|
|
|
rtl = elm_widget_mirrored_get(obj);
|
|
|
|
|
2014-09-27 22:14:10 -07:00
|
|
|
EINA_LIST_FOREACH(sd->items, l, eo_item)
|
2012-05-03 15:43:26 -07:00
|
|
|
{
|
2014-09-27 22:14:10 -07:00
|
|
|
ELM_SEGMENT_ITEM_DATA_GET(eo_item, it);
|
2012-05-03 15:43:26 -07:00
|
|
|
elm_widget_theme_object_set
|
|
|
|
(obj, VIEW(it), "segment_control", "item",
|
|
|
|
elm_widget_style_get(obj));
|
2014-03-15 11:09:56 -07:00
|
|
|
edje_object_scale_set(VIEW(it), elm_widget_scale_get(WIDGET(it)) *
|
2012-05-03 15:43:26 -07:00
|
|
|
elm_config_scale_get());
|
2011-10-20 18:08:01 -07:00
|
|
|
edje_object_mirrored_set(VIEW(it), rtl);
|
2011-04-07 09:44:54 -07:00
|
|
|
}
|
|
|
|
|
2012-05-03 15:43:26 -07:00
|
|
|
_update_list(sd);
|
|
|
|
|
2014-03-26 02:04:37 -07:00
|
|
|
return EINA_TRUE;
|
2011-04-07 09:44:54 -07:00
|
|
|
}
|
|
|
|
|
2014-03-26 02:04:37 -07:00
|
|
|
EOLIAN static Eina_Bool
|
|
|
|
_elm_segment_control_elm_widget_disable(Eo *obj, Elm_Segment_Control_Data *sd)
|
2011-04-07 09:44:54 -07:00
|
|
|
{
|
2014-04-03 08:51:11 -07:00
|
|
|
Eina_Bool int_ret = EINA_FALSE;
|
|
|
|
eo_do_super(obj, MY_CLASS, int_ret = elm_obj_widget_disable());
|
2014-03-26 02:04:37 -07:00
|
|
|
if (!int_ret) return EINA_FALSE;
|
2011-04-07 09:44:54 -07:00
|
|
|
|
2012-05-03 15:43:26 -07:00
|
|
|
_update_list(sd);
|
|
|
|
|
2014-03-26 02:04:37 -07:00
|
|
|
return EINA_TRUE;
|
2011-04-07 09:44:54 -07:00
|
|
|
}
|
|
|
|
|
2012-05-03 15:43:26 -07:00
|
|
|
// TODO: elm_widget_focus_list_next_get supports only Elm_widget list,
|
|
|
|
// not the Elm_Widget_item. Focus switching within widget not
|
|
|
|
// supported until it is supported in elm_widget
|
2011-04-07 09:44:54 -07:00
|
|
|
#if 0
|
|
|
|
static void *
|
|
|
|
_elm_list_data_get(const Eina_List *list)
|
|
|
|
{
|
2014-09-27 22:14:10 -07:00
|
|
|
Elm_Object_Item *eo_item = eina_list_data_get(list);
|
2011-04-07 09:44:54 -07:00
|
|
|
|
2014-09-27 22:14:10 -07:00
|
|
|
if (eo_item) return NULL;
|
2011-04-07 09:44:54 -07:00
|
|
|
|
2014-09-27 22:14:10 -07:00
|
|
|
ELM_SEGMENT_ITEM_DATA_GET(eo_item, it);
|
2011-10-20 18:08:01 -07:00
|
|
|
edje_object_signal_emit(VIEW(it), "elm,state,segment,selected", "elm");
|
2012-05-03 15:43:26 -07:00
|
|
|
|
2011-10-20 18:08:01 -07:00
|
|
|
return VIEW(it);
|
2011-04-07 09:44:54 -07:00
|
|
|
}
|
|
|
|
|
2014-03-26 02:04:37 -07:00
|
|
|
EOLIAN static Eina_Bool
|
|
|
|
_elm_segment_control_elm_widget_focus_next(Eo *obj, Elm_Segment_Control_Data *sd, Elm_Focus_Direction dir, Evas_Object **next)
|
2011-04-07 09:44:54 -07:00
|
|
|
{
|
2012-05-03 15:43:26 -07:00
|
|
|
static int count = 0;
|
2011-04-07 09:44:54 -07:00
|
|
|
const Eina_List *items;
|
2012-05-03 15:43:26 -07:00
|
|
|
void *(*list_data_get)(const Eina_List *list);
|
2011-04-07 09:44:54 -07:00
|
|
|
|
|
|
|
/* Focus chain */
|
|
|
|
if ((items = elm_widget_focus_custom_chain_get(obj)))
|
|
|
|
list_data_get = eina_list_data_get;
|
|
|
|
else
|
|
|
|
{
|
2012-05-03 15:43:26 -07:00
|
|
|
items = sd->items;
|
2011-04-07 09:44:54 -07:00
|
|
|
list_data_get = _elm_list_data_get;
|
2014-03-26 02:04:37 -07:00
|
|
|
if (!items) return EINA_FALSE;
|
2011-04-07 09:44:54 -07:00
|
|
|
}
|
2012-05-03 15:43:26 -07:00
|
|
|
|
2014-03-26 02:04:37 -07:00
|
|
|
return elm_widget_focus_list_next_get(obj, items, list_data_get, dir, next);
|
2011-04-07 09:44:54 -07:00
|
|
|
}
|
2012-05-02 18:19:05 -07:00
|
|
|
|
2012-05-03 15:43:26 -07:00
|
|
|
#endif
|
2012-05-02 18:19:05 -07:00
|
|
|
|
2011-04-07 09:44:54 -07:00
|
|
|
static void
|
2014-09-27 22:14:10 -07:00
|
|
|
_segment_off(Elm_Segment_Control_Item_Data *it)
|
2011-04-07 09:44:54 -07:00
|
|
|
{
|
2012-07-01 18:39:10 -07:00
|
|
|
ELM_SEGMENT_CONTROL_DATA_GET(WIDGET(it), sd);
|
2011-04-07 09:44:54 -07:00
|
|
|
|
2011-10-20 18:08:01 -07:00
|
|
|
edje_object_signal_emit(VIEW(it), "elm,state,segment,normal", "elm");
|
2011-04-07 09:44:54 -07:00
|
|
|
|
2012-05-03 15:43:26 -07:00
|
|
|
if (sd->selected_item == it) sd->selected_item = NULL;
|
2011-04-07 09:44:54 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-09-27 22:14:10 -07:00
|
|
|
_segment_on(Elm_Segment_Control_Item_Data *it)
|
2011-04-07 09:44:54 -07:00
|
|
|
{
|
2012-07-01 18:39:10 -07:00
|
|
|
ELM_SEGMENT_CONTROL_DATA_GET(WIDGET(it), sd);
|
2011-04-07 09:44:54 -07:00
|
|
|
|
2012-05-03 15:43:26 -07:00
|
|
|
if (it == sd->selected_item) return;
|
2012-05-02 18:19:05 -07:00
|
|
|
|
2012-05-03 15:43:26 -07:00
|
|
|
if (sd->selected_item) _segment_off(sd->selected_item);
|
2012-05-02 18:19:05 -07:00
|
|
|
|
2012-05-03 15:43:26 -07:00
|
|
|
edje_object_signal_emit(VIEW(it), "elm,state,segment,selected", "elm");
|
2012-05-02 18:19:05 -07:00
|
|
|
|
2012-05-03 15:43:26 -07:00
|
|
|
sd->selected_item = it;
|
2015-06-09 06:11:10 -07:00
|
|
|
eo_do(sd->obj, eo_event_callback_call(ELM_SEGMENT_CONTROL_EVENT_CHANGED, EO_OBJ(it)));
|
2011-04-07 09:44:54 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-01-06 06:30:02 -08:00
|
|
|
_on_move_resize(void *data, Evas *e EINA_UNUSED,
|
|
|
|
Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
2011-04-07 09:44:54 -07:00
|
|
|
{
|
2012-05-03 15:43:26 -07:00
|
|
|
ELM_SEGMENT_CONTROL_DATA_GET(data, sd);
|
2011-04-07 09:44:54 -07:00
|
|
|
|
2012-05-03 15:43:26 -07:00
|
|
|
_position_items(sd);
|
2011-04-07 09:44:54 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-05-03 15:43:26 -07:00
|
|
|
_on_mouse_up(void *data,
|
2014-01-06 06:30:02 -08:00
|
|
|
Evas *e EINA_UNUSED,
|
|
|
|
Evas_Object *obj EINA_UNUSED,
|
2012-05-03 15:43:26 -07:00
|
|
|
void *event_info)
|
2011-04-07 09:44:54 -07:00
|
|
|
{
|
2014-09-27 22:14:10 -07:00
|
|
|
Elm_Segment_Control_Item_Data *it = data;
|
2012-11-14 02:49:54 -08:00
|
|
|
Evas_Event_Mouse_Up *ev = event_info;
|
2011-04-07 09:44:54 -07:00
|
|
|
Evas_Coord x, y, w, h;
|
|
|
|
|
2012-07-01 18:39:10 -07:00
|
|
|
ELM_SEGMENT_CONTROL_DATA_GET(WIDGET(it), sd);
|
2011-04-07 09:44:54 -07:00
|
|
|
|
2012-11-14 02:49:54 -08:00
|
|
|
if (ev->button != 1) return;
|
|
|
|
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
|
2012-11-25 22:32:53 -08:00
|
|
|
if (elm_widget_disabled_get(sd->obj)) return;
|
|
|
|
|
2012-05-03 15:43:26 -07:00
|
|
|
if (it == sd->selected_item) return;
|
2011-04-07 09:44:54 -07:00
|
|
|
|
|
|
|
ev = event_info;
|
2011-10-20 18:08:01 -07:00
|
|
|
evas_object_geometry_get(VIEW(it), &x, &y, &w, &h);
|
2011-04-07 09:44:54 -07:00
|
|
|
|
2014-11-13 22:19:21 -08:00
|
|
|
if ((ev->canvas.x >= x) && (ev->canvas.x <= (x + w)) && (ev->canvas.y >= y)
|
2011-06-13 04:26:08 -07:00
|
|
|
&& (ev->canvas.y <= (y + h)))
|
2011-04-07 09:44:54 -07:00
|
|
|
_segment_on(it);
|
|
|
|
else
|
2011-10-20 18:08:01 -07:00
|
|
|
edje_object_signal_emit(VIEW(it), "elm,state,segment,normal", "elm");
|
2011-04-07 09:44:54 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-05-03 15:43:26 -07:00
|
|
|
_on_mouse_down(void *data,
|
2014-01-06 06:30:02 -08:00
|
|
|
Evas *e EINA_UNUSED,
|
|
|
|
Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
2011-04-07 09:44:54 -07:00
|
|
|
{
|
2014-09-27 22:14:10 -07:00
|
|
|
Elm_Segment_Control_Item_Data *it = data;
|
2012-11-14 02:49:54 -08:00
|
|
|
Evas_Event_Mouse_Down *ev = event_info;
|
2011-04-07 09:44:54 -07:00
|
|
|
|
2012-07-01 18:39:10 -07:00
|
|
|
ELM_SEGMENT_CONTROL_DATA_GET(WIDGET(it), sd);
|
2011-04-07 09:44:54 -07:00
|
|
|
|
2012-11-14 02:49:54 -08:00
|
|
|
if (ev->button != 1) return;
|
2012-11-25 22:32:53 -08:00
|
|
|
if (elm_widget_disabled_get(sd->obj)) return;
|
|
|
|
|
2012-05-03 15:43:26 -07:00
|
|
|
if (it == sd->selected_item) return;
|
2011-04-07 09:44:54 -07:00
|
|
|
|
2011-10-20 18:08:01 -07:00
|
|
|
edje_object_signal_emit(VIEW(it), "elm,state,segment,pressed", "elm");
|
2011-04-07 09:44:54 -07:00
|
|
|
}
|
|
|
|
|
2014-09-27 22:14:10 -07:00
|
|
|
static Elm_Segment_Control_Item_Data *
|
2012-05-03 15:43:26 -07:00
|
|
|
_item_find(const Evas_Object *obj,
|
|
|
|
int idx)
|
2011-04-07 09:44:54 -07:00
|
|
|
{
|
2014-09-27 22:14:10 -07:00
|
|
|
Elm_Object_Item *eo_it;
|
2011-04-07 09:44:54 -07:00
|
|
|
|
2012-05-03 15:43:26 -07:00
|
|
|
ELM_SEGMENT_CONTROL_DATA_GET(obj, sd);
|
2011-04-07 09:44:54 -07:00
|
|
|
|
2014-09-27 22:14:10 -07:00
|
|
|
eo_it = eina_list_nth(sd->items, idx);
|
|
|
|
ELM_SEGMENT_ITEM_DATA_GET(eo_it, it);
|
2011-04-07 09:44:54 -07:00
|
|
|
return it;
|
|
|
|
}
|
|
|
|
|
2014-09-27 22:14:10 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_segment_control_item_elm_widget_item_part_text_set(Eo *eo_item EINA_UNUSED,
|
|
|
|
Elm_Segment_Control_Item_Data *item,
|
|
|
|
const char *part,
|
|
|
|
const char *label)
|
2012-01-01 22:54:18 -08:00
|
|
|
{
|
2012-08-26 21:29:31 -07:00
|
|
|
char buf[1024];
|
|
|
|
|
|
|
|
if ((!part) || (!strcmp(part, "default")) ||
|
|
|
|
(!strcmp(part, "elm.text")))
|
|
|
|
{
|
|
|
|
eina_stringshare_replace(&item->label, label);
|
|
|
|
if (label)
|
|
|
|
edje_object_signal_emit(VIEW(item), "elm,state,text,visible", "elm");
|
|
|
|
else
|
|
|
|
edje_object_signal_emit(VIEW(item), "elm,state,text,hidden", "elm");
|
2015-01-06 18:22:07 -08:00
|
|
|
edje_object_part_text_escaped_set(VIEW(item), "elm.text", label);
|
2012-08-26 21:29:31 -07:00
|
|
|
}
|
2012-01-01 22:54:18 -08:00
|
|
|
else
|
2012-08-26 21:29:31 -07:00
|
|
|
{
|
|
|
|
if (label)
|
|
|
|
{
|
|
|
|
snprintf(buf, sizeof(buf), "elm,state,%s,visible", part);
|
|
|
|
edje_object_signal_emit(VIEW(item), buf, "elm");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
snprintf(buf, sizeof(buf), "elm,state,%s,hidden", part);
|
|
|
|
edje_object_signal_emit(VIEW(item), buf, "elm");
|
|
|
|
}
|
2015-01-06 18:22:07 -08:00
|
|
|
edje_object_part_text_escaped_set(VIEW(item), part, label);
|
2012-08-26 21:29:31 -07:00
|
|
|
}
|
2012-05-03 15:43:26 -07:00
|
|
|
|
2012-08-26 21:29:31 -07:00
|
|
|
edje_object_message_signal_process(VIEW(item));
|
2012-01-01 22:54:18 -08:00
|
|
|
}
|
|
|
|
|
2014-09-27 22:14:10 -07:00
|
|
|
EOLIAN static const char *
|
|
|
|
_elm_segment_control_item_elm_widget_item_part_text_get(Eo *eo_item EINA_UNUSED,
|
|
|
|
Elm_Segment_Control_Item_Data *it,
|
|
|
|
const char *part)
|
2012-01-01 22:54:18 -08:00
|
|
|
{
|
2012-08-26 21:29:31 -07:00
|
|
|
char buf[1024];
|
|
|
|
|
|
|
|
if (!part || !strcmp(part, "default"))
|
|
|
|
snprintf(buf, sizeof(buf), "elm.text");
|
|
|
|
else
|
|
|
|
snprintf(buf, sizeof(buf), "%s", part);
|
|
|
|
|
|
|
|
return edje_object_part_text_get(VIEW(it), buf);
|
2012-01-01 22:54:18 -08:00
|
|
|
}
|
|
|
|
|
2014-09-27 22:14:10 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_segment_control_item_elm_widget_item_part_content_set(Eo *eo_item EINA_UNUSED,
|
|
|
|
Elm_Segment_Control_Item_Data *item,
|
|
|
|
const char *part,
|
|
|
|
Evas_Object *content)
|
2012-01-01 22:54:18 -08:00
|
|
|
{
|
2012-08-26 21:29:31 -07:00
|
|
|
char buf[1024];
|
2012-01-01 22:54:18 -08:00
|
|
|
|
2012-08-26 21:29:31 -07:00
|
|
|
if (!part || !strcmp("icon", part))
|
2012-01-01 22:54:18 -08:00
|
|
|
{
|
2012-08-26 21:29:31 -07:00
|
|
|
if (content == item->icon) return;
|
|
|
|
|
2014-01-21 17:38:55 -08:00
|
|
|
evas_object_del(item->icon);
|
2012-08-26 21:29:31 -07:00
|
|
|
item->icon = content;
|
|
|
|
if (!item->icon)
|
|
|
|
{
|
|
|
|
elm_widget_sub_object_add(VIEW(item), item->icon);
|
|
|
|
edje_object_part_swallow(VIEW(item), "elm.swallow.icon", item->icon);
|
|
|
|
edje_object_signal_emit(VIEW(item), "elm,state,icon,visible", "elm");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
edje_object_signal_emit(VIEW(item), "elm,state,icon,hidden", "elm");
|
2012-01-01 22:54:18 -08:00
|
|
|
}
|
|
|
|
else
|
2012-08-26 21:29:31 -07:00
|
|
|
{
|
|
|
|
if (content)
|
|
|
|
{
|
2014-09-27 22:14:10 -07:00
|
|
|
edje_object_part_swallow(VIEW(item), part, content);
|
2012-08-26 21:29:31 -07:00
|
|
|
snprintf(buf, sizeof(buf), "elm,state,%s,visible", part);
|
|
|
|
edje_object_signal_emit(VIEW(item), buf, "elm");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
snprintf(buf, sizeof(buf), "elm,state,%s,hidden", part);
|
|
|
|
edje_object_signal_emit(VIEW(item), buf, "elm");
|
|
|
|
}
|
|
|
|
}
|
2012-01-01 22:54:18 -08:00
|
|
|
}
|
|
|
|
|
2014-09-27 22:14:10 -07:00
|
|
|
EOLIAN static Evas_Object *
|
|
|
|
_elm_segment_control_item_elm_widget_item_part_content_get(Eo *eo_item EINA_UNUSED,
|
|
|
|
Elm_Segment_Control_Item_Data *item,
|
|
|
|
const char *part)
|
2012-01-01 22:54:18 -08:00
|
|
|
{
|
2013-01-09 03:30:10 -08:00
|
|
|
if (part && !strcmp(part, "icon"))
|
2012-08-26 21:29:31 -07:00
|
|
|
return item->icon;
|
|
|
|
else
|
|
|
|
return edje_object_part_swallow_get(VIEW(item), part);
|
2012-01-01 22:54:18 -08:00
|
|
|
}
|
|
|
|
|
2014-09-17 06:44:05 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_segment_control_item_eo_base_destructor(Eo *eo_item, Elm_Segment_Control_Item_Data *item)
|
elementary/menu, ctxpopup, index, segment_control, diskselector, multibuttonentry, toolbar, naviframe, slideshow, hoversel, filpselector - deprecated xxxx_item_del() APIs.
But instead, made to use the elm_object_item_del() APIs
for this, elm_widget_item needed to provide elm_widget_item_del_pre_hook.
SVN revision: 67010
2012-01-09 21:02:11 -08:00
|
|
|
{
|
2014-09-27 22:14:10 -07:00
|
|
|
ELM_SEGMENT_CONTROL_DATA_GET(WIDGET(item), sd);
|
elementary/menu, ctxpopup, index, segment_control, diskselector, multibuttonentry, toolbar, naviframe, slideshow, hoversel, filpselector - deprecated xxxx_item_del() APIs.
But instead, made to use the elm_object_item_del() APIs
for this, elm_widget_item needed to provide elm_widget_item_del_pre_hook.
SVN revision: 67010
2012-01-09 21:02:11 -08:00
|
|
|
|
|
|
|
_item_free(item);
|
2012-05-03 15:43:26 -07:00
|
|
|
_update_list(sd);
|
2012-01-27 03:56:14 -08:00
|
|
|
|
2014-09-17 06:44:05 -07:00
|
|
|
eo_do_super(eo_item, ELM_SEGMENT_CONTROL_ITEM_CLASS, eo_destructor());
|
elementary/menu, ctxpopup, index, segment_control, diskselector, multibuttonentry, toolbar, naviframe, slideshow, hoversel, filpselector - deprecated xxxx_item_del() APIs.
But instead, made to use the elm_object_item_del() APIs
for this, elm_widget_item needed to provide elm_widget_item_del_pre_hook.
SVN revision: 67010
2012-01-09 21:02:11 -08:00
|
|
|
}
|
|
|
|
|
2012-08-21 03:08:56 -07:00
|
|
|
static char *
|
2014-01-06 06:30:02 -08:00
|
|
|
_access_info_cb(void *data, Evas_Object *obj EINA_UNUSED)
|
2012-08-21 03:08:56 -07:00
|
|
|
{
|
|
|
|
const char *txt = NULL;
|
2014-09-27 22:14:10 -07:00
|
|
|
Elm_Segment_Control_Item_Data *it = (Elm_Segment_Control_Item_Data *)data;
|
2012-08-21 03:08:56 -07:00
|
|
|
ELM_SEGMENT_CONTROL_ITEM_CHECK_OR_RETURN(it, NULL);
|
|
|
|
|
|
|
|
if (!txt) txt = it->label;
|
|
|
|
if (txt) return strdup(txt);
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
2014-01-06 06:30:02 -08:00
|
|
|
_access_state_cb(void *data, Evas_Object *obj EINA_UNUSED)
|
2012-08-21 03:08:56 -07:00
|
|
|
{
|
2014-09-27 22:14:10 -07:00
|
|
|
Elm_Segment_Control_Item_Data *it = (Elm_Segment_Control_Item_Data *)data;
|
2012-08-21 03:08:56 -07:00
|
|
|
ELM_SEGMENT_CONTROL_ITEM_CHECK_OR_RETURN(it, NULL);
|
|
|
|
ELM_SEGMENT_CONTROL_DATA_GET(WIDGET(it), sd);
|
2013-10-05 01:15:37 -07:00
|
|
|
ELM_WIDGET_DATA_GET_OR_RETURN(WIDGET(it), wd, NULL);
|
2012-08-21 03:08:56 -07:00
|
|
|
|
2012-11-25 22:32:53 -08:00
|
|
|
if (wd->disabled)
|
2012-08-21 03:08:56 -07:00
|
|
|
return strdup(E_("State: Disabled"));
|
|
|
|
|
|
|
|
if (it == sd->selected_item)
|
|
|
|
return strdup(E_("State: Selected"));
|
|
|
|
else
|
|
|
|
return strdup(E_("State: Unselected"));
|
|
|
|
}
|
|
|
|
|
2014-09-27 22:14:10 -07:00
|
|
|
static Evas_Object*
|
|
|
|
_elm_segment_control_item_elm_widget_item_access_register(Eo *eo_it EINA_UNUSED,
|
|
|
|
Elm_Segment_Control_Item_Data *it)
|
2012-08-21 03:08:56 -07:00
|
|
|
{
|
|
|
|
Elm_Access_Info *ai;
|
2014-09-27 22:14:10 -07:00
|
|
|
Evas_Object *ret;
|
2012-08-21 03:08:56 -07:00
|
|
|
|
2014-09-27 22:14:10 -07:00
|
|
|
eo_do_super(eo_it, ELM_SEGMENT_CONTROL_ITEM_CLASS, ret = elm_wdg_item_access_register());
|
2012-08-21 03:08:56 -07:00
|
|
|
|
2014-09-27 22:14:10 -07:00
|
|
|
ai = _elm_access_info_get(it->base->access_obj);
|
2012-08-21 03:08:56 -07:00
|
|
|
|
|
|
|
_elm_access_text_set(ai, ELM_ACCESS_TYPE, E_("Segment Control Item"));
|
|
|
|
_elm_access_callback_set(ai, ELM_ACCESS_INFO, _access_info_cb, it);
|
|
|
|
_elm_access_callback_set(ai, ELM_ACCESS_STATE, _access_state_cb, it);
|
2014-09-27 22:14:10 -07:00
|
|
|
|
|
|
|
return ret;
|
2012-08-21 03:08:56 -07:00
|
|
|
}
|
|
|
|
|
2014-09-27 22:14:10 -07:00
|
|
|
static Elm_Object_Item *
|
2012-05-03 15:43:26 -07:00
|
|
|
_item_new(Evas_Object *obj,
|
|
|
|
Evas_Object *icon,
|
|
|
|
const char *label)
|
2011-04-07 09:44:54 -07:00
|
|
|
{
|
2014-09-27 22:14:10 -07:00
|
|
|
Eo *eo_item;
|
2012-05-03 15:43:26 -07:00
|
|
|
|
2014-09-27 22:14:10 -07:00
|
|
|
eo_item = eo_add(ELM_SEGMENT_CONTROL_ITEM_CLASS, obj);
|
|
|
|
if (!eo_item) return NULL;
|
2011-04-07 09:44:54 -07:00
|
|
|
|
2014-09-27 22:14:10 -07:00
|
|
|
ELM_SEGMENT_ITEM_DATA_GET(eo_item, it);
|
2011-04-07 09:44:54 -07:00
|
|
|
|
2012-05-03 15:43:26 -07:00
|
|
|
if (label) eina_stringshare_replace(&it->label, label);
|
2011-04-07 09:44:54 -07:00
|
|
|
if (it->label)
|
2011-10-20 18:08:01 -07:00
|
|
|
edje_object_signal_emit(VIEW(it), "elm,state,text,visible", "elm");
|
2011-04-07 09:44:54 -07:00
|
|
|
else
|
2011-10-20 18:08:01 -07:00
|
|
|
edje_object_signal_emit(VIEW(it), "elm,state,text,hidden", "elm");
|
|
|
|
edje_object_message_signal_process(VIEW(it));
|
2012-04-20 05:51:10 -07:00
|
|
|
edje_object_part_text_escaped_set(VIEW(it), "elm.text", label);
|
2011-04-07 09:44:54 -07:00
|
|
|
|
|
|
|
it->icon = icon;
|
2011-10-20 18:08:01 -07:00
|
|
|
if (it->icon) elm_widget_sub_object_add(VIEW(it), it->icon);
|
2012-05-03 15:43:26 -07:00
|
|
|
evas_object_event_callback_add
|
|
|
|
(VIEW(it), EVAS_CALLBACK_MOUSE_DOWN, _on_mouse_down, it);
|
|
|
|
evas_object_event_callback_add
|
|
|
|
(VIEW(it), EVAS_CALLBACK_MOUSE_UP, _on_mouse_up, it);
|
2011-10-20 18:08:01 -07:00
|
|
|
evas_object_show(VIEW(it));
|
2011-04-07 09:44:54 -07:00
|
|
|
|
2012-08-21 03:08:56 -07:00
|
|
|
// ACCESS
|
|
|
|
if (_elm_config->access_mode == ELM_ACCESS_MODE_ON)
|
2014-09-27 22:14:10 -07:00
|
|
|
eo_do(eo_item, elm_wdg_item_access_register());
|
2012-08-21 03:08:56 -07:00
|
|
|
|
2014-08-19 00:52:24 -07:00
|
|
|
return eo_item;
|
2014-09-27 22:14:10 -07:00
|
|
|
}
|
|
|
|
|
2015-05-19 05:34:07 -07:00
|
|
|
EOLIAN static Eo *
|
2014-09-27 22:14:10 -07:00
|
|
|
_elm_segment_control_item_eo_base_constructor(Eo *obj, Elm_Segment_Control_Item_Data *it)
|
|
|
|
{
|
2015-05-19 05:34:07 -07:00
|
|
|
obj = eo_do_super_ret(obj, ELM_SEGMENT_CONTROL_ITEM_CLASS, obj, eo_constructor());
|
2014-09-27 22:14:10 -07:00
|
|
|
it->base = eo_data_scope_get(obj, ELM_WIDGET_ITEM_CLASS);
|
|
|
|
|
|
|
|
Evas_Object *parent;
|
|
|
|
eo_do (obj, parent = eo_parent_get());
|
|
|
|
|
|
|
|
VIEW(it) = edje_object_add(evas_object_evas_get(parent));
|
|
|
|
edje_object_scale_set(VIEW(it),elm_widget_scale_get(WIDGET(it)) *
|
|
|
|
elm_config_scale_get());
|
|
|
|
evas_object_smart_member_add(VIEW(it), parent);
|
|
|
|
|
|
|
|
elm_widget_sub_object_add(parent, VIEW(it));
|
|
|
|
elm_widget_theme_object_set
|
|
|
|
(parent, VIEW(it), "segment_control", "item", elm_object_style_get(parent));
|
|
|
|
edje_object_mirrored_set(VIEW(it), elm_widget_mirrored_get(WIDGET(it)));
|
2015-05-19 05:34:07 -07:00
|
|
|
|
|
|
|
return obj;
|
2011-04-07 09:44:54 -07:00
|
|
|
}
|
|
|
|
|
2014-03-26 02:04:37 -07:00
|
|
|
EOLIAN static void
|
2014-06-03 03:35:28 -07:00
|
|
|
_elm_segment_control_evas_object_smart_add(Eo *obj, Elm_Segment_Control_Data *_pd EINA_UNUSED)
|
2012-05-02 10:00:24 -07:00
|
|
|
{
|
2013-03-18 09:07:38 -07:00
|
|
|
eo_do_super(obj, MY_CLASS, evas_obj_smart_add());
|
2013-09-24 21:33:39 -07:00
|
|
|
elm_widget_sub_object_parent_add(obj);
|
2013-08-26 22:19:19 -07:00
|
|
|
|
2013-03-01 18:04:31 -08:00
|
|
|
if (!elm_layout_theme_set
|
|
|
|
(obj, "segment_control", "base", elm_widget_style_get(obj)))
|
2013-12-25 20:03:55 -08:00
|
|
|
CRI("Failed to set layout!");
|
2012-05-03 15:43:26 -07:00
|
|
|
|
|
|
|
evas_object_event_callback_add
|
|
|
|
(obj, EVAS_CALLBACK_RESIZE, _on_move_resize, obj);
|
|
|
|
evas_object_event_callback_add
|
|
|
|
(obj, EVAS_CALLBACK_MOVE, _on_move_resize, obj);
|
2012-07-17 11:45:27 -07:00
|
|
|
|
|
|
|
elm_layout_sizing_eval(obj);
|
2012-05-03 15:43:26 -07:00
|
|
|
}
|
|
|
|
|
2014-03-26 02:04:37 -07:00
|
|
|
EOLIAN static void
|
2014-06-03 03:35:28 -07:00
|
|
|
_elm_segment_control_evas_object_smart_del(Eo *obj, Elm_Segment_Control_Data *sd)
|
2012-05-03 15:43:26 -07:00
|
|
|
{
|
2014-09-27 22:14:10 -07:00
|
|
|
Elm_Object_Item *eo_it;
|
2012-05-02 10:00:24 -07:00
|
|
|
|
2014-09-27 22:14:10 -07:00
|
|
|
EINA_LIST_FREE(sd->items, eo_it)
|
2012-05-03 15:43:26 -07:00
|
|
|
{
|
2014-08-19 00:52:24 -07:00
|
|
|
eo_del(eo_it);
|
2012-05-03 15:43:26 -07:00
|
|
|
}
|
|
|
|
|
2013-03-18 09:07:38 -07:00
|
|
|
eo_do_super(obj, MY_CLASS, evas_obj_smart_del());
|
2012-05-03 15:43:26 -07:00
|
|
|
}
|
|
|
|
|
2012-11-25 22:32:53 -08:00
|
|
|
static Eina_Bool _elm_segment_control_smart_focus_next_enable = EINA_FALSE;
|
|
|
|
|
2014-03-26 02:04:37 -07:00
|
|
|
EOLIAN static Eina_Bool
|
|
|
|
_elm_segment_control_elm_widget_focus_next_manager_is(Eo *obj EINA_UNUSED, Elm_Segment_Control_Data *_pd EINA_UNUSED)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2014-03-26 02:04:37 -07:00
|
|
|
return _elm_segment_control_smart_focus_next_enable;
|
2012-11-25 22:32:53 -08:00
|
|
|
}
|
|
|
|
|
2014-03-26 02:04:37 -07:00
|
|
|
EOLIAN static Eina_Bool
|
|
|
|
_elm_segment_control_elm_widget_focus_next(Eo *obj, Elm_Segment_Control_Data *sd, Elm_Focus_Direction dir, Evas_Object **next)
|
2012-08-21 03:08:56 -07:00
|
|
|
{
|
|
|
|
Eina_List *items = NULL;
|
|
|
|
Eina_List *l;
|
2014-09-27 22:14:10 -07:00
|
|
|
Elm_Object_Item *eo_item;
|
2012-08-21 03:08:56 -07:00
|
|
|
|
2014-03-26 02:04:37 -07:00
|
|
|
ELM_SEGMENT_CONTROL_CHECK(obj) EINA_FALSE;
|
2012-08-21 03:08:56 -07:00
|
|
|
|
2014-09-27 22:14:10 -07:00
|
|
|
EINA_LIST_FOREACH(sd->items, l, eo_item)
|
|
|
|
{
|
|
|
|
ELM_SEGMENT_ITEM_DATA_GET(eo_item, it);
|
|
|
|
items = eina_list_append(items, it->base->access_obj);
|
|
|
|
}
|
2012-08-21 03:08:56 -07:00
|
|
|
|
2014-03-26 02:04:37 -07:00
|
|
|
return elm_widget_focus_list_next_get
|
2012-08-21 03:08:56 -07:00
|
|
|
(obj, items, eina_list_data_get, dir, next);
|
|
|
|
}
|
|
|
|
|
2014-03-26 02:04:37 -07:00
|
|
|
EOLIAN static Eina_Bool
|
|
|
|
_elm_segment_control_elm_widget_focus_direction_manager_is(Eo *obj EINA_UNUSED, Elm_Segment_Control_Data *_pd EINA_UNUSED)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2014-03-26 02:04:37 -07:00
|
|
|
return EINA_FALSE;
|
2012-11-25 22:32:53 -08:00
|
|
|
}
|
|
|
|
|
2012-08-21 03:08:56 -07:00
|
|
|
static void
|
2014-03-26 02:04:37 -07:00
|
|
|
_access_obj_process(Elm_Segment_Control_Data *sd, Eina_Bool is_access)
|
2012-08-21 03:08:56 -07:00
|
|
|
{
|
|
|
|
Eina_List *l;
|
2014-09-27 22:14:10 -07:00
|
|
|
Eo *eo_item;
|
2012-08-21 03:08:56 -07:00
|
|
|
|
2014-09-27 22:14:10 -07:00
|
|
|
EINA_LIST_FOREACH(sd->items, l, eo_item)
|
2012-08-21 03:08:56 -07:00
|
|
|
{
|
2014-09-27 22:14:10 -07:00
|
|
|
if (is_access) eo_do(eo_item, elm_wdg_item_access_register());
|
2012-08-21 03:08:56 -07:00
|
|
|
else
|
2014-09-27 22:14:10 -07:00
|
|
|
eo_do(eo_item, elm_wdg_item_access_unregister());
|
2012-08-21 03:08:56 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-26 02:04:37 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_segment_control_elm_widget_access(Eo *obj EINA_UNUSED, Elm_Segment_Control_Data *sd, Eina_Bool acs)
|
2012-08-01 14:02:49 -07:00
|
|
|
{
|
2014-03-26 02:04:37 -07:00
|
|
|
_elm_segment_control_smart_focus_next_enable = acs;
|
2012-11-25 22:32:53 -08:00
|
|
|
_access_obj_process(sd, _elm_segment_control_smart_focus_next_enable);
|
2012-05-03 15:43:26 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI Evas_Object *
|
|
|
|
elm_segment_control_add(Evas_Object *parent)
|
|
|
|
{
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
|
2012-11-25 22:32:53 -08:00
|
|
|
Evas_Object *obj = eo_add(MY_CLASS, parent);
|
|
|
|
return obj;
|
|
|
|
}
|
2012-05-03 15:43:26 -07:00
|
|
|
|
2015-05-19 05:34:07 -07:00
|
|
|
EOLIAN static Eo *
|
2014-03-26 02:04:37 -07:00
|
|
|
_elm_segment_control_eo_base_constructor(Eo *obj, Elm_Segment_Control_Data *sd)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2015-05-19 05:34:07 -07:00
|
|
|
obj = eo_do_super_ret(obj, MY_CLASS, obj, eo_constructor());
|
2012-11-25 22:32:53 -08:00
|
|
|
sd->obj = obj;
|
2011-04-07 09:44:54 -07:00
|
|
|
|
2012-11-25 22:32:53 -08:00
|
|
|
eo_do(obj,
|
2013-11-07 03:44:22 -08:00
|
|
|
evas_obj_type_set(MY_CLASS_NAME_LEGACY),
|
2014-06-10 19:07:15 -07:00
|
|
|
evas_obj_smart_callbacks_descriptions_set(_smart_callbacks),
|
|
|
|
elm_interface_atspi_accessible_role_set(ELM_ATSPI_ROLE_LIST));
|
2015-05-19 05:34:07 -07:00
|
|
|
|
|
|
|
return obj;
|
2011-04-07 09:44:54 -07:00
|
|
|
}
|
|
|
|
|
2014-03-26 02:04:37 -07:00
|
|
|
EOLIAN static Elm_Object_Item*
|
|
|
|
_elm_segment_control_item_add(Eo *obj, Elm_Segment_Control_Data *sd, Evas_Object *icon, const char *label)
|
2011-04-07 09:44:54 -07:00
|
|
|
{
|
2014-09-27 22:14:10 -07:00
|
|
|
Elm_Object_Item *eo_item;
|
2011-04-07 09:44:54 -07:00
|
|
|
|
2014-09-27 22:14:10 -07:00
|
|
|
eo_item = _item_new(obj, icon, label);
|
|
|
|
if (!eo_item) return NULL;
|
2011-04-07 09:44:54 -07:00
|
|
|
|
2014-09-27 22:14:10 -07:00
|
|
|
sd->items = eina_list_append(sd->items, eo_item);
|
2012-05-03 15:43:26 -07:00
|
|
|
_update_list(sd);
|
2011-04-07 09:44:54 -07:00
|
|
|
|
2014-08-19 00:52:24 -07:00
|
|
|
return eo_item;
|
2011-04-07 09:44:54 -07:00
|
|
|
}
|
|
|
|
|
2014-03-26 02:04:37 -07:00
|
|
|
EOLIAN static Elm_Object_Item*
|
|
|
|
_elm_segment_control_item_insert_at(Eo *obj, Elm_Segment_Control_Data *sd, Evas_Object *icon, const char *label, int idx)
|
2011-04-07 09:44:54 -07:00
|
|
|
{
|
2014-09-27 22:14:10 -07:00
|
|
|
Elm_Object_Item *eo_item;
|
|
|
|
Elm_Segment_Control_Item_Data *it_rel;
|
2011-04-07 09:44:54 -07:00
|
|
|
|
2012-05-03 15:43:26 -07:00
|
|
|
|
2011-06-09 22:12:28 -07:00
|
|
|
if (idx < 0) idx = 0;
|
2011-04-07 09:44:54 -07:00
|
|
|
|
2014-09-27 22:14:10 -07:00
|
|
|
eo_item = _item_new(obj, icon, label);
|
|
|
|
if (!eo_item) return NULL;
|
2011-04-07 09:44:54 -07:00
|
|
|
|
2011-06-09 22:12:28 -07:00
|
|
|
it_rel = _item_find(obj, idx);
|
2014-09-27 22:14:10 -07:00
|
|
|
if (it_rel) sd->items = eina_list_prepend_relative(sd->items, eo_item, EO_OBJ(it_rel));
|
|
|
|
else sd->items = eina_list_append(sd->items, eo_item);
|
2012-05-03 15:43:26 -07:00
|
|
|
|
|
|
|
_update_list(sd);
|
2011-04-07 09:44:54 -07:00
|
|
|
|
2014-08-19 00:52:24 -07:00
|
|
|
return eo_item;
|
2011-04-07 09:44:54 -07:00
|
|
|
}
|
|
|
|
|
2014-03-26 02:04:37 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_segment_control_item_del_at(Eo *obj, Elm_Segment_Control_Data *_pd EINA_UNUSED, int idx)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2014-09-27 22:14:10 -07:00
|
|
|
Elm_Segment_Control_Item_Data *it;
|
2011-04-07 09:44:54 -07:00
|
|
|
|
2011-06-09 22:12:28 -07:00
|
|
|
it = _item_find(obj, idx);
|
2011-04-07 09:44:54 -07:00
|
|
|
if (!it) return;
|
2012-05-03 15:43:26 -07:00
|
|
|
|
2014-08-19 00:52:24 -07:00
|
|
|
eo_do(EO_OBJ(it), elm_wdg_item_del());
|
2011-04-07 09:44:54 -07:00
|
|
|
}
|
|
|
|
|
2014-03-26 02:04:37 -07:00
|
|
|
EOLIAN static const char*
|
2015-06-25 04:21:00 -07:00
|
|
|
_elm_segment_control_item_label_get(const Eo *obj, Elm_Segment_Control_Data *_pd EINA_UNUSED, int idx)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2014-09-27 22:14:10 -07:00
|
|
|
Elm_Segment_Control_Item_Data *it;
|
2012-05-03 15:43:26 -07:00
|
|
|
|
2012-11-25 22:32:53 -08:00
|
|
|
it = _item_find(obj, idx);
|
2014-03-26 02:04:37 -07:00
|
|
|
if (it) return it->label;
|
2011-04-07 09:44:54 -07:00
|
|
|
|
2014-03-26 02:04:37 -07:00
|
|
|
return NULL;
|
2012-11-25 22:32:53 -08:00
|
|
|
}
|
2012-05-03 15:43:26 -07:00
|
|
|
|
2014-03-26 02:04:37 -07:00
|
|
|
EOLIAN static Evas_Object*
|
2015-06-25 04:21:00 -07:00
|
|
|
_elm_segment_control_item_icon_get(const Eo *obj, Elm_Segment_Control_Data *_pd EINA_UNUSED, int idx)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2014-09-27 22:14:10 -07:00
|
|
|
Elm_Segment_Control_Item_Data *it = _item_find(obj, idx);
|
2014-03-26 02:04:37 -07:00
|
|
|
if (it) return it->icon;
|
|
|
|
return NULL;
|
2012-11-25 22:32:53 -08:00
|
|
|
}
|
2011-04-07 09:44:54 -07:00
|
|
|
|
2014-03-26 02:04:37 -07:00
|
|
|
EOLIAN static int
|
|
|
|
_elm_segment_control_item_count_get(Eo *obj EINA_UNUSED, Elm_Segment_Control_Data *sd)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2014-03-26 02:04:37 -07:00
|
|
|
return eina_list_count(sd->items);
|
2011-04-07 09:44:54 -07:00
|
|
|
}
|
|
|
|
|
2014-09-27 22:14:10 -07:00
|
|
|
EOLIAN static Evas_Object *
|
2015-06-25 04:21:00 -07:00
|
|
|
_elm_segment_control_item_object_get(const Eo *eo_it EINA_UNUSED, Elm_Segment_Control_Item_Data *it)
|
2014-09-27 22:14:10 -07:00
|
|
|
{
|
2011-10-20 18:08:01 -07:00
|
|
|
return VIEW(it);
|
2011-04-07 09:44:54 -07:00
|
|
|
}
|
|
|
|
|
2014-03-26 02:04:37 -07:00
|
|
|
EOLIAN static Elm_Object_Item*
|
|
|
|
_elm_segment_control_item_selected_get(Eo *obj EINA_UNUSED, Elm_Segment_Control_Data *sd)
|
2011-04-07 09:44:54 -07:00
|
|
|
{
|
2014-08-19 00:52:24 -07:00
|
|
|
return EO_OBJ(sd->selected_item);
|
2011-04-07 09:44:54 -07:00
|
|
|
}
|
|
|
|
|
2014-09-27 22:14:10 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_segment_control_item_selected_set(Eo *eo_item EINA_UNUSED,
|
|
|
|
Elm_Segment_Control_Item_Data *item,
|
|
|
|
Eina_Bool selected)
|
|
|
|
{
|
|
|
|
ELM_SEGMENT_CONTROL_ITEM_CHECK_OR_RETURN(item);
|
|
|
|
ELM_SEGMENT_CONTROL_DATA_GET(WIDGET(item), sd);
|
2012-05-03 15:43:26 -07:00
|
|
|
|
|
|
|
if (item == sd->selected_item)
|
2011-04-07 09:44:54 -07:00
|
|
|
{
|
|
|
|
//already in selected state.
|
2011-06-09 22:12:28 -07:00
|
|
|
if (selected) return;
|
2011-04-07 09:44:54 -07:00
|
|
|
|
|
|
|
//unselect case
|
2012-01-01 22:01:24 -08:00
|
|
|
_segment_off(item);
|
2011-04-07 09:44:54 -07:00
|
|
|
}
|
2011-06-09 22:12:28 -07:00
|
|
|
else if (selected)
|
2012-01-01 22:01:24 -08:00
|
|
|
_segment_on(item);
|
2011-04-07 09:44:54 -07:00
|
|
|
}
|
|
|
|
|
2014-03-26 02:04:37 -07:00
|
|
|
EOLIAN static Elm_Object_Item*
|
2015-06-25 04:21:00 -07:00
|
|
|
_elm_segment_control_item_get(const Eo *obj, Elm_Segment_Control_Data *_pd EINA_UNUSED, int idx)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2014-09-27 22:14:10 -07:00
|
|
|
Elm_Segment_Control_Item_Data *it = _item_find(obj, idx);
|
2014-08-19 00:52:24 -07:00
|
|
|
return EO_OBJ(it);
|
2011-04-07 09:44:54 -07:00
|
|
|
}
|
|
|
|
|
2014-09-27 22:14:10 -07:00
|
|
|
EOLIAN static int
|
2015-06-25 04:21:00 -07:00
|
|
|
_elm_segment_control_item_index_get(const Eo *eo_it EINA_UNUSED, Elm_Segment_Control_Item_Data *it)
|
2011-04-07 09:44:54 -07:00
|
|
|
{
|
2012-05-03 15:43:26 -07:00
|
|
|
ELM_SEGMENT_CONTROL_ITEM_CHECK_OR_RETURN(it, -1);
|
|
|
|
|
2014-09-27 22:14:10 -07:00
|
|
|
return it->seg_index;
|
2011-04-07 09:44:54 -07:00
|
|
|
}
|
2012-11-25 22:32:53 -08:00
|
|
|
|
2014-03-26 02:04:37 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_segment_control_class_constructor(Eo_Class *klass)
|
|
|
|
{
|
2013-11-07 03:44:22 -08:00
|
|
|
evas_smart_legacy_type_register(MY_CLASS_NAME_LEGACY, klass);
|
2013-02-09 23:52:31 -08:00
|
|
|
|
2012-11-25 22:32:53 -08:00
|
|
|
if (_elm_config->access_mode == ELM_ACCESS_MODE_ON)
|
|
|
|
_elm_segment_control_smart_focus_next_enable = EINA_TRUE;
|
|
|
|
}
|
2014-03-26 02:04:37 -07:00
|
|
|
|
2014-09-27 22:14:10 -07:00
|
|
|
#include "elm_segment_control_item.eo.c"
|
2014-03-26 02:04:37 -07:00
|
|
|
#include "elm_segment_control.eo.c"
|