1 #include <Elementary.h>
5 * @defgroup SegmentControl SegmentControl
8 * SegmentControl object is a horizontal control made of multiple segments,
9 * each segment item functioning as a discrete button. A segmented control affords a compact means to group together a number of controls.
10 * A segmented control can display a title or an image. The UISegmentedControl object automatically resizes segment items to fit proportionally
11 * within their superview unless they have a specific width set. When you add and remove segments,
12 * you can request that the action be animated with sliding and fading effects.
14 typedef struct _Widget_Data Widget_Data;
24 Elm_Segment_Item *ani_it;
27 unsigned int insert_index;
28 unsigned int del_index;
29 unsigned int cur_seg_id;
31 // Eina_Bool longpressed : 1;
32 Eina_Bool selected : 1;
35 struct _Elm_Segment_Item
41 Eina_Bool delete_me : 1;
43 // Ecore_Timer *long_timer;
46 static void _mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event_info);
47 static void _mouse_up(void *data, Evas *e, Evas_Object *obj, void *event_info);
48 static void _signal_segment_on(void *data);
49 static void _signal_segment_off(void *data);
50 static void _theme_hook(Evas_Object *obj);
51 static void _item_free(Evas_Object *obj, Elm_Segment_Item *it);
52 static void _del_hook(Evas_Object *obj);
53 static void _layout(Evas_Object *o, Evas_Object_Box_Data *priv, void *data);
54 static void _segment_resizing(void *data);
55 static void _object_resize(void *data, Evas *e, Evas_Object *obj, void *event_info);
56 static void _update_list(Evas_Object *obj);
57 static void _refresh_segment_ids(Evas_Object *obj);
58 static void _state_value_set(Evas_Object *obj);
60 static Elm_Segment_Item* _item_new(Evas_Object *obj, const char *label, Evas_Object *icon);
61 static Elm_Segment_Item *_item_find(Evas_Object *obj, unsigned int index);
63 static int * _animator_animate_add_cb(Evas_Object *obj);
64 static int * _animator_animate_del_cb(Evas_Object *obj);
67 _on_focus_hook(void *data, Evas_Object *obj)
69 Widget_Data *wd = elm_widget_data_get(obj);
72 if (elm_widget_focus_get(obj))
73 evas_object_focus_set((Evas_Object *)wd->seg_ctrl, 1);
75 evas_object_focus_set((Evas_Object *)wd->seg_ctrl, 0);
79 _signal_segment_off(void *data)
81 Elm_Segment_Item *item = (Elm_Segment_Item *) data;
82 Widget_Data *wd = elm_widget_data_get(item->obj);
85 edje_object_signal_emit(item->base, "elm,action,unfocus", "elm");
86 edje_object_signal_emit(item->base, "elm,state,segment,off", "elm");
87 edje_object_signal_emit(item->base, "elm,state,text,visible", "elm");
93 _signal_segment_on(void *data)
95 Elm_Segment_Item *item = (Elm_Segment_Item *) data;
99 Widget_Data *wd = elm_widget_data_get(item->obj);
102 wd->selected = EINA_TRUE;
104 /* if (item->long_timer)
106 ecore_timer_del(item->long_timer);
107 item->long_timer = NULL;
109 //wd->longpressed = EINA_TRUE;
110 edje_object_signal_emit(item->base, "elm,state,segment,on", "elm");
111 edje_object_signal_emit(item->base, "elm,state,text,change", "elm");
113 if (item->segment_id == wd->cur_seg_id)
116 EINA_LIST_FOREACH(wd->seg_ctrl, l, it)
118 if (it->segment_id == wd->cur_seg_id)
120 _signal_segment_off (it);
124 wd->cur_seg_id = item->segment_id;
125 evas_object_smart_callback_call(item->obj, "changed", (void*)wd->cur_seg_id);
131 _mouse_up(void *data, Evas *e, Evas_Object *obj, void *event_info)
133 Elm_Segment_Item *item = (Elm_Segment_Item *) data;
134 Widget_Data *wd = elm_widget_data_get(item->obj);
137 if (item->segment_id == wd->cur_seg_id)
139 wd->selected = EINA_TRUE;
142 _signal_segment_on(item);
143 wd->selected = EINA_FALSE;
146 /*if(wd->longpressed == EINA_FALSE)
148 edje_object_signal_emit(item->base, "elm,action,unfocus", "elm");
149 edje_object_signal_emit(item->base, "elm,state,text,visible", "elm");
150 edje_object_signal_emit(item->base, "elm,state,text,change", "elm");
152 /* if (item->long_timer)
154 ecore_timer_del(item->long_timer);
155 item->long_timer = NULL;
160 _mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event_info)
162 Elm_Segment_Item *item = (Elm_Segment_Item *) data;
163 Widget_Data *wd = elm_widget_data_get(item->obj);
167 edje_object_signal_emit(item->base, "elm,action,focus", "elm");
169 /* if (item->long_timer) ecore_timer_del(item->long_timer);
170 item->long_timer = ecore_timer_add(0.3, _signal_segment_on, item);*/
174 _theme_hook(Evas_Object *obj)
176 _elm_theme_object_set(obj, obj, "segmented-control", "base", elm_widget_style_get(obj));
182 _item_free(Evas_Object *obj, Elm_Segment_Item *it)
184 Widget_Data *wd = elm_widget_data_get(obj);
188 wd->seg_ctrl = eina_list_remove(wd->seg_ctrl, it);
190 if(it->icon) evas_object_del(it->icon);
191 if(it->base) evas_object_del(it->base);
192 if(it->label) eina_stringshare_del(it->label);
193 // if (it->long_timer) ecore_timer_del(it->long_timer);
202 _del_hook(Evas_Object *obj)
204 Widget_Data *wd = elm_widget_data_get(obj);
205 Elm_Segment_Item *it;
206 Eina_List *l, *clear = NULL;
208 EINA_LIST_FOREACH(wd->seg_ctrl, l, it) clear = eina_list_append(clear, it);
209 EINA_LIST_FREE(clear, it) _item_free(obj, it);
219 _layout(Evas_Object *o, Evas_Object_Box_Data *priv, void *data)
221 Widget_Data *wd = data;
223 _els_box_layout(o, priv, 1, 0); /* making box layout non homogenous */
229 _segment_resizing(void *data)
231 Widget_Data *wd = elm_widget_data_get((Evas_Object *)data);
233 Evas_Coord w = 0, h = 0;
235 evas_object_geometry_get(wd->base, NULL, NULL, &w, &h);
236 wd->item_width = wd->width = w;
238 _state_value_set((Evas_Object *)data);
242 _object_resize(void *data, Evas *e, Evas_Object *obj, void *event_info)
246 wd = elm_widget_data_get((Evas_Object *)data);
249 ecore_job_add(_segment_resizing, (Evas_Object *)data);
252 static Elm_Segment_Item*
253 _item_new(Evas_Object *obj, const char *label, Evas_Object *icon)
255 Elm_Segment_Item *it;
257 Widget_Data *wd = elm_widget_data_get(obj);
258 if (!wd) return NULL;
260 it = calloc(1, sizeof( Elm_Segment_Item));
261 if (!it) return NULL;
263 if(obj) it->obj = obj;
264 it->delete_me = EINA_FALSE;
265 it->segment_id = wd->id;
267 it->base = edje_object_add(evas_object_evas_get(obj));
268 _elm_theme_object_set(obj, it->base, "segment", "base", elm_object_style_get(it->base));
270 if (it->label) eina_stringshare_del(it->label);
273 it->label = eina_stringshare_add(label);
280 if ((it->icon != icon) && (it->icon))
281 elm_widget_sub_object_del(obj, it->icon);
285 elm_widget_sub_object_add(obj, icon);
286 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
287 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
288 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
290 evas_object_size_hint_weight_set(it->base, 1.0, -1.0);
291 evas_object_size_hint_align_set(it->base, 1.0, -1.0);
292 evas_object_size_hint_min_set(it->base, -1, -1);
293 evas_object_size_hint_max_set(it->base, maxw, maxh);
296 edje_object_size_min_restricted_calc(obj, &mw, &mh, 0, 0);
297 evas_object_size_hint_weight_set(obj, 1.0, 1.0);
298 evas_object_size_hint_align_set(obj, -1.0, -1.0);
305 _update_list(Evas_Object *obj)
307 Elm_Segment_Item *it;
311 Widget_Data *wd = elm_widget_data_get(obj);
314 wd->count = eina_list_count(wd->seg_ctrl);
317 it = _item_find(obj, 0);
318 _elm_theme_object_set(obj, it->base, "segment", "base", "single");
\r
319 edje_object_signal_emit(it->base, "elm,state,segment,on", "elm");
320 edje_object_signal_emit(it->base, "elm,state,text,visible", "elm");
321 edje_object_signal_emit(it->base, "elm,state,text,change", "elm");
322 edje_object_message_signal_process(it->base);
324 edje_object_part_text_set(it->base, "elm.text", it->label);
326 edje_object_part_swallow(it->base, "elm.swallow.content", it->icon);
327 edje_object_signal_emit(it->base, "elm,state,icon,visible", "elm");
331 EINA_LIST_FOREACH(wd->seg_ctrl, l, it)
335 _elm_theme_object_set(obj, it->base, "segment", "base", "first");
337 else if(i==wd->count-1)
339 _elm_theme_object_set(obj, it->base, "segment", "base", "last");
343 _elm_theme_object_set(obj, it->base, "segment", "base", "default");
346 edje_object_signal_emit(it->base, "elm,state,text,visible", "elm");
347 edje_object_message_signal_process(it->base);
349 edje_object_part_text_set(it->base, "elm.text", it->label);
351 edje_object_part_swallow(it->base, "elm.swallow.content", it->icon);
352 edje_object_signal_emit(it->base, "elm,state,icon,visible", "elm");
360 _refresh_segment_ids(Evas_Object *obj)
362 Elm_Segment_Item *it;
365 Widget_Data *wd = elm_widget_data_get(obj);
368 if (wd->insert_index && wd->cur_seg_id >= wd->insert_index)
371 wd->insert_index = 0;
375 if (wd->cur_seg_id >= wd->del_index)
380 EINA_LIST_FOREACH(wd->seg_ctrl, l, it)
388 _state_value_set(Evas_Object *obj)
390 Elm_Segment_Item *it;
392 Evas_Coord mw, mh, x, y;
395 Widget_Data *wd = elm_widget_data_get(obj);
398 count = eina_list_count(wd->seg_ctrl);
400 wd->item_width = wd->width/count;
403 evas_object_geometry_get(wd->ani_it->base, &x, &y, &w1, NULL);
404 if (wd->ani_it->delete_me)
406 w1-=(wd->item_width/15);
411 w1+=(wd->item_width/15);
412 if( w1 > wd->item_width )
415 w2 = (wd->width-w1)/(count -1);
420 EINA_LIST_FOREACH(wd->seg_ctrl, l, it)
422 edje_object_size_min_restricted_calc(it->base, &mw, &mh, 0, 0);
423 evas_object_size_hint_weight_set(it->base, 1.0, 1.0);
424 evas_object_size_hint_align_set(it->base, -1.0, -1.0);
426 if(wd->ani_it && it == wd->ani_it)
428 evas_object_resize(it->base, w1, wd->height);
429 evas_object_size_hint_min_set(it->base, w1, wd->height);
430 evas_object_size_hint_max_set(it->base, w1, wd->height);
434 evas_object_resize(it->base, w2, wd->height);
435 evas_object_size_hint_min_set(it->base, w2, wd->height);
436 evas_object_size_hint_max_set(it->base, w2, wd->height);
446 _animator_animate_add_cb(Evas_Object *obj)
449 Widget_Data *wd = elm_widget_data_get(obj);
452 evas_object_geometry_get(wd->ani_it->base, NULL, NULL, &w, NULL);
453 if( w < wd->item_width )
455 _state_value_set(obj);
456 evas_object_geometry_get(wd->ani_it->base, NULL, NULL, &w, NULL);
457 return ECORE_CALLBACK_RENEW;
461 ecore_animator_del(wd->ani);
464 return ECORE_CALLBACK_CANCEL;
470 _animator_animate_del_cb(Evas_Object *obj)
473 Widget_Data *wd = elm_widget_data_get(obj);
476 evas_object_geometry_get(wd->ani_it->base, NULL, NULL, &w, NULL);
479 _state_value_set(obj);
480 evas_object_geometry_get(wd->ani_it->base, NULL, NULL, &w, NULL);
481 return ECORE_CALLBACK_RENEW;
485 _item_free(obj, wd->ani_it );
486 _refresh_segment_ids(obj);
487 ecore_animator_del(wd->ani);
491 wd->id = eina_list_count(wd->seg_ctrl);
492 return ECORE_CALLBACK_CANCEL;
496 static Elm_Segment_Item *
497 _item_find(Evas_Object *obj, unsigned int index)
499 Elm_Segment_Item *it;
502 Widget_Data *wd = elm_widget_data_get(obj);
503 if (!wd) return NULL;
505 EINA_LIST_FOREACH(wd->seg_ctrl, l, it)
516 static Elm_Segment_Item *
517 _item_search(Evas_Object *obj, Elm_Segment_Item *item)
519 Elm_Segment_Item *it;
521 Widget_Data *wd = elm_widget_data_get(obj);
525 EINA_LIST_FOREACH(wd->seg_ctrl, l, it)
536 * Add a new segmentcontrol to the parent
537 * @param parent The parent object
538 * @return The new object or NULL if it cannot be created
540 * @ingroup SegmentControl SegmentControl
543 elm_segment_control_add(Evas_Object *parent)
549 wd = ELM_NEW(Widget_Data);
550 e = evas_object_evas_get(parent);
551 obj = elm_widget_add(e);
552 elm_widget_type_set(obj, "segmented-control");
553 elm_widget_sub_object_add(parent, obj);
554 elm_widget_on_focus_hook_set( obj, _on_focus_hook, NULL );
555 elm_widget_data_set(obj, wd);
556 elm_widget_del_hook_set(obj, _del_hook);
557 elm_widget_theme_hook_set(obj, _theme_hook);
559 wd->base = edje_object_add(e);
560 _elm_theme_object_set(obj, wd->base, "segmented-control", "base", "default");
561 elm_widget_resize_object_set(obj, wd->base);
562 wd->box = evas_object_box_add(e);
563 evas_object_box_layout_set(wd->box, _layout, wd, NULL);
564 elm_widget_sub_object_add(obj, wd->box);
565 edje_object_part_swallow(wd->base, "elm.swallow.content", wd->box);
566 evas_object_show(wd->box);
568 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _object_resize, obj);
571 wd->insert_index = 0;
573 wd->selected = EINA_FALSE;
579 * Add a new segment item to segmentcontrol
580 * @param obj The SegmentControl object
581 * @param icon The icon object for added segment item
582 * @param label The label for added segment item
583 * @param animate If 1 the action be animated with sliding effects default 0.
584 * @return The new segment item or NULL if it cannot be created
586 * @ingroup SegmentControl SegmentControl
589 EAPI Elm_Segment_Item *
590 elm_segment_control_item_add(Evas_Object *obj, Evas_Object *icon, const char *label, Eina_Bool animate)
592 Elm_Segment_Item *it;
593 Widget_Data *wd = elm_widget_data_get(obj);
596 it = _item_new(obj, label, icon);
599 wd->seg_ctrl = eina_list_append(wd->seg_ctrl, it);
600 wd->id = eina_list_count(wd->seg_ctrl);
602 evas_object_event_callback_add(it->base, EVAS_CALLBACK_MOUSE_DOWN, _mouse_down, it);
603 evas_object_event_callback_add(it->base, EVAS_CALLBACK_MOUSE_UP, _mouse_up, it);
604 wd->insert_index = 0;
606 _refresh_segment_ids(obj);
608 if(animate && it->segment_id && wd->ani_it == NULL)
610 evas_object_resize(it->base, 1, wd->height);
612 wd->ani = ecore_animator_add( _animator_animate_add_cb, obj );
615 _state_value_set(obj);
616 evas_object_show( it->base);
618 evas_object_box_append(wd->box, it->base);
619 evas_object_smart_calculate(wd->box);
625 * Add a new segment item to segmentcontrol
626 * @param obj The SegmentControl object
627 * @param icon The icon object for added segment item
628 * @param label The label for added segment item
629 * @param animate If 1 the action be animated with sliding effects default 0.
630 * @return The new segment item or NULL if it cannot be created
632 * @ingroup SegmentControl SegmentControl
635 EAPI Elm_Segment_Item *
636 elm_segment_control_add_segment(Evas_Object *obj, Evas_Object *icon, const char *label, Eina_Bool animate)
638 EAPI Elm_Segment_Item * it;
639 it = elm_segment_control_item_add(obj, icon, label, animate);
645 * Insert a new segment item to segmentcontrol
646 * @param obj The SegmentControl object
647 * @param icon The icon object for added segment item
648 * @param label The label for added segment item
649 * @param index The position at which segment item to be inserted
650 * @param animate If 1 the action be animated with sliding effects default 0.
651 * @return The new segment item or NULL if it cannot be created
653 * @ingroup SegmentControl SegmentControl
656 EAPI Elm_Segment_Item *
657 elm_segment_control_item_insert_at(Evas_Object *obj, Evas_Object *icon, const char *label, unsigned int index, Eina_Bool animate)
659 Elm_Segment_Item *it, *it_rel;
660 Widget_Data *wd = elm_widget_data_get(obj);
663 it = _item_new(obj, label, icon);
664 it_rel = _item_find(obj, index);
667 wd->seg_ctrl = eina_list_append(wd->seg_ctrl, it);
672 wd->seg_ctrl = eina_list_prepend_relative(wd->seg_ctrl, it, it_rel);
674 evas_object_event_callback_add(it->base, EVAS_CALLBACK_MOUSE_DOWN, _mouse_down, it);
675 evas_object_event_callback_add(it->base, EVAS_CALLBACK_MOUSE_UP, _mouse_up, it);
676 wd->insert_index = index;
677 wd->id = eina_list_count(wd->seg_ctrl);
678 _refresh_segment_ids(obj);
681 if(animate && it->segment_id && wd->ani_it == NULL)
684 evas_object_resize(it->base, 1, wd->height);
685 wd->ani = ecore_animator_add( _animator_animate_add_cb, obj );
688 _state_value_set(obj);
690 evas_object_show( it->base);
692 if(index >= wd->id-1)
694 evas_object_box_append(wd->box, it->base);
698 evas_object_box_insert_at(wd->box, it->base, index);
701 evas_object_smart_calculate(wd->box);
707 * Insert a new segment item to segmentcontrol
708 * @param obj The SegmentControl object
709 * @param icon The icon object for added segment item
710 * @param label The label for added segment item
711 * @param index The position at which segment item to be inserted
712 * @param animate If 1 the action be animated with sliding effects default 0.
714 * @ingroup SegmentControl SegmentControl
718 elm_segment_control_insert_segment_at(Evas_Object *obj, Evas_Object *icon, const char *label, unsigned int index, Eina_Bool animate)
720 Elm_Segment_Item *it;
721 it = elm_segment_control_item_insert_at(obj, icon, label, index, animate);
727 * Delete a segment item to segmentcontrol
728 * @param obj The SegmentControl object
729 * @param item The Segment item to be deleted
730 * @param animate If 1 the action be animated with sliding effects default 0.
732 * @ingroup SegmentControl SegmentControl
735 elm_segment_control_item_del(Evas_Object *obj, Elm_Segment_Item *item, Eina_Bool animate)
737 Elm_Segment_Item *it;
738 Widget_Data *wd = elm_widget_data_get(obj);
743 it = _item_search(obj, item);
746 wd->del_index = it->segment_id;
747 if(animate && it->segment_id && wd->ani_it == NULL)
749 it->delete_me = EINA_TRUE;
751 wd->ani = ecore_animator_add( _animator_animate_del_cb, obj );
755 evas_object_box_remove(wd->box, it->base);
756 evas_object_smart_calculate(wd->box);
758 _refresh_segment_ids(obj);
759 _state_value_set(obj);
762 wd->id = eina_list_count(wd->seg_ctrl);
767 * Delete a segment item to segmentcontrol
768 * @param obj The SegmentControl object
769 * @param item The Segment item to be deleted
770 * @param animate If 1 the action be animated with sliding effects default 0.
772 * @ingroup SegmentControl SegmentControl
776 elm_segment_control_delete_segment(Evas_Object *obj, Elm_Segment_Item *item, Eina_Bool animate)
778 elm_segment_control_item_del(obj, item, animate);
784 * Delete a segment item to segmentcontrol
785 * @param obj The SegmentControl object
786 * @param index The position at which segment item to be deleted
787 * @param animate If 1 the action be animated with sliding effects default 0.
789 * @ingroup SegmentControl SegmentControl
793 elm_segment_control_item_del_at(Evas_Object *obj, unsigned int index, Eina_Bool animate)
795 Elm_Segment_Item *it;
796 Widget_Data *wd = elm_widget_data_get(obj);
799 it = _item_find(obj, index);
803 wd->del_index = index;
804 if(animate && it->segment_id)
806 if(wd->ani_it == NULL)
809 it->delete_me = EINA_TRUE;
810 wd->ani = ecore_animator_add( _animator_animate_del_cb, obj );
815 evas_object_box_remove(wd->box, it->base);
816 evas_object_smart_calculate(wd->box);
818 _refresh_segment_ids(obj);
819 _state_value_set(obj);
822 wd->id = eina_list_count(wd->seg_ctrl);
827 * Delete a segment item to segmentcontrol
828 * @param obj The SegmentControl object
829 * @param index The position at which segment item to be deleted
830 * @param animate If 1 the action be animated with sliding effects default 0.
832 * @ingroup SegmentControl SegmentControl
836 elm_segment_control_delete_segment_at(Evas_Object *obj, unsigned int index, Eina_Bool animate)
838 elm_segment_control_item_del_at( obj, index, animate);
844 * Get the label of a segment item of segmentcontrol
845 * @param obj The SegmentControl object
846 * @param index The index of the segment item
847 * @return The label of the segment item
849 * @ingroup SegmentControl SegmentControl
853 elm_segment_control_item_label_get(Evas_Object *obj, unsigned int index)
855 Elm_Segment_Item *it_rel;
856 Widget_Data *wd = elm_widget_data_get(obj);
859 it_rel = _item_find(obj, index);
861 if(it_rel) return it_rel->label;
867 * Get the label of a segment item of segmentcontrol
868 * @param obj The SegmentControl object
869 * @param index The index of the segment item
870 * @return The label of the segment item
872 * @ingroup SegmentControl SegmentControl
876 elm_segment_control_get_segment_label_at(Evas_Object *obj, unsigned int index)
879 label = elm_segment_control_item_label_get( obj, index);
885 * Get the icon of a segment item of segmentcontrol
886 * @param obj The SegmentControl object
887 * @param index The index of the segment item
888 * @return The icon object or NULL if it is not found.
890 * @ingroup SegmentControl SegmentControl
894 elm_segment_control_item_icon_get(Evas_Object *obj, unsigned int index)
896 Elm_Segment_Item *seg_rel;
897 Widget_Data *wd = elm_widget_data_get(obj);
900 seg_rel = _item_find(obj, index);
902 if(seg_rel) return seg_rel->icon;
908 * Get the icon of a segment item of segmentcontrol
909 * @param obj The SegmentControl object
910 * @param index The index of the segment item
911 * @return The icon object or NULL if it is not found.
913 * @ingroup SegmentControl SegmentControl
917 elm_segment_control_get_segment_icon_at(Evas_Object *obj, unsigned int index)
920 icon = elm_segment_control_item_icon_get( obj, index);
926 * Get the currently selected segment item of segmentcontrol
927 * @param obj The SegmentControl object
928 * @return The selected Segment item
930 * @ingroup SegmentControl SegmentControl
933 EAPI Elm_Segment_Item *
934 elm_segment_control_item_selected_get(const Evas_Object *obj)
936 Elm_Segment_Item *it;
938 Widget_Data *wd = elm_widget_data_get(obj);
939 if(!wd || !wd->seg_ctrl) return NULL;
941 EINA_LIST_FOREACH(wd->seg_ctrl, l, it)
943 if(it->segment_id == wd->cur_seg_id)
950 * Get the currently selected segment item of segmentcontrol
951 * @param obj The SegmentControl object
952 * @param value The current segment item id
953 * @return The selected Segment item
955 * @ingroup SegmentControl SegmentControl
958 EAPI Elm_Segment_Item *
959 elm_segment_control_selected_segment_get(const Evas_Object *obj, int *value)
961 Elm_Segment_Item *it;
962 it = elm_segment_control_item_selected_get( obj);
963 *value = it->segment_id;
969 * Get the count of segments of segmentcontrol
970 * @param obj The SegmentControl object
971 * @return The count of Segment items
973 * @ingroup SegmentControl SegmentControl
977 elm_segment_control_item_count_get(Evas_Object *obj)
979 Widget_Data *wd = elm_widget_data_get(obj);
986 * Get the count of segments of segmentcontrol
987 * @param obj The SegmentControl object
988 * @return The count of Segment items
990 * @ingroup SegmentControl SegmentControl
994 elm_segment_control_get_segment_count(Evas_Object *obj)
997 id = elm_segment_control_item_count_get( obj);
1003 * Get the base object of segment item in segmentcontrol
1004 * @param obj The Segment item
1005 * @return obj The base object of the segment item
1007 * @ingroup SegmentControl SegmentControl
1011 elm_segment_control_item_object_get(Elm_Segment_Item *it)
1013 if (!it) return NULL;
1019 * Select/unselect a particular segment item of segmentcontrol
1020 * @param item The Segment item that is to be selected or unselected.
1021 * @param select If 1 the segment item is selected and if 0 it will be unselected.
1023 * @ingroup SegmentControl SegmentControl
1027 elm_segment_control_item_selected_set( Elm_Segment_Item *item, Eina_Bool select)
1029 Widget_Data *wd = elm_widget_data_get(item->obj);
1030 if(!wd) return NULL;
1034 if(item->segment_id == wd->cur_seg_id)
1037 edje_object_signal_emit(item->base, "elm,action,focus", "elm");
1038 edje_object_signal_emit(item->base, "elm,state,text,visible", "elm");
1040 _signal_segment_on(item);
1043 else if(item->segment_id == wd->cur_seg_id)
1045 wd->selected = EINA_FALSE;
1046 wd->cur_seg_id = -1;
1047 _signal_segment_off(item);
1055 * Get a particular indexed segment item of segmentcontrol
1056 * @param obj The Segment control object.
1057 * @param index The index of the segment item.
1058 * @return The corresponding Segment item.
1060 * @ingroup SegmentControl SegmentControl
1063 EAPI Elm_Segment_Item *
1064 elm_segment_control_item_get_at(Evas_Object *obj, unsigned int index)
1066 Elm_Segment_Item *it;
1067 it = _item_find(obj, index);
1073 * Select the index of a Segment item of Segmentcontrol
1074 * @param item The Segment item.
1075 * @return The corresponding index of the Segment item.
1077 * @ingroup SegmentControl SegmentControl
1081 elm_segment_control_item_index_get(Elm_Segment_Item *item)
1083 Widget_Data *wd = elm_widget_data_get(item->obj);
1084 if(!wd) return NULL;
1086 return item->segment_id;