1 #ifndef ELM_WIDGET_TOOLBAR_H
2 #define ELM_WIDGET_TOOLBAR_H
4 #include "elm_interface_scrollable.h"
11 * @section elm-toolbar-class The Elementary Toolbar Class
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.
19 * @def ELM_TOOLBAR_CLASS
21 * Use this macro to cast whichever subclass of
22 * #Elm_Toolbar_Smart_Class into it, so to access its fields.
26 #define ELM_TOOLBAR_CLASS(x) ((Elm_Toolbar_Smart_Class *)x)
29 * @def ELM_TOOLBAR_DATA
31 * Use this macro to cast whichever subdata of
32 * #Elm_Toolbar_Smart_Data into it, so to access its fields.
36 #define ELM_TOOLBAR_DATA(x) ((Elm_Toolbar_Smart_Data *)x)
39 * @def ELM_TOOLBAR_SMART_CLASS_VERSION
41 * Current version for Elementary toolbar @b base smart class, a value
42 * which goes to _Elm_Toolbar_Smart_Class::version.
46 #define ELM_TOOLBAR_SMART_CLASS_VERSION 1
49 * @def ELM_TOOLBAR_SMART_CLASS_INIT
51 * Initializer for a whole #Elm_Toolbar_Smart_Class structure, with
52 * @c NULL values on its specific fields.
54 * @param smart_class_init initializer to use for the "base" field
55 * (#Evas_Smart_Class).
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
64 #define ELM_TOOLBAR_SMART_CLASS_INIT(smart_class_init) \
65 {smart_class_init, ELM_TOOLBAR_SMART_CLASS_VERSION}
68 * @def ELM_TOOLBAR_SMART_CLASS_INIT_NULL
70 * Initializer to zero out a whole #Elm_Toolbar_Smart_Class structure.
72 * @see ELM_TOOLBAR_SMART_CLASS_INIT_NAME_VERSION
73 * @see ELM_TOOLBAR_SMART_CLASS_INIT
77 #define ELM_TOOLBAR_SMART_CLASS_INIT_NULL \
78 ELM_TOOLBAR_SMART_CLASS_INIT(EVAS_SMART_CLASS_INIT_NULL)
81 * @def ELM_TOOLBAR_SMART_CLASS_INIT_NAME_VERSION
83 * Initializer to zero out a whole #Elm_Toolbar_Smart_Class structure and
84 * set its name and version.
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
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.
95 * @see ELM_TOOLBAR_SMART_CLASS_INIT_NULL
96 * @see ELM_TOOLBAR_SMART_CLASS_INIT
100 #define ELM_TOOLBAR_SMART_CLASS_INIT_NAME_VERSION(name) \
101 ELM_TOOLBAR_SMART_CLASS_INIT(ELM_WIDGET_SMART_CLASS_INIT_NAME_VERSION(name))
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.
108 * All of the functions listed on @ref Toolbar namespace will work for
109 * objects deriving from #Elm_Toolbar_Smart_Class.
111 typedef struct _Elm_Toolbar_Smart_Class
113 Elm_Widget_Smart_Class base;
115 int version; /**< Version of this smart class definition */
116 } Elm_Toolbar_Smart_Class;
118 typedef struct _Elm_Toolbar_Item Elm_Toolbar_Item;
121 * Base widget smart data extended with toolbar instance data.
123 typedef struct _Elm_Toolbar_Smart_Data Elm_Toolbar_Smart_Data;
124 struct _Elm_Toolbar_Smart_Data
126 Elm_Widget_Smart_Data base; /* base widget smart data as
127 * first member obligatory, as
128 * we're inheriting from it */
130 Evas_Object *hit_rect;
131 const Elm_Scrollable_Smart_Interface *s_iface;
133 Evas_Object *bx, *more, *bx_more, *bx_more2;
134 Evas_Object *menu_parent;
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,
142 int standard_priority;
143 unsigned int item_count;
144 unsigned int separator_count;
146 Elm_Object_Select_Mode select_mode;
147 Ecore_Timer *long_timer;
148 Ecore_Job *resize_job;
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;
158 struct _Elm_Toolbar_Item
164 const char *icon_str;
172 Elm_Toolbar_Item *reorder_to;
176 Eina_Bool visible : 1;
180 Eina_List *current_state;
182 Eina_Bool separator : 1;
183 Eina_Bool selected : 1;
185 Eina_Bool on_move : 1;
188 struct _Elm_Toolbar_Item_State
191 const char *icon_str;
201 EAPI extern const char ELM_TOOLBAR_SMART_NAME[];
202 EAPI const Elm_Toolbar_Smart_Class
203 *elm_toolbar_smart_class_get(void);
205 #define ELM_TOOLBAR_DATA_GET(o, sd) \
206 Elm_Toolbar_Smart_Data * sd = evas_object_smart_data_get(o)
208 #define ELM_TOOLBAR_DATA_GET_OR_RETURN(o, ptr) \
209 ELM_TOOLBAR_DATA_GET(o, ptr); \
212 CRITICAL("No widget data for object %p (%s)", \
213 o, evas_object_type_get(o)); \
217 #define ELM_TOOLBAR_DATA_GET_OR_RETURN_VAL(o, ptr, val) \
218 ELM_TOOLBAR_DATA_GET(o, ptr); \
221 CRITICAL("No widget data for object %p (%s)", \
222 o, evas_object_type_get(o)); \
226 #define ELM_TOOLBAR_CHECK(obj) \
227 if (!obj || !elm_widget_type_check((obj), \
228 ELM_TOOLBAR_SMART_NAME, __func__)) \
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);
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__;
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;