2005-10-10 05:16:18 -07:00
|
|
|
#include "e.h"
|
|
|
|
|
|
|
|
typedef struct _E_Widget_Data E_Widget_Data;
|
|
|
|
struct _E_Widget_Data
|
|
|
|
{
|
2005-10-12 09:02:33 -07:00
|
|
|
Evas_Object *o_check;
|
2006-07-15 07:59:51 -07:00
|
|
|
Evas_Object *o_icon;
|
2012-07-06 00:46:08 -07:00
|
|
|
int *valptr;
|
2005-10-10 05:16:18 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
static void _e_wid_del_hook(Evas_Object *obj);
|
2005-10-12 09:02:33 -07:00
|
|
|
static void _e_wid_focus_hook(Evas_Object *obj);
|
|
|
|
static void _e_wid_do(Evas_Object *obj);
|
|
|
|
static void _e_wid_activate_hook(Evas_Object *obj);
|
2005-10-16 00:32:12 -07:00
|
|
|
static void _e_wid_disable_hook(Evas_Object *obj);
|
2005-10-10 05:16:18 -07:00
|
|
|
static void _e_wid_signal_cb1(void *data, Evas_Object *obj, const char *emission, const char *source);
|
2005-10-12 09:02:33 -07:00
|
|
|
static void _e_wid_focus_steal(void *data, Evas *e, Evas_Object *obj, void *event_info);
|
2012-06-20 23:19:43 -07:00
|
|
|
|
2005-10-10 05:16:18 -07:00
|
|
|
/* local subsystem functions */
|
|
|
|
|
|
|
|
/* externally accessible functions */
|
2012-07-06 03:53:22 -07:00
|
|
|
|
2013-01-11 02:34:29 -08:00
|
|
|
/**
|
2012-07-06 03:53:22 -07:00
|
|
|
* Creates a check box widget
|
|
|
|
*
|
|
|
|
* @param evas pointer
|
|
|
|
* @param label the text to asign to check widget
|
|
|
|
* @param val pointer to int where changes are stored
|
|
|
|
* @return the newly created evas object
|
|
|
|
*/
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI Evas_Object *
|
2008-02-06 12:38:22 -08:00
|
|
|
e_widget_check_add(Evas *evas, const char *label, int *val)
|
2005-10-10 05:16:18 -07:00
|
|
|
{
|
|
|
|
Evas_Object *obj, *o;
|
|
|
|
E_Widget_Data *wd;
|
|
|
|
Evas_Coord mw, mh;
|
2012-06-20 23:19:43 -07:00
|
|
|
|
2005-10-10 05:16:18 -07:00
|
|
|
obj = e_widget_add(evas);
|
2012-06-20 23:19:43 -07:00
|
|
|
|
2005-10-10 05:16:18 -07:00
|
|
|
e_widget_del_hook_set(obj, _e_wid_del_hook);
|
2005-10-12 09:02:33 -07:00
|
|
|
e_widget_focus_hook_set(obj, _e_wid_focus_hook);
|
|
|
|
e_widget_activate_hook_set(obj, _e_wid_activate_hook);
|
2005-10-16 00:32:12 -07:00
|
|
|
e_widget_disable_hook_set(obj, _e_wid_disable_hook);
|
2005-10-10 05:16:18 -07:00
|
|
|
wd = calloc(1, sizeof(E_Widget_Data));
|
|
|
|
wd->valptr = val;
|
|
|
|
e_widget_data_set(obj, wd);
|
2012-06-20 23:19:43 -07:00
|
|
|
|
2005-10-10 05:16:18 -07:00
|
|
|
o = edje_object_add(evas);
|
2005-10-12 09:02:33 -07:00
|
|
|
wd->o_check = o;
|
2005-10-10 05:16:18 -07:00
|
|
|
e_theme_edje_object_set(o, "base/theme/widgets",
|
2012-07-06 00:46:08 -07:00
|
|
|
"e/widgets/check");
|
2006-08-22 00:39:11 -07:00
|
|
|
edje_object_signal_callback_add(o, "e,action,toggle", "*", _e_wid_signal_cb1, obj);
|
|
|
|
edje_object_part_text_set(o, "e.text.label", label);
|
2005-10-11 09:25:00 -07:00
|
|
|
evas_object_show(o);
|
2005-10-10 05:16:18 -07:00
|
|
|
edje_object_size_min_calc(o, &mw, &mh);
|
2009-09-01 06:34:42 -07:00
|
|
|
e_widget_size_min_set(obj, mw, mh);
|
2005-10-10 05:16:18 -07:00
|
|
|
if (wd->valptr)
|
|
|
|
{
|
2012-07-06 00:46:08 -07:00
|
|
|
if (*(wd->valptr)) edje_object_signal_emit(o, "e,state,checked", "e");
|
2005-10-10 05:16:18 -07:00
|
|
|
}
|
2012-06-20 23:19:43 -07:00
|
|
|
|
2005-10-10 05:16:18 -07:00
|
|
|
e_widget_sub_object_add(obj, o);
|
2005-10-12 09:02:33 -07:00
|
|
|
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN, _e_wid_focus_steal, obj);
|
2005-10-10 05:16:18 -07:00
|
|
|
e_widget_resize_object_set(obj, o);
|
2012-06-20 23:19:43 -07:00
|
|
|
|
2005-10-10 05:16:18 -07:00
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
2013-01-11 02:34:29 -08:00
|
|
|
/**
|
2012-07-06 03:53:22 -07:00
|
|
|
* Sets the value of the check box
|
|
|
|
*
|
|
|
|
* @param check the check box widget
|
|
|
|
* @param checked the value to set the widget too
|
|
|
|
*/
|
2006-04-01 01:24:56 -08:00
|
|
|
EAPI void
|
|
|
|
e_widget_check_checked_set(Evas_Object *check, int checked)
|
|
|
|
{
|
|
|
|
E_Widget_Data *wd;
|
2012-06-20 23:19:43 -07:00
|
|
|
|
2006-04-01 01:24:56 -08:00
|
|
|
wd = e_widget_data_get(check);
|
|
|
|
if (wd->valptr)
|
|
|
|
*(wd->valptr) = checked;
|
|
|
|
if (checked)
|
2006-08-22 00:39:11 -07:00
|
|
|
edje_object_signal_emit(wd->o_check, "e,state,checked", "e");
|
2006-04-01 01:24:56 -08:00
|
|
|
else
|
2006-08-22 00:39:11 -07:00
|
|
|
edje_object_signal_emit(wd->o_check, "e,state,unchecked", "e");
|
2012-06-20 23:19:43 -07:00
|
|
|
}
|
2006-04-01 01:24:56 -08:00
|
|
|
|
2013-01-11 02:34:29 -08:00
|
|
|
/**
|
2012-08-08 02:20:45 -07:00
|
|
|
* Sets the value of the check box
|
|
|
|
*
|
|
|
|
* @param check the check box widget
|
|
|
|
* @param val pointer to int where changes are stored
|
|
|
|
*/
|
|
|
|
EAPI void
|
|
|
|
e_widget_check_valptr_set(Evas_Object *check, int *val)
|
|
|
|
{
|
|
|
|
E_Widget_Data *wd;
|
|
|
|
int state;
|
|
|
|
|
|
|
|
wd = e_widget_data_get(check);
|
|
|
|
state = wd->valptr ? *wd->valptr : 0;
|
|
|
|
wd->valptr = val;
|
|
|
|
if (state == (wd->valptr && *wd->valptr)) return;
|
|
|
|
if (wd->valptr && *wd->valptr)
|
|
|
|
edje_object_signal_emit(wd->o_check, "e,state,checked", "e");
|
|
|
|
else
|
|
|
|
edje_object_signal_emit(wd->o_check, "e,state,unchecked", "e");
|
|
|
|
}
|
|
|
|
|
2013-01-11 02:34:29 -08:00
|
|
|
/**
|
|
|
|
* Get the value of the check box
|
2012-07-06 03:53:22 -07:00
|
|
|
*
|
|
|
|
* @param check the check box widget
|
|
|
|
* @return the value of the check box
|
|
|
|
*/
|
2006-04-01 01:24:56 -08:00
|
|
|
EAPI int
|
|
|
|
e_widget_check_checked_get(Evas_Object *check)
|
|
|
|
{
|
|
|
|
E_Widget_Data *wd;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
wd = e_widget_data_get(check);
|
|
|
|
if (wd->valptr)
|
|
|
|
ret = *(wd->valptr);
|
2012-06-20 23:19:43 -07:00
|
|
|
else
|
2006-04-01 01:24:56 -08:00
|
|
|
ret = -1;
|
2012-06-20 23:19:43 -07:00
|
|
|
|
2006-04-01 01:24:56 -08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-01-11 02:34:29 -08:00
|
|
|
/**
|
2012-07-06 03:53:22 -07:00
|
|
|
* Creates a check box widget with icon
|
|
|
|
*
|
|
|
|
* @param evas pointer
|
|
|
|
* @param label the text to asign to check widget
|
|
|
|
* @param icon the path to the icon file
|
|
|
|
* @param icon_w the minimum wdith of the icon
|
|
|
|
* @param icon_h the minumum height of the icon
|
|
|
|
* @param val pointer to int where changes are stored
|
|
|
|
* @return the newly created evas object
|
|
|
|
*/
|
2006-07-15 07:59:51 -07:00
|
|
|
EAPI Evas_Object *
|
2012-06-20 23:19:43 -07:00
|
|
|
e_widget_check_icon_add(Evas *evas, const char *label, const char *icon, int icon_w, int icon_h, int *val)
|
2006-07-15 07:59:51 -07:00
|
|
|
{
|
|
|
|
Evas_Object *obj, *o, *o2;
|
|
|
|
E_Widget_Data *wd;
|
|
|
|
Evas_Coord mw, mh;
|
2012-06-20 23:19:43 -07:00
|
|
|
|
2006-07-15 07:59:51 -07:00
|
|
|
obj = e_widget_add(evas);
|
2012-06-20 23:19:43 -07:00
|
|
|
|
2006-07-15 07:59:51 -07:00
|
|
|
e_widget_del_hook_set(obj, _e_wid_del_hook);
|
|
|
|
e_widget_focus_hook_set(obj, _e_wid_focus_hook);
|
|
|
|
e_widget_activate_hook_set(obj, _e_wid_activate_hook);
|
|
|
|
e_widget_disable_hook_set(obj, _e_wid_disable_hook);
|
|
|
|
wd = calloc(1, sizeof(E_Widget_Data));
|
|
|
|
wd->valptr = val;
|
|
|
|
e_widget_data_set(obj, wd);
|
|
|
|
|
|
|
|
o = edje_object_add(evas);
|
|
|
|
wd->o_check = o;
|
|
|
|
e_theme_edje_object_set(o, "base/theme/widgets",
|
2012-07-06 00:46:08 -07:00
|
|
|
"e/widgets/check_icon");
|
2006-08-22 00:39:11 -07:00
|
|
|
edje_object_signal_callback_add(o, "e,action,toggle", "*", _e_wid_signal_cb1, obj);
|
|
|
|
edje_object_part_text_set(o, "e.text.label", label);
|
2006-07-15 07:59:51 -07:00
|
|
|
evas_object_show(o);
|
|
|
|
if (label)
|
|
|
|
{
|
2012-07-06 00:46:08 -07:00
|
|
|
edje_object_signal_emit(o, "e,state,labeled", "e");
|
|
|
|
edje_object_message_signal_process(o);
|
2006-07-15 07:59:51 -07:00
|
|
|
}
|
2012-06-20 23:19:43 -07:00
|
|
|
if (icon)
|
2006-07-15 07:59:51 -07:00
|
|
|
{
|
2009-01-05 04:55:19 -08:00
|
|
|
if (icon[0] == '/')
|
|
|
|
{
|
|
|
|
o2 = e_icon_add(evas);
|
|
|
|
e_icon_file_set(o2, icon);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
o2 = edje_object_add(evas);
|
|
|
|
e_util_edje_icon_set(o2, icon);
|
|
|
|
}
|
|
|
|
edje_extern_object_min_size_set(o2, icon_w, icon_h);
|
2012-07-06 00:46:08 -07:00
|
|
|
edje_object_part_swallow(wd->o_check, "e.swallow.icon", o2);
|
|
|
|
evas_object_show(o2);
|
|
|
|
e_widget_sub_object_add(obj, o2);
|
|
|
|
wd->o_icon = o2;
|
2006-07-15 07:59:51 -07:00
|
|
|
}
|
2012-06-20 23:19:43 -07:00
|
|
|
|
2006-07-15 07:59:51 -07:00
|
|
|
edje_object_size_min_calc(o, &mw, &mh);
|
2009-09-01 06:34:42 -07:00
|
|
|
e_widget_size_min_set(obj, mw, mh);
|
2006-07-15 07:59:51 -07:00
|
|
|
if (wd->valptr)
|
|
|
|
{
|
2012-07-06 00:46:08 -07:00
|
|
|
if (*(wd->valptr)) edje_object_signal_emit(o, "e,state,checked", "e");
|
2006-07-15 07:59:51 -07:00
|
|
|
}
|
2012-06-20 23:19:43 -07:00
|
|
|
|
2006-07-15 07:59:51 -07:00
|
|
|
e_widget_sub_object_add(obj, o);
|
|
|
|
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN, _e_wid_focus_steal, obj);
|
|
|
|
e_widget_resize_object_set(obj, o);
|
|
|
|
|
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
2005-10-10 05:16:18 -07:00
|
|
|
static void
|
|
|
|
_e_wid_del_hook(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
E_Widget_Data *wd;
|
2012-06-20 23:19:43 -07:00
|
|
|
|
2005-10-10 05:16:18 -07:00
|
|
|
wd = e_widget_data_get(obj);
|
|
|
|
free(wd);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2005-10-12 09:02:33 -07:00
|
|
|
_e_wid_focus_hook(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
E_Widget_Data *wd;
|
2012-06-20 23:19:43 -07:00
|
|
|
|
2005-10-12 09:02:33 -07:00
|
|
|
wd = e_widget_data_get(obj);
|
|
|
|
if (e_widget_focus_get(obj))
|
2005-10-12 16:00:45 -07:00
|
|
|
{
|
2012-07-06 00:46:08 -07:00
|
|
|
edje_object_signal_emit(wd->o_check, "e,state,focused", "e");
|
|
|
|
evas_object_focus_set(wd->o_check, 1);
|
2005-10-12 16:00:45 -07:00
|
|
|
}
|
2005-10-12 09:02:33 -07:00
|
|
|
else
|
2005-10-12 16:00:45 -07:00
|
|
|
{
|
2012-07-06 00:46:08 -07:00
|
|
|
edje_object_signal_emit(wd->o_check, "e,state,unfocused", "e");
|
|
|
|
evas_object_focus_set(wd->o_check, 0);
|
2005-10-12 16:00:45 -07:00
|
|
|
}
|
2005-10-12 09:02:33 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_wid_do(Evas_Object *obj)
|
2005-10-10 05:16:18 -07:00
|
|
|
{
|
|
|
|
E_Widget_Data *wd;
|
2006-03-11 17:55:16 -08:00
|
|
|
|
|
|
|
if (e_widget_disabled_get(obj)) return;
|
2012-06-20 23:19:43 -07:00
|
|
|
|
2005-10-12 09:02:33 -07:00
|
|
|
wd = e_widget_data_get(obj);
|
2005-10-10 05:16:18 -07:00
|
|
|
if (wd->valptr)
|
|
|
|
{
|
2012-07-06 00:46:08 -07:00
|
|
|
if (*(wd->valptr) == 0)
|
|
|
|
{
|
|
|
|
*(wd->valptr) = 1;
|
|
|
|
edje_object_signal_emit(wd->o_check, "e,state,checked", "e");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*(wd->valptr) = 0;
|
|
|
|
edje_object_signal_emit(wd->o_check, "e,state,unchecked", "e");
|
|
|
|
}
|
2005-10-10 05:16:18 -07:00
|
|
|
}
|
2006-08-07 13:25:34 -07:00
|
|
|
evas_object_smart_callback_call(obj, "changed", NULL);
|
2008-02-08 10:42:55 -08:00
|
|
|
e_widget_change(obj);
|
2005-10-10 05:16:18 -07:00
|
|
|
}
|
2005-10-12 09:02:33 -07:00
|
|
|
|
|
|
|
static void
|
|
|
|
_e_wid_activate_hook(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
_e_wid_do(obj);
|
|
|
|
}
|
|
|
|
|
2005-10-16 00:32:12 -07:00
|
|
|
static void
|
|
|
|
_e_wid_disable_hook(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
E_Widget_Data *wd;
|
2012-06-20 23:19:43 -07:00
|
|
|
|
2005-10-16 00:32:12 -07:00
|
|
|
wd = e_widget_data_get(obj);
|
|
|
|
if (e_widget_disabled_get(obj))
|
2006-08-22 00:39:11 -07:00
|
|
|
edje_object_signal_emit(wd->o_check, "e,state,disabled", "e");
|
2005-10-16 00:32:12 -07:00
|
|
|
else
|
2006-08-22 00:39:11 -07:00
|
|
|
edje_object_signal_emit(wd->o_check, "e,state,enabled", "e");
|
2005-10-16 00:32:12 -07:00
|
|
|
}
|
2012-06-20 23:19:43 -07:00
|
|
|
|
2005-10-12 09:02:33 -07:00
|
|
|
static void
|
2010-08-18 12:42:31 -07:00
|
|
|
_e_wid_signal_cb1(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
|
2005-10-12 09:02:33 -07:00
|
|
|
{
|
|
|
|
_e_wid_do(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-08-18 12:42:31 -07:00
|
|
|
_e_wid_focus_steal(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
|
2005-10-12 09:02:33 -07:00
|
|
|
{
|
|
|
|
e_widget_focus_steal(data);
|
|
|
|
}
|
2012-07-06 00:46:08 -07:00
|
|
|
|