and now all the internal widgets understand keyboard focus and control.

dialog now uses internal widgets for buttons.


SVN revision: 17464
This commit is contained in:
Carsten Haitzler 2005-10-12 16:02:33 +00:00
parent 248f977318
commit 03651d0fcb
16 changed files with 640 additions and 779 deletions

View File

@ -4,6 +4,7 @@ images {
image: "e17_titlebar_glint1.png" COMP; image: "e17_titlebar_glint1.png" COMP;
image: "e17_titlebar_glint2.png" COMP; image: "e17_titlebar_glint2.png" COMP;
image: "e17_titlebar_glint3.png" COMP; image: "e17_titlebar_glint3.png" COMP;
image: "focus.png" COMP;
} }
group { group {
@ -15,6 +16,7 @@ group {
mouse_events: 1; mouse_events: 1;
description { description {
state: "default" 0.0; state: "default" 0.0;
min: 64 16;
image { image {
normal: "e17_button.png"; normal: "e17_button.png";
border: 8 8 8 8; border: 8 8 8 8;
@ -37,12 +39,12 @@ group {
color: 0 0 0 0; color: 0 0 0 0;
rel1 { rel1 {
relative: 0.0 0.0; relative: 0.0 0.0;
offset: 0 11; offset: 7 11;
to: "button_image"; to: "button_image";
} }
rel2 { rel2 {
relative: 0.0 1.0; relative: 0.0 1.0;
offset: 0 -12; offset: 6 -12;
to: "button_image"; to: "button_image";
} }
} }
@ -245,6 +247,29 @@ group {
color: 255 255 255 255; color: 255 255 255 255;
} }
} }
part {
name: "focus";
mouse_events: 0;
description {
state: "default" 0.0;
visible: 0;
color: 255 255 255 0;
image {
normal: "focus.png";
border: 7 7 7 7;
middle: 0;
}
fill {
smooth: 0;
}
}
description {
state: "focused" 0.0;
inherit: "default" 0.0;
visible: 1;
color: 255 255 255 255;
}
}
} }
programs { programs {
program { program {
@ -331,5 +356,21 @@ group {
target: "glint2"; target: "glint2";
target: "glint3"; target: "glint3";
} }
program {
name: "focus_in";
signal: "focus_in";
source: "";
action: STATE_SET "focused" 0.0;
transition: DECELERATE 0.2;
target: "focus";
}
program {
name: "focus_out";
signal: "focus_out";
source: "";
action: STATE_SET "default" 0.0;
transition: ACCELERATE 0.5;
target: "focus";
}
} }
} }

View File

@ -1,6 +1,7 @@
images { images {
image: "e17_menu_check1.png" COMP; image: "e17_menu_check1.png" COMP;
image: "e17_menu_check2.png" COMP; image: "e17_menu_check2.png" COMP;
image: "focus.png" COMP;
} }
group { group {
name: "widgets/check"; name: "widgets/check";
@ -89,6 +90,29 @@ group {
color: 0 0 0 0; color: 0 0 0 0;
} }
} }
part {
name: "focus";
mouse_events: 0;
description {
state: "default" 0.0;
visible: 0;
color: 255 255 255 0;
image {
normal: "focus.png";
border: 7 7 7 7;
middle: 0;
}
fill {
smooth: 0;
}
}
description {
state: "focused" 0.0;
inherit: "default" 0.0;
visible: 1;
color: 255 255 255 255;
}
}
} }
programs { programs {
program { program {
@ -124,5 +148,21 @@ group {
} }
} }
} }
program {
name: "focus_in";
signal: "focus_in";
source: "";
action: STATE_SET "focused" 0.0;
transition: DECELERATE 0.2;
target: "focus";
}
program {
name: "focus_out";
signal: "focus_out";
source: "";
action: STATE_SET "default" 0.0;
transition: ACCELERATE 0.5;
target: "focus";
}
} }
} }

View File

@ -1,158 +1,7 @@
#define FOCUS_COLOR 255 255 255 200
#define FOCUS_RECT(x1, y1, x2, y2, offx1, offy1, offx2, offy2) \
part { \
name: "focus_rect_top"; \
mouse_events: 0; \
description { \
state: "default" 0.0; \
visible: 0; \
color: FOCUS_COLOR; \
rel1 { \
relative: x1 y1; \
offset: offx1 offy1; \
} \
rel2 { \
relative: x2 y1; \
offset: offx2 offy1; \
} \
image { \
normal: "focus.png"; \
} \
fill { \
smooth: 0; \
size { \
relative: 0 0; \
offset: 32 32; \
} \
} \
} \
description { \
state: "focused" 0.0; \
inherit: "default" 0.0; \
visible: 1; \
} \
} \
part { \
name: "focus_rect_bottom"; \
mouse_events: 0; \
description { \
state: "default" 0.0; \
visible: 0; \
color: FOCUS_COLOR; \
rel1 { \
relative: x1 y2; \
offset: offx1 offy2; \
} \
rel2 { \
relative: x2 y2; \
offset: offx2 offy2; \
} \
image { \
normal: "focus.png"; \
} \
fill { \
smooth: 0; \
size { \
relative: 0 0; \
offset: 32 32; \
} \
} \
} \
description { \
state: "focused" 0.0; \
inherit: "default" 0.0; \
visible: 1; \
} \
} \
part { \
name: "focus_rect_left"; \
mouse_events: 0; \
description { \
state: "default" 0.0; \
visible: 0; \
color: FOCUS_COLOR; \
rel1 { \
relative: x1 y1; \
offset: offx1 (offy1 + 1); \
} \
rel2 { \
relative: x1 y2; \
offset: offx1 (offy2 - 1); \
} \
image { \
normal: "focus.png"; \
} \
fill { \
smooth: 0; \
size { \
relative: 0 0; \
offset: 32 32; \
} \
} \
} \
description { \
state: "focused" 0.0; \
inherit: "default" 0.0; \
visible: 1; \
} \
} \
part { \
name: "focus_rect_right"; \
mouse_events: 0; \
description { \
state: "default" 0.0; \
visible: 0; \
color: FOCUS_COLOR; \
rel1 { \
relative: x2 y1; \
offset: offx2 (offy1 + 1); \
} \
rel2 { \
relative: x2 y2; \
offset: offx2 (offy2 - 1); \
} \
image { \
normal: "focus.png"; \
} \
fill { \
smooth: 0; \
size { \
relative: 0 0; \
offset: 32 32; \
} \
} \
} \
description { \
state: "focused" 0.0; \
inherit: "default" 0.0; \
visible: 1; \
} \
}
#define FOCUS_ACTION \
action: STATE_SET "focused" 0.0; \
target: "focus_rect_top"; \
target: "focus_rect_bottom"; \
target: "focus_rect_left"; \
target: "focus_rect_right";
#define UNFOCUS_ACTION \
action: STATE_SET "default" 0.0; \
target: "focus_rect_top"; \
target: "focus_rect_bottom"; \
target: "focus_rect_left"; \
target: "focus_rect_right";
images { images {
image: "e17_menu_bg_border.png" COMP; image: "e17_menu_bg_border.png" COMP;
// image: "e17_menu_bg.png" COMP;
// image: "e17_winlist_top.png" COMP;
image: "e17_winlist_bottom.png" COMP; image: "e17_winlist_bottom.png" COMP;
image: "e17_button2.png" COMP;
image: "e17_button.png" COMP;
image: "e17_dialog_watermark.png" COMP; image: "e17_dialog_watermark.png" COMP;
image: "focus.png" COMP;
} }
styles styles
@ -178,7 +27,6 @@ group {
rel1 { rel1 {
relative: 0.0 0.0; relative: 0.0 0.0;
offset: 1 1; offset: 1 1;
// to_y: "base2";
} }
rel2 { rel2 {
relative: 1.0 1.0; relative: 1.0 1.0;
@ -209,31 +57,6 @@ group {
} }
} }
} }
/*
part {
name: "base2";
mouse_events: 0;
description {
state: "default" 0.0;
max: 99999 48;
align: 0.5 0.0;
rel1 {
relative: 0.0 0.0;
offset: 1 1;
}
rel2 {
relative: 1.0 1.0;
offset: -2 -2;
}
image {
normal: "e17_menu_bg.png";
}
fill {
smooth: 0;
}
}
}
*/
part { part {
name: "base3"; name: "base3";
mouse_events: 0; mouse_events: 0;
@ -294,31 +117,6 @@ group {
} }
} }
} }
/*
part {
name: "top";
mouse_events: 0;
description {
state: "default" 0.0;
rel1 {
relative: 0.0 0.0;
offset: 1 1;
}
rel2 {
relative: 1.0 0.0;
offset: -2 16;
to_y: "content_swallow";
}
image {
normal: "e17_winlist_top.png";
border: 0 0 0 19;
}
fill {
smooth: 0;
}
}
}
*/
part { part {
name: "bottom"; name: "bottom";
mouse_events: 0; mouse_events: 0;
@ -363,350 +161,6 @@ group {
} }
} }
group {
name: "widgets/dialog/button";
parts {
part {
name: "button_image";
type: IMAGE;
mouse_events: 1;
description {
state: "default" 0.0;
min: 64 32;
image {
normal: "e17_button.png";
border: 8 8 8 8;
}
}
description {
state: "clicked" 0.0;
min: 64 32;
image {
normal: "e17_button2.png";
border: 8 8 8 8;
}
}
}
part {
name: "icon_swallow";
type: SWALLOW;
description {
state: "default" 0.0;
align: 0.0 0.5;
color: 0 0 0 0;
rel1 {
relative: 0.0 0.0;
offset: 0 0;
to: "button_image";
}
rel2 {
relative: 0.0 1.0;
offset: 0 -7;
to: "button_image";
}
}
description {
state: "visible" 0.0;
inherit: "default" 0.0;
aspect: 1.0 1.0;
aspect_preference: VERTICAL;
align: 0.0 0.5;
color: 0 0 0 0;
rel1 {
relative: 0.0 0.0;
offset: 6 6;
to: "button_image";
}
rel2 {
relative: 0.0 1.0;
offset: 5 -7;
to: "button_image";
}
}
}
part {
name: "button_text";
type: TEXT;
effect: SHADOW;
mouse_events: 0;
description {
state: "default" 0.0;
rel1 {
relative: 1.0 0.0;
offset: 6 6;
to_x: "icon_swallow";
to_y: "button_image";
}
rel2 {
relative: 1.0 1.0;
offset: -7 -7;
to: "button_image";
}
color: 0 0 0 255;
color3: 255 255 255 128;
text {
text: "OK";
font: "Edje-Vera";
size: 10;
min: 1 1;
align: 0.5 0.5;
}
}
}
part {
name: "glint_clip";
type: RECT;
mouse_events: 0;
description {
state: "default" 0.0;
color: 255 255 255 255;
rel1 {
relative: 0.0 0.0;
offset: 3 3;
}
rel2 {
relative: 1.0 1.0;
offset: -4 -4;
}
}
}
part {
name: "glint1";
mouse_events: 0;
description {
state: "default" 0.0;
visible: 0;
color: 255 255 255 0;
align: 0.0 0.0;
max: 34 13;
rel1 {
relative: 0.0 0.0;
offset: 2 2;
}
rel2 {
relative: 1.0 1.0;
offset: -3 -3;
}
image {
normal: "e17_titlebar_glint1.png";
border: 5 0 5 0;
}
fill {
smooth: 0;
}
}
description {
state: "active" 0.0;
inherit: "default" 0.0;
visible: 1;
color: 255 255 255 255;
}
}
part {
name: "glint2";
mouse_events: 0;
clip_to: "glint_clip";
description {
state: "default" 0.0;
visible: 0;
color: 255 255 255 0;
align: 1.0 0.5;
max: 0 0;
rel1 {
relative: 0.0 0.0;
offset: 3 3;
}
rel2 {
relative: 0.0 1.0;
offset: 3 -4;
}
image {
normal: "e17_titlebar_glint2.png";
border: 0 0 5 5;
}
fill {
smooth: 0;
}
}
description {
state: "active" 0.0;
inherit: "default" 0.0;
visible: 1;
color: 255 255 255 255;
max: 169 9999;
min: 169 8;
align: 0.5 0.5;
}
description {
state: "active2" 0.0;
inherit: "default" 0.0;
visible: 1;
color: 255 255 255 128;
max: 169 9999;
min: 169 8;
align: 0.5 0.5;
rel1 {
relative: 1.0 0.0;
offset: -4 3;
}
rel2 {
relative: 1.0 1.0;
offset: -4 -4;
}
}
description {
state: "active3" 0.0;
inherit: "default" 0.0;
visible: 0;
color: 255 255 255 0;
max: 169 9999;
min: 169 8;
align: 0.0 0.5;
rel1 {
relative: 1.0 0.0;
offset: -4 3;
}
rel2 {
relative: 1.0 1.0;
offset: -4 -4;
}
}
}
part {
name: "glint3";
mouse_events: 0;
description {
state: "default" 0.0;
visible: 0;
color: 255 255 255 0;
align: 1.0 1.0;
max: 34 13;
rel1 {
relative: 0.0 0.0;
offset: 2 2;
}
rel2 {
relative: 1.0 1.0;
offset: -3 -3;
}
image {
normal: "e17_titlebar_glint3.png";
border: 0 5 0 5;
}
fill {
smooth: 0;
}
}
description {
state: "active" 0.0;
inherit: "default" 0.0;
visible: 1;
color: 255 255 255 255;
}
}
FOCUS_RECT(0.0, 0.0, 1.0, 1.0, 7, 7, -8, -8)
}
programs {
program {
name: "button_click";
signal: "mouse,down,1";
source: "button_image";
action: STATE_SET "clicked" 0.0;
target: "button_image";
}
program {
name: "button_unclick";
signal: "mouse,up,1";
source: "button_image";
action: STATE_SET "default" 0.0;
target: "button_image";
}
program {
name: "button_unclick2";
signal: "mouse,clicked,1";
source: "button_image";
action: SIGNAL_EMIT "click" "";
}
program {
name: "icon_visible";
signal: "icon_visible";
source: "";
action: STATE_SET "visible" 0.0;
target: "icon_swallow";
}
program {
name: "button_in";
signal: "mouse,in";
source: "button_image";
action: SIGNAL_EMIT "enter" "";
}
program {
name: "button_enter";
signal: "enter";
source: "";
script {
run_program(PROGRAM:"go_active");
}
}
program {
name: "go_active";
action: STATE_SET "active" 0.0;
target: "glint1";
target: "glint2";
transition: LINEAR 0.05;
after: "go_active2";
after: "go_active2b";
}
program {
name: "go_active2";
action: STATE_SET "active2" 0.0;
target: "glint2";
transition: LINEAR 0.2;
after: "go_active3";
after: "go_active3b";
}
program {
name: "go_active2b";
action: STATE_SET "active" 0.0;
target: "glint3";
transition: LINEAR 0.2;
}
program {
name: "go_active3";
action: STATE_SET "active3" 0.0;
target: "glint2";
transition: LINEAR 0.05;
}
program {
name: "go_active3b";
action: STATE_SET "default" 0.0;
target: "glint3";
transition: LINEAR 0.1;
after: "go_active4";
}
program {
name: "go_active4";
action: STATE_SET "default" 0.0;
target: "glint1";
target: "glint2";
target: "glint3";
}
program {
name: "button_focus";
signal: "focus";
source: "";
FOCUS_ACTION
}
program {
name: "button_unfocus";
signal: "unfocus";
source: "";
UNFOCUS_ACTION
}
}
}
group { group {
name: "widgets/dialog/text"; name: "widgets/dialog/text";
parts { parts {

View File

@ -1,6 +1,7 @@
images { images {
image: "e17_menu_radio1.png" COMP; image: "e17_menu_radio1.png" COMP;
image: "e17_menu_radio2.png" COMP; image: "e17_menu_radio2.png" COMP;
image: "focus.png" COMP;
} }
group { group {
name: "widgets/radio"; name: "widgets/radio";
@ -89,6 +90,29 @@ group {
color: 0 0 0 0; color: 0 0 0 0;
} }
} }
part {
name: "focus";
mouse_events: 0;
description {
state: "default" 0.0;
visible: 0;
color: 255 255 255 0;
image {
normal: "focus.png";
border: 7 7 7 7;
middle: 0;
}
fill {
smooth: 0;
}
}
description {
state: "focused" 0.0;
inherit: "default" 0.0;
visible: 1;
color: 255 255 255 255;
}
}
} }
programs { programs {
program { program {
@ -117,5 +141,21 @@ group {
name: "click2"; name: "click2";
action: SIGNAL_EMIT "toggled" "on"; action: SIGNAL_EMIT "toggled" "on";
} }
program {
name: "focus_in";
signal: "focus_in";
source: "";
action: STATE_SET "focused" 0.0;
transition: DECELERATE 0.2;
target: "focus";
}
program {
name: "focus_out";
signal: "focus_out";
source: "";
action: STATE_SET "default" 0.0;
transition: ACCELERATE 0.5;
target: "focus";
}
} }
} }

