2008-12-08 01:24:46 -08:00
|
|
|
#include <Elementary.h>
|
|
|
|
#include "elm_priv.h"
|
|
|
|
|
|
|
|
typedef struct _Widget_Data Widget_Data;
|
2011-12-19 17:03:17 -08:00
|
|
|
typedef struct _Elm_Hoversel_Item Elm_Hoversel_Item;
|
2008-12-08 01:24:46 -08:00
|
|
|
|
|
|
|
struct _Widget_Data
|
|
|
|
{
|
2008-12-09 22:33:24 -08:00
|
|
|
Evas_Object *btn, *hover;
|
2008-12-08 01:24:46 -08:00
|
|
|
Evas_Object *hover_parent;
|
2009-01-07 05:49:08 -08:00
|
|
|
Eina_List *items;
|
2010-01-18 02:28:00 -08:00
|
|
|
Eina_Bool horizontal : 1;
|
2010-09-22 10:45:49 -07:00
|
|
|
Eina_Bool expanded : 1;
|
2008-12-15 16:15:34 -08:00
|
|
|
};
|
|
|
|
|
2009-02-25 11:50:45 -08:00
|
|
|
struct _Elm_Hoversel_Item
|
2008-12-15 16:15:34 -08:00
|
|
|
{
|
2011-10-20 17:45:19 -07:00
|
|
|
ELM_WIDGET_ITEM;
|
2008-12-15 16:15:34 -08:00
|
|
|
const char *label;
|
|
|
|
const char *icon_file;
|
2009-08-14 04:17:06 -07:00
|
|
|
const char *icon_group;
|
2008-12-15 16:15:34 -08:00
|
|
|
Elm_Icon_Type icon_type;
|
2010-03-16 08:31:38 -07:00
|
|
|
Evas_Smart_Cb func;
|
2008-12-08 01:24:46 -08:00
|
|
|
};
|
|
|
|
|
2010-03-08 22:15:39 -08:00
|
|
|
static const char *widtype = NULL;
|
2008-12-08 01:24:46 -08:00
|
|
|
static void _del_pre_hook(Evas_Object *obj);
|
|
|
|
static void _del_hook(Evas_Object *obj);
|
2010-09-22 10:45:43 -07:00
|
|
|
static void _activate(Evas_Object *obj);
|
|
|
|
static void _activate_hook(Evas_Object *obj);
|
2009-08-26 09:43:17 -07:00
|
|
|
static void _disable_hook(Evas_Object *obj);
|
2008-12-08 01:24:46 -08:00
|
|
|
static void _sizing_eval(Evas_Object *obj);
|
|
|
|
static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
|
|
|
|
static void _parent_del(void *data, Evas *e, Evas_Object *obj, void *event_info);
|
|
|
|
|
2011-04-15 10:01:39 -07:00
|
|
|
static const char SIG_CLICKED[] = "clicked";
|
|
|
|
static const char SIG_SELECTED[] = "selected";
|
|
|
|
static const char SIG_DISMISSED[] = "dismissed";
|
|
|
|
|
|
|
|
static const Evas_Smart_Cb_Description _signals[] = {
|
|
|
|
{SIG_CLICKED, ""},
|
|
|
|
{SIG_SELECTED, ""},
|
|
|
|
{SIG_DISMISSED, ""},
|
|
|
|
{NULL, NULL}
|
|
|
|
};
|
|
|
|
|
2008-12-08 01:24:46 -08:00
|
|
|
static void
|
|
|
|
_del_pre_hook(Evas_Object *obj)
|
|
|
|
{
|
2010-11-02 04:26:50 -07:00
|
|
|
Elm_Hoversel_Item *item;
|
2008-12-08 01:24:46 -08:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2010-03-09 19:47:33 -08:00
|
|
|
if (!wd) return;
|
2011-10-30 17:13:32 -07:00
|
|
|
evas_object_event_callback_del_full(wd->btn, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
|
|
|
|
_changed_size_hints, obj);
|
2008-12-15 16:15:34 -08:00
|
|
|
elm_hoversel_hover_end(obj);
|
2009-11-13 14:22:05 -08:00
|
|
|
elm_hoversel_hover_parent_set(obj, NULL);
|
2010-11-02 04:26:50 -07:00
|
|
|
EINA_LIST_FREE(wd->items, item)
|
2009-04-22 20:51:50 -07:00
|
|
|
{
|
2010-11-02 04:26:50 -07:00
|
|
|
elm_widget_item_pre_notify_del(item);
|
2011-04-01 04:51:11 -07:00
|
|
|
eina_stringshare_del(item->label);
|
|
|
|
eina_stringshare_del(item->icon_file);
|
|
|
|
eina_stringshare_del(item->icon_group);
|
2010-11-02 04:26:50 -07:00
|
|
|
elm_widget_item_del(item);
|
2009-04-22 20:51:50 -07:00
|
|
|
}
|
2009-11-13 14:22:05 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_del_hook(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2010-03-09 19:47:33 -08:00
|
|
|
if (!wd) return;
|
2008-12-08 01:24:46 -08:00
|
|
|
free(wd);
|
|
|
|
}
|
|
|
|
|
2011-02-08 04:08:28 -08:00
|
|
|
static void
|
|
|
|
_mirrored_set(Evas_Object *obj, Eina_Bool rtl)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
if (!wd) return;
|
|
|
|
elm_widget_mirrored_set(wd->btn, rtl);
|
|
|
|
elm_widget_mirrored_set(wd->hover, rtl);
|
|
|
|
}
|
|
|
|
|
2009-09-02 05:48:00 -07:00
|
|
|
static void
|
|
|
|
_theme_hook(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
char buf[4096];
|
|
|
|
if (!wd) return;
|
2011-02-09 08:14:02 -08:00
|
|
|
_elm_widget_mirrored_reload(obj);
|
2011-02-10 07:13:05 -08:00
|
|
|
|
2010-01-18 02:28:00 -08:00
|
|
|
elm_hoversel_hover_end(obj);
|
|
|
|
if (wd->horizontal)
|
2011-04-01 04:51:11 -07:00
|
|
|
snprintf(buf, sizeof(buf), "hoversel_horizontal/%s", elm_widget_style_get(obj));
|
2010-01-18 02:28:00 -08:00
|
|
|
else
|
2011-04-01 04:51:11 -07:00
|
|
|
snprintf(buf, sizeof(buf), "hoversel_vertical/%s", elm_widget_style_get(obj));
|
2009-10-17 22:49:23 -07:00
|
|
|
elm_object_style_set(wd->btn, buf);
|
2010-10-07 00:44:50 -07:00
|
|
|
elm_object_disabled_set(wd->btn, elm_widget_disabled_get(obj));
|
2011-02-08 04:08:28 -08:00
|
|
|
_mirrored_set(obj, elm_widget_mirrored_get(obj));
|
2009-09-02 05:48:00 -07:00
|
|
|
}
|
|
|
|
|
2009-08-26 09:43:17 -07:00
|
|
|
static void
|
|
|
|
_disable_hook(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2010-03-09 19:47:33 -08:00
|
|
|
if (!wd) return;
|
2010-10-07 00:44:50 -07:00
|
|
|
elm_object_disabled_set(wd->btn, elm_widget_disabled_get(obj));
|
2009-08-26 09:43:17 -07:00
|
|
|
}
|
|
|
|
|
2008-12-08 01:24:46 -08:00
|
|
|
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-09-27 13:10:03 -07:00
|
|
|
if (!wd) return;
|
2008-12-09 22:33:24 -08:00
|
|
|
evas_object_size_hint_min_get(wd->btn, &minw, &minh);
|
|
|
|
evas_object_size_hint_max_get(wd->btn, &maxw, &maxh);
|
2008-12-08 01:24:46 -08:00
|
|
|
evas_object_size_hint_min_set(obj, minw, minh);
|
|
|
|
evas_object_size_hint_max_set(obj, maxw, maxh);
|
|
|
|
}
|
|
|
|
|
2010-10-05 12:09:52 -07:00
|
|
|
static void
|
|
|
|
_on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
if (!wd) return;
|
|
|
|
if (elm_widget_focus_get(obj))
|
|
|
|
elm_widget_focus_steal(wd->btn);
|
|
|
|
}
|
|
|
|
|
2008-12-08 01:24:46 -08:00
|
|
|
static void
|
2010-03-09 09:51:30 -08:00
|
|
|
_changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
|
2008-12-08 01:24:46 -08:00
|
|
|
{
|
|
|
|
_sizing_eval(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-03-09 09:51:30 -08:00
|
|
|
_hover_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
|
2008-12-08 01:24:46 -08:00
|
|
|
{
|
|
|
|
elm_hoversel_hover_end(data);
|
|
|
|
}
|
|
|
|
|
2008-12-15 16:15:34 -08:00
|
|
|
static void
|
2010-03-09 09:51:30 -08:00
|
|
|
_item_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
|
2008-12-15 16:15:34 -08:00
|
|
|
{
|
2010-11-02 04:26:50 -07:00
|
|
|
Elm_Hoversel_Item *item = data;
|
2011-10-20 18:08:01 -07:00
|
|
|
Evas_Object *obj2 = WIDGET(item);
|
2009-09-27 13:10:03 -07:00
|
|
|
|
2008-12-23 21:04:33 -08:00
|
|
|
elm_hoversel_hover_end(obj2);
|
2010-11-02 04:26:50 -07:00
|
|
|
if (item->func) item->func((void *)item->base.data, obj2, item);
|
2011-04-15 10:01:39 -07:00
|
|
|
evas_object_smart_callback_call(obj2, SIG_SELECTED, item);
|
2008-12-15 16:15:34 -08:00
|
|
|
}
|
|
|
|
|
2008-12-09 22:33:24 -08:00
|
|
|
static void
|
2009-03-19 06:36:46 -07:00
|
|
|
_activate(Evas_Object *obj)
|
2008-12-09 22:33:24 -08:00
|
|
|
{
|
2009-03-19 06:36:46 -07:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2008-12-09 22:33:24 -08:00
|
|
|
Evas_Object *bt, *bx, *ic;
|
2009-02-25 11:50:45 -08:00
|
|
|
const Eina_List *l;
|
2010-11-02 04:26:50 -07:00
|
|
|
const Elm_Hoversel_Item *item;
|
2009-09-02 05:48:00 -07:00
|
|
|
char buf[4096];
|
2009-02-25 11:50:45 -08:00
|
|
|
|
2009-09-27 13:10:03 -07:00
|
|
|
if (!wd) return;
|
2010-09-22 10:45:49 -07:00
|
|
|
if (wd->expanded)
|
|
|
|
{
|
|
|
|
elm_hoversel_hover_end(obj);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
wd->expanded = EINA_TRUE;
|
|
|
|
|
2009-09-27 13:10:03 -07:00
|
|
|
if (elm_widget_disabled_get(obj)) return;
|
2009-03-19 06:36:46 -07:00
|
|
|
wd->hover = elm_hover_add(obj);
|
2011-02-10 07:13:05 -08:00
|
|
|
elm_widget_mirrored_automatic_set(wd->hover, EINA_FALSE);
|
2010-01-18 02:28:00 -08:00
|
|
|
if (wd->horizontal)
|
|
|
|
snprintf(buf, sizeof(buf), "hoversel_horizontal/%s", elm_widget_style_get(obj));
|
|
|
|
else
|
|
|
|
snprintf(buf, sizeof(buf), "hoversel_vertical/%s", elm_widget_style_get(obj));
|
2009-10-17 22:52:20 -07:00
|
|
|
elm_object_style_set(wd->hover, buf);
|
2009-03-19 06:36:46 -07:00
|
|
|
evas_object_smart_callback_add(wd->hover, "clicked", _hover_clicked, obj);
|
2008-12-09 22:33:24 -08:00
|
|
|
elm_hover_parent_set(wd->hover, wd->hover_parent);
|
|
|
|
elm_hover_target_set(wd->hover, wd->btn);
|
|
|
|
|
|
|
|
bx = elm_box_add(wd->hover);
|
2011-02-10 07:13:05 -08:00
|
|
|
elm_widget_mirrored_automatic_set(bx, EINA_FALSE);
|
2011-05-03 21:53:39 -07:00
|
|
|
elm_box_homogeneous_set(bx, 1);
|
2011-04-01 04:51:11 -07:00
|
|
|
|
2010-01-18 02:28:00 -08:00
|
|
|
elm_box_horizontal_set(bx, wd->horizontal);
|
2011-04-01 04:51:11 -07:00
|
|
|
|
2010-01-18 02:28:00 -08:00
|
|
|
if (wd->horizontal)
|
|
|
|
snprintf(buf, sizeof(buf), "hoversel_horizontal_entry/%s",
|
|
|
|
elm_widget_style_get(obj));
|
|
|
|
else
|
|
|
|
snprintf(buf, sizeof(buf), "hoversel_vertical_entry/%s",
|
|
|
|
elm_widget_style_get(obj));
|
2010-11-02 04:26:50 -07:00
|
|
|
EINA_LIST_FOREACH(wd->items, l, item)
|
2008-12-15 16:15:34 -08:00
|
|
|
{
|
2011-04-01 04:51:11 -07:00
|
|
|
bt = elm_button_add(wd->hover);
|
2011-02-10 07:13:05 -08:00
|
|
|
elm_widget_mirrored_automatic_set(bt, EINA_FALSE);
|
2011-02-08 04:08:28 -08:00
|
|
|
elm_widget_mirrored_set(bt, elm_widget_mirrored_get(obj));
|
2011-04-01 04:51:11 -07:00
|
|
|
elm_object_style_set(bt, buf);
|
2011-06-29 02:31:01 -07:00
|
|
|
elm_object_text_set(bt, item->label);
|
2011-04-01 04:51:11 -07:00
|
|
|
if (item->icon_file)
|
|
|
|
{
|
|
|
|
ic = elm_icon_add(obj);
|
|
|
|
elm_icon_scale_set(ic, 0, 1);
|
|
|
|
if (item->icon_type == ELM_ICON_FILE)
|
|
|
|
elm_icon_file_set(ic, item->icon_file, item->icon_group);
|
|
|
|
else if (item->icon_type == ELM_ICON_STANDARD)
|
|
|
|
elm_icon_standard_set(ic, item->icon_file);
|
2011-11-17 13:02:31 -08:00
|
|
|
elm_object_part_content_set(bt, "icon", ic);
|
2011-04-01 04:51:11 -07:00
|
|
|
evas_object_show(ic);
|
|
|
|
}
|
|
|
|
evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
|
|
|
|
evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
elm_box_pack_end(bx, bt);
|
|
|
|
evas_object_smart_callback_add(bt, "clicked", _item_clicked, item);
|
|
|
|
evas_object_show(bt);
|
2008-12-15 16:15:34 -08:00
|
|
|
}
|
2008-12-09 22:33:24 -08:00
|
|
|
|
2010-01-18 02:28:00 -08:00
|
|
|
if (wd->horizontal)
|
|
|
|
elm_hover_content_set(wd->hover,
|
|
|
|
elm_hover_best_content_location_get(wd->hover,
|
|
|
|
ELM_HOVER_AXIS_HORIZONTAL),
|
|
|
|
bx);
|
|
|
|
else
|
|
|
|
elm_hover_content_set(wd->hover,
|
|
|
|
elm_hover_best_content_location_get(wd->hover,
|
|
|
|
ELM_HOVER_AXIS_VERTICAL),
|
|
|
|
bx);
|
2008-12-09 22:33:24 -08:00
|
|
|
evas_object_show(bx);
|
2009-07-06 23:46:51 -07:00
|
|
|
|
2008-12-09 22:33:24 -08:00
|
|
|
evas_object_show(wd->hover);
|
2011-04-15 10:01:39 -07:00
|
|
|
evas_object_smart_callback_call(obj, SIG_CLICKED, NULL);
|
2010-01-13 19:47:28 -08:00
|
|
|
|
2011-04-01 04:51:11 -07:00
|
|
|
// if (wd->horizontal) evas_object_hide(wd->btn);
|
2009-03-19 06:36:46 -07:00
|
|
|
}
|
|
|
|
|
2010-09-22 10:45:43 -07:00
|
|
|
static void
|
|
|
|
_activate_hook(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
_activate(obj);
|
|
|
|
}
|
|
|
|
|
2009-03-19 06:36:46 -07:00
|
|
|
static void
|
2010-03-09 09:51:30 -08:00
|
|
|
_button_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
|
2009-03-19 06:36:46 -07:00
|
|
|
{
|
2010-03-09 19:47:33 -08:00
|
|
|
_activate(data);
|
2008-12-09 22:33:24 -08:00
|
|
|
}
|
|
|
|
|
2008-12-08 01:24:46 -08:00
|
|
|
static void
|
2010-03-09 09:51:30 -08:00
|
|
|
_parent_del(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
|
2008-12-08 01:24:46 -08:00
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
2009-01-08 06:29:13 -08:00
|
|
|
if (!wd) return;
|
2008-12-08 01:24:46 -08:00
|
|
|
wd->hover_parent = NULL;
|
|
|
|
}
|
|
|
|
|
2011-06-29 22:43:56 -07:00
|
|
|
static void
|
|
|
|
_elm_hoversel_label_set(Evas_Object *obj, const char *item, const char *label)
|
|
|
|
{
|
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2011-07-04 03:52:23 -07:00
|
|
|
if (item && strcmp(item, "default")) return;
|
2011-06-29 22:43:56 -07:00
|
|
|
if (!wd) return;
|
|
|
|
elm_object_text_set(wd->btn, label);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char *
|
|
|
|
_elm_hoversel_label_get(const Evas_Object *obj, const char *item)
|
|
|
|
{
|
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2011-07-04 03:52:23 -07:00
|
|
|
if (item && strcmp(item, "default")) return NULL;
|
2011-06-29 22:43:56 -07:00
|
|
|
if ((!wd) || (!wd->btn)) return NULL;
|
|
|
|
return elm_object_text_get(wd->btn);
|
|
|
|
}
|
|
|
|
|
2008-12-08 01:24:46 -08:00
|
|
|
EAPI Evas_Object *
|
|
|
|
elm_hoversel_add(Evas_Object *parent)
|
|
|
|
{
|
|
|
|
Evas_Object *obj;
|
|
|
|
Evas *e;
|
|
|
|
Widget_Data *wd;
|
2009-07-06 23:46:51 -07:00
|
|
|
|
2011-03-31 23:08:02 -07:00
|
|
|
ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
|
2011-04-01 04:51:11 -07:00
|
|
|
|
2010-03-08 22:15:39 -08:00
|
|
|
ELM_SET_WIDTYPE(widtype, "hoversel");
|
2009-05-13 05:21:52 -07:00
|
|
|
elm_widget_type_set(obj, "hoversel");
|
|
|
|
elm_widget_sub_object_add(parent, obj);
|
2008-12-08 01:24:46 -08:00
|
|
|
elm_widget_data_set(obj, wd);
|
|
|
|
elm_widget_del_pre_hook_set(obj, _del_pre_hook);
|
|
|
|
elm_widget_del_hook_set(obj, _del_hook);
|
2010-01-14 12:06:41 -08:00
|
|
|
elm_widget_theme_hook_set(obj, _theme_hook);
|
2009-08-26 09:43:17 -07:00
|
|
|
elm_widget_disable_hook_set(obj, _disable_hook);
|
2010-09-22 10:45:43 -07:00
|
|
|
elm_widget_activate_hook_set(obj, _activate_hook);
|
2010-10-05 12:09:52 -07:00
|
|
|
elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
|
|
|
|
elm_widget_can_focus_set(obj, EINA_TRUE);
|
2011-07-04 02:18:16 -07:00
|
|
|
elm_widget_text_set_hook_set(obj, _elm_hoversel_label_set);
|
|
|
|
elm_widget_text_get_hook_set(obj, _elm_hoversel_label_get);
|
2009-07-06 23:46:51 -07:00
|
|
|
|
2008-12-09 22:33:24 -08:00
|
|
|
wd->btn = elm_button_add(parent);
|
2011-02-10 07:13:05 -08:00
|
|
|
elm_widget_mirrored_automatic_set(wd->btn, EINA_FALSE);
|
2010-09-22 10:45:49 -07:00
|
|
|
wd->expanded = EINA_FALSE;
|
2008-12-09 22:33:24 -08:00
|
|
|
elm_widget_resize_object_set(obj, wd->btn);
|
|
|
|
evas_object_event_callback_add(wd->btn, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
|
2011-04-01 04:51:11 -07:00
|
|
|
_changed_size_hints, obj);
|
2008-12-09 22:33:24 -08:00
|
|
|
evas_object_smart_callback_add(wd->btn, "clicked", _button_clicked, obj);
|
2011-04-15 10:01:39 -07:00
|
|
|
evas_object_smart_callbacks_descriptions_set(obj, _signals);
|
|
|
|
|
2010-10-19 07:17:11 -07:00
|
|
|
elm_widget_sub_object_add(obj, wd->btn);
|
|
|
|
|
2010-07-17 01:54:51 -07:00
|
|
|
elm_hoversel_hover_parent_set(obj, parent);
|
2010-10-19 07:17:11 -07:00
|
|
|
_theme_hook(obj);
|
2011-04-15 10:01:39 -07:00
|
|
|
|
2008-12-08 01:24:46 -08:00
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
elm_hoversel_hover_parent_set(Evas_Object *obj, Evas_Object *parent)
|
|
|
|
{
|
2010-03-08 22:15:39 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
2008-12-08 01:24:46 -08:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2009-01-08 06:29:13 -08:00
|
|
|
if (!wd) return;
|
2008-12-08 01:24:46 -08:00
|
|
|
if (wd->hover_parent)
|
2009-10-22 15:10:23 -07:00
|
|
|
evas_object_event_callback_del_full(wd->hover_parent, EVAS_CALLBACK_DEL,
|
2011-04-01 04:51:11 -07:00
|
|
|
_parent_del, obj);
|
2008-12-08 01:24:46 -08:00
|
|
|
wd->hover_parent = parent;
|
|
|
|
if (wd->hover_parent)
|
2009-10-22 15:10:23 -07:00
|
|
|
evas_object_event_callback_add(wd->hover_parent, EVAS_CALLBACK_DEL,
|
2009-09-27 13:10:03 -07:00
|
|
|
_parent_del, obj);
|
2008-12-08 01:24:46 -08:00
|
|
|
}
|
|
|
|
|
2010-10-14 11:54:42 -07:00
|
|
|
EAPI Evas_Object *
|
|
|
|
elm_hoversel_hover_parent_get(const Evas_Object *obj)
|
|
|
|
{
|
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
if (!wd) return NULL;
|
|
|
|
return wd->hover_parent;
|
|
|
|
}
|
|
|
|
|
2008-12-08 01:24:46 -08:00
|
|
|
EAPI void
|
2008-12-09 22:33:24 -08:00
|
|
|
elm_hoversel_label_set(Evas_Object *obj, const char *label)
|
2008-12-08 01:24:46 -08:00
|
|
|
{
|
2011-06-29 22:43:56 -07:00
|
|
|
_elm_hoversel_label_set(obj, NULL, label);
|
2008-12-09 22:33:24 -08:00
|
|
|
}
|
|
|
|
|
2010-04-07 00:37:49 -07:00
|
|
|
EAPI const char *
|
|
|
|
elm_hoversel_label_get(const Evas_Object *obj)
|
|
|
|
{
|
2011-06-29 22:43:56 -07:00
|
|
|
return _elm_hoversel_label_get(obj, NULL);
|
2010-04-07 00:37:49 -07:00
|
|
|
}
|
|
|
|
|
2010-01-13 19:47:28 -08:00
|
|
|
EAPI void
|
|
|
|
elm_hoversel_horizontal_set(Evas_Object *obj, Eina_Bool horizontal)
|
|
|
|
{
|
2010-03-08 22:15:39 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
2010-01-13 19:47:28 -08:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2010-03-09 19:47:33 -08:00
|
|
|
if (!wd) return;
|
2010-01-13 19:47:28 -08:00
|
|
|
wd->horizontal = !!horizontal;
|
|
|
|
}
|
|
|
|
|
2010-04-07 00:37:49 -07:00
|
|
|
EAPI Eina_Bool
|
|
|
|
elm_hoversel_horizontal_get(const Evas_Object *obj)
|
2009-08-11 03:44:49 -07:00
|
|
|
{
|
2010-04-07 00:37:49 -07:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
|
2009-08-11 03:44:49 -07:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2010-04-07 00:37:49 -07:00
|
|
|
if (!wd) return EINA_FALSE;
|
|
|
|
return wd->horizontal;
|
2009-08-11 03:44:49 -07:00
|
|
|
}
|
|
|
|
|
2008-12-09 22:33:24 -08:00
|
|
|
EAPI void
|
|
|
|
elm_hoversel_icon_set(Evas_Object *obj, Evas_Object *icon)
|
|
|
|
{
|
2010-03-08 22:15:39 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
2008-12-09 22:33:24 -08:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2009-01-08 06:29:13 -08:00
|
|
|
if (!wd) return;
|
2011-11-17 13:02:31 -08:00
|
|
|
elm_object_part_content_set(wd->btn, "icon", icon);
|
2008-12-09 22:33:24 -08:00
|
|
|
}
|
2008-12-08 01:24:46 -08:00
|
|
|
|
2009-08-12 15:37:48 -07:00
|
|
|
EAPI Evas_Object *
|
2010-03-23 20:06:00 -07:00
|
|
|
elm_hoversel_icon_get(const Evas_Object *obj)
|
2009-08-12 15:37:48 -07:00
|
|
|
{
|
2010-03-09 19:47:33 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
|
2009-08-12 15:37:48 -07:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2009-09-27 13:10:03 -07:00
|
|
|
if ((!wd) || (!wd->btn)) return NULL;
|
2011-11-17 13:02:31 -08:00
|
|
|
return elm_object_part_content_get(wd->btn, "icon");
|
2009-08-12 15:37:48 -07:00
|
|
|
}
|
|
|
|
|
2010-10-14 11:54:42 -07:00
|
|
|
EAPI Evas_Object *
|
|
|
|
elm_hoversel_icon_unset(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
if ((!wd) || (!wd->btn)) return NULL;
|
2011-11-17 13:02:31 -08:00
|
|
|
return elm_object_part_content_unset(wd->btn, "icon");
|
2010-10-14 11:54:42 -07:00
|
|
|
}
|
|
|
|
|
2009-03-19 06:36:46 -07:00
|
|
|
EAPI void
|
|
|
|
elm_hoversel_hover_begin(Evas_Object *obj)
|
|
|
|
{
|
2010-03-08 22:15:39 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
2009-03-19 06:36:46 -07:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
if (!wd) return;
|
|
|
|
if (wd->hover) return;
|
|
|
|
_activate(obj);
|
|
|
|
}
|
|
|
|
|
2008-12-08 01:24:46 -08:00
|
|
|
EAPI void
|
|
|
|
elm_hoversel_hover_end(Evas_Object *obj)
|
|
|
|
{
|
2010-03-08 22:15:39 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
2008-12-08 01:24:46 -08:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2009-01-08 06:29:13 -08:00
|
|
|
if (!wd) return;
|
2009-09-27 13:10:03 -07:00
|
|
|
if (!wd->hover) return;
|
2010-09-22 10:45:49 -07:00
|
|
|
wd->expanded = EINA_FALSE;
|
2009-09-27 13:10:03 -07:00
|
|
|
evas_object_del(wd->hover);
|
|
|
|
wd->hover = NULL;
|
2011-04-15 10:01:39 -07:00
|
|
|
evas_object_smart_callback_call(obj, SIG_DISMISSED, NULL);
|
2008-12-09 22:33:24 -08:00
|
|
|
}
|
|
|
|
|
2010-04-06 18:31:36 -07:00
|
|
|
EAPI Eina_Bool
|
2010-10-25 07:34:22 -07:00
|
|
|
elm_hoversel_expanded_get(const Evas_Object *obj)
|
2010-04-06 18:31:36 -07:00
|
|
|
{
|
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
if (!wd) return EINA_FALSE;
|
|
|
|
return (wd->hover) ? EINA_TRUE : EINA_FALSE;
|
|
|
|
}
|
2011-04-01 04:51:11 -07:00
|
|
|
|
2009-08-14 04:17:06 -07:00
|
|
|
EAPI void
|
|
|
|
elm_hoversel_clear(Evas_Object *obj)
|
|
|
|
{
|
2011-12-19 17:03:17 -08:00
|
|
|
Elm_Object_Item *it;
|
2009-08-14 04:17:06 -07:00
|
|
|
Eina_List *l, *ll;
|
2010-03-08 22:15:39 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
2009-08-14 04:17:06 -07:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
if (!wd) return;
|
2011-12-19 17:03:17 -08:00
|
|
|
EINA_LIST_FOREACH_SAFE(wd->items, l, ll, it) elm_hoversel_item_del(it);
|
2009-08-14 04:17:06 -07:00
|
|
|
}
|
|
|
|
|
2009-10-04 16:05:50 -07:00
|
|
|
EAPI const Eina_List *
|
2010-03-23 20:06:00 -07:00
|
|
|
elm_hoversel_items_get(const Evas_Object *obj)
|
2009-10-04 16:05:50 -07:00
|
|
|
{
|
2010-03-09 19:47:33 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
|
2009-10-04 16:05:50 -07:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
if (!wd) return NULL;
|
|
|
|
return wd->items;
|
|
|
|
}
|
|
|
|
|
2011-12-19 17:03:17 -08:00
|
|
|
EAPI Elm_Object_Item *
|
2010-03-16 08:31:38 -07:00
|
|
|
elm_hoversel_item_add(Evas_Object *obj, const char *label, const char *icon_file, Elm_Icon_Type icon_type, Evas_Smart_Cb func, const void *data)
|
2008-12-09 22:33:24 -08:00
|
|
|
{
|
2010-03-09 19:47:33 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
|
2008-12-09 22:33:24 -08:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2009-01-08 06:29:13 -08:00
|
|
|
if (!wd) return NULL;
|
2010-11-02 04:26:50 -07:00
|
|
|
Elm_Hoversel_Item *item = elm_widget_item_new(obj, Elm_Hoversel_Item);
|
|
|
|
if (!item) return NULL;
|
|
|
|
wd->items = eina_list_append(wd->items, item);
|
|
|
|
item->label = eina_stringshare_add(label);
|
|
|
|
item->icon_file = eina_stringshare_add(icon_file);
|
|
|
|
item->icon_type = icon_type;
|
|
|
|
item->func = func;
|
|
|
|
item->base.data = data;
|
2011-12-19 17:03:17 -08:00
|
|
|
return (Elm_Object_Item *) item;
|
2008-12-09 22:33:24 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
2011-12-19 17:03:17 -08:00
|
|
|
elm_hoversel_item_del(Elm_Object_Item *it)
|
2008-12-15 16:15:34 -08:00
|
|
|
{
|
2011-12-19 17:03:17 -08:00
|
|
|
ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
|
|
|
|
Widget_Data *wd;
|
|
|
|
Elm_Hoversel_Item *item = (Elm_Hoversel_Item *) it;
|
|
|
|
wd = elm_widget_data_get(WIDGET(item));
|
2009-01-08 06:29:13 -08:00
|
|
|
if (!wd) return;
|
2011-10-20 18:08:01 -07:00
|
|
|
elm_hoversel_hover_end(WIDGET(item));
|
2010-11-02 04:26:50 -07:00
|
|
|
wd->items = eina_list_remove(wd->items, item);
|
|
|
|
elm_widget_item_pre_notify_del(item);
|
|
|
|
eina_stringshare_del(item->label);
|
|
|
|
eina_stringshare_del(item->icon_file);
|
|
|
|
eina_stringshare_del(item->icon_group);
|
|
|
|
elm_widget_item_del(item);
|
2008-12-08 01:24:46 -08:00
|
|
|
}
|
2009-03-31 04:58:56 -07:00
|
|
|
|
2009-11-08 14:20:46 -08:00
|
|
|
EAPI void
|
2011-12-19 17:03:17 -08:00
|
|
|
elm_hoversel_item_del_cb_set(Elm_Object_Item *it, Evas_Smart_Cb func)
|
2009-11-08 14:20:46 -08:00
|
|
|
{
|
2011-12-19 17:03:17 -08:00
|
|
|
ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
|
|
|
|
elm_widget_item_del_cb_set(it, func);
|
2009-11-08 14:20:46 -08:00
|
|
|
}
|
|
|
|
|
2009-03-31 04:58:56 -07:00
|
|
|
EAPI void *
|
2011-12-19 17:03:17 -08:00
|
|
|
elm_hoversel_item_data_get(const Elm_Object_Item *it)
|
2009-03-31 04:58:56 -07:00
|
|
|
{
|
2011-12-19 17:03:17 -08:00
|
|
|
ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
|
|
|
|
return elm_widget_item_data_get(it);
|
2009-03-31 04:58:56 -07:00
|
|
|
}
|
2009-08-12 04:18:08 -07:00
|
|
|
|
|
|
|
EAPI const char *
|
2011-12-19 17:03:17 -08:00
|
|
|
elm_hoversel_item_label_get(const Elm_Object_Item *it)
|
2009-08-12 04:18:08 -07:00
|
|
|
{
|
2011-12-19 17:03:17 -08:00
|
|
|
ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
|
|
|
|
return ((Elm_Hoversel_Item *) it)->label;
|
2009-08-12 04:18:08 -07:00
|
|
|
}
|
2009-08-14 04:17:06 -07:00
|
|
|
|
|
|
|
EAPI void
|
2011-12-19 17:03:17 -08:00
|
|
|
elm_hoversel_item_icon_set(Elm_Object_Item *it, const char *icon_file, const char *icon_group, Elm_Icon_Type icon_type)
|
2009-08-14 04:17:06 -07:00
|
|
|
{
|
2011-12-19 17:03:17 -08:00
|
|
|
ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
|
|
|
|
Elm_Hoversel_Item *item = (Elm_Hoversel_Item *) it;
|
2010-11-02 04:26:50 -07:00
|
|
|
eina_stringshare_replace(&item->icon_file, icon_file);
|
|
|
|
eina_stringshare_replace(&item->icon_group, icon_group);
|
|
|
|
item->icon_type = icon_type;
|
2009-08-14 04:17:06 -07:00
|
|
|
}
|
|
|
|
|
2009-09-16 12:13:55 -07:00
|
|
|
EAPI void
|
2011-12-19 17:03:17 -08:00
|
|
|
elm_hoversel_item_icon_get(const Elm_Object_Item *it, const char **icon_file, const char **icon_group, Elm_Icon_Type *icon_type)
|
2009-09-16 12:13:55 -07:00
|
|
|
{
|
2011-12-19 17:03:17 -08:00
|
|
|
ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
|
|
|
|
Elm_Hoversel_Item *item = (Elm_Hoversel_Item *) it;
|
2010-11-02 04:26:50 -07:00
|
|
|
if (icon_file) *icon_file = item->icon_file;
|
|
|
|
if (icon_group) *icon_group = item->icon_group;
|
|
|
|
if (icon_type) *icon_type = item->icon_type;
|
2009-09-16 12:13:55 -07:00
|
|
|
}
|
2009-10-04 16:05:50 -07:00
|
|
|
|