2 //gcc -g `pkg-config --cflags --libs elementary` genlist_example_01.c -o genlist_example_01
5 #include <Elementary.h>
7 # include "elementary_config.h"
15 static Elm_Genlist_Item_Class _itc;
18 _item_text_get(void *data, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
20 static Elm_Genlist_Item_Class *_itc = NULL;
23 _item_label_get(void *data, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
24 >>>>>>> remotes/origin/upstream
26 time_t t = (time_t)ecore_time_unix_get();
28 int i = (int)(long)data;
32 snprintf(buf, sizeof(buf), "Very Long Item # %i - realized at %s", i, ctime(&t));
37 snprintf(buf, sizeof(buf), "short item # %i", i);
42 _item_content_get(void *data __UNUSED__, Evas_Object *obj, const char *part)
44 Evas_Object *ic = elm_icon_add(obj);
46 if (!strcmp(part, "elm.swallow.icon"))
47 elm_icon_standard_set(ic, "clock");
49 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
54 _item_sel_cb(void *data, Evas_Object *obj, void *event_info)
56 printf("sel item data [%p] on genlist obj [%p], item pointer [%p]\n",
57 data, obj, event_info);
61 _show_status_cb(void *data, Evas_Object *o __UNUSED__, void *event_info __UNUSED__)
63 Evas_Object *list = data;
64 Evas_Coord x, y, w, h, mx, my;
66 Elm_Object_Item *it = elm_genlist_selected_item_get(list);
68 const Eina_List *selected, *l, *realized;
69 printf("\nfirst selected item: %p\n", it);
71 selected = elm_genlist_selected_items_get(list);
72 printf("all selected items (%d): ", eina_list_count(selected));
73 EINA_LIST_FOREACH(selected, l, it)
76 Elm_Object_Item *glit = elm_genlist_selected_item_get(list);
78 const Eina_List *selected, *l, *realized;
79 printf("\nfirst selected item: %p\n", glit);
81 selected = elm_genlist_selected_items_get(list);
82 printf("all selected items (%d): ", eina_list_count(selected));
83 EINA_LIST_FOREACH(selected, l, glit)
85 >>>>>>> remotes/origin/upstream
88 realized = elm_genlist_realized_items_get(list);
89 printf("realized items (%d): ", eina_list_count(realized));
91 EINA_LIST_FOREACH(realized, l, it)
94 printf("genlist mode: %s\n", elm_genlist_mode_get(list));
95 printf("mode item: %p\n", elm_genlist_mode_item_get(list));
97 EINA_LIST_FOREACH(realized, l, glit)
100 printf("genlist mode: %s\n", elm_genlist_decorate_mode_get(list));
101 printf("mode item: %p\n", elm_genlist_decorated_item_get(list));
102 >>>>>>> remotes/origin/upstream
104 evas_object_geometry_get(list, &x, &y, &w, &h);
108 it = elm_genlist_at_xy_item_get(list, mx, my, NULL);
109 printf("item in the middle of the screen: %p\n", it);
111 glit = elm_genlist_at_xy_item_get(list, mx, my, NULL);
112 printf("item in the middle of the screen: %p\n", glit);
113 >>>>>>> remotes/origin/upstream
117 _realize_cb(void *data, Evas_Object *o __UNUSED__, void *event_info __UNUSED__)
119 Evas_Object *list = data;
120 elm_genlist_realized_items_update(list);
124 elm_main(int argc __UNUSED__, char **argv __UNUSED__)
126 Evas_Object *win, *bg, *box, *hbox;
127 Evas_Object *list, *btn;
130 win = elm_win_add(NULL, "genlist", ELM_WIN_BASIC);
131 elm_win_title_set(win, "Genlist - simple");
132 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
133 elm_win_autodel_set(win, EINA_TRUE);
135 bg = elm_bg_add(win);
136 elm_bg_color_set(bg, 255,255 ,255);
137 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
138 elm_win_resize_object_add(win, bg);
139 evas_object_show(bg);
141 box = elm_box_add(win);
142 evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
143 evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
144 elm_win_resize_object_add(win, box);
145 evas_object_show(box);
147 list = elm_genlist_add(win);
150 _itc.item_style = "default";
151 _itc.func.text_get = _item_text_get;
152 _itc.func.content_get = _item_content_get;
153 _itc.func.state_get = NULL;
154 _itc.func.del = NULL;
156 Eina_Bool hbounce, vbounce;
157 Elm_Scroller_Policy hp, vp;
159 printf("default values:\n");
160 printf("always select: %d\n", elm_genlist_always_select_mode_get(list));
161 elm_genlist_bounce_get(list, &hbounce, &vbounce);
162 printf("bounce - horizontal: %d, vertical: %d\n", hbounce, vbounce);
163 printf("compress mode: %d\n", elm_genlist_compress_mode_get(list));
164 printf("homogeneous: %d\n", elm_genlist_homogeneous_get(list));
165 printf("horizontal mode: %d\n", elm_genlist_horizontal_mode_get(list));
166 printf("longpress timeout: %0.3f\n",
167 elm_genlist_longpress_timeout_get(list));
168 printf("multi selection: %d\n", elm_genlist_multi_select_get(list));
169 printf("no selection mode: %d\n", elm_genlist_no_select_mode_get(list));
170 printf("height for width enabled: %d\n",
171 elm_genlist_height_for_width_mode_get(list));
175 _itc = elm_genlist_item_class_new();
176 _itc->item_style = "default";
177 _itc->func.text_get = _item_label_get;
178 _itc->func.content_get = _item_content_get;
179 _itc->func.state_get = NULL;
180 _itc->func.del = NULL;
183 Eina_Bool hbounce, vbounce, always, no_sel;
184 Elm_Scroller_Policy hp, vp;
185 Elm_Object_Select_Mode sel_mode;
187 always = no_sel = EINA_FALSE;
188 sel_mode = elm_genlist_select_mode_get(list);
189 if (sel_mode = ELM_OBJECT_SELECT_MODE_ALWAYS)
191 else if (sel_mode = ELM_OBJECT_SELECT_MODE_NONE)
194 printf("default values:\n");
195 printf("always select: %d\n", always);
196 elm_genlist_bounce_get(list, &hbounce, &vbounce);
197 printf("bounce - horizontal: %d, vertical: %d\n", hbounce, vbounce);
198 printf("homogeneous: %d\n", elm_genlist_homogeneous_get(list));
199 printf("horizontal mode: %d\n", elm_genlist_mode_get(list));
200 printf("longpress timeout: %0.3f\n",
201 elm_genlist_longpress_timeout_get(list));
202 printf("multi selection: %d\n", elm_genlist_multi_select_get(list));
203 printf("no selection mode: %d\n", no_sel);
204 >>>>>>> remotes/origin/upstream
205 elm_genlist_scroller_policy_get(list, &hp, &vp);
206 printf("scroller policy - horizontal: %d, vertical: %d\n", hp, vp);
207 printf("block count: %d\n", elm_genlist_block_count_get(list));
211 elm_genlist_always_select_mode_set(list, EINA_FALSE);
212 elm_genlist_bounce_set(list, EINA_FALSE, EINA_FALSE);
213 elm_genlist_compress_mode_set(list, EINA_TRUE);
214 elm_genlist_homogeneous_set(list, EINA_FALSE);
215 elm_genlist_horizontal_mode_set(list, ELM_LIST_LIMIT);
216 elm_genlist_multi_select_set(list, EINA_TRUE);
217 elm_genlist_no_select_mode_set(list, EINA_FALSE);
218 elm_genlist_height_for_width_mode_set(list, EINA_FALSE);
220 elm_genlist_bounce_set(list, EINA_FALSE, EINA_FALSE);
221 elm_genlist_homogeneous_set(list, EINA_FALSE);
222 elm_genlist_mode_set(list, ELM_LIST_LIMIT);
223 elm_genlist_multi_select_set(list, EINA_TRUE);
224 elm_genlist_select_mode_set(list, ELM_OBJECT_SELECT_MODE_DEFAULT);
225 >>>>>>> remotes/origin/upstream
226 elm_genlist_scroller_policy_set(list, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_ON);
227 elm_genlist_longpress_timeout_set(list, 0.5);
228 elm_genlist_block_count_set(list, 16);
230 for (i = 0; i < N_ITEMS; i++)
233 elm_genlist_item_append(list, &_itc,
235 elm_genlist_item_append(list, _itc,
236 >>>>>>> remotes/origin/upstream
237 (void *)(long)i, NULL,
238 ELM_GENLIST_ITEM_NONE,
242 evas_object_size_hint_weight_set(list, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
243 evas_object_size_hint_align_set(list, EVAS_HINT_FILL, EVAS_HINT_FILL);
244 elm_box_pack_end(box, list);
245 evas_object_show(list);
247 hbox = elm_box_add(win);
248 elm_box_horizontal_set(hbox, EINA_TRUE);
249 evas_object_size_hint_weight_set(hbox, EVAS_HINT_EXPAND, 0);
250 evas_object_size_hint_align_set(hbox, EVAS_HINT_FILL, EVAS_HINT_FILL);
251 elm_box_pack_end(box, hbox);
252 evas_object_show(hbox);
254 btn = elm_button_add(win);
255 elm_object_text_set(btn, "Show status");
256 evas_object_size_hint_weight_set(btn, 0, 0);
257 evas_object_size_hint_align_set(btn, 0.5, 0.5);
258 evas_object_smart_callback_add(btn, "clicked", _show_status_cb, list);
259 elm_box_pack_end(hbox, btn);
260 evas_object_show(btn);
262 btn = elm_button_add(win);
263 elm_object_text_set(btn, "Realize");
264 evas_object_size_hint_weight_set(btn, 0, 0);
265 evas_object_size_hint_align_set(btn, 0.5, 0.5);
266 evas_object_smart_callback_add(btn, "clicked", _realize_cb, list);
267 elm_box_pack_end(hbox, btn);
268 evas_object_show(btn);
270 evas_object_size_hint_min_set(bg, 160, 160);
271 evas_object_size_hint_max_set(bg, 200, 640);
272 evas_object_resize(win, 200, 320);
273 evas_object_show(win);