* @defgroup SegmentControl SegmentControl
* @ingroup Elementary
*
- * SegmentControl object is a horizontal control made of multiple segments,
- * each segment item functioning as a discrete button. A segmented control affords a compact means to group together a number of controls.
- * A segmented control can display a title or an image. The UISegmentedControl object automatically resizes segment items to fit proportionally
- * within their superview unless they have a specific width set. When you add and remove segments,
- * you can request that the action be animated with sliding and fading effects.
+ * SegmentControl Widget is a horizontal control made of multiple segments, each segment item
+ * functioning as a discrete two state button. A segmented control affords a compact means to group together a number of controls.
+ * Only one Segment item can be at selected state. A segmented control item can display combination of Text and Icon.
*/
typedef struct _Widget_Data Widget_Data;
+
struct _Widget_Data
{
- Evas_Object *box;
+ Evas_Object *obj;
Evas_Object *base;
- Eina_List *seg_ctrl;
- Elm_Segment_Item *ani_it;
- Ecore_Animator *ani;
- void *data;
- int width, height;
- int id;
+ Eina_List *seg_items;
+ unsigned int item_count;
+ Elm_Segment_Item *selected_item;
int item_width;
- int cur_fontsize;
- int max_height, w_pad, h_pad;
- unsigned int count;
- unsigned int insert_index;
- unsigned int del_index;
- unsigned int cur_seg_id;
- double scale_factor;
- Eina_Bool selected : 1;
};
struct _Elm_Segment_Item
{
- Evas_Object *obj;
Evas_Object *base;
Evas_Object *icon;
- Evas_Object *label_wd;
- const char *label;
- int segment_id;
- Eina_Bool delete_me : 1;
+ Evas_Object *label;
+ int seg_index;
+ Widget_Data *wd;
};
-static void _mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event_info);
-static void _mouse_up(void *data, Evas *e, Evas_Object *obj, void *event_info);
-static void _signal_segment_on(void *data);
-static void _signal_segment_off(void *data);
-static void _theme_hook(Evas_Object *obj);
static void _item_free(Evas_Object *obj, Elm_Segment_Item *it);
static void _del_hook(Evas_Object *obj);
-static void _layout(Evas_Object *o, Evas_Object_Box_Data *priv, void *data);
-static void _segment_resizing(void *data);
-static void _object_resize(void *data, Evas *e, Evas_Object *obj, void *event_info);
static void _update_list(Evas_Object *obj);
-static void _refresh_segment_ids(Evas_Object *obj);
-static void _state_value_set(Evas_Object *obj);
-
-static Elm_Segment_Item* _item_new(Evas_Object *obj, const char *label, Evas_Object *icon);
-static Elm_Segment_Item *_item_find(Evas_Object *obj, unsigned int index);
-
-static int * _animator_animate_add_cb(Evas_Object *obj);
-static int * _animator_animate_del_cb(Evas_Object *obj);
static void
-_on_focus_hook(void *data, Evas_Object *obj)
+_sizing_eval(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
+ Evas_Coord minw = -1, minh = -1;
+ Evas_Coord w, h;
+
if (!wd) return;
+ elm_coords_finger_size_adjust(1, &minw, 1, &minh);
+ edje_object_size_min_restricted_calc(wd->base, &minw, &minh, minw, minh);
+ elm_coords_finger_size_adjust(1, &minw, 1, &minh);
- if (elm_widget_focus_get(obj))
- evas_object_focus_set((Evas_Object *)wd->seg_ctrl, 1);
- else
- evas_object_focus_set((Evas_Object *)wd->seg_ctrl, 0);
+ evas_object_size_hint_min_get(obj, &w, &h);
+ if (w > minw) minw = w;
+ if (h > minh) minh = h;
+ evas_object_size_hint_min_set(obj, minw, minh);
}
static void
-_signal_segment_off(void *data)
-{
- Elm_Segment_Item *item = (Elm_Segment_Item *) data;
- Widget_Data *wd = elm_widget_data_get(item->obj);
- if (!wd) return;
-
- edje_object_signal_emit(item->base, "elm,action,unfocus", "elm");
- edje_object_signal_emit(item->base, "elm,state,segment,off", "elm");
- if(!item->label_wd && item->label)
- {
- edje_object_signal_emit(item->base, "elm,state,text,visible", "elm");
- }
- if(item->label_wd)
- {
- elm_label_text_color_set(item->label_wd, 0xff,0xff, 0xff, 0xff);
- }
-
- return;
-}
-
-static void
-_signal_segment_on(void *data)
+_del_hook(Evas_Object *obj)
{
- Elm_Segment_Item *item = (Elm_Segment_Item *) data;
Elm_Segment_Item *it;
- Eina_List *l;
-
- Widget_Data *wd = elm_widget_data_get(item->obj);
- if (!wd) return;
-
- wd->selected = EINA_TRUE;
-
- edje_object_signal_emit(item->base, "elm,state,segment,on", "elm");
- edje_object_signal_emit(item->base, "elm,action,focus", "elm");
- if(!item->label_wd)
- edje_object_signal_emit(item->base, "elm,state,text,change", "elm");
-
- if (item->segment_id == wd->cur_seg_id) return;
+ Widget_Data *wd = elm_widget_data_get(obj);
- EINA_LIST_FOREACH(wd->seg_ctrl, l, it)
- {
- if (it->segment_id == wd->cur_seg_id)
- {
- _signal_segment_off (it);
- break;
- }
- }
- wd->cur_seg_id = item->segment_id;
- evas_object_smart_callback_call(item->obj, "changed", (void*)wd->cur_seg_id);
+ EINA_LIST_FREE(wd->seg_items, it) _item_free(obj, it);
+ free(wd);
return;
}
static void
-_mouse_up(void *data, Evas *e, Evas_Object *obj, void *event_info)
+_theme_hook(Evas_Object *obj)
{
- Elm_Segment_Item *item = (Elm_Segment_Item *) data;
- Widget_Data *wd = elm_widget_data_get(item->obj);
- if (!wd) return;
- Evas_Coord wrap_width = 0, wrap_height = 0, w = 0, h = 0;
-
- if (item->segment_id == wd->cur_seg_id)
- {
- wd->selected = EINA_TRUE;
- return;
- }
- _signal_segment_on((void*)item);
- if(item->label_wd)
- elm_label_text_color_set(item->label_wd, 0x00,0x00, 0x00, 0xff);
+ Eina_List *l;
+ Elm_Segment_Item *it;
+ Widget_Data *wd = elm_widget_data_get(obj);
+ _elm_theme_object_set(obj, wd->base, "segment_control", "base",
+ elm_widget_style_get(obj));
- wd->selected = EINA_FALSE;
- return;
+ EINA_LIST_FOREACH(wd->seg_items, l, it)
+ _elm_theme_object_set(obj, it->base, "segment_control", "item", elm_widget_style_get(obj));
+ _update_list(obj);
+ _sizing_eval(obj);
+ return;
}
static void
-_mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event_info)
+_item_free(Evas_Object *obj, Elm_Segment_Item *it)
{
- Elm_Segment_Item *item = (Elm_Segment_Item *) data;
- Widget_Data *wd = elm_widget_data_get(item->obj);
-
- if (!wd) return;
-
- edje_object_signal_emit(item->base, "elm,action,focus", "elm");
+ Widget_Data *wd = elm_widget_data_get(obj);
+ if (!it || !wd) return;
-}
+ if (wd->selected_item == it) wd->selected_item = NULL;
+ if (wd->seg_items) wd->seg_items = eina_list_remove(wd->seg_items, it);
-static void
-_theme_hook(Evas_Object *obj)
-{
- _elm_theme_object_set(obj, obj, "segmented-control", "base", elm_widget_style_get(obj));
+ if (it->icon) evas_object_del(it->icon);
+ if (it->label) evas_object_del(it->label);
+ if (it->base) evas_object_del(it->base);
+ free(it);
+ it = NULL;
return;
}
static void
-_item_free(Evas_Object *obj, Elm_Segment_Item *it)
+_segment_off(Elm_Segment_Item *it)
{
- Widget_Data *wd = elm_widget_data_get(obj);
- if (!wd) return;
+ if (!it) return;
- if(wd->seg_ctrl)
- wd->seg_ctrl = eina_list_remove(wd->seg_ctrl, it);
+ edje_object_signal_emit(it->base, "elm,state,segment,normal", "elm");
+ if (it->label) elm_object_style_set(it->label, "segment_normal");
- if(it->icon) evas_object_del(it->icon);
- if(it->label_wd)
- {
- evas_object_del(it->label_wd);
- it->label_wd = NULL;
- if (edje_object_part_swallow_get(it->base, "elm.swallow.label.content") == NULL)
- {
- edje_object_part_unswallow(it->base, it->label_wd);
- }
- }
- if(it->base) evas_object_del(it->base);
- if(it->label) eina_stringshare_del(it->label);
+ if (it->wd->selected_item == it) it->wd->selected_item = NULL;
- if(it)
- free(it);
- it = NULL;
return;
}
static void
-_del_hook(Evas_Object *obj)
+_segment_on(Elm_Segment_Item *it)
{
- Widget_Data *wd = elm_widget_data_get(obj);
- Elm_Segment_Item *it;
- Eina_List *l, *clear = NULL;
+ if (!it || (it == it->wd->selected_item)) return;
- EINA_LIST_FOREACH(wd->seg_ctrl, l, it) clear = eina_list_append(clear, it);
- EINA_LIST_FREE(clear, it) _item_free(obj, it);
+ if (it->wd->selected_item) _segment_off(it->wd->selected_item);
- if(wd) free(wd);
- wd = NULL;
+ edje_object_signal_emit(it->base, "elm,state,segment,selected", "elm");
+
+ if (it->label) elm_object_style_set(it->label, "segment_selected");
+
+ it->wd->selected_item = it;
+ evas_object_smart_callback_call(it->wd->obj, "changed", (void*) it->seg_index);
return;
}
-
static void
-_layout(Evas_Object *o, Evas_Object_Box_Data *priv, void *data)
+_position_items(Evas_Object *obj)
{
- Widget_Data *wd = data;
+ Eina_List *l;
+ Elm_Segment_Item *it;
+ int bx, by, bw, bh, position;
+
+ Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
- _els_box_layout(o, priv, 1, 0); /* making box layout non homogenous */
+ wd->item_count = eina_list_count(wd->seg_items);
+ if (wd->item_count <= 0) return;
+
+ evas_object_geometry_get(wd->base, &bx, &by, &bw, &bh);
+ wd->item_width = bw / wd->item_count;
+
+ position = bx;
+ EINA_LIST_FOREACH(wd->seg_items, l, it)
+ {
+ evas_object_move(it->base, bx, by );
+ evas_object_resize(it->base, wd->item_width, bh );
+ bx += wd->item_width;
+ }
return;
}
static void
-_segment_resizing(void *data)
+_on_move_resize(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
- Widget_Data *wd = elm_widget_data_get((Evas_Object *)data);
- if (!wd) return;
- Evas_Coord w = 0, h = 0;
+ Evas_Coord law = 0, lah = 0;
+ Eina_List *l;
+ Elm_Segment_Item *it = NULL;
+ char *lbl_area;
- evas_object_geometry_get(wd->base, NULL, NULL, &w, &h);
- wd->item_width = wd->width = w;
- wd->height = h;
+ Widget_Data *wd = elm_widget_data_get((Evas_Object *) data);
+ if (!wd) return;
+ _position_items((Evas_Object *) data);
- _state_value_set((Evas_Object *)data);
+ EINA_LIST_FOREACH(wd->seg_items, l, it)
+ {
+ lbl_area = edje_object_data_get(it->base, "label.wrap.part");
+ if( it->label && lbl_area)
+ {
+ edje_object_part_geometry_get(it->base, lbl_area, NULL, NULL, &law, &lah);
+ elm_label_wrap_width_set(it->label, law);
+ //elm_label_wrap_height_set(it->label, lah); // not supported by elm_label yet
+ }
+ }
}
-static void
-_object_resize(void *data, Evas *e, Evas_Object *obj, void *event_info)
+static void
+_mouse_up(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
- Widget_Data *wd;
- if(!data) return;
- wd = elm_widget_data_get((Evas_Object *)data);
- if(!wd) return;
+ Elm_Segment_Item *it = (Elm_Segment_Item *) data;
+ if (!it) return;
+ if (it == it->wd->selected_item) return;
+ _segment_on(it);
- ecore_job_add(_segment_resizing, (Evas_Object *)data);
+ return;
}
static void
-_segment_item_resizing(void *data)
+_mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event_info)
{
- Widget_Data *wd;
- Elm_Segment_Item *it = (Elm_Segment_Item *)data;
- wd = elm_widget_data_get(it->obj);
+ Elm_Segment_Item *it = (Elm_Segment_Item *) data;
+ if (!it) return;
+ if (it == it->wd->selected_item) return;
- if(!wd) return;
- Evas_Coord w = 0, h = 0;
-
- _update_list(it->obj);
- evas_object_geometry_get(it->base, NULL, NULL, &w, &h);
+ edje_object_signal_emit(it->base, "elm,state,segment,pressed", "elm");
+ if (it->label) elm_object_style_set(it->label, "segment_pressed");
- if(wd->max_height == 1) wd->max_height = h;
-
- if(it->label_wd)
- {
- elm_label_wrap_width_set(it->label_wd, w-wd->w_pad);
- elm_label_wrap_height_set(it->label_wd, wd->max_height-wd->h_pad);
- if (it->segment_id == wd->cur_seg_id)
- {
- elm_label_text_color_set(it->label_wd, 0x00,0x00, 0x00, 0xff);
- }
- else
- elm_label_text_color_set(it->label_wd, 0xFF,0xFF, 0xFF, 0xff);
- if (edje_object_part_swallow_get(it->base, "elm.swallow.label.content") == NULL)
- {
- edje_object_part_unswallow(it->base, it->label_wd);
- }
- edje_object_part_swallow(it->base, "elm.swallow.label.content", it->label_wd);
- edje_object_signal_emit(it->base, "elm,state,label,visible", "elm");
- if (it->segment_id == wd->cur_seg_id)
- {
- elm_label_text_color_set(it->label_wd, 0x00,0x00, 0x00, 0xff);
- }
- else
- elm_label_text_color_set(it->label_wd, 0xFF,0xFF, 0xFF, 0xff);
- }
+ return;
}
-static void
-_object_item_resize(void *data, Evas *e, Evas_Object *obj, void *event_info)
+static void
+_swallow_item_objects(Elm_Segment_Item *it)
{
- ecore_job_add(_segment_item_resizing, (Evas_Object *)data);
-}
+ Evas_Coord law = 0, lah = 0;
+ char *lbl_area;
-static Elm_Segment_Item*
-_item_new(Evas_Object *obj, const char *label, Evas_Object *icon)
-{
- Elm_Segment_Item *it;
- Evas_Coord mw, mh;
- Widget_Data *wd = elm_widget_data_get(obj);
- if (!wd) return NULL;
+ if (!it) return;
- it = calloc(1, sizeof( Elm_Segment_Item));
- if (!it) return NULL;
-
- if(obj) it->obj = obj;
- it->delete_me = EINA_FALSE;
- it->segment_id = wd->id;
- it->label_wd = NULL;
-
- it->base = edje_object_add(evas_object_evas_get(obj));
- _elm_theme_object_set(obj, it->obj, "segment", "base/default", elm_object_style_get(it->obj));
-
- if (it->label) eina_stringshare_del(it->label);
- if (label)
- {
- it->label = eina_stringshare_add(label);
- }
-
- if ((it->icon != icon) && (it->icon))
- elm_widget_sub_object_del(obj, it->icon);
- it->icon = icon;
if (it->icon)
{
- elm_widget_sub_object_add(obj, icon);
- Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
- elm_coords_finger_size_adjust(1, &minw, 1, &minh);
- elm_coords_finger_size_adjust(1, &minw, 1, &minh);
-
- evas_object_size_hint_weight_set(it->base, 1.0, -1.0);
- evas_object_size_hint_align_set(it->base, 1.0, -1.0);
- evas_object_size_hint_min_set(it->base, -1, -1);
- evas_object_size_hint_max_set(it->base, maxw, maxh);
- }
-
- edje_object_size_min_restricted_calc(obj, &mw, &mh, 0, 0);
- evas_object_size_hint_weight_set(obj, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(obj, EVAS_HINT_FILL, EVAS_HINT_FILL);
-
- return it;
-}
-
-
-static void
-_update_list(Evas_Object *obj)
-{
- Elm_Segment_Item *it;
- Eina_List *l;
- int i = 0;
-
- Widget_Data *wd = elm_widget_data_get(obj);
- if (!wd) return;
-
- wd->count = eina_list_count(wd->seg_ctrl);
- if(wd->count == 1)
- {
- it = _item_find(obj, 0);
- _elm_theme_object_set(obj, it->base, "segment", "base/single", elm_object_style_get(it->obj));\r
- edje_object_signal_emit(it->base, "elm,state,segment,on", "elm");
- if(it->label && !it->label_wd)
- {
- edje_object_signal_emit(it->base, "elm,state,text,change", "elm");
- edje_object_part_text_set(it->base, "elm.text", it->label);
- }
- else
- edje_object_signal_emit(it->base, "elm,state,text,hidden", "elm");
- if (it->icon && edje_object_part_swallow_get(it->base, "elm.swallow.content") == NULL)
- {
- if(it->icon)
- {
- edje_object_part_swallow(it->base, "elm.swallow.content", it->icon);
- edje_object_signal_emit(it->base, "elm,state,icon,visible", "elm");
- }
- else
- edje_object_signal_emit(it->base, "elm,state,icon,hidden", "elm");
- }
- edje_object_message_signal_process(it->base);
-
- return;
+ edje_object_part_swallow(it->base, "elm.swallow.icon", it->icon);
+ edje_object_signal_emit(it->base, "elm,state,icon,visible", "elm");
}
+ else
+ edje_object_signal_emit(it->base, "elm,state,icon,hidden", "elm");
- EINA_LIST_FOREACH(wd->seg_ctrl, l, it)
+ if (it->label)
{
- if(i==0)
- {
- _elm_theme_object_set(obj, it->base, "segment", "base/first", elm_object_style_get(it->obj));
- }
- else if(i==wd->count-1)
- {
- _elm_theme_object_set(obj, it->base, "segment", "base/last", elm_object_style_get(it->obj));
- }
- else
- {
- _elm_theme_object_set(obj, it->base, "segment", "base/default", elm_object_style_get(it->obj));
-
- }
-
- if(it->label && !it->label_wd)
- {
- edje_object_signal_emit(it->base, "elm,state,text,visible", "elm");
- edje_object_part_text_set(it->base, "elm.text", it->label);
- }
- else
- edje_object_signal_emit(it->base, "elm,state,text,hidden", "elm");
-
- if (it->icon && edje_object_part_swallow_get(it->base, "elm.swallow.content") == NULL)
+ edje_object_part_swallow(it->base, "elm.swallow.label", it->label);
+ edje_object_signal_emit(it->base, "elm,state,text,visible", "elm");
+
+ lbl_area = edje_object_data_get(it->base, "label.wrap.part");
+ if(lbl_area)
{
- if(it->icon)
- {
- edje_object_part_swallow(it->base, "elm.swallow.content", it->icon);
- edje_object_signal_emit(it->base, "elm,state,icon,visible", "elm");
- }
- else
- edje_object_signal_emit(it->base, "elm,state,icon,hidden", "elm");
+ edje_object_part_geometry_get(it->base, lbl_area, NULL, NULL, &law, &lah );
+ elm_label_wrap_width_set(it->label, law);
+ //elm_label_wrap_height_set(it->label, lah); // not supported by elm_label yet
}
- edje_object_message_signal_process(it->base);
-
- i++;
- }
- if(wd->data && wd->selected)
- {
- _signal_segment_on(wd->data);
- wd->selected = EINA_FALSE;
}
+ else
+ edje_object_signal_emit(it->base, "elm,state,text,hidden", "elm");
}
-
-static void
-_refresh_segment_ids(Evas_Object *obj)
+static void
+_update_list(Evas_Object *obj)
{
- Elm_Segment_Item *it;
Eina_List *l;
- int i = 0;
+ Elm_Segment_Item *it = NULL;
+ int index = 0;
+
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
-
- if (wd->insert_index && wd->cur_seg_id >= wd->insert_index)
- {
- ++wd->cur_seg_id;
- wd->insert_index = 0;
- }
- if (wd->del_index)
- {
- if (wd->cur_seg_id >= wd->del_index)
- --wd->cur_seg_id;
- wd->del_index =0;
- }
- EINA_LIST_FOREACH(wd->seg_ctrl, l, it)
- {
- it->segment_id = i;
- i++;
- }
-}
-
-static void
-_state_value_set(Evas_Object *obj)
-{
- Elm_Segment_Item *it;
- Eina_List *l;
- Evas_Coord mw, mh, x, y;
+ _position_items(obj);
- int w1=0, w2, i=0;
- unsigned int count ;
- Widget_Data *wd = elm_widget_data_get(obj);
- if (!wd) return;
-
- count = eina_list_count(wd->seg_ctrl);
- if (count > 0)
- wd->item_width = wd->width/count;
- if (wd->ani_it)
+ if (wd->item_count == 1)
{
- evas_object_geometry_get(wd->ani_it->base, &x, &y, &w1, NULL);
- if (wd->ani_it->delete_me)
- {
- w1-=(wd->item_width/5);
- if( w1< 0) w1 = 0;
- }
- else
- {
- w1+=(wd->item_width/5);
- if( w1 > wd->item_width )
- w1 = wd->item_width;
- }
- w2 = (wd->width-w1)/(count -1);
- }
- else
- w2 = wd->item_width;
-
- EINA_LIST_FOREACH(wd->seg_ctrl, l, it)
- {
- edje_object_size_min_restricted_calc(it->base, &mw, &mh, 0, 0);
- evas_object_size_hint_weight_set(it->base, 1.0, 1.0);
- evas_object_size_hint_align_set(it->base, -1.0, -1.0);
-
-
- if(wd->ani_it && it == wd->ani_it)
- {
- evas_object_resize(it->base, w1, wd->height);
- evas_object_size_hint_min_set(it->base, w1, wd->height);
- evas_object_size_hint_max_set(it->base, w1, wd->height);
- }
- else
- {
- evas_object_resize(it->base, w2, wd->height);
- evas_object_size_hint_min_set(it->base, w2, wd->height);
- evas_object_size_hint_max_set(it->base, w2, wd->height);
- }
- ++i;
- }
-
- return;
-}
+ it = (Elm_Segment_Item *) eina_list_nth(wd->seg_items, 0);
+ it->seg_index = 0;
+ //Set the segment type
+ edje_object_signal_emit(it->base, "elm,type,segment,single", "elm");
-static int *
-_animator_animate_add_cb(Evas_Object *obj)
-{
- int w;
- Widget_Data *wd = elm_widget_data_get(obj);
- if (!wd) return 0;
-
- evas_object_geometry_get(wd->ani_it->base, NULL, NULL, &w, NULL);
- if( w < wd->item_width )
- {
- _state_value_set(obj);
- evas_object_geometry_get(wd->ani_it->base, NULL, NULL, &w, NULL);
- return (int*) ECORE_CALLBACK_RENEW;
- }
- else
- {
- ecore_animator_del(wd->ani);
- wd->ani = NULL;
- wd->ani_it = NULL;
- return (int*) ECORE_CALLBACK_CANCEL;
+ //Set the segment state
+ if (wd->selected_item == it)
+ {
+ edje_object_signal_emit(it->base, "elm,state,segment,selected", "elm");
+ if (it->label) elm_object_style_set(it->label, "segment_selected");
+ }
+ else
+ edje_object_signal_emit(it->base, "elm,state,segment,normal", "elm");
+
+ _swallow_item_objects(it);
+
+ return;
}
-}
+ EINA_LIST_FOREACH(wd->seg_items, l, it)
+ {
+ it->seg_index = index;
-static int *
-_animator_animate_del_cb(Evas_Object *obj)
-{
- int w;
- Widget_Data *wd = elm_widget_data_get(obj);
- if (!wd) return 0;\r
+ //Set the segment type
+ if(index == 0)
+ edje_object_signal_emit(it->base, "elm,type,segment,left", "elm");
+ else if(index == wd->item_count-1)
+ edje_object_signal_emit(it->base, "elm,type,segment,right", "elm");
+ else
+ edje_object_signal_emit(it->base, "elm,type,segment,middle", "elm");
- evas_object_geometry_get(wd->ani_it->base, NULL, NULL, &w, NULL);
- if( w > 0 )
- {
- _state_value_set(obj);
- evas_object_geometry_get(wd->ani_it->base, NULL, NULL, &w, NULL);
- return (int*) ECORE_CALLBACK_RENEW;
- }
- else
- {
- _item_free(obj, wd->ani_it );
- _refresh_segment_ids(obj);
- ecore_animator_del(wd->ani);
- wd->ani = NULL;
- wd->ani_it = NULL;
- _update_list(obj);
- wd->id = eina_list_count(wd->seg_ctrl);
- return (int*) ECORE_CALLBACK_CANCEL;
- }
+ //Set the segment state
+ if(wd->selected_item == it )
+ {
+ edje_object_signal_emit(it->base, "elm,state,segment,selected", "elm");
+ if(it->label) elm_object_style_set(it->label, "segment_selected");
+ }
+ else
+ edje_object_signal_emit(it->base, "elm,state,segment,normal", "elm");
+
+ _swallow_item_objects(it);
+ index++;
+ }
}
static Elm_Segment_Item *
_item_find(Evas_Object *obj, unsigned int index)
{
Elm_Segment_Item *it;
- Eina_List *l;
- int i = 0;
Widget_Data *wd = elm_widget_data_get(obj);
- if (!wd) return NULL;
+ if (!wd) return NULL;\r
- EINA_LIST_FOREACH(wd->seg_ctrl, l, it)
- {
- if (i == index) return it;
- i++;
- }
- return NULL;
+ it = (Elm_Segment_Item *) eina_list_nth(wd->seg_items, index);
+ return it;
}
-
-static Elm_Segment_Item *
-_item_search(Evas_Object *obj, Elm_Segment_Item *item)
+static Elm_Segment_Item*
+_item_new(Evas_Object *obj, Evas_Object *icon, const char *label )
{
Elm_Segment_Item *it;
- Eina_List *l;
Widget_Data *wd = elm_widget_data_get(obj);
- if (!wd)
- return NULL;
+ if (!wd) return NULL;
+
+ it = calloc(1, sizeof(Elm_Segment_Item));
+ if (!it) return NULL;
+ it->wd = wd;
+
+ it->base = edje_object_add(evas_object_evas_get(obj));
+ elm_widget_sub_object_add(obj, it->base);
+ _elm_theme_object_set(obj, it->base, "segment_control", "item",
+ elm_object_style_get(obj));
- EINA_LIST_FOREACH(wd->seg_ctrl, l, it)
+ if (label)
{
- if (it == item) {
- return it;
- }
+ it->label = elm_label_add(obj);
+ elm_widget_sub_object_add(it->base, it->label);
+ elm_object_style_set(it->label, "segment_normal");
+ elm_label_label_set(it->label, label);
+ elm_label_ellipsis_set(it->label, EINA_TRUE);
+ evas_object_show(it->label);
}
- return NULL;
-}
+ it->icon = icon;
+ if (it->icon) elm_widget_sub_object_add(it->base, it->icon);
+
+ evas_object_event_callback_add(it->base, EVAS_CALLBACK_MOUSE_DOWN, _mouse_down, it);
+ evas_object_event_callback_add(it->base, EVAS_CALLBACK_MOUSE_UP, _mouse_up,
+ it);
+ evas_object_show(it->base);
+
+ return it;
+}
/**
- * Add a new segmentcontrol to the parent
- * @param parent The parent object
+ * Create new SegmentControl.
+ * @param [in] parent The parent object
* @return The new object or NULL if it cannot be created
*
* @ingroup SegmentControl SegmentControl
Evas *e;
Widget_Data *wd;
- const char *deffont, *maxheight, *wpad, *hpad;
-
wd = ELM_NEW(Widget_Data);
e = evas_object_evas_get(parent);
- if(!e) return NULL;
+ if (!e) return NULL;
obj = elm_widget_add(e);
elm_widget_type_set(obj, "segmented-control");
elm_widget_sub_object_add(parent, obj);
- elm_widget_on_focus_hook_set( obj, _on_focus_hook, NULL );
elm_widget_data_set(obj, wd);
elm_widget_del_hook_set(obj, _del_hook);
elm_widget_theme_hook_set(obj, _theme_hook);
+ wd->obj = obj;
wd->base = edje_object_add(e);
- _elm_theme_object_set(obj, wd->base, "segmented-control", "base", "default");
+ _elm_theme_object_set(obj, wd->base, "segment_control", "base", "default");
elm_widget_resize_object_set(obj, wd->base);
- wd->box = evas_object_box_add(e);
- evas_object_box_layout_set(wd->box, _layout, wd, NULL);
- elm_widget_sub_object_add(obj, wd->box);
- edje_object_part_swallow(wd->base, "elm.swallow.content", wd->box);
- evas_object_show(wd->box);
-
- evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _object_resize, obj);
- wd->id = 0;
- wd->del_index = 0;
- wd->insert_index = 0;
- wd->cur_seg_id = -1;
- wd->selected = EINA_FALSE;
-
- deffont = edje_object_data_get(wd->base, "default_font_size");
- if (deffont) wd->cur_fontsize = atoi(deffont);
- else wd->cur_fontsize = 1;
-
- maxheight = edje_object_data_get(wd->base, "max_height");
- if (maxheight) wd->max_height = atoi(maxheight);
- else wd->max_height = 1;
-
- wpad = edje_object_data_get(wd->base, "w_pad");
- if (wpad) wd->w_pad = atoi(wpad);
- else wd->w_pad = 1;
-
- hpad = edje_object_data_get(wd->base, "h_pad");
- if (hpad) wd->h_pad = atoi(hpad);
- else wd->h_pad = 1;
+
+ 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);
+ wd->item_count = 0;
+ wd->selected_item = NULL;
+
+ _sizing_eval(obj);
return obj;
}
+/**
+ * Add new segment item to SegmentControl item.
+ * @param [in] obj The SegmentControl object
+ * @param [in] icon Any Objects like icon, Label, layout etc
+ * @param [in] label The label for added segment item
+ * @return The new segment item or NULL if it cannot be created
+ *
+ * @ingroup SegmentControl SegmentControl
+ */
EAPI Elm_Segment_Item *
-elm_segment_control_item_add(Evas_Object *obj, Evas_Object *icon, const char *label, Eina_Bool animate)
+elm_segment_control_item_add(Evas_Object *obj, Evas_Object *icon,
+ const char *label)
{
Elm_Segment_Item *it;
Widget_Data *wd = elm_widget_data_get(obj);
- if(!wd) return NULL;
-
- it = _item_new(obj, label, icon);
- if(!it) return NULL;
-
- wd->seg_ctrl = eina_list_append(wd->seg_ctrl, it);
- wd->id = eina_list_count(wd->seg_ctrl);
- //_update_list(obj);
- evas_object_event_callback_add(it->base, EVAS_CALLBACK_MOUSE_DOWN, _mouse_down, it);
- evas_object_event_callback_add(it->base, EVAS_CALLBACK_MOUSE_UP, _mouse_up, it);
- evas_object_event_callback_add(it->base, EVAS_CALLBACK_RESIZE, _object_item_resize, it);
- wd->insert_index = 0;
- wd->del_index = 0;
- _refresh_segment_ids(obj);
+ if (!wd) return NULL;
- if(animate && it->segment_id && wd->ani_it == NULL)
- {
- evas_object_resize(it->base, 1, wd->height);
- wd->ani_it = it;
- wd->ani = ecore_animator_add( _animator_animate_add_cb, obj );
- }
- else
- _state_value_set(obj);
- evas_object_show( it->base);
+ it = _item_new(obj, icon, label);
+ if (!it) return NULL;
- evas_object_box_append(wd->box, it->base);
- evas_object_smart_calculate(wd->box);
+ wd->seg_items = eina_list_append(wd->seg_items, it);
+ _update_list(obj);
return it;
}
/**
- * Add a new segment item to segmentcontrol
- * @param obj The SegmentControl object
- * @param icon The icon object for added segment item
- * @param label The label for added segment item
- * @param animate If 1 the action be animated with sliding effects default 0.
+ * Insert a new segment item to SegmentControl item.
+ * @param [in] obj The SegmentControl object
+ * @param [in] icon Any Objects like icon, Label, layout etc
+ * @param [in] label The label for added segment item
+ * @param [in] index Segment item location. Value should be between 0 and
+ * Existing total item count( @see elm_segment_control_item_count_get() )
* @return The new segment item or NULL if it cannot be created
*
* @ingroup SegmentControl SegmentControl
*/
EAPI Elm_Segment_Item *
-elm_segment_control_add_segment(Evas_Object *obj, Evas_Object *icon, const char *label, Eina_Bool animate)
-{
- Elm_Segment_Item * it;
- it = elm_segment_control_item_add(obj, icon, label, animate);
-\r
- return it;\r
-}
-
-EAPI Elm_Segment_Item *
-elm_segment_control_item_insert_at(Evas_Object *obj, Evas_Object *icon, const char *label, unsigned int index, Eina_Bool animate)
+elm_segment_control_item_insert_at(Evas_Object *obj, Evas_Object *icon,
+ const char *label, unsigned int index)
{
Elm_Segment_Item *it, *it_rel;
Widget_Data *wd = elm_widget_data_get(obj);
- if(!wd) return NULL;
+ if (!wd) return NULL;
+ if (index < 0 || index > wd->item_count) return NULL;
+
+ it = _item_new(obj, icon, label);
+ if (!it) return NULL;
- it = _item_new(obj, label, icon);
it_rel = _item_find(obj, index);
if (!it_rel)
- {
- wd->seg_ctrl = eina_list_append(wd->seg_ctrl, it);
- }
+ wd->seg_items = eina_list_append(wd->seg_items, it);
else
- {
- if (!it) return NULL;
- wd->seg_ctrl = eina_list_prepend_relative(wd->seg_ctrl, it, it_rel);
- }
- evas_object_event_callback_add(it->base, EVAS_CALLBACK_MOUSE_DOWN, _mouse_down, it);
- evas_object_event_callback_add(it->base, EVAS_CALLBACK_MOUSE_UP, _mouse_up, it);
- evas_object_event_callback_add(it->base, EVAS_CALLBACK_RESIZE, _object_item_resize, it);
- wd->insert_index = index;
- wd->id = eina_list_count(wd->seg_ctrl);
- _refresh_segment_ids(obj);
-
- //_update_list(obj);
- if(animate && it->segment_id && wd->ani_it == NULL)
- {
- wd->ani_it = it;
- evas_object_resize(it->base, 1, wd->height);
- wd->ani = ecore_animator_add( _animator_animate_add_cb, obj );
- }
- else
- _state_value_set(obj);
+ wd->seg_items = eina_list_prepend_relative(wd->seg_items, it, it_rel);
- evas_object_show( it->base);
-
- if(index >= wd->id-1)
- {
- evas_object_box_append(wd->box, it->base);
- }
- else
- {
- evas_object_box_insert_at(wd->box, it->base, index);
- }
-
- evas_object_smart_calculate(wd->box);
-
- return it ;
+ _update_list(obj);
+ return it;
}
/**
- * Insert a new segment item to segmentcontrol
- * @param obj The SegmentControl object
- * @param icon The icon object for added segment item
- * @param label The label for added segment item
- * @param index The position at which segment item to be inserted
- * @param animate If 1 the action be animated with sliding effects default 0.
- * @return The new segment item or NULL if it cannot be created
+ * Delete a segment item from SegmentControl
+ * @param [in] obj The SegmentControl object
+ * @param [in] it The segment item to be deleted
*
* @ingroup SegmentControl SegmentControl
*/
EAPI void
-elm_segment_control_insert_segment_at(Evas_Object *obj, Evas_Object *icon, const char *label, unsigned int index, Eina_Bool animate)
-{
- Elm_Segment_Item *it;
- it = elm_segment_control_item_insert_at(obj, icon, label, index, animate);
- return;
-}
-
-EAPI void
-elm_segment_control_item_del(Evas_Object *obj, Elm_Segment_Item *item, Eina_Bool animate)
+elm_segment_control_item_del(Evas_Object *obj, Elm_Segment_Item *it)
{
- Elm_Segment_Item *it;
Widget_Data *wd = elm_widget_data_get(obj);
- if(!wd) return;
+ if (!wd || !it) return;
+ _item_free(obj, it);
+ _update_list(obj);
-// it = _item_search(obj, item);
- it = item;
- if(!it) return;
-
- wd->del_index = it->segment_id;
- if(animate && it->segment_id && wd->ani_it == NULL)
- {
- it->delete_me = EINA_TRUE;
- wd->ani_it = it;
- wd->ani = ecore_animator_add( _animator_animate_del_cb, obj );
- }
- else
- {
- evas_object_box_remove(wd->box, it->base);
- evas_object_smart_calculate(wd->box);
-
- _item_free(obj, it);
- _refresh_segment_ids(obj);
- _state_value_set(obj);
- //_update_list(obj);
- }
- wd->id = eina_list_count(wd->seg_ctrl);
return;
}
/**
- * Delete a segment item to segmentcontrol
- * @param obj The SegmentControl object
- * @param index The position at which segment item to be deleted
- * @param animate If 1 the action be animated with sliding effects default 0.
+ * Delete a segment item of given index from SegmentControl
+ * @param [in] obj The SegmentControl object
+ * @param [in] index The position at which segment item to be deleted
*
* @ingroup SegmentControl SegmentControl
*/
EAPI void
-elm_segment_control_delete_segment(Evas_Object *obj, Elm_Segment_Item *item, Eina_Bool animate)
-{
- elm_segment_control_item_del(obj, item, animate);
-
- return;
-}
-
-EAPI void
-elm_segment_control_item_del_at(Evas_Object *obj, unsigned int index, Eina_Bool animate)
+elm_segment_control_item_del_at(Evas_Object *obj, unsigned int index)
{
Elm_Segment_Item *it;
Widget_Data *wd = elm_widget_data_get(obj);
- if(!wd) return;
+ if (!wd) return;
it = _item_find(obj, index);
+ if (!it) return;
+ _item_free(obj, it);
+ _update_list(obj);
- if(!it) return;
-
- wd->del_index = index;
- if(animate && it->segment_id)
- {
- if(wd->ani_it == NULL)
- {
- wd->ani_it = it;
- it->delete_me = EINA_TRUE;
- wd->ani = ecore_animator_add( _animator_animate_del_cb, obj );
- }
- }
- else
- {
- evas_object_box_remove(wd->box, it->base);
- evas_object_smart_calculate(wd->box);
- _item_free(obj, it);
- _refresh_segment_ids(obj);
- _state_value_set(obj);
- //_update_list(obj);
- }
- wd->id = eina_list_count(wd->seg_ctrl);
return;
}
/**
- * Delete a segment item of given index to segmentcontrol
- * @param obj The SegmentControl object
- * @param index The position at which segment item to be deleted
- * @param animate If 1 the action be animated with sliding effects default 0.
+ * Get the label of a segment item.
+ * @param [in] obj The SegmentControl object
+ * @param [in] index The index of the segment item
+ * @return The label of the segment item
*
* @ingroup SegmentControl SegmentControl
*/
-EAPI void
-elm_segment_control_delete_segment_at(Evas_Object *obj, unsigned int index, Eina_Bool animate)
-{
- elm_segment_control_item_del_at( obj, index, animate);
-
- return;
-}
-
-
-EAPI const char *
+EAPI const char*
elm_segment_control_item_label_get(Evas_Object *obj, unsigned int index)
{
- Elm_Segment_Item *it_rel;
+ Elm_Segment_Item *it;
Widget_Data *wd = elm_widget_data_get(obj);
- if(!wd) return NULL;
-
- it_rel = _item_find(obj, index);
+ if (!wd) return NULL;
- if(it_rel) return it_rel->label;
+ it = _item_find(obj, index);
+ if (it && it->label) return elm_label_label_get(it->label);
return NULL;
}
/**
- * Get the label of a segment item of segmentcontrol
- * @param obj The SegmentControl object
- * @param index The index of the segment item
- * @return The label of the segment item
+ * Set the label of a segment item.
+ * @param [in] it The SegmentControl Item
+ * @param [in] label New label text.
*
* @ingroup SegmentControl SegmentControl
*/
-EAPI const char *
-elm_segment_control_get_segment_label_at(Evas_Object *obj, unsigned int index)
+EAPI void
+elm_segment_control_item_label_set(Elm_Segment_Item* it, const char* label)
{
- char *label;
- label = elm_segment_control_item_label_get( obj, index);
+ if (!it) return;
+
+ if( !label && !it->label ) return; //No label, return
+
+ if( label && !it->label ) // Create Label Object
+ {
+ it->label = elm_label_add(it->base);
+ elm_widget_sub_object_add(it->base, it->label);
+ elm_label_label_set(it->label, label);
+ elm_label_ellipsis_set(it->label, EINA_TRUE);
+ evas_object_show(it->label);
- return label;
+ if(it->wd->selected_item == it )
+ elm_object_style_set(it->label, "segment_selected");
+ else
+ elm_object_style_set(it->label, "segment_normal");
+ }
+ else if( !label && it->label ) // Delete Label Object
+ {
+ evas_object_del(it->label);
+ it->label = NULL;
+ }
+ else // Update the text
+ elm_label_label_set(it->label, label);
+
+ _swallow_item_objects( it );
+ return;
}
+/**
+ * Get the icon of a segment item of SegmentControl
+ * @param [in] obj The SegmentControl object
+ * @param [in] index The index of the segment item
+ * @return The icon object.
+ *
+ * @ingroup SegmentControl SegmentControl
+ */
EAPI Evas_Object *
elm_segment_control_item_icon_get(Evas_Object *obj, unsigned int index)
{
- Elm_Segment_Item *seg_rel;
+ Elm_Segment_Item *it;
Widget_Data *wd = elm_widget_data_get(obj);
- if(!wd) return NULL;
-
- seg_rel = _item_find(obj, index);
+ if (!wd) return NULL;
- if(seg_rel) return seg_rel->icon;
+ it = _item_find(obj, index);
+ if (it) return it->icon;
return NULL;
}
/**
- * Get the icon of a segment item of segmentcontrol
- * @param obj The SegmentControl object
- * @param index The index of the segment item
- * @return The icon object or NULL if it is not found.
+ * Set the Icon to the segment item
+ * @param [in] it The SegmentControl Item
+ * @param [in] icon Objects like Layout, Icon, Label etc...
*
* @ingroup SegmentControl SegmentControl
*/
-EAPI Evas_Object *
-elm_segment_control_get_segment_icon_at(Evas_Object *obj, unsigned int index)
-{
- Evas_Object *icon;
- icon = elm_segment_control_item_icon_get( obj, index);
-
- return icon;
-}
-
-EAPI Elm_Segment_Item *
-elm_segment_control_item_selected_get(const Evas_Object *obj)
+EAPI void
+elm_segment_control_item_icon_set(Elm_Segment_Item *it, Evas_Object *icon)
{
- Elm_Segment_Item *it;
- Eina_List *l;
- Widget_Data *wd = elm_widget_data_get(obj);
- if(!wd || !wd->seg_ctrl) return NULL;
+ if (!it) return;
- EINA_LIST_FOREACH(wd->seg_ctrl, l, it)
+ //Remove the existing icon
+ if (it->icon)
{
- if(it->segment_id == wd->cur_seg_id)
- return it;
- }
- return NULL;
- }
+ edje_object_part_unswallow(it->base, it->icon);
+ evas_object_del(it->icon);
+ }
+
+ it->icon = icon;
+ if (it->icon) elm_widget_sub_object_add(it->base, it->icon);
+ _swallow_item_objects( it );
+}
/**
- * Get the currently selected segment item of segmentcontrol
- * @param obj The SegmentControl object
- * @return The selected Segment item
+ * Get the Segment items count from SegmentControl
+ * @param [in] obj The SegmentControl object
+ * @return Segment items count.
*
* @ingroup SegmentControl SegmentControl
*/
-EAPI Elm_Segment_Item *
-elm_segment_control_selected_segment_get(const Evas_Object *obj, int *value)
-{
- Elm_Segment_Item *it;
- it = elm_segment_control_item_selected_get( obj);
- *value = it->segment_id;
- \r
- return it;
- }
-
-
EAPI int
elm_segment_control_item_count_get(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
- if(!wd) return 0;
+ if (!wd) return 0;
- return wd->id;
+ return wd->item_count;
}
/**
- * Get the count of segments of segmentcontrol
- * @param obj The SegmentControl object
- * @return The count of Segment items
+ * Get the base object of segment item.
+ * @param [in] it The Segment item
+ * @return obj The base object of the segment item.
*
* @ingroup SegmentControl SegmentControl
*/
-EAPI int
-elm_segment_control_get_segment_count(Evas_Object *obj)
+EAPI Evas_Object*
+elm_segment_control_item_object_get(Elm_Segment_Item *it)
{
- int id;
- id = elm_segment_control_item_count_get( obj);
-
- return id;
+ if (!it) return NULL;
+ return it->base;
}
/**
- * Get the base object of segment item in segmentcontrol
- * @param obj The Segment item
- * @return obj The base object of the segment item
+ * Get the selected segment item in the SegmentControl
+ * @param [in] obj The SegmentControl object
+ * @return Selected Segment Item. NULL if none of segment item is selected.
*
* @ingroup SegmentControl SegmentControl
*/
-EAPI Evas_Object *
-elm_segment_control_item_object_get(Elm_Segment_Item *it)
+EAPI Elm_Segment_Item*
+elm_segment_control_item_selected_get(const Evas_Object *obj)
{
- if (!it) return NULL;
-
- return it->base;
+ Widget_Data *wd = elm_widget_data_get(obj);
+ if (!wd) return NULL;
+ return wd->selected_item;
}
/**
- * Select/unselect a particular segment item of segmentcontrol
- * @param item The Segment item that is to be selected or unselected.
- * @param select If 1 the segment item is selected and if 0 it will be unselected.
+ * Select/unselect a particular segment item of SegmentControl
+ * @param [in] it The Segment item that is to be selected or unselected.
+ * @param [in] select Passing EINA_TRUE will select the segment item and EINA_FALSE will unselect.
*
* @ingroup SegmentControl SegmentControl
*/
EAPI void
-elm_segment_control_item_selected_set( Elm_Segment_Item *item, Eina_Bool select)
+elm_segment_control_item_selected_set(Elm_Segment_Item *it, Eina_Bool select)
{
- if(!item) return;
- Widget_Data *wd = elm_widget_data_get(item->obj);
- if(!wd) return;
+ if (!it) return;
- if(select)
+ if (it == it->wd->selected_item)
{
- if(item->segment_id == wd->cur_seg_id) return;
- wd->selected = EINA_TRUE;
- if(wd->data)
- {
- evas_object_del((Evas_Object *)wd->data);
- wd->data = NULL;
- }
- wd->data = item;
-
- }
- else if(item->segment_id == wd->cur_seg_id)
- {
- wd->selected = EINA_FALSE;
- wd->cur_seg_id = -1;
- _signal_segment_off(item);
- }
+ if (select) return; //already in selected selected state.
- return;
+ //unselect case
+ _segment_off(it);
+ }
+ else
+ _segment_on(it);
+ return;
}
/**
- * Get a particular indexed segment item of segmentcontrol
- * @param obj The Segment control object.
- * @param index The index of the segment item.
- * @return The corresponding Segment item.
+ * Get the Segment Item from the specified Index.
+ * @param [in] obj The Segment Control object.
+ * @param [in] index The index of the segment item.
+ * @return The Segment item.
*
* @ingroup SegmentControl SegmentControl
*/
}
\r
/**
- * Get the index of a Segment item of Segmentcontrol
- * @param item The Segment item.
- * @return The corresponding index of the Segment item.
+ * Get the index of a Segment item in the SegmentControl
+ * @param [in] it The Segment Item.
+ * @return Segment Item.
*
* @ingroup SegmentControl SegmentControl
*/
EAPI int
-elm_segment_control_item_index_get(Elm_Segment_Item *item)
+elm_segment_control_item_index_get(Elm_Segment_Item *it)
{
- if(!item) return -1;
- Widget_Data *wd = elm_widget_data_get(item->obj);
- if(!wd) return -1;
+ if (!it) return -1;
+ return it->seg_index;
+}
- return item->segment_id;
+////////////////////////////////// BEGIN //////////////////////////////////////////////
+/////////////////////////// OLD SLP APIs - TO BE DEPRECATED /////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////
+
+EAPI int
+elm_segment_control_get_segment_count(Evas_Object *obj)
+{
+ printf(
+ "#####\nWARNING: Use elm_segment_control_item_count_get()\ninstead of elm_segment_control_get_segment_count()\n#####\n");
+ return elm_segment_control_item_count_get(obj);
+}
+
+EAPI Elm_Segment_Item *
+elm_segment_control_selected_segment_get(const Evas_Object *obj, int *value)
+{
+ Elm_Segment_Item *it;
+ it = elm_segment_control_item_selected_get(obj);
+ if (!it) return NULL;
+ *value = it->seg_index;
+
+ printf(
+ "#####\nWARNING: Use elm_segment_control_item_selected_get() &\nelm_segment_control_item_index_get()\n instead of elm_segment_control_selected_segment_get()\n#####\n");
+ return it;
+}
+
+EAPI Evas_Object *
+elm_segment_control_get_segment_icon_at(Evas_Object *obj, unsigned int index)
+{
+ printf(
+ "#####\nWARNING: Use elm_segment_control_item_icon_get()\ninstead of elm_segment_control_get_segment_icon_at()\n#####\n");
+ return elm_segment_control_item_icon_get(obj, index);
+}
+
+EAPI const char *
+elm_segment_control_get_segment_label_at(Evas_Object *obj, unsigned int index)
+{
+ printf(
+ "#####\nWARNING: Use elm_segment_control_item_label_get()\n instead of elm_segment_control_get_segment_label_at() \n#####\n");
+ return elm_segment_control_item_label_get(obj, index);
+}
+
+EAPI void
+elm_segment_control_delete_segment_at(Evas_Object *obj, unsigned int index,
+ Eina_Bool animate)
+{
+ printf(
+ "#####\nWARNING: Use elm_segment_control_item_del_at()\ninstead of elm_segment_control_delete_segment_at() \n#####\n");
+ elm_segment_control_item_del_at(obj, index);
+}
+
+EAPI void
+elm_segment_control_delete_segment(Evas_Object *obj, Elm_Segment_Item *item,
+ Eina_Bool animate)
+{
+ printf(
+ "#####\nWARNING: Use elm_segment_control_item_del()\ninstead of elm_segment_control_delete_segment()\n#####\n");
+ elm_segment_control_item_del(obj, item);
+}
+
+EAPI void
+elm_segment_control_insert_segment_at(Evas_Object *obj, Evas_Object *icon,
+ const char *label, unsigned int index,
+ Eina_Bool animate)
+{
+ printf(
+ "#####\nWARNING: Use elm_segment_control_item_insert_at()\ninstead of elm_segment_control_insert_segment_at()\n#####\n");
+ elm_segment_control_item_insert_at(obj, icon, label, index);
+}
+
+EAPI Elm_Segment_Item *
+elm_segment_control_add_segment(Evas_Object *obj, Evas_Object *icon,
+ const char *label, Eina_Bool animate)
+{
+ printf(
+ "#####\nWARNING: Use elm_segment_control_item_add()\n instead of elm_segment_control_add_segment()\n#####\n");
+ return elm_segment_control_item_add(obj, icon, label);
}
-/**
- * Set The Label widget to a Segment item of Segmentcontrol
- * @param item The Segment item.
- * @param label The Label.
- * @return Evas_Object The Label widget.
- *
- * @ingroup SegmentControl SegmentControl
- */
EAPI Evas_Object *
elm_segment_control_item_label_object_set(Elm_Segment_Item *item, char *label)
{
- if(!item) return NULL;
- Widget_Data *wd = elm_widget_data_get(item->obj);
- if(!wd) return NULL;
- if(!label) return NULL;
-
- item->label_wd = elm_label_add(item->obj);
- elm_label_label_set(item->label_wd, label);
- elm_label_text_align_set(item->label_wd, "middle");
- elm_label_ellipsis_set(item->label_wd, 1);
- elm_label_line_wrap_set(item->label_wd, 1);
- eina_stringshare_replace(&item->label, label);
-
- return item->label_wd;
+ printf(
+ "#####\nWARNING: Use elm_segment_control_item_label_set()\n instead of elm_segment_control_item_label_object_set()\n#####\n");
+ elm_segment_control_item_label_set(item, label);
}
+/////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////// OLD SLP APIs - TO BE DEPRECATED /////////////////////////////
+/////////////////////////////////// END ////////////////////////////////////////////////