1 #ifndef ELM_WIDGET_H
2 #define ELM_WIDGET_H
3
4 /* DO NOT USE THIS HEADER UNLESS YOU ARE PREPARED FOR BREAKING OF YOUR
5 * CODE. THIS IS ELEMENTARY'S INTERNAL WIDGET API (for now) AND IS NOT
6 * FINAL. CALL elm_widget_api_check(ELM_INTERNAL_API_VERSION) TO CHECK
7 * IT AT RUNTIME.
8 *
9 * How to make your own widget? like this (where wname is your widget
10 * name (space) and wparentname is you widget's parent widget name
11 * (the base widget class if its a 'root' one).
12 *
13 * #include <Elementary.h>
14 * #include "elm_priv.h"
15 *
16 * static const char ELM_WNAME_SMART_NAME[] = "elm_wname";
17 *
18 * #define ELM_WNAME_DATA_GET(o, sd) \
19 * Elm_WName_Smart_Data * sd = evas_object_smart_data_get(o)
20 *
21 * #define ELM_WNAME_CHECK(obj) \
22 * if (!obj || !elm_widget_type_check((obj), ELM_WNAME_SMART_NAME, \
23 * __func__)) \
24 * return
25 *
26 * typedef struct _Elm_WName_Smart_Class
27 * {
28 * Elm_WParentName_Smart_Class base;
29 * } Elm_WName_Smart_Class;
30 *
31 * typedef struct _Elm_WName_Smart_Data Elm_WName_Smart_Data;
32 * struct _Elm_WName_Smart_Data
33 * {
34 * Elm_WParentName_Smart_Data base;
35 * Evas_Object *sub; // or any private data needed for an instance
36 * // add any other instance data here too
37 * };
38 *
39 * static const char SIG_CLICKED[] = "clicked";
40 * static const Evas_Smart_Cb_Description _smart_callbacks[] = {
41 * {SIG_CLICKED, ""},
42 * {NULL, NULL}
43 * };
44 *
45 * EVAS_SMART_SUBCLASS_NEW
46 * (ELM_WNAME_SMART_NAME, _elm_wname, Elm_WName_Smart_Class,
47 * Elm_WParentName_Smart_Class, elm_wparentname_smart_class_get,
48 * _smart_callbacks);
49 *
50 * static Eina_Bool
51 * _elm_wname_smart_on_focus(Evas_Object *obj)
52 * {
53 * ELM_WNAME_DATA_GET(obj, sd);
54 *
55 * // handle focus going in and out - optional, but if you want to,
56 * // define this virtual function to handle it (e.g. to emit a
57 * // signal to an edje object)
58 *
59 * if (efl_ui_focus_object_focus_get(obj))
60 * {
61 * edje_object_signal_emit(sd->sub, "elm,action,focus", "elm");
62 * evas_object_focus_set(sd->sub, EINA_TRUE);
63 * }
64 * else
65 * {
66 * edje_object_signal_emit(sd->sub, "elm,action,unfocus", "elm");
67 * evas_object_focus_set(sd->sub, EINA_FALSE);
68 * }
69 *
70 * return EINA_TRUE;
71 * }
72 *
73 * static Eina_Bool
74 * _elm_wname_smart_theme(Evas_Object *obj)
75 * {
76 * ELM_WNAME_DATA_GET(obj, sd);
77 *
78 * if (!ELM_WIDGET_CLASS(_elm_wname_parent_sc)->theme(obj))
79 * return EINA_FALSE;
80 *
81 * // handle changes in theme/scale etc here. always call the
82 * // parent class's version, as even the base class implements it.
83 *
84 * elm_widget_theme_object_set(obj, sd->sub, "wname", "base",
85 * elm_widget_style_get(obj));
86 *
87 * return EINA_TRUE;
88 * }
89 *
90 * static Eina_Bool
91 * _elm_widget_smart_disable(Evas_Object *obj)
92 * {
93 * ELM_WNAME_DATA_GET(obj, sd);
94 *
95 * // optional, but handle if the widget gets disabled or not
96 * if (elm_widget_disabled_get(obj))
97 * edje_object_signal_emit(sd->sub, "elm,state,disabled", "elm");
98 * else
99 * edje_object_signal_emit(sd->sub, "elm,state,enabled", "elm");
100 *
101 * return EINA_TRUE;
102 * }
103 *
104 * static void
105 * _elm_wname_smart_add(Evas_Object *obj)
106 * {
107 * EVAS_SMART_DATA_ALLOC(obj, Elm_WName_Smart_Data);
108 *
109 * ELM_WIDGET_CLASS(_elm_wname_parent_sc)->base.add(obj);
110 *
111 * priv->sub = edje_object_add(evas_object_evas_get(obj));
112 * // just an example having an Edje object here. if it's really the case
113 * // you have a sub edje object as a resize object, consider inheriting
114 * // from @ref elm-layout-class.
115 * elm_widget_can_focus_set(obj, EINA_TRUE);
116 *
117 * // for this widget we will add 1 sub object that is an edje object
118 * priv->sub = edje_object_add(e);
119 * // set the theme. this follows a scheme for group name like this:
120 * // "elm/WIDGETNAME/ELEMENT/STYLE"
121 * // so here it will be:
122 * // "elm/wname/base/default"
123 * // changing style changes style name from default (all widgets start
124 * // with the default style) and element is for your widget internal
125 * // structure as you see fit
126 * elm_widget_theme_object_set
127 * (obj, priv->sub, "wname", "base", "default");
128 * // listen to a signal from the edje object to produce widget smart
129 * // callback (like click)
130 * edje_object_signal_callback_add
131 * (priv->sub, "elm,action,click", "", _clicked_signal_cb, obj);
132 * // set this sub object as the "resize object". widgets get 1 resize
133 * // object that is resized along with the object wrapper.
134 * elm_widget_resize_object_set(obj, priv->sub);
135 * }
136 *
137 * static void
138 * _elm_wname_smart_del(Evas_Object *obj)
139 * {
140 * ELM_WNAME_DATA_GET(obj, sd);
141 *
142 * // deleting 'virtual' function implementation - on deletion of
143 * // object delete object struct, etc.
144 *
145 * ELM_WIDGET_CLASS(_elm_wname_parent_sc)->base.del(obj);
146 * }
147 *
148 * static void
149 * _elm_wname_smart_set_user(Elm_WName_Smart_Class *sc)
150 * {
151 * ELM_WIDGET_CLASS(sc)->base.add = _elm_wname_smart_add;
152 * ELM_WIDGET_CLASS(sc)->base.del = _elm_wname_smart_del;
153 *
154 * ELM_WIDGET_CLASS(sc)->theme = _elm_wname_smart_theme;
155 * ELM_WIDGET_CLASS(sc)->disable = _elm_wname_smart_disable;
156 * ELM_WIDGET_CLASS(sc)->on_focus = _elm_wname_smart_on_focus;
157 * }
158 *
159 * // actual API to create your widget. add more to manipulate it as
160 * // needed mark your calls with EAPI to make them "external api"
161 * // calls.
162 *
163 * EAPI Evas_Object *
164 * elm_wname_add(Evas_Object *parent)
165 * {
166 * Evas_Object *obj;
167 *
168 * EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
169 *
170 * obj = elm_widget_add(_elm_check_smart_class_new(), parent);
171 * if (!obj) return NULL;
172 *
173 * if (!elm_widget_sub_object_add(parent, obj))
174 * ERR("could not add %p as sub object of %p", obj, parent);
175 *
176 * return obj;
177 * }
178 *
179 * // example - do "whatever" to the widget (here just emit a signal)
180 * EAPI void
181 * elm_wname_whatever(Evas_Object *obj)
182 * {
183 * // check if type is correct - check will return if it fails
184 * ELM_WNAME_CHECK(obj);
185 * // get widget data - type is correct and sane by this point, so this
186 * // should never fail
187 * ELM_WNAME_DATA_GET(obj, sd);
188 * // do whatever you like
189 * edje_object_signal_emit(sd->sub, "elm,state,action,whatever", "elm");
190 * }
191 *
192 * // you can add more - you need to see elementary's code to know how
193 * // to handle all cases. remember this api is not stable and may
194 * change. it's internal
195 */
196
197 #ifndef ELM_INTERNAL_API_ARGESFSDFEFC
198 #warning "You are using an internal elementary API. This API is not stable"
199 #warning "and is subject to change. You use this at your own risk."
200 #warning "Remember to call elm_widget_api_check(ELM_INTERNAL_API_VERSION);"
201 #warning "in your widgets before you call any other elm_widget calls to do"
202 #warning "a correct runtime version check. Also remember - you don't NEED"
203 #warning "to make an Elementary widget is almost ALL cases. You can easily"
204 #warning "make a smart object with Evas's API and do everything you need"
205 #warning "there. You only need a widget if you want to seamlessly be part"
206 #warning "of the focus tree and want to transparently become a container"
207 #warning "for any number of child Elementary widgets"
208 #error "ERROR. Compile aborted."
209 #endif
210 #define ELM_INTERNAL_API_VERSION 7000
211
212 /**
213 * @defgroup Widget Widgets Extension Infrastructure
214 *
215 * This section is intended for people willing to create @b custom
216 * Elementary widgets or to contribute new (useful, unique) widgets
217 * upstream. If neither is your case, this text won't be of any use
218 * for you.
219 *
220 * Elementary widgets are built in a @b hierarchical fashion. The idea
221 * is to factorize as much code as possible between widgets with
222 * behavioral similarities, as long as to facilitate the creation of
223 * @b custom, new widgets, may the user need them.
224 *
225 * It all starts with a base class, which aggregates behaviour
226 * @b every Elementary widget is supposed to have:
227 * #Elm_Widget_Smart_Class. Every Elementary widget will be of that
228 * type, be it directly or by means of @b inheriting from it.
229 *
230 * #Elm_Widget_Smart_Class happens to be an @c Evas_Smart_Class. If
231 * you check out Evas' documentation on it, you'll see it's how one is
232 * supposed to create custom Evas objects, what Elementary widgets
233 * are.
234 *
235 * Once one instantiates an Elementary widget, since it inherits from
236 * #Elm_Widget_Smart_Class, the system will raise a class instance of
237 * that type for you. But that happens only @b once: the first time
238 * you ask for an Elementary widget (of a given type). All subsequent
239 * ones will only point to the very same class instance. Since it's
240 * the class which points to the functions implementing the behavior
241 * of objects of that type, all of the live instances of Elementary
242 * widgets (of that type) will share the same blob of code loaded in
243 * memory to execute their routines.
244 *
245 * Now go and take a look at #Elm_Widget_Smart_Class's fields. Because
246 * it inherits from Evas' base smart class, we got a field of that
247 * type as the first member, so that Evas can handle Elementary
248 * objects internally as if they were 'normal' Evas objects. Evas has
249 * the Evas-only behavior function pointers in there, so it's all it
250 * needs.
251 *
252 * Then, comes a version field, so that whenever we got to update or
253 * change the fields on our base smart class, there'll be a runtime
254 * check of the version expected by Elementary and the one provided by
255 * any code linking with it. A mismatch will show the developer of
256 * that code he/she needs to recompile and link its code to a newer
257 * version of Elementary.
258 *
259 * The next fields are the class functions themselves. We call them
260 * 'virtual' because, as in object-oriented languages, one is supposed
261 * here to override them on inheriting classes. On most of
262 * inheritances you'll probably want to call the parent's version of
263 * the class function too: you must analyse each case to tell.
264 *
265 * Take a look at #Elm_Widget_Smart_Data. That's private data bound to
266 * each Elementary object @b instance. It aggregates data needed for
267 * all widgets, since it's meant for the #Elm_Widget_Smart_Class-typed
268 * ones.
269 *
270 * When inheriting from that base type, instance data for this new
271 * class has to have, as the first member, a field of type
272 * #Elm_Widget_Smart_Data. This has to be respected recursively -- if
273 * a third class is to be created inheriting from the one that is a
274 * direct 'child' of #Elm_Widget_Smart_Class, then the private data on
275 * this third class has to have, as its first field, a variable of the
276 * type of the private data of the second class (its parent), direct
277 * child of #Elm_Widget_Smart_Class.
278 *
279 * It is from the base private data, #Elm_Widget_Smart_Data, that we
280 * reach an object's class functions, by the given object
281 * instance. This is the reason of the first field of that struct: a
282 * pointer set to point to its class when the object is instantiated.
283 *
284 * The following figure illustrates the widget inheritance schema.
285 *
286 * @image html elm-widget-hierarchy.png
287 * @image rtf elm-widget-hierarchy.png
288 * @image latex elm-widget-hierarchy.eps
289 *
290 * @section elm-hierarchy-tree Elementary Widgets Hierarchy Tree
291 *
292 * The following figure illustrates the Elementary widget inheritance
293 * tree.
294 *
295 * @image html elm-widget-tree.png
296 * @image rtf elm-widget-tree.png
297 * @image latex elm-widget-tree.eps
298 */
299
300 #include "elm_object_item.h"
301 #include "efl_ui.eot.h"
302 typedef Eo Efl_Ui_Focus_Manager;
303
304 EAPI extern Eina_Error EFL_UI_THEME_APPLY_ERROR_NONE;
305
306 #define _EFL_UI_FOCUS_MANAGER_EO_CLASS_TYPE
307 #include "efl_ui_focus_object.eo.h"
308 #include "efl_ui_focus_manager.eo.h"
309
310 typedef Eina_Bool (*Elm_Widget_Del_Pre_Cb)(void *data);
311 typedef void (*Elm_Widget_Item_Signal_Cb)(void *data, Elm_Object_Item *item, const char *emission, const char *source);
312
313 typedef void (*Elm_Access_On_Highlight_Cb)(void *data);
314 typedef void (*Elm_Widget_On_Show_Region_Cb)(void *data, Evas_Object *obj, Eina_Rect region);
315
316
317 #include "efl_ui_widget.eo.h"
318 #include "elm_widget_item_container_eo.h"
319
320 /**
321 * @addtogroup Widget
322 * @{
323 */
324
325 /**
326 * Base widget smart data. This is data bound to an Elementary object
327 * @b instance, so its particular to that specific object and not
328 * shared between all objects in its class. It is here, though, that
329 * we got a pointer to the object's class, the first field -- @c
330 * 'api'.
331 */
332 typedef struct _Elm_Widget_Smart_Data
333 {
334 Evas_Object *parent_obj; /**< parent object of a widget in the elementary tree */
335 Eina_Array *children;
336 Evas_Object *resize_obj; /**< an unique object for each widget that shows the look of a widget. Resize object's geometry is same as the widget. This resize object is different from that of window's resize object. */
337 Evas_Object *hover_obj;
338 Evas_Object *bg;
339 Evas_Object *window;
340 Eina_List *tooltips, *cursors;
341
342 /* "show region" coordinates. all widgets got those because this
343 * info may be set and queried recursively through the widget
344 * parenting tree */
345 Eina_Rect show_region;
346
347 /* scrolling hold/freeze hints. all widgets got those because this
348 * info may be set and queried recursively through the widget
349 * parenting tree */
350 int scroll_hold;
351 int scroll_freeze;
352
353 double scale;
354 Elm_Theme *theme;
355 const char *klass; /**< 1st identifier of an edje object group which is used in theme_set. klass and group are used together. */
356 const char *group; /**< 2nd identifier of an edje object group which is used in theme_set. klass and group are used together. */
357 const char *style;
358 const char *access_info;
359 const char *accessible_name;
360
361 int child_drag_x_locked;
362 int child_drag_y_locked;
363 int disabled;
364 int tree_unfocusable;
365
366 Eina_Inlist *translate_strings;
367 Eina_List *event_cb;
368 /* this is a hook to be set on-the-fly on widgets. this is code
369 * handling the request of showing a specific region from an inner
370 * widget (mainly issued by entries, on cursor moving) */
371 void *on_show_region_data;
372 Elm_Widget_On_Show_Region_Cb on_show_region;
373 Eina_Free_Cb on_show_region_data_free;
374
375 Elm_Focus_Move_Policy focus_move_policy;
376 Elm_Focus_Region_Show_Mode focus_region_show_mode;
377
378 Efl_Ui_Widget_Focus_State focus;
379 struct {
380 int child_count;
381 Efl_Ui_Focus_Object *parent;
382 } logical;
383 struct {
384 Efl_Ui_Focus_Manager *manager;
385 Efl_Ui_Focus_Object *provider;
386 } manager;
387 struct {
388 Eina_Bool listen_to_manager;
389 Eina_List *custom_chain;
390 Evas_Object *prev, *next, *up, *down, *right, *left;
391 Elm_Object_Item *item_prev, *item_next, *item_up, *item_down, *item_right, *item_left;
392 } legacy_focus;
393 struct {
394 Efl_Model *model;
395 Efl_Model_Provider *provider;
396 Eina_Hash *model_lookup;
397 Eina_Hash *view_lookup;
398 Eina_Bool registered : 1;
399 Eina_Bool callback_to_provider : 1;
400 } properties;
401 void *shared_win_data;
402 Eina_Bool scroll_x_locked : 1;
403 Eina_Bool scroll_y_locked : 1;
404
405 Eina_Bool can_focus : 1;
406 Eina_Bool focused : 1;
407 Eina_Bool top_win_focused : 1;
408 Eina_Bool focus_move_policy_auto_mode : 1; /* This is TRUE by default */
409 Eina_Bool highlight_ignore : 1;
410 Eina_Bool highlight_in_theme : 1;
411 Eina_Bool access_highlight_in_theme : 1;
412 Eina_Bool is_mirrored : 1;
413 Eina_Bool mirrored_auto_mode : 1; /* This is TRUE by default */
414 Eina_Bool still_in : 1;
415 Eina_Bool highlighted : 1;
416 Eina_Bool highlight_root : 1;
417 Eina_Bool on_translate : 1; /**< This is true when any types of elm translate function is being called. */
418 Eina_Bool on_create : 1; /**< This is true when the widget is on creation(general widget constructor). */
419 Eina_Bool on_destroy: 1; /**< This is true when the widget is on destruction(general widget destructor). */
420 Eina_Bool provider_lookup : 1; /**< This is true when efl_provider_find is currently walking the tree */
421 Eina_Bool has_shadow : 1;
422 Eina_Bool internal : 1;
423 } Elm_Widget_Smart_Data;
424
425 typedef Elm_Widget_Smart_Data Efl_Ui_Widget_Data;
426
427 /**
428 * @}
429 */
430
431 /**< base structure for all widget items that are not Efl_Ui_Widget themselves */
432 typedef struct _Elm_Widget_Item_Data Elm_Widget_Item_Data;
433 typedef struct _Elm_Widget_Item_Signal_Data Elm_Widget_Item_Signal_Data;
434
435 /**< accessibility information to be able to set and get from the access API */
436 typedef struct _Elm_Access_Info Elm_Access_Info;
437
438 /**< accessibility info item */
439 typedef struct _Elm_Access_Item Elm_Access_Item;
440
441 typedef struct _Elm_Action Elm_Action;
442
443 /** Internal type for mouse cursors */
444 typedef struct _Elm_Cursor Elm_Cursor;
445
446 /** Internal type for tooltips */
447 typedef struct _Elm_Tooltip Elm_Tooltip;
448
449 #define ELM_ACCESS_DONE -1 /* sentence done - send done event here */
450 #define ELM_ACCESS_CANCEL -2 /* stop reading immediately */
451
452 struct _Elm_Access_Item
453 {
454 int type;
455 const void *data;
456 Elm_Access_Info_Cb func;
457 };
458
459 struct _Elm_Access_Info
460 {
461 Evas_Object *hoverobj;
462 Eina_List *items;
463 Ecore_Timer *delay_timer;
464 void *on_highlight_data;
465 Elm_Access_On_Highlight_Cb on_highlight;
466
467 void *activate_data;
468 Elm_Access_Activate_Cb activate;
469
470 /* the owner widget item that owns this access info */
471 Elm_Widget_Item_Data *widget_item;
472
473 /* the owner part object that owns this access info */
474 Evas_Object *part_object;
475
476 Evas_Object *next;
477 Evas_Object *prev;
478 };
479
480 struct _Elm_Action
481 {
482 const char *name;
483 Eina_Bool (*func)(Evas_Object *obj, const char *params);
484 };
485
486 void _elm_access_shutdown(void);
487 void _elm_access_mouse_event_enabled_set(Eina_Bool enabled);
488
489 /* if auto_higlight is EINA_TRUE, it does not steal a focus, it just moves a highlight */
490 void _elm_access_auto_highlight_set(Eina_Bool enabled);
491 Eina_Bool _elm_access_auto_highlight_get(void);
492 void _elm_access_widget_item_access_order_set(Elm_Widget_Item_Data *item, Eina_List *objs);
493 const Eina_List *_elm_access_widget_item_access_order_get(const Elm_Widget_Item_Data *item);
494 void _elm_access_widget_item_access_order_unset(Elm_Widget_Item_Data *item);
495
496 // widget focus highlight
497 void _elm_widget_focus_highlight_start(const Evas_Object *obj);
498 void _elm_widget_highlight_in_theme_update(Eo *obj);
499
500 // win focus highlight
501 void _elm_win_focus_highlight_start(Evas_Object *obj);
502 void _elm_win_focus_highlight_in_theme_update(Evas_Object *obj, Eina_Bool in_theme);
503 Evas_Object *_elm_win_focus_highlight_object_get(Evas_Object *obj);
504 void _elm_win_focus_auto_show(Evas_Object *obj);
505 void _elm_win_focus_auto_hide(Evas_Object *obj);
506
507 EAPI void _elm_access_clear(Elm_Access_Info *ac);
508 EAPI void _elm_access_text_set(Elm_Access_Info *ac, int type, const char *text);
509 EAPI void _elm_access_callback_set(Elm_Access_Info *ac, int type, Elm_Access_Info_Cb func, const void *data);
510 EAPI char *_elm_access_text_get(const Elm_Access_Info *ac, int type, const Evas_Object *obj); /* this is ok it actually returns a strduped string - it's meant to! */
511 EAPI void _elm_access_read(Elm_Access_Info *ac, int type, const Evas_Object *obj);
512 EAPI void _elm_access_say(const char *txt);
513 EAPI Elm_Access_Info *_elm_access_info_get(const Evas_Object *obj);
514 EAPI void _elm_access_object_highlight(Evas_Object *obj);
515 EAPI void _elm_access_object_unhighlight(Evas_Object *obj);
516 EAPI void _elm_access_object_highlight_disable(Evas *e);
517 EAPI void _elm_access_object_register(Evas_Object *obj, Evas_Object *hoverobj);
518 EAPI void _elm_access_object_unregister(Evas_Object *obj, Evas_Object *hoverobj);
519 EAPI Eina_Bool _elm_access_2nd_click_timeout(Evas_Object *obj);
520 EAPI void _elm_access_highlight_set(Evas_Object* obj);
521 EAPI Evas_Object * _elm_access_edje_object_part_object_register(Evas_Object *obj, const Evas_Object *partobj, const char* part);
522 EAPI void _elm_access_edje_object_part_object_unregister(Evas_Object* obj, const Evas_Object *eobj, const char* part);
523 EAPI void _elm_access_widget_item_register(Elm_Widget_Item_Data *item);
524 EAPI void _elm_access_widget_item_unregister(Elm_Widget_Item_Data *item);
525 EAPI void _elm_access_on_highlight_hook_set(Elm_Access_Info *ac, Elm_Access_On_Highlight_Cb func, void *data);
526 EAPI void _elm_access_activate_callback_set(Elm_Access_Info *ac, Elm_Access_Activate_Cb func, void *data);
527 EAPI void _elm_access_highlight_object_activate(Evas_Object *obj, Efl_Ui_Activate act);
528 EAPI void _elm_access_highlight_cycle(Evas_Object *obj, Elm_Focus_Direction dir);
529
530 EINA_DEPRECATED EAPI Elm_Access_Info *_elm_access_object_get(const Evas_Object *obj);
531
532 #define ELM_PREFS_DATA_MAGIC 0xe1f5da7a
533
534 /**< put this as the first member in your widget item struct */
535 #define ELM_WIDGET_ITEM Elm_Widget_Item_Data base
536
537 struct _Elm_Widget_Item_Signal_Data
538 {
539 Elm_Object_Item *item;
540 Elm_Widget_Item_Signal_Cb func;
541 const char *emission;
542 const char *source;
543 void *data;
544 };
545
546 #define WIDGET_ITEM_DATA_GET(eo_obj) \
547 efl_key_data_get((Eo *) eo_obj, "__elm_widget_item_data")
548
549 #define WIDGET_ITEM_DATA_SET(eo_obj, data) \
550 efl_key_data_set((Eo *) eo_obj, "__elm_widget_item_data", data)
551
552 struct _Elm_Widget_Item_Data
553 {
554 /* ef1 ~~ efl, el3 ~~ elm */
555 #define ELM_WIDGET_ITEM_MAGIC 0xef1e1301
556 EINA_MAGIC;
557 /* simple accessor macros */
558 #define VIEW(X) X->base->view
559 #define VIEW_SET(X, V) efl_wref_add(V, &X->base->view)
560 #define WIDGET(X) X->base->widget
561 #define EO_OBJ(X) ((X)?X->base->eo_obj:NULL)
562 /**< the owner widget that owns this item */
563 Evas_Object *widget;
564 /**< The Eo item, useful to invoke eo_do when only the item data is available */
565 Eo *eo_obj;
566 /**< the base view object */
567 Evas_Object *view;
568 /**< user delete callback function */
569 Evas_Smart_Cb del_func;
570 /**< widget delete callback function. don't expose this callback call */
571 Elm_Widget_Del_Pre_Cb del_pre_func;
572
573 Evas_Object *focus_previous, *focus_next;
574 Evas_Object *focus_up, *focus_down, *focus_right, *focus_left;
575 Elm_Object_Item *item_focus_previous, *item_focus_next;
576 Elm_Object_Item *item_focus_up, *item_focus_down, *item_focus_right, *item_focus_left;
577 Eina_Stringshare *style;
578
579 Evas_Object *access_obj;
580 const char *access_info;
581 const char *accessible_name;
582 Eina_List *access_order;
583 Eina_Inlist *translate_strings;
584 Eina_List *signals;
585 Eina_Hash *labels;
586 Evas_Object *track_obj;
587
588 struct {
589 void (*realized) (Eo *obj);
590 void (*unrealized) (Eo *obj);
591 } func;
592
593 Eina_Bool disabled : 1;
594 Eina_Bool on_deletion : 1;
595 Eina_Bool on_translate : 1;
596 Eina_Bool still_in : 1;
597 };
598
599 #define ELM_NEW(t) calloc(1, sizeof(t))
600
601 EAPI Eina_Bool elm_widget_api_check(int ver);
602 EAPI Eina_Bool elm_widget_access(Evas_Object *obj, Eina_Bool is_access);
603 EAPI Eina_Error elm_widget_theme(Evas_Object *obj);
604 EAPI void elm_widget_theme_specific(Evas_Object *obj, Elm_Theme *th, Eina_Bool force);
605 EAPI void elm_widget_on_show_region_hook_set(Evas_Object *obj, void *data, Elm_Widget_On_Show_Region_Cb func, Eina_Free_Cb data_free);
606 EAPI Eina_Bool elm_widget_sub_object_parent_add(Evas_Object *sobj);
607 EAPI Eina_Bool elm_widget_sub_object_add(Evas_Object *obj, Evas_Object *sobj);
608 EAPI Eina_Bool elm_widget_sub_object_del(Evas_Object *obj, Evas_Object *sobj);
609 EAPI void elm_widget_resize_object_set(Evas_Object *obj, Evas_Object *sobj);
610 EAPI void elm_widget_hover_object_set(Evas_Object *obj, Evas_Object *sobj);
611 EAPI void elm_widget_signal_emit(Evas_Object *obj, const char *emission, const char *source);
612 EAPI void elm_widget_signal_callback_add(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func, void *data);
613 EAPI void *elm_widget_signal_callback_del(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func);
614 EAPI void elm_widget_can_focus_set(Evas_Object *obj, Eina_Bool can_focus);
615 EAPI Eina_Bool elm_widget_can_focus_get(const Evas_Object *obj);
616 EAPI Eina_Bool elm_widget_child_can_focus_get(const Evas_Object *obj);
617 EAPI Eina_List *elm_widget_can_focus_child_list_get(const Evas_Object *obj);
618 EAPI void elm_widget_tree_unfocusable_set(Evas_Object *obj, Eina_Bool tree_unfocusable);
619 EAPI Eina_Bool elm_widget_tree_unfocusable_get(const Evas_Object *obj);
620 EAPI void elm_widget_highlight_ignore_set(Evas_Object *obj, Eina_Bool ignore);
621 EAPI Eina_Bool elm_widget_highlight_ignore_get(const Evas_Object *obj);
622 EAPI void elm_widget_highlight_in_theme_set(Evas_Object *obj, Eina_Bool highlight);
623 EAPI Eina_Bool elm_widget_highlight_in_theme_get(const Evas_Object *obj);
624 EAPI void elm_widget_access_highlight_in_theme_set(Evas_Object *obj, Eina_Bool highlight);
625 EAPI Eina_Bool elm_widget_access_highlight_in_theme_get(const Evas_Object *obj);
626 EAPI Eina_Bool elm_widget_highlight_get(const Evas_Object *obj);
627 EAPI Eo *elm_widget_top_get(const Eo *obj);
628 EAPI Eina_Bool elm_widget_is(const Evas_Object *obj);
629 EAPI Evas_Object *elm_widget_parent_widget_get(const Evas_Object *obj);
630 EAPI void elm_widget_event_callback_add(Evas_Object *obj, Elm_Event_Cb func, const void *data);
631 EAPI void *elm_widget_event_callback_del(Evas_Object *obj, Elm_Event_Cb func, const void *data);
632 EAPI Eina_Bool elm_widget_focus_highlight_style_set(Evas_Object *obj, const char *style);
633 EAPI const char *elm_widget_focus_highlight_style_get(const Evas_Object *obj);
634 EAPI void elm_widget_parent_highlight_set(Evas_Object *obj, Eina_Bool highlighted);
635 EAPI void elm_widget_focus_set(Evas_Object *obj, Eina_Bool focus);
636 EAPI Evas_Object *elm_widget_parent_get(const Evas_Object *obj);
637 EAPI void elm_widget_display_mode_set(Evas_Object *obj, Evas_Display_Mode dispmode);
638 EAPI Eina_Bool elm_widget_focus_highlight_enabled_get(const Evas_Object *obj);
639 EAPI void elm_widget_focus_highlight_focus_part_geometry_get(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h);
640 Evas_Object *_elm_widget_focus_highlight_object_get(const Evas_Object *obj);
641
642 /**
643 * @internal
644 *
645 * Restore the focus state of the sub-tree.
646 *
647 * This API will restore the focus state of the sub-tree to the latest
648 * state. If a sub-tree is unfocused and wants to get back to the latest
649 * focus state, this API will be helpful.
650 *
651 * @param obj The widget root of sub-tree
652 *
653 * @ingroup Widget
654 */
655
656 EAPI void elm_widget_disabled_set(Evas_Object *obj, Eina_Bool disabled);
657 EAPI Eina_Bool elm_widget_disabled_get(const Evas_Object *obj);
658 EAPI void elm_widget_show_region_set(Evas_Object *obj, Eina_Rect sr, Eina_Bool forceshow);
659 EAPI Eina_Rect elm_widget_show_region_get(const Evas_Object *obj);
660 EAPI Eina_Rect elm_widget_focus_region_get(const Evas_Object *obj);
661 EAPI void elm_widget_focus_region_show(Evas_Object *obj);
662 EAPI void elm_widget_scroll_hold_push(Evas_Object *obj);
663 EAPI void elm_widget_scroll_hold_pop(Evas_Object *obj);
664 EAPI int elm_widget_scroll_hold_get(const Evas_Object *obj);
665 EAPI void elm_widget_scroll_freeze_push(Evas_Object *obj);
666 EAPI void elm_widget_scroll_freeze_pop(Evas_Object *obj);
667 EAPI int elm_widget_scroll_freeze_get(const Evas_Object *obj);
668 EAPI void elm_widget_theme_set(Evas_Object *obj, Elm_Theme *th);
669 EAPI Elm_Theme *elm_widget_theme_get(const Evas_Object *obj);
670 EAPI Eina_Error elm_widget_style_set(Evas_Object *obj, const char *style);
671 EAPI const char *elm_widget_style_get(const Evas_Object *obj);
672 EAPI void elm_widget_type_set(Evas_Object *obj, const char *type);
673 EAPI const char *elm_widget_type_get(const Evas_Object *obj);
674 EAPI void elm_widget_tooltip_add(Evas_Object *obj, Elm_Tooltip *tt);
675 EAPI void elm_widget_tooltip_del(Evas_Object *obj, Elm_Tooltip *tt);
676 EAPI void elm_widget_cursor_add(Evas_Object *obj, Elm_Cursor *cur);
677 EAPI void elm_widget_cursor_del(Evas_Object *obj, Elm_Cursor *cur);
678 EAPI void elm_widget_scroll_lock_set(Evas_Object *obj, Efl_Ui_Layout_Orientation block);
679 EAPI Efl_Ui_Layout_Orientation elm_widget_scroll_lock_get(const Evas_Object *obj);
680 EAPI int elm_widget_scroll_child_locked_x_get(const Evas_Object *obj);
681 EAPI int elm_widget_scroll_child_locked_y_get(const Evas_Object *obj);
682 EAPI Eina_Error elm_widget_theme_object_set(Evas_Object *obj, Evas_Object *edj, const char *wname, const char *welement, const char *wstyle);
683 EAPI Eina_Bool elm_widget_type_check(const Evas_Object *obj, const char *type, const char *func);
684 EAPI Evas_Object *elm_widget_name_find(const Evas_Object *obj, const char *name, int recurse);
685 EAPI Eina_List *elm_widget_stringlist_get(const char *str);
686 EAPI void elm_widget_stringlist_free(Eina_List *list);
687 EAPI void elm_widget_focus_mouse_up_handle(Evas_Object *obj);
688 EAPI void elm_widget_activate(Evas_Object *obj, Efl_Ui_Activate act);
689 EAPI void elm_widget_part_text_set(Evas_Object *obj, const char *part, const char *label);
690 EAPI const char *elm_widget_part_text_get(const Evas_Object *obj, const char *part);
691 EAPI const char *elm_widget_translatable_part_text_get(const Evas_Object *obj, const char *part);
692 EAPI void elm_widget_domain_part_text_translatable_set(Evas_Object *obj, const char *part, const char *domain, Eina_Bool translatable);
693 EAPI void elm_widget_content_part_set(Evas_Object *obj, const char *part, Evas_Object *content);
694 EAPI Evas_Object *elm_widget_content_part_get(const Evas_Object *obj, const char *part);
695 EAPI Evas_Object *elm_widget_content_part_unset(Evas_Object *obj, const char *part);
696 EAPI void elm_widget_access_info_set(Evas_Object *obj, const char *txt);
697 EAPI const char *elm_widget_access_info_get(const Evas_Object *obj);
698 EAPI Eina_Rect elm_widget_focus_highlight_geometry_get(const Evas_Object *obj);
699 void _elm_widget_item_highlight_in_theme(Evas_Object *obj, Elm_Object_Item *it);
700 EAPI void elm_widget_focus_region_show_mode_set(Evas_Object *obj, Elm_Focus_Region_Show_Mode mode);
701 EAPI Elm_Focus_Region_Show_Mode elm_widget_focus_region_show_mode_get(const Evas_Object *obj);
702 const char *elm_widget_part_translatable_text_get(const Eo *obj, const char *part, const char **domain);
703 void elm_widget_part_translatable_text_set(Eo *obj, const char *part, const char *label, const char *domain);
704
705 EAPI Eina_Bool elm_widget_theme_klass_set(Evas_Object *obj, const char *name);
706 EAPI const char *elm_widget_theme_klass_get(const Evas_Object *obj);
707 EAPI Eina_Bool elm_widget_theme_element_set(Evas_Object *obj, const char *name);
708 EAPI const char *elm_widget_theme_element_get(const Evas_Object *obj);
709 EAPI Eina_Bool elm_widget_theme_style_set(Evas_Object *obj, const char *name);
710 EAPI const char *elm_widget_theme_style_get(const Evas_Object *obj);
711 EAPI Eina_Error elm_widget_element_update(Evas_Object *obj, Evas_Object *component, const char *name);
712
713 /* debug function. don't use it unless you are tracking parenting issues */
714 EAPI void elm_widget_tree_dump(const Evas_Object *top);
715 EAPI void elm_widget_tree_dot_dump(const Evas_Object *top, FILE *output);
716 EAPI Eina_Bool _elm_widget_onscreen_is(const Evas_Object *widget);
717 EAPI Eina_Bool _elm_widget_item_onscreen_is(const Elm_Object_Item *item);
718 const char* _elm_widget_accessible_plain_name_get(const Evas_Object *obj, const char* name);
719 const char* _elm_widget_item_accessible_plain_name_get(const Elm_Object_Item *item, const char* name);
720
721 Efl_Canvas_Object * _efl_ui_widget_bg_get(const Efl_Ui_Widget *obj);
722
723 #define ELM_WIDGET_DATA_GET_OR_RETURN(o, ptr, ...) \
724 Elm_Widget_Smart_Data *ptr; \
725 ptr = efl_data_scope_safe_get(o, EFL_UI_WIDGET_CLASS); \
726 if (EINA_UNLIKELY(!ptr)) \
727 { \
728 ERR("No widget data for object %p (%s)", \
729 o, evas_object_type_get(o)); \
730 return __VA_ARGS__; \
731 }
732
733 #define ELM_WIDGET_DATA_GET(o, ptr) \
734 Elm_Widget_Smart_Data *ptr; \
735 ptr = efl_data_scope_safe_get(o, EFL_UI_WIDGET_CLASS); \
736 if (EINA_UNLIKELY(!ptr)) \
737 ERR("No widget data for object %p (%s)", \
738 o, evas_object_type_get(o));
739
740 #define ELM_WIDGET_CHECK(obj) \
741 if (EINA_UNLIKELY(!efl_isa((obj), EFL_UI_WIDGET_CLASS))) \
742 return
743
744 #define ELM_WIDGET_ITEM_RETURN_IF_ONDEL(item, ...) \
745 do { \
746 if (item && (item)->on_deletion) { \
747 WRN("Elm_Widget_Item " # item " is deleting"); \
748 return __VA_ARGS__; \
749 } \
750 } while (0)
751
752 #define ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, ...) \
753 do { \
754 if (!item) { \
755 CRI("Elm_Widget_Item " # item " is NULL"); \
756 return __VA_ARGS__; \
757 } \
758 if ((item)->eo_obj && \
759 efl_isa((item)->eo_obj, ELM_WIDGET_ITEM_CLASS)) break; \
760 if (!EINA_MAGIC_CHECK(item, ELM_WIDGET_ITEM_MAGIC)) { \
761 EINA_MAGIC_FAIL(item, ELM_WIDGET_ITEM_MAGIC); \
762 return __VA_ARGS__; \
763 } \
764 } while (0)
765
766 #define ELM_WIDGET_ITEM_CHECK_OR_GOTO(item, label) \
767 do { \
768 if (!item) { \
769 CRI("Elm_Widget_Item " # item " is NULL"); \
770 goto label; \
771 } \
772 if ((item)->eo_obj && \
773 efl_isa((item)->eo_obj, ELM_WIDGET_ITEM_CLASS)) break; \
774 if (!EINA_MAGIC_CHECK(item, ELM_WIDGET_ITEM_MAGIC)) { \
775 EINA_MAGIC_FAIL(item, ELM_WIDGET_ITEM_MAGIC); \
776 goto label; \
777 } \
778 } while (0)
779
780 static inline Eina_Bool
_elm_widget_sub_object_redirect_to_top(Evas_Object * obj,Evas_Object * sobj)781 _elm_widget_sub_object_redirect_to_top(Evas_Object *obj, Evas_Object *sobj)
782 {
783 Eina_Bool ret = elm_widget_sub_object_del(obj, sobj);
784 if (!ret) return ret;
785 if (elm_widget_is(sobj))
786 ret = elm_widget_sub_object_add(elm_widget_top_get(obj), sobj);
787
788 return ret;
789 }
790
791 #define elm_legacy_add(k, p, ...) ({ \
792 efl_add(k, p ? p : efl_main_loop_get(), efl_canvas_object_legacy_ctor(efl_added), ##__VA_ARGS__); })
793
794 static inline Eo *
elm_widget_resize_object_get(const Eo * obj)795 elm_widget_resize_object_get(const Eo *obj)
796 {
797 Elm_Widget_Smart_Data *wd = efl_data_scope_safe_get(obj, EFL_UI_WIDGET_CLASS);
798 return wd ? wd->resize_obj : NULL;
799 }
800
801 static inline Eina_Bool
elm_widget_is_legacy(const Eo * obj)802 elm_widget_is_legacy(const Eo *obj)
803 {
804 return efl_isa(obj, EFL_UI_LEGACY_INTERFACE);
805 }
806
807 /** Takes in any canvas object and returns the first smart parent that is a widget */
808 static inline Efl_Ui_Widget *
evas_object_widget_parent_find(Evas_Object * o)809 evas_object_widget_parent_find(Evas_Object *o)
810 {
811 while (o && !efl_isa(o, EFL_UI_WIDGET_CLASS))
812 evas_object_smart_parent_get(o);
813 return o;
814 }
815
816 /* to be used by INTERNAL classes on Elementary, so that the widgets
817 * parsing script skips it */
818 #define ELM_INTERNAL_SMART_SUBCLASS_NEW EVAS_SMART_SUBCLASS_NEW
819
820 EAPI Eina_Bool elm_selection_selection_has_owner(Evas_Object *obj);
821
822 EAPI Eina_Bool _elm_layout_part_aliasing_eval(const Evas_Object *obj,
823 const char **part,
824 Eina_Bool is_text);
825
826 /* Internal EO APIs */
827 const char *efl_ui_widget_default_content_part_get(const Eo *obj);
828 const char *efl_ui_widget_default_text_part_get(const Eo *obj);
829
830
831 #define ELM_WIDGET_ITEM_PROTECTED
832 #include "elm_widget_item_eo.h"
833
834 #endif
835