17f207b0612ccf67cf02eb6d4b33826ea3475427
[framework/uifw/elementary.git] / src / lib / elm_object.h
1 /**
2  * Set a text of an object
3  *
4  * @param obj The Elementary object
5  * @param part The text part name to set (NULL for the default part)
6  * @param text The new text of the part
7  *
8  * @note Elementary objects may have many text parts (e.g. Action Slider)
9  *
10  * @ingroup General
11  */
12 EAPI void                         elm_object_part_text_set(Evas_Object *obj, const char *part, const char *text);
13
14 #define elm_object_text_set(obj, text) elm_object_part_text_set((obj), NULL, (text))
15
16 /**
17  * Get a text of an object
18  *
19  * @param obj The Elementary object
20  * @param part The text part name to get (NULL for the default part)
21  * @return text of the part or NULL for any error
22  *
23  * @note Elementary objects may have many text parts (e.g. Action Slider)
24  *
25  * @ingroup General
26  */
27 EAPI const char                  *elm_object_part_text_get(const Evas_Object *obj, const char *part);
28
29 #define elm_object_text_get(obj) elm_object_part_text_get((obj), NULL)
30
31 /**
32  * Set the content on part of a given container widget
33  *
34  * @param obj The Elementary container widget
35  * @param part The container's part name to set (some might accept
36  *        @c NULL for the default part)
37  * @param content The new content for that part
38  *
39  * All widgets deriving from the @ref elm-container-class may hold
40  * child objects as content at given parts.  This sets new content to
41  * a given part. If any object was already set as a content object in
42  * the same part, the previous object will be deleted automatically
43  * with this call. If you wish to preserve it, issue
44  * elm_object_part_content_unset() on it first.
45  *
46  * @see elm_object_part_content_set()
47  *
48  * @ingroup General
49  */
50 EAPI void                         elm_object_part_content_set(Evas_Object *obj, const char *part, Evas_Object *content);
51
52 #define elm_object_content_set(obj, content) elm_object_part_content_set((obj), NULL, (content))
53
54 /**
55  * Get the content on a part of a given container widget
56  *
57  * @param obj The Elementary container widget
58  * @param part The container's part name to get (some might accept
59  *        @c NULL for the default part)
60  * @return content of the object at the given part or @c NULL, on
61  *         errors
62  *
63  * @see elm_object_part_content_set() for more details
64  *
65  * @ingroup General
66  */
67 EAPI Evas_Object                 *elm_object_part_content_get(const Evas_Object *obj, const char *part);
68
69 #define elm_object_content_get(obj) elm_object_part_content_get((obj), NULL)
70
71 /**
72  * Unset the content on a part of a given container widget
73  *
74  * @param obj The Elementary container widget
75  * @param part The container's part name to unset (some might accept
76  *        @c NULL for the default part)
77  * @return content of the object at the given part or @c NULL, on
78  *         errors
79  *
80  * @see elm_object_part_content_set() for more details
81  *
82  * @ingroup General
83  */
84 EAPI Evas_Object                 *elm_object_part_content_unset(Evas_Object *obj, const char *part);
85
86 #define elm_object_content_unset(obj) elm_object_part_content_unset((obj), NULL)
87
88 /**
89  * Set the text to read out when in accessibility mode
90  *
91  * @param obj The object which is to be described
92  * @param txt The text that describes the widget to people with poor or no vision
93  *
94  * @ingroup General
95  */
96 EAPI void                         elm_object_access_info_set(Evas_Object *obj, const char *txt);
97
98 /**
99  * Get a named object from the children
100  *
101  * @param obj The parent object whose children to look at
102  * @param name The name of the child to find
103  * @param recurse Set to the maximum number of levels to recurse (0 == none, 1 is only look at 1 level of children etc.)
104  * @return The found object of that name, or NULL if none is found
105  *
106  * This function searches the children (or recursively children of
107  * children and so on) of the given @p obj object looking for a child with
108  * the name of @p name. If the child is found the object is returned, or
109  * NULL is returned. You can set the name of an object with
110  * evas_object_name_set(). If the name is not unique within the child
111  * objects (or the tree is @p recurse is greater than 0) then it is
112  * undefined as to which child of that name is returned, so ensure the name
113  * is unique amongst children. If recurse is set to -1 it will recurse
114  * without limit.
115  *
116  * @ingroup General
117  */
118 EAPI Evas_Object                 *elm_object_name_find(const Evas_Object *obj, const char *name, int recurse);
119
120 /**
121  * @defgroup Styles Styles
122  *
123  * Widgets can have different styles of look. These generic API's
124  * set styles of widgets, if they support them (and if the theme(s)
125  * do).
126  *
127  * @ref general_functions_example_page "This" example contemplates
128  * some of these functions.
129  */
130
131 /**
132  * Set the style to used by a given widget
133  *
134  * @param obj The Elementary widget to style
135  * @param style The name of the style to use on it
136  * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise
137  *
138  * This sets the style (by name) that will define the appearance of a
139  * widget. Styles vary from widget to widget and may also be defined
140  * by other themes by means of extensions and overlays.
141  *
142  * @see elm_theme_extension_add()
143  * @see elm_theme_extension_del()
144  * @see elm_theme_overlay_add()
145  * @see elm_theme_overlay_del()
146  *
147  * @ingroup Styles
148  */
149 EAPI Eina_Bool    elm_object_style_set(Evas_Object *obj, const char *style);
150
151 /**
152  * Get the style used by the widget
153  *
154  * This gets the style being used for that widget. Note that the string
155  * pointer is only valid as long as the object is valid and the style doesn't
156  * change.
157  *
158  * @param obj The Elementary widget to query for its style
159  * @return The style name used
160  *
161  * @see elm_object_style_set()
162  *
163  * @ingroup Styles
164  */
165 EAPI const char  *elm_object_style_get(const Evas_Object *obj);
166
167 /**
168  * Set the disabled state of an Elementary object.
169  *
170  * @param obj The Elementary object to operate on
171  * @param disabled The state to put in in: @c EINA_TRUE for
172  *        disabled, @c EINA_FALSE for enabled
173  *
174  * Elementary objects can be @b disabled, in which state they won't
175  * receive input and, in general, will be themed differently from
176  * their normal state, usually greyed out. Useful for contexts
177  * where you don't want your users to interact with some of the
178  * parts of you interface.
179  *
180  * This sets the state for the widget, either disabling it or
181  * enabling it back.
182  *
183  * @ingroup Styles
184  */
185 EAPI void         elm_object_disabled_set(Evas_Object *obj, Eina_Bool disabled);
186
187 /**
188  * Get the disabled state of an Elementary object.
189  *
190  * @param obj The Elementary object to operate on
191  * @return @c EINA_TRUE, if the widget is disabled, @c EINA_FALSE
192  *            if it's enabled (or on errors)
193  *
194  * This gets the state of the widget, which might be enabled or disabled.
195  *
196  * @ingroup Styles
197  */
198 EAPI Eina_Bool    elm_object_disabled_get(const Evas_Object *obj);
199
200 /**
201  * @defgroup WidgetNavigation Widget Tree Navigation
202  *
203  * These functions provide checks for if a Evas_Object is an Elementary widget,
204  * the possibility of getting a widget's parent, top level parent and getting a
205  * string representation of a widget's type.
206  */
207
208 /**
209  * Check if the given Evas Object is an Elementary widget.
210  *
211  * @param obj the object to query.
212  * @return @c EINA_TRUE if it is an elementary widget variant,
213  *         @c EINA_FALSE otherwise
214  * @ingroup WidgetNavigation
215  */
216 EAPI Eina_Bool    elm_object_widget_check(const Evas_Object *obj);
217
218 /**
219  * Get the first parent of the given object that is an Elementary
220  * widget.
221  *
222  * @param obj the Elementary object to query parent from.
223  * @return the parent object that is an Elementary widget, or @c
224  *         NULL, if it was not found.
225  *
226  * Use this to query for an object's parent widget.
227  *
228  * @note Most of Elementary users wouldn't be mixing non-Elementary
229  * smart objects in the objects tree of an application, as this is
230  * an advanced usage of Elementary with Evas. So, except for the
231  * application's window, which is the root of that tree, all other
232  * objects would have valid Elementary widget parents.
233  *
234  * @ingroup WidgetNavigation
235  */
236 EAPI Evas_Object *elm_object_parent_widget_get(const Evas_Object *obj);
237
238 /**
239  * Get the top level parent of an Elementary widget.
240  *
241  * @param obj The object to query.
242  * @return The top level Elementary widget, or @c NULL if parent cannot be
243  * found.
244  * @ingroup WidgetNavigation
245  */
246 EAPI Evas_Object *elm_object_top_widget_get(const Evas_Object *obj);
247
248 /**
249  * Get the string that represents this Elementary widget.
250  *
251  * @note Elementary is weird and exposes itself as a single
252  *       Evas_Object_Smart_Class of type "elm_widget", so
253  *       evas_object_type_get() always return that, making debug and
254  *       language bindings hard. This function tries to mitigate this
255  *       problem, but the solution is to change Elementary to use
256  *       proper inheritance.
257  *
258  * @param obj the object to query.
259  * @return Elementary widget name, or @c NULL if not a valid widget.
260  * @ingroup WidgetNavigation
261  */
262 EAPI const char  *elm_object_widget_type_get(const Evas_Object *obj);
263
264 /**
265  * Send a signal to the widget edje object.
266  *
267  * This function sends a signal to the edje object of the obj. An
268  * edje program can respond to a signal by specifying matching
269  * 'signal' and 'source' fields.
270  *
271  * @param obj The object
272  * @param emission The signal's name.
273  * @param source The signal's source.
274  * @ingroup General
275  */
276 EAPI void         elm_object_signal_emit(Evas_Object *obj, const char *emission, const char *source);
277
278 /**
279  * Add a callback for a signal emitted by widget edje object.
280  *
281  * This function connects a callback function to a signal emitted by the
282  * edje object of the obj.
283  * Globs can occur in either the emission or source name.
284  *
285  * @param obj The object
286  * @param emission The signal's name.
287  * @param source The signal's source.
288  * @param func The callback function to be executed when the signal is
289  * emitted.
290  * @param data A pointer to data to pass in to the callback function.
291  * @ingroup General
292  */
293 EAPI void         elm_object_signal_callback_add(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func, void *data);
294
295 /**
296  * Remove a signal-triggered callback from a widget edje object.
297  *
298  * @param obj The object handle
299  * @param emission The signal's name.
300  * @param source The signal's source.
301  * @param func The callback function to be executed when the signal is
302  * emitted.
303  * @return The data pointer of the signal callback or @c NULL, on
304  * errors.
305  *
306  * This function removes the @b last callback, previously attached to
307  * a signal emitted by an undelying Edje object of @a obj, whose
308  * parameters @a emission, @a source and @c func match exactly with
309  * those passed to a previous call to
310  * elm_object_signal_callback_add(). The data pointer that was passed
311  * to this call will be returned.
312  *
313  * @ingroup General
314  */
315 EAPI void        *elm_object_signal_callback_del(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func);
316
317 /**
318  * Add a callback for input events (key up, key down, mouse wheel)
319  * on a given Elementary widget
320  *
321  * @param obj The widget to add an event callback on
322  * @param func The callback function to be executed when the event
323  * happens
324  * @param data Data to pass in to @p func
325  *
326  * Every widget in an Elementary interface set to receive focus,
327  * with elm_object_focus_allow_set(), will propagate @b all of its
328  * key up, key down and mouse wheel input events up to its parent
329  * object, and so on. All of the focusable ones in this chain which
330  * had an event callback set, with this call, will be able to treat
331  * those events. There are two ways of making the propagation of
332  * these event upwards in the tree of widgets to @b cease:
333  * - Just return @c EINA_TRUE on @p func. @c EINA_FALSE will mean
334  *   the event was @b not processed, so the propagation will go on.
335  * - The @c event_info pointer passed to @p func will contain the
336  *   event's structure and, if you OR its @c event_flags inner
337  *   value to @c EVAS_EVENT_FLAG_ON_HOLD, you're telling Elementary
338  *   one has already handled it, thus killing the event's
339  *   propagation, too.
340  *
341  * @note Your event callback will be issued on those events taking
342  * place only if no other child widget of @p obj has consumed the
343  * event already.
344  *
345  * @note Not to be confused with @c
346  * evas_object_event_callback_add(), which will add event callbacks
347  * per type on general Evas objects (no event propagation
348  * infrastructure taken in account).
349  *
350  * @note Not to be confused with @c
351  * elm_object_signal_callback_add(), which will add callbacks to @b
352  * signals coming from a widget's theme, not input events.
353  *
354  * @note Not to be confused with @c
355  * edje_object_signal_callback_add(), which does the same as
356  * elm_object_signal_callback_add(), but directly on an Edje
357  * object.
358  *
359  * @note Not to be confused with @c
360  * evas_object_smart_callback_add(), which adds callbacks to smart
361  * objects' <b>smart events</b>, and not input events.
362  *
363  * @see elm_object_event_callback_del()
364  *
365  * @ingroup General
366  */
367 EAPI void         elm_object_event_callback_add(Evas_Object *obj, Elm_Event_Cb func, const void *data);
368
369 /**
370  * Remove an event callback from a widget.
371  *
372  * This function removes a callback, previously attached to event emission
373  * by the @p obj.
374  * The parameters func and data must match exactly those passed to
375  * a previous call to elm_object_event_callback_add(). The data pointer that
376  * was passed to this call will be returned.
377  *
378  * @param obj The object
379  * @param func The callback function to be executed when the event is
380  * emitted.
381  * @param data Data to pass in to the callback function.
382  * @return The data pointer
383  * @ingroup General
384  */
385 EAPI void        *elm_object_event_callback_del(Evas_Object *obj, Elm_Event_Cb func, const void *data);
386
387 /**
388  * Disable the orientation mode of a given widget.
389  *
390  * Orientation Mode is used for widgets to change it's styles or to send signals
391  * whenever it's window degree is changed. If the orientation mode is enabled
392  * and the widget has different looks and styles for the window degree(0, 90,
393  * 180, 270), it will apply a style that is readied for the current degree,
394  * otherwise, it will send signals to it's own edje to change it's states if
395  * the style doesn't be readied.
396  *
397  * @param obj The Elementary object to operate on orientation mode.
398  * @param disabled The state to put in in: @c EINA_TRUE for disabled,
399  *        @c EINA_FALSE for enabled.
400  *
401  * @since 1.8
402  *
403  * @ingroup General
404  */
405 EAPI void        elm_object_orientation_mode_disabled_set(Evas_Object *obj, Eina_Bool disabled);
406
407 /**
408  * Get the orientation mode of a given widget.
409  *
410  * @param obj The Elementary widget to query for its orientation mode.
411  * @return @c EINA_TRUE, if the orientation mode is disabled, @c EINA_FALSE
412  *            if the orientation mode is enabled (or on errors)
413  * @see elm_object_orientation_mode_disabled_set()
414  *
415  * @since 1.8
416  *
417  * @ingroup General
418  */
419 EAPI Eina_Bool   elm_object_orientation_mode_disabled_get(const Evas_Object *obj);
420