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.
18 #define ELM_LIST_SWIPE_MOVES 12
21 * Base widget smart data extended with list instance data.
23 typedef struct _Elm_List_Smart_Data Elm_List_Smart_Data;
24 struct _Elm_List_Smart_Data
26 Evas_Object *box, *hit_rect;
28 Eina_List *items, *selected, *to_delete;
29 Elm_Object_Item *last_selected_item;
30 Elm_Object_Item *focused_item; /**< a focused item by keypad arrow or mouse. This is set to NULL if widget looses focus. */
31 Elm_Object_Item *prev_focused_item; /**< a previous focused item by keypad arrow or mouse. */
32 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. */
33 Evas_Coord minw[2], minh[2];
34 Elm_Object_Select_Mode select_mode;
35 Elm_Object_Multi_Select_Mode multi_select_mode; /**< select mode for multiple selection */
44 } history[ELM_LIST_SWIPE_MOVES];
46 Eina_Bool focus_on_selection_enabled : 1;
47 Eina_Bool was_selected : 1;
48 Eina_Bool fix_pending : 1;
49 Eina_Bool longpressed : 1;
50 Eina_Bool scr_minw : 1;
51 Eina_Bool scr_minh : 1;
52 Eina_Bool on_hold : 1;
55 Eina_Bool delete_me : 1;
56 Eina_Bool mouse_down : 1; /**< a flag that mouse is down on the list at the moment. this flag is set to true on mouse and reset to false on mouse up */
59 typedef struct _Elm_List_Item Elm_List_Item;
64 Ecore_Timer *swipe_timer;
65 Ecore_Timer *long_timer;
66 Evas_Object *icon, *end;
72 Eina_Bool is_separator : 1;
73 Eina_Bool highlighted : 1;
74 Eina_Bool dummy_icon : 1;
75 Eina_Bool dummy_end : 1;
76 Eina_Bool selected : 1;
77 Eina_Bool deleted : 1;
78 Eina_Bool is_even : 1;
87 #define ELM_LIST_DATA_GET(o, sd) \
88 Elm_List_Smart_Data * sd = eo_data_scope_get(o, ELM_OBJ_LIST_CLASS)
90 #define ELM_LIST_DATA_GET_OR_RETURN(o, ptr) \
91 ELM_LIST_DATA_GET(o, ptr); \
92 if (EINA_UNLIKELY(!ptr)) \
94 CRI("No widget data for object %p (%s)", \
95 o, evas_object_type_get(o)); \
99 #define ELM_LIST_DATA_GET_OR_RETURN_VAL(o, ptr, val) \
100 ELM_LIST_DATA_GET(o, ptr); \
101 if (EINA_UNLIKELY(!ptr)) \
103 CRI("No widget data for object %p (%s)", \
104 o, evas_object_type_get(o)); \
108 #define ELM_LIST_CHECK(obj) \
109 if (EINA_UNLIKELY(!eo_isa((obj), ELM_OBJ_LIST_CLASS))) \
112 #define ELM_LIST_ITEM_CHECK(it) \
113 ELM_WIDGET_ITEM_CHECK_OR_RETURN((Elm_Widget_Item *)it, ); \
114 ELM_LIST_CHECK(it->base.widget); \
115 if (((Elm_List_Item *)it)->deleted) \
117 ERR("ERROR: " #it " has been DELETED.\n"); \
121 #define ELM_LIST_ITEM_CHECK_OR_RETURN(it, ...) \
122 ELM_WIDGET_ITEM_CHECK_OR_RETURN((Elm_Widget_Item *)it, __VA_ARGS__); \
123 ELM_LIST_CHECK(it->base.widget) __VA_ARGS__; \
124 if (((Elm_List_Item *)it)->deleted) \
126 ERR("ERROR: " #it " has been DELETED.\n"); \
127 return __VA_ARGS__; \