1 #ifndef ELM_WIDGET_LIST_H
2 #define ELM_WIDGET_LIST_H
4 #include "elm_interface_scrollable.h"
5 #include "elm_widget_layout.h"
11 * @section elm-list-class The Elementary List Class
13 * Elementary, besides having the @ref List widget, exposes its
14 * foundation -- the Elementary List Class -- in order to create
15 * other widgets which are a list with some more logic on top.
21 * Use this macro to cast whichever subclass of
22 * #Elm_List_Smart_Class into it, so to access its fields.
26 #define ELM_LIST_CLASS(x) ((Elm_List_Smart_Class *)x)
31 * Use this macro to cast whichever subdata of
32 * #Elm_List_Smart_Data into it, so to access its fields.
36 #define ELM_LIST_DATA(x) ((Elm_List_Smart_Data *)x)
39 * @def ELM_LIST_SMART_CLASS_VERSION
41 * Current version for Elementary list @b base smart class, a value
42 * which goes to _Elm_List_Smart_Class::version.
46 #define ELM_LIST_SMART_CLASS_VERSION 1
49 * @def ELM_LIST_SMART_CLASS_INIT
51 * Initializer for a whole #Elm_List_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_LIST_SMART_CLASS_INIT_NULL
60 * @see ELM_LIST_SMART_CLASS_INIT_NAME_VERSION
64 #define ELM_LIST_SMART_CLASS_INIT(smart_class_init) \
65 {smart_class_init, ELM_LIST_SMART_CLASS_VERSION}
68 * @def ELM_LIST_SMART_CLASS_INIT_NULL
70 * Initializer to zero out a whole #Elm_List_Smart_Class structure.
72 * @see ELM_LIST_SMART_CLASS_INIT_NAME_VERSION
73 * @see ELM_LIST_SMART_CLASS_INIT
77 #define ELM_LIST_SMART_CLASS_INIT_NULL \
78 ELM_LIST_SMART_CLASS_INIT(EVAS_SMART_CLASS_INIT_NULL)
81 * @def ELM_LIST_SMART_CLASS_INIT_NAME_VERSION
83 * Initializer to zero out a whole #Elm_List_Smart_Class structure and
84 * set its name and version.
86 * This is similar to #ELM_LIST_SMART_CLASS_INIT_NULL, but it will
87 * also set the version field of #Elm_List_Smart_Class (base field)
88 * to the latest #ELM_LIST_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_LIST_SMART_CLASS_INIT_NULL
96 * @see ELM_LIST_SMART_CLASS_INIT
100 #define ELM_LIST_SMART_CLASS_INIT_NAME_VERSION(name) \
101 ELM_LIST_SMART_CLASS_INIT \
102 (ELM_LAYOUT_SMART_CLASS_INIT_NAME_VERSION(name))
105 * Elementary list base smart class. This inherits directly from
106 * #Elm_Layout_Smart_Class and is meant to build widgets extending the
107 * behavior of a list.
109 * All of the functions listed on @ref List namespace will work for
110 * objects deriving from #Elm_List_Smart_Class.
112 typedef struct _Elm_List_Smart_Class
114 Elm_Layout_Smart_Class base;
116 int version; /**< Version of this smart class definition */
117 } Elm_List_Smart_Class;
119 #define ELM_LIST_SWIPE_MOVES 12
122 * Base widget smart data extended with list instance data.
124 typedef struct _Elm_List_Smart_Data Elm_List_Smart_Data;
125 struct _Elm_List_Smart_Data
127 Elm_Layout_Smart_Data base; /* base widget smart data as
128 * first member obligatory, as
129 * we're inheriting from it */
131 Evas_Object *box, *hit_rect;
132 const Elm_Scrollable_Smart_Interface *s_iface;
134 Eina_List *items, *selected, *to_delete;
135 Elm_Object_Item *last_selected_item;
136 Evas_Coord minw[2], minh[2];
137 Elm_Object_Select_Mode select_mode;
140 Elm_List_Mode h_mode;
146 } history[ELM_LIST_SWIPE_MOVES];
148 Eina_Bool was_selected : 1;
149 Eina_Bool fix_pending : 1;
150 Eina_Bool longpressed : 1;
151 Eina_Bool scr_minw : 1;
152 Eina_Bool scr_minh : 1;
153 Eina_Bool on_hold : 1;
156 Eina_Bool delete_me : 1;
159 typedef struct _Elm_List_Item Elm_List_Item;
160 struct _Elm_List_Item
164 Elm_List_Smart_Data *sd;
166 Ecore_Timer *swipe_timer;
167 Ecore_Timer *long_timer;
168 Evas_Object *icon, *end;
174 Eina_Bool is_separator : 1;
175 Eina_Bool highlighted : 1;
176 Eina_Bool dummy_icon : 1;
177 Eina_Bool dummy_end : 1;
178 Eina_Bool selected : 1;
179 Eina_Bool deleted : 1;
180 Eina_Bool is_even : 1;
189 EAPI extern const char ELM_LIST_SMART_NAME[];
190 EAPI const Elm_List_Smart_Class *elm_list_smart_class_get(void);
192 #define ELM_LIST_DATA_GET(o, sd) \
193 Elm_List_Smart_Data * sd = evas_object_smart_data_get(o)
195 #define ELM_LIST_DATA_GET_OR_RETURN(o, ptr) \
196 ELM_LIST_DATA_GET(o, ptr); \
199 CRITICAL("No widget data for object %p (%s)", \
200 o, evas_object_type_get(o)); \
204 #define ELM_LIST_DATA_GET_OR_RETURN_VAL(o, ptr, val) \
205 ELM_LIST_DATA_GET(o, ptr); \
208 CRITICAL("No widget data for object %p (%s)", \
209 o, evas_object_type_get(o)); \
213 #define ELM_LIST_CHECK(obj) \
214 if (!obj || !elm_widget_type_check((obj), ELM_LIST_SMART_NAME, __func__)) \
217 #define ELM_LIST_ITEM_CHECK(it) \
218 ELM_WIDGET_ITEM_CHECK_OR_RETURN((Elm_Widget_Item *)it, ); \
219 ELM_LIST_CHECK(it->base.widget); \
220 if (((Elm_List_Item *)it)->deleted) \
222 ERR("ERROR: " #it " has been DELETED.\n"); \
226 #define ELM_LIST_ITEM_CHECK_OR_RETURN(it, ...) \
227 ELM_WIDGET_ITEM_CHECK_OR_RETURN((Elm_Widget_Item *)it, __VA_ARGS__); \
228 ELM_LIST_CHECK(it->base.widget) __VA_ARGS__; \
229 if (((Elm_List_Item *)it)->deleted) \
231 ERR("ERROR: " #it " has been DELETED.\n"); \
232 return __VA_ARGS__; \