#include <Elementary.h>
#include <time.h>
#define N_ITEMS 300
static char *
_item_label_get(
void *data,
Evas_Object *obj EINA_UNUSED,
const char *part EINA_UNUSED)
{
char buf[256];
int i = (int)(uintptr_t)data;
if (i % 2)
{
int n;
snprintf(buf, sizeof(buf), "Very Long Item # %i - realized at %s", i, ctime(&t));
n = strlen(buf);
buf[n - 1] = '\0';
}
else
snprintf(buf, sizeof(buf), "short item # %i", i);
return strdup(buf);
}
_item_content_get(
void *data EINA_UNUSED,
Evas_Object *obj,
const char *part)
{
if (!strcmp(part, "elm.swallow.icon"))
return ic;
}
static void
_item_sel_cb(
void *data,
Evas_Object *obj,
void *event_info)
{
printf("sel item data [%p] on genlist obj [%p], item pointer [%p]\n",
data, obj, event_info);
}
static void
_show_status_cb(
void *data,
Evas_Object *o EINA_UNUSED,
void *event_info EINA_UNUSED)
{
printf("\nfirst selected item: %p\n", glit);
selected = elm_genlist_selected_items_get(list);
printf("%p ", glit);
printf("\n");
realized = elm_genlist_realized_items_get(list);
printf("%p ", glit);
printf("\n");
printf("genlist mode: %d\n", elm_genlist_decorate_mode_get(list));
printf("mode item: %p\n", elm_genlist_decorated_item_get(list));
mx = w / 2 + x;
my = h / 2 + y;
glit = elm_genlist_at_xy_item_get(list, mx, my, NULL);
printf("item in the middle of the screen: %p\n", glit);
}
static void
_realize_cb(
void *data,
Evas_Object *o EINA_UNUSED,
void *event_info EINA_UNUSED)
{
elm_genlist_realized_items_update(list);
}
EAPI_MAIN int
elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
{
unsigned int i;
if (!_itc)
{
}
sel_mode = elm_genlist_select_mode_get(list);
printf("default values:\n");
printf("always select: %d\n", always);
printf("bounce - horizontal: %d, vertical: %d\n", hbounce, vbounce);
printf("homogeneous: %d\n", elm_genlist_homogeneous_get(list));
printf("horizontal mode: %d\n", elm_genlist_mode_get(list));
printf("longpress timeout: %0.3f\n",
elm_genlist_longpress_timeout_get(list));
printf("multi selection: %d\n", elm_genlist_multi_select_get(list));
printf("no selection mode: %d\n", no_sel);
printf("scroller policy - horizontal: %d, vertical: %d\n", hp, vp);
printf("block count: %d\n", elm_genlist_block_count_get(list));
printf("\n");
elm_genlist_homogeneous_set(list, EINA_FALSE);
elm_genlist_multi_select_set(list, EINA_TRUE);
elm_genlist_longpress_timeout_set(list, 0.5);
elm_genlist_block_count_set(list, 16);
for (i = 0; i < N_ITEMS; i++)
{
elm_genlist_item_append(list, _itc,
(void *)(uintptr_t)i, NULL,
_item_sel_cb, NULL);
}
elm_box_pack_end(box, list);
elm_box_horizontal_set(hbox, EINA_TRUE);
elm_box_pack_end(box, hbox);
elm_object_text_set(btn, "Show status");
evas_object_size_hint_weight_set(btn, 0, 0);
evas_object_size_hint_align_set(btn, 0.5, 0.5);
elm_box_pack_end(hbox, btn);
elm_object_text_set(btn, "Realize");
evas_object_size_hint_weight_set(btn, 0, 0);
evas_object_size_hint_align_set(btn, 0.5, 0.5);
elm_box_pack_end(hbox, btn);
evas_object_resize(win, 200, 320);
return 0;
}