Binary file not shown.

View File

@ -3,23 +3,12 @@
*/ */
#include "e.h" #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 */ /* local subsystem functions */
static void _e_dialog_free(E_Dialog *dia); 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_del_func_cb(void *data, E_Dialog *dia);
static void _e_dialog_button_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event);
static void _e_dialog_cb_delete(E_Win *win); 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_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 */ /* local subsystem globals */
@ -59,14 +48,11 @@ e_dialog_new(E_Container *con)
"widgets/dialog/main"); "widgets/dialog/main");
evas_object_move(o, 0, 0); evas_object_move(o, 0, 0);
evas_object_show(o); 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; 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); 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)); o = evas_object_rectangle_add(e_win_evas_get(dia->win));
dia->event_object = o; dia->event_object = o;
@ -83,109 +69,27 @@ e_dialog_new(E_Container *con)
evas_object_event_callback_add(o, EVAS_CALLBACK_KEY_DOWN, _e_dialog_cb_key_down, dia); evas_object_event_callback_add(o, EVAS_CALLBACK_KEY_DOWN, _e_dialog_cb_key_down, dia);
dia->focused = NULL;
return dia; return dia;
} }
void void
e_dialog_button_add(E_Dialog *dia, char *label, char *icon, void (*func) (void *data, E_Dialog *dia), void *data) 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_Object *o;
Evas_Coord mw, mh;
if (!func) func = _e_dialog_del_func_cb;
db = E_NEW(E_Dialog_Button, 1); o = e_widget_button_add(e_win_evas_get(dia->win), label, icon, func, data, dia);
db->dialog = dia; e_widget_list_object_append(dia->box_object, o, 1, 1, 0.5);
if (label) db->label = strdup(label); dia->buttons = evas_list_append(dia->buttons, o);
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 int
e_dialog_button_focus_num(E_Dialog *dia, int button) e_dialog_button_focus_num(E_Dialog *dia, int button)
{ {
E_Dialog_Button *db = NULL; Evas_Object *o;
if (button < 0)
return 0;
db = evas_list_nth(dia->buttons, button); o = evas_list_nth(dia->buttons, button);
if (o) e_widget_focus_steal(o);
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", "");
return 1;
}
int
e_dialog_button_focus_button(E_Dialog *dia, E_Dialog_Button *button)
{
E_Dialog_Button *db = NULL;
if (!button)
return 0;
db = evas_list_find(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_find_list(dia->buttons, button);
edje_object_signal_emit(db->obj, "focus", "");
return 1;
} }
void void
@ -226,6 +130,8 @@ e_dialog_icon_set(E_Dialog *dia, char *icon, Evas_Coord size)
void void
e_dialog_content_set(E_Dialog *dia, Evas_Object *obj, Evas_Coord minw, Evas_Coord minh) 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_extern_object_min_size_set(obj, minw, minh);
edje_object_part_swallow(dia->bg_object, "content_swallow", obj); edje_object_part_swallow(dia->bg_object, "content_swallow", obj);
evas_object_show(obj); evas_object_show(obj);
@ -246,7 +152,7 @@ e_dialog_show(E_Dialog *dia)
} }
o = dia->box_object; 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_extern_object_min_size_set(o, mw, mh);
edje_object_part_swallow(dia->bg_object, "buttons_swallow", o); edje_object_part_swallow(dia->bg_object, "buttons_swallow", o);
@ -256,58 +162,30 @@ e_dialog_show(E_Dialog *dia)
e_win_size_min_set(dia->win, mw, mh); e_win_size_min_set(dia->win, mw, mh);
e_win_size_max_set(dia->win, mw, mh); e_win_size_max_set(dia->win, mw, mh);
e_win_show(dia->win); e_win_show(dia->win);
if (!e_widget_focus_get(dia->box_object))
e_widget_focus_set(dia->box_object, 1);
} }
/* local subsystem functions */ /* local subsystem functions */
static void static void
_e_dialog_free(E_Dialog *dia) _e_dialog_free(E_Dialog *dia)
{ {
while (dia->buttons) if (dia->buttons) evas_list_free(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->text_object) evas_object_del(dia->text_object); if (dia->text_object) evas_object_del(dia->text_object);
if (dia->icon_object) evas_object_del(dia->icon_object); if (dia->icon_object) evas_object_del(dia->icon_object);
if (dia->box_object) evas_object_del(dia->box_object); if (dia->box_object) evas_object_del(dia->box_object);
if (dia->bg_object) evas_object_del(dia->bg_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); if (dia->event_object) evas_object_del(dia->event_object);
e_object_del(E_OBJECT(dia->win)); e_object_del(E_OBJECT(dia->win));
free(dia); free(dia);
} }
static void 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; e_object_del(E_OBJECT(dia));
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);
} }
static void static void
@ -318,52 +196,64 @@ _e_dialog_cb_key_down(void *data, Evas *e, Evas_Object *obj, void *event)
ev = event; ev = event;
dia = data; dia = data;
if (!strcmp(ev->keyname, "Tab")) 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; if (e_widget_focus_get(dia->box_object))
db = dia->focused->data;
if (evas_key_modifier_is_set(evas_key_modifier_get(e_win_evas_get(dia->win)), "Shift"))
{ {
if (dia->focused->prev) dia->focused = dia->focused->prev; if (!e_widget_focus_jump(dia->box_object, 0))
else dia->focused = evas_list_last(dia->buttons); {
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 else
{ {
if (dia->focused->next) dia->focused = dia->focused->next; if (!e_widget_focus_jump(dia->content_object, 0))
else dia->focused = dia->buttons; e_widget_focus_set(dia->box_object, 0);
} }
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", "");
}
} }
else else
{ {
E_Dialog_Button *db; if (e_widget_focus_get(dia->box_object))
{
dia->focused = dia->buttons; if (!e_widget_focus_jump(dia->box_object, 1))
{
db = dia->focused->data; if (dia->text_object)
edje_object_signal_emit(db->obj, "focus", ""); e_widget_focus_set(dia->box_object, 1);
edje_object_signal_emit(db->obj, "enter", ""); 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")) || else if (((!strcmp(ev->keyname, "Return")) ||
(!strcmp(ev->keyname, "KP_Enter")) || (!strcmp(ev->keyname, "KP_Enter")) ||
(!strcmp(ev->keyname, "space"))) && dia->focused) (!strcmp(ev->keyname, "space"))))
{ {
E_Dialog_Button *db; Evas_Object *o = NULL;
db = evas_list_data(dia->focused); if ((dia->content_object) && (e_widget_focus_get(dia->content_object)))
edje_object_signal_emit(db->obj, "click", ""); 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 @@ _e_dialog_cb_delete(E_Win *win)
dia = win->data; dia = win->data;
e_object_del(E_OBJECT(dia)); 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);
}

