Tizen Native API
Functions
SegmentControl
Elementary Widgets

Functions

Evas_Objectelm_segment_control_add (Evas_Object *parent)
 Adds a new segment control widget to the given parent Elementary (container) object.
Elm_Object_Itemelm_segment_control_item_add (Evas_Object *obj, Evas_Object *icon, const char *label)
 Appends a new item to the segment control object.
Elm_Object_Itemelm_segment_control_item_insert_at (Evas_Object *obj, Evas_Object *icon, const char *label, int index)
 Inserts a new item to the segment control object at the specified position.
void elm_segment_control_item_del_at (Evas_Object *obj, int index)
 Removes a segment control item at the given index from its parent, deleting it.
int elm_segment_control_item_count_get (const Evas_Object *obj)
 Gets the segment items count from the segment control.
Elm_Object_Itemelm_segment_control_item_get (const Evas_Object *obj, int index)
 Gets the item placed at the specified index.
const char * elm_segment_control_item_label_get (const Evas_Object *obj, int index)
 Gets the label of the item.
Evas_Objectelm_segment_control_item_icon_get (const Evas_Object *obj, int index)
 Gets the icon associated to the item.
int elm_segment_control_item_index_get (const Elm_Object_Item *it)
 Gets the index of an item.
Evas_Objectelm_segment_control_item_object_get (const Elm_Object_Item *it)
 Gets the base object of the item.
Elm_Object_Itemelm_segment_control_item_selected_get (const Evas_Object *obj)
 Gets the selected item.
void elm_segment_control_item_selected_set (Elm_Object_Item *it, Eina_Bool select)
 Sets the selected state of an item.

Segment control widget is a horizontal control made of multiple segment items, each segment item functioning similar to a discrete two state button.

segment_control_inheritance_tree.png
segment_control.png

A segment control groups the items together and provides a compact single button with multiple equal size segments.

Segment item size is determined by base widget size and the number of items added. Only one segment item can be at a selected state. A segment item can display a combination of Text and any Evas_Object like Images or other widgets.

This widget inherits from the Layout one, so that all the functions acting on it also work for segment control objects.

This widget emits the following signals, besides the ones sent from Layout :

Available styles for it:

The default content parts of the segment control items that you can use are:

The default text parts of the segment control items that you can use are:

Supported common elm_object APIs.

Supported common elm_object_item APIs.


Function Documentation

Adds a new segment control widget to the given parent Elementary (container) object.

This function inserts a new segment control widget on the canvas.

Since :
2.3
Parameters:
[in]parentThe parent object
Returns:
A new segment control widget handle, otherwise NULL in case of an error
Elm_Object_Item* elm_segment_control_item_add ( Evas_Object obj,
Evas_Object icon,
const char *  label 
)

Appends a new item to the segment control object.

Since :
2.3
Remarks:
A new item is created and appended to the segment control, i.e., it is set as the last item.
If it should be inserted at another position, elm_segment_control_item_insert_at() should be used instead.
Items created with this function can be deleted with function elm_object_item_del() or elm_object_item_del_at().
label set to NULL is different from an empty string "". If an item only has icon, it is displayed bigger and it is centered. If it has an icon and a label, even an empty string, the icon is smaller and positioned towards the left.

Simple example:

 sc = elm_segment_control_add(win);
 ic = elm_icon_add(win);
 elm_image_file_set(ic, "path/to/image", NULL);
 elm_icon_resizable_set(ic, EINA_TRUE, EINA_TRUE);
 elm_segment_control_item_add(sc, ic, "label");
 evas_object_show(sc);
Parameters:
[in]objThe segment control object.
[in]iconThe icon object to use for the left side of the item
An icon can be any Evas object, but usually it is an icon created with elm_icon_add().
[in]labelThe label of the item
Note that, NULL is different from an empty string "".
Returns:
The created item, otherwise NULL on failure
See also:
elm_segment_control_item_insert_at()
elm_object_item_del()

Gets the segment items count from the segment control.

It just returns the number of items added to the segment control obj.

Since :
2.3
Parameters:
[in]objThe segment control object
Returns:
The segment items count
void elm_segment_control_item_del_at ( Evas_Object obj,
int  index 
)

Removes a segment control item at the given index from its parent, deleting it.

