2005-10-10 05:16:18 -07:00
|
|
|
#include "e.h"
|
|
|
|
|
2012-07-03 05:02:05 -07:00
|
|
|
#define SMART_NAME "e_widget"
|
|
|
|
#define API_ENTRY E_Smart_Data * sd; sd = evas_object_smart_data_get(obj); if ((!obj) || (!sd) || (evas_object_type_get(obj) && strcmp(evas_object_type_get(obj), SMART_NAME)))
|
|
|
|
#define INTERNAL_ENTRY E_Smart_Data * sd; sd = evas_object_smart_data_get(obj); if (!sd) return;
|
2005-10-10 05:16:18 -07:00
|
|
|
typedef struct _E_Smart_Data E_Smart_Data;
|
|
|
|
|
|
|
|
struct _E_Smart_Data
|
2012-06-20 23:19:43 -07:00
|
|
|
{
|
2012-07-03 05:02:05 -07:00
|
|
|
Evas_Object *parent_obj;
|
|
|
|
Evas_Coord x, y, w, h, minw, minh;
|
|
|
|
Eina_List *subobjs;
|
|
|
|
Evas_Object *resize_obj;
|
|
|
|
void (*del_func)(Evas_Object *obj);
|
|
|
|
void (*focus_func)(Evas_Object *obj);
|
|
|
|
void (*activate_func)(Evas_Object *obj);
|
|
|
|
void (*disable_func)(Evas_Object *obj);
|
|
|
|
void (*on_focus_func)(void *data, Evas_Object *obj);
|
|
|
|
void *on_focus_data;
|
|
|
|
void (*on_change_func)(void *data, Evas_Object *obj);
|
|
|
|
void *on_change_data;
|
2013-02-06 01:34:53 -08:00
|
|
|
void (*on_disable_func)(void *data, Evas_Object *obj);
|
|
|
|
void *on_disable_data;
|
2012-07-03 05:02:05 -07:00
|
|
|
void *data;
|
2009-09-01 06:34:42 -07:00
|
|
|
unsigned char can_focus : 1;
|
|
|
|
unsigned char child_can_focus : 1;
|
|
|
|
unsigned char focused : 1;
|
|
|
|
unsigned char disabled : 1;
|
2009-04-05 10:07:18 -07:00
|
|
|
};
|
2005-10-10 05:16:18 -07:00
|
|
|
|
|
|
|
/* local subsystem functions */
|
|
|
|
static void _e_smart_reconfigure(E_Smart_Data *sd);
|
|
|
|
static void _e_smart_add(Evas_Object *obj);
|
|
|
|
static void _e_smart_del(Evas_Object *obj);
|
|
|
|
static void _e_smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y);
|
|
|
|
static void _e_smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h);
|
|
|
|
static void _e_smart_show(Evas_Object *obj);
|
|
|
|
static void _e_smart_hide(Evas_Object *obj);
|
|
|
|
static void _e_smart_color_set(Evas_Object *obj, int r, int g, int b, int a);
|
2012-07-03 05:02:05 -07:00
|
|
|
static void _e_smart_clip_set(Evas_Object *obj, Evas_Object *clip);
|
2005-10-10 05:16:18 -07:00
|
|
|
static void _e_smart_clip_unset(Evas_Object *obj);
|
|
|
|
static void _e_smart_init(void);
|
|
|
|
|
|
|
|
/* local subsystem globals */
|
|
|
|
static Evas_Smart *_e_smart = NULL;
|
|
|
|
|
|
|
|
/* externally accessible functions */
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI Evas_Object *
|
2005-10-10 05:16:18 -07:00
|
|
|
e_widget_add(Evas *evas)
|
|
|
|
{
|
|
|
|
_e_smart_init();
|
|
|
|
return evas_object_smart_add(evas, _e_smart);
|
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI void
|
2012-07-03 05:02:05 -07:00
|
|
|
e_widget_del_hook_set(Evas_Object *obj, void (*func)(Evas_Object *obj))
|
2005-10-10 05:16:18 -07:00
|
|
|
{
|
|
|
|
API_ENTRY return;
|
|
|
|
sd->del_func = func;
|
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI void
|
2012-07-03 05:02:05 -07:00
|
|
|
e_widget_focus_hook_set(Evas_Object *obj, void (*func)(Evas_Object *obj))
|
2005-10-12 09:02:33 -07:00
|
|
|
{
|
|
|
|
API_ENTRY return;
|
|
|
|
sd->focus_func = func;
|
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI void
|
2012-07-03 05:02:05 -07:00
|
|
|
e_widget_activate_hook_set(Evas_Object *obj, void (*func)(Evas_Object *obj))
|
2005-10-12 09:02:33 -07:00
|
|
|
{
|
|
|
|
API_ENTRY return;
|
|
|
|
sd->activate_func = func;
|
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI void
|
2012-07-03 05:02:05 -07:00
|
|
|
e_widget_disable_hook_set(Evas_Object *obj, void (*func)(Evas_Object *obj))
|
2005-10-15 22:59:18 -07:00
|
|
|
{
|
|
|
|
API_ENTRY return;
|
|
|
|
sd->disable_func = func;
|
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI void
|
2012-07-03 05:02:05 -07:00
|
|
|
e_widget_on_focus_hook_set(Evas_Object *obj, void (*func)(void *data, Evas_Object *obj), void *data)
|
2005-10-12 09:02:33 -07:00
|
|
|
{
|
|
|
|
API_ENTRY return;
|
|
|
|
sd->on_focus_func = func;
|
|
|
|
sd->on_focus_data = data;
|
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI void
|
2012-07-03 05:02:05 -07:00
|
|
|
e_widget_on_change_hook_set(Evas_Object *obj, void (*func)(void *data, Evas_Object *obj), void *data)
|
2005-10-15 22:59:18 -07:00
|
|
|
{
|
|
|
|
API_ENTRY return;
|
|
|
|
sd->on_change_func = func;
|
|
|
|
sd->on_change_data = data;
|
|
|
|
}
|
|
|
|
|
2013-02-06 01:34:53 -08:00
|
|
|
EAPI void
|
|
|
|
e_widget_on_disable_hook_set(Evas_Object *obj, void (*func)(void *data, Evas_Object *obj), void *data)
|
|
|
|
{
|
|
|
|
API_ENTRY return;
|
|
|
|
sd->on_disable_func = func;
|
|
|
|
sd->on_disable_data = data;
|
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI void
|
2005-10-10 05:16:18 -07:00
|
|
|
e_widget_data_set(Evas_Object *obj, void *data)
|
|
|
|
{
|
|
|
|
API_ENTRY return;
|
|
|
|
sd->data = data;
|
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI void *
|
2005-10-10 05:16:18 -07:00
|
|
|
e_widget_data_get(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
API_ENTRY return NULL;
|
|
|
|
return sd->data;
|
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI void
|
2009-09-01 06:34:42 -07:00
|
|
|
e_widget_size_min_set(Evas_Object *obj, Evas_Coord minw, Evas_Coord minh)
|
2005-10-10 05:16:18 -07:00
|
|
|
{
|
|
|
|
API_ENTRY return;
|
2009-04-05 10:07:18 -07:00
|
|
|
if (minw >= 0) sd->minw = minw;
|
|
|
|
if (minh >= 0) sd->minh = minh;
|
2005-10-10 05:16:18 -07:00
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI void
|
2009-09-01 06:34:42 -07:00
|
|
|
e_widget_size_min_get(Evas_Object *obj, Evas_Coord *minw, Evas_Coord *minh)
|
2005-10-10 05:16:18 -07:00
|
|
|
{
|
|
|
|
API_ENTRY return;
|
|
|
|
if (minw) *minw = sd->minw;
|
|
|
|
if (minh) *minh = sd->minh;
|
|
|
|
}
|
|
|
|
|
2011-07-23 21:13:23 -07:00
|
|
|
static void
|
2012-07-03 05:02:05 -07:00
|
|
|
_sub_obj_del(void *data,
|
|
|
|
Evas *e __UNUSED__,
|
2011-07-23 21:13:23 -07:00
|
|
|
Evas_Object *obj,
|
2012-07-03 05:02:05 -07:00
|
|
|
void *event_info __UNUSED__)
|
2011-07-23 21:13:23 -07:00
|
|
|
{
|
|
|
|
E_Smart_Data *sd = data;
|
2012-06-20 23:19:43 -07:00
|
|
|
|
2011-07-23 21:13:23 -07:00
|
|
|
sd->subobjs = eina_list_remove(sd->subobjs, obj);
|
|
|
|
evas_object_event_callback_del(obj, EVAS_CALLBACK_DEL, _sub_obj_del);
|
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI void
|
2005-10-12 09:02:33 -07:00
|
|
|
e_widget_sub_object_add(Evas_Object *obj, Evas_Object *sobj)
|
2005-10-10 05:16:18 -07:00
|
|
|
{
|
|
|
|
API_ENTRY return;
|
2012-06-20 23:19:43 -07:00
|
|
|
|
2011-11-28 03:40:18 -08:00
|
|
|
if (eina_list_data_find(sd->subobjs, sobj)) return;
|
2012-06-20 23:19:43 -07:00
|
|
|
|
2008-10-22 04:49:33 -07:00
|
|
|
sd->subobjs = eina_list_append(sd->subobjs, sobj);
|
2012-07-24 02:46:33 -07:00
|
|
|
evas_object_event_callback_add(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
|
2005-10-12 09:02:33 -07:00
|
|
|
if (!sd->child_can_focus)
|
|
|
|
{
|
2012-07-03 05:02:05 -07:00
|
|
|
if (e_widget_can_focus_get(sobj)) sd->child_can_focus = 1;
|
2005-10-12 09:02:33 -07:00
|
|
|
}
|
2012-07-24 02:46:33 -07:00
|
|
|
if (strcmp(evas_object_type_get(sobj), SMART_NAME)) return;
|
|
|
|
|
|
|
|
sd = evas_object_smart_data_get(sobj);
|
|
|
|
if (sd)
|
2005-10-12 09:02:33 -07:00
|
|
|
{
|
2012-07-24 02:46:33 -07:00
|
|
|
if (sd->parent_obj) e_widget_sub_object_del(sd->parent_obj, sobj);
|
|
|
|
sd->parent_obj = obj;
|
2005-10-12 09:02:33 -07:00
|
|
|
}
|
2012-07-24 02:46:33 -07:00
|
|
|
evas_object_event_callback_del_full(sobj, EVAS_CALLBACK_DEL, _sub_obj_del, sd);
|
2005-10-10 05:16:18 -07:00
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI void
|
2005-10-25 17:19:52 -07:00
|
|
|
e_widget_sub_object_del(Evas_Object *obj, Evas_Object *sobj)
|
|
|
|
{
|
|
|
|
API_ENTRY return;
|
2011-07-25 04:29:37 -07:00
|
|
|
evas_object_event_callback_del(sobj, EVAS_CALLBACK_DEL, _sub_obj_del);
|
2008-10-22 04:49:33 -07:00
|
|
|
sd->subobjs = eina_list_remove(sd->subobjs, sobj);
|
2005-10-25 17:19:52 -07:00
|
|
|
if (!sd->child_can_focus)
|
|
|
|
{
|
2012-07-03 05:02:05 -07:00
|
|
|
if (e_widget_can_focus_get(sobj)) sd->child_can_focus = 0;
|
2005-10-25 17:19:52 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI void
|
2005-10-12 09:02:33 -07:00
|
|
|
e_widget_resize_object_set(Evas_Object *obj, Evas_Object *sobj)
|
2005-10-10 05:16:18 -07:00
|
|
|
{
|
|
|
|
API_ENTRY return;
|
2005-10-12 09:02:33 -07:00
|
|
|
if (sd->resize_obj) evas_object_smart_member_del(sd->resize_obj);
|
|
|
|
sd->resize_obj = sobj;
|
2008-09-16 22:22:08 -07:00
|
|
|
evas_object_smart_member_add(sobj, obj);
|
2005-10-12 09:02:33 -07:00
|
|
|
_e_smart_reconfigure(sd);
|
2005-10-10 05:16:18 -07:00
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI void
|
2005-10-12 09:02:33 -07:00
|
|
|
e_widget_can_focus_set(Evas_Object *obj, int can_focus)
|
2005-10-10 05:16:18 -07:00
|
|
|
{
|
|
|
|
API_ENTRY return;
|
2005-10-12 09:02:33 -07:00
|
|
|
sd->can_focus = can_focus;
|
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI int
|
2005-10-12 09:02:33 -07:00
|
|
|
e_widget_can_focus_get(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
API_ENTRY return 0;
|
2012-07-17 01:26:22 -07:00
|
|
|
if (sd->disabled) return 0;
|
2005-10-12 09:02:33 -07:00
|
|
|
if (sd->can_focus) return 1;
|
|
|
|
if (sd->child_can_focus) return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI int
|
2005-10-12 09:02:33 -07:00
|
|
|
e_widget_focus_get(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
API_ENTRY return 0;
|
|
|
|
return sd->focused;
|
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI Evas_Object *
|
2005-10-12 09:02:33 -07:00
|
|
|
e_widget_focused_object_get(Evas_Object *obj)
|
|
|
|
{
|
2009-04-05 10:07:18 -07:00
|
|
|
Eina_List *l = NULL;
|
2009-08-21 08:08:49 -07:00
|
|
|
Evas_Object *sobj = NULL;
|
2009-04-05 10:07:18 -07:00
|
|
|
|
2005-10-12 09:02:33 -07:00
|
|
|
API_ENTRY return NULL;
|
|
|
|
if (!sd->focused) return NULL;
|
2009-08-21 08:08:49 -07:00
|
|
|
EINA_LIST_FOREACH(sd->subobjs, l, sobj)
|
2009-04-05 10:07:18 -07:00
|
|
|
{
|
2012-07-03 05:02:05 -07:00
|
|
|
sobj = e_widget_focused_object_get(sobj);
|
|
|
|
if (sobj) return sobj;
|
2005-10-12 09:02:33 -07:00
|
|
|
}
|
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI int
|
2005-10-12 09:02:33 -07:00
|
|
|
e_widget_focus_jump(Evas_Object *obj, int forward)
|
|
|
|
{
|
|
|
|
API_ENTRY return 0;
|
2005-10-16 00:32:12 -07:00
|
|
|
if (!e_widget_can_focus_get(obj)) return 0;
|
2009-04-05 10:07:18 -07:00
|
|
|
|
2005-10-12 09:02:33 -07:00
|
|
|
/* if it has a focus func its an end-point widget like a button */
|
|
|
|
if (sd->focus_func)
|
|
|
|
{
|
2012-07-03 05:02:05 -07:00
|
|
|
if (!sd->focused) sd->focused = 1;
|
|
|
|
else sd->focused = 0;
|
|
|
|
sd->focus_func(obj);
|
|
|
|
if (sd->on_focus_func) sd->on_focus_func(sd->on_focus_data, obj);
|
|
|
|
return sd->focused;
|
2005-10-12 09:02:33 -07:00
|
|
|
}
|
|
|
|
/* its some container */
|
|
|
|
else
|
|
|
|
{
|
2012-07-03 05:02:05 -07:00
|
|
|
Eina_List *l = NULL;
|
|
|
|
Evas_Object *sobj = NULL;
|
|
|
|
int focus_next = 0;
|
|
|
|
|
|
|
|
if (!sd->focused)
|
|
|
|
{
|
|
|
|
e_widget_focus_set(obj, forward);
|
|
|
|
sd->focused = 1;
|
|
|
|
if (sd->on_focus_func) sd->on_focus_func(sd->on_focus_data, obj);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (forward)
|
|
|
|
{
|
|
|
|
EINA_LIST_FOREACH(sd->subobjs, l, sobj)
|
|
|
|
{
|
2012-07-17 01:26:22 -07:00
|
|
|
if (!e_widget_can_focus_get(sobj)) continue;
|
|
|
|
if ((focus_next) && (!e_widget_disabled_get(sobj)))
|
2012-07-03 05:02:05 -07:00
|
|
|
{
|
2012-07-17 01:26:22 -07:00
|
|
|
/* the previous focused item was unfocused - so focus
|
|
|
|
* the next one (that can be focused) */
|
|
|
|
if (e_widget_focus_jump(sobj, forward))
|
|
|
|
return 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (e_widget_focus_get(sobj))
|
2012-07-03 05:02:05 -07:00
|
|
|
{
|
2012-07-17 01:26:22 -07:00
|
|
|
/* jump to the next focused item or focus this item */
|
2012-07-03 05:02:05 -07:00
|
|
|
if (e_widget_focus_jump(sobj, forward))
|
2009-04-05 10:07:18 -07:00
|
|
|
return 1;
|
2012-07-17 01:26:22 -07:00
|
|
|
/* it returned 0 - it got to the last item and is past it */
|
|
|
|
focus_next = 1;
|
2012-07-03 05:02:05 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
EINA_LIST_REVERSE_FOREACH(sd->subobjs, l, sobj)
|
|
|
|
{
|
|
|
|
if (e_widget_can_focus_get(sobj))
|
|
|
|
{
|
|
|
|
if ((focus_next) &&
|
|
|
|
(!e_widget_disabled_get(sobj)))
|
|
|
|
{
|
|
|
|
/* the previous focused item was unfocused - so focus
|
|
|
|
* the next one (that can be focused) */
|
|
|
|
if (e_widget_focus_jump(sobj, forward))
|
2009-04-05 10:07:18 -07:00
|
|
|
return 1;
|
2012-07-03 05:02:05 -07:00
|
|
|
else break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (e_widget_focus_get(sobj))
|
|
|
|
{
|
|
|
|
/* jump to the next focused item or focus this item */
|
|
|
|
if (e_widget_focus_jump(sobj, forward))
|
2009-04-05 10:07:18 -07:00
|
|
|
return 1;
|
2012-07-03 05:02:05 -07:00
|
|
|
/* it returned 0 - it got to the last item and is past it */
|
|
|
|
focus_next = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-10-12 09:02:33 -07:00
|
|
|
}
|
|
|
|
/* no next item can be focused */
|
|
|
|
sd->focused = 0;
|
|
|
|
return 0;
|
2005-10-10 05:16:18 -07:00
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI void
|
2005-10-12 09:02:33 -07:00
|
|
|
e_widget_focus_set(Evas_Object *obj, int first)
|
2005-10-10 05:16:18 -07:00
|
|
|
{
|
|
|
|
API_ENTRY return;
|
2005-10-12 09:02:33 -07:00
|
|
|
if (!sd->focused)
|
|
|
|
{
|
2012-07-03 05:02:05 -07:00
|
|
|
sd->focused = 1;
|
|
|
|
if (sd->on_focus_func) sd->on_focus_func(sd->on_focus_data, obj);
|
2005-10-12 09:02:33 -07:00
|
|
|
}
|
|
|
|
if (sd->focus_func)
|
|
|
|
{
|
2012-07-03 05:02:05 -07:00
|
|
|
sd->focus_func(obj);
|
|
|
|
return;
|
2005-10-12 09:02:33 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-07-03 05:02:05 -07:00
|
|
|
Eina_List *l = NULL;
|
|
|
|
Evas_Object *sobj;
|
|
|
|
|
|
|
|
if (first)
|
|
|
|
{
|
|
|
|
EINA_LIST_FOREACH(sd->subobjs, l, sobj)
|
|
|
|
{
|
|
|
|
if ((e_widget_can_focus_get(sobj)) &&
|
|
|
|
(!e_widget_disabled_get(sobj)))
|
|
|
|
{
|
|
|
|
e_widget_focus_set(sobj, first);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
EINA_LIST_REVERSE_FOREACH(sd->subobjs, l, sobj)
|
|
|
|
{
|
|
|
|
if ((e_widget_can_focus_get(sobj)) &&
|
|
|
|
(!e_widget_disabled_get(sobj)))
|
|
|
|
{
|
|
|
|
e_widget_focus_set(sobj, first);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-10-12 09:02:33 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI Evas_Object *
|
2005-10-12 09:02:33 -07:00
|
|
|
e_widget_parent_get(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
API_ENTRY return NULL;
|
|
|
|
return sd->parent_obj;
|
2005-10-10 05:16:18 -07:00
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI void
|
2005-10-12 09:02:33 -07:00
|
|
|
e_widget_focused_object_clear(Evas_Object *obj)
|
2005-10-10 05:16:18 -07:00
|
|
|
{
|
2009-04-05 10:07:18 -07:00
|
|
|
Eina_List *l = NULL;
|
2009-08-21 08:08:49 -07:00
|
|
|
Evas_Object *sobj = NULL;
|
2009-04-05 10:07:18 -07:00
|
|
|
|
2005-10-10 05:16:18 -07:00
|
|
|
API_ENTRY return;
|
2005-10-12 09:02:33 -07:00
|
|
|
if (!sd->focused) return;
|
|
|
|
sd->focused = 0;
|
2009-08-21 08:08:49 -07:00
|
|
|
EINA_LIST_FOREACH(sd->subobjs, l, sobj)
|
2009-04-05 10:07:18 -07:00
|
|
|
{
|
2012-07-03 05:02:05 -07:00
|
|
|
if (e_widget_focus_get(sobj))
|
|
|
|
{
|
|
|
|
e_widget_focused_object_clear(sobj);
|
|
|
|
break;
|
|
|
|
}
|
2005-10-12 09:02:33 -07:00
|
|
|
}
|
|
|
|
if (sd->focus_func) sd->focus_func(obj);
|
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI void
|
2005-10-12 09:02:33 -07:00
|
|
|
e_widget_focus_steal(Evas_Object *obj)
|
|
|
|
{
|
2009-04-05 10:07:18 -07:00
|
|
|
Evas_Object *parent = NULL, *o = NULL;
|
2009-04-05 09:58:49 -07:00
|
|
|
|
2005-10-12 09:02:33 -07:00
|
|
|
API_ENTRY return;
|
2012-08-01 00:49:55 -07:00
|
|
|
if ((sd->focused) || (sd->disabled) || (!sd->can_focus)) return;
|
2005-10-12 09:02:33 -07:00
|
|
|
parent = obj;
|
2012-07-03 05:02:05 -07:00
|
|
|
for (;; )
|
2005-10-12 09:02:33 -07:00
|
|
|
{
|
2012-07-03 05:02:05 -07:00
|
|
|
o = e_widget_parent_get(parent);
|
|
|
|
if (!o) break;
|
|
|
|
parent = o;
|
2005-10-12 09:02:33 -07:00
|
|
|
}
|
|
|
|
e_widget_focused_object_clear(parent);
|
|
|
|
parent = obj;
|
2012-07-03 05:02:05 -07:00
|
|
|
for (;; )
|
2005-10-12 09:02:33 -07:00
|
|
|
{
|
2012-07-03 05:02:05 -07:00
|
|
|
sd = evas_object_smart_data_get(parent);
|
|
|
|
sd->focused = 1;
|
|
|
|
if (sd->on_focus_func) sd->on_focus_func(sd->on_focus_data, parent);
|
|
|
|
o = e_widget_parent_get(parent);
|
|
|
|
if (!o) break;
|
|
|
|
parent = o;
|
2005-10-12 09:02:33 -07:00
|
|
|
}
|
|
|
|
sd = evas_object_smart_data_get(obj);
|
|
|
|
if (sd->focus_func) sd->focus_func(obj);
|
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI void
|
2005-10-12 09:02:33 -07:00
|
|
|
e_widget_activate(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
API_ENTRY return;
|
2005-10-15 22:59:18 -07:00
|
|
|
e_widget_change(obj);
|
2007-08-07 07:20:47 -07:00
|
|
|
if (sd->activate_func) sd->activate_func(obj);
|
2005-10-15 22:59:18 -07:00
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI void
|
2005-10-15 22:59:18 -07:00
|
|
|
e_widget_change(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
API_ENTRY return;
|
2009-08-15 17:23:38 -07:00
|
|
|
if (sd->parent_obj) e_widget_change(sd->parent_obj);
|
2007-08-07 07:20:47 -07:00
|
|
|
if (sd->on_change_func) sd->on_change_func(sd->on_change_data, obj);
|
2005-10-15 22:59:18 -07:00
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI void
|
2005-10-15 22:59:18 -07:00
|
|
|
e_widget_disabled_set(Evas_Object *obj, int disabled)
|
|
|
|
{
|
|
|
|
API_ENTRY return;
|
2009-08-25 16:06:40 -07:00
|
|
|
if (sd->disabled == disabled) return;
|
2005-10-15 22:59:18 -07:00
|
|
|
sd->disabled = disabled;
|
2005-10-16 00:32:12 -07:00
|
|
|
if (sd->focused)
|
|
|
|
{
|
2012-07-03 05:02:05 -07:00
|
|
|
Evas_Object *o = NULL, *parent = NULL;
|
2005-10-16 00:32:12 -07:00
|
|
|
|
2012-07-03 05:02:05 -07:00
|
|
|
parent = obj;
|
|
|
|
for (;; )
|
2005-10-16 00:32:12 -07:00
|
|
|
{
|
2012-07-03 05:02:05 -07:00
|
|
|
o = e_widget_parent_get(parent);
|
|
|
|
if (!o) break;
|
|
|
|
parent = o;
|
|
|
|
}
|
|
|
|
e_widget_focus_jump(parent, 1);
|
2005-10-16 00:32:12 -07:00
|
|
|
}
|
2005-10-15 22:59:18 -07:00
|
|
|
if (sd->disable_func) sd->disable_func(obj);
|
2013-02-06 01:34:53 -08:00
|
|
|
if (sd->on_disable_func) sd->on_disable_func(sd->on_disable_data, obj);
|
2005-10-15 22:59:18 -07:00
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI int
|
2005-10-15 22:59:18 -07:00
|
|
|
e_widget_disabled_get(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
API_ENTRY return 0;
|
|
|
|
return sd->disabled;
|
2005-10-10 05:16:18 -07:00
|
|
|
}
|
|
|
|
|
2006-08-19 23:42:20 -07:00
|
|
|
EAPI E_Pointer *
|
|
|
|
e_widget_pointer_get(Evas_Object *obj)
|
|
|
|
{
|
2009-04-05 10:07:18 -07:00
|
|
|
E_Win *win = NULL;
|
|
|
|
|
2006-08-19 23:42:20 -07:00
|
|
|
API_ENTRY return NULL;
|
|
|
|
win = e_win_evas_object_win_get(obj);
|
|
|
|
if (win) return win->pointer;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2008-09-16 22:58:46 -07:00
|
|
|
EAPI void
|
2009-09-01 06:34:42 -07:00
|
|
|
e_widget_size_min_resize(Evas_Object *obj)
|
2008-09-16 22:58:46 -07:00
|
|
|
{
|
|
|
|
API_ENTRY return;
|
|
|
|
evas_object_resize(obj, sd->minw, sd->minh);
|
|
|
|
}
|
|
|
|
|
2005-10-10 05:16:18 -07:00
|
|
|
/* local subsystem functions */
|
|
|
|
static void
|
|
|
|
_e_smart_reconfigure(E_Smart_Data *sd)
|
|
|
|
{
|
|
|
|
if (sd->resize_obj)
|
|
|
|
{
|
2012-07-03 05:02:05 -07:00
|
|
|
evas_object_move(sd->resize_obj, sd->x, sd->y);
|
|
|
|
evas_object_resize(sd->resize_obj, sd->w, sd->h);
|
|
|
|
}
|
2005-10-10 05:16:18 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_smart_add(Evas_Object *obj)
|
|
|
|
{
|
2009-04-05 10:07:18 -07:00
|
|
|
E_Smart_Data *sd = NULL;
|
|
|
|
|
2005-10-10 05:16:18 -07:00
|
|
|
sd = calloc(1, sizeof(E_Smart_Data));
|
|
|
|
if (!sd) return;
|
|
|
|
sd->x = 0;
|
|
|
|
sd->y = 0;
|
|
|
|
sd->w = 0;
|
|
|
|
sd->h = 0;
|
2005-10-12 09:02:33 -07:00
|
|
|
sd->can_focus = 1;
|
2005-10-10 05:16:18 -07:00
|
|
|
evas_object_smart_data_set(obj, sd);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_smart_del(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
INTERNAL_ENTRY;
|
2012-06-20 23:19:43 -07:00
|
|
|
|
2005-10-10 05:16:18 -07:00
|
|
|
if (sd->del_func) sd->del_func(obj);
|
2012-07-04 01:29:30 -07:00
|
|
|
while (sd->subobjs)
|
|
|
|
{
|
|
|
|
Evas_Object *sobj = sd->subobjs->data;
|
2012-07-04 01:38:19 -07:00
|
|
|
/* DO NOT MACRO THIS!
|
|
|
|
* list gets reshuffled during object delete callback chain
|
|
|
|
* and breaks the world.
|
|
|
|
* BORKER CERTIFICATION: GOLD
|
|
|
|
* -discomfitor, 7/4/2012
|
|
|
|
*/
|
|
|
|
sd->subobjs = eina_list_remove_list(sd->subobjs, sd->subobjs);
|
2012-07-04 01:29:30 -07:00
|
|
|
evas_object_del(sobj);
|
|
|
|
}
|
2005-10-10 05:16:18 -07:00
|
|
|
free(sd);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
|
|
|
|
{
|
|
|
|
INTERNAL_ENTRY;
|
|
|
|
sd->x = x;
|
|
|
|
sd->y = y;
|
|
|
|
_e_smart_reconfigure(sd);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
|
|
|
|
{
|
|
|
|
INTERNAL_ENTRY;
|
|
|
|
sd->w = w;
|
|
|
|
sd->h = h;
|
|
|
|
_e_smart_reconfigure(sd);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_smart_show(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
INTERNAL_ENTRY;
|
2009-08-15 04:32:32 -07:00
|
|
|
if (sd->resize_obj)
|
|
|
|
evas_object_show(sd->resize_obj);
|
2005-10-10 05:16:18 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_smart_hide(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
INTERNAL_ENTRY;
|
2009-08-15 04:32:32 -07:00
|
|
|
if (sd->resize_obj)
|
|
|
|
evas_object_hide(sd->resize_obj);
|
2005-10-10 05:16:18 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_smart_color_set(Evas_Object *obj, int r, int g, int b, int a)
|
|
|
|
{
|
|
|
|
INTERNAL_ENTRY;
|
2009-08-15 04:32:32 -07:00
|
|
|
if (sd->resize_obj)
|
|
|
|
evas_object_color_set(sd->resize_obj, r, g, b, a);
|
2005-10-10 05:16:18 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_smart_clip_set(Evas_Object *obj, Evas_Object *clip)
|
|
|
|
{
|
|
|
|
INTERNAL_ENTRY;
|
2009-08-15 04:32:32 -07:00
|
|
|
if (sd->resize_obj)
|
|
|
|
evas_object_clip_set(sd->resize_obj, clip);
|
2005-10-10 05:16:18 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_smart_clip_unset(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
INTERNAL_ENTRY;
|
2009-08-15 04:32:32 -07:00
|
|
|
if (sd->resize_obj)
|
|
|
|
evas_object_clip_unset(sd->resize_obj);
|
2012-06-20 23:19:43 -07:00
|
|
|
}
|
2005-10-10 05:16:18 -07:00
|
|
|
|
|
|
|
/* never need to touch this */
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_smart_init(void)
|
|
|
|
{
|
|
|
|
if (_e_smart) return;
|
2012-07-03 05:02:05 -07:00
|
|
|
{
|
|
|
|
static const Evas_Smart_Class sc =
|
|
|
|
{
|
|
|
|
SMART_NAME,
|
|
|
|
EVAS_SMART_CLASS_VERSION,
|
|
|
|
_e_smart_add,
|
|
|
|
_e_smart_del,
|
|
|
|
_e_smart_move,
|
|
|
|
_e_smart_resize,
|
|
|
|
_e_smart_show,
|
|
|
|
_e_smart_hide,
|
|
|
|
_e_smart_color_set,
|
|
|
|
_e_smart_clip_set,
|
|
|
|
_e_smart_clip_unset,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
_e_smart = evas_smart_class_new(&sc);
|
|
|
|
}
|
2005-10-10 05:16:18 -07:00
|
|
|
}
|
2012-07-03 05:02:05 -07:00
|
|
|
|