View File

@ -20,17 +20,16 @@ struct _E_Dialog
Evas_Object *bg_object; Evas_Object *bg_object;
Evas_Object *box_object; Evas_Object *box_object;
Evas_Object *text_object; Evas_Object *text_object;
Evas_Object *content_object;
Evas_Object *icon_object; Evas_Object *icon_object;
Evas_Object *event_object; Evas_Object *event_object;
Evas_List *buttons; Evas_List *buttons;
Evas_List *focused;
void *data; void *data;
}; };
EAPI E_Dialog *e_dialog_new (E_Container *con); 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 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_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_title_set (E_Dialog *dia, char *title);
EAPI void e_dialog_text_set (E_Dialog *dia, char *text); 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); EAPI void e_dialog_icon_set (E_Dialog *dia, char *icon, Evas_Coord size);

View File

@ -4,7 +4,7 @@
#include "e.h" #include "e.h"
#define SMART_NAME "e_pan" #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; #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; typedef struct _E_Smart_Data E_Smart_Data;

View File

@ -309,7 +309,13 @@ _e_test_internal(E_Container *con)
} }
#elif 0 #elif 0
static int my_val = 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_rval = 1;
static int my_rval2 = 1;
static void static void
_e_test_internal(E_Container *con) _e_test_internal(E_Container *con)
@ -326,18 +332,18 @@ _e_test_internal(E_Container *con)
e = e_win_evas_get(dia->win); 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); 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 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 2", &my_val2));
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 3", &my_val3));
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 and some long text", &my_val4));
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, "Checkbox 7", &my_val5));
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, "Koneko", &my_val6));
rg = e_widget_radio_group_new(&my_rval); rg = e_widget_radio_group_new(&my_rval);
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 0", 0, rg));
@ -350,7 +356,7 @@ _e_test_internal(E_Container *con)
o = e_widget_framelist_add(e, "My Checklist on the right", 0); 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 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 1", 1, rg));
e_widget_framelist_object_append(o, e_widget_radio_add(e, "Rad 2", 2, rg)); e_widget_framelist_object_append(o, e_widget_radio_add(e, "Rad 2", 2, rg));

View File

@ -4,18 +4,26 @@
#include "e.h" #include "e.h"
#define SMART_NAME "e_widget" #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; #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; typedef struct _E_Smart_Data E_Smart_Data;
struct _E_Smart_Data struct _E_Smart_Data
{ {
Evas_Object *parent_obj;
Evas_Coord x, y, w, h; Evas_Coord x, y, w, h;
Evas_Coord minw, minh, maxw, maxh; Evas_Coord minw, minh;
Evas_List *subobjs; Evas_List *subobjs;
Evas_Object *resize_obj; Evas_Object *resize_obj;
void (*del_func) (Evas_Object *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; void *data;
unsigned char can_focus : 1;
unsigned char child_can_focus : 1;
unsigned char focused : 1;
}; };
/* local subsystem functions */ /* local subsystem functions */
@ -54,6 +62,28 @@ e_widget_del_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj))
sd->del_func = func; sd->del_func = func;
} }
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 void
e_widget_data_set(Evas_Object *obj, void *data) e_widget_data_set(Evas_Object *obj, void *data)
{ {
@ -84,34 +114,20 @@ e_widget_min_size_get(Evas_Object *obj, Evas_Coord *minw, Evas_Coord *minh)
if (minh) *minh = sd->minh; if (minh) *minh = sd->minh;
} }
void
e_widget_max_size_set(Evas_Object *obj, Evas_Coord maxw, Evas_Coord maxh)
{
API_ENTRY return;
sd->minw = maxw;
sd->maxh = maxh;
}
void
e_widget_max_size_get(Evas_Object *obj, Evas_Coord *maxw, Evas_Coord *maxh)
{
API_ENTRY return;
if (maxw) *maxw = sd->maxw;
if (maxh) *maxh = sd->maxh;
}
void void
e_widget_sub_object_add(Evas_Object *obj, Evas_Object *sobj) e_widget_sub_object_add(Evas_Object *obj, Evas_Object *sobj)
{ {
API_ENTRY return; API_ENTRY return;
sd->subobjs = evas_list_append(sd->subobjs, sobj); sd->subobjs = evas_list_append(sd->subobjs, sobj);
} if (!sd->child_can_focus)
{
void if (e_widget_can_focus_get(sobj)) sd->child_can_focus = 1;
e_widget_sub_object_del(Evas_Object *obj, Evas_Object *sobj) }
{ if (!strcmp(evas_object_type_get(sobj), SMART_NAME))
API_ENTRY return; {
sd->subobjs = evas_list_remove(sd->subobjs, sobj); sd = evas_object_smart_data_get(sobj);
if (sd) sd->parent_obj = obj;
}
} }
void void
@ -124,6 +140,238 @@ e_widget_resize_object_set(Evas_Object *obj, Evas_Object *sobj)
_e_smart_reconfigure(sd); _e_smart_reconfigure(sd);
} }
void
e_widget_can_focus_set(Evas_Object *obj, int can_focus)
{
API_ENTRY return;
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_focus_set(Evas_Object *obj, int first)
{
API_ENTRY return;
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_focused_object_clear(Evas_Object *obj)
{
Evas_List *l;
API_ENTRY return;
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 */ /* local subsystem functions */
static void static void
_e_smart_reconfigure(E_Smart_Data *sd) _e_smart_reconfigure(E_Smart_Data *sd)
@ -146,6 +394,7 @@ _e_smart_add(Evas_Object *obj)
sd->y = 0; sd->y = 0;
sd->w = 0; sd->w = 0;
sd->h = 0; sd->h = 0;
sd->can_focus = 1;
evas_object_smart_data_set(obj, sd); evas_object_smart_data_set(obj, sd);
} }
@ -263,4 +512,3 @@ _e_smart_init(void)
_e_smart_show, _e_smart_hide, _e_smart_color_set, _e_smart_show, _e_smart_hide, _e_smart_color_set,
_e_smart_clip_set, _e_smart_clip_unset, NULL); _e_smart_clip_set, _e_smart_clip_unset, NULL);
} }

