2011-04-07 09:44:54 -07:00
|
|
|
#include <Elementary.h>
|
|
|
|
#include "elm_priv.h"
|
2012-05-03 15:43:26 -07:00
|
|
|
#include "elm_widget_layout.h"
|
2011-04-07 09:44:54 -07:00
|
|
|
|
2012-05-03 15:43:26 -07:00
|
|
|
static const char SEGMENT_CONTROL_SMART_NAME[] = "elm_segment_control";
|
2011-04-07 09:44:54 -07:00
|
|
|
|
2012-05-03 15:43:26 -07:00
|
|
|
typedef struct _Elm_Segment_Control_Smart_Data Elm_Segment_Control_Smart_Data;
|
|
|
|
typedef struct _Elm_Segment_Item Elm_Segment_Item;
|
|
|
|
|
|
|
|
struct _Elm_Segment_Control_Smart_Data
|
2011-04-07 09:44:54 -07:00
|
|
|
{
|
2012-05-03 15:43:26 -07:00
|
|
|
Elm_Layout_Smart_Data base;
|
|
|
|
|
|
|
|
Eina_List *items;
|
|
|
|
Elm_Segment_Item *selected_item;
|
|
|
|
|
|
|
|
int item_width;
|
2011-04-07 09:44:54 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct _Elm_Segment_Item
|
|
|
|
{
|
2011-10-20 17:45:19 -07:00
|
|
|
ELM_WIDGET_ITEM;
|
2012-05-03 15:43:26 -07:00
|
|
|
|
2011-04-07 09:44:54 -07:00
|
|
|
Evas_Object *icon;
|
2012-05-03 15:43:26 -07:00
|
|
|
const char *label;
|
|
|
|
int seg_index;
|
2011-04-07 09:44:54 -07:00
|
|
|
};
|
|
|
|
|
2012-05-03 15:43:26 -07:00
|
|
|
#define ELM_SEGMENT_CONTROL_DATA_GET(o, sd) \
|
|
|
|
Elm_Segment_Control_Smart_Data * sd = evas_object_smart_data_get(o)
|
|
|
|
|
|
|
|
#define ELM_SEGMENT_CONTROL_DATA_GET_OR_RETURN(o, ptr) \
|
|
|
|
ELM_SEGMENT_CONTROL_DATA_GET(o, ptr); \
|
|
|
|
if (!ptr) \
|
|
|
|
{ \
|
|
|
|
CRITICAL("No widget data for object %p (%s)", \
|
|
|
|
o, evas_object_type_get(o)); \
|
|
|
|
return; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define ELM_SEGMENT_CONTROL_DATA_GET_OR_RETURN_VAL(o, ptr, val) \
|
|
|
|
ELM_SEGMENT_CONTROL_DATA_GET(o, ptr); \
|
|
|
|
if (!ptr) \
|
|
|
|
{ \
|
|
|
|
CRITICAL("No widget data for object %p (%s)", \
|
|
|
|
o, evas_object_type_get(o)); \
|
|
|
|
return val; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define ELM_SEGMENT_CONTROL_CHECK(obj) \
|
|
|
|
if (!obj || !elm_widget_type_check \
|
|
|
|
((obj), SEGMENT_CONTROL_SMART_NAME, __func__)) \
|
|
|
|
return
|
|
|
|
|
|
|
|
#define ELM_SEGMENT_CONTROL_ITEM_CHECK(it) \
|
|
|
|
ELM_WIDGET_ITEM_CHECK_OR_RETURN((Elm_Widget_Item *)it, ); \
|
|
|
|
ELM_SEGMENT_CONTROL_CHECK(it->base.widget);
|
|
|
|
|
|
|
|
#define ELM_SEGMENT_CONTROL_ITEM_CHECK_OR_RETURN(it, ...) \
|
|
|
|
ELM_WIDGET_ITEM_CHECK_OR_RETURN((Elm_Widget_Item *)it, __VA_ARGS__); \
|
|
|
|
ELM_SEGMENT_CONTROL_CHECK(it->base.widget) __VA_ARGS__;
|
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, ""},
|
|
|
|
{NULL, NULL}
|
|
|
|
};
|
|
|
|
|
2012-05-03 15:43:26 -07:00
|
|
|
/* Inheriting from elm_layout. Besides, we need no more than what is
|
|
|
|
* there */
|
|
|
|
EVAS_SMART_SUBCLASS_NEW
|
|
|
|
(SEGMENT_CONTROL_SMART_NAME, _elm_segment_control, Elm_Layout_Smart_Class,
|
|
|
|
Elm_Layout_Smart_Class, elm_layout_smart_class_get, _smart_callbacks);
|
|
|
|
|
2011-04-07 09:44:54 -07:00
|
|
|
static void
|
2012-05-03 15:43:26 -07:00
|
|
|
_elm_segment_control_smart_sizing_eval(Evas_Object *obj)
|
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
|
|
|
|
2012-05-03 15:43:26 -07:00
|
|
|
ELM_SEGMENT_CONTROL_DATA_GET(obj, sd);
|
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
|
|
|
|
(ELM_WIDGET_DATA(sd)->resize_obj, &minw, &minh, minw, minh);
|
|
|
|
elm_coords_finger_size_adjust(item_count, &minw, 1, &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
|
2012-05-03 15:43:26 -07:00
|
|
|
_item_free(Elm_Segment_Item *it)
|
|
|
|
{
|
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;
|
|
|
|
if (sd->items) sd->items = eina_list_remove(sd->items, it);
|
|
|
|
|
|
|
|
if (it->icon) evas_object_del(it->icon);
|
|
|
|
if (it->label) eina_stringshare_del(it->label);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_position_items(Elm_Segment_Control_Smart_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;
|
2011-04-07 09:44:54 -07:00
|
|
|
Elm_Segment_Item *it;
|
2012-05-03 15:43:26 -07:00
|
|
|
int bx, by, bw, bh, pos;
|
|
|
|
|
|
|
|
item_count = eina_list_count(sd->items);
|
|
|
|
if (item_count <= 0) return;
|
|
|
|
|
|
|
|
evas_object_geometry_get
|
|
|
|
(ELM_WIDGET_DATA(sd)->resize_obj, &bx, &by, &bw, &bh);
|
|
|
|
sd->item_width = bw / item_count;
|
|
|
|
rtl = elm_widget_mirrored_get(ELM_WIDGET_DATA(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
|
|
|
|
2012-05-03 15:43:26 -07:00
|
|
|
EINA_LIST_FOREACH (sd->items, l, it)
|
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-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;
|
|
|
|
}
|
|
|
|
|
|
|
|
elm_layout_sizing_eval(ELM_WIDGET_DATA(sd)->obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_swallow_item_objects(Elm_Segment_Item *it)
|
|
|
|
{
|
|
|
|
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
|
2012-05-03 15:43:26 -07:00
|
|
|
_update_list(Elm_Segment_Control_Smart_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;
|
2012-05-02 10:00:24 -07:00
|
|
|
Elm_Segment_Item *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)
|
|
|
|
{
|
|
|
|
it = eina_list_nth(sd->items, 0);
|
|
|
|
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-05-03 15:43:26 -07:00
|
|
|
if (elm_widget_disabled_get(ELM_WIDGET_DATA(sd)->obj))
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
rtl = elm_widget_mirrored_get(ELM_WIDGET_DATA(sd)->obj);
|
|
|
|
EINA_LIST_FOREACH (sd->items, l, it)
|
2011-04-07 09:44:54 -07:00
|
|
|
{
|
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");
|
|
|
|
|
|
|
|
if (elm_widget_disabled_get(ELM_WIDGET_DATA(sd)->obj))
|
|
|
|
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++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_elm_segment_control_smart_theme(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Eina_List *l;
|
|
|
|
Eina_Bool rtl;
|
|
|
|
Elm_Segment_Item *it;
|
|
|
|
|
|
|
|
ELM_SEGMENT_CONTROL_DATA_GET(obj, sd);
|
|
|
|
|
|
|
|
if (!ELM_WIDGET_CLASS(_elm_segment_control_parent_sc)->theme(obj))
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
|
|
|
rtl = elm_widget_mirrored_get(obj);
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH (sd->items, l, it)
|
|
|
|
{
|
|
|
|
elm_widget_theme_object_set
|
|
|
|
(obj, VIEW(it), "segment_control", "item",
|
|
|
|
elm_widget_style_get(obj));
|
|
|
|
edje_object_scale_set(VIEW(it), elm_widget_scale_get(VIEW(it)) *
|
|
|
|
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);
|
|
|
|
|
|
|
|
return EINA_TRUE;
|
2011-04-07 09:44:54 -07:00
|
|
|
}
|
|
|
|
|
2012-05-03 15:43:26 -07:00
|
|
|
static Eina_Bool
|
|
|
|
_elm_segment_control_smart_disable(Evas_Object *obj)
|
2011-04-07 09:44:54 -07:00
|
|
|
{
|
2012-05-03 15:43:26 -07:00
|
|
|
ELM_SEGMENT_CONTROL_DATA_GET(obj, sd);
|
|
|
|
|
|
|
|
if (!ELM_WIDGET_CLASS(_elm_segment_control_parent_sc)->disable(obj))
|
|
|
|
return EINA_FALSE;
|
2011-04-07 09:44:54 -07:00
|
|
|
|
2012-05-03 15:43:26 -07:00
|
|
|
_update_list(sd);
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
Elm_Segment_Item *it = eina_list_data_get(list);
|
|
|
|
|
|
|
|
if (it) return NULL;
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
2012-05-03 15:43:26 -07:00
|
|
|
_elm_segment_control_smart_focus_next(const Evas_Object *obj,
|
|
|
|
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
|
|
|
|
2012-05-03 15:43:26 -07:00
|
|
|
ELM_SEGMENT_CONTROL_DATA_GET(obj, sd);
|
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;
|
|
|
|
if (!items) return EINA_FALSE;
|
|
|
|
}
|
2012-05-03 15:43:26 -07:00
|
|
|
|
2011-04-07 09:44:54 -07:00
|
|
|
return elm_widget_focus_list_next_get(obj, items, list_data_get, dir, next);
|
|
|
|
}
|
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
|
|
|
|
_segment_off(Elm_Segment_Item *it)
|
|
|
|
{
|
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
|
|
|
|
_segment_on(Elm_Segment_Item *it)
|
|
|
|
{
|
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;
|
|
|
|
evas_object_smart_callback_call(ELM_WIDGET_DATA(sd)->obj, SIG_CHANGED, it);
|
2011-04-07 09:44:54 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-05-03 15:43:26 -07:00
|
|
|
_on_move_resize(void *data, Evas *e __UNUSED__,
|
|
|
|
Evas_Object *obj __UNUSED__,
|
2011-04-07 09:44:54 -07:00
|
|
|
void *event_info __UNUSED__)
|
|
|
|
{
|
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,
|
|
|
|
Evas *e __UNUSED__,
|
|
|
|
Evas_Object *obj __UNUSED__,
|
|
|
|
void *event_info)
|
2011-04-07 09:44:54 -07:00
|
|
|
{
|
|
|
|
Elm_Segment_Item *it;
|
|
|
|
Evas_Event_Mouse_Up *ev;
|
|
|
|
Evas_Coord x, y, w, h;
|
|
|
|
|
|
|
|
it = data;
|
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 (elm_widget_disabled_get(ELM_WIDGET_DATA(sd)->obj)) return;
|
2011-04-07 09:44:54 -07:00
|
|
|
|
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
|
|
|
|
2011-06-13 04:26:08 -07:00
|
|
|
if ((ev->canvas.x >= x) && (ev->output.x <= (x + w)) && (ev->canvas.y >= y)
|
|
|
|
&& (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,
|
|
|
|
Evas *e __UNUSED__,
|
|
|
|
Evas_Object *obj __UNUSED__,
|
|
|
|
void *event_info __UNUSED__)
|
2011-04-07 09:44:54 -07:00
|
|
|
{
|
|
|
|
Elm_Segment_Item *it;
|
|
|
|
|
|
|
|
it = data;
|
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 (elm_widget_disabled_get(ELM_WIDGET_DATA(sd)->obj)) return;
|
2011-04-07 09:44:54 -07:00
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
static Elm_Segment_Item *
|
2012-05-03 15:43:26 -07:00
|
|
|
_item_find(const Evas_Object *obj,
|
|
|
|
int idx)
|
2011-04-07 09:44:54 -07:00
|
|
|
{
|
|
|
|
Elm_Segment_Item *it;
|
|
|
|
|
2012-05-03 15:43:26 -07:00
|
|
|
ELM_SEGMENT_CONTROL_DATA_GET(obj, sd);
|
2011-04-07 09:44:54 -07:00
|
|
|
|
2012-05-03 15:43:26 -07:00
|
|
|
it = eina_list_nth(sd->items, idx);
|
2011-04-07 09:44:54 -07:00
|
|
|
return it;
|
|
|
|
}
|
|
|
|
|
2012-01-01 22:54:18 -08:00
|
|
|
static void
|
2012-05-03 15:43:26 -07:00
|
|
|
_item_text_set_hook(Elm_Object_Item *it,
|
|
|
|
const char *part,
|
|
|
|
const char *label)
|
2012-01-01 22:54:18 -08:00
|
|
|
{
|
|
|
|
Elm_Segment_Item *item;
|
|
|
|
|
|
|
|
if (part && strcmp(part, "default")) return;
|
|
|
|
|
2012-03-06 03:51:42 -08:00
|
|
|
item = (Elm_Segment_Item *)it;
|
2012-01-01 22:54:18 -08:00
|
|
|
eina_stringshare_replace(&item->label, label);
|
|
|
|
if (item->label)
|
|
|
|
edje_object_signal_emit(VIEW(item), "elm,state,text,visible", "elm");
|
|
|
|
else
|
|
|
|
edje_object_signal_emit(VIEW(item), "elm,state,text,hidden", "elm");
|
|
|
|
edje_object_message_signal_process(VIEW(item));
|
2012-05-03 15:43:26 -07:00
|
|
|
|
2012-01-01 22:54:18 -08:00
|
|
|
//label can be NULL also.
|
2012-04-20 05:51:10 -07:00
|
|
|
edje_object_part_text_escaped_set(VIEW(item), "elm.text", item->label);
|
2012-01-01 22:54:18 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static const char *
|
2012-05-03 15:43:26 -07:00
|
|
|
_item_text_get_hook(const Elm_Object_Item *it,
|
|
|
|
const char *part)
|
2012-01-01 22:54:18 -08:00
|
|
|
{
|
|
|
|
if (part && strcmp(part, "default")) return NULL;
|
2012-03-06 03:51:42 -08:00
|
|
|
return ((Elm_Segment_Item *)it)->label;
|
2012-01-01 22:54:18 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_item_content_set_hook(Elm_Object_Item *it,
|
|
|
|
const char *part,
|
|
|
|
Evas_Object *content)
|
|
|
|
{
|
|
|
|
Elm_Segment_Item *item;
|
2012-05-03 15:43:26 -07:00
|
|
|
|
2012-01-01 22:54:18 -08:00
|
|
|
if (part && strcmp(part, "icon")) return;
|
|
|
|
|
2012-03-06 03:51:42 -08:00
|
|
|
item = (Elm_Segment_Item *)it;
|
2012-03-29 03:08:37 -07:00
|
|
|
if (content == item->icon) return;
|
2012-01-01 22:54:18 -08:00
|
|
|
|
|
|
|
//Remove the existing icon
|
2012-03-29 03:08:37 -07:00
|
|
|
if (item->icon) evas_object_del(item->icon);
|
2012-01-01 22:54:18 -08: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");
|
|
|
|
}
|
|
|
|
|
|
|
|
static Evas_Object *
|
2012-05-03 15:43:26 -07:00
|
|
|
_item_content_get_hook(const Elm_Object_Item *it,
|
|
|
|
const char *part)
|
2012-01-01 22:54:18 -08:00
|
|
|
{
|
|
|
|
if (part && strcmp(part, "icon")) return NULL;
|
2012-05-03 15:43:26 -07:00
|
|
|
|
2012-03-06 03:51:42 -08:00
|
|
|
return ((Elm_Segment_Item *)it)->icon;
|
2012-01-01 22:54:18 -08:00
|
|
|
}
|
|
|
|
|
2012-01-27 03:56:14 -08:00
|
|
|
static Eina_Bool
|
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_del_pre_hook(Elm_Object_Item *it)
|
|
|
|
{
|
2012-03-06 03:51:42 -08:00
|
|
|
Elm_Segment_Item *item = (Elm_Segment_Item *)it;
|
2012-07-01 18:39:10 -07:00
|
|
|
ELM_SEGMENT_CONTROL_DATA_GET(WIDGET(it), 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
|
|
|
|
|
|
|
return EINA_TRUE;
|
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-05-03 15:43:26 -07:00
|
|
|
static Elm_Segment_Item *
|
|
|
|
_item_new(Evas_Object *obj,
|
|
|
|
Evas_Object *icon,
|
|
|
|
const char *label)
|
2011-04-07 09:44:54 -07:00
|
|
|
{
|
|
|
|
Elm_Segment_Item *it;
|
|
|
|
|
|
|
|
it = elm_widget_item_new(obj, Elm_Segment_Item);
|
|
|
|
if (!it) return NULL;
|
2012-05-03 15:43:26 -07:00
|
|
|
|
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
|
|
|
elm_widget_item_del_pre_hook_set(it, _item_del_pre_hook);
|
2012-01-01 22:54:18 -08:00
|
|
|
elm_widget_item_text_set_hook_set(it, _item_text_set_hook);
|
|
|
|
elm_widget_item_text_get_hook_set(it, _item_text_get_hook);
|
|
|
|
elm_widget_item_content_set_hook_set(it, _item_content_set_hook);
|
|
|
|
elm_widget_item_content_get_hook_set(it, _item_content_get_hook);
|
2011-04-07 09:44:54 -07:00
|
|
|
|
2011-10-20 18:08:01 -07:00
|
|
|
VIEW(it) = edje_object_add(evas_object_evas_get(obj));
|
2012-05-03 15:43:26 -07:00
|
|
|
edje_object_scale_set
|
|
|
|
(VIEW(it), elm_widget_scale_get(VIEW(it)) * elm_config_scale_get());
|
2011-10-20 18:08:01 -07:00
|
|
|
evas_object_smart_member_add(VIEW(it), obj);
|
2012-05-03 15:43:26 -07:00
|
|
|
|
2011-10-20 18:08:01 -07:00
|
|
|
elm_widget_sub_object_add(obj, VIEW(it));
|
2012-05-03 15:43:26 -07:00
|
|
|
elm_widget_theme_object_set
|
|
|
|
(obj, VIEW(it), "segment_control", "item", elm_object_style_get(obj));
|
|
|
|
edje_object_mirrored_set(VIEW(it), elm_widget_mirrored_get(WIDGET(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
|
|
|
|
|
|
|
return it;
|
|
|
|
}
|
|
|
|
|
2012-05-03 15:43:26 -07:00
|
|
|
static void
|
|
|
|
_elm_segment_control_smart_add(Evas_Object *obj)
|
2012-05-02 10:00:24 -07:00
|
|
|
{
|
2012-05-03 15:43:26 -07:00
|
|
|
EVAS_SMART_DATA_ALLOC(obj, Elm_Segment_Control_Smart_Data);
|
|
|
|
|
|
|
|
ELM_WIDGET_CLASS(_elm_segment_control_parent_sc)->base.add(obj);
|
|
|
|
|
|
|
|
elm_layout_theme_set
|
|
|
|
(obj, "segment_control", "base", elm_widget_style_get(obj));
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_elm_segment_control_smart_del(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Elm_Segment_Item *it;
|
2012-05-02 10:00:24 -07:00
|
|
|
|
2012-05-03 15:43:26 -07:00
|
|
|
ELM_SEGMENT_CONTROL_DATA_GET(obj, sd);
|
2012-05-02 10:00:24 -07:00
|
|
|
|
2012-05-03 15:43:26 -07:00
|
|
|
EINA_LIST_FREE (sd->items, it)
|
|
|
|
{
|
|
|
|
_item_free(it);
|
|
|
|
elm_widget_item_free(it);
|
|
|
|
}
|
|
|
|
|
|
|
|
ELM_WIDGET_CLASS(_elm_segment_control_parent_sc)->base.del(obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_elm_segment_control_smart_set_user(Elm_Layout_Smart_Class *sc)
|
|
|
|
{
|
|
|
|
ELM_WIDGET_CLASS(sc)->base.add = _elm_segment_control_smart_add;
|
|
|
|
ELM_WIDGET_CLASS(sc)->base.del = _elm_segment_control_smart_del;
|
|
|
|
|
|
|
|
ELM_WIDGET_CLASS(sc)->theme = _elm_segment_control_smart_theme;
|
|
|
|
ELM_WIDGET_CLASS(sc)->disable = _elm_segment_control_smart_disable;
|
2011-04-07 09:44:54 -07:00
|
|
|
|
|
|
|
#if 0
|
2012-05-03 15:43:26 -07:00
|
|
|
ELM_WIDGET_CLASS(sc)->focus_next = _elm_segment_control_smart_focus_next;
|
|
|
|
#else
|
|
|
|
ELM_WIDGET_CLASS(sc)->focus_next = NULL; /* not 'focus chain manager' */
|
2011-04-07 09:44:54 -07:00
|
|
|
#endif
|
|
|
|
|
2012-05-03 15:43:26 -07:00
|
|
|
ELM_WIDGET_CLASS(sc)->focus_direction = NULL;
|
|
|
|
|
|
|
|
sc->sizing_eval = _elm_segment_control_smart_sizing_eval;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI Evas_Object *
|
|
|
|
elm_segment_control_add(Evas_Object *parent)
|
|
|
|
{
|
|
|
|
Evas *e;
|
|
|
|
Evas_Object *obj;
|
|
|
|
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
|
|
|
|
|
|
|
|
e = evas_object_evas_get(parent);
|
|
|
|
if (!e) return NULL;
|
2011-04-07 09:44:54 -07:00
|
|
|
|
2012-05-03 15:43:26 -07:00
|
|
|
obj = evas_object_smart_add(e, _elm_segment_control_smart_class_new());
|
2011-04-07 09:44:54 -07:00
|
|
|
|
2012-05-03 15:43:26 -07:00
|
|
|
if (!elm_widget_sub_object_add(parent, obj))
|
|
|
|
ERR("could not add %p as sub object of %p", obj, parent);
|
2011-04-21 17:42:32 -07:00
|
|
|
|
2011-04-07 09:44:54 -07:00
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
2012-01-01 22:01:24 -08:00
|
|
|
EAPI Elm_Object_Item *
|
2012-05-03 15:43:26 -07:00
|
|
|
elm_segment_control_item_add(Evas_Object *obj,
|
|
|
|
Evas_Object *icon,
|
2011-04-07 09:44:54 -07:00
|
|
|
const char *label)
|
|
|
|
{
|
|
|
|
Elm_Segment_Item *it;
|
|
|
|
|
2012-05-03 15:43:26 -07:00
|
|
|
ELM_SEGMENT_CONTROL_CHECK(obj) NULL;
|
|
|
|
ELM_SEGMENT_CONTROL_DATA_GET(obj, sd);
|
2011-04-07 09:44:54 -07:00
|
|
|
|
|
|
|
it = _item_new(obj, icon, label);
|
|
|
|
if (!it) return NULL;
|
|
|
|
|
2012-05-03 15:43:26 -07:00
|
|
|
sd->items = eina_list_append(sd->items, it);
|
|
|
|
_update_list(sd);
|
2011-04-07 09:44:54 -07:00
|
|
|
|
2012-03-06 03:51:42 -08:00
|
|
|
return (Elm_Object_Item *)it;
|
2011-04-07 09:44:54 -07:00
|
|
|
}
|
|
|
|
|
2012-01-01 22:01:24 -08:00
|
|
|
EAPI Elm_Object_Item *
|
2012-05-03 15:43:26 -07:00
|
|
|
elm_segment_control_item_insert_at(Evas_Object *obj,
|
|
|
|
Evas_Object *icon,
|
|
|
|
const char *label,
|
|
|
|
int idx)
|
2011-04-07 09:44:54 -07:00
|
|
|
{
|
|
|
|
Elm_Segment_Item *it, *it_rel;
|
|
|
|
|
2012-05-03 15:43:26 -07:00
|
|
|
ELM_SEGMENT_CONTROL_CHECK(obj) NULL;
|
|
|
|
ELM_SEGMENT_CONTROL_DATA_GET(obj, sd);
|
|
|
|
|
2011-06-09 22:12:28 -07:00
|
|
|
if (idx < 0) idx = 0;
|
2011-04-07 09:44:54 -07:00
|
|
|
|
|
|
|
it = _item_new(obj, icon, label);
|
|
|
|
if (!it) return NULL;
|
|
|
|
|
2011-06-09 22:12:28 -07:00
|
|
|
it_rel = _item_find(obj, idx);
|
2012-05-03 15:43:26 -07:00
|
|
|
if (it_rel) sd->items = eina_list_prepend_relative(sd->items, it, it_rel);
|
|
|
|
else sd->items = eina_list_append(sd->items, it);
|
|
|
|
|
|
|
|
_update_list(sd);
|
2011-04-07 09:44:54 -07:00
|
|
|
|
2012-03-06 03:51:42 -08:00
|
|
|
return (Elm_Object_Item *)it;
|
2011-04-07 09:44:54 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
2012-05-03 15:43:26 -07:00
|
|
|
elm_segment_control_item_del_at(Evas_Object *obj,
|
|
|
|
int idx)
|
2011-04-07 09:44:54 -07:00
|
|
|
{
|
|
|
|
Elm_Segment_Item *it;
|
|
|
|
|
2012-05-03 15:43:26 -07:00
|
|
|
ELM_SEGMENT_CONTROL_CHECK(obj);
|
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
|
|
|
|
2012-03-06 03:51:42 -08:00
|
|
|
elm_object_item_del((Elm_Object_Item *)it);
|
2011-04-07 09:44:54 -07:00
|
|
|
}
|
|
|
|
|
2012-05-03 15:43:26 -07:00
|
|
|
EAPI const char *
|
|
|
|
elm_segment_control_item_label_get(const Evas_Object *obj,
|
|
|
|
int idx)
|
2011-04-07 09:44:54 -07:00
|
|
|
{
|
2012-05-03 15:43:26 -07:00
|
|
|
Elm_Segment_Item *it;
|
|
|
|
|
|
|
|
ELM_SEGMENT_CONTROL_CHECK(obj) NULL;
|
|
|
|
|
|
|
|
it = _item_find(obj, idx);
|
2011-04-07 09:44:54 -07:00
|
|
|
if (it) return it->label;
|
2012-05-03 15:43:26 -07:00
|
|
|
|
2011-04-07 09:44:54 -07:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI Evas_Object *
|
2012-05-03 15:43:26 -07:00
|
|
|
elm_segment_control_item_icon_get(const Evas_Object *obj,
|
|
|
|
int idx)
|
2011-04-07 09:44:54 -07:00
|
|
|
{
|
2012-05-03 15:43:26 -07:00
|
|
|
ELM_SEGMENT_CONTROL_CHECK(obj) NULL;
|
|
|
|
|
2012-01-01 22:54:18 -08:00
|
|
|
Elm_Segment_Item *it = _item_find(obj, idx);
|
2011-04-07 09:44:54 -07:00
|
|
|
if (it) return it->icon;
|
2012-05-03 15:43:26 -07:00
|
|
|
|
2011-04-07 09:44:54 -07:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI int
|
|
|
|
elm_segment_control_item_count_get(const Evas_Object *obj)
|
|
|
|
{
|
2012-05-03 15:43:26 -07:00
|
|
|
ELM_SEGMENT_CONTROL_CHECK(obj) 0;
|
|
|
|
ELM_SEGMENT_CONTROL_DATA_GET(obj, sd);
|
2011-04-07 09:44:54 -07:00
|
|
|
|
2012-05-03 15:43:26 -07:00
|
|
|
return eina_list_count(sd->items);
|
2011-04-07 09:44:54 -07:00
|
|
|
}
|
|
|
|
|
2012-05-03 15:43:26 -07:00
|
|
|
EAPI Evas_Object *
|
2012-01-01 22:01:24 -08:00
|
|
|
elm_segment_control_item_object_get(const Elm_Object_Item *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, NULL);
|
|
|
|
|
2011-10-20 18:08:01 -07:00
|
|
|
return VIEW(it);
|
2011-04-07 09:44:54 -07:00
|
|
|
}
|
|
|
|
|
2012-05-03 15:43:26 -07:00
|
|
|
EAPI Elm_Object_Item *
|
2011-04-07 09:44:54 -07:00
|
|
|
elm_segment_control_item_selected_get(const Evas_Object *obj)
|
|
|
|
{
|
2012-05-03 15:43:26 -07:00
|
|
|
ELM_SEGMENT_CONTROL_CHECK(obj) NULL;
|
|
|
|
ELM_SEGMENT_CONTROL_DATA_GET(obj, sd);
|
|
|
|
|
|
|
|
return (Elm_Object_Item *)sd->selected_item;
|
2011-04-07 09:44:54 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
2012-05-03 15:43:26 -07:00
|
|
|
elm_segment_control_item_selected_set(Elm_Object_Item *it,
|
|
|
|
Eina_Bool selected)
|
2011-04-07 09:44:54 -07:00
|
|
|
{
|
2012-03-06 03:51:42 -08:00
|
|
|
Elm_Segment_Item *item = (Elm_Segment_Item *)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);
|
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 (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
|
|
|
}
|
|
|
|
|
2012-01-01 22:01:24 -08:00
|
|
|
EAPI Elm_Object_Item *
|
2012-05-03 15:43:26 -07:00
|
|
|
elm_segment_control_item_get(const Evas_Object *obj,
|
|
|
|
int idx)
|
2011-04-07 09:44:54 -07:00
|
|
|
{
|
2012-05-03 15:43:26 -07:00
|
|
|
ELM_SEGMENT_CONTROL_CHECK(obj) NULL;
|
|
|
|
|
|
|
|
return (Elm_Object_Item *)_item_find(obj, idx);
|
2011-04-07 09:44:54 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI int
|
2012-01-01 22:01:24 -08:00
|
|
|
elm_segment_control_item_index_get(const Elm_Object_Item *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);
|
|
|
|
|
2012-03-06 03:51:42 -08:00
|
|
|
return ((Elm_Segment_Item *)it)->seg_index;
|
2011-04-07 09:44:54 -07:00
|
|
|
}
|