Initialize Tizen 2.3
[framework/uifw/elementary.git] / wearable / src / lib / elm_widget_multibuttonentry.h
1 #ifndef ELM_WIDGET_MULTIBUTTONENTRY_H
2 #define ELM_WIDGET_MULTIBUTTONENTRY_H
3
4 #include "elm_widget_layout.h"
5
6 /**
7  * @addtogroup Widget
8  * @{
9  *
10  * @section elm-multibuttonentry-class The Elementary Multi Button Entry Class
11  *
12  * Elementary, besides having the @ref Multibuttonentry widget,
13  * exposes its foundation -- the Elementary Multi Button Entry Class --
14  * in order to create other widgets which are a multi button entry with
15  * some more logic on top.
16  */
17
18 /**
19  * @def ELM_MULTIBUTTONENTRY_CLASS
20  *
21  * Use this macro to cast whichever subclass of
22  * #Elm_Multibuttonentry_Smart_Class into it, so to access its fields.
23  *
24  * @ingroup Widget
25  */
26 #define ELM_MULTIBUTTONENTRY_CLASS(x) ((Elm_Multibuttonentry_Smart_Class *)x)
27
28 /**
29  * @def ELM_MULTIBUTTONENTRY_DATA
30  *
31  * Use this macro to cast whichever subdata of
32  * #Elm_Multibuttonentry_Smart_Data into it, so to access its fields.
33  *
34  * @ingroup Widget
35  */
36 #define ELM_MULTIBUTTONENTRY_DATA(x)  ((Elm_Multibuttonentry_Smart_Data *)x)
37
38 /**
39  * @def ELM_MULTIBUTTONENTRY_SMART_CLASS_VERSION
40  *
41  * Current version for Elementary multibuttonentry @b base smart class, a value
42  * which goes to _Elm_Multibuttonentry_Smart_Class::version.
43  *
44  * @ingroup Widget
45  */
46 #define ELM_MULTIBUTTONENTRY_SMART_CLASS_VERSION 1
47
48 /**
49  * @def ELM_MULTIBUTTONENTRY_SMART_CLASS_INIT
50  *
51  * Initializer for a whole #Elm_Multibuttonentry_Smart_Class structure, with
52  * @c NULL values on its specific fields.
53  *
54  * @param smart_class_init initializer to use for the "base" field
55  * (#Evas_Smart_Class).
56  *
57  * @see EVAS_SMART_CLASS_INIT_NULL
58  * @see EVAS_SMART_CLASS_INIT_NAME_VERSION
59  * @see ELM_MULTIBUTTONENTRY_SMART_CLASS_INIT_NULL
60  * @see ELM_MULTIBUTTONENTRY_SMART_CLASS_INIT_NAME_VERSION
61  *
62  * @ingroup Widget
63  */
64 #define ELM_MULTIBUTTONENTRY_SMART_CLASS_INIT(smart_class_init) \
65   {smart_class_init, ELM_MULTIBUTTONENTRY_SMART_CLASS_VERSION}
66
67 /**
68  * @def ELM_MULTIBUTTONENTRY_SMART_CLASS_INIT_NULL
69  *
70  * Initializer to zero out a whole #Elm_Multibuttonentry_Smart_Class structure.
71  *
72  * @see ELM_MULTIBUTTONENTRY_SMART_CLASS_INIT_NAME_VERSION
73  * @see ELM_MULTIBUTTONENTRY_SMART_CLASS_INIT
74  *
75  * @ingroup Widget
76  */
77 #define ELM_MULTIBUTTONENTRY_SMART_CLASS_INIT_NULL \
78   ELM_MULTIBUTTONENTRY_SMART_CLASS_INIT(EVAS_SMART_CLASS_INIT_NULL)
79
80 /**
81  * @def ELM_MULTIBUTTONENTRY_SMART_CLASS_INIT_NAME_VERSION
82  *
83  * Initializer to zero out a whole #Elm_Multibuttonentry_Smart_Class
84  * structure and set its name and version.
85  *
86  * This is similar to #ELM_MULTIBUTTONENTRY_SMART_CLASS_INIT_NULL, but
87  * it will also set the version field of
88  * #Elm_Multibuttonentry_Smart_Class (base field) to the latest
89  * #ELM_MULTIBUTTONENTRY_SMART_CLASS_VERSION and name it to the
90  * specific value.
91  *
92  * It will keep a reference to the name field as a <c>"const char *"</c>,
93  * i.e., the name must be available while the structure is
94  * used (hint: static or global variable!) and must not be modified.
95  *
96  * @see ELM_MULTIBUTTONENTRY_SMART_CLASS_INIT_NULL
97  * @see ELM_MULTIBUTTONENTRY_SMART_CLASS_INIT
98  *
99  * @ingroup Widget
100  */
101 #define ELM_MULTIBUTTONENTRY_SMART_CLASS_INIT_NAME_VERSION(name) \
102   ELM_MULTIBUTTONENTRY_SMART_CLASS_INIT                          \
103     (ELM_LAYOUT_SMART_CLASS_INIT_NAME_VERSION(name))
104
105 /**
106  * Elementary multibuttonentry base smart class. This inherits
107  * directly from #Elm_Layout_Smart_Class and is meant to build widgets
108  * extending the behavior of a multibuttonentry.
109  *
110  * All of the functions listed on @ref Multibuttonentry namespace will
111  * work for objects deriving from #Elm_Multibuttonentry_Smart_Class.
112  */
113 typedef struct _Elm_Multibuttonentry_Smart_Class
114 {
115    Elm_Layout_Smart_Class base;
116
117    int                    version; /**< Version of this smart class definition */
118 } Elm_Multibuttonentry_Smart_Class;
119
120 /**
121  * Base widget smart data extended with multibuttonentry instance data.
122  */
123 typedef struct _Elm_Multibuttonentry_Item
124 {
125    ELM_WIDGET_ITEM;
126
127    Evas_Smart_Cb func;
128 } Elm_Multibuttonentry_Item;
129
130 typedef struct _Elm_Multibuttonentry_Item_Filter
131 {
132    Elm_Multibuttonentry_Item_Filter_Cb func;
133    const void                               *data;
134 } Elm_Multibuttonentry_Item_Filter;
135
136 typedef struct _Elm_Multibuttonentry_Smart_Data
137 {
138    Elm_Layout_Smart_Data               base;
139
140    Evas_Object                        *box;
141    Evas_Object                        *entry;
142    Evas_Object                        *label;
143    Evas_Object                        *guide;
144    Evas_Object                        *end;
145
146    Evas_Coord                          boxh;
147    Evas_Coord                          boxw;
148
149    Eina_List                          *filters;
150    Eina_List                          *items;
151    Elm_Object_Item                    *selected_item;
152
153    Eina_Bool                           item_be_selected : 1;
154    Eina_Bool                           editable : 1;
155    Eina_Bool                           expanded : 1;
156    Eina_Bool                           expanded_state : 1;
157    Eina_Bool                           long_pressed : 1;
158
159    Elm_Multibuttonentry_Item          *focused;
160
161    Ecore_Timer                         *longpress_timer;
162 } Elm_Multibuttonentry_Smart_Data;
163
164 /**
165  * @}
166  */
167
168 EAPI extern const char ELM_MULTIBUTTONENTRY_SMART_NAME[];
169
170 EAPI const Elm_Multibuttonentry_Smart_Class
171 *elm_multibuttonentry_smart_class_get(void);
172
173 #define ELM_MULTIBUTTONENTRY_DATA_GET(o, sd) \
174   Elm_Multibuttonentry_Smart_Data * sd = evas_object_smart_data_get(o)
175
176 #define ELM_MULTIBUTTONENTRY_DATA_GET_OR_RETURN(o, ptr) \
177   ELM_MULTIBUTTONENTRY_DATA_GET(o, ptr);                \
178   if (!ptr)                                             \
179     {                                                   \
180        CRITICAL("No widget data for object %p (%s)",    \
181                 o, evas_object_type_get(o));            \
182        return;                                          \
183     }
184
185 #define ELM_MULTIBUTTONENTRY_DATA_GET_OR_RETURN_VAL(o, ptr, val) \
186   ELM_MULTIBUTTONENTRY_DATA_GET(o, ptr);                         \
187   if (!ptr)                                                      \
188     {                                                            \
189        CRITICAL("No widget data for object %p (%s)",             \
190                 o, evas_object_type_get(o));                     \
191        return val;                                               \
192     }
193
194 #define ELM_MULTIBUTTONENTRY_CHECK(obj)             \
195   if (!obj || !elm_widget_type_check                \
196         ((obj),                                     \
197         ELM_MULTIBUTTONENTRY_SMART_NAME, __func__)) \
198     return
199
200 #define ELM_MULTIBUTTONENTRY_ITEM_CHECK(it)                 \
201   ELM_WIDGET_ITEM_CHECK_OR_RETURN((Elm_Widget_Item *)it, ); \
202   ELM_MULTIBUTTONENTRY_CHECK(it->base.widget);
203
204 #define ELM_MULTIBUTTONENTRY_ITEM_CHECK_OR_RETURN(it, ...)             \
205   ELM_WIDGET_ITEM_CHECK_OR_RETURN((Elm_Widget_Item *)it, __VA_ARGS__); \
206   ELM_MULTIBUTTONENTRY_CHECK(it->base.widget) __VA_ARGS__;
207
208 #endif