Enlightenment CVS committal Author : raster Project : e17 Module : apps/e
Dir : e17/apps/e/src/bin Modified Files: e_dialog.c e_dialog.h e_pan.c e_test.c e_widget.c e_widget.h e_widget_button.c e_widget_check.c e_widget_list.c e_widget_list.h e_widget_radio.c Log Message: and now all the internal widgets understand keyboard focus and control. dialog now uses internal widgets for buttons. =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_dialog.c,v retrieving revision 1.25 retrieving revision 1.26 diff -u -3 -r1.25 -r1.26 --- e_dialog.c 11 Oct 2005 16:25:00 -0000 1.25 +++ e_dialog.c 12 Oct 2005 16:02:33 -0000 1.26 @@ -3,23 +3,12 @@ */ #include "e.h" -struct _E_Dialog_Button -{ - E_Dialog *dialog; - Evas_Object *obj, *obj_icon; - char *label; - char *icon; - void (*func) (void *data, E_Dialog *dia); - void *data; -}; - /* local subsystem functions */ static void _e_dialog_free(E_Dialog *dia); -static void _e_dialog_cb_button_clicked(void *data, Evas_Object *obj, const char *emission, const char *source); -static void _e_dialog_button_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event); +static void _e_dialog_del_func_cb(void *data, E_Dialog *dia); static void _e_dialog_cb_delete(E_Win *win); static void _e_dialog_cb_key_down(void *data, Evas *e, Evas_Object *obj, void *event); - +static void _e_dialog_cb_wid_on_focus(void *data, Evas_Object *obj); /* local subsystem globals */ @@ -59,14 +48,11 @@ "widgets/dialog/main"); evas_object_move(o, 0, 0); evas_object_show(o); - - o = e_box_add(e_win_evas_get(dia->win)); + + o = e_widget_list_add(e_win_evas_get(dia->win), 1, 1); + e_widget_on_focus_hook_set(o, _e_dialog_cb_wid_on_focus, dia); dia->box_object = o; - e_box_orientation_set(o, 1); - e_box_homogenous_set(o, 1); - e_box_align_set(o, 0.5, 0.5); edje_object_part_swallow(dia->bg_object, "buttons_swallow", o); - evas_object_show(o); o = evas_object_rectangle_add(e_win_evas_get(dia->win)); dia->event_object = o; @@ -83,109 +69,27 @@ evas_object_event_callback_add(o, EVAS_CALLBACK_KEY_DOWN, _e_dialog_cb_key_down, dia); - dia->focused = NULL; - return dia; } void e_dialog_button_add(E_Dialog *dia, char *label, char *icon, void (*func) (void *data, E_Dialog *dia), void *data) { - E_Dialog_Button *db; - Evas_Coord mw, mh; - - db = E_NEW(E_Dialog_Button, 1); - db->dialog = dia; - if (label) db->label = strdup(label); - if (icon) db->icon = strdup(icon); - db->func = func; - db->data = data; - db->obj = edje_object_add(e_win_evas_get(dia->win)); - e_theme_edje_object_set(db->obj, "base/theme/dialog", - "widgets/dialog/button"); - edje_object_signal_callback_add(db->obj, "click", "", - _e_dialog_cb_button_clicked, db); - edje_object_part_text_set(db->obj, "button_text", db->label); - - evas_object_event_callback_add(db->obj, EVAS_CALLBACK_MOUSE_DOWN, _e_dialog_button_cb_mouse_down, db); - - if (icon) - { - db->obj_icon = edje_object_add(e_win_evas_get(dia->win)); - e_util_edje_icon_set(db->obj_icon, icon); - edje_object_part_swallow(db->obj, "icon_swallow", db->obj_icon); - edje_object_signal_emit(db->obj, "icon_visible", ""); - edje_object_message_signal_process(db->obj); - evas_object_show(db->obj_icon); - } - edje_object_size_min_calc(db->obj, &mw, &mh); - e_box_pack_end(dia->box_object, db->obj); - e_box_pack_options_set(db->obj, - 1, 1, /* fill */ - 0, 1, /* expand */ - 0.5, 0.5, /* align */ - mw, mh, /* min */ - 9999, mh /* max */ - ); - evas_object_show(db->obj); - - dia->buttons = evas_list_append(dia->buttons, db); -} - -int -e_dialog_button_focus_num(E_Dialog *dia, int button) -{ - E_Dialog_Button *db = NULL; - - if (button < 0) - return 0; - - db = evas_list_nth(dia->buttons, button); - - if (!db) - return 0; - - if (dia->focused) - { - E_Dialog_Button *focused; - - focused = dia->focused->data; - if (focused) - edje_object_signal_emit(focused->obj, "unfocus", ""); - } - - dia->focused = evas_list_nth_list(dia->buttons, button); - edje_object_signal_emit(db->obj, "focus", ""); + Evas_Object *o; - return 1; + if (!func) func = _e_dialog_del_func_cb; + o = e_widget_button_add(e_win_evas_get(dia->win), label, icon, func, data, dia); + e_widget_list_object_append(dia->box_object, o, 1, 1, 0.5); + dia->buttons = evas_list_append(dia->buttons, o); } int -e_dialog_button_focus_button(E_Dialog *dia, E_Dialog_Button *button) +e_dialog_button_focus_num(E_Dialog *dia, int button) { - E_Dialog_Button *db = NULL; - - if (!button) - return 0; - - db = evas_list_find(dia->buttons, button); - - if (!db) - return 0; + Evas_Object *o; - if (dia->focused) - { - E_Dialog_Button *focused; - - focused = dia->focused->data; - if (focused) - edje_object_signal_emit(focused->obj, "unfocus", ""); - } - - dia->focused = evas_list_find_list(dia->buttons, button); - edje_object_signal_emit(db->obj, "focus", ""); - - return 1; + o = evas_list_nth(dia->buttons, button); + if (o) e_widget_focus_steal(o); } void @@ -226,6 +130,8 @@ void e_dialog_content_set(E_Dialog *dia, Evas_Object *obj, Evas_Coord minw, Evas_Coord minh) { + dia->content_object = obj; + e_widget_on_focus_hook_set(obj, _e_dialog_cb_wid_on_focus, dia); edje_extern_object_min_size_set(obj, minw, minh); edje_object_part_swallow(dia->bg_object, "content_swallow", obj); evas_object_show(obj); @@ -246,7 +152,7 @@ } o = dia->box_object; - e_box_min_size_get(o, &mw, &mh); + e_widget_min_size_get(o, &mw, &mh); edje_extern_object_min_size_set(o, mw, mh); edje_object_part_swallow(dia->bg_object, "buttons_swallow", o); @@ -256,58 +162,30 @@ e_win_size_min_set(dia->win, mw, mh); e_win_size_max_set(dia->win, mw, mh); e_win_show(dia->win); + + if (!e_widget_focus_get(dia->box_object)) + e_widget_focus_set(dia->box_object, 1); } /* local subsystem functions */ static void _e_dialog_free(E_Dialog *dia) { - while (dia->buttons) - { - E_Dialog_Button *db; - - db = dia->buttons->data; - dia->buttons = evas_list_remove_list(dia->buttons, dia->buttons); - E_FREE(db->label); - E_FREE(db->icon); - evas_object_del(db->obj); - if (db->obj_icon) evas_object_del(db->obj_icon); - free(db); - } + if (dia->buttons) evas_list_free(dia->buttons); if (dia->text_object) evas_object_del(dia->text_object); if (dia->icon_object) evas_object_del(dia->icon_object); if (dia->box_object) evas_object_del(dia->box_object); if (dia->bg_object) evas_object_del(dia->bg_object); + if (dia->content_object) evas_object_del(dia->content_object); if (dia->event_object) evas_object_del(dia->event_object); e_object_del(E_OBJECT(dia->win)); free(dia); } static void -_e_dialog_cb_button_clicked(void *data, Evas_Object *obj, const char *emission, const char *source) +_e_dialog_del_func_cb(void *data, E_Dialog *dia) { - E_Dialog_Button *db; - - db = data; - if (db->func) - { - edje_object_signal_emit(db->obj, "focus", ""); - db->func(db->data, db->dialog); - } - else - e_object_del(E_OBJECT(db->dialog)); -} - -static void -_e_dialog_button_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event) -{ - E_Dialog *dia; - E_Dialog_Button *db; - - db = data; - dia = db->dialog; - - e_dialog_button_focus_button(dia, db); + e_object_del(E_OBJECT(dia)); } static void @@ -318,52 +196,64 @@ ev = event; dia = data; - if (!strcmp(ev->keyname, "Tab")) { - if ((dia->focused) && (dia->buttons)) + if (evas_key_modifier_is_set(evas_key_modifier_get(e_win_evas_get(dia->win)), "Shift")) { - E_Dialog_Button *db, *ndb; - - db = dia->focused->data; - if (evas_key_modifier_is_set(evas_key_modifier_get(e_win_evas_get(dia->win)), "Shift")) + if (e_widget_focus_get(dia->box_object)) { - if (dia->focused->prev) dia->focused = dia->focused->prev; - else dia->focused = evas_list_last(dia->buttons); + if (!e_widget_focus_jump(dia->box_object, 0)) + { + if (dia->text_object) + e_widget_focus_set(dia->box_object, 0); + else + { + e_widget_focus_set(dia->content_object, 0); + if (!e_widget_focus_get(dia->content_object)) + e_widget_focus_set(dia->box_object, 0); + } + } } else { - if (dia->focused->next) dia->focused = dia->focused->next; - else dia->focused = dia->buttons; - } - ndb = dia->focused->data; - if (ndb != db) - { - edje_object_signal_emit(db->obj, "unfocus", ""); - edje_object_signal_emit(ndb->obj, "focus", ""); - edje_object_signal_emit(ndb->obj, "enter", ""); + if (!e_widget_focus_jump(dia->content_object, 0)) + e_widget_focus_set(dia->box_object, 0); } - } - else + else { - E_Dialog_Button *db; - - dia->focused = dia->buttons; - - db = dia->focused->data; - edje_object_signal_emit(db->obj, "focus", ""); - edje_object_signal_emit(db->obj, "enter", ""); + if (e_widget_focus_get(dia->box_object)) + { + if (!e_widget_focus_jump(dia->box_object, 1)) + { + if (dia->text_object) + e_widget_focus_set(dia->box_object, 1); + else + { + e_widget_focus_set(dia->content_object, 1); + if (!e_widget_focus_get(dia->content_object)) + e_widget_focus_set(dia->box_object, 1); + } + } + } + else + { + if (!e_widget_focus_jump(dia->content_object, 1)) + e_widget_focus_set(dia->box_object, 1); + } } } else if (((!strcmp(ev->keyname, "Return")) || (!strcmp(ev->keyname, "KP_Enter")) || - (!strcmp(ev->keyname, "space"))) && dia->focused) + (!strcmp(ev->keyname, "space")))) { - E_Dialog_Button *db; - - db = evas_list_data(dia->focused); - edje_object_signal_emit(db->obj, "click", ""); + Evas_Object *o = NULL; + + if ((dia->content_object) && (e_widget_focus_get(dia->content_object))) + o = e_widget_focused_object_get(dia->content_object); + else + o = e_widget_focused_object_get(dia->box_object); + if (o) e_widget_activate(o); } } @@ -375,3 +265,16 @@ dia = win->data; e_object_del(E_OBJECT(dia)); } + +static void +_e_dialog_cb_wid_on_focus(void *data, Evas_Object *obj) +{ + E_Dialog *dia; + + dia = data; + if (obj == dia->content_object) + e_widget_focused_object_clear(dia->box_object); + else if (dia->content_object) + e_widget_focused_object_clear(dia->content_object); +} + =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_dialog.h,v retrieving revision 1.6 retrieving revision 1.7 diff -u -3 -r1.6 -r1.7 --- e_dialog.h 10 Oct 2005 12:16:18 -0000 1.6 +++ e_dialog.h 12 Oct 2005 16:02:33 -0000 1.7 @@ -20,17 +20,16 @@ Evas_Object *bg_object; Evas_Object *box_object; Evas_Object *text_object; + Evas_Object *content_object; Evas_Object *icon_object; Evas_Object *event_object; Evas_List *buttons; - Evas_List *focused; void *data; }; EAPI E_Dialog *e_dialog_new (E_Container *con); EAPI void e_dialog_button_add (E_Dialog *dia, char *label, char *icon, void (*func) (void *data, E_Dialog *dia), void *data); EAPI int e_dialog_button_focus_num (E_Dialog *dia, int button); -EAPI int e_dialog_button_focus_button (E_Dialog *dia, E_Dialog_Button *button); EAPI void e_dialog_title_set (E_Dialog *dia, char *title); EAPI void e_dialog_text_set (E_Dialog *dia, char *text); EAPI void e_dialog_icon_set (E_Dialog *dia, char *icon, Evas_Coord size); =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_pan.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -3 -r1.1 -r1.2 --- e_pan.c 11 Jul 2005 12:31:44 -0000 1.1 +++ e_pan.c 12 Oct 2005 16:02:33 -0000 1.2 @@ -4,7 +4,7 @@ #include "e.h" #define SMART_NAME "e_pan" -#define API_ENTRY E_Smart_Data *sd; sd = evas_object_smart_data_get(obj); if (!sd) +#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; typedef struct _E_Smart_Data E_Smart_Data; =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_test.c,v retrieving revision 1.20 retrieving revision 1.21 diff -u -3 -r1.20 -r1.21 --- e_test.c 11 Oct 2005 16:25:00 -0000 1.20 +++ e_test.c 12 Oct 2005 16:02:33 -0000 1.21 @@ -309,7 +309,13 @@ } #elif 0 static int my_val = 0; +static int my_val2 = 0; +static int my_val3 = 0; +static int my_val4 = 0; +static int my_val5 = 0; +static int my_val6 = 0; static int my_rval = 1; +static int my_rval2 = 1; static void _e_test_internal(E_Container *con) @@ -326,18 +332,18 @@ e = e_win_evas_get(dia->win); - ol = e_widget_list_add(e, 0); + ol = e_widget_list_add(e, 0, 0); - hb = e_widget_list_add(e, 1); + hb = e_widget_list_add(e, 1, 1); o = e_widget_framelist_add(e, "My Checklist", 0); e_widget_framelist_object_append(o, e_widget_check_add(e, "Checkbox 1", &my_val)); - e_widget_framelist_object_append(o, e_widget_check_add(e, "Checkbox 2", &my_val)); - e_widget_framelist_object_append(o, e_widget_check_add(e, "Checkbox 3", &my_val)); - e_widget_framelist_object_append(o, e_widget_check_add(e, "Checkbox and some long text", &my_val)); - e_widget_framelist_object_append(o, e_widget_check_add(e, "Checkbox 7", &my_val)); - e_widget_framelist_object_append(o, e_widget_check_add(e, "Koneko", &my_val)); + e_widget_framelist_object_append(o, e_widget_check_add(e, "Checkbox 2", &my_val2)); + e_widget_framelist_object_append(o, e_widget_check_add(e, "Checkbox 3", &my_val3)); + e_widget_framelist_object_append(o, e_widget_check_add(e, "Checkbox and some long text", &my_val4)); + e_widget_framelist_object_append(o, e_widget_check_add(e, "Checkbox 7", &my_val5)); + e_widget_framelist_object_append(o, e_widget_check_add(e, "Koneko", &my_val6)); rg = e_widget_radio_group_new(&my_rval); e_widget_framelist_object_append(o, e_widget_radio_add(e, "Rad 0", 0, rg)); @@ -350,7 +356,7 @@ o = e_widget_framelist_add(e, "My Checklist on the right", 0); - rg = e_widget_radio_group_new(&my_rval); + rg = e_widget_radio_group_new(&my_rval2); e_widget_framelist_object_append(o, e_widget_radio_add(e, "Rad 0", 0, rg)); e_widget_framelist_object_append(o, e_widget_radio_add(e, "Rad 1", 1, rg)); e_widget_framelist_object_append(o, e_widget_radio_add(e, "Rad 2", 2, rg)); =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_widget.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -3 -r1.1 -r1.2 --- e_widget.c 10 Oct 2005 12:16:18 -0000 1.1 +++ e_widget.c 12 Oct 2005 16:02:33 -0000 1.2 @@ -4,18 +4,26 @@ #include "e.h" #define SMART_NAME "e_widget" -#define API_ENTRY E_Smart_Data *sd; sd = evas_object_smart_data_get(obj); if (!sd) +#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; typedef struct _E_Smart_Data E_Smart_Data; struct _E_Smart_Data { + Evas_Object *parent_obj; Evas_Coord x, y, w, h; - Evas_Coord minw, minh, maxw, maxh; + Evas_Coord minw, minh; Evas_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 (*on_focus_func) (void *data, Evas_Object *obj); + void *on_focus_data; void *data; + unsigned char can_focus : 1; + unsigned char child_can_focus : 1; + unsigned char focused : 1; }; /* local subsystem functions */ @@ -55,6 +63,28 @@ } void +e_widget_focus_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj)) +{ + API_ENTRY return; + sd->focus_func = func; +} + +void +e_widget_activate_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj)) +{ + API_ENTRY return; + sd->activate_func = func; +} + +void +e_widget_on_focus_hook_set(Evas_Object *obj, void (*func) (void *data, Evas_Object *obj), void *data) +{ + API_ENTRY return; + sd->on_focus_func = func; + sd->on_focus_data = data; +} + +void e_widget_data_set(Evas_Object *obj, void *data) { API_ENTRY return; @@ -85,43 +115,261 @@ } void -e_widget_max_size_set(Evas_Object *obj, Evas_Coord maxw, Evas_Coord maxh) +e_widget_sub_object_add(Evas_Object *obj, Evas_Object *sobj) { API_ENTRY return; - sd->minw = maxw; - sd->maxh = maxh; + sd->subobjs = evas_list_append(sd->subobjs, sobj); + if (!sd->child_can_focus) + { + if (e_widget_can_focus_get(sobj)) sd->child_can_focus = 1; + } + if (!strcmp(evas_object_type_get(sobj), SMART_NAME)) + { + sd = evas_object_smart_data_get(sobj); + if (sd) sd->parent_obj = obj; + } } void -e_widget_max_size_get(Evas_Object *obj, Evas_Coord *maxw, Evas_Coord *maxh) +e_widget_resize_object_set(Evas_Object *obj, Evas_Object *sobj) { API_ENTRY return; - if (maxw) *maxw = sd->maxw; - if (maxh) *maxh = sd->maxh; + if (sd->resize_obj) evas_object_smart_member_del(sd->resize_obj); + sd->resize_obj = sobj; + evas_object_smart_member_add(obj, sobj); + _e_smart_reconfigure(sd); } void -e_widget_sub_object_add(Evas_Object *obj, Evas_Object *sobj) +e_widget_can_focus_set(Evas_Object *obj, int can_focus) { API_ENTRY return; - sd->subobjs = evas_list_append(sd->subobjs, sobj); + sd->can_focus = can_focus; +} + +int +e_widget_can_focus_get(Evas_Object *obj) +{ + API_ENTRY return 0; + if (sd->can_focus) return 1; + if (sd->child_can_focus) return 1; + return 0; +} + +int +e_widget_focus_get(Evas_Object *obj) +{ + API_ENTRY return 0; + return sd->focused; +} + +Evas_Object * +e_widget_focused_object_get(Evas_Object *obj) +{ + Evas_List *l; + API_ENTRY return NULL; + if (!sd->focused) return NULL; + for (l = sd->subobjs; l; l = l->next) + { + Evas_Object *fobj; + + fobj = e_widget_focused_object_get(l->data); + if (fobj) return fobj; + } + return obj; +} + +int +e_widget_focus_jump(Evas_Object *obj, int forward) +{ + API_ENTRY return 0; + if (!e_widget_can_focus_get(obj)) return 0; + /* if it has a focus func its an end-point widget like a button */ + if (sd->focus_func) + { + 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; + } + /* its some container */ + else + { + Evas_List *l; + int focus_next; + + 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) + { + for (l = sd->subobjs; l; l = l->next) + { + if (e_widget_can_focus_get(l->data)) + { + if (focus_next) + { + /* the previous focused item was unfocused - so focus + * the next one (that can be focused) */ + if (e_widget_focus_jump(l->data, forward)) return 1; + else break; + } + else + { + if (e_widget_focus_get(l->data)) + { + /* jump to the next focused item or focus this item */ + if (e_widget_focus_jump(l->data, forward)) return 1; + /* it returned 0 - it got to the last item and is past it */ + focus_next = 1; + } + } + } + } + } + else + { + for (l = evas_list_last(sd->subobjs); l; l = l->prev) + { + if (e_widget_can_focus_get(l->data)) + { + if (focus_next) + { + /* the previous focused item was unfocused - so focus + * the next one (that can be focused) */ + if (e_widget_focus_jump(l->data, forward)) return 1; + else break; + } + else + { + if (e_widget_focus_get(l->data)) + { + /* jump to the next focused item or focus this item */ + if (e_widget_focus_jump(l->data, forward)) return 1; + /* it returned 0 - it got to the last item and is past it */ + focus_next = 1; + } + } + } + } + } + } + } + /* no next item can be focused */ + sd->focused = 0; + return 0; } void -e_widget_sub_object_del(Evas_Object *obj, Evas_Object *sobj) +e_widget_focus_set(Evas_Object *obj, int first) { API_ENTRY return; - sd->subobjs = evas_list_remove(sd->subobjs, sobj); + if (!sd->focused) + { + sd->focused = 1; + if (sd->on_focus_func) sd->on_focus_func(sd->on_focus_data, obj); + } + if (sd->focus_func) + { + sd->focus_func(obj); + return; + } + else + { + Evas_List *l; + + if (first) + { + for (l = sd->subobjs; l; l = l->next) + { + if (e_widget_can_focus_get(l->data)) + { + e_widget_focus_set(l->data, first); + break; + } + } + } + else + { + for (l = evas_list_last(sd->subobjs); l; l = l->prev) + { + if (e_widget_can_focus_get(l->data)) + { + e_widget_focus_set(l->data, first); + break; + } + } + } + } +} + +Evas_Object * +e_widget_parent_get(Evas_Object *obj) +{ + API_ENTRY return NULL; + return sd->parent_obj; } void -e_widget_resize_object_set(Evas_Object *obj, Evas_Object *sobj) +e_widget_focused_object_clear(Evas_Object *obj) { + Evas_List *l; API_ENTRY return; - if (sd->resize_obj) evas_object_smart_member_del(sd->resize_obj); - sd->resize_obj = sobj; - evas_object_smart_member_add(obj, sobj); - _e_smart_reconfigure(sd); + if (!sd->focused) return; + sd->focused = 0; + for (l = sd->subobjs; l; l = l->next) + { + if (e_widget_focus_get(l->data)) + { + e_widget_focused_object_clear(l->data); + break; + } + } + if (sd->focus_func) sd->focus_func(obj); +} + +void +e_widget_focus_steal(Evas_Object *obj) +{ + Evas_Object *parent, *o; + API_ENTRY return; + if (sd->focused) return; + parent = obj; + for (;;) + { + o = e_widget_parent_get(parent); + if (!o) break; + parent = o; + } + e_widget_focused_object_clear(parent); + parent = obj; + for (;;) + { + 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; + } + sd = evas_object_smart_data_get(obj); + if (sd->focus_func) sd->focus_func(obj); + return; +} + +void +e_widget_activate(Evas_Object *obj) +{ + API_ENTRY return; + if (sd->activate_func) sd->activate_func(obj); } /* local subsystem functions */ @@ -146,6 +394,7 @@ sd->y = 0; sd->w = 0; sd->h = 0; + sd->can_focus = 1; evas_object_smart_data_set(obj, sd); } @@ -263,4 +512,3 @@ _e_smart_show, _e_smart_hide, _e_smart_color_set, _e_smart_clip_set, _e_smart_clip_unset, NULL); } - =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_widget.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -3 -r1.1 -r1.2 --- e_widget.h 10 Oct 2005 12:16:18 -0000 1.1 +++ e_widget.h 12 Oct 2005 16:02:33 -0000 1.2 @@ -8,15 +8,25 @@ EAPI Evas_Object *e_widget_add(Evas *evas); EAPI void e_widget_del_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj)); +EAPI void e_widget_focus_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj)); +EAPI void e_widget_activate_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj)); +EAPI void e_widget_on_focus_hook_set(Evas_Object *obj, void (*func) (void *data, Evas_Object *obj), void *data); EAPI void e_widget_data_set(Evas_Object *obj, void *data); EAPI void *e_widget_data_get(Evas_Object *obj); EAPI void e_widget_min_size_set(Evas_Object *obj, Evas_Coord minw, Evas_Coord minh); EAPI void e_widget_min_size_get(Evas_Object *obj, Evas_Coord *minw, Evas_Coord *minh); -EAPI void e_widget_max_size_set(Evas_Object *obj, Evas_Coord maxw, Evas_Coord maxh); -EAPI void e_widget_max_size_get(Evas_Object *obj, Evas_Coord *maxw, Evas_Coord *maxh); EAPI void e_widget_sub_object_add(Evas_Object *obj, Evas_Object *sobj); -EAPI void e_widget_sub_object_del(Evas_Object *obj, Evas_Object *sobj); EAPI void e_widget_resize_object_set(Evas_Object *obj, Evas_Object *sobj); - +EAPI void e_widget_can_focus_set(Evas_Object *obj, int can_focus); +EAPI int e_widget_can_focus_get(Evas_Object *obj); +EAPI int e_widget_focus_get(Evas_Object *obj); +EAPI Evas_Object *e_widget_focused_object_get(Evas_Object *obj); +EAPI int e_widget_focus_jump(Evas_Object *obj, int forward); +EAPI void e_widget_focus_set(Evas_Object *obj, int first); +EAPI void e_widget_focused_object_clear(Evas_Object *obj); +EAPI Evas_Object *e_widget_parent_get(Evas_Object *obj); +EAPI void e_widget_focus_steal(Evas_Object *obj); +EAPI void e_widget_activate(Evas_Object *obj); + #endif #endif =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_widget_button.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -3 -r1.1 -r1.2 --- e_widget_button.c 11 Oct 2005 16:25:00 -0000 1.1 +++ e_widget_button.c 12 Oct 2005 16:02:33 -0000 1.2 @@ -14,7 +14,10 @@ }; static void _e_wid_del_hook(Evas_Object *obj); +static void _e_wid_focus_hook(Evas_Object *obj); +static void _e_wid_activate_hook(Evas_Object *obj); static void _e_wid_signal_cb1(void *data, Evas_Object *obj, const char *emission, const char *source); +static void _e_wid_focus_steal(void *data, Evas *e, Evas_Object *obj, void *event_info); /* local subsystem functions */ /* externally accessible functions */ @@ -28,6 +31,8 @@ obj = e_widget_add(evas); 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); wd = calloc(1, sizeof(E_Widget_Data)); wd->func = func; wd->data = data; @@ -43,6 +48,7 @@ evas_object_show(o); 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); if (icon) @@ -73,10 +79,35 @@ } static void -_e_wid_signal_cb1(void *data, Evas_Object *obj, const char *emission, const char *source) +_e_wid_focus_hook(Evas_Object *obj) { E_Widget_Data *wd; - wd = e_widget_data_get(data); + wd = e_widget_data_get(obj); + if (e_widget_focus_get(obj)) + edje_object_signal_emit(wd->o_button, "focus_in", ""); + else + edje_object_signal_emit(wd->o_button, "focus_out", ""); +} + +static void +_e_wid_activate_hook(Evas_Object *obj) +{ + E_Widget_Data *wd; + + wd = e_widget_data_get(obj); if (wd->func) wd->func(wd->data, wd->data2); } + +static void +_e_wid_signal_cb1(void *data, Evas_Object *obj, const char *emission, const char *source) +{ + e_widget_focus_steal(data); + _e_wid_activate_hook(data); +} + +static void +_e_wid_focus_steal(void *data, Evas *e, Evas_Object *obj, void *event_info) +{ + e_widget_focus_steal(data); +} =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_widget_check.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -3 -r1.3 -r1.4 --- e_widget_check.c 11 Oct 2005 16:25:00 -0000 1.3 +++ e_widget_check.c 12 Oct 2005 16:02:33 -0000 1.4 @@ -6,11 +6,17 @@ typedef struct _E_Widget_Data E_Widget_Data; struct _E_Widget_Data { + Evas_Object *o_check; int *valptr; }; static void _e_wid_del_hook(Evas_Object *obj); +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); static void _e_wid_signal_cb1(void *data, Evas_Object *obj, const char *emission, const char *source); +static void _e_wid_focus_steal(void *data, Evas *e, Evas_Object *obj, void *event_info); + /* local subsystem functions */ /* externally accessible functions */ @@ -24,11 +30,14 @@ obj = e_widget_add(evas); 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); 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", "widgets/check"); edje_object_signal_callback_add(o, "toggled", "*", _e_wid_signal_cb1, obj); @@ -42,6 +51,7 @@ } 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; @@ -57,14 +67,52 @@ } static void -_e_wid_signal_cb1(void *data, Evas_Object *obj, const char *emission, const char *source) +_e_wid_focus_hook(Evas_Object *obj) +{ + E_Widget_Data *wd; + + wd = e_widget_data_get(obj); + if (e_widget_focus_get(obj)) + edje_object_signal_emit(wd->o_check, "focus_in", ""); + else + edje_object_signal_emit(wd->o_check, "focus_out", ""); +} + +static void +_e_wid_do(Evas_Object *obj) { E_Widget_Data *wd; - wd = e_widget_data_get(data); + wd = e_widget_data_get(obj); if (wd->valptr) { - if (!strcmp(source, "on")) *(wd->valptr) = 1; + if (*(wd->valptr) == 0) *(wd->valptr) = 1; else *(wd->valptr) = 0; } } + +static void +_e_wid_activate_hook(Evas_Object *obj) +{ + E_Widget_Data *wd; + + wd = e_widget_data_get(obj); + _e_wid_do(obj); + if (wd->valptr) + { + if (*(wd->valptr)) edje_object_signal_emit(wd->o_check, "toggle_on", ""); + else edje_object_signal_emit(wd->o_check, "toggle_off", ""); + } +} + +static void +_e_wid_signal_cb1(void *data, Evas_Object *obj, const char *emission, const char *source) +{ + _e_wid_do(data); +} + +static void +_e_wid_focus_steal(void *data, Evas *e, Evas_Object *obj, void *event_info) +{ + e_widget_focus_steal(data); +} =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_widget_list.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -3 -r1.1 -r1.2 --- e_widget_list.c 11 Oct 2005 16:25:00 -0000 1.1 +++ e_widget_list.c 12 Oct 2005 16:02:33 -0000 1.2 @@ -15,7 +15,7 @@ /* externally accessible functions */ Evas_Object * -e_widget_list_add(Evas *evas, int horiz) +e_widget_list_add(Evas *evas, int homogenous, int horiz) { Evas_Object *obj, *o; E_Widget_Data *wd; @@ -29,7 +29,7 @@ o = e_box_add(evas); wd->o_box = o; e_box_orientation_set(o, horiz); - e_box_homogenous_set(o, 0); + e_box_homogenous_set(o, homogenous); evas_object_show(o); e_widget_sub_object_add(obj, o); e_widget_resize_object_set(obj, o); =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_widget_list.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -3 -r1.1 -r1.2 --- e_widget_list.h 11 Oct 2005 16:25:00 -0000 1.1 +++ e_widget_list.h 12 Oct 2005 16:02:33 -0000 1.2 @@ -6,7 +6,7 @@ #ifndef E_WIDGET_LIST_H #define E_WIDGET_LIST_H -EAPI Evas_Object *e_widget_list_add(Evas *evas, int horiz); +EAPI Evas_Object *e_widget_list_add(Evas *evas, int homogenous, int horiz); EAPI void e_widget_list_object_append(Evas_Object *obj, Evas_Object *sobj, int fill, int expand, double align); =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_widget_radio.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -3 -r1.2 -r1.3 --- e_widget_radio.c 11 Oct 2005 16:25:00 -0000 1.2 +++ e_widget_radio.c 12 Oct 2005 16:02:33 -0000 1.3 @@ -18,7 +18,11 @@ }; static void _e_wid_del_hook(Evas_Object *obj); +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); static void _e_wid_signal_cb1(void *data, Evas_Object *obj, const char *emission, const char *source); +static void _e_wid_focus_steal(void *data, Evas *e, Evas_Object *obj, void *event_info); /* local subsystem functions */ /* externally accessible functions */ @@ -42,6 +46,8 @@ obj = e_widget_add(evas); 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); wd = calloc(1, sizeof(E_Widget_Data)); wd->group = group; wd->valnum = valnum; @@ -66,6 +72,7 @@ } 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; @@ -86,11 +93,23 @@ } static void -_e_wid_signal_cb1(void *data, Evas_Object *obj, const char *emission, const char *source) +_e_wid_focus_hook(Evas_Object *obj) +{ + E_Widget_Data *wd; + + wd = e_widget_data_get(obj); + if (e_widget_focus_get(obj)) + edje_object_signal_emit(wd->o_radio, "focus_in", ""); + else + edje_object_signal_emit(wd->o_radio, "focus_out", ""); +} + +static void +_e_wid_do(Evas_Object *obj) { E_Widget_Data *wd; - wd = e_widget_data_get(data); + wd = e_widget_data_get(obj); if ((wd->group) && (wd->group->valptr)) { Evas_List *l; @@ -99,7 +118,7 @@ for (l = wd->group->radios; l; l = l->next) { wd = e_widget_data_get(l->data); - if (l->data != data) + if (l->data != obj) { wd = e_widget_data_get(l->data); if (wd->valnum == *(wd->group->valptr)) @@ -111,7 +130,29 @@ } } if (!toggled) return; - wd = e_widget_data_get(data); - if (!strcmp(source, "on")) *(wd->group->valptr) = wd->valnum; + wd = e_widget_data_get(obj); + *(wd->group->valptr) = wd->valnum; } } + +static void +_e_wid_activate_hook(Evas_Object *obj) +{ + E_Widget_Data *wd; + + wd = e_widget_data_get(obj); + _e_wid_do(obj); + edje_object_signal_emit(wd->o_radio, "toggle_on", ""); +} + +static void +_e_wid_signal_cb1(void *data, Evas_Object *obj, const char *emission, const char *source) +{ + _e_wid_do(data); +} + +static void +_e_wid_focus_steal(void *data, Evas *e, Evas_Object *obj, void *event_info) +{ + e_widget_focus_steal(data); +} ------------------------------------------------------- This SF.Net email is sponsored by: Power Architecture Resource Center: Free content, downloads, discussions, and more. http://solutions.newsforge.com/ibmarch.tmpl _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs