parent
f4f1ad13b4
commit
d2ea9aee5d
20 changed files with 627 additions and 93 deletions
@ -0,0 +1,253 @@ |
||||
images { |
||||
image: "e17_menu_bg.png" COMP; |
||||
image: "e17_winlist_top.png" COMP; |
||||
image: "e17_winlist_bottom.png" COMP; |
||||
image: "e17_button2.png" COMP; |
||||
image: "e17_button.png" COMP; |
||||
} |
||||
|
||||
group { |
||||
name: "widgets/dialog/main"; |
||||
parts { |
||||
part { |
||||
name: "base"; |
||||
mouse_events: 0; |
||||
type: RECT; |
||||
description { |
||||
state: "default" 0.0; |
||||
rel1 { |
||||
relative: 0.0 1.0; |
||||
offset: 1 0; |
||||
to_y: "base2"; |
||||
} |
||||
rel2 { |
||||
relative: 1.0 1.0; |
||||
offset: -2 -2; |
||||
} |
||||
color: 221 221 221 255; |
||||
} |
||||
} |
||||
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 { |
||||
name: "base3"; |
||||
mouse_events: 0; |
||||
description { |
||||
state: "default" 0.0; |
||||
rel1 { |
||||
relative: 0.0 0.0; |
||||
offset: 0 0; |
||||
} |
||||
rel2 { |
||||
relative: 1.0 1.0; |
||||
offset: -1 -1; |
||||
} |
||||
image { |
||||
normal: "e17_menu_bg_border.png"; |
||||
border: 1 1 1 1; |
||||
middle: 0; |
||||
} |
||||
fill { |
||||
smooth: 0; |
||||
} |
||||
} |
||||
} |
||||
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: 16 16; |
||||
} |
||||
rel2 { |
||||
relative: 0.0 0.0; |
||||
offset: 16 -9; |
||||
to_y: "buttons_swallow"; |
||||
} |
||||
} |
||||
} |
||||
part { |
||||
name: "content_swallow"; |
||||
type: SWALLOW; |
||||
description { |
||||
state: "default" 0.0; |
||||
color: 0 0 0 0; |
||||
rel1 { |
||||
relative: 1.0 0.0; |
||||
offset: 8 16; |
||||
to_x: "icon_swallow"; |
||||
} |
||||
rel2 { |
||||
relative: 1.0 0.0; |
||||
offset: -17 -9; |
||||
to_y: "buttons_swallow"; |
||||
} |
||||
} |
||||
} |
||||
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 { |
||||
name: "bottom"; |
||||
mouse_events: 0; |
||||
description { |
||||
state: "default" 0.0; |
||||
rel1 { |
||||
relative: 0.0 1.0; |
||||
offset: 1 -3; |
||||
to_y: "content_swallow"; |
||||
} |
||||
rel2 { |
||||
relative: 1.0 1.0; |
||||
offset: -2 -2; |
||||
} |
||||
image { |
||||
normal: "e17_winlist_bottom.png"; |
||||
border: 0 0 4 0; |
||||
} |
||||
fill { |
||||
smooth: 0; |
||||
} |
||||
} |
||||
} |
||||
part { |
||||
name: "buttons_swallow"; |
||||
type: SWALLOW; |
||||
description { |
||||
state: "default" 0.0; |
||||
color: 0 0 0 0; |
||||
align: 0.5 1.0; |
||||
rel1 { |
||||
relative: 0.0 1.0; |
||||
offset: 16 -9; |
||||
} |
||||
rel2 { |
||||
relative: 1.0 1.0; |
||||
offset: -17 -9; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
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: "button_text"; |
||||
type: TEXT; |
||||
effect: SHADOW; |
||||
mouse_events: 0; |
||||
description { |
||||
state: "default" 0.0; |
||||
rel1 { |
||||
relative: 0.0 0.0; |
||||
offset: 6 6; |
||||
to: "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: 0 0; |
||||
align: 0.5 0.5; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
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"; |
||||
source: "button_image"; |
||||
action: SIGNAL_EMIT "click" ""; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,214 @@ |
||||
/*
|
||||
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 |
||||
*/ |
||||
#include "e.h" |
||||
|
||||
typedef struct _E_Dialog_Button E_Dialog_Button; |
||||
|
||||
struct _E_Dialog_Button |
||||
{ |
||||
E_Dialog *dialog; |
||||
Evas_Object *obj; |
||||
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_cb_delete(E_Win *win); |
||||
|
||||
/* local subsystem globals */ |
||||
|
||||
/* externally accessible functions */ |
||||
|
||||
E_Dialog * |
||||
e_dialog_new(E_Container *con) |
||||
{ |
||||
E_Dialog *dia; |
||||
E_Manager *man; |
||||
Evas_Object *o; |
||||
|
||||
if (!con) |
||||
{ |
||||
man = e_manager_current_get(); |
||||
if (!man) return NULL; |
||||
con = e_container_current_get(man); |
||||
if (!con) con = e_manager_container_number_get(man, 0); |
||||
if (!con) return NULL; |
||||
} |
||||
dia = E_OBJECT_ALLOC(E_Dialog, E_DIALOG_TYPE, _e_dialog_free); |
||||
if (!dia) return NULL; |
||||
dia->win = e_win_new(con); |
||||
if (!dia->win) |
||||
{ |
||||
free(dia); |
||||
return NULL; |
||||
} |
||||
dia->win->data = dia; |
||||
e_win_name_class_set(dia->win, "E", "_dialog"); |
||||
o = edje_object_add(e_win_evas_get(dia->win)); |
||||
dia->bg_object = o; |
||||
e_theme_edje_object_set(o, "base/theme/dialog", |
||||
"widgets/dialog/main"); |
||||
evas_object_move(o, 0, 0); |
||||
evas_object_show(o); |
||||
|
||||
o = evas_object_textblock_add(e_win_evas_get(dia->win)); |
||||
dia->text_object = o; |
||||
edje_object_part_swallow(dia->bg_object, "content_swallow", o); |
||||
evas_object_show(o); |
||||
{ |
||||
char format[1024]; |
||||
char *fname; |
||||
int fsize; |
||||
|
||||
fname = (char *)e_font_default_string_get("default", &fsize); |
||||
snprintf(format, sizeof(format), |
||||
"font='%s' size=%i wrap=word", |
||||
fname, fsize); |
||||
evas_object_textblock_format_insert(o, format); |
||||
evas_object_textblock_format_insert(o, "color=#000"); |
||||
evas_object_textblock_format_insert(o, "\n"); |
||||
evas_object_textblock_text_insert(o, "Here is some text"); |
||||
evas_object_textblock_format_insert(o, "\n"); |
||||
evas_object_textblock_text_insert(o, "Here is some more text"); |
||||
evas_object_textblock_format_insert(o, "\n"); |
||||
evas_object_textblock_text_insert(o, "And even more text on this line to make it really long for testing"); |
||||
evas_object_textblock_format_insert(o, "\n"); |
||||
evas_object_textblock_text_insert(o, "Short"); |
||||
evas_object_textblock_format_insert(o, "\n"); |
||||
evas_object_textblock_text_insert(o, "Aaardvaaarks On!"); |
||||
evas_object_textblock_format_insert(o, "\n"); |
||||
evas_object_textblock_format_insert(o, "\n"); |
||||
} |
||||
|
||||
o = e_box_add(e_win_evas_get(dia->win)); |
||||
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); |
||||
|
||||
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); |
||||
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); |
||||
} |
||||
|
||||
void |
||||
e_dialog_title_set(E_Dialog *dia, char *title) |
||||
{ |
||||
e_win_title_set(dia->win, title); |
||||
} |
||||
|
||||
void |
||||
e_dialog_text_set(E_Dialog *dia, char *text) |
||||
{ |
||||
} |
||||
|
||||
void |
||||
e_dialog_icon_set(E_Dialog *dia, char *icon) |
||||
{ |
||||
} |
||||
|
||||
void |
||||
e_dialog_show(E_Dialog *dia) |
||||
{ |
||||
Evas_Coord mw, mh; |
||||
Evas_Object *o; |
||||
|
||||
o = dia->text_object; |
||||
// evas_object_textblock_format_size_get(o, &mw, &mh);
|
||||
evas_object_textblock_native_size_get(o, &mw, &mh); |
||||
edje_extern_object_min_size_set(o, mw + 2, mh + 2); |
||||
edje_object_part_swallow(dia->bg_object, "content_swallow", o); |
||||
|
||||
o = dia->box_object; |
||||
e_box_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); |
||||
|
||||
edje_object_size_min_calc(dia->bg_object, &mw, &mh); |
||||
evas_object_resize(dia->bg_object, mw, mh); |
||||
e_win_resize(dia->win, mw, mh); |
||||
e_win_size_min_set(dia->win, mw, mh); |
||||
e_win_size_max_set(dia->win, mw, mh); |
||||
e_win_show(dia->win); |
||||
} |
||||
|
||||
/* 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); |
||||
IF_FREE(db->label); |
||||
IF_FREE(db->icon); |
||||
evas_object_del(db->obj); |
||||
free(db); |
||||
} |
||||
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); |
||||
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_Button *db; |
||||
|
||||
db = data; |
||||
if (db->func) |
||||
db->func(db->data, db->dialog); |
||||
else |
||||
e_object_del(E_OBJECT(db->dialog)); |
||||
} |
||||
|
||||
static void |
||||
_e_dialog_cb_delete(E_Win *win) |
||||
{ |
||||
E_Dialog *dia; |
||||
|
||||
dia = win->data; |
||||
e_object_del(E_OBJECT(dia)); |
||||
} |
@ -0,0 +1,35 @@ |
||||
/*
|
||||
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 |
||||
*/ |
||||
#ifdef E_TYPEDEFS |
||||
|
||||
typedef struct _E_Dialog E_Dialog; |
||||
|
||||
#else |
||||
#ifndef E_DIALOG_H |
||||
#define E_DIALOG_H |
||||
|
||||
#define E_DIALOG_TYPE 0xE0b01012 |
||||
|
||||
struct _E_Dialog |
||||
{ |
||||
E_Object e_obj_inherit; |
||||
|
||||
E_Win *win; |
||||
Evas_Object *bg_object; |
||||
Evas_Object *box_object; |
||||
Evas_Object *text_object; |
||||
Evas_Object *icon_object; |
||||
Evas_List *buttons; |
||||
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 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); |
||||
EAPI void e_dialog_show (E_Dialog *dia); |
||||
|
||||
#endif |
||||
#endif |