View File

@ -8,15 +8,25 @@
EAPI Evas_Object *e_widget_add(Evas *evas); 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_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_set(Evas_Object *obj, void *data);
EAPI void *e_widget_data_get(Evas_Object *obj); 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_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_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_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_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
#endif #endif

View File

@ -14,7 +14,10 @@ struct _E_Widget_Data
}; };
static void _e_wid_del_hook(Evas_Object *obj); 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_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 */ /* local subsystem functions */
/* externally accessible functions */ /* externally accessible functions */
@ -28,6 +31,8 @@ e_widget_button_add(Evas *evas, char *label, char *icon, void (*func) (void *dat
obj = e_widget_add(evas); obj = e_widget_add(evas);
e_widget_del_hook_set(obj, _e_wid_del_hook); 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 = calloc(1, sizeof(E_Widget_Data));
wd->func = func; wd->func = func;
wd->data = data; wd->data = data;
@ -43,6 +48,7 @@ e_widget_button_add(Evas *evas, char *label, char *icon, void (*func) (void *dat
evas_object_show(o); evas_object_show(o);
e_widget_sub_object_add(obj, 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); e_widget_resize_object_set(obj, o);
if (icon) if (icon)
@ -73,10 +79,35 @@ _e_wid_del_hook(Evas_Object *obj)
} }
static void 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; 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); 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);
}

