2009-01-07 05:49:08 -08:00
|
|
|
#include <Elementary.h>
|
|
|
|
#include "elm_priv.h"
|
|
|
|
|
|
|
|
typedef struct _Widget_Data Widget_Data;
|
|
|
|
typedef struct _Item Item;
|
|
|
|
|
|
|
|
struct _Widget_Data
|
|
|
|
{
|
|
|
|
Evas_Object *scroller, *box;
|
|
|
|
Eina_List *items;
|
|
|
|
Eina_List *selected;
|
|
|
|
Elementary_List_Mode mode;
|
2009-01-08 06:29:13 -08:00
|
|
|
Evas_Coord minw[2], minh[2];
|
2009-01-08 23:35:52 -08:00
|
|
|
Evas_Bool on_hold : 1;
|
|
|
|
Evas_Bool multi : 1;
|
2009-01-07 05:49:08 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct _Item
|
|
|
|
{
|
|
|
|
Evas_Object *obj;
|
|
|
|
Evas_Object *base;
|
|
|
|
const char *label;
|
2009-01-08 06:29:13 -08:00
|
|
|
Evas_Object *icon, *end;
|
2009-01-07 05:49:08 -08:00
|
|
|
void (*func) (void *data, Evas_Object *obj, void *event_info);
|
|
|
|
const void *data;
|
|
|
|
Evas_Bool even : 1;
|
|
|
|
Evas_Bool is_even : 1;
|
|
|
|
Evas_Bool fixed : 1;
|
|
|
|
Evas_Bool selected : 1;
|
2009-01-08 19:03:36 -08:00
|
|
|
Evas_Bool dummy_icon : 1;
|
|
|
|
Evas_Bool dummy_end : 1;
|
2009-01-07 05:49:08 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
static void _del_hook(Evas_Object *obj);
|
|
|
|
static void _sizing_eval(Evas_Object *obj);
|
|
|
|
static void _on_focus_hook(void *data, Evas_Object *obj);
|
2009-01-25 15:18:25 -08:00
|
|
|
static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
|
|
|
|
static void _sub_del(void *data, Evas_Object *obj, void *event_info);
|
|
|
|
|
|
|
|
static void _fix_items(Evas_Object *obj);
|
2009-01-07 05:49:08 -08:00
|
|
|
|
|
|
|
static void
|
|
|
|
_del_hook(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2009-01-08 23:35:52 -08:00
|
|
|
while (wd->items)
|
|
|
|
{
|
|
|
|
Item *it = wd->items->data;
|
|
|
|
wd->items = eina_list_remove_list(wd->items, wd->items);
|
|
|
|
eina_stringshare_del(it->label);
|
|
|
|
if (!it->fixed)
|
|
|
|
{
|
|
|
|
if (it->icon) evas_object_del(it->icon);
|
|
|
|
if (it->end) evas_object_del(it->end);
|
|
|
|
}
|
|
|
|
if (it->base) evas_object_del(it->base);
|
|
|
|
free(it);
|
|
|
|
}
|
|
|
|
eina_list_free(wd->selected);
|
2009-01-07 05:49:08 -08:00
|
|
|
free(wd);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_sizing_eval(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
|
|
|
|
|
2009-01-08 19:03:36 -08:00
|
|
|
evas_object_size_hint_min_get(wd->scroller, &minw, &minh);
|
|
|
|
evas_object_size_hint_max_get(wd->scroller, &maxw, &maxh);
|
2009-01-07 05:49:08 -08:00
|
|
|
evas_object_size_hint_min_set(obj, minw, minh);
|
|
|
|
evas_object_size_hint_max_set(obj, maxw, maxh);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_on_focus_hook(void *data, Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
// if (elm_widget_focus_get(obj))
|
|
|
|
// elm_widget_focus_steal(wd->entry);
|
|
|
|
}
|
|
|
|
|
2009-01-25 15:18:25 -08:00
|
|
|
static void
|
|
|
|
_changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
2009-02-11 03:49:43 -08:00
|
|
|
// _fix_items(data);
|
|
|
|
// _sizing_eval(data);
|
2009-01-25 15:18:25 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_sub_del(void *data, Evas_Object *obj, void *event_info)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
Evas_Object *sub = event_info;
|
|
|
|
Eina_List *l;
|
|
|
|
|
|
|
|
for (l = wd->items; l; l = l->next)
|
|
|
|
{
|
|
|
|
Item *it = l->data;
|
|
|
|
|
|
|
|
if ((sub == it->icon) || (sub == it->end))
|
|
|
|
{
|
|
|
|
if (it->icon == sub) it->icon = NULL;
|
|
|
|
if (it->end == sub) it->end = NULL;
|
|
|
|
evas_object_event_callback_del
|
|
|
|
(sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints);
|
|
|
|
_fix_items(obj);
|
|
|
|
_sizing_eval(obj);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-07 05:49:08 -08:00
|
|
|
static void
|
|
|
|
_mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event_info)
|
|
|
|
{
|
|
|
|
Item *it = data;
|
|
|
|
Widget_Data *wd = elm_widget_data_get(it->obj);
|
|
|
|
Evas_Event_Mouse_Down *ev = event_info;
|
|
|
|
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) wd->on_hold = 1;
|
|
|
|
else wd->on_hold = 0;
|
|
|
|
if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
|
|
|
|
evas_object_smart_callback_call(it->obj, "clicked", it);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_item_select(Item *it)
|
|
|
|
{
|
2009-01-08 23:35:52 -08:00
|
|
|
Widget_Data *wd = elm_widget_data_get(it->obj);
|
2009-01-07 05:49:08 -08:00
|
|
|
const char *selectraise;
|
|
|
|
if (it->selected) return;
|
|
|
|
edje_object_signal_emit(it->base, "elm,state,selected", "elm");
|
|
|
|
selectraise = edje_object_data_get(it->base, "selectraise");
|
|
|
|
if ((selectraise) && (!strcmp(selectraise, "on")))
|
|
|
|
evas_object_raise(it->base);
|
|
|
|
it->selected = 1;
|
2009-01-08 23:35:52 -08:00
|
|
|
wd->selected = eina_list_append(wd->selected, it);
|
2009-01-08 06:29:13 -08:00
|
|
|
if (it->func) it->func((void *)it->data, it->obj, it);
|
2009-01-08 23:35:52 -08:00
|
|
|
evas_object_smart_callback_call(it->obj, "selected", it);
|
2009-01-07 05:49:08 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_item_unselect(Item *it)
|
|
|
|
{
|
2009-01-08 23:35:52 -08:00
|
|
|
Widget_Data *wd = elm_widget_data_get(it->obj);
|
2009-01-07 05:49:08 -08:00
|
|
|
const char *stacking, *selectraise;
|
|
|
|
if (!it->selected) return;
|
|
|
|
edje_object_signal_emit(it->base, "elm,state,unselected", "elm");
|
|
|
|
stacking = edje_object_data_get(it->base, "stacking");
|
|
|
|
selectraise = edje_object_data_get(it->base, "selectraise");
|
|
|
|
if ((selectraise) && (!strcmp(selectraise, "on")))
|
|
|
|
{
|
|
|
|
if ((stacking) && (!strcmp(stacking, "below")))
|
|
|
|
evas_object_lower(it->base);
|
|
|
|
}
|
|
|
|
it->selected = 0;
|
2009-01-08 23:35:52 -08:00
|
|
|
wd->selected = eina_list_remove(wd->selected, it);
|
|
|
|
evas_object_smart_callback_call(it->obj, "unselected", it);
|
2009-01-07 05:49:08 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_mouse_up(void *data, Evas *evas, Evas_Object *obj, void *event_info)
|
|
|
|
{
|
|
|
|
Item *it = data;
|
|
|
|
Widget_Data *wd = elm_widget_data_get(it->obj);
|
|
|
|
Evas_Event_Mouse_Up *ev = event_info;
|
|
|
|
Eina_List *l;
|
|
|
|
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) wd->on_hold = 1;
|
|
|
|
else wd->on_hold = 0;
|
|
|
|
if (wd->on_hold)
|
|
|
|
{
|
|
|
|
wd->on_hold = 0;
|
|
|
|
return;
|
|
|
|
}
|
2009-01-08 23:35:52 -08:00
|
|
|
if (wd->multi)
|
|
|
|
{
|
|
|
|
if (!it->selected) _item_select(it);
|
|
|
|
else _item_unselect(it);
|
|
|
|
}
|
|
|
|
else
|
2009-01-07 05:49:08 -08:00
|
|
|
{
|
2009-02-16 23:50:35 -08:00
|
|
|
for (l = wd->selected; l;)
|
2009-01-08 23:35:52 -08:00
|
|
|
{
|
|
|
|
Item *it2 = l->data;
|
2009-02-16 23:50:35 -08:00
|
|
|
l = l->next;
|
2009-01-08 23:35:52 -08:00
|
|
|
if ((it2 != it) && (it2->selected)) _item_unselect(it2);
|
|
|
|
}
|
|
|
|
if (!it->selected) _item_select(it);
|
2009-01-07 05:49:08 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Item *
|
2009-01-08 06:29:13 -08:00
|
|
|
_item_new(Evas_Object *obj, const char *label, Evas_Object *icon, Evas_Object *end, void (*func) (void *data, Evas_Object *obj, void *event_info), const void *data)
|
2009-01-07 05:49:08 -08:00
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
Item *it;
|
|
|
|
|
|
|
|
it = calloc(1, sizeof(Item));
|
|
|
|
it->obj = obj;
|
|
|
|
it->label = eina_stringshare_add(label);
|
|
|
|
it->icon = icon;
|
|
|
|
it->end = end;
|
|
|
|
it->func = func;
|
|
|
|
it->data = data;
|
|
|
|
it->base = edje_object_add(evas_object_evas_get(obj));
|
|
|
|
evas_object_event_callback_add(it->base, EVAS_CALLBACK_MOUSE_DOWN,
|
|
|
|
_mouse_down, it);
|
|
|
|
evas_object_event_callback_add(it->base, EVAS_CALLBACK_MOUSE_UP,
|
|
|
|
_mouse_up, it);
|
|
|
|
evas_object_size_hint_weight_set(it->base, 1.0, 1.0);
|
|
|
|
evas_object_size_hint_align_set(it->base, -1.0, -1.0);
|
2009-01-25 15:18:25 -08:00
|
|
|
if (it->icon)
|
|
|
|
{
|
|
|
|
elm_widget_sub_object_add(obj, it->icon);
|
|
|
|
evas_object_event_callback_add(it->icon, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
|
|
|
|
_changed_size_hints, obj);
|
|
|
|
}
|
|
|
|
if (it->end)
|
|
|
|
{
|
|
|
|
elm_widget_sub_object_add(obj, it->end);
|
|
|
|
evas_object_event_callback_add(it->end, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
|
|
|
|
_changed_size_hints, obj);
|
|
|
|
}
|
2009-01-07 05:49:08 -08:00
|
|
|
return it;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_fix_items(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
Eina_List *l;
|
2009-01-08 06:29:13 -08:00
|
|
|
Evas_Coord minw[2] = { 0, 0 }, minh[2] = { 0, 0 };
|
2009-01-08 19:03:36 -08:00
|
|
|
Evas_Coord mw, mh;
|
2009-01-08 06:29:13 -08:00
|
|
|
int i, redo = 0;
|
2009-01-07 05:49:08 -08:00
|
|
|
|
2009-01-08 06:29:13 -08:00
|
|
|
for (l = wd->items; l; l = l->next)
|
|
|
|
{
|
|
|
|
Evas_Coord mw, mh;
|
|
|
|
Item *it = l->data;
|
|
|
|
if (it->icon)
|
|
|
|
{
|
|
|
|
evas_object_size_hint_min_get(it->icon, &mw, &mh);
|
|
|
|
if (mw > minw[0]) minw[0] = mw;
|
|
|
|
if (mh > minh[0]) minh[0] = mh;
|
|
|
|
}
|
|
|
|
if (it->end)
|
|
|
|
{
|
|
|
|
evas_object_size_hint_min_get(it->end, &mw, &mh);
|
|
|
|
if (mw > minw[1]) minw[1] = mw;
|
|
|
|
if (mh > minh[1]) minh[1] = mh;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((minw[0] != wd->minw[0]) || (minw[1] != wd->minw[1]) ||
|
|
|
|
(minw[0] != wd->minh[0]) || (minh[1] != wd->minh[1]))
|
|
|
|
{
|
|
|
|
wd->minw[0] = minw[0];
|
|
|
|
wd->minw[1] = minw[1];
|
|
|
|
wd->minh[0] = minh[0];
|
|
|
|
wd->minh[1] = minh[1];
|
|
|
|
redo = 1;
|
|
|
|
}
|
2009-01-07 05:49:08 -08:00
|
|
|
for (i = 0, l = wd->items; l; l = l->next, i++)
|
|
|
|
{
|
|
|
|
Item *it = l->data;
|
|
|
|
it->even = i & 0x1;
|
2009-01-08 06:29:13 -08:00
|
|
|
if ((it->even != it->is_even) || (!it->fixed) || (redo))
|
2009-01-07 05:49:08 -08:00
|
|
|
{
|
|
|
|
const char *stacking;
|
2009-01-08 19:03:36 -08:00
|
|
|
|
|
|
|
if (wd->mode == ELM_LIST_COMPRESS)
|
|
|
|
{
|
|
|
|
if (it->even)
|
|
|
|
_elm_theme_set(it->base, "list", "item_compress", "default");
|
|
|
|
else
|
|
|
|
_elm_theme_set(it->base, "list", "item_compress_odd", "default");
|
|
|
|
}
|
2009-01-07 05:49:08 -08:00
|
|
|
else
|
2009-01-08 19:03:36 -08:00
|
|
|
{
|
|
|
|
if (it->even)
|
|
|
|
_elm_theme_set(it->base, "list", "item", "default");
|
|
|
|
else
|
|
|
|
_elm_theme_set(it->base, "list", "item_odd", "default");
|
|
|
|
}
|
2009-01-07 05:49:08 -08:00
|
|
|
stacking = edje_object_data_get(it->base, "stacking");
|
|
|
|
if (stacking)
|
|
|
|
{
|
|
|
|
if (!strcmp(stacking, "below"))
|
|
|
|
evas_object_lower(it->base);
|
|
|
|
else if (!strcmp(stacking, "above"))
|
|
|
|
evas_object_raise(it->base);
|
|
|
|
}
|
|
|
|
edje_object_part_text_set(it->base, "elm.text", it->label);
|
2009-01-08 19:03:36 -08:00
|
|
|
if ((!it->icon) && (minh[0] > 0))
|
2009-01-08 06:29:13 -08:00
|
|
|
{
|
|
|
|
it->icon = evas_object_rectangle_add(evas_object_evas_get(it->base));
|
|
|
|
evas_object_color_set(it->icon, 0, 0, 0, 0);
|
2009-01-08 19:03:36 -08:00
|
|
|
it->dummy_icon = 1;
|
2009-01-08 06:29:13 -08:00
|
|
|
}
|
2009-01-08 19:03:36 -08:00
|
|
|
if ((!it->end) && (minh[1] > 0))
|
2009-01-08 06:29:13 -08:00
|
|
|
{
|
|
|
|
it->end = evas_object_rectangle_add(evas_object_evas_get(it->base));
|
|
|
|
evas_object_color_set(it->end, 0, 0, 0, 0);
|
2009-01-08 19:03:36 -08:00
|
|
|
it->dummy_end = 1;
|
2009-01-08 06:29:13 -08:00
|
|
|
}
|
|
|
|
if (it->icon)
|
|
|
|
{
|
2009-02-11 03:49:43 -08:00
|
|
|
evas_object_size_hint_min_set(it->icon, minw[0], minh[0]);
|
|
|
|
evas_object_size_hint_max_set(it->icon, 99999, 99999);
|
2009-01-08 06:29:13 -08:00
|
|
|
edje_object_part_swallow(it->base, "elm.swallow.icon", it->icon);
|
|
|
|
}
|
|
|
|
if (it->end)
|
|
|
|
{
|
2009-02-11 03:49:43 -08:00
|
|
|
evas_object_size_hint_min_set(it->end, minw[1], minh[1]);
|
|
|
|
evas_object_size_hint_max_set(it->end, 99999, 99999);
|
2009-01-08 06:29:13 -08:00
|
|
|
edje_object_part_swallow(it->base, "elm.swallow.end", it->end);
|
|
|
|
}
|
2009-01-07 05:49:08 -08:00
|
|
|
if (!it->fixed)
|
|
|
|
{
|
|
|
|
edje_object_message_signal_process(it->base);
|
2009-02-11 03:49:43 -08:00
|
|
|
mw = mh = -1;
|
|
|
|
elm_coords_finger_size_adjust(1, &mw, 1, &mh);
|
|
|
|
edje_object_size_min_restricted_calc(it->base, &mw, &mh, mw, mh);
|
|
|
|
elm_coords_finger_size_adjust(1, &mw, 1, &mh);
|
2009-01-08 19:03:36 -08:00
|
|
|
evas_object_size_hint_min_set(it->base, mw, mh);
|
2009-01-07 05:49:08 -08:00
|
|
|
evas_object_show(it->base);
|
|
|
|
}
|
|
|
|
it->fixed = 1;
|
|
|
|
it->is_even = it->even;
|
|
|
|
}
|
|
|
|
}
|
2009-01-08 19:03:36 -08:00
|
|
|
mw = 0; mh = 0;
|
|
|
|
evas_object_size_hint_min_get(wd->box, &mw, &mh);
|
|
|
|
if (wd->mode == ELM_LIST_LIMIT)
|
|
|
|
elm_scroller_content_min_limit(wd->scroller, 1, 0);
|
|
|
|
else
|
|
|
|
elm_scroller_content_min_limit(wd->scroller, 0, 0);
|
2009-01-07 05:49:08 -08:00
|
|
|
_sizing_eval(obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI Evas_Object *
|
|
|
|
elm_list_add(Evas_Object *parent)
|
|
|
|
{
|
|
|
|
Evas_Object *obj;
|
|
|
|
Evas *e;
|
|
|
|
Widget_Data *wd;
|
|
|
|
|
|
|
|
wd = ELM_NEW(Widget_Data);
|
|
|
|
e = evas_object_evas_get(parent);
|
|
|
|
obj = elm_widget_add(e);
|
|
|
|
elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
|
|
|
|
elm_widget_data_set(obj, wd);
|
|
|
|
elm_widget_del_hook_set(obj, _del_hook);
|
|
|
|
elm_widget_can_focus_set(obj, 1);
|
|
|
|
|
|
|
|
wd->scroller = elm_scroller_add(parent);
|
|
|
|
elm_widget_resize_object_set(obj, wd->scroller);
|
|
|
|
|
|
|
|
wd->box = elm_box_add(parent);
|
2009-01-08 06:29:13 -08:00
|
|
|
elm_box_homogenous_set(wd->box, 1);
|
2009-01-07 05:49:08 -08:00
|
|
|
evas_object_size_hint_weight_set(wd->box, 1.0, 0.0);
|
|
|
|
evas_object_size_hint_align_set(wd->box, -1.0, 0.0);
|
|
|
|
elm_scroller_content_set(wd->scroller, wd->box);
|
|
|
|
evas_object_show(wd->box);
|
|
|
|
|
2009-01-08 06:29:13 -08:00
|
|
|
wd->mode = ELM_LIST_SCROLL;
|
2009-01-25 15:18:25 -08:00
|
|
|
|
|
|
|
evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
|
2009-01-07 05:49:08 -08:00
|
|
|
|
|
|
|
_sizing_eval(obj);
|
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI Elm_List_Item *
|
2009-01-08 06:29:13 -08:00
|
|
|
elm_list_item_append(Evas_Object *obj, const char *label, Evas_Object *icon, Evas_Object *end, void (*func) (void *data, Evas_Object *obj, void *event_info), const void *data)
|
2009-01-07 05:49:08 -08:00
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2009-01-08 06:29:13 -08:00
|
|
|
Item *it = _item_new(obj, label, icon, end, func, data);
|
2009-01-07 05:49:08 -08:00
|
|
|
wd->items = eina_list_append(wd->items, it);
|
|
|
|
elm_box_pack_end(wd->box, it->base);
|
|
|
|
return (Elm_List_Item *)it;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI Elm_List_Item *
|
2009-01-08 06:29:13 -08:00
|
|
|
elm_list_item_prepend(Evas_Object *obj, const char *label, Evas_Object *icon, Evas_Object *end, void (*func) (void *data, Evas_Object *obj, void *event_info), const void *data)
|
2009-01-07 05:49:08 -08:00
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2009-01-08 06:29:13 -08:00
|
|
|
Item *it = _item_new(obj, label, icon, end, func, data);
|
|
|
|
wd->items = eina_list_prepend(wd->items, it);
|
|
|
|
elm_box_pack_start(wd->box, it->base);
|
|
|
|
return (Elm_List_Item *)it;
|
2009-01-07 05:49:08 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI Elm_List_Item *
|
2009-01-08 06:29:13 -08:00
|
|
|
elm_list_item_insert_before(Evas_Object *obj, Elm_List_Item *before, const char *label, Evas_Object *icon, Evas_Object *end, void (*func) (void *data, Evas_Object *obj, void *event_info), const void *data)
|
2009-01-07 05:49:08 -08:00
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2009-01-08 06:29:13 -08:00
|
|
|
Item *it = _item_new(obj, label, icon, end, func, data);
|
|
|
|
wd->items = eina_list_prepend_relative(wd->items, it, before);
|
|
|
|
elm_box_pack_before(wd->box, it->base, ((Item *)before)->base);
|
|
|
|
return (Elm_List_Item *)it;
|
2009-01-07 05:49:08 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI Elm_List_Item *
|
2009-01-08 06:29:13 -08:00
|
|
|
elm_list_item_insert_after(Evas_Object *obj, Elm_List_Item *after, const char *label, Evas_Object *icon, Evas_Object *end, void (*func) (void *data, Evas_Object *obj, void *event_info), const void *data)
|
2009-01-07 05:49:08 -08:00
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2009-01-08 06:29:13 -08:00
|
|
|
Item *it = _item_new(obj, label, icon, end, func, data);
|
|
|
|
wd->items = eina_list_append_relative(wd->items, it, after);
|
|
|
|
elm_box_pack_after(wd->box, it->base, ((Item *)after)->base);
|
|
|
|
return (Elm_List_Item *)it;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
elm_list_go(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
_fix_items(obj);
|
2009-01-07 05:49:08 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
elm_list_multi_select_set(Evas_Object *obj, Evas_Bool multi)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2009-01-08 23:35:52 -08:00
|
|
|
wd->multi = multi;
|
2009-01-07 05:49:08 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
elm_list_horizontal_mode_set(Evas_Object *obj, Elementary_List_Mode mode)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2009-01-08 06:29:13 -08:00
|
|
|
if (wd->mode == mode) return;
|
|
|
|
wd->mode = mode;
|
2009-01-08 19:03:36 -08:00
|
|
|
if (wd->mode == ELM_LIST_LIMIT)
|
|
|
|
elm_scroller_content_min_limit(wd->scroller, 1, 0);
|
|
|
|
else
|
|
|
|
elm_scroller_content_min_limit(wd->scroller, 0, 0);
|
2009-01-07 05:49:08 -08:00
|
|
|
}
|
|
|
|
|
2009-01-08 23:35:52 -08:00
|
|
|
EAPI const Eina_List *
|
|
|
|
elm_list_items_get(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
return wd->items;
|
|
|
|
}
|
|
|
|
|
2009-01-07 05:49:08 -08:00
|
|
|
EAPI const Elm_List_Item *
|
|
|
|
elm_list_selected_item_get(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2009-01-08 23:35:52 -08:00
|
|
|
if (wd->selected) return wd->selected->data;
|
2009-01-07 05:49:08 -08:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI const Eina_List *
|
2009-01-08 23:35:52 -08:00
|
|
|
elm_list_selected_items_get(Evas_Object *obj)
|
2009-01-07 05:49:08 -08:00
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2009-01-08 23:35:52 -08:00
|
|
|
return wd->selected;
|
2009-01-07 05:49:08 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
elm_list_item_selected_set(Elm_List_Item *item, Evas_Bool selected)
|
|
|
|
{
|
2009-01-08 06:29:13 -08:00
|
|
|
Item *it = (Item *)item;
|
|
|
|
Widget_Data *wd = elm_widget_data_get(it->obj);
|
|
|
|
Eina_List *l;
|
2009-01-08 23:35:52 -08:00
|
|
|
if (selected)
|
2009-01-08 06:29:13 -08:00
|
|
|
{
|
2009-01-08 23:35:52 -08:00
|
|
|
if (!wd->multi)
|
|
|
|
{
|
2009-02-16 23:50:35 -08:00
|
|
|
for (l = it->selected; l;)
|
|
|
|
{
|
|
|
|
Item *it2 = l->data;
|
|
|
|
l = l->next;
|
|
|
|
if ((it2 != it) && (it2->selected)) _item_unselect(it2);
|
|
|
|
}
|
2009-01-08 23:35:52 -08:00
|
|
|
}
|
|
|
|
if (!it->selected) _item_select(it);
|
2009-01-08 06:29:13 -08:00
|
|
|
}
|
2009-01-08 23:35:52 -08:00
|
|
|
else if (it->selected)
|
|
|
|
_item_unselect(it);
|
2009-01-07 05:49:08 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
elm_list_item_show(Elm_List_Item *item)
|
|
|
|
{
|
2009-01-08 23:35:52 -08:00
|
|
|
Item *it = (Item *)item;
|
|
|
|
Widget_Data *wd = elm_widget_data_get(it->obj);
|
|
|
|
Evas_Coord bx, by, bw, bh;
|
|
|
|
Evas_Coord x, y, w, h;
|
|
|
|
evas_object_geometry_get(wd->box, &bx, &by, &bw, &bh);
|
|
|
|
evas_object_geometry_get(it->base, &x, &y, &w, &h);
|
|
|
|
x -= bx;
|
|
|
|
y -= by;
|
|
|
|
elm_scroller_region_show(wd->scroller, x, y, w, h);
|
2009-01-07 05:49:08 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
elm_list_item_del(Elm_List_Item *item)
|
|
|
|
{
|
2009-01-08 23:35:52 -08:00
|
|
|
Item *it = (Item *)item;
|
|
|
|
Widget_Data *wd = elm_widget_data_get(it->obj);
|
|
|
|
if (it->selected) _item_unselect(it);
|
|
|
|
wd->items = eina_list_remove(wd->items, it);
|
|
|
|
eina_stringshare_del(it->label);
|
|
|
|
if (it->icon) evas_object_del(it->icon);
|
|
|
|
if (it->end) evas_object_del(it->end);
|
|
|
|
if (it->base) evas_object_del(it->base);
|
|
|
|
free(it);
|
2009-01-07 05:49:08 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI const void *
|
|
|
|
elm_list_item_data_get(Elm_List_Item *item)
|
|
|
|
{
|
2009-01-08 06:29:13 -08:00
|
|
|
Item *it = (Item *)item;
|
|
|
|
return it->data;
|
2009-01-07 05:49:08 -08:00
|
|
|
}
|
2009-01-08 19:03:36 -08:00
|
|
|
|
|
|
|
EAPI Evas_Object *
|
|
|
|
elm_list_item_icon_get(Elm_List_Item *item)
|
|
|
|
{
|
|
|
|
Item *it = (Item *)item;
|
|
|
|
if (it->dummy_icon) return NULL;
|
|
|
|
return it->icon;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI Evas_Object *
|
|
|
|
elm_list_item_end_get(Elm_List_Item *item)
|
|
|
|
{
|
|
|
|
Item *it = (Item *)item;
|
|
|
|
if (it->dummy_end) return NULL;
|
|
|
|
return it->end;
|
|
|
|
}
|