Since :
2.3
Remarks:
Items can be added with elm_segment_control_item_add() or elm_segment_control_item_insert_at().
Parameters:
[in]objThe segment control object
[in]indexThe position of the segment control item to be deleted
Elm_Object_Item* elm_segment_control_item_get ( const Evas_Object obj,
int  index 
)

Gets the item placed at the specified index.

Since :
2.3
Remarks:
Index is the position of an item in the segment control widget. Its range is from 0 to count - 1 . Count is the number of items, that can be obtained with elm_segment_control_item_count_get().
Parameters:
[in]objThe segment control object
[in]indexThe index of the segment item
Returns:
The segment control item, otherwise NULL on failure
Evas_Object* elm_segment_control_item_icon_get ( const Evas_Object obj,
int  index 
)

Gets the icon associated to the item.

Since :
2.3
Remarks:
The return value is a pointer to the icon associated to the item when it is created, with function elm_segment_control_item_add(), or later with function elm_object_item_part_content_set(). If no icon is passed as an argument, it returns NULL.
Parameters:
[in]objThe segment control object
[in]indexThe index of the segment item
Returns:
The left side icon associated to the item at index
See also:
elm_segment_control_item_add()
elm_object_item_part_content_set()

Gets the index of an item.

Since :
2.3
Remarks:
Index is the position of an item in the segment control widget. Its range is from 0 to count - 1 . Count is the number of items, that can be obtained with elm_segment_control_item_count_get().
Parameters:
[in]itThe segment control item
Returns:
The position of the item in the segment control widget
Elm_Object_Item* elm_segment_control_item_insert_at ( Evas_Object obj,
Evas_Object icon,
const char *  label,
int  index 
)

Inserts a new item to the segment control object at the specified position.

Since :
2.3
Remarks:
Index values must be between 0, when the item is prepended to the segment control, and items count, that can be obtained with elm_segment_control_item_count_get(), similar to the case when the item is appended to the segment control, just like elm_segment_control_item_add().
Items created with this function can be deleted with function elm_object_item_del() or elm_segment_control_item_del_at().
label set to NULL is different from an empty string "". If an item only has an icon, it is displayed bigger and it is centered. If it has an icon and a label, even an empty string, the icon is smaller and positioned towards the left.
Parameters:
[in]objThe segment control object
[in]iconThe icon object to use for the left side of the item
An icon can be any Evas object, but usually it is an icon created with elm_icon_add().
[in]labelThe label of the item
[in]indexThe item position
The value should be between 0 and the items count.
Returns:
The created item, otherwise NULL on failure
See also:
elm_segment_control_item_add()
elm_segment_control_item_count_get()
elm_object_item_del()
const char* elm_segment_control_item_label_get ( const Evas_Object obj,
int  index 
)

Gets the label of the item.

Since :
2.3
Remarks:
The return value is a pointer to the label associated to the item when it is created, with function elm_segment_control_item_add(), or later with function elm_object_item_text_set(). If no label is passed as an argument, it returns NULL.
Parameters:
[in]objThe segment control object
[in]indexThe index of the segment item
Returns:
The label of the item at index
See also:
elm_object_item_text_set()
elm_segment_control_item_add()

Gets the base object of the item.

Since :
2.3
Remarks:
Base object is the Evas_Object that represents that item.
Parameters:
[in]itThe segment control item
Returns:
The base object associated with it

Gets the selected item.

Since :
2.3
Remarks:
The selected item can be unselected with the function elm_segment_control_item_selected_set().
The selected item is always highlighted on the segment control.
Parameters:
[in]objThe segment control object
Returns:
The selected item, otherwise NULL if none of the segment items are selected

Sets the selected state of an item.

This sets the selected state of the given item it. EINA_TRUE for selected, EINA_FALSE for not selected.

Since :
2.3
Remarks:
If a new item is selected the previously selected item is unselected. Selected item can be obtained with the function elm_segment_control_item_selected_get().
The selected item is always highlighted on the segment control.
Parameters:
[in]itThe segment control item
[in]selectThe selected state
See also:
elm_segment_control_item_selected_get()

Except as noted, this content - excluding the Code Examples - is licensed under Creative Commons Attribution 3.0 and all of the Code Examples contained herein are licensed under BSD-3-Clause.
For details, see the Content License