View File

@ -6,11 +6,17 @@
typedef struct _E_Widget_Data E_Widget_Data; typedef struct _E_Widget_Data E_Widget_Data;
struct _E_Widget_Data struct _E_Widget_Data
{ {
Evas_Object *o_check;
int *valptr; int *valptr;
}; };
static void _e_wid_del_hook(Evas_Object *obj); 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_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 */ /* local subsystem functions */
/* externally accessible functions */ /* externally accessible functions */
@ -24,11 +30,14 @@ e_widget_check_add(Evas *evas, char *label, int *val)
obj = e_widget_add(evas); obj = e_widget_add(evas);
e_widget_del_hook_set(obj, _e_wid_del_hook); 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 = calloc(1, sizeof(E_Widget_Data));
wd->valptr = val; wd->valptr = val;
e_widget_data_set(obj, wd); e_widget_data_set(obj, wd);
o = edje_object_add(evas); o = edje_object_add(evas);
wd->o_check = o;
e_theme_edje_object_set(o, "base/theme/widgets", e_theme_edje_object_set(o, "base/theme/widgets",
"widgets/check"); "widgets/check");
edje_object_signal_callback_add(o, "toggled", "*", _e_wid_signal_cb1, obj); edje_object_signal_callback_add(o, "toggled", "*", _e_wid_signal_cb1, obj);
@ -42,6 +51,7 @@ e_widget_check_add(Evas *evas, char *label, int *val)
} }
e_widget_sub_object_add(obj, 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); e_widget_resize_object_set(obj, o);
return obj; return obj;
@ -57,14 +67,52 @@ _e_wid_del_hook(Evas_Object *obj)
} }
static void 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; 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_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(obj);
if (wd->valptr) if (wd->valptr)
{ {
if (!strcmp(source, "on")) *(wd->valptr) = 1; if (*(wd->valptr) == 0) *(wd->valptr) = 1;
else *(wd->valptr) = 0; 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);
}

