[access] use given object, if there is no highlight object in _access_highlight_next_...
[framework/uifw/elementary.git] / src / lib / elm_segment_control.h
1 /**
2  * @defgroup SegmentControl SegmentControl
3  * @ingroup Elementary
4  *
5  * @image html segment_control_inheritance_tree.png
6  * @image latex segment_control_inheritance_tree.eps
7  *
8  * @image html img/widget/segment_control/preview-00.png
9  * @image latex img/widget/segment_control/preview-00.eps width=\textwidth
10  *
11  * @image html img/segment_control.png
12  * @image latex img/segment_control.eps width=\textwidth
13  *
14  * Segment control widget is a horizontal control made of multiple segment
15  * items, each segment item functioning similar to discrete two state button.
16  * A segment control groups the items together and provides compact
17  * single button with multiple equal size segments.
18  *
19  * Segment item size is determined by base widget
20  * size and the number of items added.
21  * Only one segment item can be at selected state. A segment item can display
22  * combination of Text and any Evas_Object like Images or other widget.
23  *
24  * This widget inherits from the @ref Layout one, so that all the
25  * functions acting on it also work for segment control objects.
26  *
27  * This widget emits the following signals, besides the ones sent from
28  * @ref Layout:
29  * - @c "changed" - When the user clicks on a segment item which is not
30  *   previously selected and get selected. The event_info parameter is the
31  *   segment item pointer.
32  *
33  * Available styles for it:
34  * - @c "default"
35  *
36  * Default content parts of the segment control items that you can use for are:
37  * @li "icon" - An icon in a segment control item
38  *
39  * Default text parts of the segment control items that you can use for are:
40  * @li "default" - Title label in a segment control item
41  *
42  * Supported elm_object common APIs.
43  * @li elm_object_disabled_set
44  * @li elm_object_disabled_get
45  *
46  * Supported elm_object_item common APIs.
47  * @li @ref elm_object_item_part_text_set
48  * @li @ref elm_object_item_part_text_get
49  * @li @ref elm_object_item_part_content_set
50  * @li @ref elm_object_item_part_content_get
51  *
52  * Here is an example on its usage:
53  * @li @ref segment_control_example
54  *
55  */
56
57 /**
58  * @addtogroup SegmentControl
59  * @{
60  */
61
62 /**
63  * Add a new segment control widget to the given parent Elementary
64  * (container) object.
65  *
66  * @param parent The parent object.
67  * @return a new segment control widget handle or @c NULL, on errors.
68  *
69  * This function inserts a new segment control widget on the canvas.
70  *
71  * @ingroup SegmentControl
72  */
73 EAPI Evas_Object      *elm_segment_control_add(Evas_Object *parent);
74
75 /**
76  * Append a new item to the segment control object.
77  *
78  * @param obj The segment control object.
79  * @param icon The icon object to use for the left side of the item. An
80  * icon can be any Evas object, but usually it is an icon created
81  * with elm_icon_add().
82  * @param label The label of the item.
83  *        Note that, NULL is different from empty string "".
84  * @return The created item or @c NULL upon failure.
85  *
86  * A new item will be created and appended to the segment control, i.e., will
87  * be set as @b last item.
88  *
89  * If it should be inserted at another position,
90  * elm_segment_control_item_insert_at() should be used instead.
91  *
92  * Items created with this function can be deleted with function
93  * elm_object_item_del() or elm_object_item_del_at().
94  *
95  * @note @p label set to @c NULL is different from empty string "".
96  * If an item
97  * only has icon, it will be displayed bigger and centered. If it has
98  * icon and label, even that an empty string, icon will be smaller and
99  * positioned at left.
100  *
101  * Simple example:
102  * @code
103  * sc = elm_segment_control_add(win);
104  * ic = elm_icon_add(win);
105  * elm_image_file_set(ic, "path/to/image", NULL);
106  * elm_icon_resizable_set(ic, EINA_TRUE, EINA_TRUE);
107  * elm_segment_control_item_add(sc, ic, "label");
108  * evas_object_show(sc);
109  * @endcode
110  *
111  * @see elm_segment_control_item_insert_at()
112  * @see elm_object_item_del()
113  *
114  * @ingroup SegmentControl
115  */
116 EAPI Elm_Object_Item *elm_segment_control_item_add(Evas_Object *obj, Evas_Object *icon, const char *label);
117
118 /**
119  * Insert a new item to the segment control object at specified position.
120  *
121  * @param obj The segment control object.
122  * @param icon The icon object to use for the left side of the item. An
123  * icon can be any Evas object, but usually it is an icon created
124  * with elm_icon_add().
125  * @param label The label of the item.
126  * @param index Item position. Value should be between 0 and items count.
127  * @return The created item or @c NULL upon failure.
128
129  * Index values must be between @c 0, when item will be prepended to
130  * segment control, and items count, that can be get with
131  * elm_segment_control_item_count_get(), case when item will be appended
132  * to segment control, just like elm_segment_control_item_add().
133  *
134  * Items created with this function can be deleted with function
135  * elm_object_item_del() or elm_segment_control_item_del_at().
136  *
137  * @note @p label set to @c NULL is different from empty string "".
138  * If an item
139  * only has icon, it will be displayed bigger and centered. If it has
140  * icon and label, even that an empty string, icon will be smaller and
141  * positioned at left.
142  *
143  * @see elm_segment_control_item_add()
144  * @see elm_segment_control_item_count_get()
145  * @see elm_object_item_del()
146  *
147  * @ingroup SegmentControl
148  */
149 EAPI Elm_Object_Item *elm_segment_control_item_insert_at(Evas_Object *obj, Evas_Object *icon, const char *label, int index);
150
151 /**
152  * Remove a segment control item at given index from its parent,
153  * deleting it.
154  *
155  * @param obj The segment control object.
156  * @param index The position of the segment control item to be deleted.
157  *
158  * Items can be added with elm_segment_control_item_add() or
159  * elm_segment_control_item_insert_at().
160  *
161  * @ingroup SegmentControl
162  */
163 EAPI void              elm_segment_control_item_del_at(Evas_Object *obj, int index);
164
165 /**
166  * Get the Segment items count from segment control.
167  *
168  * @param obj The segment control object.
169  * @return Segment items count.
170  *
171  * It will just return the number of items added to segment control @p obj.
172  *
173  * @ingroup SegmentControl
174  */
175 EAPI int               elm_segment_control_item_count_get(const Evas_Object *obj);
176
177 /**
178  * Get the item placed at specified index.
179  *
180  * @param obj The segment control object.
181  * @param index The index of the segment item.
182  * @return The segment control item or @c NULL on failure.
183  *
184  * Index is the position of an item in segment control widget. Its
185  * range is from @c 0 to <tt> count - 1 </tt>.
186  * Count is the number of items, that can be get with
187  * elm_segment_control_item_count_get().
188  *
189  * @ingroup SegmentControl
190  */
191 EAPI Elm_Object_Item *elm_segment_control_item_get(const Evas_Object *obj, int index);
192
193 /**
194  * Get the label of item.
195  *
196  * @param obj The segment control object.
197  * @param index The index of the segment item.
198  * @return The label of the item at @p index.
199  *
200  * The return value is a pointer to the label associated to the item when
201  * it was created, with function elm_segment_control_item_add(), or later
202  * with function elm_object_item_text_set. If no label
203  * was passed as argument, it will return @c NULL.
204  *
205  * @see elm_object_item_text_set() for more details.
206  * @see elm_segment_control_item_add()
207  *
208  * @ingroup SegmentControl
209  */
210 EAPI const char       *elm_segment_control_item_label_get(const Evas_Object *obj, int index);
211
212 /**
213  * Get the icon associated to the item.
214  *
215  * @param obj The segment control object.
216  * @param index The index of the segment item.
217  * @return The left side icon associated to the item at @p index.
218  *
219  * The return value is a pointer to the icon associated to the item when
220  * it was created, with function elm_segment_control_item_add(), or later
221  * with function elm_object_item_part_content_set(). If no icon
222  * was passed as argument, it will return @c NULL.
223  *
224  * @see elm_segment_control_item_add()
225  * @see elm_object_item_part_content_set()
226  *
227  * @ingroup SegmentControl
228  */
229 EAPI Evas_Object      *elm_segment_control_item_icon_get(const Evas_Object *obj, int index);
230
231 /**
232  * Get the index of an item.
233  *
234  * @param it The segment control item.
235  * @return The position of item in segment control widget.
236  *
237  * Index is the position of an item in segment control widget. Its
238  * range is from @c 0 to <tt> count - 1 </tt>.
239  * Count is the number of items, that can be get with
240  * elm_segment_control_item_count_get().
241  *
242  * @ingroup SegmentControl
243  */
244 EAPI int               elm_segment_control_item_index_get(const Elm_Object_Item *it);
245
246 /**
247  * Get the base object of the item.
248  *
249  * @param it The segment control item.
250  * @return The base object associated with @p it.
251  *
252  * Base object is the @c Evas_Object that represents that item.
253  *
254  * @ingroup SegmentControl
255  */
256 EAPI Evas_Object      *elm_segment_control_item_object_get(const Elm_Object_Item *it);
257
258 /**
259  * Get the selected item.
260  *
261  * @param obj The segment control object.
262  * @return The selected item or @c NULL if none of segment items is
263  * selected.
264  *
265  * The selected item can be unselected with function
266  * elm_segment_control_item_selected_set().
267  *
268  * The selected item always will be highlighted on segment control.
269  *
270  * @ingroup SegmentControl
271  */
272 EAPI Elm_Object_Item *elm_segment_control_item_selected_get(const Evas_Object *obj);
273
274 /**
275  * Set the selected state of an item.
276  *
277  * @param it The segment control item
278  * @param select The selected state
279  *
280  * This sets the selected state of the given item @p it.
281  * @c EINA_TRUE for selected, @c EINA_FALSE for not selected.
282  *
283  * If a new item is selected the previously selected will be unselected.
284  * Selected item can be got with function
285  * elm_segment_control_item_selected_get().
286  *
287  * The selected item always will be highlighted on segment control.
288  *
289  * @see elm_segment_control_item_selected_get()
290  *
291  * @ingroup SegmentControl
292  */
293 EAPI void              elm_segment_control_item_selected_set(Elm_Object_Item *it, Eina_Bool select);
294
295 /**
296  * @}
297  */