Index example
#include <Elementary.h>
static const char *items[] =
{
"Judith",
"Paulina",
"Cathy",
"Vendella",
"Naomi",
"Ashley",
"Stacey",
"Gail"
};
static void
_index_changed(void *data EINA_UNUSED,
Evas_Object *obj EINA_UNUSED,
void *event_info)
{
Elm_Object_Item *item = elm_object_item_data_get(event_info);
elm_gengrid_item_bring_in(item, ELM_GENGRID_ITEM_SCROLLTO_IN);
}
static char *
_grid_label_get(void *data,
Evas_Object *obj EINA_UNUSED,
const char *part EINA_UNUSED)
{
int idx = (int)(uintptr_t)data;
return strdup(items[idx]);
}
Evas_Object *
_grid_content_get(void *data EINA_UNUSED,
Evas_Object *obj,
const char *part)
{
if (!strcmp(part, "elm.swallow.icon"))
{
char buf[PATH_MAX];
snprintf(buf, sizeof(buf), "%s/images/%s", elm_app_data_dir_get(),
"sky_01.jpg");
Evas_Object *icon = elm_bg_add(obj);
elm_bg_file_set(icon, buf, NULL);
evas_object_size_hint_aspect_set(icon, EVAS_ASPECT_CONTROL_VERTICAL, 1,
1);
evas_object_show(icon);
return icon;
}
return NULL;
}
/* ordering alphabetically */
static int
_index_icmp(const void *data1,
const void *data2)
{
const char *label1, *label2;
const Elm_Object_Item *index_it1 = data1;
const Elm_Object_Item *index_it2 = data2;
label1 = elm_index_item_letter_get(index_it1);
label2 = elm_index_item_letter_get(index_it2);
return strcasecmp(label1, label2);
}
EAPI_MAIN int
elm_main(int argc EINA_UNUSED,
char **argv EINA_UNUSED)
{
Evas_Object *win, *grid, *idx;
Elm_Object_Item *gg_it;
unsigned int i;
Elm_Gengrid_Item_Class gic = { 0 };
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
elm_app_info_set(elm_main, "elementary", "images");
win = elm_win_util_standard_add("index", "Index Example");
elm_win_autodel_set(win, EINA_TRUE);
grid = elm_gengrid_add(win);
elm_gengrid_item_size_set(grid, 150, 150);
gic.item_style = "default";
gic.func.text_get = _grid_label_get;
gic.func.content_get = _grid_content_get;
gic.func.state_get = NULL;
gic.func.del = NULL;
evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(win, grid);
evas_object_show(grid);
idx = elm_index_add(win);
evas_object_size_hint_weight_set(idx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(win, idx);
evas_object_show(idx);
for (i = 0; i < (sizeof(items) / sizeof(items[0])); i++)
{
char buf[32];
gg_it = elm_gengrid_item_append(grid, &gic, (void *)(uintptr_t)i, NULL, NULL);
/* indexing by first letters */
snprintf(buf, sizeof(buf), "%c", items[i][0]);
elm_index_item_sorted_insert(idx, buf, NULL, gg_it, _index_icmp, NULL);
}
evas_object_smart_callback_add(idx, "delay,changed", _index_changed, NULL);
elm_index_autohide_disabled_set(idx, EINA_FALSE);
elm_index_level_go(idx, 0);
evas_object_resize(win, 320, 300);
evas_object_show(win);
elm_run();
return 0;
}
ELM_MAIN()
EVAS_HINT_EXPAND
#define EVAS_HINT_EXPAND
Use with evas_object_size_hint_weight_set(), evas_object_size_hint_weight_get(), evas_object_size_hin...
Definition Evas_Common.h:297
EVAS_ASPECT_CONTROL_VERTICAL
@ EVAS_ASPECT_CONTROL_VERTICAL
Use all vertical container space to place an object, using the given aspect.
Definition Evas_Common.h:377
EINA_TRUE
#define EINA_TRUE
boolean value TRUE (numerical value 1)
Definition eina_types.h:539
EINA_FALSE
#define EINA_FALSE
boolean value FALSE (numerical value 0)
Definition eina_types.h:533
EINA_UNUSED
#define EINA_UNUSED
Used to indicate that a function parameter is purposely unused.
Definition eina_types.h:339
elm_app_info_set
void elm_app_info_set(void *mainfunc, const char *dom, const char *checkfile)
Re-locate the application somewhere else after compilation, if the developer wishes for easier distri...
Definition elm_main.c:496
elm_app_data_dir_get
const char * elm_app_data_dir_get(void)
Get the application's run time data prefix directory, as set by elm_app_info_set() and the way (envir...
Definition elm_main.c:586
elm_bg_file_set
Eina_Bool elm_bg_file_set(Eo *obj, const char *file, const char *group)
Sets the file (image or edje collection) to give life for the background.
Definition efl_ui_bg.c:188
elm_bg_add
Evas_Object * elm_bg_add(Evas_Object *parent)
Adds a new background to the parent.
Definition efl_ui_bg.c:304
ELM_MAIN
#define ELM_MAIN()
macro to be used after the elm_main() function
Definition elm_general.h:556
elm_object_item_data_get
void * elm_object_item_data_get(const Elm_Object_Item *it)
Get the data associated with an object item.
Definition efl_ui_widget.c:3796
elm_policy_set
Eina_Bool elm_policy_set(unsigned int policy, int value)
Set a new policy's value (for a given policy group/identifier).
Definition elm_main.c:1380
Elm_Object_Item
Eo Elm_Object_Item
An Elementary Object item handle.
Definition elm_object_item.h:6
elm_run
void elm_run(void)
Run Elementary's main loop.
Definition elm_main.c:1357
ELM_POLICY_QUIT_LAST_WINDOW_CLOSED
@ ELM_POLICY_QUIT_LAST_WINDOW_CLOSED
quit when the application's last window is closed
Definition elm_general.h:248
ELM_POLICY_QUIT
@ ELM_POLICY_QUIT
under which circumstances the application should quit automatically.
Definition elm_general.h:227
elm_gengrid_item_append
Elm_Widget_Item * elm_gengrid_item_append(Elm_Gengrid *obj, const Elm_Gengrid_Item_Class *itc, const void *data, Evas_Smart_Cb func, const void *func_data)
Append a new item in a given gengrid widget.
Definition elm_gengrid_eo.legacy.c:189
elm_gengrid_add
Evas_Object * elm_gengrid_add(Evas_Object *parent)
Add a new gengrid widget to the given parent Elementary (container) object.
Definition elm_gengrid.c:4254
elm_gengrid_item_size_set
void elm_gengrid_item_size_set(Elm_Gengrid *obj, int w, int h)
Set the size for the items of a given gengrid widget.
Definition elm_gengrid_eo.legacy.c:93
elm_gengrid_item_bring_in
void elm_gengrid_item_bring_in(Elm_Gengrid_Item *obj, Elm_Gengrid_Item_Scrollto_Type type)
Animatedly bring in, to the visible area of a gengrid, a given item on it.
Definition elm_gengrid_item_eo.legacy.c:75
ELM_GENGRID_ITEM_SCROLLTO_IN
@ ELM_GENGRID_ITEM_SCROLLTO_IN
To the nearest viewport.
Definition elm_general.h:397
elm_index_item_sorted_insert
Elm_Widget_Item * elm_index_item_sorted_insert(Elm_Index *obj, const char *letter, Evas_Smart_Cb func, const void *data, Eina_Compare_Cb cmp_func, Eina_Compare_Cb cmp_data_func)
Insert a new item into the given index widget, using cmp_func function to sort items (by item handles...
Definition elm_index_eo.legacy.c:123
elm_index_level_go
void elm_index_level_go(Elm_Index *obj, int level)
Flush the changes made to the index items so they work correctly.
Definition elm_index_eo.legacy.c:75
elm_index_autohide_disabled_set
void elm_index_autohide_disabled_set(Elm_Index *obj, Eina_Bool disabled)
Enable or disable auto hiding feature for a given index widget.
Definition elm_index_eo.legacy.c:3
elm_index_add
Evas_Object * elm_index_add(Evas_Object *parent)
Add a new index widget to the given parent Elementary (container) object.
Definition elm_index.c:1186
elm_index_item_letter_get
const char * elm_index_item_letter_get(const Elm_Index_Item *obj)
Get the letter (string) set on a given index widget item.
Definition elm_index_item_eo.legacy.c:15
elm_win_util_standard_add
Evas_Object * elm_win_util_standard_add(const char *name, const char *title)
Adds a window object with standard setup.
Definition efl_ui_win.c:9587
elm_win_resize_object_add
void elm_win_resize_object_add(Eo *obj, Evas_Object *subobj)
Add subobj as a resize object of window obj.
Definition efl_ui_win.c:9002
elm_win_autodel_set
void elm_win_autodel_set(Eo *obj, Eina_Bool autodel)
Set the window's autodel state.
Definition efl_ui_win.c:6199
evas_object_show
EVAS_API void evas_object_show(Evas_Object *eo_obj)
Makes the given Evas object visible.
Definition evas_object_main.c:1814
evas_object_size_hint_weight_set
EVAS_API void evas_object_size_hint_weight_set(Evas_Object *obj, double x, double y)
Sets the hints for an object's weight.
Definition evas_object_main.c:2638
evas_object_size_hint_aspect_set
EVAS_API void evas_object_size_hint_aspect_set(Evas_Object *obj, Evas_Aspect_Control aspect, Evas_Coord w, Evas_Coord h)
Sets the hints for an object's aspect ratio.
Definition evas_object_main.c:2581
Evas_Object
Efl_Canvas_Object Evas_Object
An Evas Object handle.
Definition Evas_Common.h:185
evas_object_resize
EVAS_API void evas_object_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
Changes the size of the given Evas object.
Definition evas_object_main.c:1236
evas_object_smart_callback_add
EVAS_API void evas_object_smart_callback_add(Evas_Object *eo_obj, const char *event, Evas_Smart_Cb func, const void *data)
Add (register) a callback function to the smart event specified by event on the smart object obj.
Definition evas_object_smart.c:1040
_Elm_Gen_Item_Class_Functions::state_get
Elm_Gen_Item_State_Get_Cb state_get
State fetching class function for genlist/gengrid item classes.
Definition elm_gen.h:101
_Elm_Gen_Item_Class_Functions::del
Elm_Gen_Item_Del_Cb del
Deletion class function for genlist/gengrid item classes.
Definition elm_gen.h:102
_Elm_Gen_Item_Class_Functions::content_get
Elm_Gen_Item_Content_Get_Cb content_get
Content fetching class function for genlist/gengrid item classes.
Definition elm_gen.h:100
_Elm_Gen_Item_Class_Functions::text_get
Elm_Gen_Item_Text_Get_Cb text_get
Text fetching class function for genlist/gengrid item classes.
Definition elm_gen.h:99
_Elm_Gen_Item_Class::func
Elm_Gen_Item_Class_Functions func
Set of callbacks.
Definition elm_gen.h:126
_Elm_Gen_Item_Class::item_style
const char * item_style
Name of the visual style to use for this item.
Definition elm_gen.h:118