elementary/map - map supports language,changed
[framework/uifw/elementary.git] / src / lib / elm_widget_toolbar.h
1 #ifndef ELM_WIDGET_TOOLBAR_H
2 #define ELM_WIDGET_TOOLBAR_H
3
4 #include "elm_interface_scrollable.h"
5 #include "els_box.h"
6
7 /**
8  * @addtogroup Widget
9  * @{
10  *
11  * @section elm-toolbar-class The Elementary Toolbar Class
12  *
13  * Elementary, besides having the @ref Toolbar widget, exposes its
14  * foundation -- the Elementary Toolbar Class -- in order to create other
15  * widgets which are a toolbar with some more logic on top.
16  */
17
18 /**
19  * @def ELM_TOOLBAR_CLASS
20  *
21  * Use this macro to cast whichever subclass of
22  * #Elm_Toolbar_Smart_Class into it, so to access its fields.
23  *
24  * @ingroup Widget
25  */
26 #define ELM_TOOLBAR_CLASS(x) ((Elm_Toolbar_Smart_Class *)x)
27
28 /**
29  * @def ELM_TOOLBAR_DATA
30  *
31  * Use this macro to cast whichever subdata of
32  * #Elm_Toolbar_Smart_Data into it, so to access its fields.
33  *
34  * @ingroup Widget
35  */
36 #define ELM_TOOLBAR_DATA(x)  ((Elm_Toolbar_Smart_Data *)x)
37
38 /**
39  * @def ELM_TOOLBAR_SMART_CLASS_VERSION
40  *
41  * Current version for Elementary toolbar @b base smart class, a value
42  * which goes to _Elm_Toolbar_Smart_Class::version.
43  *
44  * @ingroup Widget
45  */
46 #define ELM_TOOLBAR_SMART_CLASS_VERSION 1
47
48 /**
49  * @def ELM_TOOLBAR_SMART_CLASS_INIT
50  *
51  * Initializer for a whole #Elm_Toolbar_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_TOOLBAR_SMART_CLASS_INIT_NULL
60  * @see ELM_TOOLBAR_SMART_CLASS_INIT_NAME_VERSION
61  *
62  * @ingroup Widget
63  */
64 #define ELM_TOOLBAR_SMART_CLASS_INIT(smart_class_init) \
65   {smart_class_init, ELM_TOOLBAR_SMART_CLASS_VERSION}
66
67 /**
68  * @def ELM_TOOLBAR_SMART_CLASS_INIT_NULL
69  *
70  * Initializer to zero out a whole #Elm_Toolbar_Smart_Class structure.
71  *
72  * @see ELM_TOOLBAR_SMART_CLASS_INIT_NAME_VERSION
73  * @see ELM_TOOLBAR_SMART_CLASS_INIT
74  *
75  * @ingroup Widget
76  */
77 #define ELM_TOOLBAR_SMART_CLASS_INIT_NULL \
78   ELM_TOOLBAR_SMART_CLASS_INIT(EVAS_SMART_CLASS_INIT_NULL)
79
80 /**
81  * @def ELM_TOOLBAR_SMART_CLASS_INIT_NAME_VERSION
82  *
83  * Initializer to zero out a whole #Elm_Toolbar_Smart_Class structure and
84  * set its name and version.
85  *
86  * This is similar to #ELM_TOOLBAR_SMART_CLASS_INIT_NULL, but it will
87  * also set the version field of #Elm_Toolbar_Smart_Class (base field)
88  * to the latest #ELM_TOOLBAR_SMART_CLASS_VERSION and name it to the
89  * specific value.
90  *
91  * It will keep a reference to the name field as a <c>"const char *"</c>,
92  * i.e., the name must be available while the structure is
93  * used (hint: static or global variable!) and must not be modified.
94  *
95  * @see ELM_TOOLBAR_SMART_CLASS_INIT_NULL
96  * @see ELM_TOOLBAR_SMART_CLASS_INIT
97  *
98  * @ingroup Widget
99  */
100 #define ELM_TOOLBAR_SMART_CLASS_INIT_NAME_VERSION(name) \
101   ELM_TOOLBAR_SMART_CLASS_INIT(ELM_WIDGET_SMART_CLASS_INIT_NAME_VERSION(name))
102
103 /**
104  * Elementary toolbar base smart class. This inherits directly from
105  * #Elm_Widget_Smart_Class and is meant to build widgets extending the
106  * behavior of a toolbar.
107  *
108  * All of the functions listed on @ref Toolbar namespace will work for
109  * objects deriving from #Elm_Toolbar_Smart_Class.
110  */
111 typedef struct _Elm_Toolbar_Smart_Class
112 {
113    Elm_Widget_Smart_Class base;
114
115    int                    version; /**< Version of this smart class definition */
116 } Elm_Toolbar_Smart_Class;
117
118 typedef struct _Elm_Toolbar_Item Elm_Toolbar_Item;
119
120 /**
121  * Base widget smart data extended with toolbar instance data.
122  */
123 typedef struct _Elm_Toolbar_Smart_Data Elm_Toolbar_Smart_Data;
124 struct _Elm_Toolbar_Smart_Data
125 {
126    Elm_Widget_Smart_Data                 base; /* base widget smart data as
127                                                 * first member obligatory, as
128                                                 * we're inheriting from it */
129
130    Evas_Object                          *hit_rect;
131    const Elm_Scrollable_Smart_Interface *s_iface;
132
133    Evas_Object                          *bx, *more, *bx_more, *bx_more2;
134    Evas_Object                          *menu_parent;
135    Eina_Inlist                          *items;
136    Elm_Toolbar_Item                     *more_item, *selected_item;
137    Elm_Toolbar_Item                     *reorder_empty, *reorder_item;
138    Elm_Toolbar_Shrink_Mode               shrink_mode;
139    Elm_Icon_Lookup_Order                 lookup_order;
140    int                                   theme_icon_size, priv_icon_size,
141                                          icon_size;
142    int                                   standard_priority;
143    unsigned int                          item_count;
144    unsigned int                          separator_count;
145    double                                align;
146    Elm_Object_Select_Mode                select_mode;
147    Ecore_Timer                          *long_timer;
148    Ecore_Job                            *resize_job;
149
150    Eina_Bool                             vertical : 1;
151    Eina_Bool                             long_press : 1;
152    Eina_Bool                             homogeneous : 1;
153    Eina_Bool                             on_deletion : 1;
154    Eina_Bool                             reorder_mode : 1;
155    Eina_Bool                             transverse_expanded : 1;
156 };
157
158 struct _Elm_Toolbar_Item
159 {
160    ELM_WIDGET_ITEM;
161    EINA_INLIST;
162
163    const char   *label;
164    const char   *icon_str;
165    Evas_Object  *icon;
166    Evas_Object  *object;
167    Evas_Object  *o_menu;
168    Evas_Object  *in_box;
169    Evas_Object  *proxy;
170    Evas_Smart_Cb func;
171    Elm_Transit  *trans;
172    Elm_Toolbar_Item *reorder_to;
173    struct
174    {
175       int       priority;
176       Eina_Bool visible : 1;
177    } prio;
178
179    Eina_List    *states;
180    Eina_List    *current_state;
181
182    Eina_Bool     separator : 1;
183    Eina_Bool     selected : 1;
184    Eina_Bool     menu : 1;
185    Eina_Bool     on_move : 1;
186 };
187
188 struct _Elm_Toolbar_Item_State
189 {
190    const char   *label;
191    const char   *icon_str;
192    Evas_Object  *icon;
193    Evas_Smart_Cb func;
194    const void   *data;
195 };
196
197 /**
198  * @}
199  */
200
201 EAPI extern const char ELM_TOOLBAR_SMART_NAME[];
202 EAPI const Elm_Toolbar_Smart_Class
203 *elm_toolbar_smart_class_get(void);
204
205 #define ELM_TOOLBAR_DATA_GET(o, sd) \
206   Elm_Toolbar_Smart_Data * sd = evas_object_smart_data_get(o)
207
208 #define ELM_TOOLBAR_DATA_GET_OR_RETURN(o, ptr)       \
209   ELM_TOOLBAR_DATA_GET(o, ptr);                      \
210   if (!ptr)                                          \
211     {                                                \
212        CRITICAL("No widget data for object %p (%s)", \
213                 o, evas_object_type_get(o));         \
214        return;                                       \
215     }
216
217 #define ELM_TOOLBAR_DATA_GET_OR_RETURN_VAL(o, ptr, val) \
218   ELM_TOOLBAR_DATA_GET(o, ptr);                         \
219   if (!ptr)                                             \
220     {                                                   \
221        CRITICAL("No widget data for object %p (%s)",    \
222                 o, evas_object_type_get(o));            \
223        return val;                                      \
224     }
225
226 #define ELM_TOOLBAR_CHECK(obj)                                          \
227   if (!obj || !elm_widget_type_check((obj),                             \
228                                      ELM_TOOLBAR_SMART_NAME, __func__)) \
229     return
230
231 #define ELM_TOOLBAR_ITEM_CHECK(it)                          \
232   ELM_WIDGET_ITEM_CHECK_OR_RETURN((Elm_Widget_Item *)it, ); \
233   ELM_TOOLBAR_CHECK(it->base.widget);
234
235 #define ELM_TOOLBAR_ITEM_CHECK_OR_RETURN(it, ...)                      \
236   ELM_WIDGET_ITEM_CHECK_OR_RETURN((Elm_Widget_Item *)it, __VA_ARGS__); \
237   ELM_TOOLBAR_CHECK(it->base.widget) __VA_ARGS__;
238
239 #define ELM_TOOLBAR_ITEM_CHECK_OR_GOTO(it, label)              \
240   ELM_WIDGET_ITEM_CHECK_OR_GOTO((Elm_Widget_Item *)it, label); \
241   if (!it->base.widget || !elm_widget_type_check               \
242         ((it->base.widget), ELM_TOOLBAR_SMART_NAME, __func__)) goto label;
243
244 #endif