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);
135 Evas_Event_Mouse_Up * ev = event_info;
136 Evas_Coord x, y, w, h;
140 evas_object_geometry_get(obj, &x, &y, &w, &h);
141 if(ev->output.x > x && ev->output.x < x+w && ev->output.y > y && ev->output.y < y+h && wd->selected == EINA_FALSE)
143 _signal_segment_on(item);
147 wd->selected = EINA_FALSE;
151 // if(wd->longpressed == EINA_FALSE)
153 edje_object_signal_emit(item->base, "elm,action,unfocus", "elm");
154 edje_object_signal_emit(item->base, "elm,state,text,visible", "elm");
156 /* if (item->long_timer)
158 ecore_timer_del(item->long_timer);
159 item->long_timer = NULL;
164 _mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event_info)
166 Elm_Segment_Item *item = (Elm_Segment_Item *) data;
167 Widget_Data *wd = elm_widget_data_get(item->obj);
170 //wd->longpressed = EINA_FALSE;
172 if (item->segment_id == wd->cur_seg_id)
174 wd->selected = EINA_TRUE;
178 edje_object_signal_emit(item->base, "elm,action,focus", "elm");
179 edje_object_signal_emit(item->base, "elm,state,text,visible", "elm");
181 _signal_segment_on(item);
183 /* if (item->long_timer) ecore_timer_del(item->long_timer);
184 item->long_timer = ecore_timer_add(0.3, _signal_segment_on, item);*/
188 _theme_hook(Evas_Object *obj)
190 _elm_theme_object_set(obj, obj, "segmented-control", "base", elm_widget_style_get(obj));
196 _item_free(Evas_Object *obj, Elm_Segment_Item *it)
198 Widget_Data *wd = elm_widget_data_get(obj);
202 wd->seg_ctrl = eina_list_remove(wd->seg_ctrl, it);
204 if(it->icon) evas_object_del(it->icon);
205 if(it->base) evas_object_del(it->base);
206 if(it->label) eina_stringshare_del(it->label);
207 // if (it->long_timer) ecore_timer_del(it->long_timer);
216 _del_hook(Evas_Object *obj)
218 Widget_Data *wd = elm_widget_data_get(obj);
219 Elm_Segment_Item *it;
220 Eina_List *l, *clear = NULL;
222 EINA_LIST_FOREACH(wd->seg_ctrl, l, it) clear = eina_list_append(clear, it);
223 EINA_LIST_FREE(clear, it) _item_free(obj, it);
233 _layout(Evas_Object *o, Evas_Object_Box_Data *priv, void *data)
235 Widget_Data *wd = data;
237 _els_box_layout(o, priv, 1, 0); /* making box layout non homogenous */
243 _segment_resizing(void *data)
245 Widget_Data *wd = elm_widget_data_get((Evas_Object *)data);
247 Evas_Coord w = 0, h = 0;
249 evas_object_geometry_get(wd->base, NULL, NULL, &w, &h);
250 wd->item_width = wd->width = w;
252 _state_value_set((Evas_Object *)data);
256 _object_resize(void *data, Evas *e, Evas_Object *obj, void *event_info)
260 wd = elm_widget_data_get((Evas_Object *)data);
263 ecore_job_add(_segment_resizing, (Evas_Object *)data);
266 static Elm_Segment_Item*
267 _item_new(Evas_Object *obj, const char *label, Evas_Object *icon)
269 Elm_Segment_Item *it;
271 Widget_Data *wd = elm_widget_data_get(obj);
272 if (!wd) return NULL;
274 it = calloc(1, sizeof( Elm_Segment_Item));
275 if (!it) return NULL;
277 if(obj) it->obj = obj;
278 it->delete_me = EINA_FALSE;
279 it->segment_id = wd->id;
281 it->base = edje_object_add(evas_object_evas_get(obj));
282 _elm_theme_object_set(obj, it->base, "segment", "base", elm_object_style_get(it->base));
284 if (it->label) eina_stringshare_del(it->label);
287 it->label = eina_stringshare_add(label);
294 if ((it->icon != icon) && (it->icon))
295 elm_widget_sub_object_del(obj, it->icon);
299 elm_widget_sub_object_add(obj, icon);
300 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
301 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
302 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
304 evas_object_size_hint_weight_set(it->base, 1.0, -1.0);
305 evas_object_size_hint_align_set(it->base, 1.0, -1.0);
306 evas_object_size_hint_min_set(it->base, -1, -1);
307 evas_object_size_hint_max_set(it->base, maxw, maxh);
310 edje_object_size_min_restricted_calc(obj, &mw, &mh, 0, 0);
311 evas_object_size_hint_weight_set(obj, 1.0, 1.0);
312 evas_object_size_hint_align_set(obj, -1.0, -1.0);
319 _update_list(Evas_Object *obj)
321 Elm_Segment_Item *it;
325 Widget_Data *wd = elm_widget_data_get(obj);
328 wd->count = eina_list_count(wd->seg_ctrl);
331 it = _item_find(obj, 0);
332 _elm_theme_object_set(obj, it->base, "segment", "base", "single");
\r
333 edje_object_signal_emit(it->base, "elm,state,segment,on", "elm");
334 edje_object_signal_emit(it->base, "elm,state,text,visible", "elm");
335 edje_object_signal_emit(it->base, "elm,state,text,change", "elm");
336 edje_object_message_signal_process(it->base);
338 edje_object_part_text_set(it->base, "elm.text", it->label);
340 edje_object_part_swallow(it->base, "elm.swallow.content", it->icon);
341 edje_object_signal_emit(it->base, "elm,state,icon,visible", "elm");
345 EINA_LIST_FOREACH(wd->seg_ctrl, l, it)
349 _elm_theme_object_set(obj, it->base, "segment", "base", "first");
351 else if(i==wd->count-1)
353 _elm_theme_object_set(obj, it->base, "segment", "base", "last");
357 _elm_theme_object_set(obj, it->base, "segment", "base", "default");
360 edje_object_signal_emit(it->base, "elm,state,text,visible", "elm");
361 edje_object_message_signal_process(it->base);
363 edje_object_part_text_set(it->base, "elm.text", it->label);
365 edje_object_part_swallow(it->base, "elm.swallow.content", it->icon);
366 edje_object_signal_emit(it->base, "elm,state,icon,visible", "elm");
374 _refresh_segment_ids(Evas_Object *obj)
376 Elm_Segment_Item *it;
379 Widget_Data *wd = elm_widget_data_get(obj);
382 if (wd->insert_index && wd->cur_seg_id >= wd->insert_index)
385 wd->insert_index = 0;
389 if (wd->cur_seg_id >= wd->del_index)
394 EINA_LIST_FOREACH(wd->seg_ctrl, l, it)
402 _state_value_set(Evas_Object *obj)
404 Elm_Segment_Item *it;
406 Evas_Coord mw, mh, x, y;
409 Widget_Data *wd = elm_widget_data_get(obj);
412 count = eina_list_count(wd->seg_ctrl);
414 wd->item_width = wd->width/count;
417 evas_object_geometry_get(wd->ani_it->base, &x, &y, &w1, NULL);
418 if (wd->ani_it->delete_me)
420 w1-=(wd->item_width/15);
425 w1+=(wd->item_width/15);
426 if( w1 > wd->item_width )
429 w2 = (wd->width-w1)/(count -1);
434 EINA_LIST_FOREACH(wd->seg_ctrl, l, it)
436 edje_object_size_min_restricted_calc(it->base, &mw, &mh, 0, 0);
437 evas_object_size_hint_weight_set(it->base, 1.0, 1.0);
438 evas_object_size_hint_align_set(it->base, -1.0, -1.0);
440 if(wd->ani_it && it == wd->ani_it)
442 evas_object_resize(it->base, w1, wd->height);
443 evas_object_size_hint_min_set(it->base, w1, wd->height);
444 evas_object_size_hint_max_set(it->base, w1, wd->height);
448 evas_object_resize(it->base, w2, wd->height);
449 evas_object_size_hint_min_set(it->base, w2, wd->height);
450 evas_object_size_hint_max_set(it->base, w2, wd->height);
460 _animator_animate_add_cb(Evas_Object *obj)
463 Widget_Data *wd = elm_widget_data_get(obj);
466 evas_object_geometry_get(wd->ani_it->base, NULL, NULL, &w, NULL);
467 if( w < wd->item_width )
469 _state_value_set(obj);
470 evas_object_geometry_get(wd->ani_it->base, NULL, NULL, &w, NULL);
471 return ECORE_CALLBACK_RENEW;
475 ecore_animator_del(wd->ani);
478 return ECORE_CALLBACK_CANCEL;
484 _animator_animate_del_cb(Evas_Object *obj)
487 Widget_Data *wd = elm_widget_data_get(obj);
490 evas_object_geometry_get(wd->ani_it->base, NULL, NULL, &w, NULL);
493 _state_value_set(obj);
494 evas_object_geometry_get(wd->ani_it->base, NULL, NULL, &w, NULL);
495 return ECORE_CALLBACK_RENEW;
499 _item_free(obj, wd->ani_it );
500 _refresh_segment_ids(obj);
501 ecore_animator_del(wd->ani);
505 wd->id = eina_list_count(wd->seg_ctrl);
506 return ECORE_CALLBACK_CANCEL;
510 static Elm_Segment_Item *
511 _item_find(Evas_Object *obj, unsigned int index)
513 Elm_Segment_Item *it;
516 Widget_Data *wd = elm_widget_data_get(obj);
517 if (!wd) return NULL;
519 EINA_LIST_FOREACH(wd->seg_ctrl, l, it)
530 static Elm_Segment_Item *
531 _item_search(Evas_Object *obj, Elm_Segment_Item *item)
533 Elm_Segment_Item *it;
535 Widget_Data *wd = elm_widget_data_get(obj);
539 EINA_LIST_FOREACH(wd->seg_ctrl, l, it)
550 * Add a new segmentcontrol to the parent
551 * @param parent The parent object
552 * @return The new object or NULL if it cannot be created
554 * @ingroup SegmentControl SegmentControl
557 elm_segment_control_add(Evas_Object *parent)
563 wd = ELM_NEW(Widget_Data);
564 e = evas_object_evas_get(parent);
565 obj = elm_widget_add(e);
566 elm_widget_type_set(obj, "segmented-control");
567 elm_widget_sub_object_add(parent, obj);
568 elm_widget_on_focus_hook_set( obj, _on_focus_hook, NULL );
569 elm_widget_data_set(obj, wd);
570 elm_widget_del_hook_set(obj, _del_hook);
571 elm_widget_theme_hook_set(obj, _theme_hook);
573 wd->base = edje_object_add(e);
574 _elm_theme_object_set(obj, wd->base, "segmented-control", "base", "default");
575 elm_widget_resize_object_set(obj, wd->base);
576 wd->box = evas_object_box_add(e);
577 evas_object_box_layout_set(wd->box, _layout, wd, NULL);
578 elm_widget_sub_object_add(obj, wd->box);
579 edje_object_part_swallow(wd->base, "elm.swallow.content", wd->box);
580 evas_object_show(wd->box);
582 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _object_resize, obj);
585 wd->insert_index = 0;
587 wd->selected = EINA_FALSE;
593 * Add a new segment item to segmentcontrol
594 * @param obj The SegmentControl object
595 * @param icon The icon object for added segment item
596 * @param label The label for added segment item
597 * @param animate If 1 the action be animated with sliding effects default 0.
598 * @return The new segment item or NULL if it cannot be created
600 * @ingroup SegmentControl SegmentControl
603 EAPI Elm_Segment_Item *
604 elm_segment_control_item_add(Evas_Object *obj, Evas_Object *icon, const char *label, Eina_Bool animate)
606 Elm_Segment_Item *it;
607 Widget_Data *wd = elm_widget_data_get(obj);
610 it = _item_new(obj, label, icon);
613 wd->seg_ctrl = eina_list_append(wd->seg_ctrl, it);
614 wd->id = eina_list_count(wd->seg_ctrl);
616 evas_object_event_callback_add(it->base, EVAS_CALLBACK_MOUSE_DOWN, _mouse_down, it);
617 evas_object_event_callback_add(it->base, EVAS_CALLBACK_MOUSE_UP, _mouse_up, it);
618 wd->insert_index = 0;
620 _refresh_segment_ids(obj);
622 if(animate && it->segment_id && wd->ani_it == NULL)
624 evas_object_resize(it->base, 1, wd->height);
626 wd->ani = ecore_animator_add( _animator_animate_add_cb, obj );
629 _state_value_set(obj);
630 evas_object_show( it->base);
632 evas_object_box_append(wd->box, it->base);
633 evas_object_smart_calculate(wd->box);
639 * Add a new segment item to segmentcontrol
640 * @param obj The SegmentControl object
641 * @param icon The icon object for added segment item
642 * @param label The label for added segment item
643 * @param animate If 1 the action be animated with sliding effects default 0.
644 * @return The new segment item or NULL if it cannot be created
646 * @ingroup SegmentControl SegmentControl
649 EAPI Elm_Segment_Item *
650 elm_segment_control_add_segment(Evas_Object *obj, Evas_Object *icon, const char *label, Eina_Bool animate)
652 EAPI Elm_Segment_Item * it;
653 it = elm_segment_control_item_add(obj, icon, label, animate);
659 * Insert a new segment item to segmentcontrol
660 * @param obj The SegmentControl object
661 * @param icon The icon object for added segment item
662 * @param label The label for added segment item
663 * @param index The position at which segment item to be inserted
664 * @param animate If 1 the action be animated with sliding effects default 0.
665 * @return The new segment item or NULL if it cannot be created
667 * @ingroup SegmentControl SegmentControl
670 EAPI Elm_Segment_Item *
671 elm_segment_control_item_insert_at(Evas_Object *obj, Evas_Object *icon, const char *label, unsigned int index, Eina_Bool animate)
673 Elm_Segment_Item *it, *it_rel;
674 Widget_Data *wd = elm_widget_data_get(obj);
677 it = _item_new(obj, label, icon);
678 it_rel = _item_find(obj, index);
681 wd->seg_ctrl = eina_list_append(wd->seg_ctrl, it);
686 wd->seg_ctrl = eina_list_prepend_relative(wd->seg_ctrl, it, it_rel);
688 evas_object_event_callback_add(it->base, EVAS_CALLBACK_MOUSE_DOWN, _mouse_down, it);
689 evas_object_event_callback_add(it->base, EVAS_CALLBACK_MOUSE_UP, _mouse_up, it);
690 wd->insert_index = index;
691 wd->id = eina_list_count(wd->seg_ctrl);
692 _refresh_segment_ids(obj);
695 if(animate && it->segment_id && wd->ani_it == NULL)
698 evas_object_resize(it->base, 1, wd->height);
699 wd->ani = ecore_animator_add( _animator_animate_add_cb, obj );
702 _state_value_set(obj);
704 evas_object_show( it->base);
706 if(index >= wd->id-1)
708 evas_object_box_append(wd->box, it->base);
712 evas_object_box_insert_at(wd->box, it->base, index);
715 evas_object_smart_calculate(wd->box);
721 * Insert a new segment item to segmentcontrol
722 * @param obj The SegmentControl object
723 * @param icon The icon object for added segment item
724 * @param label The label for added segment item
725 * @param index The position at which segment item to be inserted
726 * @param animate If 1 the action be animated with sliding effects default 0.
728 * @ingroup SegmentControl SegmentControl
732 elm_segment_control_insert_segment_at(Evas_Object *obj, Evas_Object *icon, const char *label, unsigned int index, Eina_Bool animate)
734 Elm_Segment_Item *it;
735 it = elm_segment_control_item_insert_at(obj, icon, label, index, animate);
741 * Delete a segment item to segmentcontrol
742 * @param obj The SegmentControl object
743 * @param item The Segment item to be deleted
744 * @param animate If 1 the action be animated with sliding effects default 0.
746 * @ingroup SegmentControl SegmentControl
749 elm_segment_control_item_del(Evas_Object *obj, Elm_Segment_Item *item, Eina_Bool animate)
751 Elm_Segment_Item *it;
752 Widget_Data *wd = elm_widget_data_get(obj);
757 it = _item_search(obj, item);
760 wd->del_index = it->segment_id;
761 if(animate && it->segment_id && wd->ani_it == NULL)
763 it->delete_me = EINA_TRUE;
765 wd->ani = ecore_animator_add( _animator_animate_del_cb, obj );
769 evas_object_box_remove(wd->box, it->base);
770 evas_object_smart_calculate(wd->box);
772 _refresh_segment_ids(obj);
773 _state_value_set(obj);
776 wd->id = eina_list_count(wd->seg_ctrl);
781 * Delete a segment item to segmentcontrol
782 * @param obj The SegmentControl object
783 * @param item The Segment item to be deleted
784 * @param animate If 1 the action be animated with sliding effects default 0.
786 * @ingroup SegmentControl SegmentControl
790 elm_segment_control_delete_segment(Evas_Object *obj, Elm_Segment_Item *item, Eina_Bool animate)
792 elm_segment_control_item_del(obj, item, animate);
798 * Delete a segment item to segmentcontrol
799 * @param obj The SegmentControl object
800 * @param index The position at which segment item to be deleted
801 * @param animate If 1 the action be animated with sliding effects default 0.
803 * @ingroup SegmentControl SegmentControl
807 elm_segment_control_item_del_at(Evas_Object *obj, unsigned int index, Eina_Bool animate)
809 Elm_Segment_Item *it;
810 Widget_Data *wd = elm_widget_data_get(obj);
813 it = _item_find(obj, index);
817 wd->del_index = index;
818 if(animate && it->segment_id)
820 if(wd->ani_it == NULL)
823 it->delete_me = EINA_TRUE;
824 wd->ani = ecore_animator_add( _animator_animate_del_cb, obj );
829 evas_object_box_remove(wd->box, it->base);
830 evas_object_smart_calculate(wd->box);
832 _refresh_segment_ids(obj);
833 _state_value_set(obj);
836 wd->id = eina_list_count(wd->seg_ctrl);
841 * Delete a segment item to segmentcontrol
842 * @param obj The SegmentControl object
843 * @param index The position at which segment item to be deleted
844 * @param animate If 1 the action be animated with sliding effects default 0.
846 * @ingroup SegmentControl SegmentControl
850 elm_segment_control_delete_segment_at(Evas_Object *obj, unsigned int index, Eina_Bool animate)
852 elm_segment_control_item_del_at( obj, index, animate);
858 * Get the label of a segment item of segmentcontrol
859 * @param obj The SegmentControl object
860 * @param index The index of the segment item
861 * @return The label of the segment item
863 * @ingroup SegmentControl SegmentControl
867 elm_segment_control_item_label_get(Evas_Object *obj, unsigned int index)
869 Elm_Segment_Item *it_rel;
870 Widget_Data *wd = elm_widget_data_get(obj);
873 it_rel = _item_find(obj, index);
875 if(it_rel) return it_rel->label;
881 * Get the label of a segment item of segmentcontrol
882 * @param obj The SegmentControl object
883 * @param index The index of the segment item
884 * @return The label of the segment item
886 * @ingroup SegmentControl SegmentControl
890 elm_segment_control_get_segment_label_at(Evas_Object *obj, unsigned int index)
893 label = elm_segment_control_item_label_get( obj, index);
899 * Get the icon of a segment item of segmentcontrol
900 * @param obj The SegmentControl object
901 * @param index The index of the segment item
902 * @return The icon object or NULL if it is not found.
904 * @ingroup SegmentControl SegmentControl
908 elm_segment_control_item_icon_get(Evas_Object *obj, unsigned int index)
910 Elm_Segment_Item *seg_rel;
911 Widget_Data *wd = elm_widget_data_get(obj);
914 seg_rel = _item_find(obj, index);
916 if(seg_rel) return seg_rel->icon;
922 * Get the icon of a segment item of segmentcontrol
923 * @param obj The SegmentControl object
924 * @param index The index of the segment item
925 * @return The icon object or NULL if it is not found.
927 * @ingroup SegmentControl SegmentControl
931 elm_segment_control_get_segment_icon_at(Evas_Object *obj, unsigned int index)
934 icon = elm_segment_control_item_icon_get( obj, index);
940 * Get the currently selected segment item of segmentcontrol
941 * @param obj The SegmentControl object
942 * @return The selected Segment item
944 * @ingroup SegmentControl SegmentControl
947 EAPI Elm_Segment_Item *
948 elm_segment_control_item_selected_get(const Evas_Object *obj)
950 Elm_Segment_Item *it;
952 Widget_Data *wd = elm_widget_data_get(obj);
953 if(!wd || !wd->seg_ctrl) return NULL;
955 EINA_LIST_FOREACH(wd->seg_ctrl, l, it)
957 if(it->segment_id == wd->cur_seg_id)
964 * Get the currently selected segment item of segmentcontrol
965 * @param obj The SegmentControl object
966 * @param value The current segment item id
967 * @return The selected Segment item
969 * @ingroup SegmentControl SegmentControl
972 EAPI Elm_Segment_Item *
973 elm_segment_control_selected_segment_get(const Evas_Object *obj, int *value)
975 Elm_Segment_Item *it;
976 it = elm_segment_control_item_selected_get( obj);
977 *value = it->segment_id;
983 * Get the count of segments of segmentcontrol
984 * @param obj The SegmentControl object
985 * @return The count of Segment items
987 * @ingroup SegmentControl SegmentControl
991 elm_segment_control_item_count_get(Evas_Object *obj)
993 Widget_Data *wd = elm_widget_data_get(obj);
1000 * Get the count of segments of segmentcontrol
1001 * @param obj The SegmentControl object
1002 * @return The count of Segment items
1004 * @ingroup SegmentControl SegmentControl
1008 elm_segment_control_get_segment_count(Evas_Object *obj)
1011 id = elm_segment_control_item_count_get( obj);
1017 * Get the base object of segment item in segmentcontrol
1018 * @param obj The Segment item
1019 * @return obj The base object of the segment item
1021 * @ingroup SegmentControl SegmentControl
1025 elm_segment_control_item_object_get(Elm_Segment_Item *it)
1027 if (!it) return NULL;
1033 * Select/unselect a particular segment item of segmentcontrol
1034 * @param item The Segment item that is to be selected or unselected.
1035 * @param select If 1 the segment item is selected and if 0 it will be unselected.
1037 * @ingroup SegmentControl SegmentControl
1041 elm_segment_control_item_selected_set( Elm_Segment_Item *item, Eina_Bool select)
1043 Widget_Data *wd = elm_widget_data_get(item->obj);
1044 if(!wd) return NULL;
1048 if(item->segment_id == wd->cur_seg_id)
1051 edje_object_signal_emit(item->base, "elm,action,focus", "elm");
1052 edje_object_signal_emit(item->base, "elm,state,text,visible", "elm");
1054 _signal_segment_on(item);
1057 else if(item->segment_id == wd->cur_seg_id)
1059 wd->selected = EINA_FALSE;
1060 wd->cur_seg_id = -1;
1061 _signal_segment_off(item);
1069 * Get a particular indexed segment item of segmentcontrol
1070 * @param obj The Segment control object.
1071 * @param index The index of the segment item.
1072 * @return The corresponding Segment item.
1074 * @ingroup SegmentControl SegmentControl
1077 EAPI Elm_Segment_Item *
1078 elm_segment_control_item_get_at(Evas_Object *obj, unsigned int index)
1080 Elm_Segment_Item *it;
1081 it = _item_find(obj, index);