2008-12-08 01:24:46 -08:00
|
|
|
#include <Elementary.h>
|
|
|
|
#include "elm_priv.h"
|
|
|
|
|
2009-05-31 14:59:31 -07:00
|
|
|
/**
|
|
|
|
* @defgroup Hoversel
|
2009-07-06 23:46:51 -07:00
|
|
|
*
|
2009-05-31 14:59:31 -07:00
|
|
|
* A hoversel is a button that pops up a list of items (automatically
|
|
|
|
* choosing the direction to display) that have a lable and/or an icon to
|
|
|
|
* select from. It is a convenience widget to avoid the need to do all the
|
2009-10-22 15:10:23 -07:00
|
|
|
* piecing together yourself. It is intended for a small number of items in
|
2009-05-31 14:59:31 -07:00
|
|
|
* the hoversel menu (no more than 8), though is capable of many more.
|
2009-07-06 23:46:51 -07:00
|
|
|
*
|
2009-05-31 14:59:31 -07:00
|
|
|
* Signals that you can add callbacks for are:
|
2009-07-06 23:46:51 -07:00
|
|
|
*
|
2009-05-31 14:59:31 -07:00
|
|
|
* clicked - the user clicked the hoversel button and popped up the sel
|
2009-07-06 23:46:51 -07:00
|
|
|
*
|
2009-05-31 14:59:31 -07:00
|
|
|
* selected - an item in the hoversel list is selected. event_info is the item
|
|
|
|
* selected - Elm_Hoversel_Item
|
2009-07-06 23:46:51 -07:00
|
|
|
*
|
2009-05-31 14:59:31 -07:00
|
|
|
* dismissed - the hover is dismissed
|
|
|
|
*/
|
2008-12-08 01:24:46 -08:00
|
|
|
typedef struct _Widget_Data Widget_Data;
|
|
|
|
|
|
|
|
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;
|
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
|
|
|
{
|
|
|
|
Evas_Object *obj;
|
|
|
|
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;
|
|
|
|
void (*func) (void *data, Evas_Object *obj, void *event_info);
|
2009-11-08 14:20:46 -08:00
|
|
|
void (*del_cb) (void *data, Evas_Object *obj, void *event_info);
|
2009-01-08 06:29:13 -08:00
|
|
|
void *data;
|
2008-12-08 01:24:46 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
static void _del_pre_hook(Evas_Object *obj);
|
|
|
|
static void _del_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);
|
|
|
|
|
|
|
|
static void
|
|
|
|
_del_pre_hook(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
elm_hoversel_hover_end(obj);
|
|
|
|
elm_hoversel_hover_parent_set(obj, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_del_hook(Evas_Object *obj)
|
|
|
|
{
|
2009-04-22 20:51:50 -07:00
|
|
|
Elm_Hoversel_Item *it;
|
2008-12-08 01:24:46 -08:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2009-09-27 13:10:03 -07:00
|
|
|
|
2009-01-08 06:29:13 -08:00
|
|
|
if (!wd) return;
|
2008-12-15 16:15:34 -08:00
|
|
|
elm_hoversel_hover_end(obj);
|
2009-04-22 20:51:50 -07:00
|
|
|
EINA_LIST_FREE(wd->items, it)
|
|
|
|
{
|
2009-11-08 14:20:46 -08:00
|
|
|
if (it->del_cb) it->del_cb((void *)it->data, it->obj, it);
|
2009-07-06 23:46:51 -07:00
|
|
|
eina_stringshare_del(it->label);
|
|
|
|
eina_stringshare_del(it->icon_file);
|
2009-08-14 04:17:06 -07:00
|
|
|
eina_stringshare_del(it->icon_group);
|
2009-07-06 23:46:51 -07:00
|
|
|
free(it);
|
2009-04-22 20:51:50 -07:00
|
|
|
}
|
2008-12-08 01:24:46 -08:00
|
|
|
free(wd);
|
|
|
|
}
|
|
|
|
|
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];
|
2009-09-27 13:10:03 -07:00
|
|
|
|
2009-09-02 05:48:00 -07:00
|
|
|
if (!wd) return;
|
|
|
|
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);
|
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);
|
2009-09-27 13:10:03 -07:00
|
|
|
|
2009-08-26 09:43:17 -07:00
|
|
|
if (elm_widget_disabled_get(obj))
|
|
|
|
elm_widget_disabled_set(wd->btn, 1);
|
|
|
|
else
|
|
|
|
elm_widget_disabled_set(wd->btn, 0);
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
|
|
|
{
|
|
|
|
_sizing_eval(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_hover_clicked(void *data, Evas_Object *obj, void *event_info)
|
|
|
|
{
|
|
|
|
elm_hoversel_hover_end(data);
|
|
|
|
}
|
|
|
|
|
2008-12-15 16:15:34 -08:00
|
|
|
static void
|
|
|
|
_item_clicked(void *data, Evas_Object *obj, void *event_info)
|
|
|
|
{
|
2009-02-25 11:50:45 -08:00
|
|
|
Elm_Hoversel_Item *it = data;
|
2008-12-15 16:15:34 -08:00
|
|
|
Evas_Object *obj2 = it->obj;
|
2009-09-27 13:10:03 -07:00
|
|
|
|
2008-12-23 21:04:33 -08:00
|
|
|
elm_hoversel_hover_end(obj2);
|
2009-01-07 13:08:36 -08:00
|
|
|
if (it->func) it->func(it->data, obj2, it);
|
|
|
|
evas_object_smart_callback_call(obj2, "selected", it);
|
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;
|
|
|
|
const Elm_Hoversel_Item *it;
|
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;
|
|
|
|
if (elm_widget_disabled_get(obj)) return;
|
2009-08-26 09:43:17 -07:00
|
|
|
|
2009-03-19 06:36:46 -07:00
|
|
|
wd->hover = elm_hover_add(obj);
|
2009-09-02 05:48:00 -07:00
|
|
|
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);
|
|
|
|
elm_box_homogenous_set(bx, 1);
|
2009-02-25 11:50:45 -08:00
|
|
|
|
2009-10-22 15:10:23 -07:00
|
|
|
snprintf(buf, sizeof(buf), "hoversel_vertical_entry/%s",
|
2009-09-27 13:10:03 -07:00
|
|
|
elm_widget_style_get(obj));
|
2009-02-25 11:50:45 -08:00
|
|
|
EINA_LIST_FOREACH(wd->items, l, it)
|
2008-12-15 16:15:34 -08:00
|
|
|
{
|
2009-07-06 23:46:51 -07:00
|
|
|
bt = elm_button_add(wd->hover);
|
2009-10-17 22:49:23 -07:00
|
|
|
elm_object_style_set(bt, buf);
|
2009-07-06 23:46:51 -07:00
|
|
|
elm_button_label_set(bt, it->label);
|
|
|
|
if (it->icon_file)
|
|
|
|
{
|
|
|
|
ic = elm_icon_add(obj);
|
|
|
|
elm_icon_scale_set(ic, 0, 1);
|
|
|
|
if (it->icon_type == ELM_ICON_FILE)
|
2009-08-14 04:17:06 -07:00
|
|
|
elm_icon_file_set(ic, it->icon_file, it->icon_group);
|
2009-07-06 23:46:51 -07:00
|
|
|
else if (it->icon_type == ELM_ICON_STANDARD)
|
|
|
|
elm_icon_standard_set(ic, it->icon_file);
|
|
|
|
elm_button_icon_set(bt, ic);
|
|
|
|
evas_object_show(ic);
|
|
|
|
}
|
|
|
|
evas_object_size_hint_weight_set(bt, 1.0, 0.0);
|
|
|
|
evas_object_size_hint_align_set(bt, -1.0, -1.0);
|
|
|
|
elm_box_pack_end(bx, bt);
|
|
|
|
evas_object_smart_callback_add(bt, "clicked", _item_clicked, it);
|
|
|
|
evas_object_show(bt);
|
2008-12-15 16:15:34 -08:00
|
|
|
}
|
2008-12-09 22:33:24 -08:00
|
|
|
|
2009-09-27 13:10:03 -07:00
|
|
|
elm_hover_content_set(wd->hover,
|
2009-10-22 15:10:23 -07:00
|
|
|
elm_hover_best_content_location_get(wd->hover,
|
2009-09-27 13:10:03 -07:00
|
|
|
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);
|
2009-03-19 06:36:46 -07:00
|
|
|
evas_object_smart_callback_call(obj, "clicked", NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_button_clicked(void *data, Evas_Object *obj, void *event_info)
|
|
|
|
{
|
2009-07-06 23:46:51 -07:00
|
|
|
_activate(data);
|
2008-12-09 22:33:24 -08:00
|
|
|
}
|
|
|
|
|
2008-12-08 01:24:46 -08:00
|
|
|
static void
|
|
|
|
_parent_del(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
2009-09-27 13:10:03 -07:00
|
|
|
|
2009-01-08 06:29:13 -08:00
|
|
|
if (!wd) return;
|
2008-12-08 01:24:46 -08:00
|
|
|
wd->hover_parent = NULL;
|
|
|
|
}
|
|
|
|
|
2009-05-31 14:59:31 -07:00
|
|
|
/**
|
|
|
|
* Add a new Hoversel object
|
|
|
|
*
|
|
|
|
* @param parent The parent object
|
|
|
|
* @return The new object or NULL if it cannot be created
|
|
|
|
*
|
|
|
|
* @ingroup Hoversel
|
|
|
|
*/
|
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
|
|
|
|
2008-12-08 01:24:46 -08:00
|
|
|
wd = ELM_NEW(Widget_Data);
|
|
|
|
e = evas_object_evas_get(parent);
|
|
|
|
obj = elm_widget_add(e);
|
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);
|
2009-08-26 09:43:17 -07:00
|
|
|
elm_widget_disable_hook_set(obj, _disable_hook);
|
2009-07-06 23:46:51 -07:00
|
|
|
|
2008-12-09 22:33:24 -08:00
|
|
|
wd->btn = elm_button_add(parent);
|
2009-10-17 22:49:23 -07:00
|
|
|
elm_object_style_set(wd->btn, "hoversel_vertical");
|
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,
|
|
|
|
_changed_size_hints, obj);
|
|
|
|
evas_object_smart_callback_add(wd->btn, "clicked", _button_clicked, obj);
|
2008-12-08 01:24:46 -08:00
|
|
|
_sizing_eval(obj);
|
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
2009-05-31 14:59:31 -07:00
|
|
|
/**
|
|
|
|
* Set the Hover parent
|
2009-07-06 23:46:51 -07:00
|
|
|
*
|
2009-05-31 14:59:31 -07:00
|
|
|
* Sets the hover parent object. See Hover objects for more information.
|
|
|
|
*
|
|
|
|
* @param obj The hoversel object
|
|
|
|
* @param parent The parent to use
|
|
|
|
*
|
|
|
|
* @ingroup Hoversel
|
|
|
|
*/
|
2008-12-08 01:24:46 -08:00
|
|
|
EAPI void
|
|
|
|
elm_hoversel_hover_parent_set(Evas_Object *obj, Evas_Object *parent)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2009-09-27 13:10:03 -07:00
|
|
|
|
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,
|
|
|
|
_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
|
|
|
}
|
|
|
|
|
2009-05-31 14:59:31 -07:00
|
|
|
/**
|
|
|
|
* Set the hoversel button label
|
2009-07-06 23:46:51 -07:00
|
|
|
*
|
2009-05-31 14:59:31 -07:00
|
|
|
* This sets the label of the button that is always visible (before it is
|
|
|
|
* clicked and expanded). Also see elm_button_label_set().
|
|
|
|
*
|
|
|
|
* @param obj The hoversel object
|
|
|
|
* @param label The label text.
|
|
|
|
*
|
|
|
|
* @ingroup Hoversel
|
|
|
|
*/
|
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
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2009-09-27 13:10:03 -07:00
|
|
|
|
2009-01-08 06:29:13 -08:00
|
|
|
if (!wd) return;
|
2008-12-09 22:33:24 -08:00
|
|
|
elm_button_label_set(wd->btn, label);
|
|
|
|
}
|
|
|
|
|
2009-08-11 03:44:49 -07:00
|
|
|
/**
|
|
|
|
* Get the hoversel button label
|
|
|
|
*
|
|
|
|
* @param obj The hoversel object
|
|
|
|
* @return The label text.
|
|
|
|
*
|
|
|
|
* @ingroup Hoversel
|
|
|
|
*/
|
|
|
|
EAPI const char*
|
|
|
|
elm_hoversel_label_get(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
|
2009-09-27 13:10:03 -07:00
|
|
|
if ((!wd) || (!wd->btn)) return NULL;
|
2009-08-11 03:44:49 -07:00
|
|
|
return elm_button_label_get(wd->btn);
|
|
|
|
}
|
|
|
|
|
2009-05-31 14:59:31 -07:00
|
|
|
/**
|
|
|
|
* Set the icon of the hoversel button
|
2009-07-06 23:46:51 -07:00
|
|
|
*
|
2009-05-31 14:59:31 -07:00
|
|
|
* Sets the icon of the button that is always visible (before it is clicked
|
|
|
|
* and expanded). Also see elm_button_icon_set().
|
|
|
|
*
|
|
|
|
* @param obj The hoversel object
|
|
|
|
* @param icon The icon object
|
|
|
|
*
|
|
|
|
* @ingroup Hoversel
|
|
|
|
*/
|
2008-12-09 22:33:24 -08:00
|
|
|
EAPI void
|
|
|
|
elm_hoversel_icon_set(Evas_Object *obj, Evas_Object *icon)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2009-09-27 13:10:03 -07:00
|
|
|
|
2009-01-08 06:29:13 -08:00
|
|
|
if (!wd) return;
|
2008-12-09 22:33:24 -08:00
|
|
|
elm_button_icon_set(wd->btn, icon);
|
|
|
|
}
|
2008-12-08 01:24:46 -08:00
|
|
|
|
2009-08-12 15:37:48 -07:00
|
|
|
/**
|
|
|
|
* Get the icon of the hoversel button
|
|
|
|
*
|
|
|
|
* Get the icon of the button that is always visible (before it is clicked
|
|
|
|
* and expanded). Also see elm_button_icon_get().
|
|
|
|
*
|
|
|
|
* @param obj The hoversel object
|
|
|
|
* @return The icon object
|
|
|
|
*
|
|
|
|
* @ingroup Hoversel
|
|
|
|
*/
|
|
|
|
EAPI Evas_Object *
|
|
|
|
elm_hoversel_icon_get(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2009-09-27 13:10:03 -07:00
|
|
|
|
|
|
|
if ((!wd) || (!wd->btn)) return NULL;
|
2009-08-12 15:37:48 -07:00
|
|
|
return elm_button_icon_get(wd->btn);
|
|
|
|
}
|
|
|
|
|
2009-05-31 14:59:31 -07:00
|
|
|
/**
|
|
|
|
* Trigger the hoversel popup from code
|
2009-07-06 23:46:51 -07:00
|
|
|
*
|
2009-05-31 14:59:31 -07:00
|
|
|
* This makes the hoversel popup activate with the items added being listed.
|
|
|
|
*
|
|
|
|
* @param obj The hoversel object
|
|
|
|
*
|
|
|
|
* @ingroup Hoversel
|
|
|
|
*/
|
2009-03-19 06:36:46 -07:00
|
|
|
EAPI void
|
|
|
|
elm_hoversel_hover_begin(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2009-09-27 13:10:03 -07:00
|
|
|
|
2009-03-19 06:36:46 -07:00
|
|
|
if (!wd) return;
|
|
|
|
if (wd->hover) return;
|
|
|
|
_activate(obj);
|
|
|
|
}
|
|
|
|
|
2009-05-31 14:59:31 -07:00
|
|
|
/**
|
|
|
|
* This ends the hoversel popup.
|
2009-07-06 23:46:51 -07:00
|
|
|
*
|
2009-05-31 14:59:31 -07:00
|
|
|
* This will close the hoversel popup, making it disappear, if it was active.
|
|
|
|
*
|
|
|
|
* @param obj The hoversel object
|
|
|
|
*
|
|
|
|
* @ingroup Hoversel
|
|
|
|
*/
|
2008-12-08 01:24:46 -08:00
|
|
|
EAPI void
|
|
|
|
elm_hoversel_hover_end(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2009-09-27 13:10:03 -07:00
|
|
|
|
2009-01-08 06:29:13 -08:00
|
|
|
if (!wd) return;
|
2009-09-27 13:10:03 -07:00
|
|
|
if (!wd->hover) return;
|
|
|
|
evas_object_del(wd->hover);
|
|
|
|
wd->hover = NULL;
|
|
|
|
evas_object_smart_callback_call(obj, "dismissed", NULL);
|
2008-12-09 22:33:24 -08:00
|
|
|
}
|
|
|
|
|
2009-08-14 04:17:06 -07:00
|
|
|
/**
|
|
|
|
* Remove all the items from the given hoversel object.
|
|
|
|
*
|
|
|
|
* This will remove all the children items from the hoversel. (should not be
|
|
|
|
* called while the hoversel is active).
|
2009-10-22 15:10:23 -07:00
|
|
|
*
|
2009-08-14 04:17:06 -07:00
|
|
|
* @param obj The hoversel object
|
|
|
|
*
|
|
|
|
* @ingroup Hoversel
|
|
|
|
*/
|
|
|
|
EAPI void
|
|
|
|
elm_hoversel_clear(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Elm_Hoversel_Item *it;
|
|
|
|
Eina_List *l, *ll;
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2009-09-27 13:10:03 -07:00
|
|
|
|
2009-08-14 04:17:06 -07:00
|
|
|
if (!wd) return;
|
|
|
|
EINA_LIST_FOREACH_SAFE(wd->items, l, ll, it)
|
|
|
|
elm_hoversel_item_del(it);
|
|
|
|
}
|
|
|
|
|
2009-10-04 16:05:50 -07:00
|
|
|
/**
|
|
|
|
* Get the list of items.
|
|
|
|
*
|
|
|
|
* @param obj The hoversel object
|
|
|
|
* @return Returns a list of Elm_Hoversel_Item*
|
|
|
|
*
|
|
|
|
* @ingroup Hoversel
|
|
|
|
*/
|
|
|
|
EAPI const Eina_List *
|
|
|
|
elm_hoversel_items_get(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Elm_Hoversel_Item *it;
|
|
|
|
Eina_List *l, *ll;
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
|
|
|
|
if (!wd) return NULL;
|
|
|
|
return wd->items;
|
|
|
|
}
|
|
|
|
|
2009-05-31 14:59:31 -07:00
|
|
|
/**
|
|
|
|
* Add an item to the hoversel button
|
2009-07-06 23:46:51 -07:00
|
|
|
*
|
2009-08-14 04:17:06 -07:00
|
|
|
* This adds an item to the hoversel to show when it is clicked. Note: if you
|
|
|
|
* need to use an icon from an edje file then use elm_hoversel_item_icon_set()
|
|
|
|
* right after the this function, and set icon_file to NULL here.
|
2009-05-31 14:59:31 -07:00
|
|
|
*
|
|
|
|
* @param obj The hoversel object
|
|
|
|
* @param label The text abel to use for the item (NULL if not desired)
|
|
|
|
* @param icon_file A image file path on disk to use for the icon or standard
|
|
|
|
* icon name(NULL if not desired)
|
|
|
|
* @param icon_type The icon type if relevant
|
|
|
|
* @param func Convenience function to call when this item is selected
|
|
|
|
* @param data Data to pass to the conveience function
|
|
|
|
* @return A handle to the item added.
|
|
|
|
*
|
|
|
|
* @ingroup Hoversel
|
|
|
|
*/
|
2008-12-15 16:15:34 -08:00
|
|
|
EAPI Elm_Hoversel_Item *
|
|
|
|
elm_hoversel_item_add(Evas_Object *obj, const char *label, const char *icon_file, Elm_Icon_Type icon_type, void (*func) (void *data, Evas_Object *obj, void *event_info), const void *data)
|
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;
|
2009-02-25 11:50:45 -08:00
|
|
|
Elm_Hoversel_Item *it = calloc(1, sizeof(Elm_Hoversel_Item));
|
2008-12-15 16:15:34 -08:00
|
|
|
if (!it) return NULL;
|
|
|
|
wd->items = eina_list_append(wd->items, it);
|
|
|
|
it->obj = obj;
|
|
|
|
it->label = eina_stringshare_add(label);
|
|
|
|
it->icon_file = eina_stringshare_add(icon_file);
|
|
|
|
it->icon_type = icon_type;
|
|
|
|
it->func = func;
|
2009-01-08 06:29:13 -08:00
|
|
|
it->data = (void *)data;
|
2009-02-25 11:50:45 -08:00
|
|
|
return it;
|
2008-12-09 22:33:24 -08:00
|
|
|
}
|
|
|
|
|
2009-05-31 14:59:31 -07:00
|
|
|
/**
|
|
|
|
* Delete an item from the hoversel
|
2009-07-06 23:46:51 -07:00
|
|
|
*
|
2009-05-31 14:59:31 -07:00
|
|
|
* This deletes the item from the hoversel (should not be called while the
|
|
|
|
* hoversel is active).
|
|
|
|
*
|
|
|
|
* @param it The item to delete
|
|
|
|
*
|
|
|
|
* @ingroup Hoversel
|
|
|
|
*/
|
2008-12-09 22:33:24 -08:00
|
|
|
EAPI void
|
2009-02-25 11:50:45 -08:00
|
|
|
elm_hoversel_item_del(Elm_Hoversel_Item *it)
|
2008-12-15 16:15:34 -08:00
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(it->obj);
|
2009-09-27 13:10:03 -07:00
|
|
|
|
2009-11-08 14:20:46 -08:00
|
|
|
if (it->del_cb) it->del_cb((void *)it->data, it->obj, it);
|
2009-01-08 06:29:13 -08:00
|
|
|
if (!wd) return;
|
2008-12-17 18:01:36 -08:00
|
|
|
elm_hoversel_hover_end(it->obj);
|
2008-12-15 16:15:34 -08:00
|
|
|
wd->items = eina_list_remove(wd->items, it);
|
|
|
|
eina_stringshare_del(it->label);
|
|
|
|
eina_stringshare_del(it->icon_file);
|
2009-08-14 04:17:06 -07:00
|
|
|
eina_stringshare_del(it->icon_group);
|
2008-12-15 16:15:34 -08:00
|
|
|
free(it);
|
2008-12-08 01:24:46 -08:00
|
|
|
}
|
2009-03-31 04:58:56 -07:00
|
|
|
|
2009-11-08 14:20:46 -08:00
|
|
|
/**
|
|
|
|
* Set the function called when an hoversel item is freed.
|
|
|
|
*
|
|
|
|
* @param it The item to set the callback on
|
|
|
|
* @param func The function called
|
|
|
|
*
|
|
|
|
* @ingroup Hoversel
|
|
|
|
*/
|
|
|
|
EAPI void
|
|
|
|
elm_hoversel_item_del_cb_set(Elm_Hoversel_Item *it, void (*func)(void *data, Evas_Object *obj, void *event_info))
|
|
|
|
{
|
|
|
|
it->del_cb = func;
|
|
|
|
}
|
|
|
|
|
2009-05-31 14:59:31 -07:00
|
|
|
/**
|
|
|
|
* Get the data pointer passed to the item add function
|
2009-07-06 23:46:51 -07:00
|
|
|
*
|
2009-05-31 14:59:31 -07:00
|
|
|
* This returns the data pointer supplied with elm_hoversel_item_add() that
|
|
|
|
* will be passed to the select function callback.
|
|
|
|
*
|
|
|
|
* @param it The item to get the data from
|
|
|
|
* @return The data pointer set with elm_hoversel_item_add()
|
|
|
|
*
|
|
|
|
* @ingroup Hoversel
|
|
|
|
*/
|
2009-03-31 04:58:56 -07:00
|
|
|
EAPI void *
|
|
|
|
elm_hoversel_item_data_get(Elm_Hoversel_Item *it)
|
|
|
|
{
|
|
|
|
if (!it) return NULL;
|
|
|
|
return it->data;
|
|
|
|
}
|
2009-08-12 04:18:08 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the text label of an hoversel item
|
|
|
|
*
|
|
|
|
* This returns the text of the label of the given hoversel item
|
|
|
|
*
|
|
|
|
* @param it The item to get the label
|
|
|
|
* @return The text label of the hoversel item
|
|
|
|
*
|
|
|
|
* @ingroup Hoversel
|
|
|
|
*/
|
|
|
|
EAPI const char *
|
|
|
|
elm_hoversel_item_label_get(Elm_Hoversel_Item *it)
|
|
|
|
{
|
|
|
|
if (!it) return NULL;
|
|
|
|
return it->label;
|
|
|
|
}
|
2009-08-14 04:17:06 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the icon of the hoversel item
|
|
|
|
*
|
|
|
|
* This set the icon for the given hoversel item. The icon can be loaded from
|
|
|
|
* the standard set, from an image file or from an edje file.
|
|
|
|
*
|
|
|
|
* @param it The item to set the icon
|
|
|
|
* @param icon_file An image file path on disk to use for the icon or standard
|
|
|
|
* icon name
|
|
|
|
* @param icon_group The edje group to use if @p icon_file is an edje file. Set this
|
|
|
|
* to NULL if the icon is not an edje file
|
|
|
|
* @param icon_type The icon type
|
|
|
|
*
|
|
|
|
* @ingroup Hoversel
|
|
|
|
*/
|
|
|
|
EAPI void
|
|
|
|
elm_hoversel_item_icon_set(Elm_Hoversel_Item *it, const char *icon_file, const char *icon_group, Elm_Icon_Type icon_type)
|
|
|
|
{
|
|
|
|
if (!it) return;
|
|
|
|
|
|
|
|
if (it->icon_file) eina_stringshare_del(it->icon_file);
|
|
|
|
it->icon_file = eina_stringshare_add(icon_file);
|
|
|
|
|
|
|
|
if (it->icon_group) eina_stringshare_del(it->icon_group);
|
|
|
|
it->icon_group = eina_stringshare_add(icon_group);
|
|
|
|
|
|
|
|
it->icon_type = icon_type;
|
|
|
|
}
|
|
|
|
|
2009-09-16 12:13:55 -07:00
|
|
|
/**
|
|
|
|
* Get the icon object of the hoversel item
|
|
|
|
*
|
|
|
|
* @param it The item to get the icon from
|
|
|
|
* @param icon_file The image file path on disk used for the icon or standard
|
|
|
|
* icon name. return
|
|
|
|
* @param icon_group The edje group used if @p icon_file is an edje file. NULL
|
|
|
|
* if the icon is not an edje file. return
|
|
|
|
* @param icon_type The icon type. return
|
|
|
|
*
|
|
|
|
* @ingroup Hoversel
|
|
|
|
*/
|
|
|
|
EAPI void
|
|
|
|
elm_hoversel_item_icon_get(Elm_Hoversel_Item *it, const char **icon_file, const char **icon_group, Elm_Icon_Type *icon_type)
|
|
|
|
{
|
|
|
|
if (!it) return;
|
|
|
|
|
|
|
|
if (icon_file) *icon_file = it->icon_file;
|
|
|
|
if (icon_group) *icon_group = it->icon_group;
|
|
|
|
if (icon_type) *icon_type = it->icon_type;
|
|
|
|
}
|
2009-10-04 16:05:50 -07:00
|
|
|
|