42fe6ccff5746d8e10866cbf4be1046f030995ec
[platform/upstream/elementary.git] / src / mobile_lib / elm_widget_ctxpopup.h
1 #ifndef ELM_WIDGET_CTXPOPUP_H
2 #define ELM_WIDGET_CTXPOPUP_H
3
4 #include "elm_widget_layout.h"
5
6 #define MAX_ITEMS_PER_VIEWPORT 8
7
8 /* DO NOT USE THIS HEADER UNLESS YOU ARE PREPARED FOR BREAKING OF YOUR
9  * CODE. THIS IS ELEMENTARY'S INTERNAL WIDGET API (for now) AND IS NOT
10  * FINAL. CALL elm_widget_api_check(ELM_INTERNAL_API_VERSION) TO CHECK
11  * IT AT RUNTIME.
12  */
13
14 /**
15  * @internal
16  * @addtogroup Widget
17  * @{
18  *
19  * @section elm-ctxpopup-class The Elementary Ctxpopup Class
20  *
21  * Elementary, besides having the @ref Elm_Ctxpopup widget, exposes its
22  * foundation -- the Elementary Ctxpopup Class -- in order to create other
23  * widgets which are a ctxpopup with some more logic on top.
24  */
25
26 typedef struct _Elm_Ctxpopup_Item_Data       Elm_Ctxpopup_Item_Data;
27
28 /**
29  * Base widget smart data extended with ctxpopup instance data.
30  */
31 typedef struct _Elm_Ctxpopup_Data Elm_Ctxpopup_Data;
32 struct _Elm_Ctxpopup_Item_Data
33 {
34    Elm_Widget_Item_Data *base;
35
36    const char   *label;
37    Evas_Object  *icon;
38    Evas_Object  *btn;
39
40    struct
41      {
42         Evas_Smart_Cb org_func_cb;
43         const void    *org_data;
44         Evas_Object   *cobj;
45      } wcb;
46 };
47
48 struct _Elm_Ctxpopup_Data
49 {
50    Evas_Object           *parent;
51    Evas_Object           *box;
52
53    Evas_Object           *layout;
54    Evas_Object           *arrow;
55    Evas_Object           *scr;
56    Evas_Object           *bg;
57    Evas_Object           *content;
58    Eina_List             *items;
59
60    Elm_Ctxpopup_Direction dir;
61    Elm_Ctxpopup_Direction dir_priority[4];
62
63    int                    multi_down;
64
65    Eina_Bool              horizontal : 1;
66    Eina_Bool              visible : 1;
67    Eina_Bool              auto_hide : 1;
68    Eina_Bool              mouse_down : 1;
69 //******************** TIZEN Only
70    Eina_Bool              pressed : 1;
71 //****************************
72 };
73
74 /**
75  * @}
76  */
77
78 #define ELM_CTXPOPUP_DATA_GET(o, sd) \
79   Elm_Ctxpopup_Data * sd = eo_data_scope_get(o, ELM_CTXPOPUP_CLASS)
80
81 #define ELM_CTXPOPUP_DATA_GET_OR_RETURN(o, ptr)      \
82   ELM_CTXPOPUP_DATA_GET(o, ptr);                     \
83   if (EINA_UNLIKELY(!ptr))                           \
84     {                                                \
85        CRI("No widget data for object %p (%s)",      \
86            o, evas_object_type_get(o));              \
87        return;                                       \
88     }
89
90 #define ELM_CTXPOPUP_DATA_GET_OR_RETURN_VAL(o, ptr, val) \
91   ELM_CTXPOPUP_DATA_GET(o, ptr);                         \
92   if (EINA_UNLIKELY(!ptr))                               \
93     {                                                    \
94        CRI("No widget data for object %p (%s)",          \
95            o, evas_object_type_get(o));                  \
96        return val;                                       \
97     }
98
99 #define ELM_CTXPOPUP_CHECK(obj)                              \
100   if (EINA_UNLIKELY(!eo_isa((obj), ELM_CTXPOPUP_CLASS))) \
101     return
102
103 #define ELM_CTXPOPUP_ITEM_CHECK_OR_RETURN(it, ...)                 \
104   ELM_WIDGET_ITEM_CHECK_OR_RETURN(it->base, __VA_ARGS__); \
105   ELM_CTXPOPUP_CHECK(it->base->widget) __VA_ARGS__;
106
107 #define ELM_CTXPOPUP_ITEM_DATA_GET(o, sd) \
108   Elm_Ctxpopup_Item_Data *sd = eo_data_scope_get(o, ELM_CTXPOPUP_ITEM_CLASS)
109
110 #endif