View File

@ -15,7 +15,7 @@ static void _e_wid_del_hook(Evas_Object *obj);
/* externally accessible functions */ /* externally accessible functions */
Evas_Object * Evas_Object *
e_widget_list_add(Evas *evas, int horiz) e_widget_list_add(Evas *evas, int homogenous, int horiz)
{ {
Evas_Object *obj, *o; Evas_Object *obj, *o;
E_Widget_Data *wd; E_Widget_Data *wd;
@ -29,7 +29,7 @@ e_widget_list_add(Evas *evas, int horiz)
o = e_box_add(evas); o = e_box_add(evas);
wd->o_box = o; wd->o_box = o;
e_box_orientation_set(o, horiz); e_box_orientation_set(o, horiz);
e_box_homogenous_set(o, 0); e_box_homogenous_set(o, homogenous);
evas_object_show(o); evas_object_show(o);
e_widget_sub_object_add(obj, o); e_widget_sub_object_add(obj, o);
e_widget_resize_object_set(obj, o); e_widget_resize_object_set(obj, o);

View File

@ -6,7 +6,7 @@
#ifndef E_WIDGET_LIST_H #ifndef E_WIDGET_LIST_H
#define 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); EAPI void e_widget_list_object_append(Evas_Object *obj, Evas_Object *sobj, int fill, int expand, double align);

View File

@ -18,7 +18,11 @@ struct _E_Widget_Data
}; };
static void _e_wid_del_hook(Evas_Object *obj); 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_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 */ /* local subsystem functions */
/* externally accessible functions */ /* externally accessible functions */
@ -42,6 +46,8 @@ e_widget_radio_add(Evas *evas, char *label, int valnum, E_Radio_Group *group)
obj = e_widget_add(evas); obj = e_widget_add(evas);
e_widget_del_hook_set(obj, _e_wid_del_hook); 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 = calloc(1, sizeof(E_Widget_Data));
wd->group = group; wd->group = group;
wd->valnum = valnum; wd->valnum = valnum;
@ -66,6 +72,7 @@ e_widget_radio_add(Evas *evas, char *label, int valnum, E_Radio_Group *group)
} }
e_widget_sub_object_add(obj, 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); e_widget_resize_object_set(obj, o);
return obj; return obj;
@ -86,11 +93,23 @@ _e_wid_del_hook(Evas_Object *obj)
} }
static void 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; 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_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(obj);
if ((wd->group) && (wd->group->valptr)) if ((wd->group) && (wd->group->valptr))
{ {
Evas_List *l; Evas_List *l;
@ -99,7 +118,7 @@ _e_wid_signal_cb1(void *data, Evas_Object *obj, const char *emission, const char
for (l = wd->group->radios; l; l = l->next) for (l = wd->group->radios; l; l = l->next)
{ {
wd = e_widget_data_get(l->data); wd = e_widget_data_get(l->data);
if (l->data != data) if (l->data != obj)
{ {
wd = e_widget_data_get(l->data); wd = e_widget_data_get(l->data);
if (wd->valnum == *(wd->group->valptr)) if (wd->valnum == *(wd->group->valptr))
@ -111,7 +130,29 @@ _e_wid_signal_cb1(void *data, Evas_Object *obj, const char *emission, const char
} }
} }
if (!toggled) return; if (!toggled) return;
wd = e_widget_data_get(data); wd = e_widget_data_get(obj);
if (!strcmp(source, "on")) *(wd->group->valptr) = wd->valnum; *(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);
}