tizen 2.4 release
[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
6 /* DO NOT USE THIS HEADER UNLESS YOU ARE PREPARED FOR BREAKING OF YOUR
7  * CODE. THIS IS ELEMENTARY'S INTERNAL WIDGET API (for now) AND IS NOT
8  * FINAL. CALL elm_widget_api_check(ELM_INTERNAL_API_VERSION) TO CHECK
9  * IT AT RUNTIME.
10  */
11
12 /**
13  * @internal
14  * @addtogroup Widget
15  * @{
16  *
17  * @section elm-toolbar-class The Elementary Toolbar Class
18  *
19  * Elementary, besides having the @ref Toolbar widget, exposes its
20  * foundation -- the Elementary Toolbar Class -- in order to create other
21  * widgets which are a toolbar with some more logic on top.
22  */
23
24 typedef struct _Elm_Toolbar_Item_Data Elm_Toolbar_Item_Data;
25
26 /**
27  * Base widget smart data extended with toolbar instance data.
28  */
29 typedef struct _Elm_Toolbar_Data Elm_Toolbar_Data;
30 struct _Elm_Toolbar_Data
31 {
32    Evas_Object                          *hit_rect;
33
34    Evas_Object                          *bx, *more, *bx_more, *bx_more2;
35    Evas_Object                          *menu_parent;
36    Eina_Inlist                          *items;
37    Elm_Toolbar_Item_Data                *more_item;
38    Elm_Object_Item                      *selected_item; /**< a selected item by mouse click, return key, api, and etc. */
39    // TIZEN_ONLY(20150815): Properly unselect the last item which is selected by order.
40    Elm_Object_Item                      *auto_selected_last_item; /**< a selected item by order. */
41    //
42    Elm_Object_Item                      *focused_item; /**< a focused item by keypad arrow or mouse. This is set to NULL if widget looses focus. */
43    Elm_Object_Item                      *last_focused_item; /**< This records the last focused item when widget looses focus. This is required to set the focus on last focused item when widgets gets focus. */
44    Elm_Toolbar_Item_Data                *reorder_empty, *reorder_item;
45    Elm_Toolbar_Shrink_Mode               shrink_mode;
46    Elm_Icon_Lookup_Order                 lookup_order;
47    int                                   theme_icon_size, priv_icon_size,
48                                          icon_size;
49    int                                   standard_priority;
50    unsigned int                          item_count;
51    unsigned int                          separator_count;
52    double                                align;
53    Elm_Object_Select_Mode                select_mode;
54    Ecore_Timer                          *long_timer;
55    Ecore_Job                            *resize_job;
56
57    Eina_Bool                             vertical : 1;
58    Eina_Bool                             long_press : 1;
59    Eina_Bool                             homogeneous : 1;
60    Eina_Bool                             delete_me : 1;
61    Eina_Bool                             reorder_mode : 1;
62    Eina_Bool                             transverse_expanded : 1;
63    Eina_Bool                             mouse_down : 1; /**< a flag that mouse is down on the toolbar at the moment. This flag is set to true on mouse and reset to false on mouse up. */
64 };
65
66 struct _Elm_Toolbar_Item_Data
67 {
68    Elm_Widget_Item_Data     *base;
69    EINA_INLIST;
70
71    const char   *label;
72    const char   *icon_str;
73    Evas_Object  *icon;
74    Evas_Object  *object;
75    Evas_Object  *o_menu;
76    Evas_Object  *in_box;
77    Evas_Object  *proxy;
78    Evas_Smart_Cb func;
79    Elm_Transit  *trans;
80    Elm_Toolbar_Item_Data *reorder_to;
81    struct
82    {
83       int       priority;
84       Eina_Bool visible : 1;
85    } prio;
86
87    Eina_List    *states;
88    Eina_List    *current_state;
89
90    Eina_Bool     separator : 1;
91    Eina_Bool     selected : 1;
92    Eina_Bool     menu : 1;
93    Eina_Bool     on_move : 1;
94 };
95
96 struct _Elm_Toolbar_Item_State
97 {
98    const char   *label;
99    const char   *icon_str;
100    Evas_Object  *icon;
101    Evas_Smart_Cb func;
102    const void   *data;
103 };
104
105 /**
106  * @}
107  */
108
109 #define ELM_TOOLBAR_DATA_GET(o, sd) \
110   Elm_Toolbar_Data * sd = eo_data_scope_get(o, ELM_TOOLBAR_CLASS)
111
112 #define ELM_TOOLBAR_DATA_GET_OR_RETURN(o, ptr)       \
113   ELM_TOOLBAR_DATA_GET(o, ptr);                      \
114   if (EINA_UNLIKELY(!ptr))                           \
115     {                                                \
116        CRI("No widget data for object %p (%s)",      \
117            o, evas_object_type_get(o));              \
118        return;                                       \
119     }
120
121 #define ELM_TOOLBAR_DATA_GET_OR_RETURN_VAL(o, ptr, val) \
122   ELM_TOOLBAR_DATA_GET(o, ptr);                         \
123   if (EINA_UNLIKELY(!ptr))                              \
124     {                                                   \
125        CRI("No widget data for object %p (%s)",         \
126            o, evas_object_type_get(o));                 \
127        return val;                                      \
128     }
129
130 #define ELM_TOOLBAR_CHECK(obj)                              \
131   if (EINA_UNLIKELY(!eo_isa((obj), ELM_TOOLBAR_CLASS))) \
132     return
133
134 #define ELM_TOOLBAR_ITEM_CHECK(it)                          \
135   ELM_WIDGET_ITEM_CHECK_OR_RETURN(it->base, ); \
136   ELM_TOOLBAR_CHECK(it->base->widget);
137
138 #define ELM_TOOLBAR_ITEM_CHECK_OR_RETURN(it, ...)                      \
139   ELM_WIDGET_ITEM_CHECK_OR_RETURN(it->base, __VA_ARGS__); \
140   ELM_TOOLBAR_CHECK(it->base->widget) __VA_ARGS__;
141
142 #define ELM_TOOLBAR_ITEM_CHECK_OR_GOTO(it, label)              \
143   ELM_WIDGET_ITEM_CHECK_OR_GOTO(it->base, label); \
144   if (!it->base->widget || !eo_isa ((it->base->widget), ELM_TOOLBAR_CLASS)) goto label;
145
146 #define ELM_TOOLBAR_ITEM_DATA_GET(o, sd) \
147   Elm_Toolbar_Item_Data *sd = eo_data_scope_get(o, ELM_TOOLBAR_ITEM_CLASS)
148
149 #endif